inventory wallet view

This commit is contained in:
minjaesong
2019-02-11 18:02:52 +09:00
parent 97d0b9de64
commit 07b801ace5
6 changed files with 72 additions and 10 deletions

View File

@@ -49,7 +49,6 @@ class UIInventoryFull(
internal val catArrangement: IntArray = intArrayOf(9,6,7,1,0,2,3,4,5,8)
private val SP = "${0x3000.toChar()}${0x3000.toChar()}"
val listControlHelp: String
get() = if (AppLoader.environment == RunningEnvironment.PC)
@@ -398,6 +397,20 @@ class UIInventoryFull(
isEncumbered = actor.inventory.isEncumbered
}
private fun Int.fastLen(): Int {
return if (this < 0) 1 + this.unaryMinus().fastLen()
else if (this < 10) 1
else if (this < 100) 2
else if (this < 1000) 3
else if (this < 10000) 4
else if (this < 100000) 5
else if (this < 1000000) 6
else if (this < 10000000) 7
else if (this < 100000000) 8
else if (this < 1000000000) 9
else 10
}
override fun dispose() {
categoryBar.dispose()
itemList.dispose()

View File

@@ -14,6 +14,7 @@ import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BL
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK_ACTIVE
import net.torvald.terrarum.ui.UIItem
import net.torvald.terrarum.ui.UIItemImageButton
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import java.util.*
/**
@@ -82,6 +83,9 @@ class UIItemInventoryDynamicList(
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 horizontalCells = 11
@@ -246,6 +250,16 @@ class UIItemInventoryDynamicList(
)
}
// draw wallet text
batch.color = Color.WHITE
walletText.forEachIndexed { index, it ->
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()
)
}
super.render(batch, camera)
oldPosX = posX
@@ -347,6 +361,13 @@ class UIItemInventoryDynamicList(
itemPageCount = (inventorySortList.size.toFloat() / items.size.toFloat()).ceilInt()
// ¤ 42g
// ¤ 6969g
// ¤ 2147483647g
// g is read as "grave" /ɡraːv/ or /ɡɹeɪv/, because it isn't gram.
walletText = "<;?" + inventory.wallet.toString().padStart(4, '?') + ":"
rebuildList = false
}
@@ -356,6 +377,7 @@ class UIItemInventoryDynamicList(
gridModeButtons.forEach { it.dispose() }
scrollUpButton.dispose()
scrollDownButton.dispose()
walletFont.dispose()
}
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {