Can now adopt policies in Scenario Editor mode by double-clicking

This commit is contained in:
Yair Morgenstern
2020-08-13 18:11:21 +03:00
parent 88d72f0f39
commit 25b434cb29
3 changed files with 11 additions and 4 deletions

View File

@ -109,7 +109,7 @@ class PolicyManager {
fun adopt(policy: Policy, branchCompletion: Boolean = false) { fun adopt(policy: Policy, branchCompletion: Boolean = false) {
if (!branchCompletion) { if (!branchCompletion && !civInfo.gameInfo.gameParameters.godMode) {
if (freePolicies > 0) freePolicies-- if (freePolicies > 0) freePolicies--
else { else {
val cultureNeededForNextPolicy = getCultureNeededForNextPolicy() val cultureNeededForNextPolicy = getCultureNeededForNextPolicy()

View File

@ -71,9 +71,10 @@ class MapOptionsTable(val newGameScreen: NewGameScreen): Table() {
if (savedGame.toLowerCase().endsWith("scenario")) if (savedGame.toLowerCase().endsWith("scenario"))
scenarioSelectBox.items.add(savedGame) scenarioSelectBox.items.add(savedGame)
} }
scenarioSelectBox.onChange { selectSavedGameAsScenario(scenarioSelectBox.selected) }
scenarioSelectBox.items = scenarioSelectBox.items // it doesn't register them until you do this. scenarioSelectBox.items = scenarioSelectBox.items // it doesn't register them until you do this.
scenarioSelectBox.selected = scenarioMapSelectBox.items.first() scenarioSelectBox.selected = scenarioMapSelectBox.items.first()
// needs to be after the item change, so it doesn't activate before we choose the Scenario maptype
scenarioSelectBox.onChange { selectSavedGameAsScenario(scenarioSelectBox.selected) }
scenarioOptionsTable.add("{Scenario file}:".toLabel()).left() scenarioOptionsTable.add("{Scenario file}:".toLabel()).left()
scenarioOptionsTable.add(scenarioSelectBox) scenarioOptionsTable.add(scenarioSelectBox)
@ -83,6 +84,7 @@ class MapOptionsTable(val newGameScreen: NewGameScreen): Table() {
mapParameters.type = MapType.custom mapParameters.type = MapType.custom
mapParameters.name = mapFileSelectBox.selected mapParameters.name = mapFileSelectBox.selected
mapTypeSpecificTable.add(savedMapOptionsTable) mapTypeSpecificTable.add(savedMapOptionsTable)
newGameScreen.gameSetupInfo.gameParameters.godMode = false
newGameScreen.unlockTables() newGameScreen.unlockTables()
newGameScreen.updateTables() newGameScreen.updateTables()
} else if (mapTypeSelectBox.selected.value == MapType.scenarioMap) { } else if (mapTypeSelectBox.selected.value == MapType.scenarioMap) {
@ -103,6 +105,7 @@ class MapOptionsTable(val newGameScreen: NewGameScreen): Table() {
} else { // generated map } else { // generated map
mapParameters.name = "" mapParameters.name = ""
mapParameters.type = generatedMapOptionsTable.mapTypeSelectBox.selected.value mapParameters.type = generatedMapOptionsTable.mapTypeSelectBox.selected.value
newGameScreen.gameSetupInfo.gameParameters.godMode = false
mapTypeSpecificTable.add(generatedMapOptionsTable) mapTypeSpecificTable.add(generatedMapOptionsTable)
newGameScreen.unlockTables() newGameScreen.unlockTables()
newGameScreen.updateTables() newGameScreen.updateTables()

View File

@ -42,11 +42,10 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo
} }
else game.setScreen(PolicyPickerScreen(worldScreen)) // update policies else game.setScreen(PolicyPickerScreen(worldScreen)) // update policies
} }
if(!UncivGame.Current.worldScreen.canChangeState) if(!UncivGame.Current.worldScreen.canChangeState)
rightSideButton.disable() rightSideButton.disable()
topTable.row().pad(30f) topTable.row().pad(30f)
for (branch in viewingCiv.gameInfo.ruleSet.policyBranches.values) { for (branch in viewingCiv.gameInfo.ruleSet.policyBranches.values) {
@ -92,6 +91,11 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo
} else { } else {
rightSideButton.enable() rightSideButton.enable()
} }
if (viewingCiv.gameInfo.gameParameters.godMode && pickedPolicy == policy
&& viewingCiv.policies.isAdoptable(policy)) {
viewingCiv.policies.adopt(policy)
game.setScreen(PolicyPickerScreen(worldScreen))
}
pickedPolicy = policy pickedPolicy = policy
val policyText = mutableListOf<String>() val policyText = mutableListOf<String>()
policyText += policy.name policyText += policy.name