mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-23 14:19:15 +07:00
All city screen state-changing functions are now dependant on whether the viewing civ is the current player civ
This commit is contained in:
@ -42,7 +42,7 @@ data class LocationAction(var locations: ArrayList<Vector2> = ArrayList()) : Not
|
||||
class TechAction(val techName: String = "") : NotificationAction {
|
||||
override fun execute(worldScreen: WorldScreen) {
|
||||
val tech = GameBasics.Technologies[techName]
|
||||
worldScreen.game.screen = TechPickerScreen(worldScreen.currentPlayerCiv, tech)
|
||||
worldScreen.game.screen = TechPickerScreen(worldScreen.viewingCiv, tech)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.civilization.GreatPersonManager
|
||||
import com.unciv.models.gamebasics.Building
|
||||
@ -67,6 +68,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
|
||||
val sellAmount = cityScreen.city.getGoldForSellingBuilding(building.name)
|
||||
val sellBuildingButton = TextButton("Sell for [$sellAmount] gold".tr(),skin)
|
||||
wonderDetailsTable.add(sellBuildingButton).pad(5f).row()
|
||||
|
||||
sellBuildingButton.onClick {
|
||||
YesNoPopupTable("Are you sure you want to sell this [${building.name}]?".tr(),
|
||||
{
|
||||
@ -75,7 +77,8 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
|
||||
cityScreen.update()
|
||||
}, cityScreen)
|
||||
}
|
||||
if(cityScreen.city.hasSoldBuildingThisTurn || sellAmount > cityScreen.city.civInfo.gold)
|
||||
if(cityScreen.city.hasSoldBuildingThisTurn || sellAmount > cityScreen.city.civInfo.gold
|
||||
|| !UnCivGame.Current.worldScreen.isPlayersTurn)
|
||||
sellBuildingButton.disable()
|
||||
}
|
||||
wonderDetailsTable.addSeparator()
|
||||
@ -219,6 +222,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
|
||||
cityInfo.cityStats.update()
|
||||
cityScreen.update()
|
||||
}
|
||||
if(!UnCivGame.Current.worldScreen.isPlayersTurn) unassignButton.disable()
|
||||
specialistPickerTable.add(unassignButton)
|
||||
} else specialistPickerTable.add()
|
||||
|
||||
@ -236,7 +240,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
|
||||
cityInfo.cityStats.update()
|
||||
cityScreen.update()
|
||||
}
|
||||
if (cityInfo.population.getFreePopulation() == 0)
|
||||
if (cityInfo.population.getFreePopulation() == 0 || !UnCivGame.Current.worldScreen.isPlayersTurn)
|
||||
assignButton.disable()
|
||||
specialistPickerTable.add(assignButton)
|
||||
} else specialistPickerTable.add()
|
||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.HexMath
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.map.TileInfo
|
||||
@ -165,11 +166,13 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
||||
if(!city.isBeingRazed) {
|
||||
val razeCityButton = TextButton("Raze city".tr(), skin)
|
||||
razeCityButton.onClick { city.isBeingRazed=true; update() }
|
||||
if(!UnCivGame.Current.worldScreen.isPlayersTurn) razeCityButton.disable()
|
||||
razeCityButtonHolder.add(razeCityButton).colspan(cityPickerTable.columns)
|
||||
}
|
||||
else {
|
||||
val stopRazingCityButton = TextButton("Stop razing city".tr(), skin)
|
||||
stopRazingCityButton.onClick { city.isBeingRazed=false; update() }
|
||||
if(!UnCivGame.Current.worldScreen.isPlayersTurn) stopRazingCityButton.disable()
|
||||
razeCityButtonHolder.add(stopRazingCityButton).colspan(cityPickerTable.columns)
|
||||
}
|
||||
razeCityButtonHolder.pack()
|
||||
@ -192,7 +195,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
||||
|
||||
tileGroup.onClick {
|
||||
selectedTile = tileInfo
|
||||
if (tileGroup.isWorkable) {
|
||||
if (tileGroup.isWorkable && UnCivGame.Current.worldScreen.isPlayersTurn) {
|
||||
if (!tileInfo.isWorked() && city.population.getFreePopulation() > 0)
|
||||
city.workedTiles.add(tileInfo.position)
|
||||
else if (tileInfo.isWorked()) city.workedTiles.remove(tileInfo.position)
|
||||
|
@ -53,7 +53,8 @@ class CityScreenTileTable(val city: CityInfo): Table(){
|
||||
city.expansion.buyTile(selectedTile)
|
||||
UnCivGame.Current.screen = CityScreen(city)
|
||||
}
|
||||
if(goldCostOfTile>city.civInfo.gold) buyTileButton.disable()
|
||||
if(goldCostOfTile>city.civInfo.gold || !UnCivGame.Current.worldScreen.isPlayersTurn)
|
||||
buyTileButton.disable()
|
||||
|
||||
innerTable.add(buyTileButton)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.city.SpecialConstruction
|
||||
import com.unciv.models.gamebasics.Building
|
||||
@ -47,7 +48,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
||||
pickProductionButton.add(ImageGetter.getConstructionImage(construction).surroundWithCircle(40f)).padRight(10f)
|
||||
pickProductionButton.add(buttonText.toLabel().setFontColor(Color.WHITE))
|
||||
|
||||
if(rejectionReason=="") { // no rejection reason means we can build it!
|
||||
if(rejectionReason=="" && UnCivGame.Current.worldScreen.isPlayersTurn) { // no rejection reason means we can build it!
|
||||
pickProductionButton.onClick {
|
||||
lastConstruction = cityScreen.city.cityConstructions.currentConstruction
|
||||
cityScreen.city.cityConstructions.currentConstruction = construction
|
||||
@ -55,6 +56,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
||||
cityScreen.city.cityStats.update()
|
||||
cityScreen.update()
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
pickProductionButton.color = Color.GRAY
|
||||
|
@ -39,7 +39,7 @@ class PolicyPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen(
|
||||
}
|
||||
else game.screen = PolicyPickerScreen(civInfo) // update policies
|
||||
}
|
||||
if(!UnCivGame.Current.worldScreen.isPlayersTurn())
|
||||
if(!UnCivGame.Current.worldScreen.isPlayersTurn)
|
||||
rightSideButton.disable()
|
||||
|
||||
|
||||
|
@ -102,7 +102,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
||||
game.worldScreen.shouldUpdate = true
|
||||
dispose()
|
||||
}
|
||||
if(!UnCivGame.Current.worldScreen.isPlayersTurn())
|
||||
if(!UnCivGame.Current.worldScreen.isPlayersTurn)
|
||||
rightSideButton.disable()
|
||||
|
||||
displayTutorials("TechPickerScreen")
|
||||
|
@ -28,7 +28,7 @@ class WorldTileGroup(internal val worldScreen: WorldScreen, tileInfo: TileInfo,
|
||||
&& city!!.civInfo.isPlayerCivilization())
|
||||
addPopulationIcon()
|
||||
|
||||
val currentPlayerCiv = worldScreen.currentPlayerCiv
|
||||
val currentPlayerCiv = worldScreen.viewingCiv
|
||||
if (UnCivGame.Current.viewEntireMapForDebug
|
||||
|| currentPlayerCiv.exploredTiles.contains(tileInfo.position))
|
||||
updateCityButton(city, isViewable || UnCivGame.Current.viewEntireMapForDebug) // needs to be before the update so the units will be above the city button
|
||||
|
@ -28,7 +28,7 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
||||
val leftSideTable = Table().apply { defaults().pad(10f) }
|
||||
val rightSideTable = Table()
|
||||
|
||||
fun isNotPlayersTurn() = !UnCivGame.Current.worldScreen.isPlayersTurn()
|
||||
fun isNotPlayersTurn() = !UnCivGame.Current.worldScreen.isPlayersTurn
|
||||
|
||||
init {
|
||||
onBackButtonClicked { UnCivGame.Current.setWorldScreen() }
|
||||
|
@ -63,7 +63,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||
addGoodSizedLabel("What would you like to do with the city?").row()
|
||||
add(getCloseButton("Annex")).row()
|
||||
add(TextButton("Raze", skin).onClick {
|
||||
worldScreen.currentPlayerCiv.cities.first { it.name==popupAlert.value }.isBeingRazed=true
|
||||
worldScreen.viewingCiv.cities.first { it.name==popupAlert.value }.isBeingRazed=true
|
||||
worldScreen.shouldUpdate=true
|
||||
close()
|
||||
})
|
||||
@ -79,7 +79,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||
}
|
||||
AlertType.DemandToStopSettlingCitiesNear -> {
|
||||
val otherciv= worldScreen.gameInfo.getCivilization(popupAlert.value)
|
||||
val playerDiploManager = worldScreen.currentPlayerCiv.getDiplomacyManager(otherciv)
|
||||
val playerDiploManager = worldScreen.viewingCiv.getDiplomacyManager(otherciv)
|
||||
val translatedNation = otherciv.getTranslatedNation()
|
||||
addLeaderName(translatedNation)
|
||||
addGoodSizedLabel("Please don't settle new cities near us.").row()
|
||||
@ -103,7 +103,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||
}
|
||||
|
||||
fun close(){
|
||||
worldScreen.currentPlayerCiv.popupAlerts.remove(popupAlert)
|
||||
worldScreen.viewingCiv.popupAlerts.remove(popupAlert)
|
||||
isOpen = false
|
||||
remove()
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
onTileClicked(tileGroup.tileInfo)
|
||||
}
|
||||
override fun longPress(actor: Actor?, x: Float, y: Float): Boolean {
|
||||
if(!worldScreen.isPlayersTurn()) return false // no long click when it's not your turn
|
||||
if(!worldScreen.isPlayersTurn) return false // no long click when it's not your turn
|
||||
return onTileLongClicked(tileGroup.tileInfo)
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
val newSelectedUnit = unitTable.selectedUnit
|
||||
|
||||
if (previousSelectedUnit != null && previousSelectedUnit.getTile() != tileInfo
|
||||
&& worldScreen.isPlayersTurn()
|
||||
&& worldScreen.isPlayersTurn
|
||||
&& previousSelectedUnit.movement.canMoveTo(tileInfo) && previousSelectedUnit.movement.canReach(tileInfo)) {
|
||||
// this can take a long time, because of the unit-to-tile calculation needed, so we put it in a different thread
|
||||
addTileOverlaysWithUnitMovement(previousSelectedUnit, tileInfo)
|
||||
@ -116,7 +116,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
|
||||
if(newSelectedUnit==null || newSelectedUnit.type==UnitType.Civilian){
|
||||
val unitsInTile = selectedTile!!.getUnits()
|
||||
if(unitsInTile.isNotEmpty() && unitsInTile.first().civInfo.isAtWarWith(worldScreen.currentPlayerCiv)){
|
||||
if(unitsInTile.isNotEmpty() && unitsInTile.first().civInfo.isAtWarWith(worldScreen.viewingCiv)){
|
||||
// try to select the closest city to bombard this guy
|
||||
val citiesThatCanBombard = selectedTile!!.getTilesInDistance(2)
|
||||
.filter { it.isCityCenter() }.map { it.getCity()!! }
|
||||
@ -160,7 +160,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
if(moveHereDto!=null)
|
||||
table.add(getMoveHereButton(moveHereDto))
|
||||
|
||||
if (tileInfo.isCityCenter() && tileInfo.getOwner()==worldScreen.currentPlayerCiv) {
|
||||
if (tileInfo.isCityCenter() && tileInfo.getOwner()==worldScreen.viewingCiv) {
|
||||
for (unit in tileInfo.getCity()!!.getCenterTile().getUnits()) {
|
||||
val unitGroup = UnitGroup(unit, 60f).surroundWithCircle(80f)
|
||||
unitGroup.circle.color = Color.GRAY.cpy().apply { a = 0.5f }
|
||||
|
@ -15,7 +15,7 @@ import kotlin.math.max
|
||||
|
||||
class TradePopup(worldScreen: WorldScreen): PopupTable(worldScreen){
|
||||
init{
|
||||
val currentPlayerCiv = worldScreen.currentPlayerCiv
|
||||
val currentPlayerCiv = worldScreen.viewingCiv
|
||||
val tradeRequest = currentPlayerCiv.tradeRequests.first()
|
||||
|
||||
val requestingCiv = worldScreen.gameInfo.getCivilization(tradeRequest.requestingCiv)
|
||||
|
@ -27,9 +27,9 @@ import com.unciv.ui.worldscreen.bottombar.BattleTable
|
||||
import com.unciv.ui.worldscreen.bottombar.WorldScreenBottomBar
|
||||
import com.unciv.ui.worldscreen.unit.UnitActionsTable
|
||||
|
||||
class WorldScreen(val currentPlayerCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
val gameInfo = game.gameInfo
|
||||
fun isPlayersTurn() = currentPlayerCiv == gameInfo.currentPlayerCiv
|
||||
var isPlayersTurn = viewingCiv == gameInfo.currentPlayerCiv // todo this should be updated when passing turns
|
||||
|
||||
val tileMapHolder: TileMapHolder = TileMapHolder(this, gameInfo.tileMap)
|
||||
val minimapWrapper = MinimapHolder(tileMapHolder)
|
||||
@ -59,7 +59,7 @@ class WorldScreen(val currentPlayerCiv:CivilizationInfo) : CameraStageBaseScreen
|
||||
|
||||
techButton.touchable=Touchable.enabled
|
||||
techButton.onClick("paper") {
|
||||
game.screen = TechPickerScreen(currentPlayerCiv)
|
||||
game.screen = TechPickerScreen(viewingCiv)
|
||||
}
|
||||
|
||||
stage.addActor(tileMapHolder)
|
||||
@ -89,8 +89,8 @@ class WorldScreen(val currentPlayerCiv:CivilizationInfo) : CameraStageBaseScreen
|
||||
|
||||
val tileToCenterOn: Vector2 =
|
||||
when {
|
||||
currentPlayerCiv.cities.isNotEmpty() -> currentPlayerCiv.getCapital().location
|
||||
currentPlayerCiv.getCivUnits().isNotEmpty() -> currentPlayerCiv.getCivUnits().first().getTile().position
|
||||
viewingCiv.cities.isNotEmpty() -> viewingCiv.getCapital().location
|
||||
viewingCiv.getCivUnits().isNotEmpty() -> viewingCiv.getCivUnits().first().getTile().position
|
||||
else -> Vector2.Zero
|
||||
}
|
||||
tileMapHolder.setCenterPosition(tileToCenterOn,true)
|
||||
@ -157,23 +157,23 @@ class WorldScreen(val currentPlayerCiv:CivilizationInfo) : CameraStageBaseScreen
|
||||
// if we use the clone, then when we update viewable tiles
|
||||
// it doesn't update the explored tiles of the civ... need to think about that harder
|
||||
// it causes a bug when we move a unit to an unexplored tile (for instance a cavalry unit which can move far)
|
||||
tileMapHolder.updateTiles(currentPlayerCiv)
|
||||
tileMapHolder.updateTiles(viewingCiv)
|
||||
|
||||
topBar.update(cloneCivilization)
|
||||
notificationsScroll.update(currentPlayerCiv.notifications)
|
||||
notificationsScroll.update(viewingCiv.notifications)
|
||||
notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f,
|
||||
nextTurnButton.y - notificationsScroll.height - 5f)
|
||||
|
||||
when {
|
||||
!gameInfo.oneMoreTurnMode && gameInfo.civilizations.any { it.victoryManager.hasWon() } -> game.screen = VictoryScreen()
|
||||
currentPlayerCiv.policies.freePolicies>0 -> game.screen = PolicyPickerScreen(currentPlayerCiv)
|
||||
currentPlayerCiv.greatPeople.freeGreatPeople>0 -> game.screen = GreatPersonPickerScreen()
|
||||
currentPlayerCiv.tradeRequests.isNotEmpty() ->{
|
||||
viewingCiv.policies.freePolicies>0 -> game.screen = PolicyPickerScreen(viewingCiv)
|
||||
viewingCiv.greatPeople.freeGreatPeople>0 -> game.screen = GreatPersonPickerScreen()
|
||||
viewingCiv.tradeRequests.isNotEmpty() ->{
|
||||
TradePopup(this)
|
||||
}
|
||||
!tutorials.isTutorialShowing
|
||||
&& currentPlayerCiv.popupAlerts.any() && !AlertPopup.isOpen ->
|
||||
AlertPopup(this,currentPlayerCiv.popupAlerts.first())
|
||||
&& viewingCiv.popupAlerts.any() && !AlertPopup.isOpen ->
|
||||
AlertPopup(this,viewingCiv.popupAlerts.first())
|
||||
}
|
||||
updateNextTurnButton()
|
||||
}
|
||||
@ -181,7 +181,7 @@ class WorldScreen(val currentPlayerCiv:CivilizationInfo) : CameraStageBaseScreen
|
||||
private fun updateDiplomacyButton(civInfo: CivilizationInfo) {
|
||||
diplomacyButtonWrapper.clear()
|
||||
if(civInfo.getKnownCivs()
|
||||
.filterNot { it.isDefeated() || it==currentPlayerCiv || it.isBarbarianCivilization() }
|
||||
.filterNot { it.isDefeated() || it==viewingCiv || it.isBarbarianCivilization() }
|
||||
.any()) {
|
||||
displayTutorials("OtherCivEncountered")
|
||||
val btn = TextButton("Diplomacy".tr(), skin)
|
||||
@ -232,8 +232,8 @@ class WorldScreen(val currentPlayerCiv:CivilizationInfo) : CameraStageBaseScreen
|
||||
|
||||
nextTurnButton.onClick {
|
||||
// cycle through units not yet done
|
||||
if (currentPlayerCiv.shouldGoToDueUnit()) {
|
||||
val nextDueUnit = currentPlayerCiv.getNextDueUnit()
|
||||
if (viewingCiv.shouldGoToDueUnit()) {
|
||||
val nextDueUnit = viewingCiv.getNextDueUnit()
|
||||
if(nextDueUnit!=null) {
|
||||
tileMapHolder.setCenterPosition(nextDueUnit.currentTile.position, false, false)
|
||||
bottomBar.unitTable.selectedUnit = nextDueUnit
|
||||
@ -242,19 +242,19 @@ class WorldScreen(val currentPlayerCiv:CivilizationInfo) : CameraStageBaseScreen
|
||||
return@onClick
|
||||
}
|
||||
|
||||
val cityWithNoProductionSet = currentPlayerCiv.cities
|
||||
val cityWithNoProductionSet = viewingCiv.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)
|
||||
if (viewingCiv.shouldOpenTechPicker()) {
|
||||
game.screen = TechPickerScreen(viewingCiv.tech.freeTechs != 0, viewingCiv)
|
||||
return@onClick
|
||||
} else if (currentPlayerCiv.policies.shouldOpenPolicyPicker) {
|
||||
game.screen = PolicyPickerScreen(currentPlayerCiv)
|
||||
currentPlayerCiv.policies.shouldOpenPolicyPicker = false
|
||||
} else if (viewingCiv.policies.shouldOpenPolicyPicker) {
|
||||
game.screen = PolicyPickerScreen(viewingCiv)
|
||||
viewingCiv.policies.shouldOpenPolicyPicker = false
|
||||
return@onClick
|
||||
}
|
||||
|
||||
@ -298,13 +298,13 @@ class WorldScreen(val currentPlayerCiv:CivilizationInfo) : CameraStageBaseScreen
|
||||
}
|
||||
|
||||
fun updateNextTurnButton() {
|
||||
val text = if (currentPlayerCiv.shouldGoToDueUnit())
|
||||
val text = if (viewingCiv.shouldGoToDueUnit())
|
||||
"Next unit"
|
||||
else if(currentPlayerCiv.cities.any{it.cityConstructions.currentConstruction==""})
|
||||
else if(viewingCiv.cities.any{it.cityConstructions.currentConstruction==""})
|
||||
"Pick construction"
|
||||
else if(currentPlayerCiv.shouldOpenTechPicker())
|
||||
else if(viewingCiv.shouldOpenTechPicker())
|
||||
"Pick a tech"
|
||||
else if(currentPlayerCiv.policies.shouldOpenPolicyPicker)
|
||||
else if(viewingCiv.policies.shouldOpenPolicyPicker)
|
||||
"Pick a policy"
|
||||
else
|
||||
"Next turn"
|
||||
@ -319,7 +319,7 @@ class WorldScreen(val currentPlayerCiv:CivilizationInfo) : CameraStageBaseScreen
|
||||
override fun resize(width: Int, height: Int) {
|
||||
if (stage.viewport.screenWidth != width || stage.viewport.screenHeight != height) {
|
||||
super.resize(width, height)
|
||||
game.worldScreen = WorldScreen(currentPlayerCiv) // start over.
|
||||
game.worldScreen = WorldScreen(viewingCiv) // start over.
|
||||
game.setWorldScreen()
|
||||
}
|
||||
}
|
||||
@ -333,7 +333,7 @@ class WorldScreen(val currentPlayerCiv:CivilizationInfo) : CameraStageBaseScreen
|
||||
if (shouldUpdate) {
|
||||
shouldUpdate = false
|
||||
|
||||
if (currentPlayerCiv != gameInfo.getCurrentPlayerCivilization()) {
|
||||
if (viewingCiv != gameInfo.getCurrentPlayerCivilization()) {
|
||||
UnCivGame.Current.worldScreen.dispose() // for memory saving
|
||||
UnCivGame.Current.screen = PlayerReadyScreen(gameInfo.getCurrentPlayerCivilization())
|
||||
return
|
||||
@ -350,26 +350,26 @@ class WorldScreen(val currentPlayerCiv:CivilizationInfo) : CameraStageBaseScreen
|
||||
val shownTutorials = UnCivGame.Current.settings.tutorialsShown
|
||||
displayTutorials("NextTurn")
|
||||
if("BarbarianEncountered" !in shownTutorials
|
||||
&& currentPlayerCiv.viewableTiles.any { it.getUnits().any { unit -> unit.civInfo.isBarbarianCivilization() } })
|
||||
&& viewingCiv.viewableTiles.any { it.getUnits().any { unit -> unit.civInfo.isBarbarianCivilization() } })
|
||||
displayTutorials("BarbarianEncountered")
|
||||
if(currentPlayerCiv.cities.size > 2) displayTutorials("SecondCity")
|
||||
if(currentPlayerCiv.getHappiness() < 5) displayTutorials("HappinessGettingLow")
|
||||
if(currentPlayerCiv.getHappiness() < 0) displayTutorials("Unhappiness")
|
||||
if(currentPlayerCiv.goldenAges.isGoldenAge()) displayTutorials("GoldenAge")
|
||||
if(viewingCiv.cities.size > 2) displayTutorials("SecondCity")
|
||||
if(viewingCiv.getHappiness() < 5) displayTutorials("HappinessGettingLow")
|
||||
if(viewingCiv.getHappiness() < 0) displayTutorials("Unhappiness")
|
||||
if(viewingCiv.goldenAges.isGoldenAge()) displayTutorials("GoldenAge")
|
||||
if(gameInfo.turns >= 50 && UnCivGame.Current.settings.checkForDueUnits) displayTutorials("Idle_Units")
|
||||
if(gameInfo.turns >= 100) displayTutorials("ContactMe")
|
||||
val resources = currentPlayerCiv.getCivResources()
|
||||
val resources = viewingCiv.getCivResources()
|
||||
if(resources.any { it.resource.resourceType==ResourceType.Luxury }) displayTutorials("LuxuryResource")
|
||||
if(resources.any { it.resource.resourceType==ResourceType.Strategic}) displayTutorials("StrategicResource")
|
||||
if("EnemyCity" !in shownTutorials
|
||||
&& gameInfo.civilizations.filter { it!=currentPlayerCiv }
|
||||
.flatMap { it.cities }.any { currentPlayerCiv.exploredTiles.contains(it.location) })
|
||||
&& gameInfo.civilizations.filter { it!=viewingCiv }
|
||||
.flatMap { it.cities }.any { viewingCiv.exploredTiles.contains(it.location) })
|
||||
displayTutorials("EnemyCity")
|
||||
if(currentPlayerCiv.containsBuildingUnique("Enables construction of Spaceship parts"))
|
||||
if(viewingCiv.containsBuildingUnique("Enables construction of Spaceship parts"))
|
||||
displayTutorials("ApolloProgram")
|
||||
if(currentPlayerCiv.getCivUnits().any { it.type == UnitType.Siege })
|
||||
if(viewingCiv.getCivUnits().any { it.type == UnitType.Siege })
|
||||
displayTutorials("SiegeUnitTrained")
|
||||
if(currentPlayerCiv.tech.getTechUniques().contains("Enables embarkation for land units"))
|
||||
if(viewingCiv.tech.getTechUniques().contains("Enables embarkation for land units"))
|
||||
displayTutorials("CanEmbark")
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ import kotlin.math.max
|
||||
|
||||
class BattleTable(val worldScreen: WorldScreen): Table() {
|
||||
|
||||
private val battle = Battle(worldScreen.currentPlayerCiv.gameInfo)
|
||||
private val battle = Battle(worldScreen.viewingCiv.gameInfo)
|
||||
init{
|
||||
skin = CameraStageBaseScreen.skin
|
||||
background = ImageGetter.getBackground(ImageGetter.getBlue())
|
||||
@ -52,7 +52,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
||||
val defender: ICombatant? = Battle(worldScreen.gameInfo).getMapCombatantOfTile(selectedTile)
|
||||
|
||||
if(defender==null ||
|
||||
defender.getCivInfo()==worldScreen.currentPlayerCiv
|
||||
defender.getCivInfo()==worldScreen.viewingCiv
|
||||
|| !(UnCivGame.Current.viewEntireMapForDebug
|
||||
|| attacker.getCivInfo().exploredTiles.contains(selectedTile.position))) {
|
||||
hide()
|
||||
@ -158,7 +158,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
||||
}
|
||||
}
|
||||
|
||||
if (!worldScreen.isPlayersTurn() || attackableEnemy == null) {
|
||||
if (!worldScreen.isPlayersTurn || attackableEnemy == null) {
|
||||
attackButton.disable()
|
||||
attackButton.label.color = Color.GRAY
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(CameraStageBas
|
||||
|
||||
internal fun updateTileTable(tile: TileInfo) {
|
||||
clearChildren()
|
||||
val civInfo = worldScreen.currentPlayerCiv
|
||||
val civInfo = worldScreen.viewingCiv
|
||||
columnDefaults(0).padRight(10f)
|
||||
|
||||
if (UnCivGame.Current.viewEntireMapForDebug || civInfo.exploredTiles.contains(tile.position)) {
|
||||
@ -36,7 +36,7 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(CameraStageBas
|
||||
table.pad(10f)
|
||||
table.defaults().pad(2f)
|
||||
|
||||
for (entry in tile.getTileStats(worldScreen.currentPlayerCiv).toHashMap().filterNot { it.value == 0f }) {
|
||||
for (entry in tile.getTileStats(worldScreen.viewingCiv).toHashMap().filterNot { it.value == 0f }) {
|
||||
table.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f).align(Align.right)
|
||||
table.add(Label(entry.value.toInt().toString(), skin)).align(Align.left)
|
||||
table.row()
|
||||
|
@ -142,7 +142,7 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
UnCivGame.Current.settings.resolution = resolutionSelectBox.selected
|
||||
UnCivGame.Current.settings.save()
|
||||
UnCivGame.Current.worldScreen = WorldScreen(worldScreen.currentPlayerCiv)
|
||||
UnCivGame.Current.worldScreen = WorldScreen(worldScreen.viewingCiv)
|
||||
UnCivGame.Current.setWorldScreen()
|
||||
WorldScreenOptionsTable(UnCivGame.Current.worldScreen)
|
||||
}
|
||||
@ -165,7 +165,7 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
UnCivGame.Current.settings.tileSet = tileSetSelectBox.selected
|
||||
UnCivGame.Current.settings.save()
|
||||
UnCivGame.Current.worldScreen = WorldScreen(worldScreen.currentPlayerCiv)
|
||||
UnCivGame.Current.worldScreen = WorldScreen(worldScreen.viewingCiv)
|
||||
UnCivGame.Current.setWorldScreen()
|
||||
WorldScreenOptionsTable(UnCivGame.Current.worldScreen)
|
||||
}
|
||||
@ -248,7 +248,7 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
||||
|
||||
CameraStageBaseScreen.resetFonts()
|
||||
|
||||
UnCivGame.Current.worldScreen = WorldScreen(worldScreen.currentPlayerCiv)
|
||||
UnCivGame.Current.worldScreen = WorldScreen(worldScreen.viewingCiv)
|
||||
UnCivGame.Current.setWorldScreen()
|
||||
WorldScreenOptionsTable(UnCivGame.Current.worldScreen)
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.onClick
|
||||
import com.unciv.ui.worldscreen.TileMapHolder
|
||||
@ -18,7 +17,7 @@ class IdleUnitButton (
|
||||
|
||||
val image = ImageGetter.getImage("OtherIcons/BackArrow")
|
||||
|
||||
fun hasIdleUnits() = unitTable.worldScreen.currentPlayerCiv.getIdleUnits().isNotEmpty()
|
||||
fun hasIdleUnits() = unitTable.worldScreen.viewingCiv.getIdleUnits().isNotEmpty()
|
||||
|
||||
init {
|
||||
val imageSize = 25f
|
||||
@ -31,7 +30,7 @@ class IdleUnitButton (
|
||||
enable()
|
||||
onClick {
|
||||
|
||||
val idleUnits = unitTable.worldScreen.currentPlayerCiv.getIdleUnits()
|
||||
val idleUnits = unitTable.worldScreen.viewingCiv.getIdleUnits()
|
||||
if(idleUnits.isEmpty()) return@onClick
|
||||
|
||||
val unitToSelect: MapUnit
|
||||
|
@ -59,7 +59,7 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){
|
||||
fun update(unit: MapUnit?){
|
||||
clear()
|
||||
if (unit == null) return
|
||||
if(!worldScreen.isPlayersTurn()) return // No actions when it's not your turn!
|
||||
if(!worldScreen.isPlayersTurn) return // No actions when it's not your turn!
|
||||
for (button in UnitActions().getUnitActions(unit, worldScreen).map { getUnitActionButton(it) })
|
||||
add(button).colspan(2).pad(5f).row()
|
||||
pack()
|
||||
|
@ -86,7 +86,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
||||
|
||||
fun update() {
|
||||
if(selectedUnit!=null) {
|
||||
if (selectedUnit!!.civInfo != worldScreen.currentPlayerCiv) { // The unit that was selected, was captured. It exists but is no longer ours.
|
||||
if (selectedUnit!!.civInfo != worldScreen.viewingCiv) { // The unit that was selected, was captured. It exists but is no longer ours.
|
||||
selectedUnit = null
|
||||
selectedCity = null
|
||||
selectedUnitHasChanged = true
|
||||
@ -204,16 +204,16 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
||||
fun tileSelected(selectedTile: TileInfo) {
|
||||
|
||||
val previouslySelectedUnit = selectedUnit
|
||||
if(selectedTile.isCityCenter() && selectedTile.getOwner()==worldScreen.currentPlayerCiv){
|
||||
if(selectedTile.isCityCenter() && selectedTile.getOwner()==worldScreen.viewingCiv){
|
||||
citySelected(selectedTile.getCity()!!)
|
||||
}
|
||||
else if(selectedTile.militaryUnit!=null && selectedTile.militaryUnit!!.civInfo == worldScreen.currentPlayerCiv
|
||||
else if(selectedTile.militaryUnit!=null && selectedTile.militaryUnit!!.civInfo == worldScreen.viewingCiv
|
||||
&& selectedUnit!=selectedTile.militaryUnit
|
||||
&& (selectedTile.civilianUnit==null || selectedUnit!=selectedTile.civilianUnit)){
|
||||
selectedUnit = selectedTile.militaryUnit
|
||||
selectedCity = null
|
||||
}
|
||||
else if (selectedTile.civilianUnit!=null && selectedTile.civilianUnit!!.civInfo == worldScreen.currentPlayerCiv
|
||||
else if (selectedTile.civilianUnit!=null && selectedTile.civilianUnit!!.civInfo == worldScreen.viewingCiv
|
||||
&& selectedUnit!=selectedTile.civilianUnit){
|
||||
selectedUnit = selectedTile.civilianUnit
|
||||
selectedCity = null
|
||||
|
Reference in New Issue
Block a user