diff --git a/android/build.gradle b/android/build.gradle index 6337248330..349a5b7194 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,8 +21,8 @@ android { applicationId "com.unciv.app" minSdkVersion 14 targetSdkVersion 29 - versionCode 304 - versionName "3.1.2" + versionCode 305 + versionName "3.1.3" } // Had to add this crap for Travis to build, it wanted to sign the app diff --git a/core/src/com/unciv/models/gamebasics/tech/Technology.kt b/core/src/com/unciv/models/gamebasics/tech/Technology.kt index ca83bbaacb..72db1b76cc 100644 --- a/core/src/com/unciv/models/gamebasics/tech/Technology.kt +++ b/core/src/com/unciv/models/gamebasics/tech/Technology.kt @@ -31,10 +31,10 @@ class Technology : ICivilopedia { lineList += impimpString.tr() } - val currentPlayerCiv = UnCivGame.Current.gameInfo.currentPlayer + val viewingCiv = UnCivGame.Current.worldScreen.viewingCiv var enabledUnits = GameBasics.Units.values.filter { it.requiredTech == name && - (it.uniqueTo == null || it.uniqueTo == currentPlayerCiv) + (it.uniqueTo == null || it.uniqueTo == viewingCiv.civName) } val replacedUnits = enabledUnits.mapNotNull { it.replaces } enabledUnits = enabledUnits.filter { it.name !in replacedUnits } @@ -46,7 +46,7 @@ class Technology : ICivilopedia { var enabledBuildings = GameBasics.Buildings.values.filter { it.requiredTech == name && - (it.uniqueTo == null || it.uniqueTo == currentPlayerCiv) + (it.uniqueTo == null || it.uniqueTo == viewingCiv.civName) } val replacedBuildings = enabledBuildings.mapNotNull { it.replaces } enabledBuildings = enabledBuildings.filter { it.name !in replacedBuildings } diff --git a/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt b/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt index ca2f3d2c96..62ddeb0d78 100644 --- a/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt +++ b/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt @@ -38,7 +38,7 @@ class NewGameScreen: PickerScreen(){ rightSideButton.onClick { if (newGameParameters.players.none { it.playerType == PlayerType.Human }) { val noHumanPlayersPopup = PopupTable(this) - noHumanPlayersPopup.addGoodSizedLabel("No human players selected!").row() + noHumanPlayersPopup.addGoodSizedLabel("No human players selected!".tr()).row() noHumanPlayersPopup.addCloseButton() noHumanPlayersPopup.open() return@onClick @@ -50,7 +50,7 @@ class NewGameScreen: PickerScreen(){ UUID.fromString(player.playerId) } catch (ex: Exception) { val invalidPlayerIdPopup = PopupTable(this) - invalidPlayerIdPopup.addGoodSizedLabel("Invalid player ID!").row() + invalidPlayerIdPopup.addGoodSizedLabel("Invalid player ID!".tr()).row() invalidPlayerIdPopup.addCloseButton() invalidPlayerIdPopup.open() return@onClick diff --git a/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt index 75d4c3907b..4f8f27bf2f 100644 --- a/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt @@ -2,7 +2,6 @@ package com.unciv.ui.pickerscreens import com.badlogic.gdx.Gdx import com.badlogic.gdx.graphics.Color -import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane import com.unciv.Constants import com.unciv.UnCivGame @@ -13,7 +12,6 @@ import com.unciv.models.gamebasics.tech.Technology import com.unciv.models.gamebasics.tr import com.unciv.ui.utils.* import java.util.* -import kotlin.collections.HashSet class TechPickerScreen(internal val civInfo: CivilizationInfo, switchfromWorldScreen: Boolean = true, centerOnTech: Technology? = null) : PickerScreen() { @@ -71,7 +69,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, switchfromWorldSc topTable.add() // empty cell else { - val techButton = TechButton(tech.name,civTech,false) + val techButton = TechButton(tech.name, civTech,false) techNameToButton[tech.name] = techButton techButton.onClick { selectTechnology(tech, false, switchfromWorldScreen) } diff --git a/core/src/com/unciv/ui/tilegroups/CityButton.kt b/core/src/com/unciv/ui/tilegroups/CityButton.kt index 7514d4ef0e..ec8407a485 100644 --- a/core/src/com/unciv/ui/tilegroups/CityButton.kt +++ b/core/src/com/unciv/ui/tilegroups/CityButton.kt @@ -57,10 +57,12 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski add(airUnitTable).row() } + private fun belongsToViewingCiv() = city.civInfo == UnCivGame.Current.worldScreen.viewingCiv + private fun setButtonActions() { val unitTable = tileGroup.worldScreen.bottomBar.unitTable - if (UnCivGame.Current.viewEntireMapForDebug || city.civInfo.isCurrentPlayer()) { + if (UnCivGame.Current.viewEntireMapForDebug || belongsToViewingCiv()) { // So you can click anywhere on the button to go to the city touchable = Touchable.childrenOnly @@ -119,7 +121,7 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski val starImage = ImageGetter.getImage("OtherIcons/Star").apply { color = Color.LIGHT_GRAY } iconTable.add(starImage).size(20f).pad(2f).padLeft(10f) } - } else if (city.civInfo.isCurrentPlayer() && city.isConnectedToCapital()) { + } else if (belongsToViewingCiv() && city.isConnectedToCapital()) { val connectionImage = ImageGetter.getStatIcon("CityConnection") connectionImage.color = secondaryColor iconTable.add(connectionImage).size(20f).pad(2f).padLeft(5f) @@ -131,7 +133,7 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski iconTable.add(label).pad(10f) // sufficient horizontal padding .fillY() // provide full-height clicking area - if (UnCivGame.Current.viewEntireMapForDebug || city.civInfo.isCurrentPlayer()) + if (UnCivGame.Current.viewEntireMapForDebug || belongsToViewingCiv()) iconTable.add(getConstructionGroup(city.cityConstructions)).padRight(10f).padLeft(10f) else if (city.civInfo.isMajorCiv()) { val nationIcon = ImageGetter.getNationIcon(city.civInfo.nation.name) diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index 5552682dd2..585e877574 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -86,7 +86,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) isTransform=false // performance helper - nothing here is rotated or scaled } - + //region init functions private fun addCircleImage() { circleImage.width = 50f circleImage.height = 50f @@ -112,6 +112,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) crosshairImage.color = Color.WHITE.cpy().apply { a = 0.5f } circleCrosshairFogLayerGroup.addActor(crosshairImage) } + //endregion fun showCrosshair() { crosshairImage.isVisible = true @@ -430,7 +431,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) val shouldDisplayResource = if(showEntireMap) tileInfo.resource!=null else showResourcesAndImprovements - && tileInfo.hasViewableResource(tileInfo.tileMap.gameInfo.getCurrentPlayerCivilization()) + && tileInfo.hasViewableResource(UnCivGame.Current.worldScreen.viewingCiv) resourceImage!!.isVisible = shouldDisplayResource } } @@ -453,7 +454,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) // Instead of fading out the entire unit with its background, we just fade out its central icon, // that way it remains much more visible on the map - if (!unit.isIdle() && unit.civInfo.isPlayerCivilization()) + if (!unit.isIdle() && unit.civInfo == UnCivGame.Current.worldScreen.viewingCiv) newImage.unitBaseImage.color.a = 0.5f } return newImage diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index e5e7233e21..b1dcb78d6f 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -172,7 +172,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { topBar.update(viewingCiv) - updateTechButton(viewingCiv) + updateTechButton() techPolicyandVictoryHolder.pack() techPolicyandVictoryHolder.setPosition(10f, topBar.y - techPolicyandVictoryHolder.height - 5f) updateDiplomacyButton(viewingCiv) @@ -242,15 +242,15 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { diplomacyButtonWrapper.y = techPolicyandVictoryHolder.y -20 - diplomacyButtonWrapper.height } - private fun updateTechButton(civInfo: CivilizationInfo) { - techButtonHolder.isVisible = civInfo.cities.isNotEmpty() + private fun updateTechButton() { + techButtonHolder.isVisible = viewingCiv.cities.isNotEmpty() techButtonHolder.clearChildren() - val researchableTechs = GameBasics.Technologies.values.filter { !civInfo.tech.isResearched(it.name) && civInfo.tech.canBeResearched(it.name) } - if (civInfo.tech.currentTechnology() == null && researchableTechs.isEmpty()) - civInfo.tech.techsToResearch.add(Constants.futureTech) + val researchableTechs = GameBasics.Technologies.values.filter { !viewingCiv.tech.isResearched(it.name) && viewingCiv.tech.canBeResearched(it.name) } + if (viewingCiv.tech.currentTechnology() == null && researchableTechs.isEmpty()) + viewingCiv.tech.techsToResearch.add(Constants.futureTech) - if (civInfo.tech.currentTechnology() == null) { + if (viewingCiv.tech.currentTechnology() == null) { val buttonPic = Table() buttonPic.background = ImageGetter.getDrawable("OtherIcons/civTableBackground") .tint(colorFromRGB(7, 46, 43)) @@ -259,11 +259,11 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { techButtonHolder.add(buttonPic) } else { - val currentTech = civInfo.tech.currentTechnologyName()!! - val innerButton = TechButton(currentTech,civInfo.tech) + val currentTech = viewingCiv.tech.currentTechnologyName()!! + val innerButton = TechButton(currentTech,viewingCiv.tech) innerButton.color = colorFromRGB(7, 46, 43) techButtonHolder.add(innerButton) - val turnsToTech = civInfo.tech.turnsToTech(currentTech) + val turnsToTech = viewingCiv.tech.turnsToTech(currentTech) innerButton.text.setText(currentTech.tr() + "\r\n" + turnsToTech + (if(turnsToTech>1) " {turns}".tr() else " {turn}".tr())) }