From a5e1978a716def8e6f1a2aa4e0d4b972e82d5fc7 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 29 Mar 2019 15:38:22 +0300 Subject: [PATCH] Added popup for "move and attack" bug that I can't figure out --- core/src/com/unciv/ui/saves/LoadScreen.kt | 3 ++- .../ui/worldscreen/bottombar/BattleTable.kt | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/ui/saves/LoadScreen.kt b/core/src/com/unciv/ui/saves/LoadScreen.kt index 004318d5cc..0345e33e35 100644 --- a/core/src/com/unciv/ui/saves/LoadScreen.kt +++ b/core/src/com/unciv/ui/saves/LoadScreen.kt @@ -97,7 +97,8 @@ class LoadScreen : PickerScreen() { catch (ex:Exception){ val popup = PopupTable(this) popup.addGoodSizedLabel("It looks like your saved game can't be loaded!").row() - popup.addGoodSizedLabel("If you could copy your game data (\"Copy saved game to clipboard\" - paste into an email to yairm210@hotmail.com)").row() + popup.addGoodSizedLabel("If you could copy your game data (\"Copy saved game to clipboard\" - ").row() + popup.addGoodSizedLabel(" paste into an email to yairm210@hotmail.com)").row() popup.addGoodSizedLabel("I could maybe help you figure out what went wrong, since this isn't supposed to happen!").row() popup.open() } diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt index 0f2d3cb266..a7438a9b5f 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt @@ -14,6 +14,7 @@ import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.unit.UnitType import com.unciv.ui.utils.* import com.unciv.ui.worldscreen.WorldScreen +import com.unciv.ui.worldscreen.optionstable.PopupTable import kotlin.math.max class BattleTable(val worldScreen: WorldScreen): Table() { @@ -151,9 +152,21 @@ class BattleTable(val worldScreen: WorldScreen): Table() { if(attackableEnemy == null) attackButton.disable() else { attackButton.onClick { - battle.moveAndAttack(attacker,attackableEnemy!!) - worldScreen.tileMapHolder.removeUnitActionOverlay=true // the overlay was one of attacking - worldScreen.shouldUpdate=true + try { + battle.moveAndAttack(attacker, attackableEnemy) + worldScreen.tileMapHolder.removeUnitActionOverlay = true // the overlay was one of attacking + worldScreen.shouldUpdate = true + } + catch (ex:Exception){ + val popup = PopupTable(worldScreen) + popup.addGoodSizedLabel("You've encountered a bug that I've been looking for for a while!").row() + popup.addGoodSizedLabel("If you could copy your game data (\"Copy saved game to clipboard\" - ").row() + popup.addGoodSizedLabel(" paste into an email to yairm210@hotmail.com)").row() + popup.addGoodSizedLabel("It would help me figure out what went wrong, since this isn't supposed to happen!").row() + popup.addGoodSizedLabel("If you could tell me which unit was selected and which unit you tried to attack,").row() + popup.addGoodSizedLabel(" that would be even better!").row() + popup.open() + } } }