Commit 1fed5fe3 authored by Wolfgang Rohdewald's avatar Wolfgang Rohdewald
Browse files

pylint: remove duplicate code by defining DrawOnTopMixin

parent b62ad81a
......@@ -26,11 +26,11 @@ from util import stack, uniqueList
from log import logDebug, logException
from mi18n import i18n, i18nc
from common import LIGHTSOURCES, Internal, Debug, isAlive, StrMixin
from common import ZValues
from common import DrawOnTopMixin
from wind import Wind, East
class PlayerWind(AnimatedMixin, QGraphicsObject, StrMixin):
class PlayerWind(AnimatedMixin, QGraphicsObject, StrMixin, DrawOnTopMixin):
"""a round wind tile"""
......@@ -61,14 +61,6 @@ class PlayerWind(AnimatedMixin, QGraphicsObject, StrMixin):
scenePos = self.board.mapToScene(boardPos)
return {'pos': scenePos, 'rotation': sceneRotation(self.board)}
def setDrawingOrder(self):
"""we want the winds above all others"""
if self.activeAnimation.get('pos'):
movingZ = ZValues.movingZ
else:
movingZ = 0
self.setZValue(ZValues.markerZ + movingZ)
@property
def wind(self):
"""our wind"""
......
......@@ -497,3 +497,16 @@ class Speeds:
"""some fixed animation speeds"""
windMarker = 20
sideText = 60
class DrawOnTopMixin:
"""The inheriting QGraphicsObject will draw itself above all non moving tiles"""
def setDrawingOrder(self):
"""we want us above all non moving tiles"""
if self.activeAnimation.get('pos'):
movingZ = ZValues.movingZ
else:
movingZ = 0
self.setZValue(ZValues.markerZ + movingZ)
......@@ -7,7 +7,7 @@ SPDX-License-Identifier: GPL-2.0
"""
from common import Internal, ZValues, StrMixin, Speeds
from common import Internal, ZValues, StrMixin, Speeds, DrawOnTopMixin
from wind import Wind, East
from qt import QPointF, QGraphicsObject, QFontMetrics
from qt import QPen, QColor, QFont, Qt, QRectF
......@@ -22,7 +22,7 @@ from animation import animate, afterQueuedAnimations, AnimationSpeed
from animation import ParallelAnimationGroup, AnimatedMixin, animateAndDo
class SideText(AnimatedMixin, QGraphicsObject, StrMixin):
class SideText(AnimatedMixin, QGraphicsObject, StrMixin, DrawOnTopMixin):
"""The text written on the wall"""
......@@ -144,14 +144,6 @@ class SideText(AnimatedMixin, QGraphicsObject, StrMixin):
self.__boundingRect = QRectF(QFontMetrics(self.__font).boundingRect(txt))
self.needsRefresh = True
def setDrawingOrder(self):
"""we want the text above all non moving tiles"""
if self.activeAnimation.get('pos'):
movingZ = ZValues.movingZ
else:
movingZ = 0
self.setZValue(ZValues.markerZ + movingZ)
def paint(self, painter, unusedOption, unusedWidget=None):
"""paint the marker"""
with Painter(painter):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment