Use TextInputPanel
This commit is contained in:
parent
c91124d25c
commit
27c7ef7b50
@ -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.LargeBooleanRectangleButtonPanel
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeEnumRectangleButtonPanel
|
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.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.slot.AbstractSlotPanel
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants
|
import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants
|
||||||
@ -261,40 +262,32 @@ class MatterPanelScreen(
|
|||||||
|
|
||||||
var count = 1
|
var count = 1
|
||||||
|
|
||||||
val input = object : EditBoxPanel<MatterPanelScreen>(this@MatterPanelScreen, rowInput) {
|
val input = object : TextInputPanel<MatterPanelScreen>(this@MatterPanelScreen, rowInput) {
|
||||||
init {
|
init {
|
||||||
dock = Dock.FILL
|
dock = Dock.FILL
|
||||||
|
text = "1"
|
||||||
requestFocus()
|
requestFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun configureNew(widget: EditBox, recreation: Boolean) {
|
|
||||||
super.configureNew(widget, recreation)
|
|
||||||
widget.setMaxLength(6)
|
|
||||||
|
|
||||||
if (!recreation) {
|
|
||||||
widget.value = "1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun increase(amount: Int) {
|
fun increase(amount: Int) {
|
||||||
count = 1
|
count = 1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
count = getOrCreateWidget().value.toInt().coerceIn(1, 99999)
|
count = text.toInt().coerceIn(1, 99999)
|
||||||
} catch (_: NumberFormatException) {
|
} catch (_: NumberFormatException) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 1 && amount > 0)
|
if (count == 1 && amount > 0)
|
||||||
getOrCreateWidget().value = amount.toString()
|
text = amount.toString()
|
||||||
else
|
else
|
||||||
getOrCreateWidget().value = (count + amount).coerceIn(1, 99999).toString()
|
text = (count + amount).coerceIn(1, 99999).toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun tickInner() {
|
override fun tickInner() {
|
||||||
super.tickInner()
|
super.tickInner()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
count = getOrCreateWidget().value.toInt().coerceIn(1, 99999)
|
count = text.toInt().coerceIn(1, 99999)
|
||||||
} catch (_: NumberFormatException) {
|
} catch (_: NumberFormatException) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,7 +296,7 @@ class MatterPanelScreen(
|
|||||||
count = 1
|
count = 1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
count = getOrCreateWidget().value.toInt().coerceIn(1, 99999)
|
count = text.toInt().coerceIn(1, 99999)
|
||||||
} catch (_: NumberFormatException) {
|
} catch (_: NumberFormatException) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user