From eda4a572446852f05e5f03bdc88be2ebe29984e1 Mon Sep 17 00:00:00 2001 From: Gualdimar Date: Mon, 20 Mar 2023 01:01:06 +0200 Subject: [PATCH] Victory screen fixed button position (#8970) --- .../ui/screens/victoryscreen/VictoryScreen.kt | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreen.kt b/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreen.kt index 6119c79374..aaec9a61cd 100644 --- a/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreen.kt +++ b/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreen.kt @@ -28,14 +28,13 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() { private val playerCivInfo = worldScreen.viewingCiv private val enabledVictoryTypes = gameInfo.gameParameters.victoryTypes + private val headerTable = Table() private val contentsTable = Table() private var replayTimer : Timer.Task? = null init { val difficultyLabel = ("{Difficulty}: {${gameInfo.difficulty}}").toLabel() - difficultyLabel.setPosition(10f, stage.height - 10, Align.topLeft) - stage.addActor(difficultyLabel) val tabsTable = Table().apply { defaults().pad(10f) } val setMyVictoryButton = "Our status".toTextButton().onClick { setOurVictoryTable() } @@ -81,12 +80,30 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() { tabsTable.add(replayButton) } - topTable.add(tabsTable) - topTable.addSeparator() + val headerTableRightCell = Table() + val gameSpeedLabel = "{Game Speed}: {${gameInfo.gameParameters.speed}}".toLabel() + headerTableRightCell.add(gameSpeedLabel).row() + if(enabledVictoryTypes.contains("Time")) { + val maxTurnsLabel = "{Max Turns}: ${gameInfo.gameParameters.maxTurns}".toLabel() + headerTableRightCell.add(maxTurnsLabel).padTop(5f) + } + + val leftCell = headerTable.add(difficultyLabel).padLeft(10f).left() + headerTable.add(tabsTable).expandX().center() + val rightCell = headerTable.add(headerTableRightCell).padRight(10f).right() + headerTable.addSeparator() + headerTable.pack() + // Make the outer cells the same so that the middle one is properly centered + if(leftCell.actorWidth > rightCell.actorWidth) rightCell.width(leftCell.actorWidth) + else leftCell.width(rightCell.actorWidth) + + pickerPane.clearChildren() + pickerPane.add(headerTable).growX().row() + pickerPane.add(splitPane).expand().fill() + topTable.add(contentsTable) } - private fun wonOrLost(description: String, victoryType: String?, hasWon: Boolean) { val endGameMessage = when {