Game no longer crashes on new game screen when no scenarios are available
This commit is contained in:
parent
324f4d7a15
commit
be216d8e6b
1 changed files with 11 additions and 8 deletions
|
@ -80,16 +80,19 @@ 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)
|
||||||
for (savedGame in getScenarioFiles()) {
|
if (scenarioFiles.any()) {
|
||||||
scenarioSelectBox.items.add(FileHandleWrapper(savedGame))
|
for (savedGame in getScenarioFiles()) {
|
||||||
|
scenarioSelectBox.items.add(FileHandleWrapper(savedGame))
|
||||||
|
}
|
||||||
|
scenarioSelectBox.items = scenarioSelectBox.items // it doesn't register them until you do this.
|
||||||
|
scenarioSelectBox.selected = scenarioSelectBox.items.first()
|
||||||
|
// needs to be after the item change, so it doesn't activate before we choose the Scenario maptype
|
||||||
|
scenarioSelectBox.onChange { selectSavedGameAsScenario(scenarioSelectBox.selected.fileHandle) }
|
||||||
|
scenarioOptionsTable.add("{Scenario file}:".toLabel()).left()
|
||||||
|
scenarioOptionsTable.add(scenarioSelectBox)
|
||||||
}
|
}
|
||||||
scenarioSelectBox.items = scenarioSelectBox.items // it doesn't register them until you do this.
|
|
||||||
scenarioSelectBox.selected = scenarioSelectBox.items.first()
|
|
||||||
// needs to be after the item change, so it doesn't activate before we choose the Scenario maptype
|
|
||||||
scenarioSelectBox.onChange { selectSavedGameAsScenario(scenarioSelectBox.selected.fileHandle) }
|
|
||||||
scenarioOptionsTable.add("{Scenario file}:".toLabel()).left()
|
|
||||||
scenarioOptionsTable.add(scenarioSelectBox)
|
|
||||||
|
|
||||||
fun updateOnMapTypeChange() {
|
fun updateOnMapTypeChange() {
|
||||||
mapTypeSpecificTable.clear()
|
mapTypeSpecificTable.clear()
|
||||||
|
|
Loading…
Reference in a new issue