diff --git a/core/src/com/unciv/UncivGame.kt b/core/src/com/unciv/UncivGame.kt index 6ffed20fe7..8ab8e8962b 100644 --- a/core/src/com/unciv/UncivGame.kt +++ b/core/src/com/unciv/UncivGame.kt @@ -85,9 +85,9 @@ class UncivGame(parameters: UncivGameParameters) : Game() { * - Font (hence Fonts.resetFont() inside setSkin()) */ ImageGetter.atlas = TextureAtlas("game.atlas") - ImageGetter.setNewRuleset(ImageGetter.ruleset) + settings = GameSaver.getGeneralSettings() // needed for the screen + ImageGetter.setNewRuleset(ImageGetter.ruleset) // This needs to come after the settings, since we may have default visual mods CameraStageBaseScreen.setSkin() // needs to come AFTER the Texture reset, since the buttons depend on it - settings = GameSaver.getGeneralSettings() // needed for the screen - this also needs the atlas to be configured Gdx.graphics.isContinuousRendering = settings.continuousRendering screen = LoadingScreen() diff --git a/core/src/com/unciv/logic/GameSaver.kt b/core/src/com/unciv/logic/GameSaver.kt index 06249c13b0..ad88220cad 100644 --- a/core/src/com/unciv/logic/GameSaver.kt +++ b/core/src/com/unciv/logic/GameSaver.kt @@ -115,11 +115,6 @@ object GameSaver { GameSettings().apply { isFreshlyCreated = true } } - val atlas = ImageGetter.atlas - val currentTileSets = atlas.regions.asSequence() - .filter { it.name.startsWith("TileSets") } - .map { it.name.split("/")[1] }.distinct() - if (settings.tileSet !in currentTileSets) settings.tileSet = "Default" return settings } diff --git a/core/src/com/unciv/models/metadata/GameSettings.kt b/core/src/com/unciv/models/metadata/GameSettings.kt index 6e4e2cba5e..a9d7837234 100644 --- a/core/src/com/unciv/models/metadata/GameSettings.kt +++ b/core/src/com/unciv/models/metadata/GameSettings.kt @@ -37,6 +37,7 @@ class GameSettings { var orderTradeOffersByAmount = true var windowState = WindowState() var isFreshlyCreated = false + var visualMods = HashSet() var showExperimentalWorldWrap = false diff --git a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt index 9e4f73d9a3..b221665798 100644 --- a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt @@ -114,13 +114,30 @@ class ModManagementScreen: PickerScreen() { } } + fun refreshModActions(mod: Ruleset) { + modActionTable.clear() + val visualMods = game.settings.visualMods + if (!visualMods.contains(mod.name)) + modActionTable.add("Enable as permanent visual mod".toTextButton().onClick { + visualMods.add(mod.name); game.settings.save() + ImageGetter.setNewRuleset(ImageGetter.ruleset) + refreshModActions(mod) + }) + else modActionTable.add("Disable as permanent visual mod".toTextButton().onClick { + visualMods.remove(mod.name) + game.settings.save() + ImageGetter.setNewRuleset(ImageGetter.ruleset) + refreshModActions(mod) + }) + modActionTable.row() + } + fun refreshModTable(){ modTable.clear() val currentMods = RulesetCache.values.filter { it.name != "" } for (mod in currentMods) { val button = mod.name.toTextButton().onClick { -// modActionTable.add("Last updated: ${mod.getSummary()}") - + refreshModActions(mod) rightSideButton.setText("Delete [${mod.name}]".tr()) rightSideButton.enable() descriptionLabel.setText(mod.getSummary()) diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index 96faa9645e..d6f2b973b4 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -15,6 +15,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable import com.badlogic.gdx.utils.Align import com.unciv.Constants +import com.unciv.UncivGame import com.unciv.models.ruleset.Nation import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.tile.ResourceType @@ -65,7 +66,7 @@ object ImageGetter { } // These are from the mods - for (mod in ruleset.mods) { + for (mod in UncivGame.Current.settings.visualMods + ruleset.mods) { val modAtlasFile = Gdx.files.local("mods/$mod/game.atlas") if (!modAtlasFile.exists()) continue val modAtlas = TextureAtlas(modAtlasFile)