diff --git a/core/src/com/unciv/UnCivGame.kt b/core/src/com/unciv/UnCivGame.kt index 98dfcba926..059eb14749 100644 --- a/core/src/com/unciv/UnCivGame.kt +++ b/core/src/com/unciv/UnCivGame.kt @@ -21,9 +21,9 @@ class UnCivGame(val version: String) : Game() { * This exists so that when debugging we can see the entire map. * Remember to turn this to false before commit and upload! */ - val viewEntireMapForDebug = true + val viewEntireMapForDebug = false - // For when you need to test something in an advanced game and don't have time to faff around + /** For when you need to test something in an advanced game and don't have time to faff around */ val superchargedForDebug = false lateinit var worldScreen: WorldScreen diff --git a/core/src/com/unciv/ui/cityscreen/CityScreen.kt b/core/src/com/unciv/ui/cityscreen/CityScreen.kt index a70131d0fb..dbd834b48c 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreen.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreen.kt @@ -165,12 +165,14 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { if(!city.isBeingRazed) { val razeCityButton = TextButton("Raze city".tr(), skin) + razeCityButton.labelCell.pad(10f) razeCityButton.onClick { city.isBeingRazed=true; update() } if(!UnCivGame.Current.worldScreen.isPlayersTurn) razeCityButton.disable() razeCityButtonHolder.add(razeCityButton).colspan(cityPickerTable.columns) } else { val stopRazingCityButton = TextButton("Stop razing city".tr(), skin) + stopRazingCityButton.labelCell.pad(10f) stopRazingCityButton.onClick { city.isBeingRazed=false; update() } if(!UnCivGame.Current.worldScreen.isPlayersTurn) stopRazingCityButton.disable() razeCityButtonHolder.add(stopRazingCityButton).colspan(cityPickerTable.columns) diff --git a/core/src/com/unciv/ui/cityscreen/CityScreenCityPickerTable.kt b/core/src/com/unciv/ui/cityscreen/CityScreenCityPickerTable.kt index 22ef9ce26a..d3299cd049 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreenCityPickerTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreenCityPickerTable.kt @@ -70,6 +70,7 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){ row() val exitCityButton = TextButton("Exit city".tr(), CameraStageBaseScreen.skin) + exitCityButton.labelCell.pad(10f) exitCityButton.onClick { val game = cityScreen.game diff --git a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt index 0dfbd14963..37dd89e6ea 100644 --- a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt @@ -148,17 +148,18 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre row() val purchaseConstructionButton: TextButton if (construction.canBePurchased()) { - val buildingGoldCost = construction.getGoldCost(city.civInfo) - purchaseConstructionButton = TextButton("Buy for [$buildingGoldCost] gold".tr(), CameraStageBaseScreen.skin) + val constructionGoldCost = construction.getGoldCost(city.civInfo) + purchaseConstructionButton = TextButton("Buy for [$constructionGoldCost] gold".tr(), CameraStageBaseScreen.skin) + purchaseConstructionButton.labelCell.pad(10f) purchaseConstructionButton.onClick("coin") { - YesNoPopupTable("Would you like to purchase [${construction.name}] for [$buildingGoldCost] gold?".tr(), { + YesNoPopupTable("Would you like to purchase [${construction.name}] for [$constructionGoldCost] gold?".tr(), { cityConstructions.purchaseConstruction(construction.name) if(lastConstruction!="" && cityConstructions.getConstruction(lastConstruction).isBuildable(cityConstructions)) city.cityConstructions.currentConstruction = lastConstruction cityScreen.update() // since the list of available buildings needs to be updated too, so we can "see" that the building we bought now exists in the city }, cityScreen) } - if (buildingGoldCost > city.civInfo.gold) { + if (constructionGoldCost > city.civInfo.gold) { purchaseConstructionButton.disable() } } else { diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 41a99c8f34..88dde519c4 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.scenes.scene2d.Touchable +import com.badlogic.gdx.scenes.scene2d.ui.Button import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.unciv.Constants @@ -43,7 +44,8 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { val battleTable = BattleTable(this) val unitActionsTable = UnitActionsTable(this) - private val techButton = Table() + private val techPolicyandVictoryHolder = Table() + private val techButtonHolder = Table() private val diplomacyButtonWrapper = Table() private val nextTurnButton = createNextTurnButton() @@ -62,16 +64,25 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { tileMapHolder.addTiles() - techButton.touchable=Touchable.enabled - techButton.onClick("paper") { + techButtonHolder.touchable=Touchable.enabled + techButtonHolder.onClick("paper") { game.screen = TechPickerScreen(viewingCiv) } + techPolicyandVictoryHolder.add(techButtonHolder) + + // Don't show policies until they become relevant + if(viewingCiv.policies.adoptedPolicies.isNotEmpty() || viewingCiv.policies.canAdoptPolicy()) { + val policyScreenButton = Button(skin) + policyScreenButton.add(ImageGetter.getImage("PolicyIcons/Constitution")).size(30f).pad(15f) + policyScreenButton.onClick { game.screen = PolicyPickerScreen(viewingCiv) } + techPolicyandVictoryHolder.add(policyScreenButton).pad(10f) + } stage.addActor(tileMapHolder) stage.addActor(minimapWrapper) stage.addActor(topBar) stage.addActor(nextTurnButton) - stage.addActor(techButton) + stage.addActor(techPolicyandVictoryHolder) stage.addActor(notificationsScroll) @@ -139,8 +150,6 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { displayTutorialsOnUpdate(cloneCivilization, gameClone) - updateTechButton(cloneCivilization) - updateDiplomacyButton(cloneCivilization) bottomBar.update(tileMapHolder.selectedTile) // has to come before tilemapholder update because the tilemapholder actions depend on the selected unit! battleTable.update() @@ -157,6 +166,12 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { tileMapHolder.updateTiles(viewingCiv) topBar.update(cloneCivilization) + + updateTechButton(cloneCivilization) + techPolicyandVictoryHolder.pack() + techPolicyandVictoryHolder.setPosition(10f, topBar.y - techPolicyandVictoryHolder.height - 5f) + updateDiplomacyButton(cloneCivilization) + notificationsScroll.update(viewingCiv.notifications) notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f, nextTurnButton.y - notificationsScroll.height - 5f) @@ -217,12 +232,12 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { diplomacyButtonWrapper.add(btn) } diplomacyButtonWrapper.pack() - diplomacyButtonWrapper.y = techButton.y -20 - diplomacyButtonWrapper.height + diplomacyButtonWrapper.y = techPolicyandVictoryHolder.y -20 - diplomacyButtonWrapper.height } private fun updateTechButton(civInfo: CivilizationInfo) { - techButton.isVisible = civInfo.cities.isNotEmpty() - techButton.clearChildren() + techButtonHolder.isVisible = civInfo.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()) @@ -234,20 +249,19 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { .tint(colorFromRGB(7, 46, 43)) buttonPic.defaults().pad(10f) buttonPic.add("{Pick a tech}!".toLabel().setFontColor(Color.WHITE).setFontSize(22)) - techButton.add(buttonPic) + techButtonHolder.add(buttonPic) } else { val currentTech = civInfo.tech.currentTechnologyName()!! val innerButton = TechButton(currentTech,civInfo.tech) innerButton.color = colorFromRGB(7, 46, 43) - techButton.add(innerButton) + techButtonHolder.add(innerButton) val turnsToTech = civInfo.tech.turnsToTech(currentTech) innerButton.text.setText(currentTech.tr() + "\r\n" + turnsToTech + (if(turnsToTech>1) " {turns}".tr() else " {turn}".tr())) } - techButton.setSize(techButton.prefWidth, techButton.prefHeight) - techButton.setPosition(10f, topBar.y - techButton.height - 5f) + techButtonHolder.pack() //setSize(techButtonHolder.prefWidth, techButtonHolder.prefHeight) } private fun createNextTurnButton(): TextButton { @@ -300,6 +314,19 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { gameInfoClone.setTransients() try { gameInfoClone.nextTurn() + + if(gameInfo.gameParameters.isOnlineMultiplayer) { + try { + OnlineMultiplayer().tryUploadGame(gameInfoClone) + } catch (ex: Exception) { + val cantUploadNewGamePopup = PopupTable(this) + cantUploadNewGamePopup.addGoodSizedLabel("Can't upload the new game!") + cantUploadNewGamePopup.addCloseButton() + cantUploadNewGamePopup.open() + isPlayersTurn = true // Since we couldn't push the new game clone, then it's like we never clicked the "next turn" button + return@thread + } + } } catch (ex: Exception) { game.settings.hasCrashedRecently = true game.settings.save() @@ -308,16 +335,13 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { game.gameInfo = gameInfoClone - val shouldAutoSave = !gameInfo.gameParameters.isOnlineMultiplayer && - gameInfoClone.turns % game.settings.turnsBetweenAutosaves == 0 + val shouldAutoSave = gameInfoClone.turns % game.settings.turnsBetweenAutosaves == 0 // create a new worldscreen to show the new stuff we've changed, and switch out the current screen. // do this on main thread - it's the only one that has a GL context to create images from Gdx.app.postRunnable { - if (gameInfoClone.currentPlayerCiv.civName != viewingCiv.civName - && !gameInfoClone.gameParameters.isOnlineMultiplayer) - UnCivGame.Current.screen = PlayerReadyScreen(gameInfoClone.getCurrentPlayerCivilization()) - else { + + fun createNewWorldScreen(){ val newWorldScreen = WorldScreen(gameInfoClone.currentPlayerCiv) newWorldScreen.tileMapHolder.scrollX = tileMapHolder.scrollX newWorldScreen.tileMapHolder.scrollY = tileMapHolder.scrollY @@ -328,20 +352,17 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { game.setWorldScreen() } + if (gameInfoClone.currentPlayerCiv.civName != viewingCiv.civName + && !gameInfoClone.gameParameters.isOnlineMultiplayer) + UnCivGame.Current.screen = PlayerReadyScreen(gameInfoClone.getCurrentPlayerCivilization()) + else { + createNewWorldScreen() + } + if(shouldAutoSave) { game.worldScreen.nextTurnButton.disable() GameSaver().autoSave(gameInfoClone) { - game.worldScreen.nextTurnButton.enable() // only enable the user to next turn once we've saved the current one - } - } - if(gameInfo.gameParameters.isOnlineMultiplayer) { - try { - OnlineMultiplayer().tryUploadGame(gameInfoClone) - } catch (ex: Exception) { - val cantUploadNewGamePopup = PopupTable(this) - cantUploadNewGamePopup.addGoodSizedLabel("Can't upload the new game!") - cantUploadNewGamePopup.addCloseButton() - cantUploadNewGamePopup.open() + createNewWorldScreen() // only enable the user to next turn once we've saved the current one } } } diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt b/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt index a8de6be3f4..f82e3f6b08 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt @@ -45,11 +45,13 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() { pack() addActor(getMenuButton()) // needs to be after pack - val button = TextButton("Overview".tr(),CameraStageBaseScreen.skin) - button.onClick { UnCivGame.Current.screen = EmpireOverviewScreen() } - button.center(this) - button.x = screen.stage.width-button.width-10 - addActor(button) + val overviewButton = TextButton("Overview".tr(),CameraStageBaseScreen.skin) + overviewButton.labelCell.pad(10f) + overviewButton.pack() + overviewButton.onClick { UnCivGame.Current.screen = EmpireOverviewScreen() } + overviewButton.center(this) + overviewButton.x = screen.stage.width-overviewButton.width-10 + addActor(overviewButton) } private fun getResourceTable(): Table { diff --git a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenMenuTable.kt b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenMenuTable.kt index 1af17544e8..6df8c51f42 100644 --- a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenMenuTable.kt +++ b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenMenuTable.kt @@ -8,7 +8,6 @@ import com.unciv.ui.CivilopediaScreen import com.unciv.ui.VictoryScreen import com.unciv.ui.mapeditor.MapEditorScreen import com.unciv.ui.newgamescreen.NewGameScreen -import com.unciv.ui.pickerscreens.PolicyPickerScreen import com.unciv.ui.saves.LoadGameScreen import com.unciv.ui.saves.SaveGameScreen import com.unciv.ui.worldscreen.WorldScreen @@ -50,11 +49,6 @@ class WorldScreenMenuTable(val worldScreen: WorldScreen) : PopupTable(worldScree addButton("Victory status".tr()) { UnCivGame.Current.screen = VictoryScreen() } - addButton("Social policies".tr()){ - UnCivGame.Current.screen = PolicyPickerScreen(UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()) - } - - addButton("Options".tr()){ UnCivGame.Current.worldScreen.stage.addActor(WorldScreenOptionsTable(worldScreen)) remove()