diff --git a/core/src/com/unciv/UncivGame.kt b/core/src/com/unciv/UncivGame.kt index 034ccce00e..4581c0020d 100644 --- a/core/src/com/unciv/UncivGame.kt +++ b/core/src/com/unciv/UncivGame.kt @@ -57,7 +57,7 @@ class UncivGame(parameters: UncivGameParameters) : Game() { * Does not update World View changes until finished. * Set to 0 to disable. */ - val simulateUntilTurnForDebug: Int = 0 + var simulateUntilTurnForDebug: Int = 0 /** Console log battles */ diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 14ee8e2534..685da68e33 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -207,6 +207,8 @@ class GameInfo { currentPlayerIndex = (currentPlayerIndex + 1) % civilizations.size if (currentPlayerIndex == 0) { turns++ + if (UncivGame.Current.simulateUntilTurnForDebug != 0) + println("Starting simulation of turn $turns") } thisPlayer = civilizations[currentPlayerIndex] thisPlayer.startTurn() diff --git a/core/src/com/unciv/ui/popup/AskNumberPopup.kt b/core/src/com/unciv/ui/popup/AskNumberPopup.kt index 6a69947086..0d6e35f61c 100644 --- a/core/src/com/unciv/ui/popup/AskNumberPopup.kt +++ b/core/src/com/unciv/ui/popup/AskNumberPopup.kt @@ -12,7 +12,7 @@ import com.unciv.ui.utils.* * @param screen The previous screen the user was on * @param label A line of text shown to the user * @param icon Icon at the top, should have size 80f - * @param defaultText The text that should be in the prompt at the start + * @param defaultValue The number that should be in the prompt at the start * @param amountButtons Buttons that when clicked will add/subtract these amounts to the number * @param bounds The bounds in which the number must lie. Defaults to [Int.MIN_VALUE, Int.MAX_VALUE] * @param errorText Text that will be shown when an error is detected @@ -24,7 +24,7 @@ class AskNumberPopup( screen: BaseScreen, label: String = "Please enter a number", icon: IconCircleGroup = ImageGetter.getImage("OtherIcons/Pencil").apply { this.color = Color.BLACK }.surroundWithCircle(80f), - defaultText: String = "", + defaultValue: String = "", amountButtons: List = listOf(), bounds: IntRange = IntRange(Int.MIN_VALUE, Int.MAX_VALUE), errorText: String = "Invalid input! Please enter a valid number.", @@ -56,7 +56,7 @@ class AskNumberPopup( wrapper.add(label.toLabel()) add(wrapper).colspan(2).row() - val nameField = TextField(defaultText, skin) + val nameField = TextField(defaultValue, skin) nameField.textFieldFilter = TextField.TextFieldFilter { _, char -> char.isDigit() || char == '-' } fun isValidInt(input: String): Boolean { diff --git a/core/src/com/unciv/ui/trade/OfferColumnsTable.kt b/core/src/com/unciv/ui/trade/OfferColumnsTable.kt index 3d3ba2d9cf..9c47e024b4 100644 --- a/core/src/com/unciv/ui/trade/OfferColumnsTable.kt +++ b/core/src/com/unciv/ui/trade/OfferColumnsTable.kt @@ -88,7 +88,7 @@ class OfferColumnsTable(private val tradeLogic: TradeLogic, val screen: Diplomac screen, label = "Enter the amount of gold", icon = ImageGetter.getStatIcon("Gold").surroundWithCircle(80f), - defaultText = offer.amount.toString(), + defaultValue = offer.amount.toString(), amountButtons = if (offer.type == TradeType.Gold) listOf(50, 500) else listOf(5, 15), diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index e5fcecabd2..c437b06054 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -645,7 +645,7 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Bas game.setWorldScreen() } - private fun nextTurn() { + fun nextTurn() { isPlayersTurn = false shouldUpdate = true diff --git a/core/src/com/unciv/ui/worldscreen/mainmenu/OptionsPopup.kt b/core/src/com/unciv/ui/worldscreen/mainmenu/OptionsPopup.kt index f31972d05d..46cda2e574 100644 --- a/core/src/com/unciv/ui/worldscreen/mainmenu/OptionsPopup.kt +++ b/core/src/com/unciv/ui/worldscreen/mainmenu/OptionsPopup.kt @@ -516,9 +516,6 @@ class OptionsPopup(val previousScreen: BaseScreen) : Popup(previousScreen) { private fun autoUpdateUniques(mod: Ruleset, replaceableUniques: HashMap) { - if (mod.name.contains("mod")) - println("mod") - val filesToReplace = listOf( "Beliefs.json", "Buildings.json", @@ -552,27 +549,43 @@ class OptionsPopup(val previousScreen: BaseScreen) : Popup(previousScreen) { defaults().pad(5f) val game = UncivGame.Current + val simulateButton = "Simulate until turn:".toTextButton() + val simulateTextField = TextField(game.simulateUntilTurnForDebug.toString(), BaseScreen.skin) + val invalidInputLabel = "This is not a valid integer!".toLabel().also { it.isVisible = false } + simulateButton.onClick { + val simulateUntilTurns = simulateTextField.text.toIntOrNull() + if (simulateUntilTurns == null) { + invalidInputLabel.isVisible = true + return@onClick + } + game.simulateUntilTurnForDebug = simulateUntilTurns + invalidInputLabel.isVisible = false + game.worldScreen.nextTurn() + } + add(simulateButton) + add(simulateTextField).row() + add(invalidInputLabel).colspan(2).row() add("Supercharged".toCheckBox(game.superchargedForDebug) { game.superchargedForDebug = it - }).row() + }).colspan(2).row() add("View entire map".toCheckBox(game.viewEntireMapForDebug) { game.viewEntireMapForDebug = it - }).row() + }).colspan(2).row() if (game.isGameInfoInitialized()) { add("God mode (current game)".toCheckBox(game.gameInfo.gameParameters.godMode) { game.gameInfo.gameParameters.godMode = it - }).row() + }).colspan(2).row() } add("Save maps compressed".toCheckBox(MapSaver.saveZipped) { MapSaver.saveZipped = it - }).row() + }).colspan(2).row() add("Gdx Scene2D debug".toCheckBox(BaseScreen.enableSceneDebug) { BaseScreen.enableSceneDebug = it - }).row() + }).colspan(2).row() add("Allow untyped Uniques in mod checker".toCheckBox(RulesetCache.modCheckerAllowUntypedUniques) { RulesetCache.modCheckerAllowUntypedUniques = it - }).row() + }).colspan(2).row() add(Table().apply { add("Unique misspelling threshold".toLabel()).left().fillX() @@ -581,7 +594,7 @@ class OptionsPopup(val previousScreen: BaseScreen) : Popup(previousScreen) { RulesetCache.uniqueMisspellingThreshold = it.toDouble() } ).minWidth(120f).pad(5f) - }).row() + }).colspan(2).row() val unlockTechsButton = "Unlock all techs".toTextButton() unlockTechsButton.onClick { @@ -596,9 +609,9 @@ class OptionsPopup(val previousScreen: BaseScreen) : Popup(previousScreen) { game.gameInfo.getCurrentPlayerCivilization().updateSightAndResources() game.worldScreen.shouldUpdate = true } - add(unlockTechsButton).row() + add(unlockTechsButton).colspan(2).row() - val giveResourcesButton = "Give all strategic resources".toTextButton() + val giveResourcesButton = "Get all strategic resources".toTextButton() giveResourcesButton.onClick { if (!game.isGameInfoInitialized()) return@onClick @@ -612,7 +625,7 @@ class OptionsPopup(val previousScreen: BaseScreen) : Popup(previousScreen) { game.gameInfo.getCurrentPlayerCivilization().updateSightAndResources() game.worldScreen.shouldUpdate = true } - add(giveResourcesButton).row() + add(giveResourcesButton).colspan(2).row() } //endregion