From e7398af87799a66bd80e5c60f4f7c28d421d72e9 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 27 Feb 2022 19:06:21 -0800 Subject: [PATCH] Update ControlPoint UI to use milsymbol library. This gets us out of the business of maintaining our own icons. The milsymbol library generates the SVG data needed to display anything covered by APP-6. --- game/theater/controlpoint.py | 49 +- qt_ui/widgets/map/model/controlpointjs.py | 22 +- .../ui/ground_assets/airfield_blue_alive.svg | 1 - .../ground_assets/airfield_blue_damaged.svg | 1 - .../ground_assets/airfield_blue_destroyed.svg | 1 - .../ui/ground_assets/airfield_red_alive.svg | 1 - .../ui/ground_assets/airfield_red_damaged.svg | 1 - .../ground_assets/airfield_red_destroyed.svg | 1 - resources/ui/ground_assets/cv_blue_alive.svg | 1 - .../ui/ground_assets/cv_blue_damaged.svg | 1 - .../ui/ground_assets/cv_blue_destination.svg | 1 - .../ui/ground_assets/cv_blue_destroyed.svg | 1 - resources/ui/ground_assets/cv_red_alive.svg | 1 - resources/ui/ground_assets/cv_red_damaged.svg | 1 - .../ui/ground_assets/cv_red_destination.svg | 1 - .../ui/ground_assets/cv_red_destroyed.svg | 1 - resources/ui/ground_assets/fob_blue.png | Bin 417 -> 0 bytes resources/ui/ground_assets/fob_blue_alive.svg | 1 - .../ui/ground_assets/fob_blue_damaged.svg | 1 - .../ui/ground_assets/fob_blue_destroyed.svg | 1 - resources/ui/ground_assets/fob_red_alive.svg | 1 - .../ui/ground_assets/fob_red_damaged.svg | 1 - .../ui/ground_assets/fob_red_destroyed.svg | 1 - resources/ui/ground_assets/lha_blue_alive.svg | 1 - .../ui/ground_assets/lha_blue_damaged.svg | 1 - .../ui/ground_assets/lha_blue_destination.svg | 1 - .../ui/ground_assets/lha_blue_destroyed.svg | 1 - resources/ui/ground_assets/lha_red_alive.svg | 1 - .../ui/ground_assets/lha_red_damaged.svg | 1 - .../ui/ground_assets/lha_red_destination.svg | 1 - .../ui/ground_assets/lha_red_destroyed.svg | 1 - resources/ui/map/canvas.html | 2 + .../lib/milsymbol/milsymbol.development.js | 29606 ++++++++++++++++ .../ui/map/lib/milsymbol/milsymbol.esm.js | 29424 +++++++++++++++ resources/ui/map/lib/milsymbol/milsymbol.js | 27 + .../ui/map/lib/milsymbol/milsymbol.js.map | 1 + resources/ui/map/map.js | 44 +- 37 files changed, 59121 insertions(+), 82 deletions(-) delete mode 100644 resources/ui/ground_assets/airfield_blue_alive.svg delete mode 100644 resources/ui/ground_assets/airfield_blue_damaged.svg delete mode 100644 resources/ui/ground_assets/airfield_blue_destroyed.svg delete mode 100644 resources/ui/ground_assets/airfield_red_alive.svg delete mode 100644 resources/ui/ground_assets/airfield_red_damaged.svg delete mode 100644 resources/ui/ground_assets/airfield_red_destroyed.svg delete mode 100644 resources/ui/ground_assets/cv_blue_alive.svg delete mode 100644 resources/ui/ground_assets/cv_blue_damaged.svg delete mode 100644 resources/ui/ground_assets/cv_blue_destination.svg delete mode 100644 resources/ui/ground_assets/cv_blue_destroyed.svg delete mode 100644 resources/ui/ground_assets/cv_red_alive.svg delete mode 100644 resources/ui/ground_assets/cv_red_damaged.svg delete mode 100644 resources/ui/ground_assets/cv_red_destination.svg delete mode 100644 resources/ui/ground_assets/cv_red_destroyed.svg delete mode 100644 resources/ui/ground_assets/fob_blue.png delete mode 100644 resources/ui/ground_assets/fob_blue_alive.svg delete mode 100644 resources/ui/ground_assets/fob_blue_damaged.svg delete mode 100644 resources/ui/ground_assets/fob_blue_destroyed.svg delete mode 100644 resources/ui/ground_assets/fob_red_alive.svg delete mode 100644 resources/ui/ground_assets/fob_red_damaged.svg delete mode 100644 resources/ui/ground_assets/fob_red_destroyed.svg delete mode 100644 resources/ui/ground_assets/lha_blue_alive.svg delete mode 100644 resources/ui/ground_assets/lha_blue_damaged.svg delete mode 100644 resources/ui/ground_assets/lha_blue_destination.svg delete mode 100644 resources/ui/ground_assets/lha_blue_destroyed.svg delete mode 100644 resources/ui/ground_assets/lha_red_alive.svg delete mode 100644 resources/ui/ground_assets/lha_red_damaged.svg delete mode 100644 resources/ui/ground_assets/lha_red_destination.svg delete mode 100644 resources/ui/ground_assets/lha_red_destroyed.svg create mode 100644 resources/ui/map/lib/milsymbol/milsymbol.development.js create mode 100644 resources/ui/map/lib/milsymbol/milsymbol.esm.js create mode 100644 resources/ui/map/lib/milsymbol/milsymbol.js create mode 100644 resources/ui/map/lib/milsymbol/milsymbol.js.map diff --git a/game/theater/controlpoint.py b/game/theater/controlpoint.py index 0635b358..3821adf2 100644 --- a/game/theater/controlpoint.py +++ b/game/theater/controlpoint.py @@ -27,12 +27,21 @@ from dcs.ships import Forrestal, KUZNECOW, LHA_Tarawa, Stennis, Type_071 from dcs.terrain.terrain import Airport, ParkingSlot from dcs.unitgroup import ShipGroup, StaticGroup +from game.ato.closestairfields import ObjectiveDistanceCache from game.ground_forces.combat_stance import CombatStance from game.point_with_heading import PointWithHeading from game.runways import RunwayAssigner, RunwayData from game.scenery_group import SceneryGroup +from game.sidc import ( + Entity, + LandInstallationEntity, + SeaSurfaceEntity, + StandardIdentity, + Status, + SymbolIdentificationCode, + SymbolSet, +) from game.utils import Heading -from game.ato.closestairfields import ObjectiveDistanceCache from .base import Base from .missiontarget import MissionTarget from .theatergroundobject import ( @@ -342,6 +351,29 @@ class ControlPoint(MissionTarget, ABC): def captured(self) -> bool: return self.coalition.player + def sidc(self) -> SymbolIdentificationCode: + iff = ( + StandardIdentity.FRIEND if self.captured else StandardIdentity.HOSTILE_FAKER + ) + + if self.status is ControlPointStatus.Functional: + status = Status.PRESENT + elif self.status is ControlPointStatus.Damaged: + status = Status.PRESENT_DAMAGED + elif self.status is ControlPointStatus.Destroyed: + status = Status.PRESENT_DESTROYED + else: + raise ValueError(f"Unexpected ControlPointStatus: {self.status}") + + symbol_set, entity = self.symbol_set_and_entity() + return SymbolIdentificationCode( + standard_identity=iff, symbol_set=symbol_set, status=status, entity=entity + ) + + @abstractmethod + def symbol_set_and_entity(self) -> tuple[SymbolSet, Entity]: + ... + @property def ground_objects(self) -> List[TheaterGroundObject]: return list(self.connected_objectives) @@ -875,6 +907,9 @@ class Airfield(ControlPoint): self.airport = airport self._runway_status = RunwayStatus() + def symbol_set_and_entity(self) -> tuple[SymbolSet, Entity]: + return SymbolSet.LAND_INSTALLATIONS, LandInstallationEntity.AIPORT_AIR_BASE + def can_operate(self, aircraft: AircraftType) -> bool: # TODO: Allow helicopters. # Need to implement ground spawns so the helos don't use the runway. @@ -1058,6 +1093,9 @@ class Carrier(NavalControlPoint): cptype=ControlPointType.AIRCRAFT_CARRIER_GROUP, ) + def symbol_set_and_entity(self) -> tuple[SymbolSet, Entity]: + return SymbolSet.SEA_SURFACE, SeaSurfaceEntity.CARRIER + def mission_types(self, for_player: bool) -> Iterator[FlightType]: from game.ato import FlightType @@ -1099,6 +1137,9 @@ class Lha(NavalControlPoint): cptype=ControlPointType.LHA_GROUP, ) + def symbol_set_and_entity(self) -> tuple[SymbolSet, Entity]: + return SymbolSet.SEA_SURFACE, SeaSurfaceEntity.AMPHIBIOUS_ASSAULT_SHIP_GENERAL + def capture(self, game: Game, for_player: bool) -> None: raise RuntimeError("LHAs cannot be captured") @@ -1133,6 +1174,9 @@ class OffMapSpawn(ControlPoint): cptype=ControlPointType.OFF_MAP, ) + def symbol_set_and_entity(self) -> tuple[SymbolSet, Entity]: + return SymbolSet.LAND_INSTALLATIONS, LandInstallationEntity.AIPORT_AIR_BASE + def capture(self, game: Game, for_player: bool) -> None: raise RuntimeError("Off map control points cannot be captured") @@ -1195,6 +1239,9 @@ class Fob(ControlPoint): ) self.name = name + def symbol_set_and_entity(self) -> tuple[SymbolSet, Entity]: + return SymbolSet.LAND_INSTALLATIONS, LandInstallationEntity.MILITARY_BASE + def runway_is_operational(self) -> bool: return self.has_helipads diff --git a/qt_ui/widgets/map/model/controlpointjs.py b/qt_ui/widgets/map/model/controlpointjs.py index 7f505bc6..204f5d4a 100644 --- a/qt_ui/widgets/map/model/controlpointjs.py +++ b/qt_ui/widgets/map/model/controlpointjs.py @@ -7,7 +7,7 @@ from dcs import Point from dcs.mapping import LatLng from game.server.leaflet import LeafletLatLon -from game.theater import ConflictTheater, ControlPoint, ControlPointStatus +from game.theater import ConflictTheater, ControlPoint from game.utils import meters, nautical_miles from qt_ui.dialogs import Dialog from qt_ui.models import GameModel @@ -22,8 +22,7 @@ class ControlPointJs(QObject): positionChanged = Signal() mobileChanged = Signal() destinationChanged = Signal(list) - categoryChanged = Signal() - statusChanged = Signal() + sidcChanged = Signal() def __init__( self, @@ -45,20 +44,9 @@ class ControlPointJs(QObject): def blue(self) -> bool: return self.control_point.captured - @Property(str, notify=categoryChanged) - def category(self) -> str: - return self.control_point.category - - @Property(str, notify=statusChanged) - def status(self) -> str: - status = self.control_point.status - if status is ControlPointStatus.Functional: - return "alive" - elif status is ControlPointStatus.Damaged: - return "damaged" - elif status is ControlPointStatus.Destroyed: - return "destroyed" - raise ValueError(f"Unhandled ControlPointStatus: {status.name}") + @Property(str, notify=sidcChanged) + def sidc(self) -> str: + return str(self.control_point.sidc()) @Property(list, notify=positionChanged) def position(self) -> LeafletLatLon: diff --git a/resources/ui/ground_assets/airfield_blue_alive.svg b/resources/ui/ground_assets/airfield_blue_alive.svg deleted file mode 100644 index dcc9a38e..00000000 --- a/resources/ui/ground_assets/airfield_blue_alive.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/airfield_blue_damaged.svg b/resources/ui/ground_assets/airfield_blue_damaged.svg deleted file mode 100644 index 107f6b62..00000000 --- a/resources/ui/ground_assets/airfield_blue_damaged.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/airfield_blue_destroyed.svg b/resources/ui/ground_assets/airfield_blue_destroyed.svg deleted file mode 100644 index 7d49ff30..00000000 --- a/resources/ui/ground_assets/airfield_blue_destroyed.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/airfield_red_alive.svg b/resources/ui/ground_assets/airfield_red_alive.svg deleted file mode 100644 index 1b481dd0..00000000 --- a/resources/ui/ground_assets/airfield_red_alive.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/airfield_red_damaged.svg b/resources/ui/ground_assets/airfield_red_damaged.svg deleted file mode 100644 index 39693c44..00000000 --- a/resources/ui/ground_assets/airfield_red_damaged.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/airfield_red_destroyed.svg b/resources/ui/ground_assets/airfield_red_destroyed.svg deleted file mode 100644 index 1a2303a1..00000000 --- a/resources/ui/ground_assets/airfield_red_destroyed.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/cv_blue_alive.svg b/resources/ui/ground_assets/cv_blue_alive.svg deleted file mode 100644 index b7b50fda..00000000 --- a/resources/ui/ground_assets/cv_blue_alive.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/cv_blue_damaged.svg b/resources/ui/ground_assets/cv_blue_damaged.svg deleted file mode 100644 index 81cb15af..00000000 --- a/resources/ui/ground_assets/cv_blue_damaged.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/cv_blue_destination.svg b/resources/ui/ground_assets/cv_blue_destination.svg deleted file mode 100644 index 29f56749..00000000 --- a/resources/ui/ground_assets/cv_blue_destination.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/cv_blue_destroyed.svg b/resources/ui/ground_assets/cv_blue_destroyed.svg deleted file mode 100644 index ca7ffb57..00000000 --- a/resources/ui/ground_assets/cv_blue_destroyed.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/cv_red_alive.svg b/resources/ui/ground_assets/cv_red_alive.svg deleted file mode 100644 index 36c385b3..00000000 --- a/resources/ui/ground_assets/cv_red_alive.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/cv_red_damaged.svg b/resources/ui/ground_assets/cv_red_damaged.svg deleted file mode 100644 index af08402c..00000000 --- a/resources/ui/ground_assets/cv_red_damaged.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/cv_red_destination.svg b/resources/ui/ground_assets/cv_red_destination.svg deleted file mode 100644 index 32d06bc2..00000000 --- a/resources/ui/ground_assets/cv_red_destination.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/cv_red_destroyed.svg b/resources/ui/ground_assets/cv_red_destroyed.svg deleted file mode 100644 index 2c0ebb05..00000000 --- a/resources/ui/ground_assets/cv_red_destroyed.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/fob_blue.png b/resources/ui/ground_assets/fob_blue.png deleted file mode 100644 index d632caa3c2dd2719cc24edce123e818cf522a91c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 417 zcmV;S0bc%zP)K4{|4^&{kIDaVy8o}(|0kFK6OI4B;QxTa|3IVv6^{S^|Nj7l{|p85U;qFB`$C6fa8cAaMhPw($LH40W~(4-_T$S+Ap$gTs3wM?Z*nfB8l{}2!0*`*HBbO$RQ zU@>ips5UdphLPHHYJCS)rh9AJa;{I_K^<%dP|B>JnAkvOs{mz33J@Eh(DuarH1~JJ z5}|=K>nLS3CF&p@djU+DdQFaeKIR(g)lz}yL1_E_@qYXKZvqSepAJIr?ak`A00000 LNkvXXu0mjf@G-q4 diff --git a/resources/ui/ground_assets/fob_blue_alive.svg b/resources/ui/ground_assets/fob_blue_alive.svg deleted file mode 100644 index e78bbd81..00000000 --- a/resources/ui/ground_assets/fob_blue_alive.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/fob_blue_damaged.svg b/resources/ui/ground_assets/fob_blue_damaged.svg deleted file mode 100644 index c93ec0e6..00000000 --- a/resources/ui/ground_assets/fob_blue_damaged.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/fob_blue_destroyed.svg b/resources/ui/ground_assets/fob_blue_destroyed.svg deleted file mode 100644 index 4cc0764f..00000000 --- a/resources/ui/ground_assets/fob_blue_destroyed.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/fob_red_alive.svg b/resources/ui/ground_assets/fob_red_alive.svg deleted file mode 100644 index f6e1e238..00000000 --- a/resources/ui/ground_assets/fob_red_alive.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/fob_red_damaged.svg b/resources/ui/ground_assets/fob_red_damaged.svg deleted file mode 100644 index 72ff98f7..00000000 --- a/resources/ui/ground_assets/fob_red_damaged.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/fob_red_destroyed.svg b/resources/ui/ground_assets/fob_red_destroyed.svg deleted file mode 100644 index 0a00635a..00000000 --- a/resources/ui/ground_assets/fob_red_destroyed.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/ui/ground_assets/lha_blue_alive.svg b/resources/ui/ground_assets/lha_blue_alive.svg deleted file mode 100644 index e23f553e..00000000 --- a/resources/ui/ground_assets/lha_blue_alive.svg +++ /dev/null @@ -1 +0,0 @@ -LHA \ No newline at end of file diff --git a/resources/ui/ground_assets/lha_blue_damaged.svg b/resources/ui/ground_assets/lha_blue_damaged.svg deleted file mode 100644 index 28acacdb..00000000 --- a/resources/ui/ground_assets/lha_blue_damaged.svg +++ /dev/null @@ -1 +0,0 @@ -LHA \ No newline at end of file diff --git a/resources/ui/ground_assets/lha_blue_destination.svg b/resources/ui/ground_assets/lha_blue_destination.svg deleted file mode 100644 index 36869350..00000000 --- a/resources/ui/ground_assets/lha_blue_destination.svg +++ /dev/null @@ -1 +0,0 @@ -LHA \ No newline at end of file diff --git a/resources/ui/ground_assets/lha_blue_destroyed.svg b/resources/ui/ground_assets/lha_blue_destroyed.svg deleted file mode 100644 index 57f7440a..00000000 --- a/resources/ui/ground_assets/lha_blue_destroyed.svg +++ /dev/null @@ -1 +0,0 @@ -LHA \ No newline at end of file diff --git a/resources/ui/ground_assets/lha_red_alive.svg b/resources/ui/ground_assets/lha_red_alive.svg deleted file mode 100644 index 4291cd24..00000000 --- a/resources/ui/ground_assets/lha_red_alive.svg +++ /dev/null @@ -1 +0,0 @@ -LHA \ No newline at end of file diff --git a/resources/ui/ground_assets/lha_red_damaged.svg b/resources/ui/ground_assets/lha_red_damaged.svg deleted file mode 100644 index 51929837..00000000 --- a/resources/ui/ground_assets/lha_red_damaged.svg +++ /dev/null @@ -1 +0,0 @@ -LHA \ No newline at end of file diff --git a/resources/ui/ground_assets/lha_red_destination.svg b/resources/ui/ground_assets/lha_red_destination.svg deleted file mode 100644 index 9c971136..00000000 --- a/resources/ui/ground_assets/lha_red_destination.svg +++ /dev/null @@ -1 +0,0 @@ -LHA \ No newline at end of file diff --git a/resources/ui/ground_assets/lha_red_destroyed.svg b/resources/ui/ground_assets/lha_red_destroyed.svg deleted file mode 100644 index d8da7a5e..00000000 --- a/resources/ui/ground_assets/lha_red_destroyed.svg +++ /dev/null @@ -1 +0,0 @@ -LHA \ No newline at end of file diff --git a/resources/ui/map/canvas.html b/resources/ui/map/canvas.html index 965d4454..ab270ef6 100644 --- a/resources/ui/map/canvas.html +++ b/resources/ui/map/canvas.html @@ -18,6 +18,8 @@ + +