mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Show events on map
This commit is contained in:
35
qt_ui/widgets/map/QMapEvent.py
Normal file
35
qt_ui/widgets/map/QMapEvent.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from PySide2.QtGui import QPen
|
||||
from PySide2.QtWidgets import QGraphicsRectItem
|
||||
|
||||
import qt_ui.uiconstants as CONST
|
||||
from game.event import Event
|
||||
from theater import TheaterGroundObject, ControlPoint
|
||||
|
||||
|
||||
class QMapEvent(QGraphicsRectItem):
|
||||
|
||||
def __init__(self, parent, x: float, y: float, w: float, h: float, gameEvent: Event):
|
||||
super(QMapEvent, self).__init__(x, y, w, h)
|
||||
self.gameEvent = gameEvent
|
||||
self.parent = parent
|
||||
self.setAcceptHoverEvents(True)
|
||||
self.setZValue(2)
|
||||
self.setToolTip(str(self.gameEvent))
|
||||
|
||||
|
||||
def paint(self, painter, option, widget=None):
|
||||
|
||||
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"])
|
||||
|
||||
painter.drawRect(option.rect)
|
||||
|
||||
painter.drawPixmap(option.rect, CONST.EVENT_ICONS[self.gameEvent.__class__])
|
||||
|
||||
painter.restore()
|
||||
Reference in New Issue
Block a user