mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 07:16:54 +07:00
if tileset or unitset in different in WorldMapHolder compared to GameSetting reload the game on resume (#8519)
This commit is contained in:
parent
713f116400
commit
09d3094bd8
@ -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()
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user