mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix artifact on map when drawing events & improved base menu
This commit is contained in:
@@ -27,6 +27,7 @@ class QLiberationMap(QGraphicsView):
|
||||
"cp": True,
|
||||
"go": True,
|
||||
"lines": True,
|
||||
"events": True,
|
||||
"ennemy_sam_ranges": True,
|
||||
"ally_sam_ranges": True
|
||||
}
|
||||
@@ -200,6 +201,7 @@ class QLiberationMap(QGraphicsView):
|
||||
nonlocal occupied_rects
|
||||
point = self._transform_point(location)
|
||||
rect = QRect(point[0] - 16, point[1] - 16, 32, 32)
|
||||
print(rect)
|
||||
|
||||
i = 0
|
||||
while True:
|
||||
@@ -236,7 +238,7 @@ class QLiberationMap(QGraphicsView):
|
||||
location = self._frontline_center(event.from_cp, event.to_cp)
|
||||
|
||||
rect = _location_to_rect(location)
|
||||
scene.addItem(QMapEvent(self, rect.x(), rect.y(), rect.width(), rect.height(), event))
|
||||
scene.addItem(QMapEvent(self, rect.x(), rect.y(), 32, 32, event))
|
||||
|
||||
@staticmethod
|
||||
def set_display_rule(rule: str, value: bool):
|
||||
|
||||
@@ -52,14 +52,10 @@ class QMapControlPoint(QGraphicsRectItem):
|
||||
self.update()
|
||||
|
||||
def contextMenuEvent(self, event: QGraphicsSceneContextMenuEvent):
|
||||
# TODO : improve this and add contextual actions (just a placholder for now)
|
||||
|
||||
openBaseMenu = QAction("Open base menu")
|
||||
openBaseMenu.triggered.connect(self.openBaseMenu)
|
||||
|
||||
menu = QMenu("Menu", self.parent)
|
||||
menu.addAction("Plan a strike on " + self.model.name + " airbase")
|
||||
menu.addAction("See available intel")
|
||||
menu.addAction(openBaseMenu)
|
||||
menu.exec_(event.screenPos())
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from PySide2.QtGui import QPen
|
||||
from PySide2.QtWidgets import QGraphicsRectItem
|
||||
from PySide2.QtWidgets import QGraphicsRectItem, QGraphicsSceneMouseEvent
|
||||
|
||||
import qt_ui.uiconstants as CONST
|
||||
from game.event import Event
|
||||
from qt_ui.windows.QBriefingWindow import QBriefingWindow
|
||||
from theater import TheaterGroundObject, ControlPoint
|
||||
|
||||
|
||||
@@ -14,22 +15,29 @@ class QMapEvent(QGraphicsRectItem):
|
||||
self.parent = parent
|
||||
self.setAcceptHoverEvents(True)
|
||||
self.setZValue(2)
|
||||
print(x,y,w,h)
|
||||
self.setToolTip(str(self.gameEvent))
|
||||
|
||||
|
||||
def paint(self, painter, option, widget=None):
|
||||
|
||||
painter.save()
|
||||
if self.parent.get_display_rule("events"):
|
||||
painter.save()
|
||||
|
||||
if self.gameEvent.is_player_attacking:
|
||||
painter.setPen(QPen(brush=CONST.COLORS["blue"]))
|
||||
painter.setBrush(CONST.COLORS["blue"])
|
||||
else:
|
||||
painter.setPen(QPen(brush=CONST.COLORS["red"]))
|
||||
painter.setBrush(CONST.COLORS["red"])
|
||||
if self.gameEvent.is_player_attacking:
|
||||
painter.setPen(QPen(brush=CONST.COLORS["blue"]))
|
||||
painter.setBrush(CONST.COLORS["blue"])
|
||||
else:
|
||||
painter.setPen(QPen(brush=CONST.COLORS["red"]))
|
||||
painter.setBrush(CONST.COLORS["red"])
|
||||
|
||||
painter.drawRect(option.rect)
|
||||
painter.drawRect(option.rect)
|
||||
print(option.rect)
|
||||
painter.drawPixmap(option.rect, CONST.EVENT_ICONS[self.gameEvent.__class__])
|
||||
painter.restore()
|
||||
|
||||
painter.drawPixmap(option.rect, CONST.EVENT_ICONS[self.gameEvent.__class__])
|
||||
def mousePressEvent(self, event:QGraphicsSceneMouseEvent):
|
||||
self.openBriefing()
|
||||
|
||||
painter.restore()
|
||||
def openBriefing(self):
|
||||
self.briefing = QBriefingWindow(self.window(), self.gameEvent)
|
||||
self.briefing.show()
|
||||
Reference in New Issue
Block a user