language config now in two columns

This commit is contained in:
minjaesong
2021-09-15 17:40:31 +09:00
parent ae29f7ebea
commit fdd07debf4
34 changed files with 126 additions and 22 deletions

View File

@@ -47,6 +47,7 @@ object Lang {
load("./assets/locales/")
}
@JvmStatic operator fun invoke() { /* dummy method for manual initialisation */ }
fun load(localesDir: String) {
@@ -57,6 +58,10 @@ object Lang {
// get all of the languages installed
localesDir.listFiles().filter { it.isDirectory }.forEach { languageList.add(it.name) }
// temporary filter
languageList.remove("isIC")
languageList.remove("jakanaJP")
for (lang in languageList) {
val langFileListFiles = File("$localesDir/$lang/").listFiles()
langFileListFiles.forEach {

View File

@@ -0,0 +1,44 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.Second
import net.torvald.terrarum.ui.UICanvas
/**
* Created by minjaesong on 2021-09-15.
*/
class UIKeyboardControlPanel : UICanvas() {
override var width = 600
override var height = 600
override var openCloseTime = 0f
override fun updateUI(delta: Float) {
TODO("Not yet implemented")
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
TODO("Not yet implemented")
}
override fun doOpening(delta: Float) {
TODO("Not yet implemented")
}
override fun doClosing(delta: Float) {
TODO("Not yet implemented")
}
override fun endOpening(delta: Float) {
TODO("Not yet implemented")
}
override fun endClosing(delta: Float) {
TODO("Not yet implemented")
}
override fun dispose() {
TODO("Not yet implemented")
}
}

View File

@@ -8,6 +8,7 @@ import net.torvald.terrarum.Second
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemTextButtonList
import kotlin.math.roundToInt
class UITitleLanguage : UICanvas() {
@@ -19,17 +20,34 @@ class UITitleLanguage : UICanvas() {
override var openCloseTime: Second = 0f
private val textAreaHMargin = 48
override var width = (App.scr.width * 0.75).toInt()
override var height = App.scr.height - textAreaHMargin * 2
private val textButtonLineHeight = 32
private val localeList = Lang.languageList.toList().sorted()
private val textArea = UIItemTextButtonList(this,
24,
localeList.map { Lang.langpack["MENU_LANGUAGE_THIS_$it"] ?: "!ERR: $it" }.toTypedArray(),
App.scr.width - width, textAreaHMargin,
width, height,
textAreaWidth = width,
private val localeFirstHalf = localeList.subList(0, localeList.size / 2)
private val localeSecondHalf = localeList.subList(localeList.size / 2, localeList.size)
override var width = 480
override var height = maxOf(localeFirstHalf.size, localeSecondHalf.size) * textButtonLineHeight
private val textArea1 = UIItemTextButtonList(this,
textButtonLineHeight,
localeFirstHalf.map { Lang.langpack["MENU_LANGUAGE_THIS_$it"] ?: "!ERR: $it" }.toTypedArray(),
(App.scr.width - width) / 2, (App.scr.height - height) / 2,
width / 2, height,
textAreaWidth = width / 2,
readFromLang = false,
activeBackCol = Color(0),
highlightBackCol = Color(0),
backgroundCol = Color(0),
inactiveCol = Color.WHITE,
defaultSelection = null
)
private val textArea2 = UIItemTextButtonList(this,
textButtonLineHeight,
localeSecondHalf.map { Lang.langpack["MENU_LANGUAGE_THIS_$it"] ?: "!ERR: $it" }.toTypedArray(),
(App.scr.width - width) / 2 + (width / 2), (App.scr.height - height) / 2,
width / 2, height,
textAreaWidth = width / 2,
readFromLang = false,
activeBackCol = Color(0),
highlightBackCol = Color(0),
@@ -50,15 +68,20 @@ class UITitleLanguage : UICanvas() {
// attach listeners
textArea.selectionChangeListener = { _, newSelectionIndex ->
textArea1.selectionChangeListener = { _, newSelectionIndex ->
App.GAME_LOCALE = localeList[newSelectionIndex]
textArea2.deselect()
}
textArea2.selectionChangeListener = { _, newSelectionIndex ->
App.GAME_LOCALE = localeList[newSelectionIndex + localeFirstHalf.size]
textArea1.deselect()
}
}
override fun updateUI(delta: Float) {
textArea.update(delta)
textArea1.update(delta)
textArea2.update(delta)
//AppLoader.printdbg(this, "should be printing indefinitely")
}
@@ -66,7 +89,8 @@ class UITitleLanguage : UICanvas() {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
batch.color = Color.WHITE
textArea.render(batch, camera)
textArea1.render(batch, camera)
textArea2.render(batch, camera)
}
override fun doOpening(delta: Float) {

View File

@@ -15,15 +15,14 @@ object UITitleRemoConYaml {
- MENU_OPTIONS
- MENU_OPTIONS_GRAPHICS
- MENU_OPTIONS_CONTROLS
- MENU_CONTROLS_KEYBOARD
- MENU_CONTROLS_KEYBOARD : net.torvald.terrarum.modulebasegame.ui.UIKeyboardControlPanel
- MENU_CONTROLS_GAMEPAD
- MENU_LABEL_RETURN
- MENU_OPTIONS_SOUND
- MENU_LABEL_LANGUAGE : net.torvald.terrarum.modulebasegame.ui.UITitleLanguage
- MENU_MODULES : net.torvald.terrarum.ModOptionsHost
- MENU_LABEL_RETURN
- MENU_LABEL_CREDITS : net.torvald.terrarum.modulebasegame.ui.UITitleCredits
- MENU_LABEL_CREDITS : net.torvald.terrarum.modulebasegame.ui.UITitleCredits
- MENU_LABEL_CREDITS
- MENU_LABEL_COPYRIGHT : net.torvald.terrarum.modulebasegame.ui.UITitleCredits
- MENU_CREDIT_GPL_DNT : net.torvald.terrarum.modulebasegame.ui.UITitleGPL3
- MENU_LABEL_RETURN
- MENU_LABEL_QUIT