mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 03:23:17 -04:00
Resolved #8583 - games where it's your turn are displayed first in multiplayer popup
This commit is contained in:
parent
bbcf2d99e3
commit
cfc3fa05f0
@ -69,7 +69,7 @@ class GameList(
|
|||||||
|
|
||||||
private class GameDisplay(
|
private class GameDisplay(
|
||||||
multiplayerGameName: String,
|
multiplayerGameName: String,
|
||||||
preview: GameInfoPreview?,
|
var preview: GameInfoPreview?,
|
||||||
error: Exception?,
|
error: Exception?,
|
||||||
private val onSelected: (String) -> Unit
|
private val onSelected: (String) -> Unit
|
||||||
) : Table(), Comparable<GameDisplay> {
|
) : Table(), Comparable<GameDisplay> {
|
||||||
@ -86,7 +86,7 @@ private class GameDisplay(
|
|||||||
init {
|
init {
|
||||||
padBottom(5f)
|
padBottom(5f)
|
||||||
|
|
||||||
updateTurnIndicator(preview)
|
updateTurnIndicator()
|
||||||
updateErrorIndicator(error != null)
|
updateErrorIndicator(error != null)
|
||||||
add(statusIndicators)
|
add(statusIndicators)
|
||||||
add(gameButton)
|
add(gameButton)
|
||||||
@ -100,7 +100,8 @@ private class GameDisplay(
|
|||||||
refreshIndicator.remove()
|
refreshIndicator.remove()
|
||||||
}
|
}
|
||||||
events.receive(MultiplayerGameUpdated::class, isOurGame) {
|
events.receive(MultiplayerGameUpdated::class, isOurGame) {
|
||||||
updateTurnIndicator(it.preview)
|
preview = it.preview
|
||||||
|
updateTurnIndicator()
|
||||||
}
|
}
|
||||||
events.receive(MultiplayerGameUpdateSucceeded::class, isOurGame) {
|
events.receive(MultiplayerGameUpdateSucceeded::class, isOurGame) {
|
||||||
updateErrorIndicator(false)
|
updateErrorIndicator(false)
|
||||||
@ -115,20 +116,14 @@ private class GameDisplay(
|
|||||||
gameButton.setText(newName)
|
gameButton.setText(newName)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTurnIndicator(preview: GameInfoPreview?) {
|
private fun updateTurnIndicator() {
|
||||||
if (preview?.isUsersTurn() == true) {
|
if (isPlayersTurn()) statusIndicators.addActor(turnIndicator)
|
||||||
statusIndicators.addActor(turnIndicator)
|
else turnIndicator.remove()
|
||||||
} else {
|
|
||||||
turnIndicator.remove()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateErrorIndicator(hasError: Boolean) {
|
private fun updateErrorIndicator(hasError: Boolean) {
|
||||||
if (hasError) {
|
if (hasError) statusIndicators.addActor(errorIndicator)
|
||||||
statusIndicators.addActor(errorIndicator)
|
else errorIndicator.remove()
|
||||||
} else {
|
|
||||||
errorIndicator.remove()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createIndicator(imagePath: String): Actor {
|
private fun createIndicator(imagePath: String): Actor {
|
||||||
@ -139,7 +134,12 @@ private class GameDisplay(
|
|||||||
return container
|
return container
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun compareTo(other: GameDisplay): Int = gameName.compareTo(other.gameName)
|
fun isPlayersTurn() = preview?.isUsersTurn() == true
|
||||||
|
|
||||||
|
override fun compareTo(other: GameDisplay): Int =
|
||||||
|
if (isPlayersTurn() != other.isPlayersTurn()) // games where it's the player's turn are displayed first, thus must get the lower number
|
||||||
|
other.isPlayersTurn().compareTo(isPlayersTurn())
|
||||||
|
else gameName.compareTo(other.gameName)
|
||||||
override fun equals(other: Any?): Boolean = (other is GameDisplay) && (gameName == other.gameName)
|
override fun equals(other: Any?): Boolean = (other is GameDisplay) && (gameName == other.gameName)
|
||||||
override fun hashCode(): Int = gameName.hashCode()
|
override fun hashCode(): Int = gameName.hashCode()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user