mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 02:24:05 +09:00
separate config panel for keyboard text input
This commit is contained in:
@@ -22,7 +22,6 @@ import net.torvald.terrarum.blockproperties.WireCodex
|
|||||||
import net.torvald.terrarum.gameactors.Actor
|
import net.torvald.terrarum.gameactors.Actor
|
||||||
import net.torvald.terrarum.gameactors.ActorID
|
import net.torvald.terrarum.gameactors.ActorID
|
||||||
import net.torvald.terrarum.gameactors.faction.FactionCodex
|
import net.torvald.terrarum.gameactors.faction.FactionCodex
|
||||||
import net.torvald.terrarum.gamecontroller.IngameController
|
|
||||||
import net.torvald.terrarum.gameworld.fmod
|
import net.torvald.terrarum.gameworld.fmod
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.itemproperties.MaterialCodex
|
import net.torvald.terrarum.itemproperties.MaterialCodex
|
||||||
@@ -589,9 +588,9 @@ fun printStackTrace(obj: Any, out: PrintStream = System.out) {
|
|||||||
if (App.IS_DEVELOPMENT_BUILD) {
|
if (App.IS_DEVELOPMENT_BUILD) {
|
||||||
val indentation = " ".repeat(obj.javaClass.simpleName.length + 4)
|
val indentation = " ".repeat(obj.javaClass.simpleName.length + 4)
|
||||||
Thread.currentThread().stackTrace.forEachIndexed { index, it ->
|
Thread.currentThread().stackTrace.forEachIndexed { index, it ->
|
||||||
if (index == 3)
|
if (index == 1)
|
||||||
out.println("[${obj.javaClass.simpleName}]> $it")
|
out.println("[${obj.javaClass.simpleName}]> $it")
|
||||||
else if (index > 3)
|
else if (index > 1)
|
||||||
out.println("$indentation$it")
|
out.println("$indentation$it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -602,8 +601,9 @@ class UIContainer {
|
|||||||
fun add(vararg things: Any) {
|
fun add(vararg things: Any) {
|
||||||
things.forEach {
|
things.forEach {
|
||||||
if (it is UICanvas || it is Id_UICanvasNullable)
|
if (it is UICanvas || it is Id_UICanvasNullable)
|
||||||
data.add(it)
|
if (!data.contains(it)) data.add(it)
|
||||||
else throw IllegalArgumentException(it.javaClass.name) }
|
else throw IllegalArgumentException(it.javaClass.name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun iterator() = object : Iterator<UICanvas?> {
|
fun iterator() = object : Iterator<UICanvas?> {
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import net.torvald.terrarum.realestate.LandUtil
|
|||||||
import net.torvald.terrarum.serialise.ReadWorld
|
import net.torvald.terrarum.serialise.ReadWorld
|
||||||
import net.torvald.terrarum.ui.Toolkit
|
import net.torvald.terrarum.ui.Toolkit
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
import net.torvald.terrarum.ui.UIItemTextButton
|
|
||||||
import net.torvald.terrarum.weather.WeatherMixer
|
import net.torvald.terrarum.weather.WeatherMixer
|
||||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|||||||
@@ -6,14 +6,10 @@ import com.badlogic.gdx.graphics.Camera
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.EMDASH
|
|
||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.App
|
||||||
import net.torvald.terrarum.CommonResourcePool
|
import net.torvald.terrarum.CommonResourcePool
|
||||||
import net.torvald.terrarum.DefaultConfig
|
import net.torvald.terrarum.DefaultConfig
|
||||||
import net.torvald.terrarum.gamecontroller.IME
|
|
||||||
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
|
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.linearSearch
|
|
||||||
import net.torvald.terrarum.ui.*
|
import net.torvald.terrarum.ui.*
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
@@ -35,7 +31,6 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
override var height = 600
|
override var height = 600
|
||||||
override var openCloseTime = 0f
|
override var openCloseTime = 0f
|
||||||
|
|
||||||
private val textSelWidth = 280
|
|
||||||
|
|
||||||
private val drawX = (Toolkit.drawWidth - width) / 2
|
private val drawX = (Toolkit.drawWidth - width) / 2
|
||||||
private val drawY = (App.scr.height - height) / 2
|
private val drawY = (App.scr.height - height) / 2
|
||||||
@@ -119,7 +114,16 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
|
|
||||||
) // end of keycaps
|
) // end of keycaps
|
||||||
|
|
||||||
private val buttonReset = UIItemTextButton(this, "MENU_LABEL_RESET", kbx + 2, kby + 162, 140, true, hasBorder = true, alignment = UIItemTextButton.Companion.Alignment.CENTRE)
|
private val resetButtonWidth = 140
|
||||||
|
private val buttonReset = UIItemTextButton(this,
|
||||||
|
"MENU_LABEL_RESET",
|
||||||
|
kbx + (width - resetButtonWidth) / 2,
|
||||||
|
kby + 162 + 12,
|
||||||
|
resetButtonWidth,
|
||||||
|
readFromLang = true,
|
||||||
|
hasBorder = true,
|
||||||
|
alignment = UIItemTextButton.Companion.Alignment.CENTRE
|
||||||
|
)
|
||||||
|
|
||||||
private val symbolLeft = labels.get(0,2)
|
private val symbolLeft = labels.get(0,2)
|
||||||
private val symbolUp = labels.get(1,2)
|
private val symbolUp = labels.get(1,2)
|
||||||
@@ -134,34 +138,7 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
|
|
||||||
private val controlPalette = UIItemControlPaletteBaloon(this, (Toolkit.drawWidth - 480) / 2, kby + 219)
|
private val controlPalette = UIItemControlPaletteBaloon(this, (Toolkit.drawWidth - 480) / 2, kby + 219)
|
||||||
|
|
||||||
|
|
||||||
private val lowLayerCodes = IME.getAllLowLayers()
|
|
||||||
private val lowLayerNames = lowLayerCodes.map { { IME.getLowLayerByName(it).name } }
|
|
||||||
private val keyboardLayoutSelection = UIItemTextSelector(this, drawX + width - textSelWidth - 3, 400, lowLayerNames, lowLayerCodes.linearSearch { it == App.getConfigString("basekeyboardlayout") } ?: throw IME.LayoutNotFound(App.getConfigString("basekeyboardlayout")), textSelWidth)
|
|
||||||
|
|
||||||
private val imeCodes0 = IME.getAllHighLayers()
|
|
||||||
private val imeCodes = listOf("none") + IME.getAllHighLayers()
|
|
||||||
private val imeNames = listOf({"$EMDASH"}) + imeCodes0.map { { IME.getHighLayerByName(it).name } }
|
|
||||||
private val imeSelection = UIItemTextSelector(this, drawX + width - textSelWidth - 3, 440, imeNames, imeCodes.linearSearch { it == App.getConfigString("inputmethod") } ?: throw IME.LayoutNotFound(App.getConfigString("inputmethod")), textSelWidth)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private val keyboardTestPanel = UIItemTextLineInput(this, drawX + (width - 480) / 2 + 3, 480, 474, enableIMEButton = true, enablePasteButton = true)
|
|
||||||
|
|
||||||
|
|
||||||
private val keyboardConfigItems = listOf(
|
|
||||||
keyboardLayoutSelection,
|
|
||||||
imeSelection,
|
|
||||||
keyboardTestPanel
|
|
||||||
)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
keyboardLayoutSelection.selectionChangeListener = {
|
|
||||||
App.setConfig("basekeyboardlayout", lowLayerCodes[it])
|
|
||||||
}
|
|
||||||
imeSelection.selectionChangeListener = {
|
|
||||||
App.setConfig("inputmethod", imeCodes[it])
|
|
||||||
}
|
|
||||||
|
|
||||||
keycaps.values.forEach { addUIitem(it) }
|
keycaps.values.forEach { addUIitem(it) }
|
||||||
updateKeycaps()
|
updateKeycaps()
|
||||||
@@ -177,11 +154,6 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
// addUIitem(keyboardTestPanel)
|
// addUIitem(keyboardTestPanel)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun inputStrobed(e: TerrarumKeyboardEvent) {
|
|
||||||
super.inputStrobed(e)
|
|
||||||
keyboardTestPanel.inputStrobed(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun resetKeyConfig() {
|
private fun resetKeyConfig() {
|
||||||
listOf("control_key_up",
|
listOf("control_key_up",
|
||||||
"control_key_left",
|
"control_key_left",
|
||||||
@@ -236,12 +208,7 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
|
|
||||||
buttonReset.update(delta)
|
buttonReset.update(delta)
|
||||||
|
|
||||||
if (keycapClicked >= 0 && controlSelected < 0) {
|
controlPalette.update(delta)
|
||||||
controlPalette.update(delta)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
keyboardConfigItems.forEach { it.update(delta) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
@@ -254,18 +221,12 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
|
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
|
|
||||||
App.fontGame.draw(batch, Lang["MENU_LABEL_KEYBOARD_LAYOUT"], kbx + 1, keyboardLayoutSelection.initialY)
|
|
||||||
App.fontGame.draw(batch, Lang["MENU_LABEL_IME"], kbx + 1, imeSelection.initialY)
|
|
||||||
|
|
||||||
|
|
||||||
if (keycapClicked >= 0 && controlSelected < 0) {
|
if (keycapClicked >= 0 && controlSelected < 0) {
|
||||||
controlPalette.render(batch, camera)
|
controlPalette.render(batch, camera)
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
keyboardConfigItems.forEach { it.render(batch, camera) }
|
|
||||||
}
|
|
||||||
|
|
||||||
val title = Lang["MENU_CONTROLS_KEYBOARD"]
|
// title
|
||||||
|
val title = Lang["MENU_OPTIONS_CONTROLS"]
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
App.fontGame.draw(batch, title, drawX.toFloat() + (width - App.fontGame.getWidth(title)) / 2, drawY.toFloat())
|
App.fontGame.draw(batch, title, drawX.toFloat() + (width - App.fontGame.getWidth(title)) / 2, drawY.toFloat())
|
||||||
|
|
||||||
@@ -278,24 +239,6 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
updateKeycaps()
|
updateKeycaps()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
|
||||||
buttonReset.touchDown(screenX, screenY, pointer, button)
|
|
||||||
keyboardConfigItems.forEach { it.touchDown(screenX, screenY, pointer, button) }
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
|
||||||
buttonReset.touchUp(screenX, screenY, pointer, button)
|
|
||||||
keyboardConfigItems.forEach { it.touchUp(screenX, screenY, pointer, button) }
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun scrolled(amountX: Float, amountY: Float): Boolean {
|
|
||||||
super.scrolled(amountX, amountY)
|
|
||||||
keyboardConfigItems.forEach { it.scrolled(amountX, amountY) }
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun doOpening(delta: Float) {
|
override fun doOpening(delta: Float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,8 +262,8 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
/**
|
/**
|
||||||
* @param key LibGDX keycode. Set it to `null` to "disable" the key. Also see [com.badlogic.gdx.Input.Keys]
|
* @param key LibGDX keycode. Set it to `null` to "disable" the key. Also see [com.badlogic.gdx.Input.Keys]
|
||||||
*/
|
*/
|
||||||
class UIItemKeycap(
|
private class UIItemKeycap(
|
||||||
parent: UIKeyboardControlPanel,
|
parent: UICanvas,
|
||||||
initialX: Int,
|
initialX: Int,
|
||||||
initialY: Int,
|
initialY: Int,
|
||||||
val key: Int?,
|
val key: Int?,
|
||||||
@@ -330,8 +273,14 @@ class UIItemKeycap(
|
|||||||
) : UIItem(parent, initialX, initialY) {
|
) : UIItem(parent, initialX, initialY) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
this.posX = initialX + parent.kbx
|
if (parent is UIKeyboardControlPanel ) {
|
||||||
this.posY = initialY + parent.kby
|
this.posX = initialX + parent.kbx
|
||||||
|
this.posY = initialY + parent.kby
|
||||||
|
}
|
||||||
|
else if (parent is UIKeyboardInputPanel) {
|
||||||
|
this.posX = initialX + parent.kbx
|
||||||
|
this.posY = initialY + parent.kby
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override val height = 28
|
override val height = 28
|
||||||
|
|||||||
@@ -0,0 +1,296 @@
|
|||||||
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.Input
|
||||||
|
import com.badlogic.gdx.graphics.Camera
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import net.torvald.EMDASH
|
||||||
|
import net.torvald.terrarum.App
|
||||||
|
import net.torvald.terrarum.CommonResourcePool
|
||||||
|
import net.torvald.terrarum.gamecontroller.IME
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
import net.torvald.terrarum.linearSearch
|
||||||
|
import net.torvald.terrarum.ui.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2021-11-10.
|
||||||
|
*/
|
||||||
|
class UIKeyboardInputPanel(remoCon: UIRemoCon?) : UICanvas() {
|
||||||
|
|
||||||
|
override var width = 480
|
||||||
|
override var height = 600
|
||||||
|
override var openCloseTime = 0f
|
||||||
|
|
||||||
|
|
||||||
|
private val drawX = (Toolkit.drawWidth - width) / 2
|
||||||
|
private val drawY = (App.scr.height - height) / 2
|
||||||
|
|
||||||
|
internal val kbx = drawX + 1
|
||||||
|
internal val kby = drawY + 95
|
||||||
|
|
||||||
|
private val oneu = 28
|
||||||
|
private val onehalfu = 44
|
||||||
|
private val twou = 52
|
||||||
|
private val twohalfu = 68
|
||||||
|
private val threeu = 84
|
||||||
|
private val spaceu = 188
|
||||||
|
|
||||||
|
private val keycaps = hashMapOf(
|
||||||
|
Input.Keys.GRAVE to UIItemInputKeycap(this, 1, 1, Input.Keys.GRAVE, oneu),
|
||||||
|
Input.Keys.NUM_1 to UIItemInputKeycap(this, 33,1, Input.Keys.NUM_1, oneu),
|
||||||
|
Input.Keys.NUM_2 to UIItemInputKeycap(this, 65,1, Input.Keys.NUM_2, oneu),
|
||||||
|
Input.Keys.NUM_3 to UIItemInputKeycap(this, 97,1, Input.Keys.NUM_3, oneu),
|
||||||
|
Input.Keys.NUM_4 to UIItemInputKeycap(this, 129,1, Input.Keys.NUM_4, oneu),
|
||||||
|
Input.Keys.NUM_5 to UIItemInputKeycap(this, 161,1, Input.Keys.NUM_5, oneu),
|
||||||
|
Input.Keys.NUM_6 to UIItemInputKeycap(this, 193,1, Input.Keys.NUM_6, oneu),
|
||||||
|
Input.Keys.NUM_7 to UIItemInputKeycap(this, 225,1, Input.Keys.NUM_7, oneu),
|
||||||
|
Input.Keys.NUM_8 to UIItemInputKeycap(this, 257,1, Input.Keys.NUM_8, oneu),
|
||||||
|
Input.Keys.NUM_9 to UIItemInputKeycap(this, 289,1, Input.Keys.NUM_9, oneu),
|
||||||
|
Input.Keys.NUM_0 to UIItemInputKeycap(this, 321,1, Input.Keys.NUM_0, oneu),
|
||||||
|
Input.Keys.MINUS to UIItemInputKeycap(this, 353,1, Input.Keys.MINUS, oneu),
|
||||||
|
Input.Keys.EQUALS to UIItemInputKeycap(this, 385,1, Input.Keys.EQUALS, oneu),
|
||||||
|
Input.Keys.BACKSPACE to UIItemInputKeycap(this, 417,1, Input.Keys.BACKSPACE, 60),
|
||||||
|
|
||||||
|
Input.Keys.TAB to UIItemInputKeycap(this, 1,33, Input.Keys.TAB, onehalfu),
|
||||||
|
Input.Keys.Q to UIItemInputKeycap(this, 49,33, Input.Keys.Q, oneu),
|
||||||
|
Input.Keys.W to UIItemInputKeycap(this, 81,33, Input.Keys.W, oneu),
|
||||||
|
Input.Keys.E to UIItemInputKeycap(this, 113,33, Input.Keys.E, oneu),
|
||||||
|
Input.Keys.R to UIItemInputKeycap(this, 145,33, Input.Keys.R, oneu),
|
||||||
|
Input.Keys.T to UIItemInputKeycap(this, 177,33, Input.Keys.T, oneu),
|
||||||
|
Input.Keys.Y to UIItemInputKeycap(this, 209,33, Input.Keys.Y, oneu),
|
||||||
|
Input.Keys.U to UIItemInputKeycap(this, 241,33, Input.Keys.U, oneu),
|
||||||
|
Input.Keys.I to UIItemInputKeycap(this, 273,33, Input.Keys.I, oneu),
|
||||||
|
Input.Keys.O to UIItemInputKeycap(this, 305,33, Input.Keys.O, oneu),
|
||||||
|
Input.Keys.P to UIItemInputKeycap(this, 337,33, Input.Keys.P, oneu),
|
||||||
|
Input.Keys.LEFT_BRACKET to UIItemInputKeycap(this, 369,33, Input.Keys.LEFT_BRACKET, oneu),
|
||||||
|
Input.Keys.RIGHT_BRACKET to UIItemInputKeycap(this, 401,33, Input.Keys.RIGHT_BRACKET, oneu),
|
||||||
|
Input.Keys.BACKSLASH to UIItemInputKeycap(this, 433,33, Input.Keys.BACKSLASH, onehalfu),
|
||||||
|
|
||||||
|
Input.Keys.CAPS_LOCK to UIItemInputKeycap(this, 1,65, Input.Keys.CAPS_LOCK, twou),
|
||||||
|
Input.Keys.A to UIItemInputKeycap(this, 57,65, Input.Keys.A, oneu),
|
||||||
|
Input.Keys.S to UIItemInputKeycap(this, 89,65, Input.Keys.S, oneu),
|
||||||
|
Input.Keys.D to UIItemInputKeycap(this, 121,65, Input.Keys.D, oneu),
|
||||||
|
Input.Keys.F to UIItemInputKeycap(this, 153,65, Input.Keys.F, oneu, true),
|
||||||
|
Input.Keys.G to UIItemInputKeycap(this, 185,65, Input.Keys.G, oneu),
|
||||||
|
Input.Keys.H to UIItemInputKeycap(this, 217,65, Input.Keys.H, oneu),
|
||||||
|
Input.Keys.J to UIItemInputKeycap(this, 249,65, Input.Keys.J, oneu, true),
|
||||||
|
Input.Keys.K to UIItemInputKeycap(this, 281,65, Input.Keys.K, oneu),
|
||||||
|
Input.Keys.L to UIItemInputKeycap(this, 313,65, Input.Keys.L, oneu),
|
||||||
|
Input.Keys.SEMICOLON to UIItemInputKeycap(this, 345,65, Input.Keys.SEMICOLON, oneu),
|
||||||
|
Input.Keys.APOSTROPHE to UIItemInputKeycap(this, 377,65, Input.Keys.APOSTROPHE, oneu),
|
||||||
|
Input.Keys.ENTER to UIItemInputKeycap(this, 409,65, Input.Keys.ENTER, twohalfu),
|
||||||
|
|
||||||
|
Input.Keys.SHIFT_LEFT to UIItemInputKeycap(this, 1,97, Input.Keys.SHIFT_LEFT, twohalfu),
|
||||||
|
Input.Keys.Z to UIItemInputKeycap(this, 73,97, Input.Keys.Z, oneu),
|
||||||
|
Input.Keys.X to UIItemInputKeycap(this, 105,97, Input.Keys.X, oneu),
|
||||||
|
Input.Keys.C to UIItemInputKeycap(this, 137,97, Input.Keys.C, oneu),
|
||||||
|
Input.Keys.V to UIItemInputKeycap(this, 169,97, Input.Keys.V, oneu),
|
||||||
|
Input.Keys.B to UIItemInputKeycap(this, 201,97, Input.Keys.B, oneu),
|
||||||
|
Input.Keys.N to UIItemInputKeycap(this, 233,97, Input.Keys.N, oneu),
|
||||||
|
Input.Keys.M to UIItemInputKeycap(this, 265,97, Input.Keys.M, oneu),
|
||||||
|
Input.Keys.COMMA to UIItemInputKeycap(this, 297,97, Input.Keys.COMMA, oneu),
|
||||||
|
Input.Keys.PERIOD to UIItemInputKeycap(this, 329,97, Input.Keys.PERIOD, oneu),
|
||||||
|
Input.Keys.SLASH to UIItemInputKeycap(this, 361,97, Input.Keys.SLASH, oneu),
|
||||||
|
Input.Keys.SHIFT_RIGHT to UIItemInputKeycap(this, 393,97, Input.Keys.SHIFT_RIGHT, threeu),
|
||||||
|
|
||||||
|
Input.Keys.CONTROL_LEFT to UIItemInputKeycap(this, 1,129, Input.Keys.CONTROL_LEFT, onehalfu),
|
||||||
|
-2 to UIItemInputKeycap(this, 49,129, null, oneu),
|
||||||
|
Input.Keys.ALT_LEFT to UIItemInputKeycap(this, 81,129, Input.Keys.ALT_LEFT, onehalfu),
|
||||||
|
Input.Keys.SPACE to UIItemInputKeycap(this, 129,129, Input.Keys.SPACE, spaceu),
|
||||||
|
Input.Keys.ALT_RIGHT to UIItemInputKeycap(this, 321,129, Input.Keys.ALT_RIGHT, onehalfu),
|
||||||
|
-3 to UIItemInputKeycap(this, 369,129, null, oneu),
|
||||||
|
-4 to UIItemInputKeycap(this, 401,129, null, oneu),
|
||||||
|
Input.Keys.CONTROL_RIGHT to UIItemInputKeycap(this, 433,129, Input.Keys.CONTROL_RIGHT, onehalfu),
|
||||||
|
|
||||||
|
) // end of keycaps
|
||||||
|
|
||||||
|
private val textSelWidth = 266
|
||||||
|
private val selectorWidth = 600
|
||||||
|
private val halfselw = selectorWidth / 2
|
||||||
|
private val selDrawX = (Toolkit.drawWidth - selectorWidth) / 2
|
||||||
|
private val halfw = width / 2
|
||||||
|
|
||||||
|
private val y1 = 400
|
||||||
|
private val y2 = y1 + 40
|
||||||
|
private val y3 = y2 + 48
|
||||||
|
|
||||||
|
private val lowLayerCodes = IME.getAllLowLayers().sorted()
|
||||||
|
private val lowLayerNames = lowLayerCodes.map { { IME.getLowLayerByName(it).name } }
|
||||||
|
private val keyboardLayoutSelection = UIItemTextSelector(this,
|
||||||
|
selDrawX + (halfselw - textSelWidth) / 2,
|
||||||
|
y2,
|
||||||
|
lowLayerNames,
|
||||||
|
lowLayerCodes.linearSearch { it == App.getConfigString("basekeyboardlayout") } ?: throw IME.LayoutNotFound(App.getConfigString("basekeyboardlayout")),
|
||||||
|
textSelWidth
|
||||||
|
)
|
||||||
|
|
||||||
|
private val imeCodes0 = IME.getAllHighLayers().sorted()
|
||||||
|
private val imeCodes = listOf("none") + imeCodes0
|
||||||
|
private val imeNames = listOf({"$EMDASH"}) + imeCodes0.map { { IME.getHighLayerByName(it).name } }
|
||||||
|
private val imeSelection = UIItemTextSelector(this,
|
||||||
|
selDrawX + halfselw + (halfselw - textSelWidth) / 2,
|
||||||
|
y2,
|
||||||
|
imeNames,
|
||||||
|
imeCodes.linearSearch { it == App.getConfigString("inputmethod") } ?: throw IME.LayoutNotFound(App.getConfigString("inputmethod")),
|
||||||
|
textSelWidth
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private val keyboardTestPanel = UIItemTextLineInput(this,
|
||||||
|
drawX + (width - 480) / 2 + 3,
|
||||||
|
y3,
|
||||||
|
474
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
init {
|
||||||
|
keycaps.values.forEach { addUIitem(it) }
|
||||||
|
|
||||||
|
|
||||||
|
keyboardLayoutSelection.selectionChangeListener = {
|
||||||
|
App.setConfig("basekeyboardlayout", lowLayerCodes[it])
|
||||||
|
}
|
||||||
|
imeSelection.selectionChangeListener = {
|
||||||
|
App.setConfig("inputmethod", imeCodes[it])
|
||||||
|
}
|
||||||
|
|
||||||
|
addUIitem(keyboardTestPanel)
|
||||||
|
addUIitem(keyboardLayoutSelection)
|
||||||
|
addUIitem(imeSelection)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateUI(delta: Float) {
|
||||||
|
uiItems.forEach { it.update(delta) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
|
||||||
|
val txt1 = Lang["MENU_LABEL_KEYBOARD_LAYOUT"]; val tw1 = App.fontGame.getWidth(txt1)
|
||||||
|
App.fontGame.draw(batch, txt1, selDrawX + (halfselw - tw1) / 2, y1)
|
||||||
|
|
||||||
|
val txt2 = Lang["MENU_LABEL_IME"]; val tw2 = App.fontGame.getWidth(txt2)
|
||||||
|
App.fontGame.draw(batch, txt2, selDrawX + halfselw + (halfselw - tw2) / 2, y1)
|
||||||
|
|
||||||
|
// title
|
||||||
|
val title = Lang["MENU_CONTROLS_KEYBOARD"]
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
App.fontGame.draw(batch, title, drawX.toFloat() + (width - App.fontGame.getWidth(title)) / 2, drawY.toFloat())
|
||||||
|
|
||||||
|
uiItems.forEach { it.render(batch, camera) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doOpening(delta: Float) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doClosing(delta: Float) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endOpening(delta: Float) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endClosing(delta: Float) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param key LibGDX keycode. Set it to `null` to "disable" the key. Also see [com.badlogic.gdx.Input.Keys]
|
||||||
|
*/
|
||||||
|
private class UIItemInputKeycap(
|
||||||
|
parent: UICanvas,
|
||||||
|
initialX: Int,
|
||||||
|
initialY: Int,
|
||||||
|
val key: Int?,
|
||||||
|
override val width: Int,
|
||||||
|
val homerow: Boolean = false
|
||||||
|
) : UIItem(parent, initialX, initialY) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (parent is UIKeyboardControlPanel ) {
|
||||||
|
this.posX = initialX + parent.kbx
|
||||||
|
this.posY = initialY + parent.kby
|
||||||
|
}
|
||||||
|
else if (parent is UIKeyboardInputPanel) {
|
||||||
|
this.posX = initialX + parent.kbx
|
||||||
|
this.posY = initialY + parent.kby
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override val height = 28
|
||||||
|
|
||||||
|
private val labels = CommonResourcePool.getAsTextureRegionPack("inventory_category")
|
||||||
|
|
||||||
|
var selected = false
|
||||||
|
|
||||||
|
private val borderKeyForbidden = Color(0x000000C0)
|
||||||
|
private val borderKeyNormal = Toolkit.Theme.COL_INACTIVE
|
||||||
|
private val borderMouseUp = Toolkit.Theme.COL_ACTIVE
|
||||||
|
private val borderKeyPressed = Toolkit.Theme.COL_HIGHLIGHT
|
||||||
|
private val borderKeyPressedAndSelected = Color(0x33FF33FF.toInt())
|
||||||
|
|
||||||
|
private val keycapFill = Toolkit.Theme.COL_CELL_FILL
|
||||||
|
|
||||||
|
private val keylabelCol = Toolkit.Theme.COL_DISABLED
|
||||||
|
private val configuredKeyCol = Color.WHITE
|
||||||
|
|
||||||
|
override fun update(delta: Float) {
|
||||||
|
super.update(delta)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
|
super.render(batch, camera)
|
||||||
|
|
||||||
|
// key background
|
||||||
|
batch.color = keycapFill
|
||||||
|
Toolkit.fillArea(batch, posX, posY, width, height)
|
||||||
|
|
||||||
|
batch.color = if (key == null)
|
||||||
|
borderKeyForbidden
|
||||||
|
else if (Gdx.input.isKeyPressed(key) && selected)
|
||||||
|
borderKeyPressedAndSelected
|
||||||
|
else if (Gdx.input.isKeyPressed(key) || selected)
|
||||||
|
borderKeyPressed
|
||||||
|
else if (mouseUp)
|
||||||
|
borderMouseUp
|
||||||
|
else
|
||||||
|
borderKeyNormal
|
||||||
|
|
||||||
|
// key border
|
||||||
|
Toolkit.drawBoxBorder(batch, posX, posY, width, height)
|
||||||
|
|
||||||
|
if (homerow) {
|
||||||
|
Toolkit.drawBoxBorder(batch, posX + 9, posY + 26, 10, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// keysym
|
||||||
|
if (key == Input.Keys.CONTROL_LEFT || key == Input.Keys.CONTROL_RIGHT)
|
||||||
|
batch.draw(labels.get(21,3), (posX + (width - 20) / 2).toFloat(), posY + 4f)
|
||||||
|
else if (key == Input.Keys.ALT_LEFT || key == Input.Keys.ALT_RIGHT)
|
||||||
|
batch.draw(labels.get(22,3), (posX + (width - 20) / 2).toFloat(), posY + 4f)
|
||||||
|
else if (key == Input.Keys.SHIFT_LEFT || key == Input.Keys.SHIFT_RIGHT)
|
||||||
|
batch.draw(labels.get(23,3), (posX + (width - 20) / 2).toFloat(), posY + 4f)
|
||||||
|
else if (key == Input.Keys.TAB)
|
||||||
|
batch.draw(labels.get(23,5), (posX + (width - 20) / 2).toFloat(), posY + 4f)
|
||||||
|
else if (key == Input.Keys.BACKSPACE)
|
||||||
|
batch.draw(labels.get(24,5), (posX + (width - 20) / 2).toFloat(), posY + 4f)
|
||||||
|
else if (key == Input.Keys.CAPS_LOCK)
|
||||||
|
batch.draw(labels.get(24,3), (posX + (width - 20) / 2).toFloat(), posY + 4f)
|
||||||
|
else if (key == Input.Keys.ENTER)
|
||||||
|
batch.draw(labels.get(17,3), (posX + (width - 20) / 2).toFloat(), posY + 4f)
|
||||||
|
else {
|
||||||
|
// the real keysym
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ object UITitleRemoConYaml {
|
|||||||
- MENU_OPTIONS
|
- MENU_OPTIONS
|
||||||
- MENU_LABEL_GRAPHICS : net.torvald.terrarum.modulebasegame.ui.GraphicsControlPanel
|
- MENU_LABEL_GRAPHICS : net.torvald.terrarum.modulebasegame.ui.GraphicsControlPanel
|
||||||
- MENU_OPTIONS_CONTROLS : net.torvald.terrarum.modulebasegame.ui.UIKeyboardControlPanel
|
- MENU_OPTIONS_CONTROLS : net.torvald.terrarum.modulebasegame.ui.UIKeyboardControlPanel
|
||||||
|
- MENU_CONTROLS_KEYBOARD : net.torvald.terrarum.modulebasegame.ui.UIKeyboardInputPanel
|
||||||
- MENU_LABEL_LANGUAGE : net.torvald.terrarum.modulebasegame.ui.UITitleLanguage
|
- MENU_LABEL_LANGUAGE : net.torvald.terrarum.modulebasegame.ui.UITitleLanguage
|
||||||
- MENU_MODULES : net.torvald.terrarum.ModOptionsHost
|
- MENU_MODULES : net.torvald.terrarum.ModOptionsHost
|
||||||
- MENU_LABEL_RETURN+WRITETOCONFIG
|
- MENU_LABEL_RETURN+WRITETOCONFIG
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ abstract class UICanvas(
|
|||||||
abstract override fun dispose()
|
abstract override fun dispose()
|
||||||
|
|
||||||
fun addUIitem(uiItem: UIItem) {
|
fun addUIitem(uiItem: UIItem) {
|
||||||
uiItems.add(uiItem)
|
if (!uiItems.contains(uiItem)) uiItems.add(uiItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mouseInScreen(x: Int, y: Int) = x in 0 until App.scr.width && y in 0 until App.scr.height
|
fun mouseInScreen(x: Int, y: Int) = x in 0 until App.scr.width && y in 0 until App.scr.height
|
||||||
|
|||||||
@@ -82,10 +82,15 @@ class UIItemTextLineInput(
|
|||||||
val TEXTINPUT_COL_TEXT_NOMORE = Color(0xFF8888FF.toInt())
|
val TEXTINPUT_COL_TEXT_NOMORE = Color(0xFF8888FF.toInt())
|
||||||
val TEXTINPUT_COL_TEXT_DISABLED = Toolkit.Theme.COL_DISABLED
|
val TEXTINPUT_COL_TEXT_DISABLED = Toolkit.Theme.COL_DISABLED
|
||||||
val TEXTINPUT_COL_BACKGROUND = Toolkit.Theme.COL_CELL_FILL
|
val TEXTINPUT_COL_BACKGROUND = Toolkit.Theme.COL_CELL_FILL
|
||||||
|
val TEXTINPUT_COL_BACKGROUND2 = Toolkit.Theme.COL_CELL_FILL.cpy()
|
||||||
const val CURSOR_BLINK_TIME = 1f / 3f
|
const val CURSOR_BLINK_TIME = 1f / 3f
|
||||||
|
|
||||||
private const val UI_TEXT_MARGIN = 2
|
private const val UI_TEXT_MARGIN = 2
|
||||||
private const val WIDTH_ONEBUTTON = 24
|
private const val WIDTH_ONEBUTTON = 24
|
||||||
|
|
||||||
|
init {
|
||||||
|
TEXTINPUT_COL_BACKGROUND2.a = 1f - (1f - TEXTINPUT_COL_BACKGROUND2.a) * (1f - TEXTINPUT_COL_BACKGROUND2.a)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val fbo = FrameBuffer(
|
private val fbo = FrameBuffer(
|
||||||
|
|||||||
@@ -20,9 +20,10 @@ class UIItemTextSelector(
|
|||||||
parentUI: UICanvas,
|
parentUI: UICanvas,
|
||||||
initialX: Int, initialY: Int,
|
initialX: Int, initialY: Int,
|
||||||
val labelfuns: List<() -> String>,
|
val labelfuns: List<() -> String>,
|
||||||
intialSelection: Int,
|
initialSelection: Int,
|
||||||
override val width: Int,
|
override val width: Int,
|
||||||
private val drawBorder: Boolean = true
|
private val drawBorder: Boolean = true,
|
||||||
|
private val clickToShowPalette: Boolean = true
|
||||||
) : UIItem(parentUI, initialX, initialY) {
|
) : UIItem(parentUI, initialX, initialY) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -39,13 +40,16 @@ class UIItemTextSelector(
|
|||||||
|
|
||||||
private val fbo = FrameBuffer(Pixmap.Format.RGBA8888, width - 2*buttonW - 6, height - 4, true)
|
private val fbo = FrameBuffer(Pixmap.Format.RGBA8888, width - 2*buttonW - 6, height - 4, true)
|
||||||
|
|
||||||
var selection = intialSelection
|
var selection = initialSelection
|
||||||
private var fboUpdateLatch = true
|
private var fboUpdateLatch = true
|
||||||
|
|
||||||
private var mouseOnButton = 0 // 0: nothing, 1: left, 2: right
|
private var mouseOnButton = 0 // 0: nothing, 1: left, 2: right, 3: middle
|
||||||
|
|
||||||
var selectionChangeListener: (Int) -> Unit = {}
|
var selectionChangeListener: (Int) -> Unit = {}
|
||||||
|
|
||||||
|
private var paletteShowing = false
|
||||||
|
// private var paletteScrollUnit = initialSelection
|
||||||
|
|
||||||
override fun update(delta: Float) {
|
override fun update(delta: Float) {
|
||||||
super.update(delta)
|
super.update(delta)
|
||||||
|
|
||||||
@@ -59,16 +63,35 @@ class UIItemTextSelector(
|
|||||||
else
|
else
|
||||||
0
|
0
|
||||||
|
|
||||||
if (!mouseLatched && Terrarum.mouseDown && mouseOnButton in 1..2) {
|
if (!mouseLatched && Terrarum.mouseDown) {
|
||||||
|
if (mouseOnButton in 1..2) {
|
||||||
|
selection = (selection + (mouseOnButton * 2) - 3) fmod labelfuns.size
|
||||||
|
fboUpdateLatch = true
|
||||||
|
selectionChangeListener(selection)
|
||||||
|
|
||||||
|
paletteShowing = false
|
||||||
|
}
|
||||||
|
else if (mouseOnButton == 3 && clickToShowPalette) {
|
||||||
|
if (!paletteShowing) {
|
||||||
|
paletteShowing = true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
paletteShowing = false
|
||||||
|
selectionChangeListener(selection)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
paletteShowing = false
|
||||||
|
}
|
||||||
|
|
||||||
mouseLatched = true
|
mouseLatched = true
|
||||||
selection = (selection + (mouseOnButton * 2) - 3) fmod labelfuns.size
|
|
||||||
fboUpdateLatch = true
|
|
||||||
selectionChangeListener(selection)
|
|
||||||
}
|
}
|
||||||
else if (!Terrarum.mouseDown) mouseLatched = false
|
else if (!Terrarum.mouseDown) mouseLatched = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
|
val labelCache = labelfuns.map { it() }
|
||||||
|
|
||||||
|
|
||||||
batch.end()
|
batch.end()
|
||||||
|
|
||||||
@@ -78,7 +101,7 @@ class UIItemTextSelector(
|
|||||||
gdxClearAndSetBlend(0f, 0f, 0f, 0f)
|
gdxClearAndSetBlend(0f, 0f, 0f, 0f)
|
||||||
|
|
||||||
it.color = Color.WHITE
|
it.color = Color.WHITE
|
||||||
val t = labelfuns[selection]()
|
val t = labelCache[selection]
|
||||||
val tw = App.fontGame.getWidth(t)
|
val tw = App.fontGame.getWidth(t)
|
||||||
App.fontGameFBO.draw(it, t, (fbo.width - tw) / 2, 0)
|
App.fontGameFBO.draw(it, t, (fbo.width - tw) / 2, 0)
|
||||||
} }
|
} }
|
||||||
@@ -96,7 +119,7 @@ class UIItemTextSelector(
|
|||||||
Toolkit.fillArea(batch, posX + width - buttonW, posY, buttonW, height)
|
Toolkit.fillArea(batch, posX + width - buttonW, posY, buttonW, height)
|
||||||
|
|
||||||
// text area border
|
// text area border
|
||||||
if (mouseOnButton != 3) {
|
if (!paletteShowing && mouseOnButton != 3) {
|
||||||
batch.color = Toolkit.Theme.COL_INACTIVE
|
batch.color = Toolkit.Theme.COL_INACTIVE
|
||||||
Toolkit.drawBoxBorder(batch, posX - 1, posY - 1, width + 2, height + 2)
|
Toolkit.drawBoxBorder(batch, posX - 1, posY - 1, width + 2, height + 2)
|
||||||
}
|
}
|
||||||
@@ -112,7 +135,7 @@ class UIItemTextSelector(
|
|||||||
Toolkit.drawBoxBorder(batch, posX + width - buttonW - 1, posY - 1, buttonW + 2, height + 2)
|
Toolkit.drawBoxBorder(batch, posX + width - buttonW - 1, posY - 1, buttonW + 2, height + 2)
|
||||||
|
|
||||||
// text area border (again)
|
// text area border (again)
|
||||||
if (mouseOnButton == 3) {
|
if (!paletteShowing && mouseOnButton == 3) {
|
||||||
batch.color = Toolkit.Theme.COL_ACTIVE
|
batch.color = Toolkit.Theme.COL_ACTIVE
|
||||||
Toolkit.drawBoxBorder(batch, posX + buttonW + 2, posY - 1, width - 2*buttonW - 4, height + 2)
|
Toolkit.drawBoxBorder(batch, posX + buttonW + 2, posY - 1, width - 2*buttonW - 4, height + 2)
|
||||||
}
|
}
|
||||||
@@ -129,13 +152,50 @@ class UIItemTextSelector(
|
|||||||
batch.draw(labels.get(17,0), posX + width - buttonW + (buttonW - labels.tileW) / 2f, posY + (height - labels.tileH) / 2f)
|
batch.draw(labels.get(17,0), posX + width - buttonW + (buttonW - labels.tileW) / 2f, posY + (height - labels.tileH) / 2f)
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
batch.color = UIItemTextLineInput.TEXTINPUT_COL_TEXT
|
if (!paletteShowing) {
|
||||||
batch.draw(fbo.colorBufferTexture, posX + buttonW + 3f, posY + 2f, fbo.width.toFloat(), fbo.height.toFloat())
|
batch.color = UIItemTextLineInput.TEXTINPUT_COL_TEXT
|
||||||
|
batch.draw(fbo.colorBufferTexture, posX + buttonW + 3f, posY + 2f, fbo.width.toFloat(), fbo.height.toFloat())
|
||||||
|
}
|
||||||
|
// palette
|
||||||
|
else {
|
||||||
|
val palX = posX + buttonW + 3
|
||||||
|
val palY = posY - palCellHeight * selection - palCursorGap
|
||||||
|
val palW = width - 2*buttonW - 6
|
||||||
|
val palH = palCellHeight * labelCache.size + 2*palCursorGap
|
||||||
|
|
||||||
|
// palette background
|
||||||
|
batch.color = Color(128)
|
||||||
|
Toolkit.fillArea(batch, palX-1, palY-1, palW+2, palH+2)
|
||||||
|
batch.color = UIItemTextLineInput.TEXTINPUT_COL_BACKGROUND
|
||||||
|
Toolkit.fillArea(batch, palX, palY, palW, palH)
|
||||||
|
|
||||||
|
// cursor
|
||||||
|
batch.color = palCursorCol
|
||||||
|
Toolkit.drawBoxBorder(batch, posX + buttonW + 2, posY - 1, width - 2*buttonW - 4, height + 2)
|
||||||
|
// palette border
|
||||||
|
batch.color = Toolkit.Theme.COL_ACTIVE
|
||||||
|
Toolkit.drawBoxBorder(batch, palX - 1, palY - 1, palW + 2, palH + 2)
|
||||||
|
|
||||||
|
// palette items
|
||||||
|
labelCache.forEachIndexed { index, s ->
|
||||||
|
batch.color = if (index == selection) Toolkit.Theme.COL_HIGHLIGHT else UIItemTextLineInput.TEXTINPUT_COL_TEXT
|
||||||
|
val t = labelCache[index]
|
||||||
|
val tw = App.fontGame.getWidth(t)
|
||||||
|
App.fontGame.draw(batch, t,
|
||||||
|
palX + (palW - tw) / 2,
|
||||||
|
palY + 2 + palCellHeight * index +
|
||||||
|
(if (index > selection) 1 else if (index == selection) 0 else -1) * palCursorGap + palCursorGap
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
super.render(batch, camera)
|
super.render(batch, camera)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val palCursorCol = Toolkit.Theme.COL_INACTIVE.cpy().mul(1f,1f,1f,0.5f)
|
||||||
|
private val palCellHeight = height // must be same as the text area height
|
||||||
|
private val palCursorGap = 6 // preferably multiple of 3
|
||||||
|
|
||||||
override fun scrolled(amountX: Float, amountY: Float): Boolean {
|
override fun scrolled(amountX: Float, amountY: Float): Boolean {
|
||||||
if (mouseUp) {
|
if (mouseUp) {
|
||||||
if (amountX <= -1 || amountY <= -1)
|
if (amountX <= -1 || amountY <= -1)
|
||||||
|
|||||||
Reference in New Issue
Block a user