From 3f1a385747bccc5ea9ba332aa13be99bb968cb80 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sat, 22 Oct 2022 21:38:46 +0300 Subject: [PATCH] Simplified init resources on new game --- core/src/com/unciv/UncivGame.kt | 10 +++------- core/src/com/unciv/ui/images/ImageGetter.kt | 6 +----- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/core/src/com/unciv/UncivGame.kt b/core/src/com/unciv/UncivGame.kt index fed3ff7c7c..3dbee9ff0e 100644 --- a/core/src/com/unciv/UncivGame.kt +++ b/core/src/com/unciv/UncivGame.kt @@ -226,16 +226,12 @@ class UncivGame(parameters: UncivGameParameters) : Game() { /** The new game info may have different mods or rulesets, which may use different resources that need to be loaded. */ private suspend fun initializeResources(prevGameInfo: GameInfo?, newGameInfo: GameInfo) { - if (prevGameInfo == null || prevGameInfo.ruleSet != newGameInfo.ruleSet) { + if (prevGameInfo == null + || prevGameInfo.gameParameters.baseRuleset != newGameInfo.gameParameters.baseRuleset + || prevGameInfo.gameParameters.mods != newGameInfo.gameParameters.mods) { withGLContext { ImageGetter.setNewRuleset(newGameInfo.ruleSet) } - } - - if (prevGameInfo == null || - prevGameInfo.gameParameters.baseRuleset != newGameInfo.gameParameters.baseRuleset || - prevGameInfo.gameParameters.mods != newGameInfo.gameParameters.mods - ) { val fullModList = newGameInfo.gameParameters.getModsAndBaseRuleset() musicController.setModList(fullModList) } diff --git a/core/src/com/unciv/ui/images/ImageGetter.kt b/core/src/com/unciv/ui/images/ImageGetter.kt index 283bab7861..4968118a19 100644 --- a/core/src/com/unciv/ui/images/ImageGetter.kt +++ b/core/src/com/unciv/ui/images/ImageGetter.kt @@ -36,11 +36,7 @@ import kotlin.math.sqrt object ImageGetter { private const val whiteDotLocation = "OtherIcons/whiteDot" - // When we used to load images directly from different files, without using a texture atlas, - // The draw() phase of the main screen would take a really long time because the BatchRenderer would - // always have to switch between like 170 different textures. - // So, we now use TexturePacker in the DesktopLauncher class to pack all the different images into single images, - // and the atlas is what tells us what was packed where. + // We use texture atlases to minimize texture swapping - see https://yairm210.medium.com/the-libgdx-performance-guide-1d068a84e181 lateinit var atlas: TextureAtlas private val atlases = HashMap() var ruleset = Ruleset()