storage chest ui to display its name and player encumbrance meter

This commit is contained in:
minjaesong
2021-03-16 17:37:52 +09:00
parent 5f7db4cf19
commit bae438c2df
11 changed files with 89 additions and 28 deletions

View File

@@ -14,6 +14,7 @@ import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTOR
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalWidth
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVEN_DEBUG_MODE
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.controlHelpHeight
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericKeyDownFun
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericTouchDownFun
import net.torvald.terrarum.ui.UICanvas
@@ -26,8 +27,10 @@ internal class UIInventoryCells(
override var height: Int = AppLoader.screenH
override var openCloseTime: Second = 0.0f
private val weightBarWidth = UIItemInventoryElemSimple.height * 2f + UIItemInventoryItemGrid.listGap
companion object {
val weightBarWidth = UIItemInventoryElemSimple.height * 2f + UIItemInventoryItemGrid.listGap
var encumbBarYPos = 0f
}
internal var encumbrancePerc = 0f
private set
@@ -106,6 +109,7 @@ internal class UIInventoryCells(
if (AppLoader.fontGame.getWidth(full.listControlHelp) + 2 + controlHintXPos >= encumbBarTextXPos)
AppLoader.fontGame.lineHeight
else 0f
Companion.encumbBarYPos = encumbBarYPos // q&d hack to share some numbers
AppLoader.fontGame.draw(batch,
encumbranceText,
@@ -120,7 +124,7 @@ internal class UIInventoryCells(
batch.color = encumbBack
batch.fillRect(
encumbBarXPos, encumbBarYPos,
weightBarWidth, full.controlHelpHeight - 6f
weightBarWidth, controlHelpHeight - 6f
)
// encumbrance bar
batch.color = encumbCol
@@ -130,7 +134,7 @@ internal class UIInventoryCells(
1f
else // make sure 1px is always be seen
minOf(weightBarWidth, maxOf(1f, weightBarWidth * encumbrancePerc)),
full.controlHelpHeight - 6f
controlHelpHeight - 6f
)
// debug text
batch.color = Color.LIGHT_GRAY
@@ -138,7 +142,7 @@ internal class UIInventoryCells(
AppLoader.fontSmallNumbers.draw(batch,
"${full.actor.inventory.capacity}/${full.actor.inventory.maxCapacity}",
encumbBarTextXPos,
encumbBarYPos + full.controlHelpHeight - 4f
encumbBarYPos + controlHelpHeight - 4f
)
}
}

View File

@@ -53,6 +53,8 @@ class UIInventoryFull(
val gradStartCol = Color(0x404040_60)
val gradEndCol = Color(0x000000_70)
val gradHeight = 48f
val controlHelpHeight = AppLoader.fontGame.lineHeight
}
//val REQUIRED_MARGIN: Int = 138 // hard-coded value. Don't know the details. Range: [91-146]. I chose MAX-8 because cell gap is 8
@@ -108,9 +110,7 @@ class UIInventoryFull(
else
"$gamepadLabelStart ${Lang["GAME_ACTION_CLOSE"]}$SP" +
"$gamepadLabelLT ${Lang["GAME_INVENTORY"]}"
val controlHelpHeight = AppLoader.fontGame.lineHeight
//val catBarWidth = 330
val catBar = UIItemInventoryCatBar(
this,
(AppLoader.screenW - catBarWidth) / 2,