if tileset or unitset in different in WorldMapHolder compared to GameSetting reload the game on resume (#8519)

This commit is contained in:
ryg-git 2023-02-24 02:35:03 +05:30 committed by GitHub
parent 713f116400
commit 09d3094bd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View File

@ -17,6 +17,8 @@ class TileSetStrings(tileSet: String = UncivGame.Current.settings.tileSet, unitS
// this is so that when we have 100s of TileGroups, they won't all individually come up with all these strings themselves,
// it gets pretty memory-intensive (10s of MBs which is a lot for lower-end phones)
val tileSetName = tileSet
val unitSetName = unitSet
val tileSetLocation = "TileSets/$tileSet/"
val unitSetLocation = "TileSets/$unitSet/"
val tileSetConfig = TileSetCache[tileSet]?.config ?: TileSetConfig()

View File

@ -47,6 +47,7 @@ import com.unciv.ui.screens.newgamescreen.NewGameScreen
import com.unciv.ui.screens.pickerscreens.ModManagementScreen
import com.unciv.ui.screens.worldscreen.mainmenu.WorldScreenMenuPopup
import com.unciv.ui.screens.mainmenuscreen.EasterEggRulesets.modifyForEasterEgg
import com.unciv.ui.screens.worldscreen.WorldScreen
import com.unciv.utils.concurrency.Concurrency
import com.unciv.utils.concurrency.launchOnGLThread
import kotlin.math.min
@ -221,9 +222,18 @@ class MainMenuScreen: BaseScreen(), RecreateOnResize {
private fun resumeGame() {
if (GUI.isWorldLoaded()) {
GUI.resetToWorldScreen()
GUI.getWorldScreen().popups.filterIsInstance(WorldScreenMenuPopup::class.java).forEach(Popup::close)
ImageGetter.ruleset = game.gameInfo!!.ruleset
val currentTileSet = GUI.getMap().currentTileSetStrings
val currentGameSetting = GUI.getSettings()
if (currentTileSet.tileSetName != currentGameSetting.tileSet ||
currentTileSet.unitSetName != currentGameSetting.unitSet) {
for (screen in game.screenStack.filterIsInstance<WorldScreen>()) screen.dispose()
game.screenStack.removeAll { it is WorldScreen }
QuickSave.autoLoadGame(this)
} else {
GUI.resetToWorldScreen()
GUI.getWorldScreen().popups.filterIsInstance(WorldScreenMenuPopup::class.java).forEach(Popup::close)
ImageGetter.ruleset = game.gameInfo!!.ruleset
}
} else {
QuickSave.autoLoadGame(this)
}

View File

@ -69,6 +69,8 @@ class WorldMapHolder(
private lateinit var tileGroupMap: TileGroupMap<WorldTileGroup>
lateinit var currentTileSetStrings: TileSetStrings
init {
if (Gdx.app.type == Application.ApplicationType.Desktop) this.setFlingTime(0f)
continuousScrollingX = tileMap.mapParameters.worldWrap
@ -109,6 +111,7 @@ class WorldMapHolder(
internal fun addTiles() {
val tileSetStrings = TileSetStrings()
currentTileSetStrings = tileSetStrings
val tileGroupsNew = tileMap.values.map { WorldTileGroup(it, tileSetStrings) }
tileGroupMap = TileGroupMap(this, tileGroupsNew, continuousScrollingX)