Show events on map

This commit is contained in:
Khopa
2019-07-06 13:54:45 +02:00
parent 4e5e0a4a7a
commit 1776452964
6 changed files with 122 additions and 5 deletions

View 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()