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