mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
parent
0b507422f0
commit
461028deed
@ -12,6 +12,7 @@ import com.unciv.logic.GameInfo
|
|||||||
import com.unciv.logic.IsPartOfGameInfoSerialization
|
import com.unciv.logic.IsPartOfGameInfoSerialization
|
||||||
import com.unciv.logic.files.UncivFiles
|
import com.unciv.logic.files.UncivFiles
|
||||||
import com.unciv.logic.UncivShowableException
|
import com.unciv.logic.UncivShowableException
|
||||||
|
import com.unciv.logic.civilization.Civilization
|
||||||
import com.unciv.logic.civilization.PlayerType
|
import com.unciv.logic.civilization.PlayerType
|
||||||
import com.unciv.logic.multiplayer.OnlineMultiplayer
|
import com.unciv.logic.multiplayer.OnlineMultiplayer
|
||||||
import com.unciv.models.metadata.GameSettings
|
import com.unciv.models.metadata.GameSettings
|
||||||
@ -36,7 +37,9 @@ import com.unciv.ui.screens.mainmenuscreen.MainMenuScreen
|
|||||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||||
import com.unciv.ui.components.extensions.center
|
import com.unciv.ui.components.extensions.center
|
||||||
import com.unciv.ui.screens.worldscreen.PlayerReadyScreen
|
import com.unciv.ui.screens.worldscreen.PlayerReadyScreen
|
||||||
|
import com.unciv.ui.screens.worldscreen.WorldMapHolder
|
||||||
import com.unciv.ui.screens.worldscreen.WorldScreen
|
import com.unciv.ui.screens.worldscreen.WorldScreen
|
||||||
|
import com.unciv.ui.screens.worldscreen.unit.UnitTable
|
||||||
import com.unciv.utils.Log
|
import com.unciv.utils.Log
|
||||||
import com.unciv.utils.concurrency.Concurrency
|
import com.unciv.utils.concurrency.Concurrency
|
||||||
import com.unciv.utils.concurrency.launchOnGLThread
|
import com.unciv.utils.concurrency.launchOnGLThread
|
||||||
@ -48,6 +51,66 @@ import java.io.PrintWriter
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayDeque
|
import kotlin.collections.ArrayDeque
|
||||||
|
|
||||||
|
object GUI {
|
||||||
|
|
||||||
|
fun isDebugMapVisible(): Boolean {
|
||||||
|
return UncivGame.Current.viewEntireMapForDebug
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setUpdateWorldOnNextRender() {
|
||||||
|
UncivGame.Current.worldScreen?.shouldUpdate = true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun pushScreen(screen: BaseScreen) {
|
||||||
|
UncivGame.Current.pushScreen(screen)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun resetToWorldScreen() {
|
||||||
|
UncivGame.Current.resetToWorldScreen()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSettings(): GameSettings {
|
||||||
|
return UncivGame.Current.settings
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isWorldLoaded(): Boolean {
|
||||||
|
return UncivGame.Current.worldScreen != null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isMyTurn(): Boolean {
|
||||||
|
return UncivGame.Current.worldScreen!!.isPlayersTurn
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isAllowedChangeState(): Boolean {
|
||||||
|
return UncivGame.Current.worldScreen!!.canChangeState
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getWorldScreen(): WorldScreen {
|
||||||
|
return UncivGame.Current.worldScreen!!
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getWorldScreenIfActive(): WorldScreen? {
|
||||||
|
return UncivGame.Current.getWorldScreenIfActive()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getMap(): WorldMapHolder {
|
||||||
|
return UncivGame.Current.worldScreen!!.mapHolder
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getUnitTable(): UnitTable {
|
||||||
|
return UncivGame.Current.worldScreen!!.bottomUnitTable
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getViewingPlayer(): Civilization {
|
||||||
|
return UncivGame.Current.worldScreen!!.viewingCiv
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSelectedPlayer(): Civilization {
|
||||||
|
return UncivGame.Current.worldScreen!!.selectedCiv
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
class UncivGame(parameters: UncivGameParameters) : Game() {
|
class UncivGame(parameters: UncivGameParameters) : Game() {
|
||||||
constructor() : this(UncivGameParameters())
|
constructor() : this(UncivGameParameters())
|
||||||
|
|
||||||
@ -61,7 +124,6 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
|||||||
|
|
||||||
var deepLinkedMultiplayerGame: String? = null
|
var deepLinkedMultiplayerGame: String? = null
|
||||||
var gameInfo: GameInfo? = null
|
var gameInfo: GameInfo? = null
|
||||||
private set
|
|
||||||
lateinit var settings: GameSettings
|
lateinit var settings: GameSettings
|
||||||
lateinit var musicController: MusicController
|
lateinit var musicController: MusicController
|
||||||
lateinit var onlineMultiplayer: OnlineMultiplayer
|
lateinit var onlineMultiplayer: OnlineMultiplayer
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.logic.automation.ai
|
package com.unciv.logic.automation.ai
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.IsPartOfGameInfoSerialization
|
import com.unciv.logic.IsPartOfGameInfoSerialization
|
||||||
import com.unciv.logic.civilization.Civilization
|
import com.unciv.logic.civilization.Civilization
|
||||||
@ -32,7 +33,7 @@ class TacticalAI : IsPartOfGameInfoSerialization {
|
|||||||
Log.debug("MYTAG Zone $zoneId City: ${zone?.city} Area: ${zone?.area} Area size: ${
|
Log.debug("MYTAG Zone $zoneId City: ${zone?.city} Area: ${zone?.area} Area size: ${
|
||||||
tile.tileMap.continentSizes[tile.getContinent()]} Zone size: ${zone?.tileCount}")
|
tile.tileMap.continentSizes[tile.getContinent()]} Zone size: ${zone?.tileCount}")
|
||||||
|
|
||||||
val mapHolder = UncivGame.Current.worldScreen!!.mapHolder
|
val mapHolder = GUI.getMap()
|
||||||
|
|
||||||
for (otherTile in mapHolder.tileMap.values.asSequence()) {
|
for (otherTile in mapHolder.tileMap.values.asSequence()) {
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.unciv.logic.city
|
package com.unciv.logic.city
|
||||||
|
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.IsPartOfGameInfoSerialization
|
import com.unciv.logic.IsPartOfGameInfoSerialization
|
||||||
import com.unciv.logic.automation.Automation
|
import com.unciv.logic.automation.Automation
|
||||||
@ -673,8 +674,7 @@ class CityConstructions : IsPartOfGameInfoSerialization {
|
|||||||
city.cityStats.update()
|
city.cityStats.update()
|
||||||
city.civ.cache.updateCivResources()
|
city.civ.cache.updateCivResources()
|
||||||
// If bought the worldscreen will not have been marked to update, and the new improvement won't show until later...
|
// If bought the worldscreen will not have been marked to update, and the new improvement won't show until later...
|
||||||
if (UncivGame.isCurrentInitialized() && UncivGame.Current.worldScreen != null)
|
GUI.setUpdateWorldOnNextRender()
|
||||||
UncivGame.Current.worldScreen!!.shouldUpdate = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Support for [UniqueType.CreatesOneImprovement]:
|
/** Support for [UniqueType.CreatesOneImprovement]:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.logic.city.managers
|
package com.unciv.logic.city.managers
|
||||||
|
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.battle.Battle
|
import com.unciv.logic.battle.Battle
|
||||||
import com.unciv.logic.city.City
|
import com.unciv.logic.city.City
|
||||||
@ -158,10 +159,7 @@ class CityInfoConquestFunctions(val city: City){
|
|||||||
city.isPuppet = false
|
city.isPuppet = false
|
||||||
city.cityConstructions.inProgressConstructions.clear() // undo all progress of the previous civ on units etc.
|
city.cityConstructions.inProgressConstructions.clear() // undo all progress of the previous civ on units etc.
|
||||||
city.cityStats.update()
|
city.cityStats.update()
|
||||||
val worldScreen = UncivGame.Current.worldScreen
|
GUI.setUpdateWorldOnNextRender()
|
||||||
if (!UncivGame.Current.consoleMode && worldScreen != null) {
|
|
||||||
worldScreen.shouldUpdate = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun diplomaticRepercussionsForConqueringCity(oldCiv: Civilization, conqueringCiv: Civilization) {
|
private fun diplomaticRepercussionsForConqueringCity(oldCiv: Civilization, conqueringCiv: Civilization) {
|
||||||
|
@ -2,6 +2,7 @@ package com.unciv.logic.civilization.managers
|
|||||||
|
|
||||||
import com.badlogic.gdx.math.Vector2
|
import com.badlogic.gdx.math.Vector2
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.GameInfo
|
import com.unciv.logic.GameInfo
|
||||||
import com.unciv.logic.IsPartOfGameInfoSerialization
|
import com.unciv.logic.IsPartOfGameInfoSerialization
|
||||||
@ -835,16 +836,14 @@ class AssignedQuest(val questName: String = "",
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onClickAction() {
|
fun onClickAction() {
|
||||||
val game = UncivGame.Current
|
|
||||||
|
|
||||||
when (questName) {
|
when (questName) {
|
||||||
QuestName.ClearBarbarianCamp.value -> {
|
QuestName.ClearBarbarianCamp.value -> {
|
||||||
game.resetToWorldScreen()
|
GUI.resetToWorldScreen()
|
||||||
game.worldScreen!!.mapHolder.setCenterPosition(Vector2(data1.toFloat(), data2.toFloat()), selectUnit = false)
|
GUI.getMap().setCenterPosition(Vector2(data1.toFloat(), data2.toFloat()), selectUnit = false)
|
||||||
}
|
}
|
||||||
QuestName.Route.value -> {
|
QuestName.Route.value -> {
|
||||||
game.resetToWorldScreen()
|
GUI.resetToWorldScreen()
|
||||||
game.worldScreen!!.mapHolder.setCenterPosition(gameInfo.getCivilization(assigner).getCapital()!!.location, selectUnit = false)
|
GUI.getMap().setCenterPosition(gameInfo.getCivilization(assigner).getCapital()!!.location, selectUnit = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.unciv.models.ruleset.tech
|
package com.unciv.models.ruleset.tech
|
||||||
|
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.civilization.Civilization
|
import com.unciv.logic.civilization.Civilization
|
||||||
import com.unciv.models.ruleset.Building
|
import com.unciv.models.ruleset.Building
|
||||||
@ -50,7 +51,7 @@ class Technology: RulesetObject() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val viewingCiv = UncivGame.Current.worldScreen!!.viewingCiv
|
val viewingCiv = GUI.getViewingPlayer()
|
||||||
val enabledUnits = getEnabledUnits(ruleset, viewingCiv)
|
val enabledUnits = getEnabledUnits(ruleset, viewingCiv)
|
||||||
if (enabledUnits.any()) {
|
if (enabledUnits.any()) {
|
||||||
lineList += "{Units enabled}: "
|
lineList += "{Units enabled}: "
|
||||||
@ -224,7 +225,7 @@ class Technology: RulesetObject() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val viewingCiv = UncivGame.Current.worldScreen?.viewingCiv
|
val viewingCiv = GUI.getViewingPlayer()
|
||||||
val enabledUnits = getEnabledUnits(ruleset, viewingCiv)
|
val enabledUnits = getEnabledUnits(ruleset, viewingCiv)
|
||||||
if (enabledUnits.any()) {
|
if (enabledUnits.any()) {
|
||||||
lineList += FormattedLine()
|
lineList += FormattedLine()
|
||||||
|
@ -8,6 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.actions.RepeatAction
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.map.mapunit.MapUnit
|
import com.unciv.logic.map.mapunit.MapUnit
|
||||||
import com.unciv.ui.components.extensions.addToCenter
|
import com.unciv.ui.components.extensions.addToCenter
|
||||||
@ -206,14 +207,14 @@ class UnitGroup(val unit: MapUnit, val size: Float): Group() {
|
|||||||
|
|
||||||
// Unit base icon is faded out only if out of moves
|
// Unit base icon is faded out only if out of moves
|
||||||
// Foreign unit icons are never faded!
|
// Foreign unit icons are never faded!
|
||||||
val shouldBeFaded = (unit.owner == UncivGame.Current.worldScreen?.viewingCiv?.civName
|
val shouldBeFaded = (unit.owner == GUI.getSelectedPlayer().civName
|
||||||
&& unit.currentMovement == 0f && UncivGame.Current.settings.unitIconOpacity == 1f)
|
&& unit.currentMovement == 0f && GUI.getSettings().unitIconOpacity == 1f)
|
||||||
val alpha = if (shouldBeFaded) opacity * 0.5f else opacity
|
val alpha = if (shouldBeFaded) opacity * 0.5f else opacity
|
||||||
flagIcon.color.a = alpha
|
flagIcon.color.a = alpha
|
||||||
flagBg.color.a = alpha
|
flagBg.color.a = alpha
|
||||||
flagSelection.color.a = opacity
|
flagSelection.color.a = opacity
|
||||||
|
|
||||||
if (UncivGame.Current.settings.continuousRendering) {
|
if (GUI.getSettings().continuousRendering) {
|
||||||
flagSelection.color.a = opacity
|
flagSelection.color.a = opacity
|
||||||
flagSelection.addAction(
|
flagSelection.addAction(
|
||||||
Actions.repeat(
|
Actions.repeat(
|
||||||
|
@ -9,6 +9,7 @@ import com.badlogic.gdx.scenes.scene2d.Touchable
|
|||||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions
|
import com.badlogic.gdx.scenes.scene2d.actions.Actions
|
||||||
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.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.battle.CityCombatant
|
import com.unciv.logic.battle.CityCombatant
|
||||||
import com.unciv.logic.city.City
|
import com.unciv.logic.city.City
|
||||||
@ -112,7 +113,7 @@ private class DefenceTable(city: City) : BorderedTable(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
||||||
val viewingCiv = UncivGame.Current.worldScreen!!.viewingCiv
|
val viewingCiv = GUI.getViewingPlayer()
|
||||||
|
|
||||||
borderSize = 4f
|
borderSize = 4f
|
||||||
bgColor = Color.BLACK
|
bgColor = Color.BLACK
|
||||||
@ -160,18 +161,18 @@ class AirUnitTable(city: City, numberOfUnits: Int, size: Float=14f) : BorderedTa
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class StatusTable(worldScreen: WorldScreen, city: City, iconSize: Float = 18f) : Table() {
|
private class StatusTable(city: City, iconSize: Float = 18f) : Table() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
||||||
val padBetween = 2f
|
val padBetween = 2f
|
||||||
val viewingCiv = UncivGame.Current.worldScreen!!.viewingCiv
|
val viewingCiv = GUI.getViewingPlayer()
|
||||||
|
|
||||||
if (city.civ == viewingCiv) {
|
if (city.civ == viewingCiv) {
|
||||||
if (city.isBlockaded()) {
|
if (city.isBlockaded()) {
|
||||||
val connectionImage = ImageGetter.getImage("OtherIcons/Blockade")
|
val connectionImage = ImageGetter.getImage("OtherIcons/Blockade")
|
||||||
add(connectionImage).size(iconSize)
|
add(connectionImage).size(iconSize)
|
||||||
worldScreen.displayTutorial(TutorialTrigger.CityBlockade)
|
GUI.getWorldScreen().displayTutorial(TutorialTrigger.CityBlockade)
|
||||||
} else if (!city.isCapital() && city.isConnectedToCapital()) {
|
} else if (!city.isCapital() && city.isConnectedToCapital()) {
|
||||||
val connectionImage = ImageGetter.getStatIcon("CityConnection")
|
val connectionImage = ImageGetter.getStatIcon("CityConnection")
|
||||||
add(connectionImage).size(iconSize)
|
add(connectionImage).size(iconSize)
|
||||||
@ -210,7 +211,7 @@ private class CityTable(city: City, forPopup: Boolean = false) : BorderedTable(
|
|||||||
isTransform = false
|
isTransform = false
|
||||||
touchable = Touchable.enabled
|
touchable = Touchable.enabled
|
||||||
|
|
||||||
val viewingCiv = UncivGame.Current.worldScreen!!.viewingCiv
|
val viewingCiv = GUI.getViewingPlayer()
|
||||||
|
|
||||||
bgBorderColor = when {
|
bgBorderColor = when {
|
||||||
city.civ == viewingCiv -> colorFromRGB(233, 233, 172)
|
city.civ == viewingCiv -> colorFromRGB(233, 233, 172)
|
||||||
@ -392,9 +393,6 @@ private class CityTable(city: City, forPopup: Boolean = false) : BorderedTable(
|
|||||||
|
|
||||||
class CityButton(val city: City, private val tileGroup: TileGroup): Table(BaseScreen.skin){
|
class CityButton(val city: City, private val tileGroup: TileGroup): Table(BaseScreen.skin){
|
||||||
|
|
||||||
val worldScreen = UncivGame.Current.worldScreen!!
|
|
||||||
val uncivGame = worldScreen.game
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
touchable = Touchable.disabled
|
touchable = Touchable.disabled
|
||||||
}
|
}
|
||||||
@ -431,13 +429,13 @@ class CityButton(val city: City, private val tileGroup: TileGroup): Table(BaseSc
|
|||||||
add(cityTable).row()
|
add(cityTable).row()
|
||||||
|
|
||||||
// If city state - add influence bar
|
// If city state - add influence bar
|
||||||
if (city.civ.isCityState() && city.civ.knows(worldScreen.viewingCiv)) {
|
if (city.civ.isCityState() && city.civ.knows(GUI.getViewingPlayer())) {
|
||||||
val diplomacyManager = city.civ.getDiplomacyManager(worldScreen.viewingCiv)
|
val diplomacyManager = city.civ.getDiplomacyManager(GUI.getViewingPlayer())
|
||||||
add(InfluenceTable(diplomacyManager.getInfluence(), diplomacyManager.relationshipLevel())).padTop(1f).row()
|
add(InfluenceTable(diplomacyManager.getInfluence(), diplomacyManager.relationshipLevel())).padTop(1f).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add statuses: connection, resistance, puppet, raze, WLTKD
|
// Add statuses: connection, resistance, puppet, raze, WLTKD
|
||||||
add(StatusTable(worldScreen, city)).padTop(3f)
|
add(StatusTable(city)).padTop(3f)
|
||||||
|
|
||||||
pack()
|
pack()
|
||||||
|
|
||||||
@ -481,13 +479,13 @@ class CityButton(val city: City, private val tileGroup: TileGroup): Table(BaseSc
|
|||||||
(tile.civilianUnit != null) && direction.epsilonEquals(0f, 1f) ->
|
(tile.civilianUnit != null) && direction.epsilonEquals(0f, 1f) ->
|
||||||
insertHiddenUnitMarker(HiddenUnitMarkerPosition.Left)
|
insertHiddenUnitMarker(HiddenUnitMarkerPosition.Left)
|
||||||
// detect military under the city
|
// detect military under the city
|
||||||
(tile.militaryUnit != null && !tile.hasEnemyInvisibleUnit(worldScreen.viewingCiv)) && direction.epsilonEquals(1f, 1f) ->
|
(tile.militaryUnit != null && !tile.hasEnemyInvisibleUnit(GUI.getViewingPlayer())) && direction.epsilonEquals(1f, 1f) ->
|
||||||
insertHiddenUnitMarker(HiddenUnitMarkerPosition.Center)
|
insertHiddenUnitMarker(HiddenUnitMarkerPosition.Center)
|
||||||
// detect civilian right-below the city
|
// detect civilian right-below the city
|
||||||
(tile.civilianUnit != null) && direction.epsilonEquals(1f, 0f) ->
|
(tile.civilianUnit != null) && direction.epsilonEquals(1f, 0f) ->
|
||||||
insertHiddenUnitMarker(HiddenUnitMarkerPosition.Right)
|
insertHiddenUnitMarker(HiddenUnitMarkerPosition.Right)
|
||||||
}
|
}
|
||||||
} else if (tile.militaryUnit != null && !tile.hasEnemyInvisibleUnit(worldScreen.viewingCiv)) {
|
} else if (tile.militaryUnit != null && !tile.hasEnemyInvisibleUnit(GUI.getViewingPlayer())) {
|
||||||
when {
|
when {
|
||||||
// detect military left from the city
|
// detect military left from the city
|
||||||
direction.epsilonEquals(0f, 1f) ->
|
direction.epsilonEquals(0f, 1f) ->
|
||||||
@ -518,11 +516,11 @@ class CityButton(val city: City, private val tileGroup: TileGroup): Table(BaseSc
|
|||||||
listOfHiddenUnitMarkers.add(indicator)
|
listOfHiddenUnitMarkers.add(indicator)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun belongsToViewingCiv() = city.civ == worldScreen.viewingCiv
|
private fun belongsToViewingCiv() = city.civ == GUI.getViewingPlayer()
|
||||||
|
|
||||||
private fun setButtonActions() {
|
private fun setButtonActions() {
|
||||||
|
|
||||||
val unitTable = worldScreen.bottomUnitTable
|
val unitTable = GUI.getUnitTable()
|
||||||
|
|
||||||
// So you can click anywhere on the button to go to the city
|
// So you can click anywhere on the button to go to the city
|
||||||
touchable = Touchable.childrenOnly
|
touchable = Touchable.childrenOnly
|
||||||
@ -531,12 +529,12 @@ class CityButton(val city: City, private val tileGroup: TileGroup): Table(BaseSc
|
|||||||
// clicking swings the button a little down to allow selection of units there.
|
// clicking swings the button a little down to allow selection of units there.
|
||||||
// this also allows to target selected units to move to the city tile from elsewhere.
|
// this also allows to target selected units to move to the city tile from elsewhere.
|
||||||
if (isButtonMoved) {
|
if (isButtonMoved) {
|
||||||
val viewingCiv = worldScreen.viewingCiv
|
val viewingCiv = GUI.getViewingPlayer()
|
||||||
// second tap on the button will go to the city screen
|
// second tap on the button will go to the city screen
|
||||||
// if this city belongs to you and you are not iterating though the air units
|
// if this city belongs to you and you are not iterating though the air units
|
||||||
if (uncivGame.viewEntireMapForDebug || viewingCiv.isSpectator()
|
if (GUI.isDebugMapVisible() || viewingCiv.isSpectator()
|
||||||
|| (belongsToViewingCiv() && !tileGroup.tile.airUnits.contains(unitTable.selectedUnit))) {
|
|| (belongsToViewingCiv() && !tileGroup.tile.airUnits.contains(unitTable.selectedUnit))) {
|
||||||
uncivGame.pushScreen(CityScreen(city))
|
GUI.pushScreen(CityScreen(city))
|
||||||
} else if (viewingCiv.knows(city.civ)) {
|
} else if (viewingCiv.knows(city.civ)) {
|
||||||
foreignCityInfoPopup()
|
foreignCityInfoPopup()
|
||||||
}
|
}
|
||||||
@ -584,13 +582,13 @@ class CityButton(val city: City, private val tileGroup: TileGroup): Table(BaseSc
|
|||||||
private fun foreignCityInfoPopup() {
|
private fun foreignCityInfoPopup() {
|
||||||
fun openDiplomacy() {
|
fun openDiplomacy() {
|
||||||
// If city doesn't belong to you, go directly to its owner's diplomacy screen.
|
// If city doesn't belong to you, go directly to its owner's diplomacy screen.
|
||||||
worldScreen.game.pushScreen(DiplomacyScreen(worldScreen.viewingCiv, city.civ))
|
GUI.pushScreen(DiplomacyScreen(GUI.getViewingPlayer(), city.civ))
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's nothing to display cuz no Religion - skip popup
|
// If there's nothing to display cuz no Religion - skip popup
|
||||||
if (!city.civ.gameInfo.isReligionEnabled()) return openDiplomacy()
|
if (!city.civ.gameInfo.isReligionEnabled()) return openDiplomacy()
|
||||||
|
|
||||||
val popup = Popup(worldScreen).apply {
|
val popup = Popup(GUI.getWorldScreen()).apply {
|
||||||
name = "ForeignCityInfoPopup"
|
name = "ForeignCityInfoPopup"
|
||||||
add(CityTable(city, true)).fillX().padBottom(5f).colspan(3).row()
|
add(CityTable(city, true)).fillX().padBottom(5f).colspan(3).row()
|
||||||
add(CityReligionInfoTable(city.religion, true)).colspan(3).row()
|
add(CityReligionInfoTable(city.religion, true)).colspan(3).row()
|
||||||
|
@ -11,7 +11,7 @@ import com.unciv.ui.components.extensions.darken
|
|||||||
import com.unciv.ui.screens.worldscreen.WorldScreen
|
import com.unciv.ui.screens.worldscreen.WorldScreen
|
||||||
|
|
||||||
|
|
||||||
class WorldTileGroup(internal val worldScreen: WorldScreen, tile: Tile, tileSetStrings: TileSetStrings)
|
class WorldTileGroup(tile: Tile, tileSetStrings: TileSetStrings)
|
||||||
: TileGroup(tile,tileSetStrings) {
|
: TileGroup(tile,tileSetStrings) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -50,5 +50,5 @@ class WorldTileGroup(internal val worldScreen: WorldScreen, tile: Tile, tileSetS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clone(): WorldTileGroup = WorldTileGroup(worldScreen, tile , tileSetStrings)
|
override fun clone(): WorldTileGroup = WorldTileGroup(tile , tileSetStrings)
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Cell
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Array
|
import com.badlogic.gdx.utils.Array
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.models.metadata.GameSettings
|
import com.unciv.models.metadata.GameSettings
|
||||||
import com.unciv.models.metadata.ScreenSize
|
import com.unciv.models.metadata.ScreenSize
|
||||||
@ -169,7 +170,8 @@ private fun addMaxZoomSlider(table: Table, settings: GameSettings) {
|
|||||||
) {
|
) {
|
||||||
settings.maxWorldZoomOut = it
|
settings.maxWorldZoomOut = it
|
||||||
settings.save()
|
settings.save()
|
||||||
UncivGame.Current.worldScreen?.mapHolder?.reloadMaxZoom()
|
if (GUI.isWorldLoaded())
|
||||||
|
GUI.getMap().reloadMaxZoom()
|
||||||
}
|
}
|
||||||
table.add(maxZoomSlider).pad(5f).row()
|
table.add(maxZoomSlider).pad(5f).row()
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.ui.popups.options
|
package com.unciv.ui.popups.options
|
||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.files.UncivFiles
|
import com.unciv.logic.files.UncivFiles
|
||||||
import com.unciv.logic.files.MapSaver
|
import com.unciv.logic.files.MapSaver
|
||||||
@ -19,8 +20,7 @@ fun debugTab() = Table(BaseScreen.skin).apply {
|
|||||||
defaults().pad(5f)
|
defaults().pad(5f)
|
||||||
val game = UncivGame.Current
|
val game = UncivGame.Current
|
||||||
|
|
||||||
val worldScreen = game.worldScreen
|
if (GUI.isWorldLoaded()) {
|
||||||
if (worldScreen != null) {
|
|
||||||
val simulateButton = "Simulate until turn:".toTextButton()
|
val simulateButton = "Simulate until turn:".toTextButton()
|
||||||
val simulateTextField = UncivTextField.create("Turn", game.simulateUntilTurnForDebug.toString())
|
val simulateTextField = UncivTextField.create("Turn", game.simulateUntilTurnForDebug.toString())
|
||||||
val invalidInputLabel = "This is not a valid integer!".toLabel().also { it.isVisible = false }
|
val invalidInputLabel = "This is not a valid integer!".toLabel().also { it.isVisible = false }
|
||||||
@ -32,7 +32,7 @@ fun debugTab() = Table(BaseScreen.skin).apply {
|
|||||||
}
|
}
|
||||||
game.simulateUntilTurnForDebug = simulateUntilTurns
|
game.simulateUntilTurnForDebug = simulateUntilTurns
|
||||||
invalidInputLabel.isVisible = false
|
invalidInputLabel.isVisible = false
|
||||||
worldScreen.nextTurn()
|
GUI.getWorldScreen().nextTurn()
|
||||||
}
|
}
|
||||||
add(simulateButton)
|
add(simulateButton)
|
||||||
add(simulateTextField).row()
|
add(simulateTextField).row()
|
||||||
@ -89,7 +89,7 @@ fun debugTab() = Table(BaseScreen.skin).apply {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
curGameInfo.getCurrentPlayerCivilization().cache.updateSightAndResources()
|
curGameInfo.getCurrentPlayerCivilization().cache.updateSightAndResources()
|
||||||
if (worldScreen != null) worldScreen.shouldUpdate = true
|
GUI.setUpdateWorldOnNextRender()
|
||||||
}
|
}
|
||||||
add(unlockTechsButton).colspan(2).row()
|
add(unlockTechsButton).colspan(2).row()
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ fun debugTab() = Table(BaseScreen.skin).apply {
|
|||||||
tile.changeImprovement(resource.getImprovements().first())
|
tile.changeImprovement(resource.getImprovements().first())
|
||||||
}
|
}
|
||||||
curGameInfo.getCurrentPlayerCivilization().cache.updateSightAndResources()
|
curGameInfo.getCurrentPlayerCivilization().cache.updateSightAndResources()
|
||||||
if (worldScreen != null) worldScreen.shouldUpdate = true
|
GUI.setUpdateWorldOnNextRender()
|
||||||
}
|
}
|
||||||
add(giveResourcesButton).colspan(2).row()
|
add(giveResourcesButton).colspan(2).row()
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Array
|
import com.badlogic.gdx.utils.Array
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.models.metadata.GameSettings
|
import com.unciv.models.metadata.GameSettings
|
||||||
import com.unciv.models.metadata.ScreenSize
|
import com.unciv.models.metadata.ScreenSize
|
||||||
@ -39,8 +40,9 @@ fun displayTab(
|
|||||||
if (Gdx.app.type == Application.ApplicationType.Desktop) {
|
if (Gdx.app.type == Application.ApplicationType.Desktop) {
|
||||||
addFullscreenSelectBox(this, settings, optionsPopup.selectBoxMinWidth)
|
addFullscreenSelectBox(this, settings, optionsPopup.selectBoxMinWidth)
|
||||||
optionsPopup.addCheckbox(this, "Map mouse auto-scroll", settings.mapAutoScroll, true) {
|
optionsPopup.addCheckbox(this, "Map mouse auto-scroll", settings.mapAutoScroll, true) {
|
||||||
UncivGame.Current.worldScreen?.mapHolder?.isAutoScrollEnabled = it
|
|
||||||
settings.mapAutoScroll = it
|
settings.mapAutoScroll = it
|
||||||
|
if (GUI.isWorldLoaded())
|
||||||
|
GUI.getMap().isAutoScrollEnabled = settings.mapAutoScroll
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,9 +114,9 @@ private fun addMinimapSizeSlider(table: Table, settings: GameSettings, selectBox
|
|||||||
settings.minimapSize = size
|
settings.minimapSize = size
|
||||||
}
|
}
|
||||||
settings.save()
|
settings.save()
|
||||||
val worldScreen = UncivGame.Current.getWorldScreenIfActive()
|
val worldScreen = GUI.getWorldScreenIfActive()
|
||||||
if (worldScreen != null)
|
if (worldScreen != null)
|
||||||
worldScreen.shouldUpdate = true
|
GUI.setUpdateWorldOnNextRender()
|
||||||
}
|
}
|
||||||
table.add(minimapSlider).minWidth(selectBoxMinWidth).pad(10f).row()
|
table.add(minimapSlider).minWidth(selectBoxMinWidth).pad(10f).row()
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.ui.popups.options
|
package com.unciv.ui.popups.options
|
||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.civilization.PlayerType
|
import com.unciv.logic.civilization.PlayerType
|
||||||
import com.unciv.models.metadata.GameSettings
|
import com.unciv.models.metadata.GameSettings
|
||||||
@ -21,7 +22,7 @@ fun gameplayTab(
|
|||||||
optionsPopup.addCheckbox(this, "Move units with a single tap", settings.singleTapMove) { settings.singleTapMove = it }
|
optionsPopup.addCheckbox(this, "Move units with a single tap", settings.singleTapMove) { settings.singleTapMove = it }
|
||||||
optionsPopup.addCheckbox(this, "Auto-assign city production", settings.autoAssignCityProduction, true) { shouldAutoAssignCityProduction ->
|
optionsPopup.addCheckbox(this, "Auto-assign city production", settings.autoAssignCityProduction, true) { shouldAutoAssignCityProduction ->
|
||||||
settings.autoAssignCityProduction = shouldAutoAssignCityProduction
|
settings.autoAssignCityProduction = shouldAutoAssignCityProduction
|
||||||
val worldScreen = UncivGame.Current.getWorldScreenIfActive()
|
val worldScreen = GUI.getWorldScreenIfActive()
|
||||||
if (shouldAutoAssignCityProduction && worldScreen != null &&
|
if (shouldAutoAssignCityProduction && worldScreen != null &&
|
||||||
worldScreen.viewingCiv.isCurrentPlayer() && worldScreen.viewingCiv.playerType == PlayerType.Human
|
worldScreen.viewingCiv.isCurrentPlayer() && worldScreen.viewingCiv.playerType == PlayerType.Human
|
||||||
) {
|
) {
|
||||||
|
@ -8,6 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
||||||
import com.badlogic.gdx.utils.Array
|
import com.badlogic.gdx.utils.Array
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.ui.screens.mainmenuscreen.MainMenuScreen
|
import com.unciv.ui.screens.mainmenuscreen.MainMenuScreen
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.event.EventBus
|
import com.unciv.logic.event.EventBus
|
||||||
@ -161,7 +162,7 @@ class OptionsPopup(
|
|||||||
val checkbox = text.toCheckBox(initialState) {
|
val checkbox = text.toCheckBox(initialState) {
|
||||||
action(it)
|
action(it)
|
||||||
settings.save()
|
settings.save()
|
||||||
val worldScreen = UncivGame.Current.getWorldScreenIfActive()
|
val worldScreen = GUI.getWorldScreenIfActive()
|
||||||
if (updateWorld && worldScreen != null) worldScreen.shouldUpdate = true
|
if (updateWorld && worldScreen != null) worldScreen.shouldUpdate = true
|
||||||
}
|
}
|
||||||
if (newRow) table.add(checkbox).colspan(2).left().row()
|
if (newRow) table.add(checkbox).colspan(2).left().row()
|
||||||
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
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.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.automation.Automation
|
import com.unciv.logic.automation.Automation
|
||||||
import com.unciv.logic.city.City
|
import com.unciv.logic.city.City
|
||||||
@ -53,7 +54,7 @@ class CityScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Toggles or adds/removes all state changing buttons */
|
/** Toggles or adds/removes all state changing buttons */
|
||||||
val canChangeState = UncivGame.Current.worldScreen!!.canChangeState
|
val canChangeState = GUI.isAllowedChangeState()
|
||||||
|
|
||||||
// Clockwise from the top-left
|
// Clockwise from the top-left
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.city.IConstruction
|
import com.unciv.logic.city.IConstruction
|
||||||
import com.unciv.logic.city.PerpetualConstruction
|
import com.unciv.logic.city.PerpetualConstruction
|
||||||
@ -118,7 +119,7 @@ class ConstructionInfoTable(val cityScreen: CityScreen): Table() {
|
|||||||
}
|
}
|
||||||
if (cityScreen.city.hasSoldBuildingThisTurn && !cityScreen.city.civ.gameInfo.gameParameters.godMode
|
if (cityScreen.city.hasSoldBuildingThisTurn && !cityScreen.city.civ.gameInfo.gameParameters.godMode
|
||||||
|| cityScreen.city.isPuppet
|
|| cityScreen.city.isPuppet
|
||||||
|| !UncivGame.Current.worldScreen!!.isPlayersTurn || !cityScreen.canChangeState)
|
|| !GUI.isMyTurn() || !GUI.isAllowedChangeState())
|
||||||
sellBuildingButton.disable()
|
sellBuildingButton.disable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor
|
|||||||
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.Constants
|
import com.unciv.Constants
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.ui.images.ImageGetter
|
import com.unciv.ui.images.ImageGetter
|
||||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||||
@ -82,7 +83,7 @@ class SpecialistAllocationTable(val cityScreen: CityScreen) : Table(BaseScreen.s
|
|||||||
cityInfo.cityStats.update()
|
cityInfo.cityStats.update()
|
||||||
cityScreen.update()
|
cityScreen.update()
|
||||||
}
|
}
|
||||||
if (cityInfo.population.getFreePopulation() == 0 || !UncivGame.Current.worldScreen!!.isPlayersTurn)
|
if (cityInfo.population.getFreePopulation() == 0 || !GUI.isMyTurn())
|
||||||
assignButton.clear()
|
assignButton.clear()
|
||||||
return assignButton
|
return assignButton
|
||||||
}
|
}
|
||||||
@ -99,7 +100,7 @@ class SpecialistAllocationTable(val cityScreen: CityScreen) : Table(BaseScreen.s
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (assignedSpecialists <= 0 || cityInfo.isPuppet) unassignButton.isVisible = false
|
if (assignedSpecialists <= 0 || cityInfo.isPuppet) unassignButton.isVisible = false
|
||||||
if (!UncivGame.Current.worldScreen!!.isPlayersTurn) unassignButton.clear()
|
if (!GUI.isMyTurn()) unassignButton.clear()
|
||||||
return unassignButton
|
return unassignButton
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ 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.Constants
|
import com.unciv.Constants
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.civilization.AlertType
|
import com.unciv.logic.civilization.AlertType
|
||||||
import com.unciv.logic.civilization.Civilization
|
import com.unciv.logic.civilization.Civilization
|
||||||
@ -72,7 +73,7 @@ class DiplomacyScreen(
|
|||||||
private val rightSideTable = Table()
|
private val rightSideTable = Table()
|
||||||
private val closeButton = Constants.close.toTextButton()
|
private val closeButton = Constants.close.toTextButton()
|
||||||
|
|
||||||
private fun isNotPlayersTurn() = !UncivGame.Current.worldScreen!!.canChangeState
|
private fun isNotPlayersTurn() = !GUI.isMyTurn() || !GUI.isAllowedChangeState()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val splitPane = SplitPane(leftSideScroll, rightSideTable, false, skin)
|
val splitPane = SplitPane(leftSideScroll, rightSideTable, false, skin)
|
||||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.Touchable
|
|||||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions
|
import com.badlogic.gdx.scenes.scene2d.actions.Actions
|
||||||
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.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.GameInfo
|
import com.unciv.logic.GameInfo
|
||||||
import com.unciv.logic.GameStarter
|
import com.unciv.logic.GameStarter
|
||||||
@ -219,11 +220,10 @@ class MainMenuScreen: BaseScreen(), RecreateOnResize {
|
|||||||
|
|
||||||
|
|
||||||
private fun resumeGame() {
|
private fun resumeGame() {
|
||||||
val curWorldScreen = game.worldScreen
|
if (GUI.isWorldLoaded()) {
|
||||||
if (curWorldScreen != null) {
|
GUI.resetToWorldScreen()
|
||||||
game.resetToWorldScreen()
|
GUI.getWorldScreen().popups.filterIsInstance(WorldScreenMenuPopup::class.java).forEach(Popup::close)
|
||||||
ImageGetter.ruleset = game.gameInfo!!.ruleset
|
ImageGetter.ruleset = game.gameInfo!!.ruleset
|
||||||
curWorldScreen.popups.filterIsInstance(WorldScreenMenuPopup::class.java).forEach(Popup::close)
|
|
||||||
} else {
|
} else {
|
||||||
QuickSave.autoLoadGame(this)
|
QuickSave.autoLoadGame(this)
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ enum class EmpireOverviewCategories(
|
|||||||
fun (viewingPlayer: Civilization) = (viewingPlayer.naturalWonders.isEmpty() && viewingPlayer.cities.isEmpty()).toState()),
|
fun (viewingPlayer: Civilization) = (viewingPlayer.naturalWonders.isEmpty() && viewingPlayer.cities.isEmpty()).toState()),
|
||||||
Notifications("OtherIcons/Notifications", 'N', Align.top,
|
Notifications("OtherIcons/Notifications", 'N', Align.top,
|
||||||
fun (viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?)
|
fun (viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?)
|
||||||
= NotificationsOverviewTable(worldScreen = UncivGame.Current.worldScreen!!, viewingPlayer, overviewScreen, persistedData),
|
= NotificationsOverviewTable(viewingPlayer, overviewScreen, persistedData),
|
||||||
fun (_: Civilization) = EmpireOverviewTabState.Normal)
|
fun (_: Civilization) = EmpireOverviewTabState.Normal)
|
||||||
|
|
||||||
; //must be here
|
; //must be here
|
||||||
|
@ -3,6 +3,7 @@ package com.unciv.ui.screens.overviewscreen
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
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.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.civilization.Civilization
|
import com.unciv.logic.civilization.Civilization
|
||||||
import com.unciv.logic.civilization.Notification
|
import com.unciv.logic.civilization.Notification
|
||||||
@ -16,7 +17,6 @@ import com.unciv.ui.components.extensions.toLabel
|
|||||||
import com.unciv.ui.screens.worldscreen.WorldScreen
|
import com.unciv.ui.screens.worldscreen.WorldScreen
|
||||||
|
|
||||||
class NotificationsOverviewTable(
|
class NotificationsOverviewTable(
|
||||||
val worldScreen: WorldScreen,
|
|
||||||
viewingPlayer: Civilization,
|
viewingPlayer: Civilization,
|
||||||
overviewScreen: EmpireOverviewScreen,
|
overviewScreen: EmpireOverviewScreen,
|
||||||
persistedData: EmpireOverviewTabPersistableData? = null
|
persistedData: EmpireOverviewTabPersistableData? = null
|
||||||
@ -36,12 +36,14 @@ class NotificationsOverviewTable(
|
|||||||
persistableData.scrollY = pager.getPageScrollY(index)
|
persistableData.scrollY = pager.getPageScrollY(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
val notificationLog = viewingPlayer.notificationsLog
|
|
||||||
|
|
||||||
|
private val worldScreen = GUI.getWorldScreen()
|
||||||
|
|
||||||
|
private val notificationLog = viewingPlayer.notificationsLog
|
||||||
private val notificationTable = Table(BaseScreen.skin)
|
private val notificationTable = Table(BaseScreen.skin)
|
||||||
|
|
||||||
val scaleFactor = 0.3f
|
private val scaleFactor = 0.3f
|
||||||
val inverseScaleFactor = 1f / scaleFactor
|
private val inverseScaleFactor = 1f / scaleFactor
|
||||||
private val maxWidthOfStage = 0.333f
|
private val maxWidthOfStage = 0.333f
|
||||||
private val maxEntryWidth = worldScreen.stage.width * maxWidthOfStage * inverseScaleFactor
|
private val maxEntryWidth = worldScreen.stage.width * maxWidthOfStage * inverseScaleFactor
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.unciv.ui.screens.overviewscreen
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.civilization.Civilization
|
import com.unciv.logic.civilization.Civilization
|
||||||
import com.unciv.models.ruleset.ModOptionsConstants
|
import com.unciv.models.ruleset.ModOptionsConstants
|
||||||
@ -138,7 +139,7 @@ class StatsOverviewTab(
|
|||||||
for (city in viewingPlayer.cities) { city.cityStats.update() }
|
for (city in viewingPlayer.cities) { city.cityStats.update() }
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
slider.isDisabled = !UncivGame.Current.worldScreen!!.canChangeState
|
slider.isDisabled = !GUI.isAllowedChangeState()
|
||||||
|
|
||||||
sliderTable.add(slider).padTop(15f)
|
sliderTable.add(slider).padTop(15f)
|
||||||
add(sliderTable).colspan(2)
|
add(sliderTable).colspan(2)
|
||||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.Group
|
|||||||
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.Constants
|
import com.unciv.Constants
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.logic.civilization.Civilization
|
import com.unciv.logic.civilization.Civilization
|
||||||
import com.unciv.logic.map.mapunit.MapUnit
|
import com.unciv.logic.map.mapunit.MapUnit
|
||||||
import com.unciv.logic.map.tile.Tile
|
import com.unciv.logic.map.tile.Tile
|
||||||
@ -80,9 +81,8 @@ class UnitOverviewTab(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun showWorldScreenAt(position: Vector2, unit: MapUnit?) {
|
private fun showWorldScreenAt(position: Vector2, unit: MapUnit?) {
|
||||||
val game = overviewScreen.game
|
GUI.resetToWorldScreen()
|
||||||
game.resetToWorldScreen()
|
GUI.getMap().setCenterPosition(position, forceSelectUnit = unit)
|
||||||
game.worldScreen!!.mapHolder.setCenterPosition(position, forceSelectUnit = unit)
|
|
||||||
}
|
}
|
||||||
private fun showWorldScreenAt(unit: MapUnit) = showWorldScreenAt(unit.currentTile.position, unit)
|
private fun showWorldScreenAt(unit: MapUnit) = showWorldScreenAt(unit.currentTile.position, unit)
|
||||||
private fun showWorldScreenAt(tile: Tile) = showWorldScreenAt(tile.position, null)
|
private fun showWorldScreenAt(tile: Tile) = showWorldScreenAt(tile.position, null)
|
||||||
@ -216,7 +216,7 @@ class UnitOverviewTab(
|
|||||||
if (unit.promotions.canBePromoted())
|
if (unit.promotions.canBePromoted())
|
||||||
promotionsTable.add(
|
promotionsTable.add(
|
||||||
ImageGetter.getImage("OtherIcons/Star").apply {
|
ImageGetter.getImage("OtherIcons/Star").apply {
|
||||||
color = if (game.worldScreen!!.canChangeState && unit.currentMovement > 0f && unit.attacksThisTurn == 0)
|
color = if (GUI.isAllowedChangeState() && unit.currentMovement > 0f && unit.attacksThisTurn == 0)
|
||||||
Color.GOLDENROD
|
Color.GOLDENROD
|
||||||
else Color.GOLDENROD.darken(0.25f)
|
else Color.GOLDENROD.darken(0.25f)
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.SplitPane
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
|
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.ui.images.IconTextButton
|
import com.unciv.ui.images.IconTextButton
|
||||||
import com.unciv.ui.components.AutoScrollPane
|
import com.unciv.ui.components.AutoScrollPane
|
||||||
@ -73,7 +74,7 @@ class PickerPane(
|
|||||||
|
|
||||||
/** Sets the text of the [rightSideButton] and enables it if it's the player's turn */
|
/** Sets the text of the [rightSideButton] and enables it if it's the player's turn */
|
||||||
fun pick(rightButtonText: String) {
|
fun pick(rightButtonText: String) {
|
||||||
if (UncivGame.Current.worldScreen!!.isPlayersTurn) rightSideButton.enable()
|
if (GUI.isMyTurn()) rightSideButton.enable()
|
||||||
rightSideButton.setText(rightButtonText)
|
rightSideButton.setText(rightButtonText)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Cell
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
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.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.civilization.Civilization
|
import com.unciv.logic.civilization.Civilization
|
||||||
import com.unciv.models.TutorialTrigger
|
import com.unciv.models.TutorialTrigger
|
||||||
@ -51,16 +52,13 @@ private object PolicyColors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Policy.isAdopted() : Boolean {
|
fun Policy.isAdopted() : Boolean {
|
||||||
val worldScreen = UncivGame.Current.worldScreen ?: return false
|
return GUI.getSelectedPlayer().policies.isAdopted(this.name)
|
||||||
val viewingCiv = worldScreen.selectedCiv
|
|
||||||
return viewingCiv.policies.isAdopted(this.name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Policy.isPickable() : Boolean {
|
fun Policy.isPickable() : Boolean {
|
||||||
val worldScreen = UncivGame.Current.worldScreen ?: return false
|
val viewingCiv = GUI.getViewingPlayer()
|
||||||
val viewingCiv = worldScreen.viewingCiv
|
val selectedCiv = GUI.getSelectedPlayer()
|
||||||
val selectedCiv = worldScreen.selectedCiv
|
if (!GUI.isMyTurn()
|
||||||
if (!worldScreen.isPlayersTurn
|
|
||||||
|| viewingCiv.isDefeated()
|
|| viewingCiv.isDefeated()
|
||||||
|| selectedCiv.policies.isAdopted(this.name)
|
|| selectedCiv.policies.isAdopted(this.name)
|
||||||
|| this.policyBranchType == PolicyBranchType.BranchComplete
|
|| this.policyBranchType == PolicyBranchType.BranchComplete
|
||||||
@ -109,13 +107,10 @@ class PolicyButton(val policy: Policy, size: Float = 30f) : BorderedTable(
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateState() {
|
private fun updateState() {
|
||||||
|
|
||||||
val worldScreen = UncivGame.Current.worldScreen ?: return
|
|
||||||
val viewingCiv = worldScreen.selectedCiv
|
|
||||||
|
|
||||||
val isPickable = policy.isPickable()
|
val isPickable = policy.isPickable()
|
||||||
val isAdopted = viewingCiv.policies.isAdopted(policy.name)
|
val isAdopted = GUI.getSelectedPlayer().policies.isAdopted(policy.name)
|
||||||
|
|
||||||
when {
|
when {
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Cell
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
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.GUI
|
||||||
import com.unciv.logic.map.mapunit.MapUnit
|
import com.unciv.logic.map.mapunit.MapUnit
|
||||||
import com.unciv.models.TutorialTrigger
|
import com.unciv.models.TutorialTrigger
|
||||||
import com.unciv.models.UncivSound
|
import com.unciv.models.UncivSound
|
||||||
@ -161,7 +162,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen(), RecreateOnResiz
|
|||||||
}
|
}
|
||||||
|
|
||||||
val canBePromoted = unit.promotions.canBePromoted()
|
val canBePromoted = unit.promotions.canBePromoted()
|
||||||
val canChangeState = game.worldScreen!!.canChangeState
|
val canChangeState = GUI.isAllowedChangeState()
|
||||||
val canPromoteNow = canBePromoted && canChangeState
|
val canPromoteNow = canBePromoted && canChangeState
|
||||||
&& unit.currentMovement > 0 && unit.attacksThisTurn == 0
|
&& unit.currentMovement > 0 && unit.attacksThisTurn == 0
|
||||||
rightSideButton.isEnabled = canPromoteNow
|
rightSideButton.isEnabled = canPromoteNow
|
||||||
@ -202,7 +203,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen(), RecreateOnResiz
|
|||||||
val availablePromotions = unit.promotions.getAvailablePromotions()
|
val availablePromotions = unit.promotions.getAvailablePromotions()
|
||||||
|
|
||||||
val canBePromoted = unit.promotions.canBePromoted()
|
val canBePromoted = unit.promotions.canBePromoted()
|
||||||
val canChangeState = game.worldScreen!!.canChangeState
|
val canChangeState = GUI.isAllowedChangeState()
|
||||||
|
|
||||||
// Create nodes
|
// Create nodes
|
||||||
// Pass 1 - create nodes for all promotions
|
// Pass 1 - create nodes for all promotions
|
||||||
|
@ -8,6 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label
|
|||||||
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.Constants
|
import com.unciv.Constants
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.civilization.Civilization
|
import com.unciv.logic.civilization.Civilization
|
||||||
import com.unciv.logic.civilization.managers.TechManager
|
import com.unciv.logic.civilization.managers.TechManager
|
||||||
@ -398,7 +399,7 @@ class TechPickerScreen(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UncivGame.Current.worldScreen!!.canChangeState) {
|
if (!GUI.isAllowedChangeState()) {
|
||||||
rightSideButton.disable()
|
rightSideButton.disable()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ class WorldMapHolder(
|
|||||||
|
|
||||||
internal fun addTiles() {
|
internal fun addTiles() {
|
||||||
val tileSetStrings = TileSetStrings()
|
val tileSetStrings = TileSetStrings()
|
||||||
val tileGroupsNew = tileMap.values.map { WorldTileGroup(worldScreen, it, tileSetStrings) }
|
val tileGroupsNew = tileMap.values.map { WorldTileGroup(it, tileSetStrings) }
|
||||||
tileGroupMap = TileGroupMap(this, tileGroupsNew, continuousScrollingX)
|
tileGroupMap = TileGroupMap(this, tileGroupsNew, continuousScrollingX)
|
||||||
|
|
||||||
for (tileGroup in tileGroupsNew) {
|
for (tileGroup in tileGroupsNew) {
|
||||||
|
@ -3,6 +3,7 @@ package com.unciv.ui.screens.worldscreen.minimap
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.ui.images.IconCircleGroup
|
import com.unciv.ui.images.IconCircleGroup
|
||||||
import com.unciv.ui.components.extensions.onClick
|
import com.unciv.ui.components.extensions.onClick
|
||||||
@ -42,7 +43,7 @@ class MapOverlayToggleButton(
|
|||||||
/** Toggle overlay. Called on click. */
|
/** Toggle overlay. Called on click. */
|
||||||
fun toggle() {
|
fun toggle() {
|
||||||
setter(!getter())
|
setter(!getter())
|
||||||
UncivGame.Current.worldScreen!!.shouldUpdate = true
|
GUI.setUpdateWorldOnNextRender()
|
||||||
// Setting worldScreen.shouldUpdate implicitly causes this.update() to be called by the WorldScreen on the next update.
|
// Setting worldScreen.shouldUpdate implicitly causes this.update() to be called by the WorldScreen on the next update.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.ui.screens.worldscreen.unit.actions
|
package com.unciv.ui.screens.worldscreen.unit.actions
|
||||||
|
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.automation.unit.UnitAutomation
|
import com.unciv.logic.automation.unit.UnitAutomation
|
||||||
import com.unciv.logic.automation.unit.WorkerAutomation
|
import com.unciv.logic.automation.unit.WorkerAutomation
|
||||||
@ -30,14 +31,13 @@ import com.unciv.ui.screens.worldscreen.unit.UnitTable
|
|||||||
|
|
||||||
object UnitActions {
|
object UnitActions {
|
||||||
|
|
||||||
fun getUnitActions(unit: MapUnit, worldScreen: WorldScreen): List<UnitAction> {
|
fun getUnitActions(unit: MapUnit): List<UnitAction> {
|
||||||
return if (unit.showAdditionalActions) getAdditionalActions(unit, worldScreen)
|
return if (unit.showAdditionalActions) getAdditionalActions(unit)
|
||||||
else getNormalActions(unit, worldScreen)
|
else getNormalActions(unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getNormalActions(unit: MapUnit, worldScreen: WorldScreen): List<UnitAction> {
|
private fun getNormalActions(unit: MapUnit): List<UnitAction> {
|
||||||
val tile = unit.getTile()
|
val tile = unit.getTile()
|
||||||
val unitTable = worldScreen.bottomUnitTable
|
|
||||||
val actionList = ArrayList<UnitAction>()
|
val actionList = ArrayList<UnitAction>()
|
||||||
|
|
||||||
if (unit.isMoving())
|
if (unit.isMoving())
|
||||||
@ -53,12 +53,12 @@ object UnitActions {
|
|||||||
addPromoteAction(unit, actionList)
|
addPromoteAction(unit, actionList)
|
||||||
UnitActionsUpgrade.addUnitUpgradeAction(unit, actionList)
|
UnitActionsUpgrade.addUnitUpgradeAction(unit, actionList)
|
||||||
addTransformAction(unit, actionList)
|
addTransformAction(unit, actionList)
|
||||||
UnitActionsPillage.addPillageAction(unit, actionList, worldScreen)
|
UnitActionsPillage.addPillageAction(unit, actionList)
|
||||||
addParadropAction(unit, actionList)
|
addParadropAction(unit, actionList)
|
||||||
addAirSweepAction(unit, actionList)
|
addAirSweepAction(unit, actionList)
|
||||||
addSetupAction(unit, actionList)
|
addSetupAction(unit, actionList)
|
||||||
addFoundCityAction(unit, actionList, tile)
|
addFoundCityAction(unit, actionList, tile)
|
||||||
addBuildingImprovementsAction(unit, actionList, tile, worldScreen)
|
addBuildingImprovementsAction(unit, actionList, tile)
|
||||||
addRepairAction(unit, actionList)
|
addRepairAction(unit, actionList)
|
||||||
addCreateWaterImprovements(unit, actionList)
|
addCreateWaterImprovements(unit, actionList)
|
||||||
UnitActionsGreatPerson.addGreatPersonActions(unit, actionList, tile)
|
UnitActionsGreatPerson.addGreatPersonActions(unit, actionList, tile)
|
||||||
@ -71,32 +71,32 @@ object UnitActions {
|
|||||||
addTriggerUniqueActions(unit, actionList)
|
addTriggerUniqueActions(unit, actionList)
|
||||||
addAddInCapitalAction(unit, actionList, tile)
|
addAddInCapitalAction(unit, actionList, tile)
|
||||||
|
|
||||||
addWaitAction(unit, actionList, worldScreen)
|
addWaitAction(unit, actionList)
|
||||||
|
|
||||||
addToggleActionsAction(unit, actionList, unitTable)
|
addToggleActionsAction(unit, actionList)
|
||||||
|
|
||||||
return actionList
|
return actionList
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAdditionalActions(unit: MapUnit, worldScreen: WorldScreen): List<UnitAction> {
|
private fun getAdditionalActions(unit: MapUnit): List<UnitAction> {
|
||||||
val tile = unit.getTile()
|
val tile = unit.getTile()
|
||||||
val unitTable = worldScreen.bottomUnitTable
|
|
||||||
val actionList = ArrayList<UnitAction>()
|
val actionList = ArrayList<UnitAction>()
|
||||||
|
|
||||||
addSleepActions(actionList, unit, true)
|
addSleepActions(actionList, unit, true)
|
||||||
addFortifyActions(actionList, unit, true)
|
addFortifyActions(actionList, unit, true)
|
||||||
|
|
||||||
addSwapAction(unit, actionList, worldScreen)
|
addSwapAction(unit, actionList)
|
||||||
addDisbandAction(actionList, unit, worldScreen)
|
addDisbandAction(actionList, unit)
|
||||||
addGiftAction(unit, actionList, tile)
|
addGiftAction(unit, actionList, tile)
|
||||||
|
|
||||||
|
|
||||||
addToggleActionsAction(unit, actionList, unitTable)
|
addToggleActionsAction(unit, actionList)
|
||||||
|
|
||||||
return actionList
|
return actionList
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addSwapAction(unit: MapUnit, actionList: ArrayList<UnitAction>, worldScreen: WorldScreen) {
|
private fun addSwapAction(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
||||||
|
val worldScreen = GUI.getWorldScreen()
|
||||||
// Air units cannot swap
|
// Air units cannot swap
|
||||||
if (unit.baseUnit.movesLikeAirUnits()) return
|
if (unit.baseUnit.movesLikeAirUnits()) return
|
||||||
// Disable unit swapping if multiple units are selected. It would make little sense.
|
// Disable unit swapping if multiple units are selected. It would make little sense.
|
||||||
@ -118,16 +118,18 @@ object UnitActions {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addDisbandAction(actionList: ArrayList<UnitAction>, unit: MapUnit, worldScreen: WorldScreen) {
|
private fun addDisbandAction(actionList: ArrayList<UnitAction>, unit: MapUnit) {
|
||||||
|
val worldScreen = GUI.getWorldScreen()
|
||||||
actionList += UnitAction(type = UnitActionType.DisbandUnit, action = {
|
actionList += UnitAction(type = UnitActionType.DisbandUnit, action = {
|
||||||
if (!worldScreen.hasOpenPopups()) {
|
if (!worldScreen.hasOpenPopups()) {
|
||||||
val disbandText = if (unit.currentTile.getOwner() == unit.civ)
|
val disbandText = if (unit.currentTile.getOwner() == unit.civ)
|
||||||
"Disband this unit for [${unit.baseUnit.getDisbandGold(unit.civ)}] gold?".tr()
|
"Disband this unit for [${unit.baseUnit.getDisbandGold(unit.civ)}] gold?".tr()
|
||||||
else "Do you really want to disband this unit?".tr()
|
else "Do you really want to disband this unit?".tr()
|
||||||
ConfirmPopup(UncivGame.Current.worldScreen!!, disbandText, "Disband unit") {
|
ConfirmPopup(worldScreen, disbandText, "Disband unit") {
|
||||||
unit.disband()
|
unit.disband()
|
||||||
worldScreen.shouldUpdate = true
|
GUI.setUpdateWorldOnNextRender()
|
||||||
if (UncivGame.Current.settings.autoUnitCycle) worldScreen.switchToNextUnit()
|
if (GUI.getSettings().autoUnitCycle)
|
||||||
|
worldScreen.switchToNextUnit()
|
||||||
}.open()
|
}.open()
|
||||||
}
|
}
|
||||||
}.takeIf { unit.currentMovement > 0 })
|
}.takeIf { unit.currentMovement > 0 })
|
||||||
@ -189,7 +191,7 @@ object UnitActions {
|
|||||||
tile.changeImprovement("City center")
|
tile.changeImprovement("City center")
|
||||||
tile.removeRoad()
|
tile.removeRoad()
|
||||||
unit.destroy()
|
unit.destroy()
|
||||||
UncivGame.Current.worldScreen!!.shouldUpdate = true
|
GUI.setUpdateWorldOnNextRender()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit.civ.playerType == PlayerType.AI)
|
if (unit.civ.playerType == PlayerType.AI)
|
||||||
@ -206,7 +208,7 @@ object UnitActions {
|
|||||||
else {
|
else {
|
||||||
// ask if we would be breaking a promise
|
// ask if we would be breaking a promise
|
||||||
val text = "Do you want to break your promise to [$leaders]?"
|
val text = "Do you want to break your promise to [$leaders]?"
|
||||||
ConfirmPopup(UncivGame.Current.worldScreen!!, text, "Break promise", action = foundAction).open(force = true)
|
ConfirmPopup(GUI.getWorldScreen(), text, "Break promise", action = foundAction).open(force = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -360,9 +362,7 @@ object UnitActions {
|
|||||||
private fun addBuildingImprovementsAction(
|
private fun addBuildingImprovementsAction(
|
||||||
unit: MapUnit,
|
unit: MapUnit,
|
||||||
actionList: ArrayList<UnitAction>,
|
actionList: ArrayList<UnitAction>,
|
||||||
tile: Tile,
|
tile: Tile) {
|
||||||
worldScreen: WorldScreen
|
|
||||||
) {
|
|
||||||
if (!unit.cache.hasUniqueToBuildImprovements) return
|
if (!unit.cache.hasUniqueToBuildImprovements) return
|
||||||
if (unit.isEmbarked()) return
|
if (unit.isEmbarked()) return
|
||||||
|
|
||||||
@ -376,7 +376,10 @@ object UnitActions {
|
|||||||
actionList += UnitAction(UnitActionType.ConstructImprovement,
|
actionList += UnitAction(UnitActionType.ConstructImprovement,
|
||||||
isCurrentAction = unit.currentTile.hasImprovementInProgress(),
|
isCurrentAction = unit.currentTile.hasImprovementInProgress(),
|
||||||
action = {
|
action = {
|
||||||
worldScreen.game.pushScreen(ImprovementPickerScreen(tile, unit) { if (UncivGame.Current.settings.autoUnitCycle) worldScreen.switchToNextUnit() })
|
GUI.pushScreen(ImprovementPickerScreen(tile, unit) {
|
||||||
|
if (GUI.getSettings().autoUnitCycle)
|
||||||
|
GUI.getWorldScreen().switchToNextUnit()
|
||||||
|
})
|
||||||
}.takeIf { couldConstruct }
|
}.takeIf { couldConstruct }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -628,7 +631,7 @@ object UnitActions {
|
|||||||
unit.destroy() // City states don't get GPs
|
unit.destroy() // City states don't get GPs
|
||||||
else
|
else
|
||||||
unit.gift(recipient)
|
unit.gift(recipient)
|
||||||
UncivGame.Current.worldScreen!!.shouldUpdate = true
|
GUI.setUpdateWorldOnNextRender()
|
||||||
}
|
}
|
||||||
|
|
||||||
return UnitAction(UnitActionType.GiftUnit, action = giftAction)
|
return UnitAction(UnitActionType.GiftUnit, action = giftAction)
|
||||||
@ -645,23 +648,23 @@ object UnitActions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addWaitAction(unit: MapUnit, actionList: ArrayList<UnitAction>, worldScreen: WorldScreen) {
|
private fun addWaitAction(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
||||||
actionList += UnitAction(
|
actionList += UnitAction(
|
||||||
type = UnitActionType.Wait,
|
type = UnitActionType.Wait,
|
||||||
action = {
|
action = {
|
||||||
unit.due = false
|
unit.due = false
|
||||||
worldScreen.switchToNextUnit()
|
GUI.getWorldScreen().switchToNextUnit()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addToggleActionsAction(unit: MapUnit, actionList: ArrayList<UnitAction>, unitTable: UnitTable) {
|
private fun addToggleActionsAction(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
||||||
actionList += UnitAction(
|
actionList += UnitAction(
|
||||||
type = if (unit.showAdditionalActions) UnitActionType.HideAdditionalActions
|
type = if (unit.showAdditionalActions) UnitActionType.HideAdditionalActions
|
||||||
else UnitActionType.ShowAdditionalActions,
|
else UnitActionType.ShowAdditionalActions,
|
||||||
action = {
|
action = {
|
||||||
unit.showAdditionalActions = !unit.showAdditionalActions
|
unit.showAdditionalActions = !unit.showAdditionalActions
|
||||||
unitTable.update()
|
GUI.getWorldScreen().bottomUnitTable.update()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.unciv.ui.screens.worldscreen.unit.actions
|
package com.unciv.ui.screens.worldscreen.unit.actions
|
||||||
|
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.civilization.NotificationCategory
|
import com.unciv.logic.civilization.NotificationCategory
|
||||||
import com.unciv.logic.civilization.NotificationIcon
|
import com.unciv.logic.civilization.NotificationIcon
|
||||||
@ -17,7 +18,7 @@ import kotlin.random.Random
|
|||||||
|
|
||||||
object UnitActionsPillage {
|
object UnitActionsPillage {
|
||||||
|
|
||||||
fun addPillageAction(unit: MapUnit, actionList: ArrayList<UnitAction>, worldScreen: WorldScreen) {
|
fun addPillageAction(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
||||||
val pillageAction = getPillageAction(unit)
|
val pillageAction = getPillageAction(unit)
|
||||||
?: return
|
?: return
|
||||||
if (pillageAction.action == null)
|
if (pillageAction.action == null)
|
||||||
@ -27,16 +28,16 @@ object UnitActionsPillage {
|
|||||||
action = null)
|
action = null)
|
||||||
else actionList += UnitAction(type = UnitActionType.Pillage,
|
else actionList += UnitAction(type = UnitActionType.Pillage,
|
||||||
title = "${UnitActionType.Pillage} [${unit.currentTile.getImprovementToPillageName()!!}]") {
|
title = "${UnitActionType.Pillage} [${unit.currentTile.getImprovementToPillageName()!!}]") {
|
||||||
if (!worldScreen.hasOpenPopups()) {
|
if (!GUI.getWorldScreen().hasOpenPopups()) {
|
||||||
val pillageText = "Are you sure you want to pillage this [${unit.currentTile.getImprovementToPillageName()!!}]?"
|
val pillageText = "Are you sure you want to pillage this [${unit.currentTile.getImprovementToPillageName()!!}]?"
|
||||||
ConfirmPopup(
|
ConfirmPopup(
|
||||||
UncivGame.Current.worldScreen!!,
|
GUI.getWorldScreen(),
|
||||||
pillageText,
|
pillageText,
|
||||||
"Pillage",
|
"Pillage",
|
||||||
true
|
true
|
||||||
) {
|
) {
|
||||||
(pillageAction.action)()
|
(pillageAction.action)()
|
||||||
worldScreen.shouldUpdate = true
|
GUI.setUpdateWorldOnNextRender()
|
||||||
}.open()
|
}.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.unciv.ui.screens.worldscreen.unit.actions
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Button
|
import com.badlogic.gdx.scenes.scene2d.ui.Button
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.map.mapunit.MapUnit
|
import com.unciv.logic.map.mapunit.MapUnit
|
||||||
import com.unciv.models.UnitAction
|
import com.unciv.models.UnitAction
|
||||||
@ -21,7 +22,7 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table() {
|
|||||||
clear()
|
clear()
|
||||||
if (unit == null) return
|
if (unit == null) return
|
||||||
if (!worldScreen.canChangeState) return // No actions when it's not your turn or spectator!
|
if (!worldScreen.canChangeState) return // No actions when it's not your turn or spectator!
|
||||||
for (button in UnitActions.getUnitActions(unit, worldScreen)
|
for (button in UnitActions.getUnitActions(unit)
|
||||||
.map { getUnitActionButton(unit, it) })
|
.map { getUnitActionButton(unit, it) })
|
||||||
add(button).left().padBottom(2f).row()
|
add(button).left().padBottom(2f).row()
|
||||||
pack()
|
pack()
|
||||||
@ -46,7 +47,7 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table() {
|
|||||||
} else {
|
} else {
|
||||||
actionButton.onActivation(unitAction.uncivSound) {
|
actionButton.onActivation(unitAction.uncivSound) {
|
||||||
unitAction.action.invoke()
|
unitAction.action.invoke()
|
||||||
UncivGame.Current.worldScreen!!.shouldUpdate = true
|
GUI.setUpdateWorldOnNextRender()
|
||||||
// We keep the unit action/selection overlay from the previous unit open even when already selecting another unit
|
// We keep the unit action/selection overlay from the previous unit open even when already selecting another unit
|
||||||
// so you need less clicks/touches to do things, but once we do an action with the new unit, we want to close this
|
// so you need less clicks/touches to do things, but once we do an action with the new unit, we want to close this
|
||||||
// overlay, since the user definitely wants to interact with the new unit.
|
// overlay, since the user definitely wants to interact with the new unit.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user