mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-20 09:17:47 +07:00
* Solves #3802 Mod translations don't appear in new game screen * Rehomed translationActiveMods to Translations
This commit is contained in:
parent
6ffbce4ee1
commit
722772b08e
@ -32,6 +32,10 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
|
||||
|
||||
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].
|
||||
* This includes translations provided by mods from [activeMods]
|
||||
@ -222,8 +226,9 @@ val curlyBraceRegex = Regex("""\{([^}]*)\}""")
|
||||
* but with placeholder or sentence brackets removed.
|
||||
*/
|
||||
fun String.tr(): String {
|
||||
val activeMods = if (UncivGame.Current.isGameInfoInitialized())
|
||||
UncivGame.Current.gameInfo.gameParameters.mods else null
|
||||
val activeMods = with(UncivGame.Current) {
|
||||
if (isGameInfoInitialized()) gameInfo.gameParameters.mods else translations.translationActiveMods
|
||||
}
|
||||
|
||||
// There might still be optimization potential here!
|
||||
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.Table
|
||||
import com.badlogic.gdx.utils.Array
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.models.metadata.BaseRuleset
|
||||
import com.unciv.models.metadata.GameSpeed
|
||||
import com.unciv.models.ruleset.RulesetCache
|
||||
@ -174,6 +175,7 @@ class GameOptionsTable(val previousScreen: IPreviousScreen, val updatePlayerPick
|
||||
|
||||
fun Table.addModCheckboxes() {
|
||||
val table = ModCheckboxTable(gameParameters.mods, previousScreen as CameraStageBaseScreen) {
|
||||
UncivGame.Current.translations.translationActiveMods = gameParameters.mods
|
||||
reloadRuleset()
|
||||
update()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user