mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-07 00:41:39 +07:00
* Solves #3802 Mod translations don't appear in new game screen * Rehomed translationActiveMods to Translations
This commit is contained in:
@ -32,6 +32,10 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
|
|||||||
|
|
||||||
private var modsWithTranslations: HashMap<String, Translations> = hashMapOf() // key == mod name
|
private var modsWithTranslations: HashMap<String, Translations> = hashMapOf() // key == mod name
|
||||||
|
|
||||||
|
// used by tr() whenever GameInfo not initialized (allowing new game screen to use mod translations)
|
||||||
|
var translationActiveMods = LinkedHashSet<String>()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for the translation entry of a given [text] for a given [language].
|
* Searches for the translation entry of a given [text] for a given [language].
|
||||||
* This includes translations provided by mods from [activeMods]
|
* This includes translations provided by mods from [activeMods]
|
||||||
@ -222,8 +226,9 @@ val curlyBraceRegex = Regex("""\{([^}]*)\}""")
|
|||||||
* but with placeholder or sentence brackets removed.
|
* but with placeholder or sentence brackets removed.
|
||||||
*/
|
*/
|
||||||
fun String.tr(): String {
|
fun String.tr(): String {
|
||||||
val activeMods = if (UncivGame.Current.isGameInfoInitialized())
|
val activeMods = with(UncivGame.Current) {
|
||||||
UncivGame.Current.gameInfo.gameParameters.mods else null
|
if (isGameInfoInitialized()) gameInfo.gameParameters.mods else translations.translationActiveMods
|
||||||
|
}
|
||||||
|
|
||||||
// There might still be optimization potential here!
|
// There might still be optimization potential here!
|
||||||
if (contains("[")) { // Placeholders!
|
if (contains("[")) { // Placeholders!
|
||||||
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.CheckBox
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Array
|
import com.badlogic.gdx.utils.Array
|
||||||
|
import com.unciv.UncivGame
|
||||||
import com.unciv.models.metadata.BaseRuleset
|
import com.unciv.models.metadata.BaseRuleset
|
||||||
import com.unciv.models.metadata.GameSpeed
|
import com.unciv.models.metadata.GameSpeed
|
||||||
import com.unciv.models.ruleset.RulesetCache
|
import com.unciv.models.ruleset.RulesetCache
|
||||||
@ -174,6 +175,7 @@ class GameOptionsTable(val previousScreen: IPreviousScreen, val updatePlayerPick
|
|||||||
|
|
||||||
fun Table.addModCheckboxes() {
|
fun Table.addModCheckboxes() {
|
||||||
val table = ModCheckboxTable(gameParameters.mods, previousScreen as CameraStageBaseScreen) {
|
val table = ModCheckboxTable(gameParameters.mods, previousScreen as CameraStageBaseScreen) {
|
||||||
|
UncivGame.Current.translations.translationActiveMods = gameParameters.mods
|
||||||
reloadRuleset()
|
reloadRuleset()
|
||||||
update()
|
update()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user