mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
IME icon by language; fixed a bug where text input field would not reset IME when it has been deactivated
This commit is contained in:
BIN
assets/graphics/gui/ime_icons_by_language.tga
LFS
Normal file
BIN
assets/graphics/gui/ime_icons_by_language.tga
LFS
Normal file
Binary file not shown.
@@ -374,6 +374,7 @@ let inRange = (s,a,b) => (a <= s && s <= b)
|
|||||||
let isDiacritics = (s) => s !== undefined && inRange(s.charCodeAt(0), 0x0300, 0x036F)
|
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",
|
return Object.freeze({"n":"\uDBBF\uDFC1Бъл. Многоезична\uDBBF\uDFC0","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite",
|
||||||
"t":states.keylayouts,
|
"t":states.keylayouts,
|
||||||
|
"l":"bgBG",
|
||||||
// return: [displayed output, composed output]
|
// return: [displayed output, composed output]
|
||||||
"accept":(headkey,shiftin,altgrin)=>{
|
"accept":(headkey,shiftin,altgrin)=>{
|
||||||
let layer = 1*shiftin + 2*altgrin
|
let layer = 1*shiftin + 2*altgrin
|
||||||
|
|||||||
@@ -345,6 +345,7 @@ let bufAssemble = (isPreview) => {
|
|||||||
let bufDebugStringify = (buf) => [0,1,2].map(i => (buf[i] == undefined) ? "·" : `${buf[i]}`).join(' ')
|
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",
|
return Object.freeze({"n":"두벌식 표준","v":"one","c":"CuriousTo\uA75Bvald","m":"rewrite",
|
||||||
"t":states.keylayouts.map(it => [it[0],it[1]]),
|
"t":states.keylayouts.map(it => [it[0],it[1]]),
|
||||||
|
"l":"koKR",
|
||||||
// return: [displayed output, composed output]
|
// return: [displayed output, composed output]
|
||||||
"accept":(headkey,shiftin,altgrin)=>{
|
"accept":(headkey,shiftin,altgrin)=>{
|
||||||
let layer = 1*shiftin// + 2*altgrin
|
let layer = 1*shiftin// + 2*altgrin
|
||||||
|
|||||||
@@ -345,6 +345,7 @@ let bufAssemble = () => {
|
|||||||
let bufDebugStringify = (buf) => [0,1,2].map(i => (buf[i] == undefined) ? "·" : `${buf[i]}`).join(' ')
|
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",
|
return Object.freeze({"n":"두벌식 수정 표준","v":"one","c":"CuriousTo\uA75Bvald","m":"rewrite",
|
||||||
"t":states.keylayouts.map(it => [it[0],it[1]]),
|
"t":states.keylayouts.map(it => [it[0],it[1]]),
|
||||||
|
"l":"koKR",
|
||||||
// return: [displayed output, composed output]
|
// return: [displayed output, composed output]
|
||||||
"accept":(headkey,shiftin,altgrin)=>{
|
"accept":(headkey,shiftin,altgrin)=>{
|
||||||
let layer = 1*shiftin// + 2*altgrin
|
let layer = 1*shiftin// + 2*altgrin
|
||||||
|
|||||||
@@ -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(' ')
|
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",
|
return Object.freeze({"n":"세벌식 3-90","v":"one","c":"CuriousTo\uA75Bvald","m":"rewrite",
|
||||||
"t":states.keylayouts.map(it => [it[0],it[1]]),
|
"t":states.keylayouts.map(it => [it[0],it[1]]),
|
||||||
|
"l":"koKR",
|
||||||
// return: [displayed output, composed output]
|
// return: [displayed output, composed output]
|
||||||
"accept":(headkey,shiftin,altgrin)=>{
|
"accept":(headkey,shiftin,altgrin)=>{
|
||||||
let layer = 1*shiftin// + 2*altgrin
|
let layer = 1*shiftin// + 2*altgrin
|
||||||
|
|||||||
@@ -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(' ')
|
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",
|
return Object.freeze({"n":"세벌식 공자판","v":"one","c":"CuriousTo\uA75Bvald","m":"rewrite",
|
||||||
"t":states.keylayouts.map(it => [it[0],it[1]]),
|
"t":states.keylayouts.map(it => [it[0],it[1]]),
|
||||||
|
"l":"koKR",
|
||||||
// return: [displayed output, composed output]
|
// return: [displayed output, composed output]
|
||||||
"accept":(headkey,shiftin,altgrin)=>{
|
"accept":(headkey,shiftin,altgrin)=>{
|
||||||
let layer = 1*shiftin// + 2*altgrin
|
let layer = 1*shiftin// + 2*altgrin
|
||||||
|
|||||||
@@ -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(' ')
|
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",
|
return Object.freeze({"n":"신세벌식 ’03","v":"one","c":"CuriousTo\uA75Bvald","m":"rewrite",
|
||||||
"t":states.keylayouts.map(it => [it[0],it[1]]),
|
"t":states.keylayouts.map(it => [it[0],it[1]]),
|
||||||
|
"l":"koKR",
|
||||||
// return: [displayed output, composed output]
|
// return: [displayed output, composed output]
|
||||||
"accept":(headkey,shiftin,altgrin)=>{
|
"accept":(headkey,shiftin,altgrin)=>{
|
||||||
let layer = 1*shiftin// + 2*altgrin
|
let layer = 1*shiftin// + 2*altgrin
|
||||||
|
|||||||
@@ -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(' ')
|
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",
|
return Object.freeze({"n":"신세벌식 P2","v":"one","c":"CuriousTo\uA75Bvald","m":"rewrite",
|
||||||
"t":states.keylayouts.map(it => [it[0],it[1]]),
|
"t":states.keylayouts.map(it => [it[0],it[1]]),
|
||||||
|
"l":"koKR",
|
||||||
// return: [displayed output, composed output]
|
// return: [displayed output, composed output]
|
||||||
"accept":(headkey,shiftin,altgrin)=>{
|
"accept":(headkey,shiftin,altgrin)=>{
|
||||||
let layer = 1*shiftin// + 2*altgrin
|
let layer = 1*shiftin// + 2*altgrin
|
||||||
|
|||||||
@@ -374,6 +374,7 @@ let inRange = (s,a,b) => (a <= s && s <= b)
|
|||||||
let isDiacritics = (s) => s !== undefined && inRange(s.charCodeAt(0), 0x0300, 0x036F)
|
let isDiacritics = (s) => s !== undefined && inRange(s.charCodeAt(0), 0x0300, 0x036F)
|
||||||
return Object.freeze({"n":"ЙЦУКЕН Многоязычна","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite",
|
return Object.freeze({"n":"ЙЦУКЕН Многоязычна","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite",
|
||||||
"t":states.keylayouts,
|
"t":states.keylayouts,
|
||||||
|
"l":"ruRU",
|
||||||
// return: [displayed output, composed output]
|
// return: [displayed output, composed output]
|
||||||
"accept":(headkey,shiftin,altgrin)=>{
|
"accept":(headkey,shiftin,altgrin)=>{
|
||||||
let layer = 1*shiftin + 2*altgrin
|
let layer = 1*shiftin + 2*altgrin
|
||||||
|
|||||||
@@ -262,6 +262,7 @@ let inRange = (s,a,b) => (a <= s && s <= b)
|
|||||||
let isDiacritics = (s) => s !== undefined && inRange(s.charCodeAt(0), 0x0300, 0x036F)
|
let isDiacritics = (s) => s !== undefined && inRange(s.charCodeAt(0), 0x0300, 0x036F)
|
||||||
return Object.freeze({"n":"ЙЦУКЕН (Рус. Apple)","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite",
|
return Object.freeze({"n":"ЙЦУКЕН (Рус. Apple)","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite",
|
||||||
"t":states.keylayouts,
|
"t":states.keylayouts,
|
||||||
|
"l":"ruRU",
|
||||||
// return: [displayed output, composed output]
|
// return: [displayed output, composed output]
|
||||||
"accept":(headkey,shiftin,altgrin)=>{
|
"accept":(headkey,shiftin,altgrin)=>{
|
||||||
let layer = 1*shiftin + 2*altgrin
|
let layer = 1*shiftin + 2*altgrin
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ let inRange = (s,a,b) => (a <= s && s <= b)
|
|||||||
let isDiacritics = (s) => s !== undefined && inRange(s.charCodeAt(0), 0x0300, 0x036F)
|
let isDiacritics = (s) => s !== undefined && inRange(s.charCodeAt(0), 0x0300, 0x036F)
|
||||||
return Object.freeze({"n":"Рус. Фонетическая","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite",
|
return Object.freeze({"n":"Рус. Фонетическая","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite",
|
||||||
"tf":states.layouttable,
|
"tf":states.layouttable,
|
||||||
|
"l":"ruRU",
|
||||||
// return: [displayed output, composed output]
|
// return: [displayed output, composed output]
|
||||||
"accept":(headkey,shiftin,altgrin,lowlayerkey)=>{
|
"accept":(headkey,shiftin,altgrin,lowlayerkey)=>{
|
||||||
let layer = 1*shiftin// + 2*altgrin
|
let layer = 1*shiftin// + 2*altgrin
|
||||||
|
|||||||
@@ -271,6 +271,7 @@ let getCandidatesUsingBuf = () => {
|
|||||||
}
|
}
|
||||||
return Object.freeze({"n":"五仓简体 Qwerty","v":"many","c":"CuriousTo\uA75Bvald, 倉頡之友 。馬來西亞 http://www.chinesecj.com","m":"candidates",
|
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]]),
|
"t":states.keylayouts.map(it => [(it[2]||it[0]),it[1]]),
|
||||||
|
"l":"zhCN",
|
||||||
// return: [displayed output, composed output]
|
// return: [displayed output, composed output]
|
||||||
"accept":(headkey,shiftin,altgrin)=>{
|
"accept":(headkey,shiftin,altgrin)=>{
|
||||||
let layer = 1*shiftin// + 2*altgrin
|
let layer = 1*shiftin// + 2*altgrin
|
||||||
|
|||||||
@@ -271,6 +271,7 @@ let getCandidatesUsingBuf = () => {
|
|||||||
}
|
}
|
||||||
return Object.freeze({"n":"五倉正體 Qwerty","v":"many","c":"CuriousTo\uA75Bvald, 倉頡之友 。馬來西亞 http://www.chinesecj.com","m":"candidates",
|
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]]),
|
"t":states.keylayouts.map(it => [(it[2]||it[0]),it[1]]),
|
||||||
|
"l":"zhTW",
|
||||||
// return: [displayed output, composed output]
|
// return: [displayed output, composed output]
|
||||||
"accept":(headkey,shiftin,altgrin)=>{
|
"accept":(headkey,shiftin,altgrin)=>{
|
||||||
let layer = 1*shiftin// + 2*altgrin
|
let layer = 1*shiftin// + 2*altgrin
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ public class App implements ApplicationListener {
|
|||||||
|
|
||||||
public static TerrarumSansBitmap fontGame;
|
public static TerrarumSansBitmap fontGame;
|
||||||
public static TerrarumSansBitmap fontGameFBO;
|
public static TerrarumSansBitmap fontGameFBO;
|
||||||
|
public static TerrarumSansBitmap fontUITitle;
|
||||||
public static TinyAlphNum fontSmallNumbers;
|
public static TinyAlphNum fontSmallNumbers;
|
||||||
|
|
||||||
/** A gamepad. Multiple gamepads may controll this single virtualised gamepad. */
|
/** A gamepad. Multiple gamepads may controll this single virtualised gamepad. */
|
||||||
@@ -286,7 +287,7 @@ public class App implements ApplicationListener {
|
|||||||
"xinput", "xbox", "game", "joy", "pad"
|
"xinput", "xbox", "game", "joy", "pad"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static InputStrober inputStrober = InputStrober.INSTANCE; // kinda dummy field
|
public static InputStrober inputStrober;
|
||||||
|
|
||||||
public static Screen getCurrentScreen() {
|
public static Screen getCurrentScreen() {
|
||||||
return currentScreen;
|
return currentScreen;
|
||||||
@@ -502,6 +503,11 @@ public class App implements ApplicationListener {
|
|||||||
false,
|
false,
|
||||||
256, false, 0.5f, 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,
|
fontGameFBO = new TerrarumSansBitmap(FONT_DIR, false, true, false,
|
||||||
false,
|
false,
|
||||||
64, false, 203f/255f, false
|
64, false, 203f/255f, false
|
||||||
@@ -843,6 +849,8 @@ public class App implements ApplicationListener {
|
|||||||
tileMaker.invoke(false);
|
tileMaker.invoke(false);
|
||||||
|
|
||||||
IME.invoke();
|
IME.invoke();
|
||||||
|
inputStrober = InputStrober.INSTANCE;
|
||||||
|
|
||||||
// check if selected IME is accessible; if not, set selected IME to none
|
// check if selected IME is accessible; if not, set selected IME to none
|
||||||
String selectedIME = getConfigString("inputmethod");
|
String selectedIME = getConfigString("inputmethod");
|
||||||
if (!selectedIME.equals("none") && !IME.INSTANCE.getAllHighLayers().contains(selectedIME)) {
|
if (!selectedIME.equals("none") && !IME.INSTANCE.getAllHighLayers().contains(selectedIME)) {
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
package net.torvald.terrarum.gamecontroller
|
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.terrarum.App.printdbg
|
||||||
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
typealias IMECandidates = List<String>
|
typealias IMECandidates = List<String>
|
||||||
@@ -33,6 +38,7 @@ data class TerrarumIME(
|
|||||||
data class TerrarumIMEConf(
|
data class TerrarumIMEConf(
|
||||||
val name: String,
|
val name: String,
|
||||||
val copying: String,
|
val copying: String,
|
||||||
|
val lang: String,
|
||||||
val candidates: TerrarumIMEViewCount,
|
val candidates: TerrarumIMEViewCount,
|
||||||
val symbols: Keysyms?,
|
val symbols: Keysyms?,
|
||||||
val symbolsfun: Keysymfun?,
|
val symbolsfun: Keysymfun?,
|
||||||
@@ -84,6 +90,8 @@ object IME {
|
|||||||
.allowIO(false)
|
.allowIO(false)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
val icons = HashMap<String, TextureRegion>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
context.getBindings("js").putMember("IMEProvider", IMEProviderDelegate(this))
|
context.getBindings("js").putMember("IMEProvider", IMEProviderDelegate(this))
|
||||||
|
|
||||||
@@ -96,6 +104,36 @@ object IME {
|
|||||||
printdbg(this, "Registering High layer ${it.nameWithoutExtension.lowercase()}")
|
printdbg(this, "Registering High layer ${it.nameWithoutExtension.lowercase()}")
|
||||||
highLayers[it.nameWithoutExtension.lowercase()] = parseImeFile(it)
|
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() {}
|
@JvmStatic fun invoke() {}
|
||||||
@@ -175,6 +213,7 @@ object IME {
|
|||||||
val keysyms = Array(256) { Array<String?>(4) { null } }
|
val keysyms = Array(256) { Array<String?>(4) { null } }
|
||||||
var keysymtable: Keysymfun? = null
|
var keysymtable: Keysymfun? = null
|
||||||
val mode = jsval.getMember("m").asString().toIMEMode()
|
val mode = jsval.getMember("m").asString().toIMEMode()
|
||||||
|
val lang = jsval.getMember("l").asString()
|
||||||
|
|
||||||
// keylayout is static (not affected by the Low Layout)
|
// keylayout is static (not affected by the Low Layout)
|
||||||
if (jsval.hasMember("t")) {
|
if (jsval.hasMember("t")) {
|
||||||
@@ -197,14 +236,13 @@ object IME {
|
|||||||
keysymtable = HashMap()
|
keysymtable = HashMap()
|
||||||
val tf = jsval.getMember("tf")
|
val tf = jsval.getMember("tf")
|
||||||
tf.memberKeys.forEach {
|
tf.memberKeys.forEach {
|
||||||
println("[IME] keeb $name; tf[$it] = ?")
|
|
||||||
keysymtable[it] = tf.getMember(it).asString()
|
keysymtable[it] = tf.getMember(it).asString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TerrarumIME(
|
return TerrarumIME(
|
||||||
name,
|
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 ->
|
{ headkey, shifted, alted, lowLayerKeysym ->
|
||||||
val a = jsval.invokeMember("accept", headkey, shifted, alted, lowLayerKeysym)
|
val a = jsval.invokeMember("accept", headkey, shifted, alted, lowLayerKeysym)
|
||||||
a.getArrayElement(0).asString().toCanditates() to a.getArrayElement(1).asString()
|
a.getArrayElement(0).asString().toCanditates() to a.getArrayElement(1).asString()
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : UICanvas() {
|
|||||||
// draw texts
|
// draw texts
|
||||||
val loadGameTitleStr = Lang[titles[mode]]// + "$EMDASH$hash"
|
val loadGameTitleStr = Lang[titles[mode]]// + "$EMDASH$hash"
|
||||||
// "Game Load"
|
// "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
|
// Control help
|
||||||
App.fontGame.draw(batch, controlHelp, uiX.toFloat(), controlHelperY.toFloat())
|
App.fontGame.draw(batch, controlHelp, uiX.toFloat(), controlHelperY.toFloat())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,9 +121,8 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
|||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
// ui title
|
// ui title
|
||||||
val titlestr = Lang["CONTEXT_WORLD_NEW"]
|
// val titlestr = Lang["CONTEXT_WORLD_NEW"]
|
||||||
// "Game Load"
|
// App.fontUITitle.draw(batch, titlestr, drawX + (width - App.fontGame.getWidth(titlestr)).div(2).toFloat(), titleTextPosY.toFloat())
|
||||||
App.fontGame.draw(batch, titlestr, drawX + (width - App.fontGame.getWidth(titlestr)).div(2).toFloat(), titleTextPosY.toFloat())
|
|
||||||
|
|
||||||
// draw size previews
|
// draw size previews
|
||||||
val texture = tex[sizeSelector.selection]
|
val texture = tex[sizeSelector.selection]
|
||||||
|
|||||||
@@ -252,12 +252,14 @@ class ConsoleWindow : UICanvas() {
|
|||||||
0f, -height.toFloat()
|
0f, -height.toFloat()
|
||||||
)*/
|
)*/
|
||||||
textinput.isActive = false
|
textinput.isActive = false
|
||||||
|
textinput.mouseoverUpdateLatch = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endOpening(delta: Float) {
|
override fun endOpening(delta: Float) {
|
||||||
drawOffY = 0f
|
drawOffY = 0f
|
||||||
openingTimeCounter = 0f
|
openingTimeCounter = 0f
|
||||||
textinput.isActive = true
|
textinput.isActive = true
|
||||||
|
textinput.mouseoverUpdateLatch = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endClosing(delta: Float) {
|
override fun endClosing(delta: Float) {
|
||||||
|
|||||||
@@ -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
|
* 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.
|
* 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 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
|
* @param height height of the text input where the text gets drawn, not the entire item
|
||||||
*
|
*
|
||||||
@@ -101,7 +103,11 @@ class UIItemTextLineInput(
|
|||||||
true
|
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 cursorX = 0
|
||||||
var cursorDrawScroll = 0
|
var cursorDrawScroll = 0
|
||||||
@@ -119,7 +125,7 @@ class UIItemTextLineInput(
|
|||||||
private val btn1PosX = posX + width - 2*WIDTH_ONEBUTTON - 3
|
private val btn1PosX = posX + width - 2*WIDTH_ONEBUTTON - 3
|
||||||
private val btn2PosX = posX + width - WIDTH_ONEBUTTON
|
private val btn2PosX = posX + width - WIDTH_ONEBUTTON
|
||||||
|
|
||||||
var mouseoverUpdateLatch = false
|
var mouseoverUpdateLatch = true // keep it true by default!
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
if (!value) {
|
if (!value) {
|
||||||
@@ -144,8 +150,8 @@ 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 fun getIME(): TerrarumIME? {
|
private fun getIME(ignoreOnOff: Boolean = false): TerrarumIME? {
|
||||||
if (!imeOn) return null
|
if (!imeOn && !ignoreOnOff) return null
|
||||||
|
|
||||||
val selectedIME = App.getConfigString("inputmethod")
|
val selectedIME = App.getConfigString("inputmethod")
|
||||||
|
|
||||||
@@ -381,8 +387,8 @@ class UIItemTextLineInput(
|
|||||||
|
|
||||||
private fun String.toCodePoints() = this.codePoints().toList().filter { it > 0 }.toList()
|
private fun String.toCodePoints() = this.codePoints().toList().filter { it > 0 }.toList()
|
||||||
|
|
||||||
private fun endComposing() {
|
private fun endComposing(force: Boolean = false) {
|
||||||
getIME()?.let {
|
getIME(force)?.let {
|
||||||
val s = it.endCompose()
|
val s = it.endCompose()
|
||||||
if (s.isNotEmpty()) {
|
if (s.isNotEmpty()) {
|
||||||
if (it.config.mode == TerrarumIMEMode.REWRITE) {
|
if (it.config.mode == TerrarumIMEMode.REWRITE) {
|
||||||
@@ -438,6 +444,8 @@ class UIItemTextLineInput(
|
|||||||
|
|
||||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
|
|
||||||
|
val ime = getIME(true)
|
||||||
|
|
||||||
batch.end()
|
batch.end()
|
||||||
|
|
||||||
if (true || fboUpdateLatch) {
|
if (true || fboUpdateLatch) {
|
||||||
@@ -508,11 +516,13 @@ class UIItemTextLineInput(
|
|||||||
Toolkit.fillArea(batch, cursorXOnScreen, posY, 1, 23)
|
Toolkit.fillArea(batch, cursorXOnScreen, posY, 1, 23)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val imeButton = IME.icons[ime?.config?.lang] ?: labels.get(7, 2)
|
||||||
|
|
||||||
// draw icon
|
// draw icon
|
||||||
if (enablePasteButton && enableIMEButton) {
|
if (enablePasteButton && enableIMEButton) {
|
||||||
// IME button
|
// 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.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
|
// paste button
|
||||||
batch.color = if (mouseUpOnButton2 && mouseDown) Toolkit.Theme.COL_ACTIVE else if (mouseUpOnButton2) Toolkit.Theme.COL_HIGHLIGHT else Toolkit.Theme.COL_INACTIVE
|
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)
|
batch.draw(labels.get(8,2), btn2PosX + 2f, posY + 2f)
|
||||||
@@ -525,17 +535,17 @@ class UIItemTextLineInput(
|
|||||||
else if (!enablePasteButton && enableIMEButton) {
|
else if (!enablePasteButton && enableIMEButton) {
|
||||||
// IME button
|
// 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.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
|
// state of the candidates are concurrently changing, so we buffer them
|
||||||
val localCandidates = ArrayList<CodepointSequence>(); candidates.forEach { localCandidates.add(it) }
|
val localCandidates = ArrayList<CodepointSequence>(); candidates.forEach { localCandidates.add(it) }
|
||||||
|
|
||||||
// draw candidates view
|
// draw candidates view
|
||||||
if (localCandidates.isNotEmpty()) {
|
if (localCandidates.isNotEmpty() && ime != null) {
|
||||||
|
|
||||||
val textWidths = localCandidates.map { App.fontGame.getWidth(CodepointSequence(it)) }
|
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 candidatesCount = minOf(candidatesMax, localCandidates.size)
|
||||||
val isOnecolumn = (candidatesCount <= 3)
|
val isOnecolumn = (candidatesCount <= 3)
|
||||||
val halfcount = if (isOnecolumn) candidatesCount else FastMath.ceil(candidatesCount / 2f)
|
val halfcount = if (isOnecolumn) candidatesCount else FastMath.ceil(candidatesCount / 2f)
|
||||||
|
|||||||
Reference in New Issue
Block a user