Multiplayer: Disable resign button on games where it's not your turn

This commit is contained in:
yairm210 2024-08-08 11:01:02 +03:00
parent 2ea36b512c
commit 9eb504a4bf
2 changed files with 12 additions and 10 deletions

View File

@ -786,6 +786,7 @@ class GameInfoPreview() {
}
fun getCivilization(civName: String) = civilizations.first { it.civName == civName }
fun getCurrentPlayerCiv() = getCivilization(currentPlayer)
}
/** Class to use when parsing jsons if you only want the serialization [version]. */

View File

@ -256,16 +256,12 @@ class MultiplayerScreen : PickerScreen() {
val helpButton = "Help".toTextButton()
helpButton.onClick {
val helpPopup = Popup(this)
helpPopup.addGoodSizedLabel("To create a multiplayer game, check the 'multiplayer' toggle in the New Game screen, and for each human player insert that player's user ID.")
.row()
helpPopup.addGoodSizedLabel("You can assign your own user ID there easily, and other players can copy their user IDs here and send them to you for you to include them in the game.")
.row()
helpPopup.addGoodSizedLabel("To create a multiplayer game, check the 'multiplayer' toggle in the New Game screen, and for each human player insert that player's user ID.").row()
helpPopup.addGoodSizedLabel("You can assign your own user ID there easily, and other players can copy their user IDs here and send them to you for you to include them in the game.").row()
helpPopup.row()
helpPopup.addGoodSizedLabel("Once you've created your game, the Game ID gets automatically copied to your clipboard so you can send it to the other players.")
.row()
helpPopup.addGoodSizedLabel("Players can enter your game by copying the game ID to the clipboard, and clicking on the 'Add multiplayer game' button")
.row()
helpPopup.addGoodSizedLabel("Once you've created your game, the Game ID gets automatically copied to your clipboard so you can send it to the other players.").row()
helpPopup.addGoodSizedLabel("Players can enter your game by copying the game ID to the clipboard, and clicking on the 'Add multiplayer game' button").row()
helpPopup.row()
helpPopup.addGoodSizedLabel("The symbol of your nation will appear next to the game when it's your turn").row()
@ -298,14 +294,19 @@ class MultiplayerScreen : PickerScreen() {
selectedGame = multiplayerGame
for (button in gameSpecificButtons)
button.enable()
for (button in gameSpecificButtons) button.enable()
if (multiplayerGame.preview != null) {
copyGameIdButton.enable()
} else {
copyGameIdButton.disable()
}
if (multiplayerGame.preview?.getCurrentPlayerCiv()?.playerId == game.settings.multiplayer.userId) {
resignButton.enable()
} else {
resignButton.disable()
}
rightSideButton.enable()
descriptionLabel.setText(MultiplayerHelpers.buildDescriptionText(multiplayerGame))