From 5a458e93cb1dec2574bfdcc7ba5d7351e00a5440 Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Sun, 14 Nov 2021 13:14:16 +0100 Subject: [PATCH] Fixed a crash when changing the base ruleset while in portrait mode (#5671) * Fixed a crash when changing the base ruleset while in portrait mode * Whoops --- .../com/unciv/ui/newgamescreen/GameOptionsTable.kt | 14 ++++++++++---- .../com/unciv/ui/newgamescreen/NewGameScreen.kt | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt b/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt index 048ba7f56c..b705d77eb4 100644 --- a/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt +++ b/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt @@ -15,13 +15,14 @@ import com.unciv.ui.utils.* class GameOptionsTable( val previousScreen: IPreviousScreen, - val withoutMods: Boolean = false, + val isPortrait: Boolean = false, val updatePlayerPickerTable:(desiredCiv:String)->Unit ) : Table(CameraStageBaseScreen.skin) { var gameParameters = previousScreen.gameSetupInfo.gameParameters val ruleset = previousScreen.ruleset var locked = false - private var modCheckboxes: ModCheckboxTable? = null + var modCheckboxes: ModCheckboxTable? = null + private set; init { getGameOptionsTable() @@ -38,7 +39,11 @@ class GameOptionsTable( defaults().pad(5f) // We assign this first to make sure addBaseRulesetSelectBox doesn't reference a null object - if (!withoutMods) modCheckboxes = getModCheckboxes() + if (isPortrait) { + modCheckboxes = getModCheckboxes(isPortrait = true) + } else { + modCheckboxes = getModCheckboxes() + } add(Table().apply { defaults().pad(5f) @@ -62,7 +67,8 @@ class GameOptionsTable( checkboxTable.addReligionCheckbox(cityStateSlider) add(checkboxTable).center().row() - if (!withoutMods) add(modCheckboxes).row() + if (!isPortrait) + add(modCheckboxes).row() pack() } diff --git a/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt b/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt index 90071fc46b..3c3f8e7462 100644 --- a/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt +++ b/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt @@ -162,7 +162,7 @@ class NewGameScreen( }).expandX().fillX().row() topTable.addSeparator(Color.DARK_GRAY, height = 1f) - topTable.add(newGameOptionsTable.getModCheckboxes(isPortrait = true)).expandX().fillX().row() + topTable.add(newGameOptionsTable.modCheckboxes).expandX().fillX().row() topTable.addSeparator(Color.DARK_GRAY, height = 1f) topTable.add(ExpanderTab("Map Options") {