mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-05 07:49:17 +07:00
Hopefully solved ANR when loading the game initially
This commit is contained in:
@ -40,28 +40,34 @@ class UncivGame(val version: String) : Game() {
|
||||
lateinit var ruleset:Ruleset
|
||||
|
||||
override fun create() {
|
||||
// If this takes too long players, especially with older phones, get ANR problems.
|
||||
// Whatever needs graphics needs to be done on the main thread,
|
||||
// So it's basically a long set of deferred actions.
|
||||
// We probably could make this better by moving stuff that we can to another thread but ehhhhhhh
|
||||
|
||||
Current = this
|
||||
ruleset = Ruleset(true)
|
||||
Gdx.app.postRunnable {
|
||||
ruleset = Ruleset(true)
|
||||
|
||||
if(Gdx.app.type!= Application.ApplicationType.Desktop)
|
||||
viewEntireMapForDebug=false
|
||||
Gdx.input.setCatchKey(Input.Keys.BACK, true)
|
||||
settings = GameSaver().getGeneralSettings()
|
||||
if(settings.userId=="") { // assign permanent user id
|
||||
settings.userId = UUID.randomUUID().toString()
|
||||
settings.save()
|
||||
}
|
||||
if (GameSaver().getSave("Autosave").exists()) {
|
||||
try {
|
||||
loadGame("Autosave")
|
||||
} catch (ex: Exception) { // silent fail if we can't read the autosave
|
||||
startNewGame()
|
||||
if (Gdx.app.type != Application.ApplicationType.Desktop)
|
||||
viewEntireMapForDebug = false
|
||||
Gdx.input.setCatchKey(Input.Keys.BACK, true)
|
||||
settings = GameSaver().getGeneralSettings()
|
||||
if (settings.userId == "") { // assign permanent user id
|
||||
settings.userId = UUID.randomUUID().toString()
|
||||
settings.save()
|
||||
}
|
||||
}
|
||||
else setScreen(LanguagePickerScreen())
|
||||
if (GameSaver().getSave("Autosave").exists()) {
|
||||
try {
|
||||
loadGame("Autosave")
|
||||
} catch (ex: Exception) { // silent fail if we can't read the autosave
|
||||
startNewGame()
|
||||
}
|
||||
} else setScreen(LanguagePickerScreen())
|
||||
|
||||
thread { startMusic() }
|
||||
isInitialized=true
|
||||
thread { startMusic() }
|
||||
isInitialized = true
|
||||
}
|
||||
}
|
||||
|
||||
fun startMusic(){
|
||||
|
Reference in New Issue
Block a user