From 7df71571dca489452990c45fe46eac4e07a94174 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Thu, 2 Jun 2022 15:32:09 +0200 Subject: [PATCH] Prevent senseless BattleTable display and fix right-click issues (#7003) --- .../com/unciv/ui/worldscreen/WorldMapHolder.kt | 5 +++++ .../ui/worldscreen/bottombar/BattleTable.kt | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt b/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt index f68e312f4c..e9cb9570f4 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt @@ -216,6 +216,11 @@ class WorldMapHolder( } private fun onTileRightClicked(unit: MapUnit, tile: TileInfo) { + removeUnitActionOverlay() + selectedTile = tile + unitMovementPaths.clear() + worldScreen.shouldUpdate = true + if (worldScreen.bottomUnitTable.selectedUnitIsSwapping) { if (unit.movement.canUnitSwapTo(tile)) { swapMoveUnitToTargetTile(unit, tile) diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt index d4cc173fc0..a9f009383c 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt @@ -33,28 +33,28 @@ class BattleTable(val worldScreen: WorldScreen): Table() { touchable = Touchable.enabled } - fun hide(){ + private fun hide() { isVisible = false clear() pack() } fun update() { - isVisible = true - if (!worldScreen.canChangeState) { hide(); return } + if (!worldScreen.canChangeState) return hide() - val attacker = tryGetAttacker() - if (attacker == null) { hide(); return } + val attacker = tryGetAttacker() ?: return hide() if (attacker is MapUnitCombatant && attacker.unit.baseUnit.isNuclearWeapon()) { val selectedTile = worldScreen.mapHolder.selectedTile - if (selectedTile == null) { hide(); return } // no selected tile + ?: return hide() // no selected tile simulateNuke(attacker, selectedTile) } else { - val defender = tryGetDefender() - if (defender == null) { hide(); return } + val defender = tryGetDefender() ?: return hide() + if (attacker is CityCombatant && defender is CityCombatant) return hide() simulateBattle(attacker, defender) } + + isVisible = true pack() addBorderAllowOpacity(1f, Color.WHITE) }