From 27c7ef7b504174cf41f75d2b784ddcd8c28082b6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 7 Mar 2023 21:04:33 +0700 Subject: [PATCH] Use TextInputPanel --- .../client/screen/matter/MatterPanelScreen.kt | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt index 3edc1fe4d..eb86c69f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeBooleanRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeEnumRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.EditBoxPanel +import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants @@ -261,40 +262,32 @@ class MatterPanelScreen( var count = 1 - val input = object : EditBoxPanel(this@MatterPanelScreen, rowInput) { + val input = object : TextInputPanel(this@MatterPanelScreen, rowInput) { init { dock = Dock.FILL + text = "1" requestFocus() } - override fun configureNew(widget: EditBox, recreation: Boolean) { - super.configureNew(widget, recreation) - widget.setMaxLength(6) - - if (!recreation) { - widget.value = "1" - } - } - fun increase(amount: Int) { count = 1 try { - count = getOrCreateWidget().value.toInt().coerceIn(1, 99999) + count = text.toInt().coerceIn(1, 99999) } catch (_: NumberFormatException) { } if (count == 1 && amount > 0) - getOrCreateWidget().value = amount.toString() + text = amount.toString() else - getOrCreateWidget().value = (count + amount).coerceIn(1, 99999).toString() + text = (count + amount).coerceIn(1, 99999).toString() } override fun tickInner() { super.tickInner() try { - count = getOrCreateWidget().value.toInt().coerceIn(1, 99999) + count = text.toInt().coerceIn(1, 99999) } catch (_: NumberFormatException) { } } @@ -303,7 +296,7 @@ class MatterPanelScreen( count = 1 try { - count = getOrCreateWidget().value.toInt().coerceIn(1, 99999) + count = text.toInt().coerceIn(1, 99999) } catch (_: NumberFormatException) { }