mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 03:23:17 -04: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,
|
// 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)
|
// 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 tileSetLocation = "TileSets/$tileSet/"
|
||||||
val unitSetLocation = "TileSets/$unitSet/"
|
val unitSetLocation = "TileSets/$unitSet/"
|
||||||
val tileSetConfig = TileSetCache[tileSet]?.config ?: TileSetConfig()
|
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.pickerscreens.ModManagementScreen
|
||||||
import com.unciv.ui.screens.worldscreen.mainmenu.WorldScreenMenuPopup
|
import com.unciv.ui.screens.worldscreen.mainmenu.WorldScreenMenuPopup
|
||||||
import com.unciv.ui.screens.mainmenuscreen.EasterEggRulesets.modifyForEasterEgg
|
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.Concurrency
|
||||||
import com.unciv.utils.concurrency.launchOnGLThread
|
import com.unciv.utils.concurrency.launchOnGLThread
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
@ -221,9 +222,18 @@ class MainMenuScreen: BaseScreen(), RecreateOnResize {
|
|||||||
|
|
||||||
private fun resumeGame() {
|
private fun resumeGame() {
|
||||||
if (GUI.isWorldLoaded()) {
|
if (GUI.isWorldLoaded()) {
|
||||||
GUI.resetToWorldScreen()
|
val currentTileSet = GUI.getMap().currentTileSetStrings
|
||||||
GUI.getWorldScreen().popups.filterIsInstance(WorldScreenMenuPopup::class.java).forEach(Popup::close)
|
val currentGameSetting = GUI.getSettings()
|
||||||
ImageGetter.ruleset = game.gameInfo!!.ruleset
|
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 {
|
} else {
|
||||||
QuickSave.autoLoadGame(this)
|
QuickSave.autoLoadGame(this)
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,8 @@ class WorldMapHolder(
|
|||||||
|
|
||||||
private lateinit var tileGroupMap: TileGroupMap<WorldTileGroup>
|
private lateinit var tileGroupMap: TileGroupMap<WorldTileGroup>
|
||||||
|
|
||||||
|
lateinit var currentTileSetStrings: TileSetStrings
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (Gdx.app.type == Application.ApplicationType.Desktop) this.setFlingTime(0f)
|
if (Gdx.app.type == Application.ApplicationType.Desktop) this.setFlingTime(0f)
|
||||||
continuousScrollingX = tileMap.mapParameters.worldWrap
|
continuousScrollingX = tileMap.mapParameters.worldWrap
|
||||||
@ -109,6 +111,7 @@ class WorldMapHolder(
|
|||||||
|
|
||||||
internal fun addTiles() {
|
internal fun addTiles() {
|
||||||
val tileSetStrings = TileSetStrings()
|
val tileSetStrings = TileSetStrings()
|
||||||
|
currentTileSetStrings = tileSetStrings
|
||||||
val tileGroupsNew = tileMap.values.map { WorldTileGroup(it, tileSetStrings) }
|
val tileGroupsNew = tileMap.values.map { WorldTileGroup(it, tileSetStrings) }
|
||||||
tileGroupMap = TileGroupMap(this, tileGroupsNew, continuousScrollingX)
|
tileGroupMap = TileGroupMap(this, tileGroupsNew, continuousScrollingX)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user