mirror of
https://github.com/yairm210/Unciv.git
synced 2025-10-17 12:12:55 -04:00
Players can now continue to view (but not change) game data when other players are playing their turns
This commit is contained in:
parent
2f6eec5ff8
commit
cbf1b8bb11
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "com.unciv.app"
|
applicationId "com.unciv.app"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 282
|
versionCode 283
|
||||||
versionName "2.19.1"
|
versionName "2.19.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Had to add this crap for Travis to build, it wanted to sign the app
|
// Had to add this crap for Travis to build, it wanted to sign the app
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.unciv.ui.pickerscreens
|
package com.unciv.ui.pickerscreens
|
||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.*
|
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.models.gamebasics.tr
|
import com.unciv.models.gamebasics.tr
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ open class PickerScreen : CameraStageBaseScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected fun pick(rightButtonText: String) {
|
protected fun pick(rightButtonText: String) {
|
||||||
rightSideButton.enable()
|
if(UnCivGame.Current.worldScreen.isPlayersTurn) rightSideButton.enable()
|
||||||
rightSideButton.setText(rightButtonText)
|
rightSideButton.setText(rightButtonText)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -102,8 +102,6 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
|||||||
game.worldScreen.shouldUpdate = true
|
game.worldScreen.shouldUpdate = true
|
||||||
dispose()
|
dispose()
|
||||||
}
|
}
|
||||||
if(!UnCivGame.Current.worldScreen.isPlayersTurn)
|
|
||||||
rightSideButton.disable()
|
|
||||||
|
|
||||||
displayTutorials("TechPickerScreen")
|
displayTutorials("TechPickerScreen")
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import com.unciv.ui.utils.*
|
|||||||
import com.unciv.ui.worldscreen.bottombar.BattleTable
|
import com.unciv.ui.worldscreen.bottombar.BattleTable
|
||||||
import com.unciv.ui.worldscreen.bottombar.WorldScreenBottomBar
|
import com.unciv.ui.worldscreen.bottombar.WorldScreenBottomBar
|
||||||
import com.unciv.ui.worldscreen.unit.UnitActionsTable
|
import com.unciv.ui.worldscreen.unit.UnitActionsTable
|
||||||
|
import kotlin.concurrent.thread
|
||||||
|
|
||||||
class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||||
val gameInfo = game.gameInfo
|
val gameInfo = game.gameInfo
|
||||||
@ -258,60 +259,59 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
return@onClick
|
return@onClick
|
||||||
}
|
}
|
||||||
|
|
||||||
Gdx.input.inputProcessor = null // remove input processing - nothing will be clicked!
|
nextTurn(nextTurnButton) // If none of the above
|
||||||
nextTurnButton.disable()
|
|
||||||
nextTurnButton.setText("Working...".tr())
|
|
||||||
|
|
||||||
kotlin.concurrent.thread {
|
|
||||||
try {
|
|
||||||
gameInfo.nextTurn()
|
|
||||||
}
|
|
||||||
catch (ex:Exception){
|
|
||||||
game.settings.hasCrashedRecently=true
|
|
||||||
game.settings.save()
|
|
||||||
throw ex
|
|
||||||
}
|
|
||||||
|
|
||||||
if(gameInfo.turns % game.settings.turnsBetweenAutosaves == 0) {
|
|
||||||
GameSaver().autoSave(gameInfo) {
|
|
||||||
nextTurnButton.enable() // only enable the user to next turn once we've saved the current one
|
|
||||||
updateNextTurnButton()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else nextTurnButton.enable() // Enable immediately
|
|
||||||
|
|
||||||
// If we put this BEFORE the save game, then we try to save the game...
|
|
||||||
// but the main thread does other stuff, including showing tutorials which guess what? Changes the game data
|
|
||||||
// BOOM! Exception!
|
|
||||||
// That's why this needs to be after the game is saved.
|
|
||||||
shouldUpdate=true
|
|
||||||
|
|
||||||
// do this on main thread
|
|
||||||
Gdx.app.postRunnable {
|
|
||||||
updateNextTurnButton()
|
|
||||||
}
|
|
||||||
Gdx.input.inputProcessor = stage
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nextTurnButton
|
return nextTurnButton
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun nextTurn(nextTurnButton: TextButton) {
|
||||||
|
isPlayersTurn = false
|
||||||
|
shouldUpdate = true
|
||||||
|
|
||||||
|
thread {
|
||||||
|
try {
|
||||||
|
gameInfo.nextTurn()
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
game.settings.hasCrashedRecently = true
|
||||||
|
game.settings.save()
|
||||||
|
throw ex
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameInfo.turns % game.settings.turnsBetweenAutosaves == 0) {
|
||||||
|
GameSaver().autoSave(gameInfo) {
|
||||||
|
nextTurnButton.enable() // only enable the user to next turn once we've saved the current one
|
||||||
|
updateNextTurnButton()
|
||||||
|
}
|
||||||
|
} else nextTurnButton.enable() // Enable immediately
|
||||||
|
|
||||||
|
// If we put this BEFORE the save game, then we try to save the game...
|
||||||
|
// but the main thread does other stuff, including showing tutorials which guess what? Changes the game data
|
||||||
|
// BOOM! Exception!
|
||||||
|
// That's why this needs to be after the game is saved.
|
||||||
|
isPlayersTurn = true
|
||||||
|
shouldUpdate = true
|
||||||
|
|
||||||
|
// do this on main thread
|
||||||
|
Gdx.app.postRunnable {
|
||||||
|
updateNextTurnButton()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun updateNextTurnButton() {
|
fun updateNextTurnButton() {
|
||||||
val text = if (viewingCiv.shouldGoToDueUnit())
|
val text = when {
|
||||||
"Next unit"
|
!isPlayersTurn -> "Waiting for other players..."
|
||||||
else if(viewingCiv.cities.any{it.cityConstructions.currentConstruction==""})
|
viewingCiv.shouldGoToDueUnit() -> "Next unit"
|
||||||
"Pick construction"
|
viewingCiv.cities.any{it.cityConstructions.currentConstruction==""} -> "Pick construction"
|
||||||
else if(viewingCiv.shouldOpenTechPicker())
|
viewingCiv.shouldOpenTechPicker() -> "Pick a tech"
|
||||||
"Pick a tech"
|
viewingCiv.policies.shouldOpenPolicyPicker -> "Pick a policy"
|
||||||
else if(viewingCiv.policies.shouldOpenPolicyPicker)
|
else -> "Next turn"
|
||||||
"Pick a policy"
|
}
|
||||||
else
|
|
||||||
"Next turn"
|
|
||||||
nextTurnButton.setText(text.tr())
|
nextTurnButton.setText(text.tr())
|
||||||
nextTurnButton.color = if(text=="Next turn") Color.WHITE else Color.GRAY
|
nextTurnButton.color = if(text=="Next turn") Color.WHITE else Color.GRAY
|
||||||
nextTurnButton.pack()
|
nextTurnButton.pack()
|
||||||
if(AlertPopup.isOpen) nextTurnButton.disable()
|
if(AlertPopup.isOpen || !isPlayersTurn) nextTurnButton.disable()
|
||||||
else nextTurnButton.enable()
|
else nextTurnButton.enable()
|
||||||
nextTurnButton.setPosition(stage.width - nextTurnButton.width - 10f, topBar.y - nextTurnButton.height - 10f)
|
nextTurnButton.setPosition(stage.width - nextTurnButton.width - 10f, topBar.y - nextTurnButton.height - 10f)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user