Commit 8407f1b2 authored by Wolfgang Rohdewald's avatar Wolfgang Rohdewald
Browse files

Tiles in scoring dialog now show correctly when shadows are enabled

parent efb1fc47
......@@ -400,9 +400,11 @@ class Board(QGraphicsRectItem, StrMixin):
lightSourceIndex = (lightSourceIndex + sceneRotation(self) // 90) % 4
return LIGHTSOURCES[lightSourceIndex]
def tileFacePos(self):
def tileFacePos(self, showShadows=None):
"""the face pos of a uiTile relative to its origin"""
if not Internal.Preferences.showShadows:
if showShadows is None:
showShadows = Internal.Preferences.showShadows
if not showShadows:
return QPointF()
lightSource = self.rotatedLightSource()
xoffset = self.tileset.shadowWidth() - 1 if 'E' in lightSource else 0
......
......@@ -154,18 +154,22 @@ class UITile(AnimatedMixin, QGraphicsObject, StrMixin):
else self.tileset.faceSize)
return self._boundingRect
def facePos(self):
def facePos(self, showShadows=None):
"""return the face position relative to the tile
depend on tileset, lightSource and shadow"""
return self.board.tileFacePos()
if showShadows is None:
showShadows = Internal.Preferences.showShadows
return self.board.tileFacePos(showShadows)
def showFace(self):
"""should we show face for this tile?"""
return self.tile.isKnown
def __elementId(self):
def __elementId(self, showShadows=None):
"""return the SVG element id of the tile"""
if not Internal.Preferences.showShadows:
if showShadows is None:
showShadows = Internal.Preferences.showShadows
if not showShadows:
return "TILE_2"
lightSourceIndex = LIGHTSOURCES.index(self.board.rotatedLightSource())
return "TILE_{}".format(lightSourceIndex % 4 + 1)
......@@ -227,11 +231,11 @@ class UITile(AnimatedMixin, QGraphicsObject, StrMixin):
except ZeroDivisionError:
xScale = 1
yScale = 1
# draw the tile too far to the left/upper side such that its shadow is outside of the print region
if not withBorders:
painter.scale(*self.tileset.tileFaceRelation())
painter.translate(-self.facePos())
renderer = self.tileset.renderer()
renderer.render(painter, self.__elementId())
renderer.render(painter, self.__elementId(showShadows=withBorders))
painter.resetTransform()
self._drawDarkness(painter)
if self.showFace():
......@@ -239,7 +243,8 @@ class UITile(AnimatedMixin, QGraphicsObject, StrMixin):
faceSize = QSize(
int(faceSize.width() * xScale),
int(faceSize.height() * yScale))
painter.translate(self.facePos())
painter.resetTransform()
painter.translate(self.facePos(withBorders))
renderer.render(painter, self.tileset.svgName[self.tile.exposed],
QRectF(QPointF(), QSizeF(faceSize)))
return result
......
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