mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 02:24:05 +09:00
working pen menu
This commit is contained in:
Binary file not shown.
@@ -571,6 +571,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
textureWhiteSquare.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
|
textureWhiteSquare.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
|
||||||
|
|
||||||
textureWhiteCircle = new Texture(Gdx.files.internal("assets/graphics/circle_512.tga"));
|
textureWhiteCircle = new Texture(Gdx.files.internal("assets/graphics/circle_512.tga"));
|
||||||
|
textureWhiteCircle.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
|
||||||
|
|
||||||
TextureRegionPack.Companion.setGlobalFlipY(true);
|
TextureRegionPack.Companion.setGlobalFlipY(true);
|
||||||
fontGame = new GameFontBase("assets/graphics/fonts/terrarum-sans-bitmap", false, true,
|
fontGame = new GameFontBase("assets/graphics/fonts/terrarum-sans-bitmap", false, true,
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package net.torvald.terrarum
|
|||||||
import com.badlogic.gdx.Input
|
import com.badlogic.gdx.Input
|
||||||
import com.google.gson.JsonArray
|
import com.google.gson.JsonArray
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keys must be all lowercase
|
* Keys must be all lowercase
|
||||||
@@ -103,6 +105,25 @@ object DefaultConfig {
|
|||||||
//jsonObject.addProperty("fx3dlut", false)
|
//jsonObject.addProperty("fx3dlut", false)
|
||||||
|
|
||||||
|
|
||||||
|
// settings regarding debugger
|
||||||
|
val buildingMakerFavs = JsonArray()
|
||||||
|
intArrayOf(
|
||||||
|
Block.GLASS_CRUDE,
|
||||||
|
Block.PLANK_NORMAL,
|
||||||
|
Block.PLANK_BIRCH,
|
||||||
|
Block.STONE_QUARRIED,
|
||||||
|
Block.STONE_BRICKS,
|
||||||
|
|
||||||
|
Block.STONE_TILE_WHITE,
|
||||||
|
Block.TORCH,
|
||||||
|
Block.PLANK_NORMAL + BlockCodex.MAX_TERRAIN_TILES,
|
||||||
|
Block.PLANK_BIRCH + BlockCodex.MAX_TERRAIN_TILES,
|
||||||
|
Block.GLASS_CRUDE + BlockCodex.MAX_TERRAIN_TILES).forEach {
|
||||||
|
buildingMakerFavs.add(it)
|
||||||
|
}
|
||||||
|
jsonObject.add("buildingmakerfavs", buildingMakerFavs)
|
||||||
|
|
||||||
|
|
||||||
return jsonObject
|
return jsonObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -682,6 +682,8 @@ fun Float.sqrt() = FastMath.sqrt(this)
|
|||||||
fun Int.abs() = this.absoluteValue
|
fun Int.abs() = this.absoluteValue
|
||||||
fun Double.bipolarClamp(limit: Double) =
|
fun Double.bipolarClamp(limit: Double) =
|
||||||
this.coerceIn(-limit, limit)
|
this.coerceIn(-limit, limit)
|
||||||
|
fun Boolean.toInt() = if (this) 1 else 0
|
||||||
|
|
||||||
|
|
||||||
fun absMax(left: Double, right: Double): Double {
|
fun absMax(left: Double, right: Double): Double {
|
||||||
if (left > 0 && right > 0)
|
if (left > 0 && right > 0)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package net.torvald.terrarum.gameactors.ai
|
package net.torvald.terrarum.gameactors.ai
|
||||||
|
|
||||||
import org.luaj.vm2.*
|
import org.luaj.vm2.LuaValue
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-10-24.
|
* Created by minjaesong on 2016-10-24.
|
||||||
@@ -387,5 +387,4 @@ fun Int.toLua() = LuaValue.valueOf(this)
|
|||||||
fun String.toLua() = LuaValue.valueOf(this)
|
fun String.toLua() = LuaValue.valueOf(this)
|
||||||
fun Double?.toLua() = if (this == null) LuaValue.NIL else this.toLua()
|
fun Double?.toLua() = if (this == null) LuaValue.NIL else this.toLua()
|
||||||
fun Int?.toLua() = if (this == null) LuaValue.NIL else this.toLua()
|
fun Int?.toLua() = if (this == null) LuaValue.NIL else this.toLua()
|
||||||
fun String?.toLua() = if (this == null) LuaValue.NIL else this.toLua()
|
fun String?.toLua() = if (this == null) LuaValue.NIL else this.toLua()
|
||||||
fun Boolean.toInt() = if (this) 1 else 0
|
|
||||||
@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
|||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
|
import net.torvald.terrarum.blockproperties.BlockPropUtil
|
||||||
import net.torvald.terrarum.gameactors.*
|
import net.torvald.terrarum.gameactors.*
|
||||||
import net.torvald.terrarum.itemproperties.ItemID
|
import net.torvald.terrarum.itemproperties.ItemID
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||||
@@ -267,6 +268,8 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
// actually open
|
// actually open
|
||||||
uiPenMenu.setAsOpen()
|
uiPenMenu.setAsOpen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BlockPropUtil.dynamicLumFuncTickClock()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderGame() {
|
private fun renderGame() {
|
||||||
@@ -284,6 +287,8 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
fun setPencilColour(itemID: ItemID) {
|
fun setPencilColour(itemID: ItemID) {
|
||||||
uiPaletteSelector.fore = itemID
|
uiPaletteSelector.fore = itemID
|
||||||
|
currentPenMode = PENMODE_PENCIL
|
||||||
|
currentPenTarget = PENTARGET_TERRAIN // TERRAIN is arbitrary chosen to prevent possible conflict; for the pencil itself this property does nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import com.badlogic.gdx.graphics.Camera
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory
|
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
|
import net.torvald.terrarum.ui.UIItemImageButton
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
|
|
||||||
@@ -17,20 +19,20 @@ import org.dyn4j.geometry.Vector2
|
|||||||
class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val SIZE = 400
|
const val SIZE = 330
|
||||||
const val RADIUS = SIZE / 2.0
|
const val RADIUS = SIZE / 2.0
|
||||||
const val RADIUSF = RADIUS.toFloat()
|
const val RADIUSF = RADIUS.toFloat()
|
||||||
|
|
||||||
const val BLOCKS_ROW_RADIUS = 150.0
|
const val BLOCKS_ROW_RADIUS = 120.0
|
||||||
const val TOOLS_ROW_RADIUS = 72.0
|
const val TOOLS_ROW_RADIUS = 56.0
|
||||||
|
|
||||||
const val BLOCK_BACK_SIZE = 72
|
const val BLOCK_BACK_SIZE = 72
|
||||||
const val BLOCK_BACK_RADIUS = BLOCK_BACK_SIZE / 2f
|
const val BLOCK_BACK_RADIUS = BLOCK_BACK_SIZE / 2f
|
||||||
|
|
||||||
const val ICON_SIZE = 38
|
const val ICON_SIZE = 38
|
||||||
const val ICON_SIZEH = ICON_SIZE / 2f
|
const val ICON_SIZEH = ICON_SIZE / 2f
|
||||||
const val ICON_HITBOX_SIZE = 52
|
const val CLOSE_BUTTON_SIZE = 48
|
||||||
const val ICON_HITBOX_RADIUS = ICON_HITBOX_SIZE / 2f
|
const val CLOSE_BUTTON_RADIUS = CLOSE_BUTTON_SIZE / 2f
|
||||||
|
|
||||||
const val PALETTE_SIZE = 10
|
const val PALETTE_SIZE = 10
|
||||||
const val TOOLS_SIZE = 5
|
const val TOOLS_SIZE = 5
|
||||||
@@ -40,16 +42,46 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
|||||||
private val blockCellCol = ItemSlotImageFactory.CELLCOLOUR_WHITE
|
private val blockCellCol = ItemSlotImageFactory.CELLCOLOUR_WHITE
|
||||||
/** Centre pos. */
|
/** Centre pos. */
|
||||||
private val blockCellPos = Array<Vector2>(PALETTE_SIZE) {
|
private val blockCellPos = Array<Vector2>(PALETTE_SIZE) {
|
||||||
val newvec = Vector2(0.0, 0.0 - BLOCKS_ROW_RADIUS)
|
Vector2(0.0, 0.0 - BLOCKS_ROW_RADIUS)
|
||||||
newvec.rotate(Math.PI / 5.0 * it).plus(Vector2(RADIUS, RADIUS))
|
.rotate(Math.PI / 5.0 * it)
|
||||||
|
.plus(Vector2(RADIUS, RADIUS))
|
||||||
}
|
}
|
||||||
/** Centre pos. */
|
private val toolIcons = TextureRegionPack(ModMgr.getGdxFile("basegame", "gui/buildingmaker/penmenu_icons.tga"), 38, 38)
|
||||||
private val toolsPos = Array<Vector2>(TOOLS_SIZE) {
|
private val toolButtons = Array<UIItemImageButton>(TOOLS_SIZE) {
|
||||||
val newvec = Vector2(TOOLS_ROW_RADIUS, 0.0)
|
val newvec = Vector2(TOOLS_ROW_RADIUS, 0.0)
|
||||||
newvec.rotate(Math.PI / 2.5 * it).plus(Vector2(RADIUS, RADIUS))
|
.rotate(Math.PI / 2.5 * it)
|
||||||
}
|
.plus(Vector2(RADIUS - ICON_SIZEH, RADIUS - ICON_SIZEH))
|
||||||
|
|
||||||
private val menuIcons = TextureRegionPack(ModMgr.getGdxFile("basegame", "gui/buildingmaker/penmenu_icons.tga"), 38, 38)
|
UIItemImageButton(
|
||||||
|
this, toolIcons.get(it, 0),
|
||||||
|
backgroundCol = Color(0),
|
||||||
|
highlightBackCol = Color(0),
|
||||||
|
activeBackCol = Color(0),
|
||||||
|
posX = newvec.x.roundInt(),
|
||||||
|
posY = newvec.y.roundInt(),
|
||||||
|
width = ICON_SIZE, height = ICON_SIZE,
|
||||||
|
highlightable = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
private val toolButtonsJob = arrayOf(
|
||||||
|
{ parent.currentPenMode = BuildingMaker.PENMODE_MARQUEE },
|
||||||
|
{ parent.currentPenMode = BuildingMaker.PENMODE_MARQUEE_ERASE },
|
||||||
|
{
|
||||||
|
parent.uiPalette.isVisible = true
|
||||||
|
parent.uiPalette.setPosition(Gdx.input.x - parent.uiPalette.width / 2, Gdx.input.y - parent.uiPalette.height / 2)
|
||||||
|
parent.uiPalette.posX = parent.uiPalette.posX.coerceIn(0, Terrarum.WIDTH - parent.uiPalette.width)
|
||||||
|
parent.uiPalette.posY = parent.uiPalette.posY.coerceIn(0, Terrarum.HEIGHT - parent.uiPalette.height)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
parent.currentPenMode = BuildingMaker.PENMODE_PENCIL_ERASE
|
||||||
|
parent.currentPenTarget = BuildingMaker.PENTARGET_TERRAIN
|
||||||
|
},
|
||||||
|
{
|
||||||
|
parent.currentPenMode = BuildingMaker.PENMODE_PENCIL_ERASE
|
||||||
|
parent.currentPenTarget = BuildingMaker.PENTARGET_WALL
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
override var width = SIZE
|
override var width = SIZE
|
||||||
override var height = SIZE
|
override var height = SIZE
|
||||||
@@ -57,10 +89,43 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
|||||||
|
|
||||||
private var mouseVec = Vector2(0.0, 0.0)
|
private var mouseVec = Vector2(0.0, 0.0)
|
||||||
|
|
||||||
|
private var mouseOnCloseButton = false
|
||||||
|
private var mouseOnBlocksSlot: Int? = null
|
||||||
|
|
||||||
|
init {
|
||||||
|
// make toolbox work
|
||||||
|
toolButtons.forEachIndexed { index, button ->
|
||||||
|
uiItems.add(button)
|
||||||
|
|
||||||
|
button.clickOnceListener = { _, _, b ->
|
||||||
|
if (b == AppLoader.getConfigInt("mouseprimary")) {
|
||||||
|
toolButtonsJob[index].invoke()
|
||||||
|
closeGracefully()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun updateUI(delta: Float) {
|
override fun updateUI(delta: Float) {
|
||||||
mouseVec.x = relativeMouseX.toDouble()
|
mouseVec.x = relativeMouseX.toDouble()
|
||||||
mouseVec.y = relativeMouseY.toDouble()
|
mouseVec.y = relativeMouseY.toDouble()
|
||||||
|
|
||||||
|
toolButtons.forEach { it.update(delta) }
|
||||||
|
|
||||||
|
// determine if cursor is above shits
|
||||||
|
mouseOnCloseButton = (mouseVec.distanceSquared(RADIUS, RADIUS) <= CLOSE_BUTTON_RADIUS.sqr())
|
||||||
|
// --> blocks slot
|
||||||
|
for (i in 0 until PALETTE_SIZE) {
|
||||||
|
val posVec = blockCellPos[i]
|
||||||
|
if (mouseVec.distanceSquared(posVec) <= BLOCK_BACK_RADIUS.sqr()) {
|
||||||
|
mouseOnBlocksSlot = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
mouseOnBlocksSlot = null
|
||||||
|
// actually selecting the slot is handled by renderUI()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) {
|
if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) {
|
||||||
this.isVisible = false
|
this.isVisible = false
|
||||||
parent.tappedOnUI = false
|
parent.tappedOnUI = false
|
||||||
@@ -69,36 +134,50 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
|||||||
// primary click
|
// primary click
|
||||||
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary"))) {
|
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary"))) {
|
||||||
// close by clicking close button or out-of-boud
|
// close by clicking close button or out-of-boud
|
||||||
if (mouseVec.distanceSquared(RADIUS, RADIUS) !in ICON_HITBOX_RADIUS.sqr()..RADIUSF.sqr()) {
|
if (mouseVec.distanceSquared(RADIUS, RADIUS) !in CLOSE_BUTTON_RADIUS.sqr()..RADIUSF.sqr()) {
|
||||||
this.isVisible = false
|
closeGracefully()
|
||||||
parent.tappedOnUI = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun closeGracefully() {
|
||||||
|
this.isVisible = false
|
||||||
|
parent.tappedOnUI = true
|
||||||
|
}
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
// draw back
|
// draw back
|
||||||
batch.color = backCol
|
batch.color = backCol
|
||||||
batch.fillCircle(0f, 0f, SIZE.toFloat(), SIZE.toFloat())
|
batch.fillCircle(0f, 0f, SIZE.toFloat(), SIZE.toFloat())
|
||||||
|
|
||||||
// draw fore
|
// draw blocks slot
|
||||||
batch.color = blockCellCol
|
batch.color = blockCellCol
|
||||||
|
val slotConfig = AppLoader.getConfigIntArray("buildingmakerfavs")
|
||||||
for (i in 0 until PALETTE_SIZE) {
|
for (i in 0 until PALETTE_SIZE) {
|
||||||
val x = blockCellPos[i].x.roundInt().toFloat() - BLOCK_BACK_RADIUS
|
val x = blockCellPos[i].x.roundInt().toFloat()
|
||||||
val y = blockCellPos[i].y.roundInt().toFloat() - BLOCK_BACK_RADIUS
|
val y = blockCellPos[i].y.roundInt().toFloat()
|
||||||
batch.fillCircle(x, y, BLOCK_BACK_SIZE.toFloat(), BLOCK_BACK_SIZE.toFloat())
|
batch.color = blockCellCol
|
||||||
|
repeat((i == mouseOnBlocksSlot).toInt() + 1) { batch.fillCircle(x - BLOCK_BACK_RADIUS, y - BLOCK_BACK_RADIUS, BLOCK_BACK_SIZE.toFloat(), BLOCK_BACK_SIZE.toFloat()) }
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
batch.draw(ItemCodex.getItemImage(slotConfig[i]), x - 16, y - 16, 32f, 32f)
|
||||||
|
|
||||||
|
// update as well while looping
|
||||||
|
if (i == mouseOnBlocksSlot && Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary"))) {
|
||||||
|
parent.setPencilColour(slotConfig[i])
|
||||||
|
closeGracefully()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw close button
|
// draw close button
|
||||||
batch.fillCircle(RADIUSF - ICON_HITBOX_RADIUS, RADIUSF - ICON_HITBOX_RADIUS, ICON_HITBOX_SIZE.toFloat(), ICON_HITBOX_SIZE.toFloat())
|
batch.color = blockCellCol
|
||||||
|
repeat(mouseOnCloseButton.toInt() + 1) { batch.fillCircle(RADIUSF - CLOSE_BUTTON_RADIUS, RADIUSF - CLOSE_BUTTON_RADIUS, CLOSE_BUTTON_SIZE.toFloat(), CLOSE_BUTTON_SIZE.toFloat()) }
|
||||||
|
|
||||||
|
batch.color = if (mouseOnCloseButton) toolButtons[0].activeCol else toolButtons[0].inactiveCol
|
||||||
|
batch.draw(toolIcons.get(5, 0), RADIUSF - ICON_SIZEH, RADIUSF - ICON_SIZEH)
|
||||||
|
|
||||||
// draw icons
|
// draw icons
|
||||||
batch.color = Color.WHITE
|
toolButtons.forEach {
|
||||||
batch.draw(menuIcons.get(5, 0), RADIUSF - ICON_SIZEH, RADIUSF - ICON_SIZEH)
|
it.render(batch, camera)
|
||||||
for (i in 0 until TOOLS_SIZE) {
|
|
||||||
val x = toolsPos[i].x.roundInt().toFloat() - ICON_SIZEH
|
|
||||||
val y = toolsPos[i].y.roundInt().toFloat() - ICON_SIZEH
|
|
||||||
batch.draw(menuIcons.get(i, 0), x, y)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +194,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
menuIcons.dispose()
|
toolIcons.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,9 +4,9 @@ import com.badlogic.gdx.Gdx
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.terrarum.gameactors.ai.toInt
|
|
||||||
import net.torvald.terrarum.itemproperties.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
|
import net.torvald.terrarum.toInt
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,19 @@ open class UIItemImageButton(
|
|||||||
parent: UICanvas,
|
parent: UICanvas,
|
||||||
val image: TextureRegion,
|
val image: TextureRegion,
|
||||||
|
|
||||||
|
/** Colour when mouse is over */
|
||||||
val activeCol: Color = UIItemTextButton.defaultActiveCol,
|
val activeCol: Color = UIItemTextButton.defaultActiveCol,
|
||||||
|
/** Colour when mouse is over */
|
||||||
val activeBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_ACTIVECOL,
|
val activeBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_ACTIVECOL,
|
||||||
|
/** Colour when mouse is over */
|
||||||
val activeBackBlendMode: String = BlendMode.NORMAL,
|
val activeBackBlendMode: String = BlendMode.NORMAL,
|
||||||
|
/** Colour when clicked/selected */
|
||||||
val highlightCol: Color = UIItemTextButton.defaultHighlightCol,
|
val highlightCol: Color = UIItemTextButton.defaultHighlightCol,
|
||||||
|
/** Colour when clicked/selected */
|
||||||
val highlightBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_HIGHLIGHTCOL,
|
val highlightBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_HIGHLIGHTCOL,
|
||||||
|
/** Colour when clicked/selected */
|
||||||
val highlightBackBlendMode: String = BlendMode.NORMAL,
|
val highlightBackBlendMode: String = BlendMode.NORMAL,
|
||||||
|
/** Colour on normal status */
|
||||||
val inactiveCol: Color = UIItemTextButton.defaultInactiveCol,
|
val inactiveCol: Color = UIItemTextButton.defaultInactiveCol,
|
||||||
val backgroundCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUNDCOL,
|
val backgroundCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUNDCOL,
|
||||||
val backgroundBlendMode: String = BlendMode.NORMAL,
|
val backgroundBlendMode: String = BlendMode.NORMAL,
|
||||||
@@ -30,6 +37,7 @@ open class UIItemImageButton(
|
|||||||
override val width: Int = image.regionWidth,
|
override val width: Int = image.regionWidth,
|
||||||
override val height: Int = image.regionHeight,
|
override val height: Int = image.regionHeight,
|
||||||
|
|
||||||
|
/** When clicked, toggle its "lit" status */
|
||||||
var highlightable: Boolean
|
var highlightable: Boolean
|
||||||
) : UIItem(parent) {
|
) : UIItem(parent) {
|
||||||
|
|
||||||
@@ -89,7 +97,7 @@ open class UIItemImageButton(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
if (mouseUp) {
|
if (mouseUp && highlightable) {
|
||||||
highlighted = !highlighted
|
highlighted = !highlighted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,16 +23,24 @@ open class UIItemTextButton(
|
|||||||
override val width: Int,
|
override val width: Int,
|
||||||
val readFromLang: Boolean = false,
|
val readFromLang: Boolean = false,
|
||||||
|
|
||||||
val activeCol: Color = defaultActiveCol,
|
/** Colour when mouse is over */
|
||||||
|
val activeCol: Color = UIItemTextButton.defaultActiveCol,
|
||||||
|
/** Colour when mouse is over */
|
||||||
val activeBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_ACTIVECOL,
|
val activeBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_ACTIVECOL,
|
||||||
|
/** Colour when mouse is over */
|
||||||
val activeBackBlendMode: String = BlendMode.NORMAL,
|
val activeBackBlendMode: String = BlendMode.NORMAL,
|
||||||
|
/** Colour when clicked/selected */
|
||||||
val highlightCol: Color = UIItemTextButton.defaultHighlightCol,
|
val highlightCol: Color = UIItemTextButton.defaultHighlightCol,
|
||||||
|
/** Colour when clicked/selected */
|
||||||
val highlightBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_HIGHLIGHTCOL,
|
val highlightBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_HIGHLIGHTCOL,
|
||||||
|
/** Colour when clicked/selected */
|
||||||
val highlightBackBlendMode: String = BlendMode.NORMAL,
|
val highlightBackBlendMode: String = BlendMode.NORMAL,
|
||||||
|
/** Colour on normal status */
|
||||||
val inactiveCol: Color = UIItemTextButton.defaultInactiveCol,
|
val inactiveCol: Color = UIItemTextButton.defaultInactiveCol,
|
||||||
val backgroundCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUNDCOL,
|
val backgroundCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUNDCOL,
|
||||||
val backgroundBlendMode: String = BlendMode.NORMAL,
|
val backgroundBlendMode: String = BlendMode.NORMAL,
|
||||||
|
|
||||||
|
|
||||||
val preGapX: Int = 0,
|
val preGapX: Int = 0,
|
||||||
val postGapX: Int = 0,
|
val postGapX: Int = 0,
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,7 @@ package net.torvald.terrarum.ui
|
|||||||
import com.badlogic.gdx.graphics.Camera
|
import com.badlogic.gdx.graphics.Camera
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.BlendMode
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.Second
|
|
||||||
import net.torvald.terrarum.fillRect
|
|
||||||
import net.torvald.terrarum.gameactors.ai.toInt
|
|
||||||
import net.torvald.terrarum.roundInt
|
|
||||||
import net.torvald.terrarum.ui.UIItemTextButton.Companion.defaultActiveCol
|
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,16 +26,24 @@ class UIItemTextButtonList(
|
|||||||
val iconCol: Color = UIItemTextButton.defaultInactiveCol,
|
val iconCol: Color = UIItemTextButton.defaultInactiveCol,
|
||||||
|
|
||||||
// copied directly from UIItemTextButton
|
// copied directly from UIItemTextButton
|
||||||
val activeCol: Color = defaultActiveCol,
|
/** Colour when mouse is over */
|
||||||
val activeBackCol: Color = DEFAULT_BACKGROUND_ACTIVECOL,
|
val activeCol: Color = UIItemTextButton.defaultActiveCol,
|
||||||
|
/** Colour when mouse is over */
|
||||||
|
val activeBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_ACTIVECOL,
|
||||||
|
/** Colour when mouse is over */
|
||||||
val activeBackBlendMode: String = BlendMode.NORMAL,
|
val activeBackBlendMode: String = BlendMode.NORMAL,
|
||||||
|
/** Colour when clicked/selected */
|
||||||
val highlightCol: Color = UIItemTextButton.defaultHighlightCol,
|
val highlightCol: Color = UIItemTextButton.defaultHighlightCol,
|
||||||
val highlightBackCol: Color = DEFAULT_BACKGROUND_HIGHLIGHTCOL,
|
/** Colour when clicked/selected */
|
||||||
|
val highlightBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_HIGHLIGHTCOL,
|
||||||
|
/** Colour when clicked/selected */
|
||||||
val highlightBackBlendMode: String = BlendMode.NORMAL,
|
val highlightBackBlendMode: String = BlendMode.NORMAL,
|
||||||
|
/** Colour on normal status */
|
||||||
val inactiveCol: Color = UIItemTextButton.defaultInactiveCol,
|
val inactiveCol: Color = UIItemTextButton.defaultInactiveCol,
|
||||||
val backgroundCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUNDCOL,
|
val backgroundCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUNDCOL,
|
||||||
val backgroundBlendMode: String = BlendMode.NORMAL,
|
val backgroundBlendMode: String = BlendMode.NORMAL,
|
||||||
|
|
||||||
|
|
||||||
val kinematic: Boolean = false,
|
val kinematic: Boolean = false,
|
||||||
|
|
||||||
val alignment: UIItemTextButton.Companion.Alignment = UIItemTextButton.Companion.Alignment.CENTRE,
|
val alignment: UIItemTextButton.Companion.Alignment = UIItemTextButton.Companion.Alignment.CENTRE,
|
||||||
|
|||||||
Reference in New Issue
Block a user