From c68b19470f798fffc684548a2b5772c339639a0f Mon Sep 17 00:00:00 2001 From: Toxile Date: Mon, 16 Dec 2024 08:55:13 +0000 Subject: [PATCH] UI: standardised alignment and creation of options checkboxes, Unciv-themed slider buttons, multiplayer settings server text field layout and spacing (#12650) * [1] * [2] * [1] * [3] * [3] * [4] * Update template.properties --- .../jsons/translations/template.properties | 2 +- .../ui/components/widgets/UncivSlider.kt | 8 ++--- .../unciv/ui/popups/options/AdvancedTab.kt | 7 ++-- .../unciv/ui/popups/options/AutomationTab.kt | 5 +-- .../com/unciv/ui/popups/options/DebugTab.kt | 34 +++++-------------- .../com/unciv/ui/popups/options/DisplayTab.kt | 11 +++--- .../unciv/ui/popups/options/MultiplayerTab.kt | 10 +++--- 7 files changed, 30 insertions(+), 47 deletions(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index c4e9b357a7..d451fb0053 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -1885,7 +1885,7 @@ Enable multiplayer status button in singleplayer games = Update status of currently played game every: = In-game, update status of all games every: = Server address = -Check connection to server = +Check connection = Awaiting response... = Success! = Failed! = diff --git a/core/src/com/unciv/ui/components/widgets/UncivSlider.kt b/core/src/com/unciv/ui/components/widgets/UncivSlider.kt index d911d237a0..882ae1a9a1 100644 --- a/core/src/com/unciv/ui/components/widgets/UncivSlider.kt +++ b/core/src/com/unciv/ui/components/widgets/UncivSlider.kt @@ -156,9 +156,9 @@ class UncivSlider ( stepChanged() // Initialize tip formatting if (plusMinus) { - minusButton = "-".toLabel(ImageGetter.CHARCOAL, plusMinusFontSize) + minusButton = "-".toLabel(Color.WHITE, plusMinusFontSize) .apply { setAlignment(Align.center) } - .surroundWithCircle(plusMinusCircleSize) + .surroundWithCircle(plusMinusCircleSize, true, BaseScreen.skin.getColor("color")) minusButton.onClick { addToValue(-stepSize) } @@ -172,9 +172,9 @@ class UncivSlider ( if (plusMinus) { if (vertical) row() - plusButton = "+".toLabel(ImageGetter.CHARCOAL, plusMinusFontSize) + plusButton = "+".toLabel(Color.WHITE, plusMinusFontSize) .apply { setAlignment(Align.center) } - .surroundWithCircle(plusMinusCircleSize) + .surroundWithCircle(plusMinusCircleSize, true, BaseScreen.skin.getColor("color")) plusButton.onClick { addToValue(stepSize) } diff --git a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt index f42f21286f..a8704104fe 100644 --- a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt +++ b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt @@ -352,13 +352,10 @@ class AdvancedTab( } private fun addEasterEggsCheckBox() { - val checkbox = "Enable Easter Eggs".toCheckBox(settings.enableEasterEggs) { settings.enableEasterEggs = it } - add(checkbox).colspan(2).row() + optionsPopup.addCheckbox(this, "Enable Easter Eggs", settings.enableEasterEggs) { settings.enableEasterEggs = it } } private fun addEnlargeNotificationsCheckBox() { - val checkbox = "Enlarge selected notifications" - .toCheckBox(settings.enlargeSelectedNotification) { settings.enlargeSelectedNotification = it } - add(checkbox).colspan(2).row() + optionsPopup.addCheckbox(this, "Enlarge selected notifications", settings.enlargeSelectedNotification) { settings.enlargeSelectedNotification = it } } } diff --git a/core/src/com/unciv/ui/popups/options/AutomationTab.kt b/core/src/com/unciv/ui/popups/options/AutomationTab.kt index b92f03bd03..d207f706a4 100644 --- a/core/src/com/unciv/ui/popups/options/AutomationTab.kt +++ b/core/src/com/unciv/ui/popups/options/AutomationTab.kt @@ -2,6 +2,7 @@ package com.unciv.ui.popups.options import com.badlogic.gdx.scenes.scene2d.ui.Table import com.unciv.GUI +import com.unciv.Constants import com.unciv.logic.civilization.PlayerType import com.unciv.models.metadata.GameSettings import com.unciv.ui.components.extensions.addSeparator @@ -15,7 +16,7 @@ fun automationTab(optionsPopup: OptionsPopup defaults().pad(5f) val settings = optionsPopup.settings - add("Automation".toLabel(fontSize = 24)).colspan(2).row() + add("Automation".toLabel(fontSize = Constants.headingFontSize)).colspan(2).row() optionsPopup.addCheckbox(this, "Auto-assign city production", settings.autoAssignCityProduction, true) { shouldAutoAssignCityProduction -> settings.autoAssignCityProduction = shouldAutoAssignCityProduction @@ -56,7 +57,7 @@ fun automationTab(optionsPopup: OptionsPopup ) { settings.citiesAutoBombardAtEndOfTurn = it } addSeparator() - add("AutoPlay".toLabel(fontSize = 24)).colspan(2).row() + add("AutoPlay".toLabel(fontSize = Constants.headingFontSize)).colspan(2).row() // fun addAutoPlaySections() { // optionsPopup.addCheckbox( // this, diff --git a/core/src/com/unciv/ui/popups/options/DebugTab.kt b/core/src/com/unciv/ui/popups/options/DebugTab.kt index c27e1c89f7..0759c4ae55 100644 --- a/core/src/com/unciv/ui/popups/options/DebugTab.kt +++ b/core/src/com/unciv/ui/popups/options/DebugTab.kt @@ -49,36 +49,20 @@ fun debugTab( add(invalidInputLabel).colspan(2).row() } - add("Supercharged".toCheckBox(DebugUtils.SUPERCHARGED) { - DebugUtils.SUPERCHARGED = it - }).colspan(2).row() - add("View entire map".toCheckBox(DebugUtils.VISIBLE_MAP) { - DebugUtils.VISIBLE_MAP = it - }).colspan(2).row() - add("Show coordinates on tiles".toCheckBox(DebugUtils.SHOW_TILE_COORDS) { - DebugUtils.SHOW_TILE_COORDS = it - }).colspan(2).row() - add("Show tile image locations".toCheckBox(DebugUtils.SHOW_TILE_IMAGE_LOCATIONS) { - DebugUtils.SHOW_TILE_IMAGE_LOCATIONS = it - }).colspan(2).row() + optionsPopup.addCheckbox(this, "Supercharged", DebugUtils.SUPERCHARGED) { DebugUtils.SUPERCHARGED = it } + optionsPopup.addCheckbox(this, "View entire map", DebugUtils.VISIBLE_MAP) { DebugUtils.VISIBLE_MAP = it } + optionsPopup.addCheckbox(this, "Show coordinates on tiles", DebugUtils.SHOW_TILE_COORDS) { DebugUtils.SHOW_TILE_COORDS = it } + optionsPopup.addCheckbox(this, "Show tile image locations", DebugUtils.SHOW_TILE_IMAGE_LOCATIONS) { DebugUtils.SHOW_TILE_IMAGE_LOCATIONS = it } val curGameInfo = game.gameInfo if (curGameInfo != null) { - add("God mode (current game)".toCheckBox(curGameInfo.gameParameters.godMode) { - curGameInfo.gameParameters.godMode = it - }).colspan(2).row() + optionsPopup.addCheckbox(this, "God mode (current game)", curGameInfo.gameParameters.godMode) { curGameInfo.gameParameters.godMode = it } } - add("Save games compressed".toCheckBox(UncivFiles.saveZipped) { - UncivFiles.saveZipped = it - }).colspan(2).row() - add("Save maps compressed".toCheckBox(MapSaver.saveZipped) { - MapSaver.saveZipped = it - }).colspan(2).row() - - add("Gdx Scene2D debug".toCheckBox(BaseScreen.enableSceneDebug) { - BaseScreen.enableSceneDebug = it - }).colspan(2).row() + optionsPopup.addCheckbox(this, "Save games compressed", UncivFiles.saveZipped) { UncivFiles.saveZipped = it } + optionsPopup.addCheckbox(this, "Save maps compressed", MapSaver.saveZipped) { MapSaver.saveZipped = it } + optionsPopup.addCheckbox(this, "Gdx Scene2D debug", BaseScreen.enableSceneDebug) { BaseScreen.enableSceneDebug = it } + add(Table().apply { add("Unique misspelling threshold".toLabel()).left().fillX() diff --git a/core/src/com/unciv/ui/popups/options/DisplayTab.kt b/core/src/com/unciv/ui/popups/options/DisplayTab.kt index 5257994a30..3c221d498b 100644 --- a/core/src/com/unciv/ui/popups/options/DisplayTab.kt +++ b/core/src/com/unciv/ui/popups/options/DisplayTab.kt @@ -7,6 +7,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.SelectBox import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.utils.Array import com.unciv.GUI +import com.unciv.Constants import com.unciv.models.metadata.GameSettings import com.unciv.models.metadata.GameSettings.ScreenSize import com.unciv.models.skins.SkinCache @@ -41,7 +42,7 @@ fun displayTab( val settings = optionsPopup.settings - add("Screen".toLabel(fontSize = 24)).colspan(2).row() + add("Screen".toLabel(fontSize = Constants.headingFontSize)).colspan(2).row() addScreenSizeSelectBox(this, settings, optionsPopup.selectBoxMinWidth, onChange) addScreenOrientationSelectBox(this, settings, optionsPopup.selectBoxMinWidth, onChange) @@ -58,14 +59,14 @@ fun displayTab( } addSeparator() - add("Graphics".toLabel(fontSize = 24)).colspan(2).row() + add("Graphics".toLabel(fontSize = Constants.headingFontSize)).colspan(2).row() addTileSetSelectBox(this, settings, optionsPopup.selectBoxMinWidth, onChange) addUnitSetSelectBox(this, settings, optionsPopup.selectBoxMinWidth, onChange) addSkinSelectBox(this, settings, optionsPopup.selectBoxMinWidth, onChange) addSeparator() - add("UI".toLabel(fontSize = 24)).colspan(2).row() + add("UI".toLabel(fontSize = Constants.headingFontSize)).colspan(2).row() addNotificationScrollSelect(this, settings, optionsPopup.selectBoxMinWidth) addMinimapSizeSlider(this, settings, optionsPopup.selectBoxMinWidth) @@ -77,7 +78,7 @@ fun displayTab( addPediaUnitArtSizeSlider(this, settings, optionsPopup.selectBoxMinWidth) addSeparator() - add("Visual Hints".toLabel(fontSize = 24)).colspan(2).row() + add("Visual Hints".toLabel(fontSize = Constants.headingFontSize)).colspan(2).row() optionsPopup.addCheckbox(this, "Show unit movement arrows", settings.showUnitMovements, true) { settings.showUnitMovements = it } optionsPopup.addCheckbox(this, "Show suggested city locations for units that can found cities", settings.showSettlersSuggestedCityLocations, true) { settings.showSettlersSuggestedCityLocations = it } @@ -89,7 +90,7 @@ fun displayTab( addUnitIconAlphaSlider(this, settings, optionsPopup.selectBoxMinWidth) addSeparator() - add("Performance".toLabel(fontSize = 24)).colspan(2).row() + add("Performance".toLabel(fontSize = Constants.headingFontSize)).colspan(2).row() optionsPopup.addCheckbox(this, "Continuous rendering", settings.continuousRendering) { settings.continuousRendering = it diff --git a/core/src/com/unciv/ui/popups/options/MultiplayerTab.kt b/core/src/com/unciv/ui/popups/options/MultiplayerTab.kt index f087645805..a76c766300 100644 --- a/core/src/com/unciv/ui/popups/options/MultiplayerTab.kt +++ b/core/src/com/unciv/ui/popups/options/MultiplayerTab.kt @@ -5,6 +5,7 @@ import com.badlogic.gdx.Gdx import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextField import com.unciv.UncivGame +import com.unciv.Constants import com.unciv.logic.files.IMediaFinder import com.unciv.logic.multiplayer.Multiplayer import com.unciv.logic.multiplayer.storage.FileStorageRateLimitReached @@ -101,7 +102,7 @@ private fun addMultiplayerServerOptions( ) { val settings = optionsPopup.settings - val connectionToServerButton = "Check connection to server".toTextButton() + val connectionToServerButton = "Check connection".toTextButton() val textToShowForOnlineMultiplayerAddress = if (Multiplayer.usesCustomServer()) { settings.multiplayer.server @@ -115,7 +116,7 @@ private fun addMultiplayerServerOptions( serverIpTable.add("Server address".toLabel().onClick { multiplayerServerTextField.text = Gdx.app.clipboard.contents - }).colspan(2).row() + }).colspan(2).padBottom(Constants.defaultFontSize / 2.0f).row() multiplayerServerTextField.onChange { fixTextFieldUrlOnType(multiplayerServerTextField) // we can't trim on 'fixTextFieldUrlOnType' for reasons @@ -128,8 +129,7 @@ private fun addMultiplayerServerOptions( } serverIpTable.add(multiplayerServerTextField) - .minWidth(optionsPopup.stageToShowOn.width / 2) - .colspan(2).growX().padBottom(8f).row() + .minWidth(optionsPopup.stageToShowOn.width / 3).padRight(Constants.defaultFontSize.toFloat()).growX() serverIpTable.add(connectionToServerButton.onClick { val popup = Popup(optionsPopup.stageToShowOn).apply { @@ -152,7 +152,7 @@ private fun addMultiplayerServerOptions( popup.reuseWith("Failed!", true) } } - }).colspan(2).row() + }).row() if (UncivGame.Current.onlineMultiplayer.multiplayerServer.featureSet.authVersion > 0) { val passwordTextField = UncivTextField(