control preset to be stored into separate file

This commit is contained in:
minjaesong
2026-02-07 16:19:42 +09:00
parent e838991826
commit 068d0bf1b2
22 changed files with 336 additions and 87 deletions

View File

@@ -35,9 +35,9 @@ object SmelterGuiEventBuilder {
): (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit { return { gameItem: GameItem?, amount: Long, mouseButton: Int, itemExtraInfo: Any?, theButton: UIItemInventoryCellBase ->
val playerInventory = getPlayerInventory()
val amount = if (mouseButton == App.getConfigInt("config_mouseprimary"))
val amount = if (mouseButton == App.getConfigInt("control_mouse_primary"))
amount
else if (mouseButton == App.getConfigInt("config_mousesecondary"))
else if (mouseButton == App.getConfigInt("control_mouse_secondary"))
1
else
null
@@ -175,9 +175,9 @@ object SmelterGuiEventBuilder {
itemListUpdate { oreItemFilter(it.itm) }
}
else if (oreItemStatus.isNotNull()) {
val removeCount = if (mouseButton == App.getConfigInt("config_mouseprimary"))
val removeCount = if (mouseButton == App.getConfigInt("control_mouse_primary"))
oreItemStatus.qty
else if (mouseButton == App.getConfigInt("config_mousesecondary"))
else if (mouseButton == App.getConfigInt("control_mouse_secondary"))
1L
else
null
@@ -254,9 +254,9 @@ object SmelterGuiEventBuilder {
itemListUpdate { ItemCodex.hasTag(it.itm, "COMBUSTIBLE") }
}
else if (fireboxItemStatus.isNotNull()) {
val removeCount = if (mouseButton == App.getConfigInt("config_mouseprimary"))
val removeCount = if (mouseButton == App.getConfigInt("control_mouse_primary"))
fireboxItemStatus.qty
else if (mouseButton == App.getConfigInt("config_mousesecondary"))
else if (mouseButton == App.getConfigInt("control_mouse_secondary"))
1L
else
null
@@ -333,9 +333,9 @@ object SmelterGuiEventBuilder {
}
if (productItemStatus.isNotNull()) {
val removeCount = if (mouseButton == App.getConfigInt("config_mouseprimary"))
val removeCount = if (mouseButton == App.getConfigInt("control_mouse_primary"))
productItemStatus.qty
else if (mouseButton == App.getConfigInt("config_mousesecondary"))
else if (mouseButton == App.getConfigInt("control_mouse_secondary"))
1L
else
null

View File

@@ -260,8 +260,8 @@ class UIAlloyingFurnace(val smelter: FixtureAlloyingFurnace) : UICanvas(
}
private val SP = "\u3000"
private val ML = getMouseButton(App.getConfigInt("config_mouseprimary"))
private val MR = getMouseButton(App.getConfigInt("config_mousesecondary"))
private val ML = getMouseButton(App.getConfigInt("control_mouse_primary"))
private val MR = getMouseButton(App.getConfigInt("control_mouse_secondary"))
private val MW = getMouseButton(2)
private val controlHelpForSmelter = listOf(
// no slot selected

View File

@@ -150,7 +150,7 @@ open class UIItemInventoryItemGrid(
fun createInvCellGenericTouchDownFun(listRebuildFun: () -> Unit): (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit {
return { item: GameItem?, amount: Long, button: Int, _, _ ->
if (button == App.getConfigInt("config_mouseprimary")) {
if (button == App.getConfigInt("control_mouse_primary")) {
if (item != null && Terrarum.ingame != null) {
// equip da shit
val itemEquipSlot = item.equipPosition

View File

@@ -61,7 +61,7 @@ class UIJukeboxInventory(val parent: UIJukebox) : UICanvas() {
init {
fixtureDiscCell.forEachIndexed { index, thisButton ->
thisButton.touchDownFun = { gameItem, amount, mouseButton, _, _ ->
if (operatedByTheInstaller && mouseButton == App.getConfigInt("config_mouseprimary")) {
if (operatedByTheInstaller && mouseButton == App.getConfigInt("control_mouse_primary")) {
if (gameItem != null) {
// if the disc being removed is the same disc being played, stop the playback
if (index == parent.parent.discCurrentlyPlaying) {
@@ -175,7 +175,7 @@ class UIJukeboxSonglistPanel(val parent: UIJukebox) : UICanvas() {
colourTheme = songButtonColourTheme,
keyDownFun = { _, _, _ -> Unit },
touchDownFun = { index, button, _ ->
if (button == App.getConfigInt("config_mouseprimary") && !parent.parent.musicIsPlaying) {
if (button == App.getConfigInt("control_mouse_primary") && !parent.parent.musicIsPlaying) {
parent.parent.playDisc(index)
}
}

View File

@@ -139,7 +139,8 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
}*/
presetSelector.selectionChangeListener = { index ->
App.setConfig("control_preset_keyboard", ControlPresets.presetLabels[index])
ControlPresetConfig.set("control_preset_keyboard", ControlPresets.presetLabels[index])
ControlPresetConfig.save()
updateKeycaps()
}
@@ -163,8 +164,11 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
"control_key_crafting",
"control_key_discard",
).forEach {
App.setConfig(it, DefaultConfig.hashMap[it]!! as Int)
// Reset to ESDF defaults (matches ControlPresetConfig defaults)
val defaultKey = ControlPresets.esdf[it] ?: return@forEach
ControlPresetConfig.set(it, defaultKey)
}
ControlPresetConfig.save()
}
private fun updateKeycaps() {
@@ -243,18 +247,19 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
}
fun setControlOf(key: Int, control: Int) {
if (App.getConfigString("control_preset_keyboard") != "Custom") {
System.err.println("[UIKeyboardControlPanel] cannot set a control if the preset is not 'Custom' (current preset: ${App.getConfigString("control_preset_keyboard")})")
if (ControlPresetConfig.getString("control_preset_keyboard") != "Custom") {
System.err.println("[UIKeyboardControlPanel] cannot set a control if the preset is not 'Custom' (current preset: ${ControlPresetConfig.getString("control_preset_keyboard")})")
return
}
if (control >= 0) {
val controlName = UIItemControlPaletteBaloon.indexToConfigKey[control]!!
val conflicts = App.gameConfig.keySet.filter {
// Check for conflicts in ControlPresetConfig
val conflicts = ControlPresetConfig.keySet.filter {
(it as String).startsWith("control_key_")
}.map {
(it as String).let { it to
try { (App.getConfigInt(it) == key) }
try { (ControlPresetConfig.getInt(it) == key) }
catch (_: ClassCastException) { false }
}
}.filter { it.second }.map { it.first }.firstOrNull()
@@ -262,13 +267,14 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
println("[UIKeyboardControlPanel] key=$key, control=$controlName")
if (conflicts != null) {
val oldValue = App.getConfigInt(controlName)
App.setConfig(conflicts, oldValue)
val oldValue = ControlPresetConfig.getInt(controlName)
ControlPresetConfig.set(conflicts, oldValue)
println("[UIKeyboardControlPanel] set config $conflicts=$oldValue")
}
App.setConfig(controlName, key)
ControlPresetConfig.set(controlName, key)
ControlPresetConfig.save()
println("[UIKeyboardControlPanel] set config $controlName=$key")
}
updateKeycaps()

View File

@@ -246,8 +246,8 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
}
private val SP = "\u3000"
private val ML = getMouseButton(App.getConfigInt("config_mouseprimary"))
private val MR = getMouseButton(App.getConfigInt("config_mousesecondary"))
private val ML = getMouseButton(App.getConfigInt("control_mouse_primary"))
private val MR = getMouseButton(App.getConfigInt("control_mouse_secondary"))
private val MW = getMouseButton(2)
private val controlHelpForSmelter = listOf(
// no slot selected

View File

@@ -97,9 +97,9 @@ internal class UIStorageChest : UICanvas(
itemListChest = UITemplateHalfInventory(this, true, { getFixtureInventory() }, { chestNameFun() }).also {
it.itemListKeyDownFun = { _, _, _, _, _ -> Unit }
it.itemListTouchDownFun = { gameItem, amount, button, _, _ ->
val amount = if (button == App.getConfigInt("config_mouseprimary"))
val amount = if (button == App.getConfigInt("control_mouse_primary"))
amount
else if (button == App.getConfigInt("config_mousesecondary"))
else if (button == App.getConfigInt("control_mouse_secondary"))
1
else
null
@@ -137,9 +137,9 @@ internal class UIStorageChest : UICanvas(
itemListPlayer = UITemplateHalfInventory(this, false).also {
it.itemListKeyDownFun = { _, _, _, _, _ -> Unit }
it.itemListTouchDownFun = { gameItem, amount, button, _, _ ->
val amount = if (button == App.getConfigInt("config_mouseprimary"))
val amount = if (button == App.getConfigInt("control_mouse_primary"))
amount
else if (button == App.getConfigInt("config_mousesecondary"))
else if (button == App.getConfigInt("control_mouse_secondary"))
1
else
null
@@ -227,8 +227,8 @@ internal class UIStorageChest : UICanvas(
private val cellsWidth = (UIItemInventoryItemGrid.listGap + UIItemInventoryElemWide.height) * 6 - UIItemInventoryItemGrid.listGap
private val SP = "\u3000"
private val ML = getMouseButton(App.getConfigInt("config_mouseprimary"))
private val MR = getMouseButton(App.getConfigInt("config_mousesecondary"))
private val ML = getMouseButton(App.getConfigInt("control_mouse_primary"))
private val MR = getMouseButton(App.getConfigInt("control_mouse_secondary"))
private val MW = getMouseButton(2)
private val controlHelpLeft: String
get() = if (App.environment == RunningEnvironment.PC)

View File

@@ -96,7 +96,7 @@ class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
keyDownFun = { _, _, _, _, _ -> Unit },
wheelFun = { _, _, _, _, _, _ -> },
touchDownFun = { gameItem, amount, button, _, _ ->
if (button == App.getConfigInt("config_mouseprimary")) {
if (button == App.getConfigInt("control_mouse_primary")) {
if (gameItem != null) {
negotiator.refund(getFixtureInventory(), getPlayerInventory(), gameItem, amount)
}
@@ -119,7 +119,7 @@ class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
keyDownFun = { _, _, _, _, _ -> Unit },
wheelFun = { _, _, _, _, _, _ -> },
touchDownFun = { gameItem, amount, button, _, _ ->
if (button == App.getConfigInt("config_mouseprimary")) {
if (button == App.getConfigInt("control_mouse_primary")) {
if (gameItem != null) {
negotiator.accept(getPlayerInventory(), getFixtureInventory(), gameItem, amount)
}