mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 05:41:11 +07:00
Fixed Crash (#3549)
the game crashed because the UncivShowableException thrown by GameInfo, when used mods are not installed anymore, did not get catched
This commit is contained in:
@ -8,6 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.*
|
|||||||
import com.unciv.logic.GameInfo
|
import com.unciv.logic.GameInfo
|
||||||
import com.unciv.logic.GameSaver
|
import com.unciv.logic.GameSaver
|
||||||
import com.unciv.logic.IdChecker
|
import com.unciv.logic.IdChecker
|
||||||
|
import com.unciv.logic.UncivShowableException
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.pickerscreens.PickerScreen
|
import com.unciv.ui.pickerscreens.PickerScreen
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
@ -209,22 +210,27 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (gameSaveFile in savedGames) {
|
for (gameSaveFile in savedGames) {
|
||||||
try {
|
|
||||||
val gameTable = Table()
|
val gameTable = Table()
|
||||||
val turnIndicator = Table()
|
val turnIndicator = Table()
|
||||||
|
var currentTurnUser = ""
|
||||||
|
|
||||||
|
try {
|
||||||
turnIndicator.add(ImageGetter.getImage("EmojiIcons/Turn"))
|
turnIndicator.add(ImageGetter.getImage("EmojiIcons/Turn"))
|
||||||
gameTable.add(turnIndicator)
|
gameTable.add(turnIndicator)
|
||||||
|
|
||||||
val lastModifiedMillis = gameSaveFile.lastModified()
|
val lastModifiedMillis = gameSaveFile.lastModified()
|
||||||
val gameButton = gameSaveFile.name().toTextButton()
|
val gameButton = gameSaveFile.name().toTextButton()
|
||||||
var currentTurnUser = ""
|
|
||||||
|
|
||||||
gameButton.onClick {
|
gameButton.onClick {
|
||||||
selectedGameFile = gameSaveFile
|
selectedGameFile = gameSaveFile
|
||||||
if (multiplayerGames[gameSaveFile] != null){
|
if (multiplayerGames[gameSaveFile] != null){
|
||||||
copyGameIdButton.enable()
|
copyGameIdButton.enable()
|
||||||
editButton.enable()
|
editButton.enable()
|
||||||
|
} else {
|
||||||
|
copyGameIdButton.disable()
|
||||||
|
editButton.disable()
|
||||||
}
|
}
|
||||||
|
|
||||||
rightSideButton.enable()
|
rightSideButton.enable()
|
||||||
|
|
||||||
//get Minutes since last modified
|
//get Minutes since last modified
|
||||||
@ -234,7 +240,16 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
|
|||||||
descriptionLabel.setText(descriptionText)
|
descriptionLabel.setText(descriptionText)
|
||||||
}
|
}
|
||||||
|
|
||||||
thread {
|
gameTable.add(gameButton).pad(5f).row()
|
||||||
|
leftSubTable.add(gameTable).row()
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
//skipping one save is not fatal
|
||||||
|
ToastPopup("Could not refresh!".tr(), this)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
thread (name = "loadGameFile") {
|
||||||
|
try {
|
||||||
val game = gameSaver.loadGameFromFile(gameSaveFile)
|
val game = gameSaver.loadGameFromFile(gameSaveFile)
|
||||||
|
|
||||||
//Add games to list so saves don't have to be loaded as Files so often
|
//Add games to list so saves don't have to be loaded as Files so often
|
||||||
@ -250,14 +265,24 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
|
|||||||
//set variable so it can be displayed when gameButton.onClick gets called
|
//set variable so it can be displayed when gameButton.onClick gets called
|
||||||
currentTurnUser = game.currentPlayer
|
currentTurnUser = game.currentPlayer
|
||||||
}
|
}
|
||||||
}
|
}catch (usx: UncivShowableException){
|
||||||
|
//Gets thrown when mods are not installed
|
||||||
|
Gdx.app.postRunnable {
|
||||||
|
val popup = Popup(this)
|
||||||
|
popup.addGoodSizedLabel(usx.message!! + " in ${gameSaveFile.name()}").row()
|
||||||
|
popup.addCloseButton()
|
||||||
|
popup.open(true)
|
||||||
|
|
||||||
gameTable.add(gameButton).pad(5f).row()
|
turnIndicator.clear()
|
||||||
leftSubTable.add(gameTable).row()
|
turnIndicator.add(ImageGetter.getImage("StatIcons/Malcontent")).size(50f)
|
||||||
} catch (ex: Exception) {
|
}
|
||||||
//skipping one save is not fatal
|
}catch (ex: Exception){
|
||||||
|
Gdx.app.postRunnable {
|
||||||
ToastPopup("Could not refresh!".tr(), this)
|
ToastPopup("Could not refresh!".tr(), this)
|
||||||
continue
|
turnIndicator.clear()
|
||||||
|
turnIndicator.add(ImageGetter.getImage("StatIcons/Malcontent")).size(50f)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user