mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-29 22:29:15 +07:00
More steps towards upload/downloading multiplayer games
This commit is contained in:
@ -72,6 +72,7 @@ class NewGameScreen: PickerScreen(){
|
|||||||
val cantUploadNewGamePopup = PopupTable(this)
|
val cantUploadNewGamePopup = PopupTable(this)
|
||||||
cantUploadNewGamePopup.addGoodSizedLabel("Can't upload the new game!")
|
cantUploadNewGamePopup.addGoodSizedLabel("Can't upload the new game!")
|
||||||
cantUploadNewGamePopup.addCloseButton()
|
cantUploadNewGamePopup.addCloseButton()
|
||||||
|
cantUploadNewGamePopup.open()
|
||||||
newGame = null
|
newGame = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
update()
|
update()
|
||||||
|
|
||||||
if(gameInfo.gameParameters.isOnlineMultiplayer && !gameInfo.isUpToDate) {
|
if(gameInfo.gameParameters.isOnlineMultiplayer && !gameInfo.isUpToDate) {
|
||||||
|
isPlayersTurn = false // until we're up to date, don't let the player do anything
|
||||||
val loadingGamePopup = PopupTable(this)
|
val loadingGamePopup = PopupTable(this)
|
||||||
loadingGamePopup.add("Loading latest game state...")
|
loadingGamePopup.add("Loading latest game state...")
|
||||||
loadingGamePopup.open()
|
loadingGamePopup.open()
|
||||||
@ -113,6 +114,10 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
game.loadGame(latestGame)
|
game.loadGame(latestGame)
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
loadingGamePopup.close()
|
loadingGamePopup.close()
|
||||||
|
val couldntDownloadLatestGame = PopupTable(this)
|
||||||
|
couldntDownloadLatestGame.addGoodSizedLabel("Couldn't download the latest game state!")
|
||||||
|
couldntDownloadLatestGame.addCloseButton()
|
||||||
|
couldntDownloadLatestGame.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,7 +133,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
val gameClone = gameInfo.clone()
|
val gameClone = gameInfo.clone()
|
||||||
gameClone.setTransients()
|
gameClone.setTransients()
|
||||||
val cloneCivilization = gameClone.getCurrentPlayerCivilization()
|
val cloneCivilization = gameClone.getCurrentPlayerCivilization()
|
||||||
kotlin.concurrent.thread {
|
thread {
|
||||||
gameInfo.civilizations.forEach { it.setCitiesConnectedToCapitalTransients() }
|
gameInfo.civilizations.forEach { it.setCitiesConnectedToCapitalTransients() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,12 +308,16 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
game.gameInfo = gameInfoClone
|
game.gameInfo = gameInfoClone
|
||||||
|
|
||||||
val shouldAutoSave = gameInfoClone.turns % game.settings.turnsBetweenAutosaves == 0
|
val shouldAutoSave = !gameInfo.gameParameters.isOnlineMultiplayer &&
|
||||||
|
gameInfoClone.turns % game.settings.turnsBetweenAutosaves == 0
|
||||||
|
|
||||||
// create a new worldscreen to show the new stuff we've changed, and switch out the current screen.
|
// create a new worldscreen to show the new stuff we've changed, and switch out the current screen.
|
||||||
// do this on main thread - it's the only one that has a GL context to create images from
|
// do this on main thread - it's the only one that has a GL context to create images from
|
||||||
Gdx.app.postRunnable {
|
Gdx.app.postRunnable {
|
||||||
if(gameInfoClone.currentPlayerCiv.civName == viewingCiv.civName) {
|
if (gameInfoClone.currentPlayerCiv.civName != viewingCiv.civName
|
||||||
|
&& !gameInfoClone.gameParameters.isOnlineMultiplayer)
|
||||||
|
UnCivGame.Current.screen = PlayerReadyScreen(gameInfoClone.getCurrentPlayerCivilization())
|
||||||
|
else {
|
||||||
val newWorldScreen = WorldScreen(gameInfoClone.currentPlayerCiv)
|
val newWorldScreen = WorldScreen(gameInfoClone.currentPlayerCiv)
|
||||||
newWorldScreen.tileMapHolder.scrollX = tileMapHolder.scrollX
|
newWorldScreen.tileMapHolder.scrollX = tileMapHolder.scrollX
|
||||||
newWorldScreen.tileMapHolder.scrollY = tileMapHolder.scrollY
|
newWorldScreen.tileMapHolder.scrollY = tileMapHolder.scrollY
|
||||||
@ -318,7 +327,6 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
game.worldScreen = newWorldScreen
|
game.worldScreen = newWorldScreen
|
||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
}
|
}
|
||||||
else UnCivGame.Current.screen = PlayerReadyScreen(gameInfoClone.getCurrentPlayerCivilization())
|
|
||||||
|
|
||||||
if(shouldAutoSave) {
|
if(shouldAutoSave) {
|
||||||
game.worldScreen.nextTurnButton.disable()
|
game.worldScreen.nextTurnButton.disable()
|
||||||
@ -326,6 +334,16 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
game.worldScreen.nextTurnButton.enable() // only enable the user to next turn once we've saved the current one
|
game.worldScreen.nextTurnButton.enable() // only enable the user to next turn once we've saved the current one
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(gameInfo.gameParameters.isOnlineMultiplayer) {
|
||||||
|
try {
|
||||||
|
OnlineMultiplayer().tryUploadGame(gameInfoClone)
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
val cantUploadNewGamePopup = PopupTable(this)
|
||||||
|
cantUploadNewGamePopup.addGoodSizedLabel("Can't upload the new game!")
|
||||||
|
cantUploadNewGamePopup.addCloseButton()
|
||||||
|
cantUploadNewGamePopup.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user