mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-14 17:59:11 +07:00
Added a NewGameScreen option to choose the base ruleset - it works, which means G&K and Vanilla games can coexist well!
We're ready to start making changes! =D
This commit is contained in:
@ -40,6 +40,7 @@ class GameParameters { // Default values are the default new game
|
|||||||
parameters.victoryTypes = ArrayList(victoryTypes)
|
parameters.victoryTypes = ArrayList(victoryTypes)
|
||||||
parameters.startingEra = startingEra
|
parameters.startingEra = startingEra
|
||||||
parameters.isOnlineMultiplayer = isOnlineMultiplayer
|
parameters.isOnlineMultiplayer = isOnlineMultiplayer
|
||||||
|
parameters.baseRuleset = baseRuleset
|
||||||
parameters.mods = LinkedHashSet(mods)
|
parameters.mods = LinkedHashSet(mods)
|
||||||
return parameters
|
return parameters
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.CheckBox
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Array
|
import com.badlogic.gdx.utils.Array
|
||||||
|
import com.unciv.models.metadata.BaseRuleset
|
||||||
import com.unciv.models.metadata.GameSpeed
|
import com.unciv.models.metadata.GameSpeed
|
||||||
import com.unciv.models.ruleset.RulesetCache
|
import com.unciv.models.ruleset.RulesetCache
|
||||||
import com.unciv.models.ruleset.VictoryType
|
import com.unciv.models.ruleset.VictoryType
|
||||||
@ -32,6 +33,7 @@ class GameOptionsTable(previousScreen: IPreviousScreen, val updatePlayerPickerTa
|
|||||||
add("Game Options".toLabel(fontSize = 24)).padTop(0f).padBottom(20f).colspan(2).row()
|
add("Game Options".toLabel(fontSize = 24)).padTop(0f).padBottom(20f).colspan(2).row()
|
||||||
add(Table().apply {
|
add(Table().apply {
|
||||||
defaults().pad(5f)
|
defaults().pad(5f)
|
||||||
|
//addBaseRulesetSelectBox()
|
||||||
addDifficultySelectBox()
|
addDifficultySelectBox()
|
||||||
addGameSpeedSelectBox()
|
addGameSpeedSelectBox()
|
||||||
addEraSelectBox()
|
addEraSelectBox()
|
||||||
@ -107,6 +109,14 @@ class GameOptionsTable(previousScreen: IPreviousScreen, val updatePlayerPickerTa
|
|||||||
{ gameParameters.difficulty = it }
|
{ gameParameters.difficulty = it }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun Table.addBaseRulesetSelectBox() {
|
||||||
|
addSelectBox("{Base Ruleset}:", BaseRuleset.values().map { it.fullName }, gameParameters.baseRuleset.fullName)
|
||||||
|
{
|
||||||
|
gameParameters.baseRuleset = BaseRuleset.values().first { br -> br.fullName == it }
|
||||||
|
reloadRuleset()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun Table.addGameSpeedSelectBox() {
|
private fun Table.addGameSpeedSelectBox() {
|
||||||
addSelectBox("{Game Speed}:", GameSpeed.values().map { it.name }, gameParameters.gameSpeed.name)
|
addSelectBox("{Game Speed}:", GameSpeed.values().map { it.name }, gameParameters.gameSpeed.name)
|
||||||
{ gameParameters.gameSpeed = GameSpeed.valueOf(it) }
|
{ gameParameters.gameSpeed = GameSpeed.valueOf(it) }
|
||||||
@ -145,21 +155,21 @@ class GameOptionsTable(previousScreen: IPreviousScreen, val updatePlayerPickerTa
|
|||||||
add(victoryConditionsTable).colspan(2).row()
|
add(victoryConditionsTable).colspan(2).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun reloadRuleset() {
|
||||||
|
ruleset.clear()
|
||||||
|
val newRuleset = RulesetCache.getComplexRuleset(gameParameters)
|
||||||
|
ruleset.add(newRuleset)
|
||||||
|
ruleset.mods += gameParameters.mods
|
||||||
|
ruleset.modOptions = newRuleset.modOptions
|
||||||
|
|
||||||
|
ImageGetter.ruleset = ruleset
|
||||||
|
ImageGetter.setTextureRegionDrawables()
|
||||||
|
}
|
||||||
|
|
||||||
fun Table.addModCheckboxes() {
|
fun Table.addModCheckboxes() {
|
||||||
val modRulesets = RulesetCache.filter { it.key != "" }.values
|
val modRulesets = RulesetCache.filter { it.key != "" }.values
|
||||||
if (modRulesets.isEmpty()) return
|
if (modRulesets.isEmpty()) return
|
||||||
|
|
||||||
fun reloadMods() {
|
|
||||||
ruleset.clear()
|
|
||||||
val newRuleset = RulesetCache.getComplexRuleset(gameParameters)
|
|
||||||
ruleset.add(newRuleset)
|
|
||||||
ruleset.mods += gameParameters.mods
|
|
||||||
ruleset.modOptions = newRuleset.modOptions
|
|
||||||
|
|
||||||
ImageGetter.ruleset = ruleset
|
|
||||||
ImageGetter.setTextureRegionDrawables()
|
|
||||||
}
|
|
||||||
|
|
||||||
add("Mods:".toLabel(fontSize = 24)).padTop(16f).colspan(2).row()
|
add("Mods:".toLabel(fontSize = 24)).padTop(16f).colspan(2).row()
|
||||||
val modCheckboxTable = Table().apply { defaults().pad(5f) }
|
val modCheckboxTable = Table().apply { defaults().pad(5f) }
|
||||||
@ -170,7 +180,7 @@ class GameOptionsTable(previousScreen: IPreviousScreen, val updatePlayerPickerTa
|
|||||||
checkBox.onChange {
|
checkBox.onChange {
|
||||||
if (checkBox.isChecked) gameParameters.mods.add(mod.name)
|
if (checkBox.isChecked) gameParameters.mods.add(mod.name)
|
||||||
else gameParameters.mods.remove(mod.name)
|
else gameParameters.mods.remove(mod.name)
|
||||||
reloadMods()
|
reloadRuleset()
|
||||||
var desiredCiv = ""
|
var desiredCiv = ""
|
||||||
if (checkBox.isChecked) {
|
if (checkBox.isChecked) {
|
||||||
val modNations = RulesetCache[mod.name]?.nations
|
val modNations = RulesetCache[mod.name]?.nations
|
||||||
|
@ -31,8 +31,9 @@ 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 val ruleset = RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters)
|
||||||
var playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters)
|
|
||||||
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
|
||||||
|
var playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters)
|
||||||
var mapOptionsTable = MapOptionsTable(this)
|
var mapOptionsTable = MapOptionsTable(this)
|
||||||
|
|
||||||
|
|
||||||
@ -40,13 +41,14 @@ class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSe
|
|||||||
setDefaultCloseAction(previousScreen)
|
setDefaultCloseAction(previousScreen)
|
||||||
scrollPane.setScrollingDisabled(true, true)
|
scrollPane.setScrollingDisabled(true, true)
|
||||||
|
|
||||||
|
topTable.add(ScrollPane(newGameOptionsTable).apply { setOverscroll(false, false) })
|
||||||
|
.maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top()
|
||||||
|
topTable.addSeparatorVertical()
|
||||||
topTable.add(ScrollPane(mapOptionsTable).apply { setOverscroll(false, false) })
|
topTable.add(ScrollPane(mapOptionsTable).apply { setOverscroll(false, false) })
|
||||||
.maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top()
|
.maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top()
|
||||||
topTable.addSeparatorVertical()
|
topTable.addSeparatorVertical()
|
||||||
topTable.add(playerPickerTable).maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top()
|
topTable.add(playerPickerTable).maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top()
|
||||||
topTable.addSeparatorVertical()
|
|
||||||
topTable.add(ScrollPane(newGameOptionsTable).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)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user