mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
resolution input will have red text if the text format is invalid
This commit is contained in:
@@ -78,12 +78,13 @@ class UIGraphicsControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
(it as UIItemTextLineInput).textCommitListener = { text ->
|
(it as UIItemTextLineInput).textCommitListener = { text ->
|
||||||
val text = text.lowercase()
|
val text = text.lowercase()
|
||||||
if (text.matches(Regex("""[0-9]+x[0-9]+"""))) {
|
if (text.matches(Regex("""[0-9]+x[0-9]+"""))) {
|
||||||
|
it.markAsNormal()
|
||||||
val width = text.substringBefore('x').toInt()
|
val width = text.substringBefore('x').toInt()
|
||||||
val height = text.substringAfter('x').toInt()
|
val height = text.substringAfter('x').toInt()
|
||||||
App.setConfig(keyWidth, width)
|
App.setConfig(keyWidth, width)
|
||||||
App.setConfig(keyHeight, height)
|
App.setConfig(keyHeight, height)
|
||||||
}
|
}
|
||||||
// else it.markAsInvalid
|
else it.markAsInvalid()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,6 +150,24 @@ class UIItemTextLineInput(
|
|||||||
private val candidatesBackCol = TEXTINPUT_COL_BACKGROUND.cpy().mul(1f,1f,1f,1.5f)
|
private val candidatesBackCol = TEXTINPUT_COL_BACKGROUND.cpy().mul(1f,1f,1f,1.5f)
|
||||||
private val candidateNumberStrWidth = App.fontGame.getWidth("8. ")
|
private val candidateNumberStrWidth = App.fontGame.getWidth("8. ")
|
||||||
|
|
||||||
|
private var textStatus = 0 // 0: normal, 1: invalid, 2: disabled
|
||||||
|
|
||||||
|
private var textColours = arrayOf(
|
||||||
|
Color.WHITE,
|
||||||
|
Color(0xff8888ff.toInt()),
|
||||||
|
Color(0x888888ff.toInt())
|
||||||
|
)
|
||||||
|
|
||||||
|
fun markAsNormal() {
|
||||||
|
textStatus = 0
|
||||||
|
}
|
||||||
|
fun markAsInvalid() {
|
||||||
|
textStatus = 1
|
||||||
|
}
|
||||||
|
fun markAsDisabled() {
|
||||||
|
textStatus = 2
|
||||||
|
}
|
||||||
|
|
||||||
/** Event fired whenever a character is entered or pasted from clipboard */
|
/** Event fired whenever a character is entered or pasted from clipboard */
|
||||||
var textCommitListener: (String) -> Unit = {}
|
var textCommitListener: (String) -> Unit = {}
|
||||||
|
|
||||||
@@ -489,7 +507,7 @@ class UIItemTextLineInput(
|
|||||||
fbo.inAction(camera as OrthographicCamera, batch) { batch.inUse {
|
fbo.inAction(camera as OrthographicCamera, batch) { batch.inUse {
|
||||||
gdxClearAndEnableBlend(0f, 0f, 0f, 0f)
|
gdxClearAndEnableBlend(0f, 0f, 0f, 0f)
|
||||||
|
|
||||||
it.color = Color.WHITE
|
it.color = textColours[textStatus]
|
||||||
|
|
||||||
val text = if (textbuf.isEmpty()) currentPlaceholderText else textbuf
|
val text = if (textbuf.isEmpty()) currentPlaceholderText else textbuf
|
||||||
val tw = App.fontGameFBO.getWidth(text)
|
val tw = App.fontGameFBO.getWidth(text)
|
||||||
|
|||||||
Reference in New Issue
Block a user