Resolved #899 - Added setting to disable city auto-picking construction

This commit is contained in:
Yair Morgenstern 2019-06-24 19:35:45 +03:00
parent 2f97ed54c0
commit 7e50f70bd5
7 changed files with 58 additions and 27 deletions

View File

@ -846,7 +846,7 @@
}
"Augustus Caesar":{
Italian:"Cesare Augusto"Harun al-Rashid
Italian:"Cesare Augusto"
}
"+25% Production towards any buildings that already exist in the Capital":{

View File

@ -15,6 +15,7 @@ class GameSettings {
var turnsBetweenAutosaves = 1
var tileSet:String = "FantasyHex"
var showTutorials: Boolean = true
var autoAssignCityProduction: Boolean = true
fun save(){
GameSaver().setGeneralSettings(this)

View File

@ -2,6 +2,7 @@ package com.unciv.logic.automation
import com.badlogic.gdx.graphics.Color
import com.unciv.Constants
import com.unciv.UnCivGame
import com.unciv.logic.battle.CityCombatant
import com.unciv.logic.city.CityConstructions
import com.unciv.logic.city.CityInfo
@ -85,6 +86,7 @@ class Automation {
fun chooseNextConstruction(cityConstructions: CityConstructions) {
cityConstructions.run {
if(!UnCivGame.Current.settings.autoAssignCityProduction) return
if (getCurrentConstruction() !is SpecialConstruction) return // don't want to be stuck on these forever
val buildableNotWonders = getBuildableBuildings().filterNot { it.isWonder || it.isNationalWonder }

View File

@ -57,7 +57,8 @@ class CityConstructions {
fun getCityProductionTextForCityButton(): String {
val currentConstructionSnapshot = currentConstruction // See below
var result = currentConstructionSnapshot .tr()
if (SpecialConstruction.getSpecialConstructions().none { it.name==currentConstructionSnapshot })
if (currentConstructionSnapshot!=""
&& SpecialConstruction.getSpecialConstructions().none { it.name==currentConstructionSnapshot })
result += "\r\n" + turnsToConstruction(currentConstructionSnapshot ) + " {turns}".tr()
return result
}
@ -65,7 +66,8 @@ class CityConstructions {
fun getProductionForTileInfo(): String {
val currentConstructionSnapshot = currentConstruction // this is because there were rare errors tht I assume were caused because currentContruction changed on another thread
var result = currentConstructionSnapshot.tr()
if (SpecialConstruction.getSpecialConstructions().none { it.name==currentConstructionSnapshot })
if (currentConstructionSnapshot!=""
&& SpecialConstruction.getSpecialConstructions().none { it.name==currentConstructionSnapshot })
result += "\r\n{in} ".tr() + turnsToConstruction(currentConstructionSnapshot) + " {turns}".tr()
return result
}

View File

@ -20,6 +20,19 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
var constructionScrollPane:ScrollPane?=null
var lastConstruction = ""
fun update() {
val city = cityScreen.city
pad(10f)
columnDefaults(0).padRight(10f)
clear()
addConstructionPickerScrollpane(city)
addCurrentConstructionTable(city)
pack()
}
private fun getProductionButton(construction: String, buttonText: String, rejectionReason: String=""): Table {
val pickProductionButton = Table()
pickProductionButton.touchable = Touchable.enabled
@ -54,18 +67,6 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
return pickProductionButton
}
fun update() {
val city = cityScreen.city
pad(10f)
columnDefaults(0).padRight(10f)
clear()
addConstructionPickerScrollpane(city)
addCurrentConstructionTable(city)
pack()
}
private fun Table.addCategory(title:String,list:ArrayList<Table>){
if(list.isEmpty()) return
val titleTable = Table()
@ -169,26 +170,35 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
currentConstructionTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK,0.5f))
currentConstructionTable.pad(10f)
currentConstructionTable.add(
ImageGetter.getConstructionImage(city.cityConstructions.currentConstruction).surroundWithCircle(50f))
.pad(5f)
val userNeedsToSetProduction = city.cityConstructions.currentConstruction==""
if(!userNeedsToSetProduction) {
currentConstructionTable.add(
ImageGetter.getConstructionImage(city.cityConstructions.currentConstruction).surroundWithCircle(50f))
.pad(5f)
val buildingText = city.cityConstructions.getCityProductionTextForCityButton()
currentConstructionTable.add(buildingText.toLabel().setFontColor(Color.WHITE)).row()
val buildingText = city.cityConstructions.getCityProductionTextForCityButton()
currentConstructionTable.add(buildingText.toLabel().setFontColor(Color.WHITE)).row()
}
else{
currentConstructionTable.add() // no icon
currentConstructionTable.add("Pick construction".toLabel()).row()
}
val currentConstruction = city.cityConstructions.getCurrentConstruction()
val description: String
if (currentConstruction is BaseUnit)
description = currentConstruction.getDescription(true)
else if (currentConstruction is Building)
description = currentConstruction.getDescription(true, city.civInfo)
else description = currentConstruction.description.tr()
if(userNeedsToSetProduction)
description=""
else if (construction is BaseUnit)
description = construction.getDescription(true)
else if (construction is Building)
description = construction.getDescription(true, city.civInfo)
else description = construction.description.tr()
val descriptionLabel = description.toLabel()
descriptionLabel.setWrap(true)
descriptionLabel.width = stage.width / 4
val descriptionScroll = ScrollPane(descriptionLabel)
currentConstructionTable.add(descriptionScroll).colspan(2).width(stage.width / 4).height(stage.height / 8)
currentConstructionTable.add(descriptionScroll).colspan(2)
.width(stage.width / 4).height(stage.height / 8)
add(currentConstructionTable.addBorder(2f, Color.WHITE))
}

View File

@ -16,6 +16,7 @@ import com.unciv.models.gamebasics.tile.ResourceType
import com.unciv.models.gamebasics.tr
import com.unciv.models.gamebasics.unit.UnitType
import com.unciv.ui.VictoryScreen
import com.unciv.ui.cityscreen.CityScreen
import com.unciv.ui.pickerscreens.GreatPersonPickerScreen
import com.unciv.ui.pickerscreens.PolicyPickerScreen
import com.unciv.ui.pickerscreens.TechButton
@ -246,6 +247,13 @@ class WorldScreen : CameraStageBaseScreen() {
return@onClick
}
val cityWithNoProductionSet = currentPlayerCiv.cities
.firstOrNull{it.cityConstructions.currentConstruction==""}
if(cityWithNoProductionSet!=null){
game.screen = CityScreen(cityWithNoProductionSet)
return@onClick
}
if (currentPlayerCiv.shouldOpenTechPicker()) {
game.screen = TechPickerScreen(currentPlayerCiv.tech.freeTechs != 0, currentPlayerCiv)
return@onClick
@ -297,6 +305,8 @@ class WorldScreen : CameraStageBaseScreen() {
fun updateNextTurnButton() {
val text = if (currentPlayerCiv.shouldGoToDueUnit())
"Next unit"
else if(currentPlayerCiv.cities.any{it.cityConstructions.currentConstruction==""})
"Pick construction"
else if(currentPlayerCiv.shouldOpenTechPicker())
"Pick a tech"
else if(currentPlayerCiv.policies.shouldOpenPolicyPicker)

View File

@ -68,6 +68,12 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
update()
}
add("Auto-assign city production".toLabel())
addButton(if(settings.autoAssignCityProduction) "Yes".tr() else "No".tr()) {
settings.autoAssignCityProduction= !settings.autoAssignCityProduction
update()
}
addLanguageSelectBox()
addResolutionSelectBox()