mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Added Polygon drawing mode for map background
This commit is contained in:
parent
9c58e73b39
commit
d95912322c
@ -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()
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"])
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user