Moved screen orientation setting from advanced tab to display tab

This commit is contained in:
yairm210 2024-09-04 18:19:38 +03:00
parent 396bf60e25
commit 18c53f77d3
2 changed files with 23 additions and 22 deletions

View File

@ -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<ScreenOrientation>(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()

View File

@ -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<ScreenOrientation>(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()