mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
language vars are fully moved to apploader
This commit is contained in:
@@ -18,7 +18,7 @@ object DefaultConfig {
|
||||
|
||||
|
||||
jsonObject.addProperty("imtooyoungtodie", false) // no perma-death
|
||||
jsonObject.addProperty("language", Terrarum.sysLang)
|
||||
jsonObject.addProperty("language", TerrarumAppLoader.getSysLang())
|
||||
jsonObject.addProperty("notificationshowuptime", 6500)
|
||||
jsonObject.addProperty("multithread", true) // experimental!
|
||||
|
||||
|
||||
@@ -113,13 +113,6 @@ object Terrarum : Screen {
|
||||
|
||||
|
||||
|
||||
val sysLang: String
|
||||
get() {
|
||||
val lan = System.getProperty("user.language")
|
||||
val country = System.getProperty("user.country")
|
||||
return lan + country
|
||||
}
|
||||
|
||||
var previousScreen: Screen? = null // to be used with temporary states like StateMonitorCheck
|
||||
|
||||
|
||||
@@ -145,27 +138,6 @@ object Terrarum : Screen {
|
||||
var environment: RunningEnvironment
|
||||
private set
|
||||
|
||||
private val localeSimple = arrayOf("de", "en", "es", "it")
|
||||
var gameLocale = "lateinit" // TODO move into AppLoader
|
||||
set(value) {
|
||||
if (value.isBlank() || value.isEmpty()) {
|
||||
field = sysLang
|
||||
}
|
||||
else {
|
||||
try {
|
||||
if (localeSimple.contains(value.substring(0..1)))
|
||||
field = value.substring(0..1)
|
||||
else
|
||||
field = value
|
||||
}
|
||||
catch (e: StringIndexOutOfBoundsException) {
|
||||
field = value
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fontGame.reload(value)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -434,12 +406,12 @@ object Terrarum : Screen {
|
||||
|
||||
|
||||
|
||||
gameLocale = getConfigString("language")
|
||||
println("[Terrarum] locale = $gameLocale")
|
||||
TerrarumAppLoader.GAME_LOCALE = getConfigString("language")
|
||||
println("[Terrarum] locale = ${TerrarumAppLoader.GAME_LOCALE}")
|
||||
|
||||
|
||||
|
||||
ModMgr // invoke Module Manager, will also invoke BlockCodex
|
||||
ModMgr // invoke Module Manager, which will also invoke BlockCodex
|
||||
ItemCodex // invoke Item Codex
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
||||
import net.torvald.terrarumsansbitmap.gdx.GameFontBase;
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
@@ -33,7 +34,37 @@ public class TerrarumAppLoader implements ApplicationListener {
|
||||
|
||||
public static final String GAME_NAME = "Terrarum";
|
||||
public static final String COPYRIGHT_DATE_NAME = "Copyright 2013-2017 Torvald (minjaesong)";
|
||||
public static final String GAME_LOCALE = System.getProperty("user.language") + System.getProperty("user.country");
|
||||
public static String GAME_LOCALE = System.getProperty("user.language") + System.getProperty("user.country");
|
||||
|
||||
private static final String[] localeSimple = {"de", "en", "es", "it"}; // must be sorted!!
|
||||
|
||||
public static String getSysLang() {
|
||||
String lan = System.getProperty("user.language");
|
||||
String country = System.getProperty("user.country");
|
||||
return lan + country;
|
||||
}
|
||||
|
||||
public static void setGAME_LOCALE(String value) {
|
||||
if (value.isEmpty() || value.equals("")) {
|
||||
GAME_LOCALE = getSysLang();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
if (Arrays.binarySearch(localeSimple, value.substring(0, 2)) >= 0) {
|
||||
GAME_LOCALE = value.substring(0, 2);
|
||||
}
|
||||
else {
|
||||
GAME_LOCALE = value;
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e) {
|
||||
GAME_LOCALE = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fontGame.reload(value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppLoader
|
||||
|
||||
import java.io.IOException
|
||||
|
||||
@@ -11,14 +12,14 @@ import java.io.IOException
|
||||
internal object SetLocale : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
val prevLocale = Terrarum.gameLocale
|
||||
Terrarum.gameLocale = args[1]
|
||||
val prevLocale = TerrarumAppLoader.GAME_LOCALE
|
||||
TerrarumAppLoader.GAME_LOCALE = args[1]
|
||||
try {
|
||||
Echo("Set locale to '" + Terrarum.gameLocale + "'.")
|
||||
Echo("Set locale to '" + TerrarumAppLoader.GAME_LOCALE + "'.")
|
||||
}
|
||||
catch (e: IOException) {
|
||||
Echo("could not read lang file.")
|
||||
Terrarum.gameLocale = prevLocale
|
||||
TerrarumAppLoader.GAME_LOCALE = prevLocale
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ object Lang {
|
||||
fun pluralise(word: String, count: Int): String {
|
||||
if (count < 2) return word
|
||||
|
||||
when (Terrarum.gameLocale) {
|
||||
when (TerrarumAppLoader.GAME_LOCALE) {
|
||||
"fr" -> {
|
||||
if (Arrays.binarySearch(FRENCH_WORD_NORMAL_PLURAL, word) >= 0) {
|
||||
return word + "s"
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppLoader
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
|
||||
@@ -70,7 +71,7 @@ class UITitleRemoConLanguage(val superMenu: UICanvas) : UICanvas() {
|
||||
|
||||
// attach listeners
|
||||
textArea.selectionChangeListener = { _, newSelectionIndex ->
|
||||
Terrarum.gameLocale = localeList[newSelectionIndex]
|
||||
TerrarumAppLoader.GAME_LOCALE = localeList[newSelectionIndex]
|
||||
}
|
||||
|
||||
menubar.buttons[menuLabels.indexOf("MENU_LABEL_RETURN")].clickOnceListener = { _, _, _ ->
|
||||
|
||||
Reference in New Issue
Block a user