fixed a bug where storagechest would not show anything on the item slot; changed inventory UI so that it would sync with the Toolkit.Theme

This commit is contained in:
minjaesong
2021-10-29 15:00:16 +09:00
parent 8dd4248f67
commit 27ddb76df7
14 changed files with 275 additions and 290 deletions

View File

@@ -212,6 +212,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
}
override fun endOpening(delta: Float) {
INGAME.setTooltipMessage(null)
}
override fun endClosing(delta: Float) {

View File

@@ -5,13 +5,10 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK_ACTIVE
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELL_COL
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.itemListHeight
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericKeyDownFun
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericTouchDownFun
import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.Toolkit.Theme.COL_INVENTORY_CELL_BORDER
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItem
@@ -32,7 +29,7 @@ class UIItemInventoryEquippedView(
companion object {
val WIDTH = 2 * UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap
//val HEIGHT = UIItemInventoryDynamicList.HEIGHT
val SPRITE_DRAW_COL = Color(0xddddddff.toInt())
val SPRITE_DRAW_COL = Color(0xf2f2f2ff.toInt())
}
private val listGap = 8
@@ -42,8 +39,6 @@ class UIItemInventoryEquippedView(
lateinit var inventorySortList: Array<GameItem?>
private var rebuildList = true
val spriteViewBackCol: Color = CELL_COL
private val equipPosIcon = CommonResourcePool.getAsTextureRegionPack("inventory_category")
private val cellToIcon = intArrayOf(0,1,2,3,4,5,6,7,6,7,6,7)
@@ -57,10 +52,6 @@ class UIItemInventoryEquippedView(
item = null,
amount = UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT,
itemImage = null,
mouseoverBackCol = Color(CELLCOLOUR_BLACK_ACTIVE),
mouseoverBackBlendMode = BlendMode.SCREEN,
backCol = CELL_COL,
backBlendMode = BlendMode.NORMAL,
drawBackOnNull = true,
keyDownFun = createInvCellGenericKeyDownFun(),
touchDownFun = createInvCellGenericTouchDownFun(inventoryListRebuildFun) // to "unselect" the equipped item and main item grid would "untick" accordingly
@@ -73,16 +64,16 @@ class UIItemInventoryEquippedView(
}
override fun render(batch: SpriteBatch, camera: Camera) {
blendNormal(batch)
val posXDelta = posX - oldPosX
itemGrid.forEach { it.posX += posXDelta }
// sprite background
blendNormal(batch)
batch.color = spriteViewBackCol
// sprite cell background
batch.color = Toolkit.Theme.COL_CELL_FILL
Toolkit.fillArea(batch, posX, posY, width, width)
batch.color = COL_INVENTORY_CELL_BORDER
// sprite cell border
batch.color = Toolkit.Theme.COL_INVENTORY_CELL_BORDER
Toolkit.drawBoxBorder(batch, posX, posY, width, width)

View File

@@ -55,8 +55,6 @@ class UIItemInventoryItemGrid(
override val width = horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 1) * listGap
override val height = verticalCells * UIItemInventoryElemSimple.height + (verticalCells - 1) * listGap
val backColour = CELL_COL
init {
CommonResourcePool.addToLoadingList("inventory_walletnumberfont") {
TextureRegionPack("./assets/graphics/fonts/inventory_wallet_numbers.tga", 20, 9)
@@ -92,13 +90,10 @@ class UIItemInventoryItemGrid(
var inventorySortList = ArrayList<InventoryPair>()
private var rebuildList = true
val defaultTextColour = Color(0xeaeaea_ff.toInt())
private val walletFont = TextureRegionPack("./assets/graphics/fonts/inventory_wallet_numbers.tga", 20, 9)
private var walletText = ""
companion object {
const val listGap = 8
const val LIST_TO_CONTROL_GAP = 12
@@ -179,12 +174,7 @@ class UIItemInventoryItemGrid(
item = null,
amount = UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT,
itemImage = null,
mouseoverBackCol = Color(CELLCOLOUR_BLACK_ACTIVE),
mouseoverBackBlendMode = BlendMode.SCREEN,
backCol = backColour,
backBlendMode = BlendMode.NORMAL,
drawBackOnNull = true,
inactiveTextCol = defaultTextColour,
keyDownFun = keyDownFun,
touchDownFun = touchDownFun
)
@@ -202,12 +192,7 @@ class UIItemInventoryItemGrid(
item = null,
amount = UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT,
itemImage = null,
mouseoverBackCol = Color(CELLCOLOUR_BLACK_ACTIVE),
mouseoverBackBlendMode = BlendMode.SCREEN,
backCol = backColour,
backBlendMode = BlendMode.NORMAL,
drawBackOnNull = true,
inactiveTextCol = defaultTextColour,
keyDownFun = keyDownFun,
touchDownFun = touchDownFun
)
@@ -228,7 +213,7 @@ class UIItemInventoryItemGrid(
posX - LIST_TO_CONTROL_GAP - catBar.catIcons.tileW + 2
private fun getIconPosY(index: Int) =
posY - 2 + (4 + UIItemInventoryElemWide.height - catBar.catIcons.tileH) * index
posY - 1 + (4 + UIItemInventoryElemWide.height - catBar.catIcons.tileH) * index
/** Long/compact mode buttons */
internal val gridModeButtons = Array<UIItemImageButton>(2) { index ->
@@ -350,7 +335,7 @@ class UIItemInventoryItemGrid(
batch.draw(
walletFont.get(0, it - '0'),
gridModeButtons[0].posX.toFloat(), // scroll button size: 20px, font width: 20 px
gridModeButtons[0].posY + height - index * walletFont.tileH.toFloat()
gridModeButtons[0].posY + height - index * walletFont.tileH - 1f
)
}
}