diff --git a/assets/mods/basegame/locales/daDK/game.json b/assets/mods/basegame/locales/daDK/game.json index 502102bed..a322efcfa 100644 --- a/assets/mods/basegame/locales/daDK/game.json +++ b/assets/mods/basegame/locales/daDK/game.json @@ -4,5 +4,6 @@ "CONTEXT_WORLD_COUNT": "Verdener: ", "CONTEXT_ITEM_MAP": "Kort", "MENU_LABEL_MENU": "Menu", - "GAME_INVENTORY_REGISTER": "Registrer" + "GAME_INVENTORY_REGISTER": "Registrer", + "GAME_ACTION_SELECT_SLOT": "Vælg Slot" } \ No newline at end of file diff --git a/assets/mods/basegame/locales/daDK/inventory_control_helper.json b/assets/mods/basegame/locales/daDK/inventory_control_helper.json new file mode 100644 index 000000000..2d84ce6c2 --- /dev/null +++ b/assets/mods/basegame/locales/daDK/inventory_control_helper.json @@ -0,0 +1,11 @@ +{ + "GAME_ACTION_PUT_ALL": "Sæt Hele", + "GAME_ACTION_PUT_ONE": "Sæt En", + "GAME_ACTION_TAKE_ALL": "Tag Hele", + "GAME_ACTION_TAKE_ONE": "Tag En", + + "GAME_ACTION_PUT_ALL_CONT": "Sæt Hele", + "GAME_ACTION_PUT_ONE_CONT": "En", + "GAME_ACTION_TAKE_ALL_CONT": "Tag Hele", + "GAME_ACTION_TAKE_ONE_CONT": "En" +} \ No newline at end of file diff --git a/assets/mods/basegame/locales/en/game.json b/assets/mods/basegame/locales/en/game.json index b3aba216c..b16bbda8a 100644 --- a/assets/mods/basegame/locales/en/game.json +++ b/assets/mods/basegame/locales/en/game.json @@ -14,11 +14,12 @@ "MENU_LABEL_USE_CODE": "Use Code", "MENU_MODE_BUILDINGMAKER": "POI Editor", "MENU_MONITOR_CALI_TITLE": "Check Monitor", - "MENU_OPTIONS_SHOW_ORES_TOOLTIP_WHEN_MINING": "Show Ores Tooltip When Mining", - "MENU_OPTIONS_MAX_CRAFTING": "Max Number of Items For Crafting", + "MENU_OPTIONS_SHOW_ORES_TOOLTIP_WHEN_MINING": "Show Ore Tooltip When Mining", + "MENU_OPTIONS_MAX_CRAFTING": "Max Number of Items for Crafting", "MENU_UPDATE_UPDATE_AVAILABLE": "Update Available!", "GAME_ACTION_GRAPPLE": "Grapple", "GAME_ACTION_QUICKSEL": "Quick Select", + "GAME_ACTION_SELECT_SLOT": "Select Slot", "GAME_ACTION_TELEPORT": "Teleport", "GAME_CRAFTABLE_ITEMS": "Craftable Items", "GAME_CRAFTING": "Crafting", @@ -27,7 +28,5 @@ "GAME_INVENTORY_INGREDIENTS": "Ingredients", "GAME_INVENTORY_POTIONS": "Potions", "GAME_INVENTORY_REGISTER": "Register", - "GAME_INVENTORY_WALLS": "Walls", - - "GAME_INVENTORY_DROP": "Toss" /* overwrites Polyglot; please don't include this line for translation */ + "GAME_INVENTORY_WALLS": "Walls" } \ No newline at end of file diff --git a/assets/mods/basegame/locales/en/inventory_control_helper.json b/assets/mods/basegame/locales/en/inventory_control_helper.json new file mode 100644 index 000000000..70d26db70 --- /dev/null +++ b/assets/mods/basegame/locales/en/inventory_control_helper.json @@ -0,0 +1,11 @@ +{ + "GAME_ACTION_PUT_ALL": "Put All", + "GAME_ACTION_PUT_ONE": "Put One", + "GAME_ACTION_TAKE_ALL": "Take All", + "GAME_ACTION_TAKE_ONE": "Take One", + + "GAME_ACTION_PUT_ALL_CONT": "Put All", + "GAME_ACTION_PUT_ONE_CONT": "One", + "GAME_ACTION_TAKE_ALL_CONT": "Take All", + "GAME_ACTION_TAKE_ONE_CONT": "One" +} \ No newline at end of file diff --git a/assets/mods/basegame/locales/en/polyglot_overwrites.json b/assets/mods/basegame/locales/en/polyglot_overwrites.json new file mode 100644 index 000000000..bad258fce --- /dev/null +++ b/assets/mods/basegame/locales/en/polyglot_overwrites.json @@ -0,0 +1,3 @@ +{ + "GAME_INVENTORY_DROP": "Toss" /* overwrites Polyglot; please don't include this line for translation */ +} \ No newline at end of file diff --git a/assets/mods/basegame/locales/fiFI/inventory_control_helper.json b/assets/mods/basegame/locales/fiFI/inventory_control_helper.json new file mode 100644 index 000000000..ca64fa81c --- /dev/null +++ b/assets/mods/basegame/locales/fiFI/inventory_control_helper.json @@ -0,0 +1,11 @@ +{ + "GAME_ACTION_PUT_ALL": "Laita Kaikki", + "GAME_ACTION_PUT_ONE": "Laita Yksi", + "GAME_ACTION_TAKE_ALL": "Ota Kaikki", + "GAME_ACTION_TAKE_ONE": "Ota Yksi", + + "GAME_ACTION_PUT_ALL_CONT": "Laita Kaikki", + "GAME_ACTION_PUT_ONE_CONT": "Yksi", + "GAME_ACTION_TAKE_ALL_CONT": "Ota Kaikki", + "GAME_ACTION_TAKE_ONE_CONT": "Yksi" +} \ No newline at end of file diff --git a/assets/mods/basegame/locales/jaJP/inventory_control_helper.json b/assets/mods/basegame/locales/jaJP/inventory_control_helper.json new file mode 100644 index 000000000..9db0abf74 --- /dev/null +++ b/assets/mods/basegame/locales/jaJP/inventory_control_helper.json @@ -0,0 +1,11 @@ +{ + "GAME_ACTION_PUT_ALL": "全て入れる", + "GAME_ACTION_PUT_ONE": "一つ入れる", + "GAME_ACTION_TAKE_ALL": "全て取る", + "GAME_ACTION_TAKE_ONE": "一つ取る", + + "GAME_ACTION_PUT_ALL_CONT": "全て", + "GAME_ACTION_PUT_ONE_CONT": "一つ入れる", + "GAME_ACTION_TAKE_ALL_CONT": "全て", + "GAME_ACTION_TAKE_ONE_CONT": "一つ取る" +} \ No newline at end of file diff --git a/assets/mods/basegame/locales/koKR/game.json b/assets/mods/basegame/locales/koKR/game.json index dc96555a4..7b21c9f9b 100644 --- a/assets/mods/basegame/locales/koKR/game.json +++ b/assets/mods/basegame/locales/koKR/game.json @@ -18,6 +18,7 @@ "MENU_UPDATE_UPDATE_AVAILABLE": "새 업데이트가 있습니다!", "GAME_ACTION_GRAPPLE": "매달리기", "GAME_ACTION_QUICKSEL": "빠른 선택", + "GAME_ACTION_SELECT_SLOT": "슬롯 선택", "GAME_ACTION_TELEPORT": "텔레포트하기", "GAME_CRAFTABLE_ITEMS": "제작 가능한 아이템", "GAME_CRAFTING": "제작", diff --git a/assets/mods/basegame/locales/koKR/inventory_control_helper.json b/assets/mods/basegame/locales/koKR/inventory_control_helper.json new file mode 100644 index 000000000..296d43eff --- /dev/null +++ b/assets/mods/basegame/locales/koKR/inventory_control_helper.json @@ -0,0 +1,11 @@ +{ + "GAME_ACTION_PUT_ALL": "모두 넣기", + "GAME_ACTION_PUT_ONE": "하나 넣기", + "GAME_ACTION_TAKE_ALL": "모두 가져가기", + "GAME_ACTION_TAKE_ONE": "하나 가져가기", + + "GAME_ACTION_PUT_ALL_CONT": "모두", + "GAME_ACTION_PUT_ONE_CONT": "하나 넣기", + "GAME_ACTION_TAKE_ALL_CONT": "모두", + "GAME_ACTION_TAKE_ONE_CONT": "하나 가져가기" +} \ No newline at end of file diff --git a/src/net/torvald/terrarum/ControlPresets.kt b/src/net/torvald/terrarum/ControlPresets.kt index 35c71e781..9689eb353 100644 --- a/src/net/torvald/terrarum/ControlPresets.kt +++ b/src/net/torvald/terrarum/ControlPresets.kt @@ -87,4 +87,5 @@ object ControlPresets { return (presets[presetName] ?: throw IllegalStateException("No such keyboard preset: $presetName")).getOrDefault(label, App.getConfigInt(label)) } + } \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIInventoryCells.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIInventoryCells.kt index ed736d9ad..d59c3be6b 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIInventoryCells.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIInventoryCells.kt @@ -67,15 +67,14 @@ internal class UIInventoryCells( min(UIInventoryCells.weightBarWidth, max(1f, UIInventoryCells.weightBarWidth * encumbrancePerc)), UIInventoryFull.controlHelpHeight - 6f ) - // debug text - batch.color = Color.LIGHT_GRAY - if (App.IS_DEVELOPMENT_BUILD) { - App.fontSmallNumbers.draw( - batch, - "${actorInventory.capacity}/${actorInventory.maxCapacity}", - encumbBarTextXPos, - encumbBarYPos + UIInventoryFull.controlHelpHeight - 4f - ) + + // tooltip + if (Terrarum.mouseScreenX.toFloat() in encumbBarXPos..encumbBarXPos+UIInventoryCells.weightBarWidth && Terrarum.mouseScreenY.toFloat() in encumbBarYPos..encumbBarYPos+UIInventoryFull.controlHelpHeight - 6f) { + INGAME.setTooltipMessage("${actorInventory.capacity}/${actorInventory.maxCapacity}") + tooltipShowing[10001] = true + } + else { + tooltipShowing[10001] = false } } } diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryCellBase.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryCellBase.kt index aefed4933..ed7ce8e05 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryCellBase.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryCellBase.kt @@ -114,6 +114,10 @@ object UIItemInventoryCellCommonRes { Toolkit.Theme.COL_CELL_FILL ) + /** + * Special hash values: + * - 10001: Encumbrance bar + */ val tooltipShowing = HashMap() // Long: `hash` field on UIItemInventoryItemGrid } diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UISmelterBasic.kt b/src/net/torvald/terrarum/modulebasegame/ui/UISmelterBasic.kt index 2e9ea90f9..25684c5a8 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UISmelterBasic.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UISmelterBasic.kt @@ -17,6 +17,7 @@ import net.torvald.terrarum.ui.UIItemCatBar.Companion.FILTER_CAT_ALL import net.torvald.terrarum.ui.UIItemInventoryElemWide.Companion.UNIQUE_ITEM_HAS_NO_AMOUNT import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.unicode.getKeycapPC +import net.torvald.unicode.getMouseButton import kotlin.math.roundToInt import kotlin.math.roundToLong @@ -189,6 +190,13 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas( emptyCellIcon = smelterCellIcons.get(1, 0), keyDownFun = { _, _, _, _, _ -> }, touchDownFun = { _, _, button, _, self -> + if (clickedOn != 0) { + clickedOn = 0 + oreItemSlot.forceHighlighted = false + fireboxItemSlot.forceHighlighted = false + itemListUpdate() + } + if (smelter.productItem != null) { val removeCount = if (button == App.getConfigInt("config_mouseprimary")) smelter.productItem!!.qty @@ -287,11 +295,46 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas( return true } - private val controlHelp: String - get() = if (App.environment == RunningEnvironment.PC) - "${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}" + private val SP = "\u3000" + private val controlHelpForSmelter = listOf( + // no slot selected + { if (App.environment == RunningEnvironment.PC) + "${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" + + "${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_SELECT_SLOT"]}" else - "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" + "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }, + // ore slot + { if (App.environment == RunningEnvironment.PC) + "${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" + + "${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" + + "${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}" + else + "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }, + // firebox slot + { if (App.environment == RunningEnvironment.PC) + "${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" + + "${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" + + "${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}" + else + "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" } + ) + + private val controlHelpForInventory = listOf( + // no slot selected + { "" }, + // ore slot + { if (App.environment == RunningEnvironment.PC) + "${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" + + "${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE_CONT"]}" + else + "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }, + // firebox slot + { if (App.environment == RunningEnvironment.PC) + "${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" + + "${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE_CONT"]}" + else + "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" } + ) override fun renderUI(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) { batch.color = backdropColour @@ -307,14 +350,30 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas( // control hints batch.color = Color.WHITE val controlHintXPos = leftPanelX + 2f + val controlHintXPos2 = playerThings.posX + 2f blendNormalStraightAlpha(batch) - App.fontGame.draw(batch, controlHelp, controlHintXPos, UIInventoryFull.yEnd - 20) + App.fontGame.draw(batch, controlHelpForSmelter[clickedOn](), controlHintXPos, UIInventoryFull.yEnd - 20) + + // deal with the text that is too long + val encumbBarXPos = playerThings.posX + playerThings.width - UIInventoryCells.weightBarWidth + 36 + val encumbBarYPos = UIInventoryFull.yEnd - 20 + 3f + + val tr = controlHelpForInventory[clickedOn]() + val trLen = App.fontGame.getWidth(tr) + val encumbTextX = encumbBarXPos - 6 - App.fontGame.getWidth(Lang["GAME_INVENTORY_ENCUMBRANCE"]) + if (controlHintXPos2 + trLen + 4 >= encumbTextX) { + tr.split(SP).forEachIndexed { index, s -> + App.fontGame.draw(batch, s, controlHintXPos2, UIInventoryFull.yEnd - 20 + 20 * index) + } + } + else { + App.fontGame.draw(batch, controlHelpForInventory[clickedOn](), controlHintXPos2, 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) } diff --git a/src/net/torvald/unicode/UniTextShortcuts.kt b/src/net/torvald/unicode/UniTextShortcuts.kt index d4a4f0b07..3706e773f 100644 --- a/src/net/torvald/unicode/UniTextShortcuts.kt +++ b/src/net/torvald/unicode/UniTextShortcuts.kt @@ -71,6 +71,13 @@ fun getKeycapPC(c: Char) = when (c.uppercaseChar()) { else -> throw IllegalArgumentException("Not in range: ${c.code - 32}") } fun getKeycapPC(keycode: Int) = getKeycapPC(com.badlogic.gdx.Input.Keys.toString(keycode)[0]) +fun getMouseButton(button: Int) = when (button) { + 0 -> KEYCAP_LEFT_MOUSE + 1 -> KEYCAP_RIGHT_MOUSE + 2 -> KEYCAP_WHEEL + else -> throw IllegalArgumentException("Unknown mouse button: $button") +} + fun getKeycapConsole(c: Char) = when (c.uppercaseChar()) { in ' '..'_' -> (0xE040 + c.code - 32).toChar() else -> throw IllegalArgumentException("Not in range: ${c.code - 32}")