mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-14 23:56:07 +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("imtooyoungtodie", false) // no perma-death
|
||||||
jsonObject.addProperty("language", Terrarum.sysLang)
|
jsonObject.addProperty("language", TerrarumAppLoader.getSysLang())
|
||||||
jsonObject.addProperty("notificationshowuptime", 6500)
|
jsonObject.addProperty("notificationshowuptime", 6500)
|
||||||
jsonObject.addProperty("multithread", true) // experimental!
|
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
|
var previousScreen: Screen? = null // to be used with temporary states like StateMonitorCheck
|
||||||
|
|
||||||
|
|
||||||
@@ -145,27 +138,6 @@ object Terrarum : Screen {
|
|||||||
var environment: RunningEnvironment
|
var environment: RunningEnvironment
|
||||||
private set
|
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")
|
TerrarumAppLoader.GAME_LOCALE = getConfigString("language")
|
||||||
println("[Terrarum] locale = $gameLocale")
|
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
|
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.GameFontBase;
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack;
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,7 +34,37 @@ public class TerrarumAppLoader implements ApplicationListener {
|
|||||||
|
|
||||||
public static final String GAME_NAME = "Terrarum";
|
public static final String GAME_NAME = "Terrarum";
|
||||||
public static final String COPYRIGHT_DATE_NAME = "Copyright 2013-2017 Torvald (minjaesong)";
|
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.langpack.Lang
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.TerrarumAppLoader
|
||||||
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
@@ -11,14 +12,14 @@ import java.io.IOException
|
|||||||
internal object SetLocale : ConsoleCommand {
|
internal object SetLocale : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 2) {
|
if (args.size == 2) {
|
||||||
val prevLocale = Terrarum.gameLocale
|
val prevLocale = TerrarumAppLoader.GAME_LOCALE
|
||||||
Terrarum.gameLocale = args[1]
|
TerrarumAppLoader.GAME_LOCALE = args[1]
|
||||||
try {
|
try {
|
||||||
Echo("Set locale to '" + Terrarum.gameLocale + "'.")
|
Echo("Set locale to '" + TerrarumAppLoader.GAME_LOCALE + "'.")
|
||||||
}
|
}
|
||||||
catch (e: IOException) {
|
catch (e: IOException) {
|
||||||
Echo("could not read lang file.")
|
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 {
|
fun pluralise(word: String, count: Int): String {
|
||||||
if (count < 2) return word
|
if (count < 2) return word
|
||||||
|
|
||||||
when (Terrarum.gameLocale) {
|
when (TerrarumAppLoader.GAME_LOCALE) {
|
||||||
"fr" -> {
|
"fr" -> {
|
||||||
if (Arrays.binarySearch(FRENCH_WORD_NORMAL_PLURAL, word) >= 0) {
|
if (Arrays.binarySearch(FRENCH_WORD_NORMAL_PLURAL, word) >= 0) {
|
||||||
return word + "s"
|
return word + "s"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ 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 net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.TerrarumAppLoader
|
||||||
import net.torvald.terrarum.gameactors.Second
|
import net.torvald.terrarum.gameactors.Second
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
|
||||||
@@ -70,7 +71,7 @@ class UITitleRemoConLanguage(val superMenu: UICanvas) : UICanvas() {
|
|||||||
|
|
||||||
// attach listeners
|
// attach listeners
|
||||||
textArea.selectionChangeListener = { _, newSelectionIndex ->
|
textArea.selectionChangeListener = { _, newSelectionIndex ->
|
||||||
Terrarum.gameLocale = localeList[newSelectionIndex]
|
TerrarumAppLoader.GAME_LOCALE = localeList[newSelectionIndex]
|
||||||
}
|
}
|
||||||
|
|
||||||
menubar.buttons[menuLabels.indexOf("MENU_LABEL_RETURN")].clickOnceListener = { _, _, _ ->
|
menubar.buttons[menuLabels.indexOf("MENU_LABEL_RETURN")].clickOnceListener = { _, _, _ ->
|
||||||
|
|||||||
Reference in New Issue
Block a user