Fix display of AA ranges for most ship types.

Fixes https://github.com/Khopa/dcs_liberation/issues/390
This commit is contained in:
Dan Albert 2020-12-06 14:21:41 -08:00
parent 2012ad0aa3
commit e0223ded54
2 changed files with 22 additions and 13 deletions

View File

@ -140,6 +140,10 @@ class TheaterGroundObject(MissionTarget):
def alive_unit_count(self) -> int: def alive_unit_count(self) -> int:
return sum(len(g.units) for g in self.groups) return sum(len(g.units) for g in self.groups)
@property
def might_have_aa(self) -> bool:
return False
class BuildingGroundObject(TheaterGroundObject): class BuildingGroundObject(TheaterGroundObject):
def __init__(self, name: str, category: str, group_id: int, object_id: int, def __init__(self, name: str, category: str, group_id: int, object_id: int,
@ -175,6 +179,10 @@ class NavalGroundObject(TheaterGroundObject):
yield FlightType.ANTISHIP yield FlightType.ANTISHIP
yield from super().mission_types(for_player) yield from super().mission_types(for_player)
@property
def might_have_aa(self) -> bool:
return True
class GenericCarrierGroundObject(NavalGroundObject): class GenericCarrierGroundObject(NavalGroundObject):
pass pass
@ -282,6 +290,10 @@ class SamGroundObject(BaseDefenseGroundObject):
yield FlightType.DEAD yield FlightType.DEAD
yield from super().mission_types(for_player) yield from super().mission_types(for_player)
@property
def might_have_aa(self) -> bool:
return True
class VehicleGroupGroundObject(BaseDefenseGroundObject): class VehicleGroupGroundObject(BaseDefenseGroundObject):
def __init__(self, name: str, group_id: int, position: Point, def __init__(self, name: str, group_id: int, position: Point,
@ -325,6 +337,10 @@ class EwrGroundObject(BaseDefenseGroundObject):
yield FlightType.DEAD yield FlightType.DEAD
yield from super().mission_types(for_player) yield from super().mission_types(for_player)
@property
def might_have_aa(self) -> bool:
return True
class ShipGroundObject(NavalGroundObject): class ShipGroundObject(NavalGroundObject):
def __init__(self, name: str, group_id: int, position: Point, def __init__(self, name: str, group_id: int, position: Point,

View File

@ -27,7 +27,7 @@ from dcs.mapping import point_from_heading
import qt_ui.uiconstants as CONST import qt_ui.uiconstants as CONST
from game import Game, db from game import Game, db
from game.theater import ControlPoint, Enum from game.theater import ControlPoint, Enum, NavalControlPoint
from game.theater.conflicttheater import FrontLine from game.theater.conflicttheater import FrontLine
from game.theater.theatergroundobject import ( from game.theater.theatergroundobject import (
EwrGroundObject, EwrGroundObject,
@ -243,15 +243,9 @@ class QLiberationMap(QGraphicsView):
scene.addEllipse(transformed[0]-diameter/2, transformed[1]-diameter/2, diameter, diameter, CONST.COLORS["transparent"], CONST.COLORS["light_green_transparent"]) scene.addEllipse(transformed[0]-diameter/2, transformed[1]-diameter/2, diameter, diameter, CONST.COLORS["transparent"], CONST.COLORS["light_green_transparent"])
@staticmethod @staticmethod
def ground_object_display_options(ground_object: TheaterGroundObject, cp: ControlPoint) -> Tuple[bool, bool]: def should_display_ground_objects_at(cp: ControlPoint) -> bool:
is_missile = isinstance(ground_object, MissileSiteGroundObject) return ((DisplayOptions.sam_ranges and cp.captured) or
is_aa = ground_object.category == "aa" and not is_missile
is_ewr = isinstance(ground_object, EwrGroundObject)
is_display_type = is_aa or is_ewr
should_display = ((DisplayOptions.sam_ranges and cp.captured)
or
(DisplayOptions.enemy_sam_ranges and not cp.captured)) (DisplayOptions.enemy_sam_ranges and not cp.captured))
return is_display_type, should_display
def draw_threat_range(self, scene: QGraphicsScene, ground_object: TheaterGroundObject, cp: ControlPoint) -> None: def draw_threat_range(self, scene: QGraphicsScene, ground_object: TheaterGroundObject, cp: ControlPoint) -> None:
go_pos = self._transform_point(ground_object.position) go_pos = self._transform_point(ground_object.position)
@ -286,9 +280,8 @@ class QLiberationMap(QGraphicsView):
buildings = self.game.theater.find_ground_objects_by_obj_name(ground_object.obj_name) buildings = self.game.theater.find_ground_objects_by_obj_name(ground_object.obj_name)
scene.addItem(QMapGroundObject(self, go_pos[0], go_pos[1], 14, 12, cp, ground_object, self.game, buildings)) scene.addItem(QMapGroundObject(self, go_pos[0], go_pos[1], 14, 12, cp, ground_object, self.game, buildings))
is_display_type, should_display = self.ground_object_display_options(ground_object, cp) should_display = self.should_display_ground_objects_at(cp)
if ground_object.might_have_aa and should_display:
if is_display_type and should_display:
self.draw_threat_range(scene, ground_object, cp) self.draw_threat_range(scene, ground_object, cp)
added_objects.append(ground_object.obj_name) added_objects.append(ground_object.obj_name)