mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-20 09:17:47 +07:00
Fix screen bugs when you don't use splitpane in pickscreen (#3760)
This commit is contained in:
parent
72bf5f198d
commit
464d89298a
@ -82,7 +82,6 @@ class MainMenuScreen: CameraStageBaseScreen() {
|
||||
|
||||
val newGameButton = getTableBlock("Start new game", "OtherIcons/New") {
|
||||
game.setScreen(NewGameScreen(this))
|
||||
dispose()
|
||||
}
|
||||
column1.add(newGameButton).row()
|
||||
|
||||
|
@ -45,7 +45,6 @@ class NewMapScreen(val mapParameters: MapParameters = MapParameters()) : PickerS
|
||||
|
||||
topTable.apply {
|
||||
add(ScrollPane(newMapScreenOptionsTable).apply { setOverscroll(false, false) })
|
||||
.height(topTable.parent.height)
|
||||
pack()
|
||||
setFillParent(true)
|
||||
}
|
||||
|
@ -70,8 +70,7 @@ class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false) : PickerSc
|
||||
}
|
||||
}
|
||||
|
||||
topTable.add(ScrollPane(mapsTable)).height(stage.height * 2 / 3)
|
||||
.maxWidth(stage.width / 2)
|
||||
topTable.add(ScrollPane(mapsTable)).maxWidth(stage.width / 2)
|
||||
|
||||
val rightSideTable = Table().apply { defaults().pad(10f) }
|
||||
|
||||
|
@ -5,7 +5,6 @@ import com.badlogic.gdx.files.FileHandle
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin
|
||||
import com.badlogic.gdx.utils.Array
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.*
|
||||
import com.unciv.logic.civilization.PlayerType
|
||||
import com.unciv.logic.map.MapParameters
|
||||
@ -37,13 +36,13 @@ class GameSetupInfo(var gameId:String, var gameParameters: GameParameters, var m
|
||||
}
|
||||
}
|
||||
|
||||
class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSetupInfo?=null): IPreviousScreen, PickerScreen() {
|
||||
class NewGameScreen(private val previousScreen: CameraStageBaseScreen, _gameSetupInfo: GameSetupInfo?=null): IPreviousScreen, PickerScreen() {
|
||||
override val gameSetupInfo = _gameSetupInfo ?: GameSetupInfo()
|
||||
override var ruleset = RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters.mods) // needs to be set because the gameoptionstable etc. depend on this
|
||||
var newGameOptionsTable = GameOptionsTable(this) { desiredCiv: String -> playerPickerTable.update(desiredCiv) }
|
||||
|
||||
// Has to be defined before the mapOptionsTable, since the mapOptionsTable refers to it on init
|
||||
var playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters)
|
||||
private var playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters)
|
||||
var mapOptionsTable = MapOptionsTable(this)
|
||||
|
||||
|
||||
@ -51,19 +50,16 @@ class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSe
|
||||
setDefaultCloseAction(previousScreen)
|
||||
scrollPane.setScrollingDisabled(true, true)
|
||||
|
||||
topTable.add(ScrollPane(newGameOptionsTable, skin).apply { setOverscroll(false, false) })
|
||||
.maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top()
|
||||
topTable.add(ScrollPane(newGameOptionsTable).apply { setOverscroll(false, false) })
|
||||
.width(stage.width / 3).padTop(20f).top()
|
||||
topTable.addSeparatorVertical()
|
||||
topTable.add(ScrollPane(mapOptionsTable, skin).apply { setOverscroll(false, false) })
|
||||
.maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top()
|
||||
topTable.add(ScrollPane(mapOptionsTable).apply { setOverscroll(false, false) })
|
||||
.width(stage.width / 3).padTop(20f).top()
|
||||
topTable.addSeparatorVertical()
|
||||
topTable.add(ScrollPane(playerPickerTable, skin)
|
||||
topTable.add(ScrollPane(playerPickerTable)
|
||||
.apply { setOverscroll(false, false) }
|
||||
.apply { setScrollingDisabled(true, false) })
|
||||
.maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top()
|
||||
|
||||
topTable.pack()
|
||||
topTable.setFillParent(true)
|
||||
.width(stage.width / 3).padTop(20f).top()
|
||||
|
||||
updateRuleset()
|
||||
|
||||
@ -194,10 +190,18 @@ class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSe
|
||||
var newGame: GameInfo? = null
|
||||
|
||||
override fun render(delta: Float) {
|
||||
if (newGame != null)
|
||||
if (newGame != null) {
|
||||
game.loadGame(newGame!!)
|
||||
previousScreen.dispose()
|
||||
}
|
||||
super.render(delta)
|
||||
}
|
||||
|
||||
override fun resize(width: Int, height: Int) {
|
||||
if (stage.viewport.screenWidth != width || stage.viewport.screenHeight != height) {
|
||||
game.setScreen(NewGameScreen(previousScreen, gameSetupInfo))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TranslatedSelectBox(values : Collection<String>, default:String, skin: Skin) : SelectBox<TranslatedSelectBox.TranslatedString>(skin) {
|
||||
|
@ -45,13 +45,13 @@ class ModManagementScreen: PickerScreen() {
|
||||
topTable.row()
|
||||
|
||||
|
||||
topTable.add(ScrollPane(modTable)).height(scrollPane.height * 0.8f).pad(10f)
|
||||
topTable.add(ScrollPane(modTable)).pad(10f)
|
||||
|
||||
downloadTable.add(getDownloadButton()).row()
|
||||
|
||||
tryDownloadPage(1)
|
||||
|
||||
topTable.add(ScrollPane(downloadTable)).height(scrollPane.height * 0.8f)//.size(downloadTable.width, topTable.height)
|
||||
topTable.add(ScrollPane(downloadTable))
|
||||
|
||||
topTable.add(modActionTable)
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class LoadGameScreen(previousScreen:CameraStageBaseScreen) : PickerScreen() {
|
||||
setDefaultCloseAction(previousScreen)
|
||||
|
||||
resetWindowState()
|
||||
topTable.add(ScrollPane(saveTable)).height(stage.height * 2 / 3)
|
||||
topTable.add(ScrollPane(saveTable))
|
||||
|
||||
val rightSideTable = getRightSideTable()
|
||||
|
||||
@ -174,7 +174,7 @@ class LoadGameScreen(previousScreen:CameraStageBaseScreen) : PickerScreen() {
|
||||
|
||||
val savedAt = Date(save.lastModified())
|
||||
descriptionLabel.setText("Loading...".tr())
|
||||
textToSet += "\n{Saved at}: ".tr() + SimpleDateFormat("yyyy-MM-dd HH:mm").format(savedAt)
|
||||
textToSet += "\n{Saved at}: ".tr() + SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US).format(savedAt)
|
||||
thread { // Even loading the game to get its metadata can take a long time on older phones
|
||||
try {
|
||||
val game = GameSaver.loadGameFromFile(save)
|
||||
|
@ -27,7 +27,7 @@ class SaveGameScreen(val gameInfo: GameInfo) : PickerScreen() {
|
||||
gameNameTextField.textFieldFilter = TextField.TextFieldFilter { _, char -> char != '\\' && char != '/' }
|
||||
currentSaves.add("Current saves".toLabel()).row()
|
||||
updateShownSaves(false)
|
||||
topTable.add(ScrollPane(currentSaves)).height(stage.height * 2 / 3)
|
||||
topTable.add(ScrollPane(currentSaves))
|
||||
|
||||
val newSave = Table()
|
||||
val defaultSaveName = gameInfo.currentPlayer + " - " + gameInfo.turns + " turns"
|
||||
|
Loading…
Reference in New Issue
Block a user