[kde-doc-english] [kigo/frameworks] /: Port to frameworks branch: mark last move stone
Frederik Schwarzer
schwarzer at kde.org
Fri Jan 8 02:44:07 UTC 2016
Git commit f12b894dc536a4c2a317d51b2191757e6437462d by Frederik Schwarzer, on behalf of Michal Humpula.
Committed on 08/01/2016 at 02:38.
Pushed by schwarzer into branch 'frameworks'.
Port to frameworks branch: mark last move stone
REVIEW: 125506
GUI: visually marking last move with slightly different stone
M +- -- data/themes/kigo_default.svgz
M +- -- data/themes/kigo_plain.svgz
M +5 -0 src/game/stone.cpp
M +2 -0 src/game/stone.h
M +6 -2 src/gui/graphicsview/gamescene.cpp
M +18 -0 src/gui/graphicsview/themerenderer.cpp
M +2 -0 src/gui/graphicsview/themerenderer.h
http://commits.kde.org/kigo/f12b894dc536a4c2a317d51b2191757e6437462d
diff --git a/data/themes/kigo_default.svgz b/data/themes/kigo_default.svgz
index 39a3989..38873d4 100644
Binary files a/data/themes/kigo_default.svgz and b/data/themes/kigo_default.svgz differ
diff --git a/data/themes/kigo_plain.svgz b/data/themes/kigo_plain.svgz
index 99a0dea..1009095 100644
Binary files a/data/themes/kigo_plain.svgz and b/data/themes/kigo_plain.svgz 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
More information about the kde-doc-english
mailing list