mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
control helpers for smelter
This commit is contained in:
@@ -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"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
3
assets/mods/basegame/locales/en/polyglot_overwrites.json
Normal file
3
assets/mods/basegame/locales/en/polyglot_overwrites.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"GAME_INVENTORY_DROP": "Toss" /* overwrites Polyglot; please don't include this line for translation */
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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": "一つ取る"
|
||||
}
|
||||
@@ -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": "제작",
|
||||
|
||||
@@ -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": "하나 가져가기"
|
||||
}
|
||||
@@ -87,4 +87,5 @@ object ControlPresets {
|
||||
|
||||
return (presets[presetName] ?: throw IllegalStateException("No such keyboard preset: $presetName")).getOrDefault(label, App.getConfigInt(label))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,10 @@ object UIItemInventoryCellCommonRes {
|
||||
Toolkit.Theme.COL_CELL_FILL
|
||||
)
|
||||
|
||||
/**
|
||||
* Special hash values:
|
||||
* - 10001: Encumbrance bar
|
||||
*/
|
||||
val tooltipShowing = HashMap<Long, Boolean>() // Long: `hash` field on UIItemInventoryItemGrid
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user