mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
inventory UI wip update
Two columns, some marginal spaces to make it look better Former-commit-id: c26d11e499970280b78193772d29937295916ae2
This commit is contained in:
@@ -25,6 +25,11 @@
|
||||
"TILE_STONE_QUARRIED_PLURAL": "Quarried stones",
|
||||
"TILE_SAND": "Sand",
|
||||
"TILE_SAND_PLURAL": "Sands",
|
||||
"TILE_SAND_WHITE": "White sand",
|
||||
"TILE_SAND_RED": "Red sand",
|
||||
"TILE_SAND_DESERT": "Sand",
|
||||
"TILE_SAND_BLACK": "Black sand",
|
||||
"TILE_SAND_GREEN": "Green sand",
|
||||
"TILE_GRAVEL": "Gravel",
|
||||
"TILE_GRAVEL_PLURAL": "Gravels",
|
||||
"TILE_ORE_MALACHITE": "Malachite",
|
||||
@@ -71,6 +76,12 @@
|
||||
"TILE_PLATFORM_BLOODROSE_PLURAL": "Rosewood platforms",
|
||||
"TILE_TORCH": "Torch",
|
||||
"TILE_TORCH_PLURAL": "Torches",
|
||||
"TILE_SANDSTONE": "Sandstone",
|
||||
"TILE_SANDSTONE_WHITE": "White sandstone",
|
||||
"TILE_SANDSTONE_RED": "Red sandstone",
|
||||
"TILE_SANDSTONE_DESERT": "Sandstone",
|
||||
"TILE_SANDSTONE_BLACK": "Black sandstone",
|
||||
"TILE_SANDSTONE_GREEN": "Green sandstone",
|
||||
"TILE_WATER": "Water",
|
||||
"TILE_WATER_PLURAL": "Waters",
|
||||
"TILE_LAVA": "Lava",
|
||||
|
||||
78
assets/locales/koKR/tiles.json
Normal file
78
assets/locales/koKR/tiles.json
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"TILE_STONE": "돌",
|
||||
"TILE_STONE_PLURAL": "돌",
|
||||
"TILE_DIRT": "흙",
|
||||
"TILE_DIRT_PLURAL": "흙",
|
||||
"TILE_GRASS": "잔디",
|
||||
"TILE_GRAS_PLURALS": "잔디",
|
||||
"TILE_PLANK_NORMAL": "나무판자",
|
||||
"TILE_PLANK_NORMAL_PLURAL": "나무판자",
|
||||
"TILE_PLANK_EBONY": "흑단",
|
||||
"TILE_PLANK_EBONY_PLURAL": "흑단",
|
||||
"TILE_PLANK_BIRCH": "백단",
|
||||
"TILE_PLANK_BIRCH_PLURAL": "백단",
|
||||
"TILE_PLANK_BLOODROSE": "자단",
|
||||
"TILE_PLANK_BLOODROSE_PLURAL": "자단",
|
||||
"TILE_TRUNK_NORMAL": "통나무",
|
||||
"TILE_TRUNK_NORMAL_PLURAL": "통나무",
|
||||
"TILE_TRUNK_EBONY": "흑단나무",
|
||||
"TILE_TRUNK_EBONY_PLURAL": "흑단나무",
|
||||
"TILE_TRUNK_BIRCH": "백단나무",
|
||||
"TILE_TRUNK_BIRCH_PLURAL": "백단나무",
|
||||
"TILE_TRUNK_BLOODROSE": "자단나무",
|
||||
"TILE_TRUNK_BLOODROSE_PLURAL": "자단나무",
|
||||
"TILE_STONE_QUARRIED": "캔 돌",
|
||||
"TILE_STONE_QUARRIED_PLURAL": "캔 돌",
|
||||
"TILE_SAND": "모래",
|
||||
"TILE_SAND_PLURAL": "모래",
|
||||
"TILE_GRAVEL": "자갈",
|
||||
"TILE_GRAVEL_PLURAL": "자갈",
|
||||
"TILE_ORE_MALACHITE": "공작석",
|
||||
"TILE_ORE_MALACHITES": "공작석",
|
||||
"TILE_ORE_HEMATITE": "적철석",
|
||||
"TILE_ORE_HEMATITE_PLURAL": "적철석",
|
||||
"TILE_ORE_NATURAL_GOLD": "자연금",
|
||||
"TILE_ORE_NATERAL_GOLD_PLURAL": "자연금",
|
||||
"TILE_ORE_NATURAL_SILVER": "자연은",
|
||||
"TILE_ORE_NATURAL_SILVER_PLURAL": "자연은",
|
||||
"TILE_ORE_RUTILE": "금홍석",
|
||||
"TILE_ORE_RUTILE_PLURAL": "금홍석",
|
||||
"TILE_ORE_AURICHALCUMITE": "진금석",
|
||||
"TILE_ORE_AURICHALCUMITE_PLURAL": "진금석",
|
||||
"TILE_GEM_RUBY": "홍옥석",
|
||||
"TILE_GEM_RUBY_PLURAL": "홍옥석",
|
||||
"TILE_GEM_EMERALD": "취옥석",
|
||||
"TILE_GEM_EMERALD_PLURAL": "취옥석",
|
||||
"TILE_GEM_SAPPHIRE": "청옥석",
|
||||
"TILE_GEM_SAPPHIRE_PLURAL": "청옥석",
|
||||
"TILE_GEM_TOPAZ": "황옥석",
|
||||
"TILE_GEM_TOPAZ_PLURAL": "황옥석",
|
||||
"TILE_GEM_DIAMOND": "금강석",
|
||||
"TILE_GEM_DIAMOND_PLURAL": "금강석",
|
||||
"TILE_GEM_AMETHYST": "자수정석",
|
||||
"TILE_GEM_AMETHYST_PLURAL": "자수정석",
|
||||
"TILE_SNOW": "눈",
|
||||
"TILE_SNOW_PLURAL": "눈",
|
||||
"TILE_ICE_FRAGILE": "살얼음",
|
||||
"TILE_ICE_FRAGILE_PLURAL": "살얼음",
|
||||
"TILE_ICE_NATURAL": "얼음",
|
||||
"TILE_ICE_NATURAL_PLURAL": "얼음",
|
||||
"TILE_ICE_CLEAR_MAGICAL": "깨끗한 얼음",
|
||||
"TILE_ICE_CLEAR_MAGICAL_PLURAL": "깨끗한 얼음",
|
||||
"TILE_PLATFORM_STONE": "돌 발판",
|
||||
"TILE_PLATFORM_STONE_PLURAL": "돌 발판",
|
||||
"TILE_PLATFORM_WOODEN": "나무 발판",
|
||||
"TILE_PLATFORM_WOODEN_PLURAL": "나무 발판",
|
||||
"TILE_PLATFORM_EBONY": "흑단 발판",
|
||||
"TILE_PLATFORM_EBONY_PLURAL": "흑단 발판",
|
||||
"TILE_PLATFORM_BIRCH": "백단 발판",
|
||||
"TILE_PLATFORM_BIRCH_PLURAL": "백단 발판",
|
||||
"TILE_PLATFORM_BLOODROSE": "적단 발판",
|
||||
"TILE_PLATFORM_BLOODROSE_PLURAL": "적단 발판",
|
||||
"TILE_TORCH": "횃불",
|
||||
"TILE_TORCH_PLURAL": "횃불",
|
||||
"TILE_WATER": "물",
|
||||
"TILE_WATER_PLURAL": "물",
|
||||
"TILE_LAVA": "용암",
|
||||
"TILE_LAVA_PLURAL": "용암"
|
||||
}
|
||||
@@ -25,10 +25,10 @@ class StateUITest : BasicGameState() {
|
||||
val inventory = ActorInventory()
|
||||
|
||||
init {
|
||||
ui = UIHandler(SimpleUI(inventory))
|
||||
ui = UIHandler(SimpleUI(inventory, 800, Terrarum.HEIGHT - 160))
|
||||
|
||||
ui.posX = 50
|
||||
ui.posY = 30
|
||||
ui.posX = 0
|
||||
ui.posY = 60
|
||||
ui.isVisible = true
|
||||
|
||||
|
||||
@@ -83,9 +83,11 @@ class StateUITest : BasicGameState() {
|
||||
|
||||
|
||||
|
||||
private class SimpleUI(val inventory: ActorInventory) : UICanvas {
|
||||
override var width = 700
|
||||
override var height = 480 // multiple of 40 (2 * font.lineHeight)
|
||||
private class SimpleUI(
|
||||
val inventory: ActorInventory,
|
||||
override var width: Int,
|
||||
override var height: Int
|
||||
) : UICanvas {
|
||||
override var handler: UIHandler? = null
|
||||
override var openCloseTime: Int = UICanvas.OPENCLOSE_GENERIC
|
||||
|
||||
@@ -93,6 +95,8 @@ private class SimpleUI(val inventory: ActorInventory) : UICanvas {
|
||||
|
||||
val catButtonsToCatIdent = HashMap<String, String>()
|
||||
|
||||
val backgroundColour = Color(0x1c1c1c)
|
||||
|
||||
init {
|
||||
catButtonsToCatIdent.put("GAME_INVENTORY_WEAPONS", InventoryItem.Category.WEAPON)
|
||||
catButtonsToCatIdent.put("CONTEXT_ITEM_TOOL_PLURAL", InventoryItem.Category.TOOL)
|
||||
@@ -109,7 +113,11 @@ private class SimpleUI(val inventory: ActorInventory) : UICanvas {
|
||||
|
||||
}
|
||||
|
||||
val buttons = UIItemTextButtonList(
|
||||
val itemStripGutterV = 6
|
||||
val itemStripGutterH = 8
|
||||
val itemInterColGutter = 8
|
||||
|
||||
val catButtons = UIItemTextButtonList(
|
||||
this,
|
||||
arrayOf(
|
||||
"MENU_LABEL_ALL",
|
||||
@@ -126,31 +134,35 @@ private class SimpleUI(val inventory: ActorInventory) : UICanvas {
|
||||
),
|
||||
width = (width / 3 / 100) * 100, // chop to hundreds unit (100, 200, 300, ...) with the black magic of integer division
|
||||
height = height,
|
||||
verticalGutter = itemStripGutterH,
|
||||
readFromLang = true,
|
||||
textAreaWidth = 100,
|
||||
defaultSelection = 0,
|
||||
iconSpriteSheet = SpriteSheet("./assets/graphics/gui/inventory/category.tga", 20, 20),
|
||||
iconSpriteSheetIndices = intArrayOf(9,0,1,2,3,4,5,6,7,8),
|
||||
highlightBackCol = Color(0x202020),
|
||||
highlightBackCol = backgroundColour screen Color(0x0c0c0c),
|
||||
highlightBackBlendMode = BlendMode.NORMAL,
|
||||
backgroundCol = Color(0x383838),
|
||||
kinematic = true
|
||||
)
|
||||
|
||||
val itemStripGutterV = 10
|
||||
val itemStripGutterH = 48
|
||||
|
||||
val itemsStripWidth = width - buttons.width - 2 * itemStripGutterH
|
||||
val items = Array(height / (UIItemInventoryElem.height + itemStripGutterV), { UIItemInventoryElem(
|
||||
parentUI = this,
|
||||
posX = buttons.width + itemStripGutterH,
|
||||
posY = it * (UIItemInventoryElem.height + itemStripGutterV),
|
||||
width = itemsStripWidth,
|
||||
item = null,
|
||||
amount = UIItemInventoryElem.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
||||
itemImage = null,
|
||||
backCol = Color(255, 255, 255, 0x30)
|
||||
) })
|
||||
val itemsStripWidth = ((width - catButtons.width) - (2 * itemStripGutterH + itemInterColGutter)) / 2
|
||||
val items = Array(
|
||||
2 + height / (UIItemInventoryElem.height + itemStripGutterV) * 2, {
|
||||
UIItemInventoryElem(
|
||||
parentUI = this,
|
||||
posX = catButtons.width + if (it % 2 == 0) itemStripGutterH else (itemStripGutterH + itemsStripWidth + itemInterColGutter),
|
||||
posY = itemStripGutterH + it / 2 * (UIItemInventoryElem.height + itemStripGutterV),
|
||||
width = itemsStripWidth,
|
||||
item = null,
|
||||
amount = UIItemInventoryElem.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
||||
itemImage = null,
|
||||
mouseoverBackCol = Color(0x282828),
|
||||
mouseoverBackBlendMode = BlendMode.SCREEN,
|
||||
drawBackOnNull = false
|
||||
//backCol = Color(0x101010),
|
||||
//backBlendMode = BlendMode.SCREEN
|
||||
) })
|
||||
val itemsScrollOffset = 0
|
||||
|
||||
var inventorySortList = ArrayList<InventoryPair>()
|
||||
@@ -159,19 +171,19 @@ private class SimpleUI(val inventory: ActorInventory) : UICanvas {
|
||||
private var oldCatSelect = -1
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
Terrarum.gameLocale = "fiFI" // hot swap this to test
|
||||
Terrarum.gameLocale = "koKR" // hot swap this to test
|
||||
|
||||
buttons.update(gc, delta)
|
||||
catButtons.update(gc, delta)
|
||||
|
||||
|
||||
// monitor and check if category selection has been changed
|
||||
if (oldCatSelect != buttons.selectedIndex) {
|
||||
if (oldCatSelect != catButtons.selectedIndex) {
|
||||
rebuildList = true
|
||||
}
|
||||
|
||||
|
||||
if (rebuildList) {
|
||||
val filter = catButtonsToCatIdent[buttons.selectedButton.labelText]
|
||||
val filter = catButtonsToCatIdent[catButtons.selectedButton.labelText]
|
||||
|
||||
inventorySortList = ArrayList<InventoryPair>()
|
||||
|
||||
@@ -207,14 +219,14 @@ private class SimpleUI(val inventory: ActorInventory) : UICanvas {
|
||||
}
|
||||
|
||||
|
||||
oldCatSelect = buttons.selectedIndex
|
||||
oldCatSelect = catButtons.selectedIndex
|
||||
}
|
||||
|
||||
override fun render(gc: GameContainer, g: Graphics) {
|
||||
g.color = Color(0x202020)
|
||||
g.color = backgroundColour
|
||||
g.fillRect(0f, 0f, width.toFloat(), height.toFloat())
|
||||
|
||||
buttons.render(gc, g)
|
||||
catButtons.render(gc, g)
|
||||
|
||||
|
||||
items.forEach {
|
||||
@@ -240,4 +252,4 @@ private class SimpleUI(val inventory: ActorInventory) : UICanvas {
|
||||
override fun endClosing(gc: GameContainer, delta: Int) {
|
||||
UICanvas.endClosingFade(handler)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -635,3 +635,10 @@ operator fun Color.times(other: Color) = Color(
|
||||
this.b * other.b,
|
||||
this.a * other.a
|
||||
)
|
||||
|
||||
operator fun Color.minus(other: Color) = Color(
|
||||
this.r - other.r,
|
||||
this.g - other.g,
|
||||
this.b - other.b,
|
||||
this.a - other.a
|
||||
)
|
||||
|
||||
@@ -23,10 +23,13 @@ class UIItemInventoryElem(
|
||||
var item: InventoryItem?,
|
||||
var amount: Int,
|
||||
var itemImage: Image?,
|
||||
val mouseoverBackCol: Color = Color(0,0,0,0),
|
||||
val mouseoverBackBlendMode: String = BlendMode.NORMAL,
|
||||
val backCol: Color = Color(0,0,0,0),
|
||||
val backColBlendMode: String = BlendMode.NORMAL,
|
||||
val backBlendMode: String = BlendMode.NORMAL,
|
||||
var quickslot: Int? = null,
|
||||
var equippedSlot: Int? = null
|
||||
var equippedSlot: Int? = null,
|
||||
val drawBackOnNull: Boolean = true
|
||||
) : UIItem(parentUI) {
|
||||
|
||||
companion object {
|
||||
@@ -38,7 +41,7 @@ class UIItemInventoryElem(
|
||||
|
||||
private val imgOffset: Float
|
||||
get() = (this.height - itemImage!!.height).div(2).toFloat() // to snap to the pixel grid
|
||||
private val textOffsetX = 52f
|
||||
private val textOffsetX = 50f
|
||||
private val textOffsetY = 8f
|
||||
|
||||
|
||||
@@ -55,17 +58,23 @@ class UIItemInventoryElem(
|
||||
}
|
||||
|
||||
override fun render(gc: GameContainer, g: Graphics) {
|
||||
if (item != null && itemImage != null) {
|
||||
g.font = Terrarum.fontGame
|
||||
|
||||
g.font = Terrarum.fontGame
|
||||
|
||||
if (item != null || drawBackOnNull) {
|
||||
if (mouseUp) {
|
||||
BlendMode.resolve(backColBlendMode)
|
||||
g.color = backCol
|
||||
g.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
||||
BlendMode.resolve(mouseoverBackBlendMode)
|
||||
g.color = mouseoverBackCol
|
||||
}
|
||||
else {
|
||||
BlendMode.resolve(backBlendMode)
|
||||
g.color = backCol
|
||||
}
|
||||
g.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
||||
}
|
||||
|
||||
|
||||
if (item != null && itemImage != null) {
|
||||
blendNormal()
|
||||
|
||||
g.drawImage(itemImage!!, posX + imgOffset, posY + imgOffset)
|
||||
@@ -80,7 +89,7 @@ class UIItemInventoryElem(
|
||||
|
||||
|
||||
// durability metre
|
||||
val barFullLen = (width - 20f) - textOffsetX
|
||||
val barFullLen = (width - 8f) - textOffsetX
|
||||
val barOffset = posX + textOffsetX
|
||||
if (item!!.maxDurability > 0.0) {
|
||||
g.color = durabilityBack
|
||||
|
||||
@@ -99,7 +99,7 @@ object TilePropCSV {
|
||||
"15"; "2";"TILE_SANDSTONE_RED" ; "33587232"; "25";"1900";"rock"; "0"; "1"; "1"; "0"; "15"; "2"; "0"; "0"; "N/A"; "0";"16"
|
||||
"15"; "3";"TILE_SANDSTONE_DESERT" ; "33587232"; "25";"1900";"rock"; "0"; "1"; "1"; "0"; "15"; "3"; "0"; "0"; "N/A"; "0";"16"
|
||||
"15"; "4";"TILE_SANDSTONE_BLACK" ; "33587232"; "25";"1900";"rock"; "0"; "1"; "1"; "0"; "15"; "4"; "0"; "0"; "N/A"; "0";"16"
|
||||
"15"; "5";"TILE_SANDSTONE_BLACK" ; "33587232"; "25";"1900";"rock"; "0"; "1"; "1"; "0"; "15"; "5"; "0"; "0"; "N/A"; "0";"16"
|
||||
"15"; "5";"TILE_SANDSTONE_GREEN" ; "33587232"; "25";"1900";"rock"; "0"; "1"; "1"; "0"; "15"; "5"; "0"; "0"; "N/A"; "0";"16"
|
||||
"16"; "0";"TILE_LANTERN_IRON_REGULAR"; "8396808"; "0"; "N/A";"fxtr"; "0"; "0"; "0"; "267553792"; "16"; "0"; "0"; "0"; "N/A"; "0";"16"
|
||||
"16"; "1";"TILE_SUNSTONE" ; "33587232"; "0"; "N/A";"rock"; "0"; "1"; "0"; "0"; "16"; "1"; "0"; "2"; "N/A"; "0";"16"
|
||||
"16"; "2";"TILE_DAYLIGHT_CAPACITOR" ; "33587232"; "0"; "N/A";"glas"; "0"; "1"; "0"; "0"; "16"; "2"; "0"; "3"; "N/A"; "0";"16"
|
||||
|
||||
@@ -18,6 +18,7 @@ class UIItemTextButtonList(
|
||||
labelsList: Array<String>,
|
||||
override val width: Int,
|
||||
override val height: Int,
|
||||
val verticalGutter: Int = 0,
|
||||
val readFromLang: Boolean = false,
|
||||
val defaultSelection: Int = 0,
|
||||
|
||||
@@ -27,13 +28,13 @@ class UIItemTextButtonList(
|
||||
val iconSpriteSheetIndices: IntArray? = null,
|
||||
|
||||
// copied directly from UIItemTextButton
|
||||
val activeCol: Color = Color.white,
|
||||
val activeCol: Color = Color(0xffffff),
|
||||
val activeBackCol: Color = Color(0,0,0,0),
|
||||
val activeBackBlendMode: String = BlendMode.NORMAL,
|
||||
val highlightCol: Color = Color(0x00f8ff),
|
||||
val highlightBackCol: Color = Color(0xb0b0b0),
|
||||
val highlightBackBlendMode: String = BlendMode.MULTIPLY,
|
||||
val inactiveCol: Color = Color(0xc8c8c8),
|
||||
val inactiveCol: Color = Color(0xc0c0c0),
|
||||
val backgroundCol: Color = Color(0,0,0,0),
|
||||
val backgroundBlendMode: String = BlendMode.NORMAL,
|
||||
val kinematic: Boolean = false // more "kinetic" movement of selector
|
||||
@@ -54,7 +55,7 @@ class UIItemTextButtonList(
|
||||
UIItemTextButton(
|
||||
parentUI, s,
|
||||
posX = 0,
|
||||
posY = (height / labelsList.size.minus(1).toFloat() * index).roundInt(),
|
||||
posY = verticalGutter + ((height - 2 * verticalGutter) / labelsList.size.minus(1).toFloat() * index).roundInt(),
|
||||
width = width,
|
||||
readFromLang = readFromLang,
|
||||
activeCol = activeCol,
|
||||
@@ -72,12 +73,16 @@ class UIItemTextButtonList(
|
||||
UIItemTextButton(
|
||||
parentUI, s,
|
||||
posX = 0,
|
||||
posY = (height / labelsList.size.minus(1).toFloat() * index).roundInt(),
|
||||
posY = verticalGutter + ((height - 2 * verticalGutter) / labelsList.size.minus(1).toFloat() * index).roundInt(),
|
||||
width = width,
|
||||
readFromLang = readFromLang,
|
||||
activeBackCol = Color(0,0,0,0),
|
||||
activeBackBlendMode = BlendMode.NORMAL,
|
||||
highlightBackCol = Color(0,0,0,0),
|
||||
activeCol = activeCol,
|
||||
activeBackCol = activeBackCol,
|
||||
activeBackBlendMode = activeBackBlendMode,
|
||||
highlightCol = highlightCol,
|
||||
highlightBackCol = activeBackCol, // we are using custom highlighter
|
||||
highlightBackBlendMode = activeBackBlendMode, // we are using custom highlighter
|
||||
inactiveCol = inactiveCol,
|
||||
preGapX = pregap,
|
||||
postGapX = postgap
|
||||
)
|
||||
@@ -157,6 +162,8 @@ class UIItemTextButtonList(
|
||||
}
|
||||
}
|
||||
|
||||
g.color = backgroundCol
|
||||
|
||||
}
|
||||
|
||||
override fun keyPressed(key: Int, c: Char) {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 155 KiB After Width: | Height: | Size: 146 KiB |
Reference in New Issue
Block a user