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) {
removeUnitActionOverlay()
selectedTile = tile
unitMovementPaths.clear()
worldScreen.shouldUpdate = true
if (worldScreen.bottomUnitTable.selectedUnitIsSwapping) {
if (unit.movement.canUnitSwapTo(tile)) {
swapMoveUnitToTargetTile(unit, tile)

View File

@ -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)
}