Constructions requiring missing resources once again shown in city construction choices

This commit is contained in:
Yair Morgenstern
2020-03-29 16:19:07 +03:00
parent b0a74dfa86
commit 0db473e5bc
3 changed files with 19 additions and 12 deletions

View File

@ -9,7 +9,7 @@ interface IConstruction : INamed {
fun getProductionCost(civInfo: CivilizationInfo): Int
fun getGoldCost(civInfo: CivilizationInfo): Int
fun isBuildable(construction: CityConstructions): Boolean
fun shouldBeDisplayed(construction: CityConstructions): Boolean
fun shouldBeDisplayed(cityConstructions: CityConstructions): Boolean
fun postBuildEvent(construction: CityConstructions, wasBought: Boolean = false): Boolean // Yes I'm hilarious.
fun getResource(): String?
fun canBePurchased(): Boolean
@ -18,8 +18,8 @@ interface IConstruction : INamed {
open class PerpetualConstruction(override var name: String, val description: String) : IConstruction{
override fun shouldBeDisplayed(construction: CityConstructions): Boolean {
return isBuildable(construction)
override fun shouldBeDisplayed(cityConstructions: CityConstructions): Boolean {
return isBuildable(cityConstructions)
}
open fun getProductionTooltip(cityInfo: CityInfo) : String
= "\r\n${(cityInfo.cityStats.currentCityStats.production / CONVERSION_RATE).roundToInt()}/${"{turn}".tr()}"

View File

@ -118,7 +118,9 @@ class BaseUnit : INamed, IConstruction {
override fun shouldBeDisplayed(construction: CityConstructions): Boolean {
val rejectionReason = getRejectionReason(construction)
return rejectionReason=="" || rejectionReason.startsWith("Requires")
return rejectionReason==""
|| rejectionReason.startsWith("Requires")
|| rejectionReason.startsWith("Consumes")
}
fun getRejectionReason(construction: CityConstructions): String {

View File

@ -1,5 +1,6 @@
package com.unciv.ui.worldscreen
import com.badlogic.gdx.Application
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Color
@ -25,6 +26,7 @@ import com.unciv.ui.tilegroups.TileSetStrings
import com.unciv.ui.tilegroups.WorldTileGroup
import com.unciv.ui.utils.*
import com.unciv.ui.worldscreen.unit.UnitContextMenu
import sun.awt.ExtendedKeyCodes
import kotlin.concurrent.thread
@ -60,14 +62,17 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
layout() // Fit the scroll pane to the contents - otherwise, setScroll won't work!
addAction(Actions.forever(Actions.delay(0.05f, Actions.run {
val amountToMove = 30/scaleX
if(Gdx.input.isKeyPressed(Input.Keys.W)) scrollY -= amountToMove
if(Gdx.input.isKeyPressed(Input.Keys.S)) scrollY += amountToMove
if(Gdx.input.isKeyPressed(Input.Keys.A)) scrollX -= amountToMove
if(Gdx.input.isKeyPressed(Input.Keys.D)) scrollX += amountToMove
updateVisualScroll()
})))
// Apparently this lakes loads of CPU so restrict it as much as possible
if(Gdx.app.type==Application.ApplicationType.Desktop) {
addAction(Actions.forever(Actions.delay(0.05f, Actions.run {
val amountToMove = 30 / scaleX
if (Gdx.input.isKeyPressed(Input.Keys.W)) scrollY -= amountToMove
if (Gdx.input.isKeyPressed(Input.Keys.S)) scrollY += amountToMove
if (Gdx.input.isKeyPressed(Input.Keys.A)) scrollX -= amountToMove
if (Gdx.input.isKeyPressed(Input.Keys.D)) scrollX += amountToMove
updateVisualScroll()
})))
}
}
private fun onTileClicked(tileInfo: TileInfo) {