Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Games
Kajongg
Commits
1fed5fe3
Commit
1fed5fe3
authored
Apr 09, 2021
by
Wolfgang Rohdewald
Browse files
pylint: remove duplicate code by defining DrawOnTopMixin
parent
b62ad81a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/board.py
View file @
1fed5fe3
...
...
@@ -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"""
...
...
src/common.py
View file @
1fed5fe3
...
...
@@ -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
)
src/uiwall.py
View file @
1fed5fe3
...
...
@@ -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
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment