mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 22:37:02 -04:00
Solved ANR when loading large games from the load screen
This commit is contained in:
parent
5e157b66d0
commit
925e092629
@ -38,10 +38,14 @@ class LoadGameScreen(previousScreen:CameraStageBaseScreen) : PickerScreen() {
|
||||
topTable.add(rightSideTable)
|
||||
|
||||
rightSideButton.onClick {
|
||||
ToastPopup("Loading...", this)
|
||||
thread {
|
||||
try {
|
||||
UncivGame.Current.loadGame(selectedSave)
|
||||
}
|
||||
catch (ex:Exception){
|
||||
// This is what can lead to ANRs - reading the file and setting the transients, that's why this is in another thread
|
||||
val loadedGame = GameSaver.loadGameByName(selectedSave)
|
||||
Gdx.app.postRunnable { UncivGame.Current.loadGame(loadedGame) }
|
||||
} catch (ex: Exception) {
|
||||
Gdx.app.postRunnable {
|
||||
val cantLoadGamePopup = Popup(this)
|
||||
cantLoadGamePopup.addGoodSizedLabel("It looks like your saved game can't be loaded!").row()
|
||||
if (ex is UncivShowableException && ex.localizedMessage != null) {
|
||||
@ -59,6 +63,8 @@ class LoadGameScreen(previousScreen:CameraStageBaseScreen) : PickerScreen() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user