chore: more direct 'can change state' propagations

This commit is contained in:
Yair Morgenstern 2023-02-20 20:02:30 +02:00
parent 9371ff5035
commit a5f2db5ec0
3 changed files with 8 additions and 11 deletions

View File

@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.unciv.GUI
import com.unciv.UncivGame
import com.unciv.logic.city.IConstruction
import com.unciv.logic.city.PerpetualConstruction
@ -120,7 +119,7 @@ class ConstructionInfoTable(val cityScreen: CityScreen): Table() {
if (cityScreen.city.hasSoldBuildingThisTurn && !cityScreen.city.civ.gameInfo.gameParameters.godMode
|| cityScreen.city.isPuppet
|| !GUI.isMyTurn() || !GUI.isAllowedChangeState())
|| !cityScreen.canChangeState)
sellBuildingButton.disable()
}
}

View File

@ -5,10 +5,6 @@ import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align
import com.unciv.Constants
import com.unciv.GUI
import com.unciv.UncivGame
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.screens.basescreen.BaseScreen
import com.unciv.ui.components.ExpanderTab
import com.unciv.ui.components.extensions.addBorder
import com.unciv.ui.components.extensions.addSeparatorVertical
@ -17,6 +13,8 @@ import com.unciv.ui.components.extensions.onClick
import com.unciv.ui.components.extensions.surroundWithCircle
import com.unciv.ui.components.extensions.toGroup
import com.unciv.ui.components.extensions.toLabel
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.screens.basescreen.BaseScreen
class SpecialistAllocationTable(val cityScreen: CityScreen) : Table(BaseScreen.skin) {
val cityInfo = cityScreen.city
@ -83,7 +81,7 @@ class SpecialistAllocationTable(val cityScreen: CityScreen) : Table(BaseScreen.s
cityInfo.cityStats.update()
cityScreen.update()
}
if (cityInfo.population.getFreePopulation() == 0 || !GUI.isMyTurn())
if (cityInfo.population.getFreePopulation() == 0 || !cityScreen.canChangeState)
assignButton.clear()
return assignButton
}
@ -100,7 +98,7 @@ class SpecialistAllocationTable(val cityScreen: CityScreen) : Table(BaseScreen.s
}
if (assignedSpecialists <= 0 || cityInfo.isPuppet) unassignButton.isVisible = false
if (!GUI.isMyTurn()) unassignButton.clear()
if (!cityScreen.canChangeState) unassignButton.clear()
return unassignButton
}

View File

@ -29,10 +29,8 @@ import com.unciv.models.ruleset.unique.UniqueType
import com.unciv.models.translations.tr
import com.unciv.ui.audio.MusicMood
import com.unciv.ui.audio.MusicTrackChooserFlags
import com.unciv.ui.screens.basescreen.BaseScreen
import com.unciv.ui.components.Fonts
import com.unciv.ui.components.KeyCharAndCode
import com.unciv.ui.screens.basescreen.RecreateOnResize
import com.unciv.ui.components.UncivTooltip.Companion.addTooltip
import com.unciv.ui.components.extensions.addSeparator
import com.unciv.ui.components.extensions.disable
@ -46,6 +44,8 @@ import com.unciv.ui.components.extensions.toTextButton
import com.unciv.ui.components.tilegroups.InfluenceTable
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.popups.ConfirmPopup
import com.unciv.ui.screens.basescreen.BaseScreen
import com.unciv.ui.screens.basescreen.RecreateOnResize
import com.unciv.ui.screens.civilopediascreen.CivilopediaScreen
import kotlin.math.floor
import kotlin.math.roundToInt
@ -73,7 +73,7 @@ class DiplomacyScreen(
private val rightSideTable = Table()
private val closeButton = Constants.close.toTextButton()
private fun isNotPlayersTurn() = !GUI.isMyTurn() || !GUI.isAllowedChangeState()
private fun isNotPlayersTurn() = !GUI.isAllowedChangeState()
init {
val splitPane = SplitPane(leftSideScroll, rightSideTable, false, skin)