diff --git a/core/src/com/unciv/MainMenuScreen.kt b/core/src/com/unciv/MainMenuScreen.kt index 6d20e9c2b3..2418098941 100644 --- a/core/src/com/unciv/MainMenuScreen.kt +++ b/core/src/com/unciv/MainMenuScreen.kt @@ -86,8 +86,8 @@ class MainMenuScreen: CameraStageBaseScreen() { } } - val column1 = Table().apply { defaults().pad(10f) } - val column2 = if(singleColumn) column1 else Table().apply { defaults().pad(10f) } + val column1 = Table().apply { defaults().pad(10f).fillX() } + val column2 = if(singleColumn) column1 else Table().apply { defaults().pad(10f).fillX() } val autosaveGame = GameSaver.getSave(autosave, false) if (autosaveGame.exists()) { diff --git a/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt b/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt index 1b2acc5bb6..d69f31af5e 100644 --- a/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt +++ b/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt @@ -11,6 +11,7 @@ import com.unciv.ui.utils.* class MapEditorMenuPopup(var mapEditorScreen: MapEditorScreen): Popup(mapEditorScreen) { init { + defaults().fillX() addButton("New map", 'n') { UncivGame.Current.setScreen(NewMapScreen(mapEditorScreen.tileMap.mapParameters)) } addButton("Save map", 's') { mapEditorScreen.game.setScreen(SaveAndLoadMapScreen(mapEditorScreen.tileMap, true, mapEditorScreen)); this.close() } addButton("Load map", 'l') { mapEditorScreen.game.setScreen(SaveAndLoadMapScreen(mapEditorScreen.tileMap, false, mapEditorScreen)); this.close() } diff --git a/core/src/com/unciv/ui/utils/Popup.kt b/core/src/com/unciv/ui/utils/Popup.kt index 9de9ac3638..2bbf2a63ea 100644 --- a/core/src/com/unciv/ui/utils/Popup.kt +++ b/core/src/com/unciv/ui/utils/Popup.kt @@ -73,6 +73,7 @@ open class Popup(val screen: CameraStageBaseScreen): Table(CameraStageBaseScreen /* All additions to the popup are to the inner table - we shouldn't care that there's an inner table at all */ final override fun add(actor: T): Cell = innerTable.add(actor) override fun row(): Cell = innerTable.row() + override fun defaults(): Cell = innerTable.defaults() fun addSeparator() = innerTable.addSeparator() /** diff --git a/core/src/com/unciv/ui/worldscreen/mainmenu/WorldScreenMenuPopup.kt b/core/src/com/unciv/ui/worldscreen/mainmenu/WorldScreenMenuPopup.kt index d659a1ba1a..849ef9c003 100644 --- a/core/src/com/unciv/ui/worldscreen/mainmenu/WorldScreenMenuPopup.kt +++ b/core/src/com/unciv/ui/worldscreen/mainmenu/WorldScreenMenuPopup.kt @@ -19,50 +19,31 @@ import com.unciv.ui.victoryscreen.VictoryScreen import com.unciv.ui.worldscreen.WorldScreen class WorldScreenMenuPopup(val worldScreen: WorldScreen) : Popup(worldScreen) { - - val buttonWidth = 200f - val buttonHeight = 30f - init { - addMenuButton("Main menu") { worldScreen.game.setScreen(MainMenuScreen()) } - addMenuButton("Civilopedia") { worldScreen.game.setScreen(CivilopediaScreen(worldScreen.gameInfo.ruleSet)) } - addMenuButton("Save game") { worldScreen.game.setScreen(SaveGameScreen(worldScreen.gameInfo)) } - addMenuButton("Load game") { worldScreen.game.setScreen(LoadGameScreen(worldScreen)) } + defaults().fillX() + addButton("Main menu") { worldScreen.game.setScreen(MainMenuScreen()) } + addButton("Civilopedia") { worldScreen.game.setScreen(CivilopediaScreen(worldScreen.gameInfo.ruleSet)) } + addButton("Save game") { worldScreen.game.setScreen(SaveGameScreen(worldScreen.gameInfo)) } + addButton("Load game") { worldScreen.game.setScreen(LoadGameScreen(worldScreen)) } - addMenuButton("Start new game") { + addButton("Start new game") { val newGameScreen = NewGameScreen(worldScreen, GameSetupInfo(worldScreen.gameInfo)) worldScreen.game.setScreen(newGameScreen) } - addMenuButton("Victory status") { worldScreen.game.setScreen(VictoryScreen(worldScreen)) } - addMenuButton("Options") { worldScreen.openOptionsPopup() } - addMenuButton("Community") { WorldScreenCommunityPopup(worldScreen).open(force = true) } - - addSquareButton(Constants.close) { + addButton("Victory status") { worldScreen.game.setScreen(VictoryScreen(worldScreen)) } + addButton("Options") { worldScreen.openOptionsPopup() } + addButton("Community") { close() - }.size(buttonWidth, buttonHeight) - } - - fun addMenuButton(text: String, action: () -> Unit) { - addSquareButton(text) { - action() - close() - }.size(buttonWidth, buttonHeight) - innerTable.addSeparator() - } - - - fun addSquareButton(text: String, action: () -> Unit): Cell { - val button = Table() - button.add(text.toLabel()) - button.onClick(action) - button.touchable = Touchable.enabled - return add(button).apply { row() } + WorldScreenCommunityPopup(worldScreen).open(force = true) } + addCloseButton() + pack() } } class WorldScreenCommunityPopup(val worldScreen: WorldScreen) : Popup(worldScreen) { init { + defaults().fillX() addButton("Discord") { Gdx.net.openURI("https://discord.gg/bjrB4Xw") close()