Redid layout for the New Game screen - see #2549

This commit is contained in:
Yair Morgenstern 2020-05-12 20:38:44 +03:00
parent 105a7d63b0
commit 0190854b88
4 changed files with 59 additions and 59 deletions

View File

@ -19,7 +19,7 @@ class MapOptionsTable(val newGameScreen: NewGameScreen): Table(){
init { init {
defaults().pad(5f) defaults().pad(5f)
add("Map options".toLabel(fontSize = 24)).colspan(2).row() add("Map options".toLabel(fontSize = 24)).top().colspan(2).row()
addMapTypeSelection() addMapTypeSelection()
} }

View File

@ -38,8 +38,13 @@ class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSe
val playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters) val playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters)
val newGameScreenOptionsTable = NewGameScreenOptionsTable(this) { desiredCiv: String -> playerPickerTable.update(desiredCiv) } val newGameScreenOptionsTable = NewGameScreenOptionsTable(this) { desiredCiv: String -> playerPickerTable.update(desiredCiv) }
topTable.add(ScrollPane(newGameScreenOptionsTable).apply{setOverscroll(false,false)}).height(topTable.parent.height) topTable.add(ScrollPane(MapOptionsTable(this)).apply { setOverscroll(false, false) })
topTable.add(playerPickerTable).height(topTable.parent.height) .maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top()
topTable.addSeparatorVertical()
topTable.add(playerPickerTable).maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top()
topTable.addSeparatorVertical()
topTable.add(ScrollPane(newGameScreenOptionsTable).apply { setOverscroll(false, false) })
.maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top()
topTable.pack() topTable.pack()
topTable.setFillParent(true) topTable.setFillParent(true)
@ -145,4 +150,3 @@ class TranslatedSelectBox(values : Collection<String>, default:String, skin: Ski
selected = if (defaultItem != null) defaultItem else array.first() selected = if (defaultItem != null) defaultItem else array.first()
} }
} }

View File

@ -23,11 +23,8 @@ class NewGameScreenOptionsTable(newGameScreen: NewGameScreen, val updatePlayerPi
top() top()
defaults().pad(5f) defaults().pad(5f)
val mapOptionsColumn = MapOptionsTable(newGameScreen)
add(mapOptionsColumn).row()
val gameOptionsColumn = Table().apply { defaults().pad(5f) } val gameOptionsColumn = Table().apply { defaults().pad(5f) }
gameOptionsColumn.add("Game options".toLabel(fontSize = 24)).colspan(2).row() gameOptionsColumn.add("Game options".toLabel(fontSize = 24)).padTop(0f).colspan(2).row()
gameOptionsColumn.addDifficultySelectBox() gameOptionsColumn.addDifficultySelectBox()
gameOptionsColumn.addGameSpeedSelectBox() gameOptionsColumn.addGameSpeedSelectBox()
gameOptionsColumn.addEraSelectBox() gameOptionsColumn.addEraSelectBox()
@ -181,4 +178,3 @@ class NewGameScreenOptionsTable(newGameScreen: NewGameScreen, val updatePlayerPi
} }
} }

View File

@ -22,10 +22,12 @@ import java.util.*
class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters: GameParameters): Table() { class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters: GameParameters): Table() {
val playerListTable = Table() val playerListTable = Table()
val nationsPopupWidth = newGameScreen.stage.width / 2f val nationsPopupWidth = newGameScreen.stage.width / 2f
val civBlocksWidth = newGameScreen.stage.width / 3
init { init {
top() top()
add(ScrollPane(playerListTable).apply{setOverscroll(false,false)}).width(newGameScreen.stage.width/2) add("Civilizations".toLabel(fontSize = 24)).padBottom(20f).row()
add(ScrollPane(playerListTable).apply { setOverscroll(false, false) }).width(civBlocksWidth)
update() update()
} }
@ -40,7 +42,7 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
if (desiredCiv.isNotEmpty()) assignDesiredCiv(desiredCiv) if (desiredCiv.isNotEmpty()) assignDesiredCiv(desiredCiv)
for (player in newGameParameters.players) { for (player in newGameParameters.players) {
playerListTable.add(getPlayerTable(player, gameBasics)).pad(10f).row() playerListTable.add(getPlayerTable(player, gameBasics)).width(civBlocksWidth).padBottom(20f).row()
} }
if (newGameParameters.players.count() < gameBasics.nations.values.count { it.isMajorCiv() }) { if (newGameParameters.players.count() < gameBasics.nations.values.count { it.isMajorCiv() }) {
playerListTable.add("+".toLabel(Color.BLACK, 30).apply { this.setAlignment(Align.center) } playerListTable.add("+".toLabel(Color.BLACK, 30).apply { this.setAlignment(Align.center) }
@ -69,7 +71,7 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
playerTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.8f)) playerTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.8f))
val nationTable = getNationTable(player) val nationTable = getNationTable(player)
playerTable.add(nationTable) playerTable.add(nationTable).left()
val playerTypeTextbutton = player.playerType.name.toTextButton() val playerTypeTextbutton = player.playerType.name.toTextButton()
playerTypeTextbutton.onClick { playerTypeTextbutton.onClick {
@ -78,10 +80,10 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
else player.playerType = PlayerType.AI else player.playerType = PlayerType.AI
update() update()
} }
playerTable.add(playerTypeTextbutton).width(100f).pad(5f) playerTable.add(playerTypeTextbutton).width(100f).pad(5f).right()
playerTable.add("-".toLabel(Color.BLACK, 30).apply { this.setAlignment(Align.center) } playerTable.add("-".toLabel(Color.BLACK, 30).apply { this.setAlignment(Align.center) }
.surroundWithCircle(40f) .surroundWithCircle(40f)
.onClick { newGameParameters.players.remove(player); update() }).pad(5f).row() .onClick { newGameParameters.players.remove(player); update() }).pad(5f).right().row()
if (newGameParameters.isOnlineMultiplayer && player.playerType == PlayerType.Human) { if (newGameParameters.isOnlineMultiplayer && player.playerType == PlayerType.Human) {
val playerIdTextfield = TextField(player.playerId, CameraStageBaseScreen.skin) val playerIdTextfield = TextField(player.playerId, CameraStageBaseScreen.skin)
@ -128,7 +130,7 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
.surroundWithCircle(40f, false).apply { circle.color = Color.WHITE } .surroundWithCircle(40f, false).apply { circle.color = Color.WHITE }
else ImageGetter.getNationIndicator(newGameScreen.ruleset.nations[player.chosenCiv]!!, 40f) else ImageGetter.getNationIndicator(newGameScreen.ruleset.nations[player.chosenCiv]!!, 40f)
nationTable.add(nationImage).pad(5f) nationTable.add(nationImage).pad(5f)
nationTable.add(player.chosenCiv.toLabel()).width(230f).pad(5f) nationTable.add(player.chosenCiv.toLabel()).pad(5f)
nationTable.touchable = Touchable.enabled nationTable.touchable = Touchable.enabled
nationTable.onClick { nationTable.onClick {
popupNationPicker(player) popupNationPicker(player)
@ -173,5 +175,3 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
update() update()
} }
} }