Cancel improvement (#2359)
* Bring Incas into the main game (also changes slinger withdraw ability to inheritable) * Update Nations.json * For @JoshDM - Improvement Picker offers "Cancel improvement order" * Improvement Picker offers "Cancel improvement order" - cleanup * Improvement Picker offers "Cancel improvement order" - cleanup 2 * Improvement Picker offers "Cancel improvement order" - cleanup 3 Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
This commit is contained in:
parent
86de66eeba
commit
7511fc52df
5 changed files with 31 additions and 12 deletions
|
@ -136,6 +136,9 @@
|
|||
"name": "Remove Railroad",
|
||||
"turnsToBuild": 2
|
||||
},
|
||||
{
|
||||
"name": "Cancel improvement order",
|
||||
},
|
||||
|
||||
// Great Person improvements
|
||||
{
|
||||
|
|
|
@ -46,12 +46,13 @@ object Constants {
|
|||
const val random = "Random"
|
||||
val greatImprovements = listOf("Academy", "Landmark", "Manufactory", "Customs house", "Citadel")
|
||||
|
||||
val unitActionSetUp = "Set Up"
|
||||
val unitActionSleep = "Sleep"
|
||||
val unitActionSleepUntilHealed = "Sleep until healed"
|
||||
val unitActionAutomation = "Automate"
|
||||
val unitActionExplore = "Explore"
|
||||
val futureTech = "Future Tech"
|
||||
const val unitActionSetUp = "Set Up"
|
||||
const val unitActionSleep = "Sleep"
|
||||
const val unitActionSleepUntilHealed = "Sleep until healed"
|
||||
const val unitActionAutomation = "Automate"
|
||||
const val unitActionExplore = "Explore"
|
||||
const val futureTech = "Future Tech"
|
||||
|
||||
const val cancelImprovementOrder = "Cancel improvement order"
|
||||
const val tutorialPopupNamePrefix = "Tutorial: "
|
||||
}
|
|
@ -280,6 +280,7 @@ open class TileInfo {
|
|||
improvement.name == "Railroad" && this.roadStatus != RoadStatus.Railroad -> true
|
||||
improvement.name == "Remove Road" && this.roadStatus == RoadStatus.Road -> true
|
||||
improvement.name == "Remove Railroad" && this.roadStatus == RoadStatus.Railroad -> true
|
||||
improvement.name == Constants.cancelImprovementOrder && this.improvementInProgress != null -> true
|
||||
topTerrain.unbuildable && !(topTerrain.name == Constants.forest && improvement.name == "Camp") -> false
|
||||
"Can only be built on Coastal tiles" in improvement.uniques && isCoastalTile() -> true
|
||||
else -> hasViewableResource(civInfo) && getTileResource().improvement == improvement.name
|
||||
|
@ -387,6 +388,10 @@ open class TileInfo {
|
|||
improvementInProgress = improvement.name
|
||||
turnsToImprovement = improvement.getTurnsToBuild(civInfo)
|
||||
}
|
||||
fun stopWorkingOnImprovement() {
|
||||
improvementInProgress = null
|
||||
turnsToImprovement = 0
|
||||
}
|
||||
|
||||
fun hasEnemySubmarine(viewingCiv:CivilizationInfo): Boolean {
|
||||
val unitsInTile = getUnits()
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Button
|
|||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.Constants
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.ruleset.tile.TileImprovement
|
||||
|
@ -23,9 +24,14 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
|||
|
||||
fun accept(improvement: TileImprovement?) {
|
||||
if (improvement != null) {
|
||||
tileInfo.startWorkingOnImprovement(improvement, currentPlayerCiv)
|
||||
if (tileInfo.civilianUnit != null) tileInfo.civilianUnit!!.action = null // this is to "wake up" the worker if it's sleeping
|
||||
onAccept()
|
||||
if (improvement.name == Constants.cancelImprovementOrder ) {
|
||||
tileInfo.stopWorkingOnImprovement()
|
||||
// no onAccept() - Worker can stay selected
|
||||
} else {
|
||||
tileInfo.startWorkingOnImprovement(improvement, currentPlayerCiv)
|
||||
if (tileInfo.civilianUnit != null) tileInfo.civilianUnit!!.action = null // this is to "wake up" the worker if it's sleeping
|
||||
onAccept()
|
||||
}
|
||||
game.setWorldScreen()
|
||||
dispose()
|
||||
}
|
||||
|
@ -50,11 +56,13 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
|||
|
||||
group.add(image).size(30f).pad(10f)
|
||||
|
||||
var labelText = improvement.name.tr() + " - " + improvement.getTurnsToBuild(currentPlayerCiv) + " {turns}"
|
||||
var labelText = improvement.name.tr()
|
||||
val turnsToBuild = improvement.getTurnsToBuild(currentPlayerCiv)
|
||||
if (turnsToBuild > 0) labelText += " - $turnsToBuild {turns}"
|
||||
val provideResource = tileInfo.hasViewableResource(currentPlayerCiv) && tileInfo.getTileResource().improvement == improvement.name
|
||||
if (provideResource) labelText += "\n"+"Provides [${tileInfo.resource}]".tr()
|
||||
val removeImprovement = (improvement.name!=RoadStatus.Road.name
|
||||
&& improvement.name!=RoadStatus.Railroad.name && !improvement.name.startsWith("Remove"))
|
||||
&& improvement.name!=RoadStatus.Railroad.name && !improvement.name.startsWith("Remove") && improvement.name != Constants.cancelImprovementOrder)
|
||||
if (tileInfo.improvement!=null && removeImprovement) labelText += "\n" + "Replaces [${tileInfo.improvement}]".tr()
|
||||
|
||||
group.add(labelText.toLabel()).pad(10f)
|
||||
|
@ -124,6 +132,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
|||
regularImprovements.add(pickNow).padLeft(10f)
|
||||
regularImprovements.row()
|
||||
}
|
||||
|
||||
topTable.add(regularImprovements)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
|||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.Constants
|
||||
import com.unciv.models.ruleset.Nation
|
||||
import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.ruleset.tile.ResourceType
|
||||
|
@ -123,7 +124,7 @@ object ImageGetter {
|
|||
val productionCircleColor = Color.BROWN.cpy().lerp(Color.WHITE,0.5f)!!
|
||||
val goldCircleColor = Color.GOLD.cpy().lerp(Color.WHITE,0.5f)!!
|
||||
fun getImprovementIcon(improvementName:String, size:Float=20f):Actor{
|
||||
if(improvementName.startsWith("Remove"))
|
||||
if(improvementName.startsWith("Remove") || improvementName == Constants.cancelImprovementOrder)
|
||||
return getImage("OtherIcons/Stop")
|
||||
if(improvementName.startsWith("StartingLocation ")){
|
||||
val nationName = improvementName.removePrefix("StartingLocation ")
|
||||
|
|
Loading…
Reference in a new issue