From c98ca0846035fc268532fad95853f08c5d909d74 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 16 Nov 2021 14:03:24 +0900 Subject: [PATCH] IME icon by language; fixed a bug where text input field would not reset IME when it has been deactivated --- assets/graphics/gui/ime_icons_by_language.tga | 3 ++ assets/keylayout/bg_bg_bds.ime | 1 + assets/keylayout/ko_kr_2set_ksx5002.ime | 1 + assets/keylayout/ko_kr_2set_ksx5002_alt.ime | 1 + assets/keylayout/ko_kr_3set_390.ime | 1 + assets/keylayout/ko_kr_3set_391.ime | 1 + assets/keylayout/ko_kr_3set_shin_03.ime | 1 + assets/keylayout/ko_kr_3set_shin_p2.ime | 1 + assets/keylayout/ru_ru_jcuken.ime | 1 + assets/keylayout/ru_ru_jcuken_apple.ime | 1 + assets/keylayout/ru_ru_phonetique.ime | 1 + assets/keylayout/zh_cn_cangjie5.ime | 1 + assets/keylayout/zh_tw_cangjie5.ime | 1 + src/net/torvald/terrarum/App.java | 10 ++++- .../torvald/terrarum/gamecontroller/IME.kt | 42 ++++++++++++++++++- .../modulebasegame/ui/UILoadDemoSavefiles.kt | 2 +- .../terrarum/modulebasegame/ui/UINewWorld.kt | 5 +-- src/net/torvald/terrarum/ui/ConsoleWindow.kt | 2 + .../terrarum/ui/UIItemTextLineInput.kt | 30 ++++++++----- 19 files changed, 89 insertions(+), 17 deletions(-) create mode 100644 assets/graphics/gui/ime_icons_by_language.tga diff --git a/assets/graphics/gui/ime_icons_by_language.tga b/assets/graphics/gui/ime_icons_by_language.tga new file mode 100644 index 000000000..29b5c0262 --- /dev/null +++ b/assets/graphics/gui/ime_icons_by_language.tga @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b8ea3d61c4bd56abfe616b0ed3070966e7bcf530a5d74a0a75a98f5e604ff78 +size 80018 diff --git a/assets/keylayout/bg_bg_bds.ime b/assets/keylayout/bg_bg_bds.ime index 4d378a2cd..8256828c4 100644 --- a/assets/keylayout/bg_bg_bds.ime +++ b/assets/keylayout/bg_bg_bds.ime @@ -374,6 +374,7 @@ let inRange = (s,a,b) => (a <= s && s <= b) let isDiacritics = (s) => s !== undefined && inRange(s.charCodeAt(0), 0x0300, 0x036F) return Object.freeze({"n":"\uDBBF\uDFC1Бъл. Многоезична\uDBBF\uDFC0","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite", "t":states.keylayouts, +"l":"bgBG", // return: [displayed output, composed output] "accept":(headkey,shiftin,altgrin)=>{ let layer = 1*shiftin + 2*altgrin diff --git a/assets/keylayout/ko_kr_2set_ksx5002.ime b/assets/keylayout/ko_kr_2set_ksx5002.ime index ee8b1e704..03d85268a 100644 --- a/assets/keylayout/ko_kr_2set_ksx5002.ime +++ b/assets/keylayout/ko_kr_2set_ksx5002.ime @@ -345,6 +345,7 @@ let bufAssemble = (isPreview) => { let bufDebugStringify = (buf) => [0,1,2].map(i => (buf[i] == undefined) ? "·" : `${buf[i]}`).join(' ') return Object.freeze({"n":"두벌식 표준","v":"one","c":"CuriousTo\uA75Bvald","m":"rewrite", "t":states.keylayouts.map(it => [it[0],it[1]]), +"l":"koKR", // return: [displayed output, composed output] "accept":(headkey,shiftin,altgrin)=>{ let layer = 1*shiftin// + 2*altgrin diff --git a/assets/keylayout/ko_kr_2set_ksx5002_alt.ime b/assets/keylayout/ko_kr_2set_ksx5002_alt.ime index f43b99a1e..f470b5fe5 100644 --- a/assets/keylayout/ko_kr_2set_ksx5002_alt.ime +++ b/assets/keylayout/ko_kr_2set_ksx5002_alt.ime @@ -345,6 +345,7 @@ let bufAssemble = () => { let bufDebugStringify = (buf) => [0,1,2].map(i => (buf[i] == undefined) ? "·" : `${buf[i]}`).join(' ') return Object.freeze({"n":"두벌식 수정 표준","v":"one","c":"CuriousTo\uA75Bvald","m":"rewrite", "t":states.keylayouts.map(it => [it[0],it[1]]), +"l":"koKR", // return: [displayed output, composed output] "accept":(headkey,shiftin,altgrin)=>{ let layer = 1*shiftin// + 2*altgrin diff --git a/assets/keylayout/ko_kr_3set_390.ime b/assets/keylayout/ko_kr_3set_390.ime index c2262e6fe..fa9679191 100644 --- a/assets/keylayout/ko_kr_3set_390.ime +++ b/assets/keylayout/ko_kr_3set_390.ime @@ -374,6 +374,7 @@ let isBufferNotEmpty = (buf) => buf[0] !== undefined || buf[1] !== undefined || let bufDebugStringify = (buf) => [0,1,2].map(i => (buf[i] == undefined) ? "·" : `\\u${buf[i].codePointAt(0).toString(16).toUpperCase()}`).join(' ') return Object.freeze({"n":"세벌식 3-90","v":"one","c":"CuriousTo\uA75Bvald","m":"rewrite", "t":states.keylayouts.map(it => [it[0],it[1]]), +"l":"koKR", // return: [displayed output, composed output] "accept":(headkey,shiftin,altgrin)=>{ let layer = 1*shiftin// + 2*altgrin diff --git a/assets/keylayout/ko_kr_3set_391.ime b/assets/keylayout/ko_kr_3set_391.ime index afc755629..82bbcc11d 100644 --- a/assets/keylayout/ko_kr_3set_391.ime +++ b/assets/keylayout/ko_kr_3set_391.ime @@ -374,6 +374,7 @@ let isBufferNotEmpty = (buf) => buf[0] !== undefined || buf[1] !== undefined || let bufDebugStringify = (buf) => [0,1,2].map(i => (buf[i] == undefined) ? "·" : `\\u${buf[i].codePointAt(0).toString(16).toUpperCase()}`).join(' ') return Object.freeze({"n":"세벌식 공자판","v":"one","c":"CuriousTo\uA75Bvald","m":"rewrite", "t":states.keylayouts.map(it => [it[0],it[1]]), +"l":"koKR", // return: [displayed output, composed output] "accept":(headkey,shiftin,altgrin)=>{ let layer = 1*shiftin// + 2*altgrin diff --git a/assets/keylayout/ko_kr_3set_shin_03.ime b/assets/keylayout/ko_kr_3set_shin_03.ime index 1382a3167..c85dd7277 100644 --- a/assets/keylayout/ko_kr_3set_shin_03.ime +++ b/assets/keylayout/ko_kr_3set_shin_03.ime @@ -384,6 +384,7 @@ let isBufferNotEmpty = (buf) => buf[0] !== undefined || buf[1] !== undefined || let bufDebugStringify = (buf) => [0,1,2].map(i => (buf[i] == undefined) ? "·" : `\\u${buf[i].codePointAt(0).toString(16).toUpperCase()}`).join(' ') return Object.freeze({"n":"신세벌식 ’03","v":"one","c":"CuriousTo\uA75Bvald","m":"rewrite", "t":states.keylayouts.map(it => [it[0],it[1]]), +"l":"koKR", // return: [displayed output, composed output] "accept":(headkey,shiftin,altgrin)=>{ let layer = 1*shiftin// + 2*altgrin diff --git a/assets/keylayout/ko_kr_3set_shin_p2.ime b/assets/keylayout/ko_kr_3set_shin_p2.ime index a1dffd0ca..51dfb3e48 100644 --- a/assets/keylayout/ko_kr_3set_shin_p2.ime +++ b/assets/keylayout/ko_kr_3set_shin_p2.ime @@ -384,6 +384,7 @@ let isBufferNotEmpty = (buf) => buf[0] !== undefined || buf[1] !== undefined || let bufDebugStringify = (buf) => [0,1,2].map(i => (buf[i] == undefined) ? "·" : `\\u${buf[i].codePointAt(0).toString(16).toUpperCase()}`).join(' ') return Object.freeze({"n":"신세벌식 P2","v":"one","c":"CuriousTo\uA75Bvald","m":"rewrite", "t":states.keylayouts.map(it => [it[0],it[1]]), +"l":"koKR", // return: [displayed output, composed output] "accept":(headkey,shiftin,altgrin)=>{ let layer = 1*shiftin// + 2*altgrin diff --git a/assets/keylayout/ru_ru_jcuken.ime b/assets/keylayout/ru_ru_jcuken.ime index b5b9abcaf..832af16a5 100644 --- a/assets/keylayout/ru_ru_jcuken.ime +++ b/assets/keylayout/ru_ru_jcuken.ime @@ -374,6 +374,7 @@ let inRange = (s,a,b) => (a <= s && s <= b) let isDiacritics = (s) => s !== undefined && inRange(s.charCodeAt(0), 0x0300, 0x036F) return Object.freeze({"n":"ЙЦУКЕН Многоязычна","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite", "t":states.keylayouts, +"l":"ruRU", // return: [displayed output, composed output] "accept":(headkey,shiftin,altgrin)=>{ let layer = 1*shiftin + 2*altgrin diff --git a/assets/keylayout/ru_ru_jcuken_apple.ime b/assets/keylayout/ru_ru_jcuken_apple.ime index b30756645..6bee841ed 100644 --- a/assets/keylayout/ru_ru_jcuken_apple.ime +++ b/assets/keylayout/ru_ru_jcuken_apple.ime @@ -262,6 +262,7 @@ let inRange = (s,a,b) => (a <= s && s <= b) let isDiacritics = (s) => s !== undefined && inRange(s.charCodeAt(0), 0x0300, 0x036F) return Object.freeze({"n":"ЙЦУКЕН (Рус. Apple)","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite", "t":states.keylayouts, +"l":"ruRU", // return: [displayed output, composed output] "accept":(headkey,shiftin,altgrin)=>{ let layer = 1*shiftin + 2*altgrin diff --git a/assets/keylayout/ru_ru_phonetique.ime b/assets/keylayout/ru_ru_phonetique.ime index 3ecf47124..29330b0a3 100644 --- a/assets/keylayout/ru_ru_phonetique.ime +++ b/assets/keylayout/ru_ru_phonetique.ime @@ -32,6 +32,7 @@ let inRange = (s,a,b) => (a <= s && s <= b) let isDiacritics = (s) => s !== undefined && inRange(s.charCodeAt(0), 0x0300, 0x036F) return Object.freeze({"n":"Рус. Фонетическая","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite", "tf":states.layouttable, +"l":"ruRU", // return: [displayed output, composed output] "accept":(headkey,shiftin,altgrin,lowlayerkey)=>{ let layer = 1*shiftin// + 2*altgrin diff --git a/assets/keylayout/zh_cn_cangjie5.ime b/assets/keylayout/zh_cn_cangjie5.ime index de4061b5a..6500c7237 100644 --- a/assets/keylayout/zh_cn_cangjie5.ime +++ b/assets/keylayout/zh_cn_cangjie5.ime @@ -271,6 +271,7 @@ let getCandidatesUsingBuf = () => { } return Object.freeze({"n":"五仓简体 Qwerty","v":"many","c":"CuriousTo\uA75Bvald, 倉頡之友 。馬來西亞 http://www.chinesecj.com","m":"candidates", "t":states.keylayouts.map(it => [(it[2]||it[0]),it[1]]), +"l":"zhCN", // return: [displayed output, composed output] "accept":(headkey,shiftin,altgrin)=>{ let layer = 1*shiftin// + 2*altgrin diff --git a/assets/keylayout/zh_tw_cangjie5.ime b/assets/keylayout/zh_tw_cangjie5.ime index 4d3badf1f..3be86f720 100644 --- a/assets/keylayout/zh_tw_cangjie5.ime +++ b/assets/keylayout/zh_tw_cangjie5.ime @@ -271,6 +271,7 @@ let getCandidatesUsingBuf = () => { } return Object.freeze({"n":"五倉正體 Qwerty","v":"many","c":"CuriousTo\uA75Bvald, 倉頡之友 。馬來西亞 http://www.chinesecj.com","m":"candidates", "t":states.keylayouts.map(it => [(it[2]||it[0]),it[1]]), +"l":"zhTW", // return: [displayed output, composed output] "accept":(headkey,shiftin,altgrin)=>{ let layer = 1*shiftin// + 2*altgrin diff --git a/src/net/torvald/terrarum/App.java b/src/net/torvald/terrarum/App.java index b26ba3928..30dc21e96 100644 --- a/src/net/torvald/terrarum/App.java +++ b/src/net/torvald/terrarum/App.java @@ -183,6 +183,7 @@ public class App implements ApplicationListener { public static TerrarumSansBitmap fontGame; public static TerrarumSansBitmap fontGameFBO; + public static TerrarumSansBitmap fontUITitle; public static TinyAlphNum fontSmallNumbers; /** A gamepad. Multiple gamepads may controll this single virtualised gamepad. */ @@ -286,7 +287,7 @@ public class App implements ApplicationListener { "xinput", "xbox", "game", "joy", "pad" }; - public static InputStrober inputStrober = InputStrober.INSTANCE; // kinda dummy field + public static InputStrober inputStrober; public static Screen getCurrentScreen() { return currentScreen; @@ -502,6 +503,11 @@ public class App implements ApplicationListener { false, 256, false, 0.5f, false ); + fontUITitle = new TerrarumSansBitmap(FONT_DIR, false, true, false, + false, + 64, false, 0.5f, false + ); + fontUITitle.setInterchar(2); fontGameFBO = new TerrarumSansBitmap(FONT_DIR, false, true, false, false, 64, false, 203f/255f, false @@ -843,6 +849,8 @@ public class App implements ApplicationListener { tileMaker.invoke(false); IME.invoke(); + inputStrober = InputStrober.INSTANCE; + // check if selected IME is accessible; if not, set selected IME to none String selectedIME = getConfigString("inputmethod"); if (!selectedIME.equals("none") && !IME.INSTANCE.getAllHighLayers().contains(selectedIME)) { diff --git a/src/net/torvald/terrarum/gamecontroller/IME.kt b/src/net/torvald/terrarum/gamecontroller/IME.kt index 2b0065449..d2ff1637b 100644 --- a/src/net/torvald/terrarum/gamecontroller/IME.kt +++ b/src/net/torvald/terrarum/gamecontroller/IME.kt @@ -1,6 +1,11 @@ package net.torvald.terrarum.gamecontroller +import com.badlogic.gdx.Gdx +import com.badlogic.gdx.graphics.Pixmap +import com.badlogic.gdx.graphics.g2d.TextureRegion +import net.torvald.terrarum.App import net.torvald.terrarum.App.printdbg +import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import java.io.File typealias IMECandidates = List @@ -33,6 +38,7 @@ data class TerrarumIME( data class TerrarumIMEConf( val name: String, val copying: String, + val lang: String, val candidates: TerrarumIMEViewCount, val symbols: Keysyms?, val symbolsfun: Keysymfun?, @@ -84,6 +90,8 @@ object IME { .allowIO(false) .build() + val icons = HashMap() + init { context.getBindings("js").putMember("IMEProvider", IMEProviderDelegate(this)) @@ -96,6 +104,36 @@ object IME { printdbg(this, "Registering High layer ${it.nameWithoutExtension.lowercase()}") highLayers[it.nameWithoutExtension.lowercase()] = parseImeFile(it) } + + + val iconSheet = TextureRegionPack("assets/graphics/gui/ime_icons_by_language.tga", 20, 20) + val iconPixmap = Pixmap(Gdx.files.internal("assets/graphics/gui/ime_icons_by_language.tga")) + for (k in 0 until iconPixmap.height step 20) { + val langCode = StringBuilder() + for (c in 0 until 4) { + val x = c + var charnum = 0 + for (b in 0 until 7) { + val y = k + b + if (iconPixmap.getPixel(x, y) and 255 != 0) { + charnum = charnum or (1 shl b) + } + } + if (charnum != 0) langCode.append(charnum.toChar()) + } + + if (langCode.isNotEmpty()) { + printdbg(this, "Icon order #${(k+1) / 20} - icons[\"$langCode\"] = iconSheet.get(1, ${k/20})") + iconSheet.get(1, k / 20).let { + it.flip(false, true) + icons["$langCode"] = it + } + + } + } + + App.disposables.add(iconSheet) + iconPixmap.dispose() } @JvmStatic fun invoke() {} @@ -175,6 +213,7 @@ object IME { val keysyms = Array(256) { Array(4) { null } } var keysymtable: Keysymfun? = null val mode = jsval.getMember("m").asString().toIMEMode() + val lang = jsval.getMember("l").asString() // keylayout is static (not affected by the Low Layout) if (jsval.hasMember("t")) { @@ -197,14 +236,13 @@ object IME { keysymtable = HashMap() val tf = jsval.getMember("tf") tf.memberKeys.forEach { - println("[IME] keeb $name; tf[$it] = ?") keysymtable[it] = tf.getMember(it).asString() } } return TerrarumIME( name, - TerrarumIMEConf(name, copying, candidatesCount, if (keysymtable == null) keysyms else null, if (keysymtable == null) null else keysymtable, mode), + TerrarumIMEConf(name, copying, lang, candidatesCount, if (keysymtable == null) keysyms else null, if (keysymtable == null) null else keysymtable, mode), { headkey, shifted, alted, lowLayerKeysym -> val a = jsval.invokeMember("accept", headkey, shifted, alted, lowLayerKeysym) a.getArrayElement(0).asString().toCanditates() to a.getArrayElement(1).asString() diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UILoadDemoSavefiles.kt b/src/net/torvald/terrarum/modulebasegame/ui/UILoadDemoSavefiles.kt index 7d5dcfabc..dc97f614f 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UILoadDemoSavefiles.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UILoadDemoSavefiles.kt @@ -361,7 +361,7 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : UICanvas() { // draw texts val loadGameTitleStr = Lang[titles[mode]]// + "$EMDASH$hash" // "Game Load" - App.fontGame.draw(batch, loadGameTitleStr, (width - App.fontGame.getWidth(loadGameTitleStr)).div(2).toFloat(), titleTextPosY.toFloat()) + App.fontUITitle.draw(batch, loadGameTitleStr, (width - App.fontGame.getWidth(loadGameTitleStr)).div(2).toFloat(), titleTextPosY.toFloat()) // Control help App.fontGame.draw(batch, controlHelp, uiX.toFloat(), controlHelperY.toFloat()) } diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UINewWorld.kt b/src/net/torvald/terrarum/modulebasegame/ui/UINewWorld.kt index 64b478019..9391826a0 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UINewWorld.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UINewWorld.kt @@ -121,9 +121,8 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() { override fun renderUI(batch: SpriteBatch, camera: Camera) { batch.color = Color.WHITE // ui title - val titlestr = Lang["CONTEXT_WORLD_NEW"] - // "Game Load" - App.fontGame.draw(batch, titlestr, drawX + (width - App.fontGame.getWidth(titlestr)).div(2).toFloat(), titleTextPosY.toFloat()) +// val titlestr = Lang["CONTEXT_WORLD_NEW"] +// App.fontUITitle.draw(batch, titlestr, drawX + (width - App.fontGame.getWidth(titlestr)).div(2).toFloat(), titleTextPosY.toFloat()) // draw size previews val texture = tex[sizeSelector.selection] diff --git a/src/net/torvald/terrarum/ui/ConsoleWindow.kt b/src/net/torvald/terrarum/ui/ConsoleWindow.kt index e869447be..bee95e93d 100644 --- a/src/net/torvald/terrarum/ui/ConsoleWindow.kt +++ b/src/net/torvald/terrarum/ui/ConsoleWindow.kt @@ -252,12 +252,14 @@ class ConsoleWindow : UICanvas() { 0f, -height.toFloat() )*/ textinput.isActive = false + textinput.mouseoverUpdateLatch = false } override fun endOpening(delta: Float) { drawOffY = 0f openingTimeCounter = 0f textinput.isActive = true + textinput.mouseoverUpdateLatch = true } override fun endClosing(delta: Float) { diff --git a/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt b/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt index 56d9a0f37..504d16433 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt @@ -50,6 +50,8 @@ data class InputLenCap(val count: Int, val unit: CharLenUnit) { * Protip: if there are multiple TextLineInputs on a same UI, draw bottom one first, otherwise the IME's * candidate window will be hidden by the bottom UIItem if they overlaps. * + * Note: mouseoverUpdateLatch must be latched to make buttons work + * * @param width width of the text input where the text gets drawn, not the entire item * @param height height of the text input where the text gets drawn, not the entire item * @@ -101,7 +103,11 @@ class UIItemTextLineInput( true ) - var isActive: Boolean = true + var isActive: Boolean = false // keep it false by default! + set(value) { + if (field && !value) endComposing(true) + field = value + } var cursorX = 0 var cursorDrawScroll = 0 @@ -119,7 +125,7 @@ class UIItemTextLineInput( private val btn1PosX = posX + width - 2*WIDTH_ONEBUTTON - 3 private val btn2PosX = posX + width - WIDTH_ONEBUTTON - var mouseoverUpdateLatch = false + var mouseoverUpdateLatch = true // keep it true by default! set(value) { field = value if (!value) { @@ -144,8 +150,8 @@ class UIItemTextLineInput( private val candidatesBackCol = TEXTINPUT_COL_BACKGROUND.cpy().mul(1f,1f,1f,1.5f) private val candidateNumberStrWidth = App.fontGame.getWidth("8. ") - private fun getIME(): TerrarumIME? { - if (!imeOn) return null + private fun getIME(ignoreOnOff: Boolean = false): TerrarumIME? { + if (!imeOn && !ignoreOnOff) return null val selectedIME = App.getConfigString("inputmethod") @@ -381,8 +387,8 @@ class UIItemTextLineInput( private fun String.toCodePoints() = this.codePoints().toList().filter { it > 0 }.toList() - private fun endComposing() { - getIME()?.let { + private fun endComposing(force: Boolean = false) { + getIME(force)?.let { val s = it.endCompose() if (s.isNotEmpty()) { if (it.config.mode == TerrarumIMEMode.REWRITE) { @@ -438,6 +444,8 @@ class UIItemTextLineInput( override fun render(batch: SpriteBatch, camera: Camera) { + val ime = getIME(true) + batch.end() if (true || fboUpdateLatch) { @@ -508,11 +516,13 @@ class UIItemTextLineInput( Toolkit.fillArea(batch, cursorXOnScreen, posY, 1, 23) } + val imeButton = IME.icons[ime?.config?.lang] ?: labels.get(7, 2) + // draw icon if (enablePasteButton && enableIMEButton) { // IME button batch.color = if (mouseUpOnButton1 && mouseDown || imeOn) Toolkit.Theme.COL_ACTIVE else if (mouseUpOnButton1) Toolkit.Theme.COL_HIGHLIGHT else Toolkit.Theme.COL_INACTIVE - batch.draw(labels.get(7,2), btn1PosX + 2f, posY + 2f) + batch.draw(imeButton, btn1PosX + 2f, posY + 2f) // paste button batch.color = if (mouseUpOnButton2 && mouseDown) Toolkit.Theme.COL_ACTIVE else if (mouseUpOnButton2) Toolkit.Theme.COL_HIGHLIGHT else Toolkit.Theme.COL_INACTIVE batch.draw(labels.get(8,2), btn2PosX + 2f, posY + 2f) @@ -525,17 +535,17 @@ class UIItemTextLineInput( else if (!enablePasteButton && enableIMEButton) { // IME button batch.color = if (mouseUpOnButton1 && mouseDown || imeOn) Toolkit.Theme.COL_ACTIVE else if (mouseUpOnButton1) Toolkit.Theme.COL_HIGHLIGHT else Toolkit.Theme.COL_INACTIVE - batch.draw(labels.get(7,2), btn2PosX + 2f, posY + 2f) + batch.draw(imeButton, btn2PosX + 2f, posY + 2f) } // state of the candidates are concurrently changing, so we buffer them val localCandidates = ArrayList(); candidates.forEach { localCandidates.add(it) } // draw candidates view - if (localCandidates.isNotEmpty()) { + if (localCandidates.isNotEmpty() && ime != null) { val textWidths = localCandidates.map { App.fontGame.getWidth(CodepointSequence(it)) } - val candidatesMax = getIME()!!.config.candidates.toInt() + val candidatesMax = ime.config.candidates.toInt() val candidatesCount = minOf(candidatesMax, localCandidates.size) val isOnecolumn = (candidatesCount <= 3) val halfcount = if (isOnecolumn) candidatesCount else FastMath.ceil(candidatesCount / 2f)