mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-10 12:51:16 +07:00
Game handles 'picking a scenario based on a custom ruleset' well
This commit is contained in:
parent
0c4947a03e
commit
2e0d73cf75
@ -61,6 +61,7 @@ class MapOptionsTable(val newGameScreen: NewGameScreen): Table() {
|
|||||||
val scenario = MapSaver.loadScenario(mapParameters.name)
|
val scenario = MapSaver.loadScenario(mapParameters.name)
|
||||||
newGameScreen.gameSetupInfo.gameParameters = scenario.gameParameters
|
newGameScreen.gameSetupInfo.gameParameters = scenario.gameParameters
|
||||||
newGameScreen.gameSetupInfo.mapParameters = mapParameters
|
newGameScreen.gameSetupInfo.mapParameters = mapParameters
|
||||||
|
newGameScreen.updateRuleset()
|
||||||
// update PlayerTable and GameOptionsTable
|
// update PlayerTable and GameOptionsTable
|
||||||
newGameScreen.lockTables()
|
newGameScreen.lockTables()
|
||||||
newGameScreen.updateTables()
|
newGameScreen.updateTables()
|
||||||
|
@ -10,6 +10,7 @@ import com.unciv.logic.*
|
|||||||
import com.unciv.logic.civilization.PlayerType
|
import com.unciv.logic.civilization.PlayerType
|
||||||
import com.unciv.logic.map.MapParameters
|
import com.unciv.logic.map.MapParameters
|
||||||
import com.unciv.models.metadata.GameParameters
|
import com.unciv.models.metadata.GameParameters
|
||||||
|
import com.unciv.models.ruleset.Ruleset
|
||||||
import com.unciv.models.ruleset.RulesetCache
|
import com.unciv.models.ruleset.RulesetCache
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.pickerscreens.PickerScreen
|
import com.unciv.ui.pickerscreens.PickerScreen
|
||||||
@ -35,7 +36,7 @@ class GameSetupInfo(var gameId:String, var gameParameters: GameParameters, var m
|
|||||||
|
|
||||||
class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSetupInfo?=null): IPreviousScreen, PickerScreen() {
|
class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSetupInfo?=null): IPreviousScreen, PickerScreen() {
|
||||||
override val gameSetupInfo = _gameSetupInfo ?: GameSetupInfo()
|
override val gameSetupInfo = _gameSetupInfo ?: GameSetupInfo()
|
||||||
override val ruleset = RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters)
|
override var ruleset = RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters) // needs to be set because the gameoptionstable etc. depend on this
|
||||||
var newGameOptionsTable = GameOptionsTable(this) { desiredCiv: String -> playerPickerTable.update(desiredCiv) }
|
var newGameOptionsTable = GameOptionsTable(this) { desiredCiv: String -> playerPickerTable.update(desiredCiv) }
|
||||||
// Has to be defined before the mapOptionsTable, since the mapOptionsTable refers to it on init
|
// Has to be defined before the mapOptionsTable, since the mapOptionsTable refers to it on init
|
||||||
var playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters)
|
var playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters)
|
||||||
@ -57,6 +58,8 @@ class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSe
|
|||||||
topTable.pack()
|
topTable.pack()
|
||||||
topTable.setFillParent(true)
|
topTable.setFillParent(true)
|
||||||
|
|
||||||
|
updateRuleset()
|
||||||
|
|
||||||
rightSideButton.enable()
|
rightSideButton.enable()
|
||||||
rightSideButton.setText("Start game!".tr())
|
rightSideButton.setText("Start game!".tr())
|
||||||
rightSideButton.onClick {
|
rightSideButton.onClick {
|
||||||
@ -135,6 +138,11 @@ class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSe
|
|||||||
Gdx.graphics.requestRendering()
|
Gdx.graphics.requestRendering()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateRuleset(){
|
||||||
|
ruleset.clear()
|
||||||
|
ruleset.add(RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters))
|
||||||
|
}
|
||||||
|
|
||||||
fun lockTables() {
|
fun lockTables() {
|
||||||
playerPickerTable.locked = true
|
playerPickerTable.locked = true
|
||||||
newGameOptionsTable.locked = true
|
newGameOptionsTable.locked = true
|
||||||
|
Loading…
Reference in New Issue
Block a user