Prevent senseless BattleTable display and fix right-click issues (#7003)

This commit is contained in:
SomeTroglodyte 2022-06-02 15:32:09 +02:00 committed by GitHub
parent cdeabd044d
commit 7df71571dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 8 deletions

View File

@ -216,6 +216,11 @@ class WorldMapHolder(
} }
private fun onTileRightClicked(unit: MapUnit, tile: TileInfo) { private fun onTileRightClicked(unit: MapUnit, tile: TileInfo) {
removeUnitActionOverlay()
selectedTile = tile
unitMovementPaths.clear()
worldScreen.shouldUpdate = true
if (worldScreen.bottomUnitTable.selectedUnitIsSwapping) { if (worldScreen.bottomUnitTable.selectedUnitIsSwapping) {
if (unit.movement.canUnitSwapTo(tile)) { if (unit.movement.canUnitSwapTo(tile)) {
swapMoveUnitToTargetTile(unit, tile) swapMoveUnitToTargetTile(unit, tile)

View File

@ -33,28 +33,28 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
touchable = Touchable.enabled touchable = Touchable.enabled
} }
fun hide(){ private fun hide() {
isVisible = false isVisible = false
clear() clear()
pack() pack()
} }
fun update() { fun update() {
isVisible = true if (!worldScreen.canChangeState) return hide()
if (!worldScreen.canChangeState) { hide(); return }
val attacker = tryGetAttacker() val attacker = tryGetAttacker() ?: return hide()
if (attacker == null) { hide(); return }
if (attacker is MapUnitCombatant && attacker.unit.baseUnit.isNuclearWeapon()) { if (attacker is MapUnitCombatant && attacker.unit.baseUnit.isNuclearWeapon()) {
val selectedTile = worldScreen.mapHolder.selectedTile val selectedTile = worldScreen.mapHolder.selectedTile
if (selectedTile == null) { hide(); return } // no selected tile ?: return hide() // no selected tile
simulateNuke(attacker, selectedTile) simulateNuke(attacker, selectedTile)
} else { } else {
val defender = tryGetDefender() val defender = tryGetDefender() ?: return hide()
if (defender == null) { hide(); return } if (attacker is CityCombatant && defender is CityCombatant) return hide()
simulateBattle(attacker, defender) simulateBattle(attacker, defender)
} }
isVisible = true
pack() pack()
addBorderAllowOpacity(1f, Color.WHITE) addBorderAllowOpacity(1f, Color.WHITE)
} }