Few UI fixes (#3070)

* Fixed close button in LoadMapScreen
setDefaultCloseAction(MainMenuScreen())
* Fixed mapFileSelectBox in MapOptionsTable
first map will be properly selected upon creation of mapFileSelectBox
This commit is contained in:
HadeanLake 2020-09-01 18:44:00 +03:00 committed by GitHub
parent 91ad769eb2
commit 0570f0a974
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.badlogic.gdx.utils.Align
import com.unciv.MainMenuScreen
import com.unciv.UncivGame
import com.unciv.logic.MapSaver
import com.unciv.logic.map.TileMap
@ -79,8 +80,7 @@ class LoadMapScreen(previousMap: TileMap?) : PickerScreen(){
rightSideTable.add(deleteButton).row()
topTable.add(rightSideTable)
if (previousMap != null)
closeButton.onClick { UncivGame.Current.setScreen(MapEditorScreen(previousMap)) }
setDefaultCloseAction(MainMenuScreen())
update()
}

View file

@ -145,7 +145,9 @@ class MapOptionsTable(val newGameScreen: NewGameScreen): Table() {
}
mapFileSelectBox.items = mapFiles
val selectedItem = mapFiles.firstOrNull { it.fileHandle.name()==mapParameters.name }
if(selectedItem!=null) mapFileSelectBox.selected = selectedItem
if (selectedItem != null) mapFileSelectBox.selected = selectedItem
else mapFileSelectBox.selected = mapFiles.first()
newGameScreen.gameSetupInfo.mapFile = mapFileSelectBox.selected.fileHandle
mapFileSelectBox.onChange {
val mapFile = mapFileSelectBox.selected.fileHandle