mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-12 16:59:11 +07:00
All UI changes in MultiplayerScreen now use postRunnable to run on the main thread
This commit is contained in:
@ -135,9 +135,9 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
thread(name="MultiplayerDownload") {
|
|
||||||
addGameButton.setText("Working...".tr())
|
addGameButton.setText("Working...".tr())
|
||||||
addGameButton.disable()
|
addGameButton.disable()
|
||||||
|
thread(name="MultiplayerDownload") {
|
||||||
try {
|
try {
|
||||||
// The tryDownload can take more than 500ms. Therefore, to avoid ANRs,
|
// The tryDownload can take more than 500ms. Therefore, to avoid ANRs,
|
||||||
// we need to run it in a different thread.
|
// we need to run it in a different thread.
|
||||||
@ -157,10 +157,12 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
|
|||||||
errorPopup.open()
|
errorPopup.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Gdx.app.postRunnable {
|
||||||
addGameButton.setText(addGameText)
|
addGameButton.setText(addGameText)
|
||||||
addGameButton.enable()
|
addGameButton.enable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//just loads the game from savefile
|
//just loads the game from savefile
|
||||||
//the game will be downloaded opon joining it anyway
|
//the game will be downloaded opon joining it anyway
|
||||||
@ -256,12 +258,15 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
|
|||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
//skipping one is not fatal
|
//skipping one is not fatal
|
||||||
//Trying to use as many prev. used strings as possible
|
//Trying to use as many prev. used strings as possible
|
||||||
|
Gdx.app.postRunnable {
|
||||||
ResponsePopup("Could not download game!".tr() + " ${multiplayerGameList.getValue(gameId)}", this)
|
ResponsePopup("Could not download game!".tr() + " ${multiplayerGameList.getValue(gameId)}", this)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Reset UI
|
//Reset UI
|
||||||
|
Gdx.app.postRunnable {
|
||||||
addGameButton.enable()
|
addGameButton.enable()
|
||||||
refreshButton.setText(refreshText)
|
refreshButton.setText(refreshText)
|
||||||
refreshButton.enable()
|
refreshButton.enable()
|
||||||
@ -269,6 +274,7 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
|
|||||||
reloadGameListUI()
|
reloadGameListUI()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Adds a Button to add the currently running game to multiplayerGameList
|
//Adds a Button to add the currently running game to multiplayerGameList
|
||||||
private fun addCurrentGameButton(){
|
private fun addCurrentGameButton(){
|
||||||
|
Reference in New Issue
Block a user