From 57b1a01e2c5225a7d908bbbcba184c8c9e80c6b9 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 18 Mar 2021 10:57:02 +0200 Subject: [PATCH] Resolved #3705 - loading game popup stays until the game is loaded --- core/src/com/unciv/MainMenuScreen.kt | 15 ++++++++++++--- core/src/com/unciv/logic/city/CityStats.kt | 2 +- core/src/com/unciv/logic/map/TileInfo.kt | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/MainMenuScreen.kt b/core/src/com/unciv/MainMenuScreen.kt index 3072509c5b..7175ba7305 100644 --- a/core/src/com/unciv/MainMenuScreen.kt +++ b/core/src/com/unciv/MainMenuScreen.kt @@ -179,13 +179,18 @@ class MainMenuScreen: CameraStageBaseScreen() { private fun autoLoadGame() { - ToastPopup("Loading...", this) + val loadingPopup = Popup(this) + loadingPopup.addGoodSizedLabel("Loading...") + loadingPopup.open() thread { // Load game from file to class on separate thread to avoid ANR... var savedGame: GameInfo try { savedGame = GameSaver.loadGameByName(autosave) } catch (outOfMemory: OutOfMemoryError) { - Gdx.app.postRunnable { ToastPopup("Not enough memory on phone to load game!", this) } + Gdx.app.postRunnable { + loadingPopup.close() + ToastPopup("Not enough memory on phone to load game!", this) + } return@thread } catch (ex: Exception) { // silent fail if we can't read the autosave for any reason - try to load the last autosave by turn number first // This can help for situations when the autosave is corrupted @@ -193,7 +198,10 @@ class MainMenuScreen: CameraStageBaseScreen() { val autosaves = GameSaver.getSaves().filter { it.name() != autosave && it.name().startsWith(autosave) } savedGame = GameSaver.loadGameFromFile(autosaves.maxBy { it.lastModified() }!!) } catch (ex: Exception) { - Gdx.app.postRunnable { ToastPopup("Cannot resume game!", this) } + Gdx.app.postRunnable { + loadingPopup.close() + ToastPopup("Cannot resume game!", this) + } return@thread } } @@ -203,6 +211,7 @@ class MainMenuScreen: CameraStageBaseScreen() { game.loadGame(savedGame) dispose() } catch (outOfMemory: OutOfMemoryError) { + loadingPopup.close() ToastPopup("Not enough memory on phone to load game!", this) } diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 30655f67fe..9293bc4128 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -43,7 +43,7 @@ class CityStats { val stats = Stats() for (cell in cityInfo.tilesInRange .filter { cityInfo.location == it.position || cityInfo.isWorked(it) || - it.getTileImprovement()?.hasUnique("Provides yield without assigned population")==true && it.owningCity == cityInfo }) + it.getTileImprovement()?.hasUnique("Tile provides yield without assigned population")==true && it.owningCity == cityInfo }) stats.add(cell.getTileStats(cityInfo, cityInfo.civInfo)) return stats } diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 771bea5893..77095a2360 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -220,7 +220,7 @@ open class TileInfo { fun isWorked(): Boolean = getWorkingCity() != null fun providesYield() = getCity() != null && (isCityCenter() || isWorked() - || getTileImprovement()?.hasUnique("Provides yield without assigned population")==true) + || getTileImprovement()?.hasUnique("Tile provides yield without assigned population")==true) fun isLocked(): Boolean { val workingCity = getWorkingCity()