From 9c58e73b39326a5b1b0e15567dfb1cfcf4cd01ec Mon Sep 17 00:00:00 2001 From: Khopa Date: Mon, 12 Oct 2020 18:12:45 +0200 Subject: [PATCH 1/5] Added more display options for SAMS --- qt_ui/displayoptions.py | 4 +++- qt_ui/widgets/map/QLiberationMap.py | 16 +++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/qt_ui/displayoptions.py b/qt_ui/displayoptions.py index 1efa13ae..6d9f5baf 100644 --- a/qt_ui/displayoptions.py +++ b/qt_ui/displayoptions.py @@ -51,7 +51,9 @@ class DisplayOptions: control_points = DisplayRule("Control Points", True) lines = DisplayRule("Lines", True) events = DisplayRule("Events", True) - sam_ranges = DisplayRule("SAM Ranges", True) + sam_ranges = DisplayRule("Ally SAM Threat Range", False) + enemy_sam_ranges = DisplayRule("Enemy SAM Threat Range", True) + detection_range = DisplayRule("SAM Detection Range", False) waypoint_info = DisplayRule("Waypoint Information", True) flight_paths = FlightPathOptions() diff --git a/qt_ui/widgets/map/QLiberationMap.py b/qt_ui/widgets/map/QLiberationMap.py index 3c0064f9..b6a78027 100644 --- a/qt_ui/widgets/map/QLiberationMap.py +++ b/qt_ui/widgets/map/QLiberationMap.py @@ -49,7 +49,7 @@ class QLiberationMap(QGraphicsView): # A tuple of (package index, flight index), or none. self.selected_flight: Optional[Tuple[int, int]] = None - self.setMinimumSize(800,600) + self.setMinimumSize(800, 600) self.setMaximumHeight(2160) self._zoom = 0 self.factor = 1 @@ -99,8 +99,6 @@ class QLiberationMap(QGraphicsView): if self.game is not None: self.reload_scene() - - """ Uncomment to set up theather reference points @@ -175,14 +173,17 @@ class QLiberationMap(QGraphicsView): if ground_object.obj_name in added_objects: continue - go_pos = self._transform_point(ground_object.position) if not ground_object.airbase_group: 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)) is_aa = ground_object.category == "aa" - if is_aa and DisplayOptions.sam_ranges: + should_display = ((DisplayOptions.sam_ranges and cp.captured) + or + (DisplayOptions.enemy_sam_ranges and not cp.captured)) + + if is_aa and should_display: threat_range = 0 detection_range = 0 can_fire = False @@ -205,8 +206,9 @@ class QLiberationMap(QGraphicsView): detection_radius = Point(*go_pos).distance_to_point(Point(*detection_pos)) # Add detection range circle - scene.addEllipse(go_pos[0] - detection_radius/2 + 7, go_pos[1] - detection_radius/2 + 6, - detection_radius, detection_radius, self.detection_pen(cp.captured)) + if DisplayOptions.detection_range: + scene.addEllipse(go_pos[0] - detection_radius/2 + 7, go_pos[1] - detection_radius/2 + 6, + detection_radius, detection_radius, self.detection_pen(cp.captured)) # Add threat range circle scene.addEllipse(go_pos[0] - threat_radius / 2 + 7, go_pos[1] - threat_radius / 2 + 6, From d95912322c0660dff6afd36980519618e0bc0e80 Mon Sep 17 00:00:00 2001 From: Khopa Date: Mon, 12 Oct 2020 18:48:50 +0200 Subject: [PATCH 2/5] Added Polygon drawing mode for map background --- qt_ui/displayoptions.py | 1 + qt_ui/uiconstants.py | 5 +++ qt_ui/widgets/map/QLiberationMap.py | 53 ++++++++++++++++++----------- 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/qt_ui/displayoptions.py b/qt_ui/displayoptions.py index 6d9f5baf..c92f1577 100644 --- a/qt_ui/displayoptions.py +++ b/qt_ui/displayoptions.py @@ -54,6 +54,7 @@ class DisplayOptions: sam_ranges = DisplayRule("Ally SAM Threat Range", False) enemy_sam_ranges = DisplayRule("Enemy SAM Threat Range", True) detection_range = DisplayRule("SAM Detection Range", False) + map_poly = DisplayRule("Map Polygon Debug Mode", False) waypoint_info = DisplayRule("Waypoint Information", True) flight_paths = FlightPathOptions() diff --git a/qt_ui/uiconstants.py b/qt_ui/uiconstants.py index 4dff2c0a..c138cf34 100644 --- a/qt_ui/uiconstants.py +++ b/qt_ui/uiconstants.py @@ -49,6 +49,7 @@ COLORS: Dict[str, QColor] = { "super_red": QColor(227, 32, 0), "green": QColor(128, 186, 128), + "light_green": QColor(223, 255, 173), "bright_green": QColor(64, 200, 64), "black": QColor(0, 0, 0), @@ -59,6 +60,10 @@ COLORS: Dict[str, QColor] = { "night_overlay": QColor(12, 20, 69), "dawn_dust_overlay": QColor(46, 38, 85), + "grey": QColor(150, 150, 150), + "dark_grey": QColor(75, 75, 75), + "dark_dark_grey": QColor(48, 48, 48), + } CP_SIZE = 12 diff --git a/qt_ui/widgets/map/QLiberationMap.py b/qt_ui/widgets/map/QLiberationMap.py index b6a78027..ea0cee56 100644 --- a/qt_ui/widgets/map/QLiberationMap.py +++ b/qt_ui/widgets/map/QLiberationMap.py @@ -4,8 +4,8 @@ import datetime import logging from typing import List, Optional, Tuple -from PySide2.QtCore import Qt -from PySide2.QtGui import QBrush, QColor, QPen, QPixmap, QWheelEvent +from PySide2.QtCore import Qt, QPointF +from PySide2.QtGui import QBrush, QColor, QPen, QPixmap, QWheelEvent, QPolygonF from PySide2.QtWidgets import ( QFrame, QGraphicsItem, @@ -470,23 +470,36 @@ class QLiberationMap(QGraphicsView): def addBackground(self): scene = self.scene() - bg = QPixmap("./resources/" + self.game.theater.overview_image) - scene.addPixmap(bg) + if not DisplayOptions.map_poly: + bg = QPixmap("./resources/" + self.game.theater.overview_image) + scene.addPixmap(bg) + + # Apply graphical effects to simulate current daytime + if self.game.current_turn_daytime == "day": + pass + elif self.game.current_turn_daytime == "night": + ov = QPixmap(bg.width(), bg.height()) + ov.fill(CONST.COLORS["night_overlay"]) + overlay = scene.addPixmap(ov) + effect = QGraphicsOpacityEffect() + effect.setOpacity(0.7) + overlay.setGraphicsEffect(effect) + else: + ov = QPixmap(bg.width(), bg.height()) + ov.fill(CONST.COLORS["dawn_dust_overlay"]) + overlay = scene.addPixmap(ov) + effect = QGraphicsOpacityEffect() + effect.setOpacity(0.3) + overlay.setGraphicsEffect(effect) - # Apply graphical effects to simulate current daytime - if self.game.current_turn_daytime == "day": - pass - elif self.game.current_turn_daytime == "night": - ov = QPixmap(bg.width(), bg.height()) - ov.fill(CONST.COLORS["night_overlay"]) - overlay = scene.addPixmap(ov) - effect = QGraphicsOpacityEffect() - effect.setOpacity(0.7) - overlay.setGraphicsEffect(effect) else: - ov = QPixmap(bg.width(), bg.height()) - ov.fill(CONST.COLORS["dawn_dust_overlay"]) - overlay = scene.addPixmap(ov) - effect = QGraphicsOpacityEffect() - effect.setOpacity(0.3) - overlay.setGraphicsEffect(effect) + # Polygon display mode + for inclusion_zone in self.game.theater.landmap[0]: + poly = QPolygonF([QPointF(*self._transform_point(Point(point[0], point[1]))) for point in inclusion_zone]) + scene.addPolygon(poly, CONST.COLORS["grey"], CONST.COLORS["dark_grey"]) + + for exclusion_zone in self.game.theater.landmap[1]: + poly = QPolygonF([QPointF(*self._transform_point(Point(point[0], point[1]))) for point in exclusion_zone]) + scene.addPolygon(poly, CONST.COLORS["grey"], CONST.COLORS["dark_dark_grey"]) + + From 5a245bf362a510355a53692a297e59cf19bc1bc1 Mon Sep 17 00:00:00 2001 From: Khopa Date: Mon, 12 Oct 2020 18:53:15 +0200 Subject: [PATCH 3/5] Fixed crash in polygon display mode for Nevada map. --- qt_ui/widgets/map/QLiberationMap.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/qt_ui/widgets/map/QLiberationMap.py b/qt_ui/widgets/map/QLiberationMap.py index ea0cee56..cd61d310 100644 --- a/qt_ui/widgets/map/QLiberationMap.py +++ b/qt_ui/widgets/map/QLiberationMap.py @@ -494,12 +494,14 @@ class QLiberationMap(QGraphicsView): else: # Polygon display mode - for inclusion_zone in self.game.theater.landmap[0]: - poly = QPolygonF([QPointF(*self._transform_point(Point(point[0], point[1]))) for point in inclusion_zone]) - scene.addPolygon(poly, CONST.COLORS["grey"], CONST.COLORS["dark_grey"]) + if self.game.theater.landmap is not None: - for exclusion_zone in self.game.theater.landmap[1]: - poly = QPolygonF([QPointF(*self._transform_point(Point(point[0], point[1]))) for point in exclusion_zone]) - scene.addPolygon(poly, CONST.COLORS["grey"], CONST.COLORS["dark_dark_grey"]) + for inclusion_zone in self.game.theater.landmap[0]: + poly = QPolygonF([QPointF(*self._transform_point(Point(point[0], point[1]))) for point in inclusion_zone]) + scene.addPolygon(poly, CONST.COLORS["grey"], CONST.COLORS["dark_grey"]) + + for exclusion_zone in self.game.theater.landmap[1]: + poly = QPolygonF([QPointF(*self._transform_point(Point(point[0], point[1]))) for point in exclusion_zone]) + scene.addPolygon(poly, CONST.COLORS["grey"], CONST.COLORS["dark_dark_grey"]) From 411e71b9a26b4587392ee726efca4a7753565064 Mon Sep 17 00:00:00 2001 From: Khopa Date: Mon, 12 Oct 2020 20:57:32 +0200 Subject: [PATCH 4/5] Added setting to display culling distance --- game/game.py | 7 +++++++ qt_ui/displayoptions.py | 1 + qt_ui/uiconstants.py | 1 + qt_ui/widgets/map/QLiberationMap.py | 11 +++++++++++ 4 files changed, 20 insertions(+) diff --git a/game/game.py b/game/game.py index 57fabfd6..dcac8220 100644 --- a/game/game.py +++ b/game/game.py @@ -421,6 +421,13 @@ class Game: return False return True + def get_culling_points(self): + """ + Check culling points + :return: List of culling points + """ + return self.__culling_points + # 1 = red, 2 = blue def get_player_coalition_id(self): return 2 diff --git a/qt_ui/displayoptions.py b/qt_ui/displayoptions.py index c92f1577..bec194fb 100644 --- a/qt_ui/displayoptions.py +++ b/qt_ui/displayoptions.py @@ -56,6 +56,7 @@ class DisplayOptions: detection_range = DisplayRule("SAM Detection Range", False) map_poly = DisplayRule("Map Polygon Debug Mode", False) waypoint_info = DisplayRule("Waypoint Information", True) + culling = DisplayRule("Display Culling Zones", False) flight_paths = FlightPathOptions() @classmethod diff --git a/qt_ui/uiconstants.py b/qt_ui/uiconstants.py index c138cf34..31e4901f 100644 --- a/qt_ui/uiconstants.py +++ b/qt_ui/uiconstants.py @@ -50,6 +50,7 @@ COLORS: Dict[str, QColor] = { "green": QColor(128, 186, 128), "light_green": QColor(223, 255, 173), + "light_green_transparent": QColor(180, 255, 140, 50), "bright_green": QColor(64, 200, 64), "black": QColor(0, 0, 0), diff --git a/qt_ui/widgets/map/QLiberationMap.py b/qt_ui/widgets/map/QLiberationMap.py index cd61d310..568d66ac 100644 --- a/qt_ui/widgets/map/QLiberationMap.py +++ b/qt_ui/widgets/map/QLiberationMap.py @@ -152,6 +152,17 @@ class QLiberationMap(QGraphicsView): # text = scene.addText(str(r), font=QFont("Trebuchet MS", 10, weight=5, italic=False)) # text.setPos(0, i * 24) + # Display Culling + if DisplayOptions.culling and self.game.settings.perf_culling: + culling_points = self.game_model.game.get_culling_points() + culling_distance = self.game_model.game.settings.perf_culling_distance + for point in culling_points: + culling_distance_point = Point(point.x + culling_distance*1000, point.y + culling_distance*1000) + distance_point = self._transform_point(culling_distance_point) + transformed = self._transform_point(point) + diameter = distance_point[0] - transformed[0] + scene.addEllipse(transformed[0]-diameter/2, transformed[1]-diameter/2, diameter, diameter, CONST.COLORS["transparent"], CONST.COLORS["light_green_transparent"]) + for cp in self.game.theater.controlpoints: pos = self._transform_point(cp.position) From 883a66a792b0c5344f35ecc6301dda947556892f Mon Sep 17 00:00:00 2001 From: Khopa Date: Tue, 13 Oct 2020 00:35:27 +0200 Subject: [PATCH 5/5] Fix : Added missing channel.json file --- resources/dcs/beacons/thechannel.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 resources/dcs/beacons/thechannel.json diff --git a/resources/dcs/beacons/thechannel.json b/resources/dcs/beacons/thechannel.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/resources/dcs/beacons/thechannel.json @@ -0,0 +1 @@ +[] \ No newline at end of file