Resolved crashes in game options table when changing base ruleset before the mod list was defined

This commit is contained in:
yairm210 2021-11-13 22:18:11 +02:00
parent eefe499fff
commit 4b43ff5b5e

View File

@ -37,6 +37,9 @@ class GameOptionsTable(
top() top()
defaults().pad(5f) defaults().pad(5f)
// We assign this first to make sure addBaseRulesetSelectBox doesn't reference a null object
if (!withoutMods) modCheckboxes = getModCheckboxes()
add(Table().apply { add(Table().apply {
defaults().pad(5f) defaults().pad(5f)
addBaseRulesetSelectBox() addBaseRulesetSelectBox()
@ -59,9 +62,7 @@ class GameOptionsTable(
checkboxTable.addReligionCheckbox(cityStateSlider) checkboxTable.addReligionCheckbox(cityStateSlider)
add(checkboxTable).center().row() add(checkboxTable).center().row()
if (!withoutMods) if (!withoutMods) add(modCheckboxes).row()
modCheckboxes = getModCheckboxes()
add(modCheckboxes).row()
pack() pack()
} }
@ -173,9 +174,6 @@ class GameOptionsTable(
"This base ruleset is not compatible with the previously selected\nextension mods. They have been disabled.".tr() "This base ruleset is not compatible with the previously selected\nextension mods. They have been disabled.".tr()
ToastPopup(toastMessage, previousScreen as CameraStageBaseScreen, 5000L) ToastPopup(toastMessage, previousScreen as CameraStageBaseScreen, 5000L)
// _technically_, [modCheckBoxes] can be [null] at this point,
// but only if you change the option while the table is still loading,
// but the timeframe for that is so small I'm just going to ignore that
modCheckboxes!!.disableAllCheckboxes() modCheckboxes!!.disableAllCheckboxes()
} else if (modLinkErrors.isWarnUser()) { } else if (modLinkErrors.isWarnUser()) {
val toastMessage = val toastMessage =