From 074c27c6cc669f602b79ebda73442793281594f3 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 24 Oct 2023 17:25:20 +0900 Subject: [PATCH] config: empty resolution input to use default; also accepts 720p and 1080p --- .../modulebasegame/ui/ControlPanelCommon.kt | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/src/net/torvald/terrarum/modulebasegame/ui/ControlPanelCommon.kt b/src/net/torvald/terrarum/modulebasegame/ui/ControlPanelCommon.kt index 9bd420fed..08ef62dbe 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/ControlPanelCommon.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/ControlPanelCommon.kt @@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.g2d.SpriteBatch import net.torvald.terrarum.App import net.torvald.terrarum.CommonResourcePool +import net.torvald.terrarum.TerrarumScreenSize import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.ui.* import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack @@ -129,7 +130,7 @@ object ControlPanelCommon { UIItemTextLineInput(parent, x, y, CONFIG_SPINNER_WIDTH, defaultValue = { "${App.getConfigInt(keyWidth)}x${App.getConfigInt(keyHeight)}" }, maxLen = InputLenCap(9, InputLenCap.CharLenUnit.CODEPOINTS), - keyFilter = { it.headkey == Input.Keys.ENTER || it.headkey == Input.Keys.BACKSPACE || it.character?.matches(Regex("[0-9xX]")) == true }, + keyFilter = { it.headkey == Input.Keys.ENTER || it.headkey == Input.Keys.BACKSPACE || it.character?.matches(Regex("[0-9xXpP]")) == true }, alignment = UIItemTextButton.Companion.Alignment.CENTRE ) to { it: UIItem, optionStr: String -> (it as UIItemTextLineInput).textCommitListener = { text -> @@ -141,7 +142,51 @@ object ControlPanelCommon { App.setConfig(keyWidth, width) App.setConfig(keyHeight, height) } - else it.markAsInvalid() + else if (text == "720p") { + it.markAsNormal() + App.setConfig(keyWidth, 1280) + App.setConfig(keyHeight, 720) + } + else if (text == "800p") { + it.markAsNormal() + App.setConfig(keyWidth, 1280) + App.setConfig(keyHeight, 800) + } + else if (text == "900p") { + it.markAsNormal() + App.setConfig(keyWidth, 1600) + App.setConfig(keyHeight, 900) + } + else if (text == "1080p") { + it.markAsNormal() + App.setConfig(keyWidth, 1920) + App.setConfig(keyHeight, 1080) + } + else if (text == "1200p") { + it.markAsNormal() + App.setConfig(keyWidth, 1920) + App.setConfig(keyHeight, 1200) + } + else if (text == "1440p") { + it.markAsNormal() + App.setConfig(keyWidth, 2560) + App.setConfig(keyHeight, 1440) + } + else if (text == "1600p") { + it.markAsNormal() + App.setConfig(keyWidth, 2560) + App.setConfig(keyHeight, 1600) + } + else if (text == "2160p") { + it.markAsNormal() + App.setConfig(keyWidth, 3840) + App.setConfig(keyHeight, 2160) + } + else { + it.markAsInvalid() + App.setConfig(keyWidth, TerrarumScreenSize.defaultW) + App.setConfig(keyHeight, TerrarumScreenSize.defaultH) + } } } }