Game no longer crashes on new game screen when no scenarios are available

This commit is contained in:
Yair Morgenstern 2020-08-15 21:58:02 +03:00
parent 324f4d7a15
commit be216d8e6b

View file

@ -80,7 +80,9 @@ class MapOptionsTable(val newGameScreen: NewGameScreen): Table() {
override fun toString() = fileHandle.name() override fun toString() = fileHandle.name()
} }
val scenarioFiles = getScenarioFiles()
val scenarioSelectBox = SelectBox<FileHandleWrapper>(CameraStageBaseScreen.skin) val scenarioSelectBox = SelectBox<FileHandleWrapper>(CameraStageBaseScreen.skin)
if (scenarioFiles.any()) {
for (savedGame in getScenarioFiles()) { for (savedGame in getScenarioFiles()) {
scenarioSelectBox.items.add(FileHandleWrapper(savedGame)) scenarioSelectBox.items.add(FileHandleWrapper(savedGame))
} }
@ -90,6 +92,7 @@ class MapOptionsTable(val newGameScreen: NewGameScreen): Table() {
scenarioSelectBox.onChange { selectSavedGameAsScenario(scenarioSelectBox.selected.fileHandle) } scenarioSelectBox.onChange { selectSavedGameAsScenario(scenarioSelectBox.selected.fileHandle) }
scenarioOptionsTable.add("{Scenario file}:".toLabel()).left() scenarioOptionsTable.add("{Scenario file}:".toLabel()).left()
scenarioOptionsTable.add(scenarioSelectBox) scenarioOptionsTable.add(scenarioSelectBox)
}
fun updateOnMapTypeChange() { fun updateOnMapTypeChange() {
mapTypeSpecificTable.clear() mapTypeSpecificTable.clear()