summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Humpula <[email protected]>2015-10-03 16:34:02 +0200
committerFrederik Schwarzer <[email protected]>2016-01-08 03:38:56 +0100
commitf12b894dc536a4c2a317d51b2191757e6437462d (patch)
tree938199718863ed9e01cd5d9c21783bab603778c1
parenta907bc81cd89ec723c3aa2cf35362a6e6baf9b4e (diff)
Port to frameworks branch: mark last move stone
REVIEW: 125506 GUI: visually marking last move with slightly different stone
-rw-r--r--data/themes/kigo_default.svgzbin139164 -> 154660 bytes
-rw-r--r--data/themes/kigo_plain.svgzbin84905 -> 85175 bytes
-rw-r--r--src/game/stone.cpp5
-rw-r--r--src/game/stone.h2
-rw-r--r--src/gui/graphicsview/gamescene.cpp8
-rw-r--r--src/gui/graphicsview/themerenderer.cpp18
-rw-r--r--src/gui/graphicsview/themerenderer.h2
7 files changed, 33 insertions, 2 deletions
diff --git a/data/themes/kigo_default.svgz b/data/themes/kigo_default.svgz
index 39a3989..38873d4 100644
--- a/data/themes/kigo_default.svgz
+++ b/data/themes/kigo_default.svgz
Binary files differ
diff --git a/data/themes/kigo_plain.svgz b/data/themes/kigo_plain.svgz
index 99a0dea..1009095 100644
--- a/data/themes/kigo_plain.svgz
+++ b/data/themes/kigo_plain.svgz
Binary files differ
diff --git a/src/game/stone.cpp b/src/game/stone.cpp
index 653e8d1..b7c673a 100644
--- a/src/game/stone.cpp
+++ b/src/game/stone.cpp
@@ -77,4 +77,9 @@ QDebug operator<<(QDebug debug, const Stone &stone)
return debug;
}
+bool operator==(const Stone &stone, const Stone &other)
+{
+ return (stone.x() == other.x()) && (stone.y() == other.y());
+}
+
} // End of namespace Kigo
diff --git a/src/game/stone.h b/src/game/stone.h
index 2702c6b..3d85070 100644
--- a/src/game/stone.h
+++ b/src/game/stone.h
@@ -70,6 +70,8 @@ private:
QDebug operator<<(QDebug debug, const Stone &stone);
+bool operator==(const Stone &stone, const Stone &other);
+
} // End of namespace Kigo
#endif
diff --git a/src/gui/graphicsview/gamescene.cpp b/src/gui/graphicsview/gamescene.cpp
index ff66b3f..0800660 100644
--- a/src/gui/graphicsview/gamescene.cpp
+++ b/src/gui/graphicsview/gamescene.cpp
@@ -134,13 +134,16 @@ void GameScene::updateStoneItems()
QGraphicsPixmapItem *item;
const int halfStoneSize = m_stonePixmapSize.width() / 2;
+ const Stone lastStone = (m_game->moves().size() > 0) ? m_game->lastMove().stone() : Stone::Invalid;
+
foreach (item, m_stoneItems) { // Clear all stone items
removeItem(item);
}
m_stoneItems.clear();
foreach (const Stone &stone, m_game->stones(m_game->blackPlayer())) {
- item = addPixmap(ThemeRenderer::self()->renderElement(ThemeRenderer::Element::BlackStone, m_stonePixmapSize));
+ ThemeRenderer::Element element = (stone == lastStone) ? ThemeRenderer::Element::BlackStoneLast : ThemeRenderer::Element::BlackStone;
+ item = addPixmap(ThemeRenderer::self()->renderElement(element, m_stonePixmapSize));
item->setZValue(2);
const int xOff = stone.x() >= 'I' ? stone.x() - 'A' - 1 : stone.x() - 'A';
item->setPos(QPointF(m_gridRect.x() + xOff * m_cellSize - halfStoneSize + 1,
@@ -148,7 +151,8 @@ void GameScene::updateStoneItems()
m_stoneItems.append(item);
}
foreach (const Stone &stone, m_game->stones(m_game->whitePlayer())) {
- item = addPixmap(ThemeRenderer::self()->renderElement(ThemeRenderer::Element::WhiteStone, m_stonePixmapSize));
+ ThemeRenderer::Element element = (stone == lastStone) ? ThemeRenderer::Element::WhiteStoneLast : ThemeRenderer::Element::WhiteStone;
+ item = addPixmap(ThemeRenderer::self()->renderElement(element, m_stonePixmapSize));
item->setZValue(2);
const int xOff = stone.x() >= 'I' ? stone.x() - 'A' - 1 : stone.x() - 'A';
item->setPos(QPointF(m_gridRect.x() + xOff * m_cellSize - halfStoneSize + 1,
diff --git a/src/gui/graphicsview/themerenderer.cpp b/src/gui/graphicsview/themerenderer.cpp
index 82d0e32..076b8c7 100644
--- a/src/gui/graphicsview/themerenderer.cpp
+++ b/src/gui/graphicsview/themerenderer.cpp
@@ -112,6 +112,9 @@ QPixmap ThemeRenderer::renderElement(Element element, const QSize &size) const
case Element::WhiteStone:
cacheName = QStringLiteral("white_stone_%1x%2").arg(size.width()).arg(size.height());
break;
+ case Element::WhiteStoneLast:
+ cacheName = QStringLiteral("white_stone_last_%1x%2").arg(size.width()).arg(size.height());
+ break;
case Element::WhiteStoneTransparent:
cacheName = QStringLiteral("white_stone_%1x%2_trans").arg(size.width()).arg(size.height());
break;
@@ -121,6 +124,9 @@ QPixmap ThemeRenderer::renderElement(Element element, const QSize &size) const
case Element::BlackStone:
cacheName = QStringLiteral("black_stone_%1x%2").arg(size.width()).arg(size.height());
break;
+ case Element::BlackStoneLast:
+ cacheName = QStringLiteral("black_stone_last_%1x%2").arg(size.width()).arg(size.height());
+ break;
case Element::BlackStoneTransparent:
cacheName = QStringLiteral("black_stone_%1x%2_trans").arg(size.width()).arg(size.height());
break;
@@ -151,6 +157,9 @@ QPixmap ThemeRenderer::renderElement(Element element, const QSize &size) const
case Element::WhiteStone:
m_renderer->render(&p, QStringLiteral("white_stone"));
break;
+ case Element::WhiteStoneLast:
+ m_renderer->render(&p, QStringLiteral("white_stone_last"));
+ break;
case Element::WhiteStoneTransparent:
p.setOpacity(0.5);
m_renderer->render(&p, QStringLiteral("white_stone"));
@@ -161,6 +170,9 @@ QPixmap ThemeRenderer::renderElement(Element element, const QSize &size) const
case Element::BlackStone:
m_renderer->render(&p, QStringLiteral("black_stone"));
break;
+ case Element::BlackStoneLast:
+ m_renderer->render(&p, QStringLiteral("black_stone_last"));
+ break;
case Element::BlackStoneTransparent:
p.setOpacity(0.5);
m_renderer->render(&p, QStringLiteral("black_stone"));
@@ -193,6 +205,9 @@ QSize ThemeRenderer::elementSize(Element element) const
case Element::WhiteStone:
sizeRect = m_renderer->boundsOnElement(QStringLiteral("white_stone"));
break;
+ case Element::WhiteStoneLast:
+ sizeRect = m_renderer->boundsOnElement(QStringLiteral("white_stone"));
+ break;
case Element::WhiteStoneTransparent:
sizeRect = m_renderer->boundsOnElement(QStringLiteral("white_stone"));
break;
@@ -202,6 +217,9 @@ QSize ThemeRenderer::elementSize(Element element) const
case Element::BlackStone:
sizeRect = m_renderer->boundsOnElement(QStringLiteral("black_stone"));
break;
+ case Element::BlackStoneLast:
+ sizeRect = m_renderer->boundsOnElement(QStringLiteral("black_stone"));
+ break;
case Element::BlackStoneTransparent:
sizeRect = m_renderer->boundsOnElement(QStringLiteral("black_stone"));
break;
diff --git a/src/gui/graphicsview/themerenderer.h b/src/gui/graphicsview/themerenderer.h
index b82e100..66237b8 100644
--- a/src/gui/graphicsview/themerenderer.h
+++ b/src/gui/graphicsview/themerenderer.h
@@ -60,9 +60,11 @@ public:
Board,
HandicapMark,
WhiteStone,
+ WhiteStoneLast,
WhiteStoneTransparent,
WhiteTerritory,
BlackStone,
+ BlackStoneLast,
BlackStoneTransparent,
BlackTerritory,
PlacementMarker