mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
uiitem and template refactoring; new smelter ui wip
This commit is contained in:
@@ -55,5 +55,11 @@
|
|||||||
"ingredients": [
|
"ingredients": [
|
||||||
[1, 6, "basegame:51"]
|
[1, 6, "basegame:51"]
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"item@basegame:6": { /* storage chest */
|
||||||
|
"workbench": "basiccrafting",
|
||||||
|
"ingredients": [
|
||||||
|
[1, 20, "$WOOD"] /* 1 chest = 20 wood */
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
assets/mods/basegame/gui/smelter_icons.tga
LFS
Normal file
BIN
assets/mods/basegame/gui/smelter_icons.tga
LFS
Normal file
Binary file not shown.
@@ -14,6 +14,7 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
|||||||
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UICrafting
|
import net.torvald.terrarum.modulebasegame.ui.UICrafting
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UISmelterBasic
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,7 +29,7 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
|||||||
constructor() : super(
|
constructor() : super(
|
||||||
BlockBox(BlockBox.NO_COLLISION, 3, 4), // temporary value, will be overwritten by spawn()
|
BlockBox(BlockBox.NO_COLLISION, 3, 4), // temporary value, will be overwritten by spawn()
|
||||||
nameFun = { Lang["ITEM_SMELTER_SMALL"] },
|
nameFun = { Lang["ITEM_SMELTER_SMALL"] },
|
||||||
mainUI = UICrafting(null)
|
mainUI = UISmelterBasic()
|
||||||
) {
|
) {
|
||||||
CommonResourcePool.addToLoadingList("particles-tiki_smoke.tga") {
|
CommonResourcePool.addToLoadingList("particles-tiki_smoke.tga") {
|
||||||
TextureRegionPack(ModMgr.getGdxFile("basegame", "particles/bigger_smoke.tga"), 16, 16)
|
TextureRegionPack(ModMgr.getGdxFile("basegame", "particles/bigger_smoke.tga"), 16, 16)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.CraftingStation
|
|||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UITemplateHalfInventory.Companion.INVENTORY_NAME_TEXT_GAP
|
||||||
import net.torvald.terrarum.ui.*
|
import net.torvald.terrarum.ui.*
|
||||||
import net.torvald.terrarum.ui.UIItemCatBar.Companion.FILTER_CAT_ALL
|
import net.torvald.terrarum.ui.UIItemCatBar.Companion.FILTER_CAT_ALL
|
||||||
import net.torvald.unicode.getKeycapPC
|
import net.torvald.unicode.getKeycapPC
|
||||||
@@ -30,7 +31,7 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
|
|||||||
toggleButtonLiteral = if (full == null) "control_gamepad_start" else null
|
toggleButtonLiteral = if (full == null) "control_gamepad_start" else null
|
||||||
), HasInventory {
|
), HasInventory {
|
||||||
|
|
||||||
override var width = App.scr.width
|
override var width = Toolkit.drawWidth
|
||||||
override var height = App.scr.height
|
override var height = App.scr.height
|
||||||
|
|
||||||
private val playerThings = UITemplateHalfInventory(this, false).also {
|
private val playerThings = UITemplateHalfInventory(this, false).also {
|
||||||
@@ -82,7 +83,6 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
|
|||||||
|
|
||||||
override fun getNegotiator() = negotiator
|
override fun getNegotiator() = negotiator
|
||||||
override fun getFixtureInventory(): FixtureInventory = craftables
|
override fun getFixtureInventory(): FixtureInventory = craftables
|
||||||
|
|
||||||
override fun getPlayerInventory(): FixtureInventory = INGAME.actorNowPlaying!!.inventory
|
override fun getPlayerInventory(): FixtureInventory = INGAME.actorNowPlaying!!.inventory
|
||||||
|
|
||||||
private val halfSlotOffset = (UIItemInventoryElemSimple.height + listGap) / 2
|
private val halfSlotOffset = (UIItemInventoryElemSimple.height + listGap) / 2
|
||||||
@@ -93,7 +93,6 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
|
|||||||
private val thisOffsetY = UIInventoryFull.INVENTORY_CELLS_OFFSET_Y()
|
private val thisOffsetY = UIInventoryFull.INVENTORY_CELLS_OFFSET_Y()
|
||||||
private val cellsWidth = (listGap + UIItemInventoryElemWide.height) * 6 - listGap
|
private val cellsWidth = (listGap + UIItemInventoryElemWide.height) * 6 - listGap
|
||||||
|
|
||||||
private val TEXT_GAP = 26
|
|
||||||
private val LAST_LINE_IN_GRID = ((UIItemInventoryElemWide.height + listGap) * (UIInventoryFull.CELLS_VRT - 2)) + 22//359 // TEMPORARY VALUE!
|
private val LAST_LINE_IN_GRID = ((UIItemInventoryElemWide.height + listGap) * (UIInventoryFull.CELLS_VRT - 2)) + 22//359 // TEMPORARY VALUE!
|
||||||
|
|
||||||
private var recipeClicked: CraftingCodex.CraftingRecipe? = null
|
private var recipeClicked: CraftingCodex.CraftingRecipe? = null
|
||||||
@@ -443,11 +442,9 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
|
|||||||
// text label for two inventory grids
|
// text label for two inventory grids
|
||||||
val craftingLabel = Lang["GAME_CRAFTING"]
|
val craftingLabel = Lang["GAME_CRAFTING"]
|
||||||
val ingredientsLabel = Lang["GAME_INVENTORY_INGREDIENTS"]
|
val ingredientsLabel = Lang["GAME_INVENTORY_INGREDIENTS"]
|
||||||
val playerName = INGAME.actorNowPlaying!!.actorValue.getAsString(AVKey.NAME).orEmpty().let { it.ifBlank { Lang["GAME_INVENTORY"] } }
|
|
||||||
|
|
||||||
App.fontGame.draw(batch, craftingLabel, thisOffsetX + (cellsWidth - App.fontGame.getWidth(craftingLabel)) / 2, thisOffsetY - TEXT_GAP)
|
App.fontGame.draw(batch, craftingLabel, thisOffsetX + (cellsWidth - App.fontGame.getWidth(craftingLabel)) / 2, thisOffsetY - INVENTORY_NAME_TEXT_GAP)
|
||||||
App.fontGame.draw(batch, ingredientsLabel, thisOffsetX + (cellsWidth - App.fontGame.getWidth(ingredientsLabel)) / 2, thisOffsetY + LAST_LINE_IN_GRID - TEXT_GAP)
|
App.fontGame.draw(batch, ingredientsLabel, thisOffsetX + (cellsWidth - App.fontGame.getWidth(ingredientsLabel)) / 2, thisOffsetY + LAST_LINE_IN_GRID - INVENTORY_NAME_TEXT_GAP)
|
||||||
App.fontGame.draw(batch, playerName, thisOffsetX2 + (cellsWidth - App.fontGame.getWidth(playerName)) / 2, thisOffsetY - TEXT_GAP)
|
|
||||||
|
|
||||||
|
|
||||||
// control hints
|
// control hints
|
||||||
@@ -456,11 +453,11 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
|
|||||||
App.fontGame.draw(batch, controlHelp, controlHintXPos, UIInventoryFull.yEnd - 20)
|
App.fontGame.draw(batch, controlHelp, controlHintXPos, UIInventoryFull.yEnd - 20)
|
||||||
|
|
||||||
|
|
||||||
if (full != null) {
|
if (INGAME.actorNowPlaying != null) {
|
||||||
//draw player encumb
|
//draw player encumb
|
||||||
val encumbBarXPos = thisXend - UIInventoryCells.weightBarWidth + 36
|
val encumbBarXPos = thisXend - UIInventoryCells.weightBarWidth + 36
|
||||||
val encumbBarYPos = UIInventoryFull.yEnd - 20 + 3f
|
val encumbBarYPos = UIInventoryFull.yEnd - 20 + 3f
|
||||||
UIInventoryCells.drawEncumbranceBar(batch, encumbBarXPos, encumbBarYPos, encumbrancePerc, full.actor.inventory)
|
UIInventoryCells.drawEncumbranceBar(batch, encumbBarXPos, encumbBarYPos, encumbrancePerc, INGAME.actorNowPlaying!!.inventory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,19 +44,19 @@ class UIItemInventoryEquippedView(
|
|||||||
|
|
||||||
private val equipPosIcon = CommonResourcePool.getAsTextureRegionPack("inventory_category")
|
private val equipPosIcon = CommonResourcePool.getAsTextureRegionPack("inventory_category")
|
||||||
private val cellToIcon = intArrayOf(0,1,2,3,4,5,6,7,6,7,6,7)
|
private val cellToIcon = intArrayOf(0,1,2,3,4,5,6,7,6,7,6,7)
|
||||||
private val equipPosIconCol = Color(0xdddddd7f.toInt())
|
|
||||||
|
|
||||||
private val itemGrid = Array<UIItemInventoryCellBase>(2 * 6) {
|
private val itemGrid = Array<UIItemInventoryCellBase>(2 * 6) {
|
||||||
UIItemInventoryElemSimple(
|
UIItemInventoryElemSimple(
|
||||||
parentUI = parentUI,
|
parentUI = parentUI,
|
||||||
initialX = this.posX + (UIItemInventoryElemSimple.height + listGap) * ((it + 4) % 2),
|
initialX = this.posX + (UIItemInventoryElemSimple.height + listGap) * ((it + 4) % 2),
|
||||||
initialY = this.posY + (UIItemInventoryElemSimple.height + listGap) * ((it + 4) / 2),
|
initialY = this.posY + (UIItemInventoryElemSimple.height + listGap) * ((it + 4) / 2),
|
||||||
item = null,
|
item = null,
|
||||||
amount = UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
amount = UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
||||||
itemImage = null,
|
itemImage = null,
|
||||||
drawBackOnNull = true,
|
drawBackOnNull = true,
|
||||||
keyDownFun = createInvCellGenericKeyDownFun(),
|
keyDownFun = createInvCellGenericKeyDownFun(),
|
||||||
touchDownFun = createInvCellGenericTouchDownFun(inventoryListRebuildFun) // to "unselect" the equipped item and main item grid would "untick" accordingly
|
touchDownFun = createInvCellGenericTouchDownFun(inventoryListRebuildFun), // to "unselect" the equipped item and main item grid would "untick" accordingly
|
||||||
|
emptyCellIcon = equipPosIcon.get(cellToIcon[it], 1)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,10 +107,6 @@ class UIItemInventoryEquippedView(
|
|||||||
// slot image on each cells
|
// slot image on each cells
|
||||||
itemGrid.forEachIndexed { index, cell ->
|
itemGrid.forEachIndexed { index, cell ->
|
||||||
cell.render(frameDelta, batch, camera)
|
cell.render(frameDelta, batch, camera)
|
||||||
if (cell.item == null) {
|
|
||||||
batch.color = equipPosIconCol
|
|
||||||
batch.draw(equipPosIcon.get(cellToIcon[index], 1), 15f + cell.posX, 15f + cell.posY)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
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.gameactors.AVKey
|
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
||||||
import net.torvald.terrarum.modulebasegame.gameitems.ItemFileRef
|
import net.torvald.terrarum.modulebasegame.gameitems.ItemFileRef
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.defaultInventoryCellTheme
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.defaultInventoryCellTheme
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIJukebox.Companion.SLOT_SIZE
|
import net.torvald.terrarum.modulebasegame.ui.UIJukebox.Companion.SLOT_SIZE
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UITemplateHalfInventory.Companion.INVENTORY_NAME_TEXT_GAP
|
||||||
import net.torvald.terrarum.ui.*
|
import net.torvald.terrarum.ui.*
|
||||||
import net.torvald.terrarum.ui.UIItemInventoryElemWide
|
import net.torvald.terrarum.ui.UIItemInventoryElemWide
|
||||||
import net.torvald.unicode.EMDASH
|
import net.torvald.unicode.EMDASH
|
||||||
@@ -117,13 +117,8 @@ class UIJukeboxInventory(val parent: UIJukebox) : UICanvas() {
|
|||||||
uiItems.forEach { it.render(frameDelta, batch, camera) }
|
uiItems.forEach { it.render(frameDelta, batch, camera) }
|
||||||
|
|
||||||
// chest name text
|
// chest name text
|
||||||
val chestName = Lang["ITEM_JUKEBOX"]
|
|
||||||
val playerName = INGAME.actorNowPlaying!!.actorValue.getAsString(AVKey.NAME).orEmpty().let { it.ifBlank { Lang["GAME_INVENTORY"] } }
|
|
||||||
|
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
App.fontGame.draw(batch, chestName, thisOffsetX + (cellsWidth - App.fontGame.getWidth(chestName)) / 2, thisOffsetY - 30)
|
Toolkit.drawTextCentered(batch, App.fontGame, Lang["ITEM_JUKEBOX"], cellsWidth, thisOffsetX, thisOffsetY - INVENTORY_NAME_TEXT_GAP)
|
||||||
App.fontGame.draw(batch, playerName, thisOffsetX2 + (cellsWidth - App.fontGame.getWidth(playerName)) / 2, thisOffsetY - 30)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
|
|||||||
174
src/net/torvald/terrarum/modulebasegame/ui/UISmelterBasic.kt
Normal file
174
src/net/torvald/terrarum/modulebasegame/ui/UISmelterBasic.kt
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import net.torvald.terrarum.*
|
||||||
|
import net.torvald.terrarum.gameitems.GameItem
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
||||||
|
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
||||||
|
import net.torvald.terrarum.ui.*
|
||||||
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
import net.torvald.unicode.getKeycapPC
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2024-01-29.
|
||||||
|
*/
|
||||||
|
class UISmelterBasic() : UICanvas(
|
||||||
|
toggleKeyLiteral = "control_key_inventory",
|
||||||
|
toggleButtonLiteral = "control_gamepad_start"
|
||||||
|
), HasInventory {
|
||||||
|
|
||||||
|
override var width = Toolkit.drawWidth
|
||||||
|
override var height = App.scr.height
|
||||||
|
|
||||||
|
private val playerThings = UITemplateHalfInventory(this, false).also {
|
||||||
|
it.itemListTouchDownFun = { gameItem, _, _, _, _ ->
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val negotiator = object : InventoryTransactionNegotiator() {
|
||||||
|
override fun accept(player: FixtureInventory, fixture: FixtureInventory, item: GameItem, amount: Long) {
|
||||||
|
// TODO()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun refund(fixture: FixtureInventory, player: FixtureInventory, item: GameItem, amount: Long) {
|
||||||
|
// TODO()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getNegotiator() = negotiator
|
||||||
|
override fun getFixtureInventory(): FixtureInventory = TODO()
|
||||||
|
override fun getPlayerInventory(): FixtureInventory = INGAME.actorNowPlaying!!.inventory
|
||||||
|
|
||||||
|
init {
|
||||||
|
CommonResourcePool.addToLoadingList("basegame_gui_smelter_icons") {
|
||||||
|
TextureRegionPack(ModMgr.getGdxFile("basegame", "gui/smelter_icons.tga"), 20, 20)
|
||||||
|
}
|
||||||
|
CommonResourcePool.loadAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val smelterCellIcons = CommonResourcePool.getAsTextureRegionPack("basegame_gui_smelter_icons")
|
||||||
|
|
||||||
|
private var smelterBackdrop =
|
||||||
|
FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/smelter_tall.tga")
|
||||||
|
|
||||||
|
private var fuelCaloriesNow = 0f
|
||||||
|
private var fuelCaloriesMax: Float? = null
|
||||||
|
|
||||||
|
private var temperature = 0f // 0f..1f
|
||||||
|
private var progress = 0f
|
||||||
|
|
||||||
|
|
||||||
|
private val leftPanelWidth = playerThings.width
|
||||||
|
private val leftPanelHeight = playerThings.height
|
||||||
|
private val leftPanelX = playerThings.posX - leftPanelWidth - UIItemInventoryItemGrid.listGap - UIItemInventoryElemWide.height
|
||||||
|
private val leftPanelY = playerThings.posY
|
||||||
|
|
||||||
|
private val backdropColour = Color(0x7f7f7fff)
|
||||||
|
private val backdropZoom = 6
|
||||||
|
private val backdropX = (leftPanelX + (leftPanelWidth - smelterBackdrop.regionWidth * backdropZoom) / 2).toFloat()
|
||||||
|
private val backdropY = (leftPanelY + (leftPanelHeight - smelterBackdrop.regionHeight * backdropZoom) / 2).toFloat()
|
||||||
|
|
||||||
|
private val oreX = backdropX + 12 * backdropZoom + 3
|
||||||
|
private val oreY = backdropY + 23 * backdropZoom + 3
|
||||||
|
|
||||||
|
private val fireboxX = backdropX + 12 * backdropZoom + 3
|
||||||
|
private val fireboxY = backdropY + 39 * backdropZoom + 3
|
||||||
|
|
||||||
|
private val productX = backdropX + 37 * backdropZoom + 3
|
||||||
|
private val productY = backdropY + 39 * backdropZoom + 3
|
||||||
|
|
||||||
|
private val oreItemSlot = UIItemInventoryElemSimple(
|
||||||
|
this, oreX.toInt(), oreY.toInt(),
|
||||||
|
emptyCellIcon = smelterCellIcons.get(1, 1),
|
||||||
|
keyDownFun = { _, _, _, _, _ -> },
|
||||||
|
touchDownFun = { item, amount, _, _, _ -> }
|
||||||
|
)
|
||||||
|
private val fireboxItemSlot = UIItemInventoryElemSimple(
|
||||||
|
this, fireboxX.toInt(), fireboxY.toInt(),
|
||||||
|
emptyCellIcon = smelterCellIcons.get(0, 0),
|
||||||
|
keyDownFun = { _, _, _, _, _ -> },
|
||||||
|
touchDownFun = { item, amount, _, _, _ -> }
|
||||||
|
)
|
||||||
|
private val productItemslot = UIItemInventoryElemSimple(
|
||||||
|
this, productX.toInt(), productY.toInt(),
|
||||||
|
emptyCellIcon = smelterCellIcons.get(1, 0),
|
||||||
|
keyDownFun = { _, _, _, _, _ -> },
|
||||||
|
touchDownFun = { item, amount, _, _, _ -> }
|
||||||
|
)
|
||||||
|
|
||||||
|
private var encumbrancePerc = 0f
|
||||||
|
|
||||||
|
private fun itemListUpdate() {
|
||||||
|
// let itemlists be sorted
|
||||||
|
// itemListCraftable.rebuild(UIItemCatBar.FILTER_CAT_ALL)
|
||||||
|
playerThings.rebuild(UIItemCatBar.FILTER_CAT_ALL)
|
||||||
|
encumbrancePerc = getPlayerInventory().let {
|
||||||
|
it.capacity.toFloat() / it.maxCapacity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
addUIitem(playerThings)
|
||||||
|
addUIitem(fireboxItemSlot)
|
||||||
|
addUIitem(oreItemSlot)
|
||||||
|
addUIitem(productItemslot)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun show() {
|
||||||
|
super.show()
|
||||||
|
playerThings.setGetInventoryFun { INGAME.actorNowPlaying!!.inventory }
|
||||||
|
itemListUpdate()
|
||||||
|
|
||||||
|
UIItemInventoryItemGrid.tooltipShowing.clear()
|
||||||
|
INGAME.setTooltipMessage(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateUI(delta: Float) {
|
||||||
|
uiItems.forEach { it.update(delta) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private val controlHelp: String
|
||||||
|
get() = if (App.environment == RunningEnvironment.PC)
|
||||||
|
"${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}"
|
||||||
|
else
|
||||||
|
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}"
|
||||||
|
|
||||||
|
override fun renderUI(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
|
||||||
|
batch.color = backdropColour
|
||||||
|
batch.draw(smelterBackdrop, backdropX, backdropY, smelterBackdrop.regionWidth * 6f, smelterBackdrop.regionHeight * 6f)
|
||||||
|
|
||||||
|
uiItems.forEach { it.render(frameDelta, batch, camera) }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// control hints
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
val controlHintXPos = leftPanelX + 2f
|
||||||
|
blendNormalStraightAlpha(batch)
|
||||||
|
App.fontGame.draw(batch, controlHelp, controlHintXPos, UIInventoryFull.yEnd - 20)
|
||||||
|
|
||||||
|
|
||||||
|
if (INGAME.actorNowPlaying != null) {
|
||||||
|
//draw player encumb
|
||||||
|
val encumbBarXPos = playerThings.posX + playerThings.width - UIInventoryCells.weightBarWidth + 36
|
||||||
|
val encumbBarYPos = UIInventoryFull.yEnd - 20 + 3f
|
||||||
|
UIInventoryCells.drawEncumbranceBar(batch, encumbBarXPos, encumbBarYPos, encumbrancePerc, INGAME.actorNowPlaying!!.inventory)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
blendNormalStraightAlpha(batch)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -95,7 +95,7 @@ internal class UIStorageChest : UICanvas(
|
|||||||
catBar.selectionChangeListener = { old, new -> itemListUpdate() }
|
catBar.selectionChangeListener = { old, new -> itemListUpdate() }
|
||||||
|
|
||||||
|
|
||||||
itemListChest = UITemplateHalfInventory(this, true) { getFixtureInventory() }.also {
|
itemListChest = UITemplateHalfInventory(this, true, { getFixtureInventory() }, { chestNameFun() }).also {
|
||||||
it.itemListKeyDownFun = { _, _, _, _, _ -> Unit }
|
it.itemListKeyDownFun = { _, _, _, _, _ -> Unit }
|
||||||
it.itemListTouchDownFun = { gameItem, amount, button, _, _ ->
|
it.itemListTouchDownFun = { gameItem, amount, button, _, _ ->
|
||||||
if (button == App.getConfigInt("config_mouseprimary")) {
|
if (button == App.getConfigInt("config_mouseprimary")) {
|
||||||
@@ -210,19 +210,12 @@ internal class UIStorageChest : UICanvas(
|
|||||||
blendNormalStraightAlpha(batch)
|
blendNormalStraightAlpha(batch)
|
||||||
|
|
||||||
// encumbrance meter
|
// encumbrance meter
|
||||||
val chestName = chestNameFun()
|
|
||||||
val playerName = INGAME.actorNowPlaying!!.actorValue.getAsString(AVKey.NAME).orEmpty().let { it.ifBlank { Lang["GAME_INVENTORY"] } }
|
|
||||||
val encumbBarXPos = itemListPlayer.posX + itemListPlayer.width - UIInventoryCells.weightBarWidth + 36
|
val encumbBarXPos = itemListPlayer.posX + itemListPlayer.width - UIInventoryCells.weightBarWidth + 36
|
||||||
val yEnd = -UIInventoryFull.YPOS_CORRECTION + (App.scr.height + UIInventoryFull.internalHeight).div(2).toFloat() // directly copied from UIInventoryFull.yEnd
|
val yEnd = -UIInventoryFull.YPOS_CORRECTION + (App.scr.height + UIInventoryFull.internalHeight).div(2).toFloat() // directly copied from UIInventoryFull.yEnd
|
||||||
val encumbBarYPos = yEnd - 20 + 3 // dunno why but extra 3 px is needed
|
val encumbBarYPos = yEnd - 20 + 3 // dunno why but extra 3 px is needed
|
||||||
|
|
||||||
UIInventoryCells.drawEncumbranceBar(batch, encumbBarXPos, encumbBarYPos, encumbrancePerc, getPlayerInventory())
|
UIInventoryCells.drawEncumbranceBar(batch, encumbBarXPos, encumbBarYPos, encumbrancePerc, getPlayerInventory())
|
||||||
|
|
||||||
// chest name text
|
|
||||||
batch.color = Color.WHITE
|
|
||||||
App.fontGame.draw(batch, chestName, thisOffsetX + (cellsWidth - App.fontGame.getWidth(chestName)) / 2, thisOffsetY - 30)
|
|
||||||
App.fontGame.draw(batch, playerName, thisOffsetX2 + (cellsWidth - App.fontGame.getWidth(playerName)) / 2, thisOffsetY - 30)
|
|
||||||
|
|
||||||
// control hint
|
// control hint
|
||||||
App.fontGame.draw(batch, controlHelp, thisOffsetX - 34f, encumbBarYPos - 3)
|
App.fontGame.draw(batch, controlHelp, thisOffsetX - 34f, encumbBarYPos - 3)
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.ui
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
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.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameitems.GameItem
|
import net.torvald.terrarum.gameitems.GameItem
|
||||||
import net.torvald.terrarum.gameitems.ItemID
|
import net.torvald.terrarum.gameitems.ItemID
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
||||||
@@ -22,9 +25,14 @@ import net.torvald.terrarum.ui.*
|
|||||||
class UITemplateHalfInventory(
|
class UITemplateHalfInventory(
|
||||||
parent: UICanvas,
|
parent: UICanvas,
|
||||||
drawOnLeft: Boolean,
|
drawOnLeft: Boolean,
|
||||||
getInventoryFun: () -> FixtureInventory = { INGAME.actorNowPlaying!!.inventory }
|
getInventoryFun: () -> FixtureInventory = { INGAME.actorNowPlaying!!.inventory },
|
||||||
|
val inventoryNameFun: () -> String = { INGAME.actorNowPlaying!!.actorValue.getAsString(AVKey.NAME).orEmpty().let { it.ifBlank { Lang["GAME_INVENTORY"] } } }
|
||||||
) : UITemplate(parent) {
|
) : UITemplate(parent) {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val INVENTORY_NAME_TEXT_GAP = 28
|
||||||
|
}
|
||||||
|
|
||||||
val itemList: UIItemInventoryItemGrid
|
val itemList: UIItemInventoryItemGrid
|
||||||
|
|
||||||
private val halfSlotOffset = (UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap) / 2
|
private val halfSlotOffset = (UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap) / 2
|
||||||
@@ -78,8 +86,13 @@ class UITemplateHalfInventory(
|
|||||||
itemList.getInventory = getter
|
itemList.getInventory = getter
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun update(delta: Float) = itemList.update(delta)
|
override fun update(delta: Float) = itemList.update(delta)
|
||||||
inline fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) = itemList.render(frameDelta, batch, camera)
|
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
|
||||||
|
itemList.render(frameDelta, batch, camera)
|
||||||
|
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
Toolkit.drawTextCentered(batch, App.fontGame, inventoryNameFun(), width, posX, thisOffsetY - INVENTORY_NAME_TEXT_GAP)
|
||||||
|
}
|
||||||
|
|
||||||
var posX: Int
|
var posX: Int
|
||||||
get() = itemList.posX
|
get() = itemList.posX
|
||||||
@@ -95,4 +108,7 @@ class UITemplateHalfInventory(
|
|||||||
override fun getUIitems(): List<UIItem> {
|
override fun getUIitems(): List<UIItem> {
|
||||||
return listOf(itemList)
|
return listOf(itemList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ abstract class UICanvas(
|
|||||||
open var openCloseTime: Second = OPENCLOSE_GENERIC
|
open var openCloseTime: Second = OPENCLOSE_GENERIC
|
||||||
|
|
||||||
|
|
||||||
protected val uiItems = ArrayList<UIItem>()
|
protected val uiItems = ArrayList<UIItemisable>()
|
||||||
|
|
||||||
|
|
||||||
val relativeMouseX: Int
|
val relativeMouseX: Int
|
||||||
@@ -189,12 +189,9 @@ abstract class UICanvas(
|
|||||||
|
|
||||||
abstract override fun dispose()
|
abstract override fun dispose()
|
||||||
|
|
||||||
fun addUIitem(uiItem: UIItem) {
|
fun addUIitem(uiItem: UIItemisable) {
|
||||||
if (!uiItems.contains(uiItem)) uiItems.add(uiItem)
|
if (!uiItems.contains(uiItem)) uiItems.add(uiItem)
|
||||||
}
|
}
|
||||||
fun addUIitem(template: UITemplate) {
|
|
||||||
template.getUIitems().forEach { addUIitem(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun mouseInScreen(x: Int, y: Int) = x in 0 until App.scr.windowW && y in 0 until App.scr.windowH
|
fun mouseInScreen(x: Int, y: Int) = x in 0 until App.scr.windowW && y in 0 until App.scr.windowH
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
|
|||||||
*
|
*
|
||||||
* Created by minjaesong on 2015-12-31.
|
* Created by minjaesong on 2015-12-31.
|
||||||
*/
|
*/
|
||||||
abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: Int): Disposable { // do not replace parentUI to UIHandler!
|
abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: Int): UIItemisable() { // do not replace parentUI to UIHandler!
|
||||||
|
|
||||||
// X/Y Position relative to the containing canvas
|
// X/Y Position relative to the containing canvas
|
||||||
var posX: Int = initialX
|
var posX: Int = initialX
|
||||||
@@ -145,11 +145,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
open var isActive = true
|
open var isActive = true
|
||||||
|
|
||||||
|
|
||||||
open fun show() {}
|
override fun update(delta: Float) {
|
||||||
open fun hide() {}
|
|
||||||
|
|
||||||
|
|
||||||
open fun update(delta: Float) {
|
|
||||||
if (parentUI.isVisible) {
|
if (parentUI.isVisible) {
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
updateListener.invoke(delta)
|
updateListener.invoke(delta)
|
||||||
@@ -177,7 +173,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
/**
|
/**
|
||||||
* In this time, you do write like: ```draw(posX + 4, posY + 32)```, unlike UICanvas, because posX/posY comes from the parent UI.
|
* In this time, you do write like: ```draw(posX + 4, posY + 32)```, unlike UICanvas, because posX/posY comes from the parent UI.
|
||||||
*/
|
*/
|
||||||
open fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
|
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
|
||||||
if (parentUI.isVisible) {
|
if (parentUI.isVisible) {
|
||||||
// if (isActive) {
|
// if (isActive) {
|
||||||
mouseOverCall?.render(frameDelta, batch, camera)
|
mouseOverCall?.render(frameDelta, batch, camera)
|
||||||
@@ -190,7 +186,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
}
|
}
|
||||||
|
|
||||||
// keyboard controlled
|
// keyboard controlled
|
||||||
open fun keyDown(keycode: Int): Boolean {
|
override fun keyDown(keycode: Int): Boolean {
|
||||||
if (parentUI.isVisible && isEnabled) {
|
if (parentUI.isVisible && isEnabled) {
|
||||||
keyDownListener.invoke(keycode)
|
keyDownListener.invoke(keycode)
|
||||||
return true
|
return true
|
||||||
@@ -198,7 +194,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
open fun keyUp(keycode: Int): Boolean {
|
override fun keyUp(keycode: Int): Boolean {
|
||||||
if (parentUI.isVisible && isEnabled) {
|
if (parentUI.isVisible && isEnabled) {
|
||||||
keyUpListener.invoke(keycode)
|
keyUpListener.invoke(keycode)
|
||||||
return true
|
return true
|
||||||
@@ -206,7 +202,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
open fun keyTyped(character: Char): Boolean {
|
override fun keyTyped(character: Char): Boolean {
|
||||||
if (parentUI.isVisible && isEnabled) {
|
if (parentUI.isVisible && isEnabled) {
|
||||||
keyTypedListener.invoke(character)
|
keyTypedListener.invoke(character)
|
||||||
return true
|
return true
|
||||||
@@ -216,7 +212,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
}
|
}
|
||||||
|
|
||||||
// mouse controlled
|
// mouse controlled
|
||||||
open fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
|
override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
|
||||||
if (parentUI.isVisible && isEnabled) {
|
if (parentUI.isVisible && isEnabled) {
|
||||||
touchDraggedListener.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer)
|
touchDraggedListener.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer)
|
||||||
return true
|
return true
|
||||||
@@ -224,7 +220,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
open fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
var actionDone = false
|
var actionDone = false
|
||||||
|
|
||||||
if (parentUI.isVisible && isEnabled) {
|
if (parentUI.isVisible && isEnabled) {
|
||||||
@@ -241,7 +237,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
|
|
||||||
return actionDone
|
return actionDone
|
||||||
}
|
}
|
||||||
open fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
clickOnceListenerFired = false
|
clickOnceListenerFired = false
|
||||||
|
|
||||||
if (parentUI.isVisible && mouseUp) {
|
if (parentUI.isVisible && mouseUp) {
|
||||||
@@ -251,7 +247,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
open fun scrolled(amountX: Float, amountY: Float): Boolean {
|
override fun scrolled(amountX: Float, amountY: Float): Boolean {
|
||||||
if (parentUI.isVisible && mouseUp && isEnabled) {
|
if (parentUI.isVisible && mouseUp && isEnabled) {
|
||||||
scrolledListener.invoke(amountX, amountY)
|
scrolledListener.invoke(amountX, amountY)
|
||||||
return true
|
return true
|
||||||
@@ -259,9 +255,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
open fun inputStrobed(e: TerrarumKeyboardEvent) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract override fun dispose()
|
abstract override fun dispose()
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ class UIItemInventoryElemSimple(
|
|||||||
highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting
|
highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting
|
||||||
colourTheme: InventoryCellColourTheme = defaultInventoryCellTheme,
|
colourTheme: InventoryCellColourTheme = defaultInventoryCellTheme,
|
||||||
var showItemCount: Boolean = true,
|
var showItemCount: Boolean = true,
|
||||||
|
var emptyCellIcon: TextureRegion? = null, // icon to draw when the cell is empty
|
||||||
|
var emptyCellIconColour: Color = Color(0xdddddd7f.toInt()),
|
||||||
) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo, highlightEquippedItem, colourTheme) {
|
) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo, highlightEquippedItem, colourTheme) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -52,6 +54,9 @@ class UIItemInventoryElemSimple(
|
|||||||
private val imgOffsetX: Float
|
private val imgOffsetX: Float
|
||||||
get() = (this.height - itemImageOrDefault.regionWidth).div(2).toFloat() // to snap to the pixel grid
|
get() = (this.height - itemImageOrDefault.regionWidth).div(2).toFloat() // to snap to the pixel grid
|
||||||
|
|
||||||
|
private val emptyCellIconOffsetX = (this.height - (emptyCellIcon?.regionWidth ?: 0)).div(2).toFloat()
|
||||||
|
private val emptyCellIconOffsetY = (this.height - (emptyCellIcon?.regionHeight ?: 0)).div(2).toFloat()
|
||||||
|
|
||||||
override fun update(delta: Float) {
|
override fun update(delta: Float) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -123,6 +128,15 @@ class UIItemInventoryElemSimple(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
// empty cell image
|
||||||
|
emptyCellIcon?.let {
|
||||||
|
batch.color = emptyCellIconColour
|
||||||
|
batch.draw(it, posX + emptyCellIconOffsetX, posY + emptyCellIconOffsetY)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// see IFs above?
|
// see IFs above?
|
||||||
|
|||||||
@@ -1,10 +1,44 @@
|
|||||||
package net.torvald.terrarum.ui
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import com.badlogic.gdx.utils.Disposable
|
||||||
|
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2024-01-10.
|
* Created by minjaesong on 2024-01-10.
|
||||||
*/
|
*/
|
||||||
abstract class UITemplate(val parent: UICanvas) {
|
abstract class UITemplate(val parent: UICanvas) : UIItemisable() {
|
||||||
|
|
||||||
abstract fun getUIitems(): List<UIItem>
|
abstract fun getUIitems(): List<UIItem>
|
||||||
|
|
||||||
|
override fun show() { getUIitems().forEach { it.show() } }
|
||||||
|
override fun hide() { getUIitems().forEach { it.hide() } }
|
||||||
|
override fun inputStrobed(e: TerrarumKeyboardEvent) { getUIitems().forEach { it.inputStrobed(e) } }
|
||||||
|
override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { getUIitems().forEach { it.touchDragged(screenX, screenY, pointer) }; return true }
|
||||||
|
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { getUIitems().forEach { it.touchDown(screenX, screenY, pointer, button) }; return true }
|
||||||
|
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { getUIitems().forEach { it.touchUp(screenX, screenY, pointer, button) }; return true }
|
||||||
|
override fun scrolled(amountX: Float, amountY: Float): Boolean { getUIitems().forEach { it.scrolled(amountX, amountY) }; return true }
|
||||||
|
override fun keyDown(keycode: Int): Boolean { getUIitems().forEach { it.keyDown(keycode) }; return true }
|
||||||
|
override fun keyUp(keycode: Int): Boolean { getUIitems().forEach { it.keyUp(keycode) }; return true }
|
||||||
|
override fun keyTyped(char: Char): Boolean { getUIitems().forEach { it.keyTyped(char) }; return true }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2024-01-29.
|
||||||
|
*/
|
||||||
|
abstract class UIItemisable : Disposable {
|
||||||
|
abstract fun update(delta: Float)
|
||||||
|
abstract fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera)
|
||||||
|
open fun show() {}
|
||||||
|
open fun hide() {}
|
||||||
|
open fun inputStrobed(e: TerrarumKeyboardEvent) {}
|
||||||
|
open fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean = false
|
||||||
|
open fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean = false
|
||||||
|
open fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean = false
|
||||||
|
open fun scrolled(amountX: Float, amountY: Float): Boolean = false
|
||||||
|
open fun keyDown(keycode: Int): Boolean = false
|
||||||
|
open fun keyUp(keycode: Int): Boolean = false
|
||||||
|
open fun keyTyped(char: Char): Boolean = false
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package net.torvald.terrarum.ui
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.App
|
||||||
import net.torvald.terrarum.CommonResourcePool
|
import net.torvald.terrarum.CommonResourcePool
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
||||||
@@ -34,4 +36,8 @@ class UITemplateCatBar(
|
|||||||
override fun getUIitems(): List<UIItem> {
|
override fun getUIitems(): List<UIItem> {
|
||||||
return listOf(catBar)
|
return listOf(catBar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun update(delta: Float) = catBar.update(delta)
|
||||||
|
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) = catBar.render(frameDelta, batch, camera)
|
||||||
|
override fun dispose() = catBar.dispose()
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user