mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-12 00:39:56 +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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addGameButton.setText("Working...".tr())
|
||||||
|
addGameButton.disable()
|
||||||
thread(name="MultiplayerDownload") {
|
thread(name="MultiplayerDownload") {
|
||||||
addGameButton.setText("Working...".tr())
|
|
||||||
addGameButton.disable()
|
|
||||||
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,8 +157,10 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
|
|||||||
errorPopup.open()
|
errorPopup.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addGameButton.setText(addGameText)
|
Gdx.app.postRunnable {
|
||||||
addGameButton.enable()
|
addGameButton.setText(addGameText)
|
||||||
|
addGameButton.enable()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,14 +183,14 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//reloads all gameFiles to refresh UI
|
//reloads all gameFiles to refresh UI
|
||||||
fun reloadGameListUI(){
|
fun reloadGameListUI() {
|
||||||
val leftSubTable = Table()
|
val leftSubTable = Table()
|
||||||
val gameSaver = GameSaver
|
val gameSaver = GameSaver
|
||||||
val savedGames : List<String>?
|
val savedGames: List<String>?
|
||||||
|
|
||||||
try {
|
try {
|
||||||
savedGames = gameSaver.getSaves(true)
|
savedGames = gameSaver.getSaves(true)
|
||||||
}catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
val errorPopup = Popup(this)
|
val errorPopup = Popup(this)
|
||||||
errorPopup.addGoodSizedLabel("Could not refresh!".tr())
|
errorPopup.addGoodSizedLabel("Could not refresh!".tr())
|
||||||
errorPopup.row()
|
errorPopup.row()
|
||||||
@ -208,7 +210,7 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
|
|||||||
|
|
||||||
if (isUsersTurn(game)) {
|
if (isUsersTurn(game)) {
|
||||||
gameTable.add(ImageGetter.getNationIndicator(game.currentPlayerCiv.nation, 45f))
|
gameTable.add(ImageGetter.getNationIndicator(game.currentPlayerCiv.nation, 45f))
|
||||||
}else{
|
} else {
|
||||||
gameTable.add()
|
gameTable.add()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +232,7 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
|
|||||||
|
|
||||||
gameTable.add(gameButton).pad(5f).row()
|
gameTable.add(gameButton).pad(5f).row()
|
||||||
leftSubTable.add(gameTable).row()
|
leftSubTable.add(gameTable).row()
|
||||||
}catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
//skipping one save is not fatal
|
//skipping one save is not fatal
|
||||||
ResponsePopup("Could not refresh!".tr(), this)
|
ResponsePopup("Could not refresh!".tr(), this)
|
||||||
continue
|
continue
|
||||||
@ -256,17 +258,21 @@ 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
|
||||||
ResponsePopup("Could not download game!".tr() + " ${multiplayerGameList.getValue(gameId)}", this)
|
Gdx.app.postRunnable {
|
||||||
|
ResponsePopup("Could not download game!".tr() + " ${multiplayerGameList.getValue(gameId)}", this)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Reset UI
|
//Reset UI
|
||||||
addGameButton.enable()
|
Gdx.app.postRunnable {
|
||||||
refreshButton.setText(refreshText)
|
addGameButton.enable()
|
||||||
refreshButton.enable()
|
refreshButton.setText(refreshText)
|
||||||
unselectGame()
|
refreshButton.enable()
|
||||||
reloadGameListUI()
|
unselectGame()
|
||||||
|
reloadGameListUI()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user