From 18c53f77d3c5702e72fafcde5ef79eaa91c68c26 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Wed, 4 Sep 2024 18:19:38 +0300 Subject: [PATCH] Moved screen orientation setting from advanced tab to display tab --- .../unciv/ui/popups/options/AdvancedTab.kt | 19 -------------- .../com/unciv/ui/popups/options/DisplayTab.kt | 26 ++++++++++++++++--- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt index b987321e71..3643985bd0 100644 --- a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt +++ b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt @@ -34,7 +34,6 @@ import com.unciv.ui.popups.ConfirmPopup import com.unciv.ui.screens.basescreen.BaseScreen import com.unciv.utils.Concurrency import com.unciv.utils.Display -import com.unciv.utils.ScreenOrientation import com.unciv.utils.launchOnGLThread import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -55,9 +54,6 @@ class AdvancedTab( addAutosaveTurnsSelectBox() addSeparator(Color.GRAY) - if (Display.hasOrientation()) - addOrientationSelectBox() - if (Display.hasCutout()) addCutoutCheckbox() @@ -96,21 +92,6 @@ class AdvancedTab( } } - private fun addOrientationSelectBox() { - add("Screen orientation".toLabel()).left().fillX() - - val selectBox = SelectBox(skin) - selectBox.items = Array(ScreenOrientation.entries.toTypedArray()) - selectBox.selected = settings.displayOrientation - selectBox.onChange { - val orientation = selectBox.selected - settings.displayOrientation = orientation - Display.setOrientation(orientation) - optionsPopup.reopenAfterDisplayLayoutChange() - } - - add(selectBox).minWidth(optionsPopup.selectBoxMinWidth).pad(10f).row() - } private fun addAutosaveTurnsSelectBox() { add("Turns between autosaves".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 d36aff6bbc..5257994a30 100644 --- a/core/src/com/unciv/ui/popups/options/DisplayTab.kt +++ b/core/src/com/unciv/ui/popups/options/DisplayTab.kt @@ -23,10 +23,11 @@ import com.unciv.ui.components.widgets.UncivSlider import com.unciv.ui.components.widgets.WrappableLabel import com.unciv.ui.images.ImageGetter import com.unciv.ui.popups.ConfirmPopup -import com.unciv.ui.screens.basescreen.BaseScreen +import com.unciv.ui.screens.basescreen.BaseScreen.Companion.skin import com.unciv.ui.screens.worldscreen.NotificationsScroll import com.unciv.utils.Display import com.unciv.utils.ScreenMode +import com.unciv.utils.ScreenOrientation /** * @param onChange Callback for _major_ changes, OptionsPopup will rebuild itself and the WorldScreen @@ -34,7 +35,7 @@ import com.unciv.utils.ScreenMode fun displayTab( optionsPopup: OptionsPopup, onChange: () -> Unit, -) = Table(BaseScreen.skin).apply { +) = Table(skin).apply { pad(10f) defaults().pad(2.5f) @@ -42,8 +43,9 @@ fun displayTab( add("Screen".toLabel(fontSize = 24)).colspan(2).row() - addScreenModeSelectBox(this, settings, optionsPopup.selectBoxMinWidth) addScreenSizeSelectBox(this, settings, optionsPopup.selectBoxMinWidth, onChange) + addScreenOrientationSelectBox(this, settings, optionsPopup.selectBoxMinWidth, onChange) + addScreenModeSelectBox(this, settings, optionsPopup.selectBoxMinWidth) if (Gdx.app.type == Application.ApplicationType.Desktop) { @@ -205,6 +207,24 @@ private fun addScreenSizeSelectBox(table: Table, settings: GameSettings, selectB } } +private fun addScreenOrientationSelectBox(table: Table, settings: GameSettings, selectBoxMinWidth: Float, onOrientationChange: () -> Unit){ + if (!Display.hasOrientation()) return + + table.add("Screen orientation".toLabel()).left().fillX() + + val selectBox = SelectBox(skin) + selectBox.items = Array(ScreenOrientation.entries.toTypedArray()) + selectBox.selected = settings.displayOrientation + selectBox.onChange { + val orientation = selectBox.selected + settings.displayOrientation = orientation + Display.setOrientation(orientation) + onOrientationChange() + } + + table.add(selectBox).minWidth(selectBoxMinWidth).pad(10f).row() +} + private fun addTileSetSelectBox(table: Table, settings: GameSettings, selectBoxMinWidth: Float, onTilesetChange: () -> Unit) { table.add("Tileset".toLabel()).left().fillX()