mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
Resolved #3705 - loading game popup stays until the game is loaded
This commit is contained in:
parent
dd4778495e
commit
57b1a01e2c
@ -179,13 +179,18 @@ class MainMenuScreen: CameraStageBaseScreen() {
|
|||||||
|
|
||||||
|
|
||||||
private fun autoLoadGame() {
|
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...
|
thread { // Load game from file to class on separate thread to avoid ANR...
|
||||||
var savedGame: GameInfo
|
var savedGame: GameInfo
|
||||||
try {
|
try {
|
||||||
savedGame = GameSaver.loadGameByName(autosave)
|
savedGame = GameSaver.loadGameByName(autosave)
|
||||||
} catch (outOfMemory: OutOfMemoryError) {
|
} 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
|
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
|
} 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
|
// 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) }
|
val autosaves = GameSaver.getSaves().filter { it.name() != autosave && it.name().startsWith(autosave) }
|
||||||
savedGame = GameSaver.loadGameFromFile(autosaves.maxBy { it.lastModified() }!!)
|
savedGame = GameSaver.loadGameFromFile(autosaves.maxBy { it.lastModified() }!!)
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
Gdx.app.postRunnable { ToastPopup("Cannot resume game!", this) }
|
Gdx.app.postRunnable {
|
||||||
|
loadingPopup.close()
|
||||||
|
ToastPopup("Cannot resume game!", this)
|
||||||
|
}
|
||||||
return@thread
|
return@thread
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,6 +211,7 @@ class MainMenuScreen: CameraStageBaseScreen() {
|
|||||||
game.loadGame(savedGame)
|
game.loadGame(savedGame)
|
||||||
dispose()
|
dispose()
|
||||||
} catch (outOfMemory: OutOfMemoryError) {
|
} catch (outOfMemory: OutOfMemoryError) {
|
||||||
|
loadingPopup.close()
|
||||||
ToastPopup("Not enough memory on phone to load game!", this)
|
ToastPopup("Not enough memory on phone to load game!", this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class CityStats {
|
|||||||
val stats = Stats()
|
val stats = Stats()
|
||||||
for (cell in cityInfo.tilesInRange
|
for (cell in cityInfo.tilesInRange
|
||||||
.filter { cityInfo.location == it.position || cityInfo.isWorked(it) ||
|
.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))
|
stats.add(cell.getTileStats(cityInfo, cityInfo.civInfo))
|
||||||
return stats
|
return stats
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ open class TileInfo {
|
|||||||
|
|
||||||
fun isWorked(): Boolean = getWorkingCity() != null
|
fun isWorked(): Boolean = getWorkingCity() != null
|
||||||
fun providesYield() = getCity() != null && (isCityCenter() || isWorked()
|
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 {
|
fun isLocked(): Boolean {
|
||||||
val workingCity = getWorkingCity()
|
val workingCity = getWorkingCity()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user