Separated base ruleset mods in new game screen - cannot activate multiple base ruleset mods

This commit is contained in:
Yair Morgenstern 2020-08-31 21:24:36 +03:00
parent ce8e410969
commit c61ec2120b
2 changed files with 30 additions and 7 deletions

View file

@ -258,6 +258,8 @@ It looks like we can't make a map with the parameters you requested! =
Maybe you put too many players into too small a map? = Maybe you put too many players into too small a map? =
No human players selected! = No human players selected! =
Mods: = Mods: =
Base ruleset mods: =
Extension mods: =
# Multiplayer # Multiplayer

View file

@ -178,12 +178,14 @@ class GameOptionsTable(val previousScreen: IPreviousScreen, val updatePlayerPick
} }
fun Table.addModCheckboxes() { fun Table.addModCheckboxes() {
val modRulesets = RulesetCache.values.filter { it.name != "" val modRulesets = RulesetCache.values.filter {
&& (it.name in gameParameters.mods || !it.modOptions.uniques.contains("Scenario only")) } // Don't allow scenario mods for a regular 'new game' it.name != ""
if (modRulesets.isEmpty()) return && (it.name in gameParameters.mods || !it.modOptions.uniques.contains("Scenario only"))
} // Don't allow scenario mods for a regular 'new game'
val baseRulesetCheckboxes = ArrayList<CheckBox>()
val extentionRulesetModButtons = ArrayList<CheckBox>()
add("Mods:".toLabel(fontSize = 24)).padTop(16f).colspan(2).row()
val modCheckboxTable = Table().apply { defaults().pad(5f) }
for (mod in modRulesets) { for (mod in modRulesets) {
val checkBox = CheckBox(mod.name.tr(), CameraStageBaseScreen.skin) val checkBox = CheckBox(mod.name.tr(), CameraStageBaseScreen.skin)
checkBox.isDisabled = locked checkBox.isDisabled = locked
@ -199,13 +201,32 @@ class GameOptionsTable(val previousScreen: IPreviousScreen, val updatePlayerPick
if (modNations != null && modNations.size > 0) { if (modNations != null && modNations.size > 0) {
desiredCiv = modNations.keys.first() desiredCiv = modNations.keys.first()
} }
if (mod.modOptions.isBaseRuleset)
for (oldBaseRuleset in gameParameters.mods)
if (modRulesets.firstOrNull { it.name == oldBaseRuleset }?.modOptions?.isBaseRuleset == true)
gameParameters.mods.remove(oldBaseRuleset)
} }
updatePlayerPickerTable(desiredCiv) updatePlayerPickerTable(desiredCiv)
} }
modCheckboxTable.add(checkBox).row() if (mod.modOptions.isBaseRuleset) baseRulesetCheckboxes.add(checkBox)
else extentionRulesetModButtons.add(checkBox)
}
if (baseRulesetCheckboxes.any()) {
add("Base ruleset mods:".toLabel(fontSize = 24)).padTop(16f).colspan(2).row()
val modCheckboxTable = Table().apply { defaults().pad(5f) }
for (checkbox in baseRulesetCheckboxes) modCheckboxTable.add(checkbox).row()
add(modCheckboxTable).colspan(2).row()
}
if (extentionRulesetModButtons.any()) {
add("Extension mods:".toLabel(fontSize = 24)).padTop(16f).colspan(2).row()
val modCheckboxTable = Table().apply { defaults().pad(5f) }
for (checkbox in extentionRulesetModButtons) modCheckboxTable.add(checkbox).row()
add(modCheckboxTable).colspan(2).row()
} }
add(modCheckboxTable).colspan(2).row()
} }
} }