[kde-doc-english] [kigo] /: mark last move stone

Michal Humpula michal.humpula at hudrydum.cz
Wed Dec 2 18:26:12 UTC 2015


Git commit 26cb60513ed190bd73ec67a363b7fcb4e48c9caf by Michal Humpula.
Committed on 02/12/2015 at 18:24.
Pushed by michalhumpula into branch 'master'.

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/26cb60513ed190bd73ec67a363b7fcb4e48c9caf

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 a6d7b85..c6a000c 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 fb1ecfc..85c4093 100644
--- a/src/gui/graphicsview/gamescene.cpp
+++ b/src/gui/graphicsview/gamescene.cpp
@@ -120,13 +120,16 @@ void GameScene::updateStoneItems()
     QGraphicsPixmapItem *item;
     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::BlackStone, m_stonePixmapSize));
+        ThemeRenderer::Element element = (stone == lastStone) ? ThemeRenderer::BlackStoneLast : ThemeRenderer::BlackStone;
+        item = addPixmap(ThemeRenderer::self()->renderElement(element, m_stonePixmapSize));
         item->setZValue(2);
         int xOff = stone.x() >= 'I' ? stone.x() - 'A' - 1 : stone.x() - 'A';
         item->setPos(QPointF(m_gridRect.x() + xOff * m_cellSize - halfStoneSize + 1,
@@ -134,7 +137,8 @@ void GameScene::updateStoneItems()
         m_stoneItems.append(item);
     }
     foreach (const Stone &stone, m_game->stones(m_game->whitePlayer())) {
-        item = addPixmap(ThemeRenderer::self()->renderElement(ThemeRenderer::WhiteStone, m_stonePixmapSize));
+        ThemeRenderer::Element element = (stone == lastStone) ? ThemeRenderer::WhiteStoneLast : ThemeRenderer::WhiteStone;
+        item = addPixmap(ThemeRenderer::self()->renderElement(element, m_stonePixmapSize));
         item->setZValue(2);
         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 7411950..619f63d 100644
--- a/src/gui/graphicsview/themerenderer.cpp
+++ b/src/gui/graphicsview/themerenderer.cpp
@@ -114,6 +114,9 @@ QPixmap ThemeRenderer::renderElement(Element element, const QSize &size) const
         case WhiteStone:
             cacheName = QString("white_stone_%1x%2").arg(size.width()).arg(size.height());
             break;
+        case WhiteStoneLast:
+            cacheName = QString("white_stone_last_%1x%2").arg(size.width()).arg(size.height());
+            break;
         case WhiteStoneTransparent:
             cacheName = QString("white_stone_%1x%2_trans").arg(size.width()).arg(size.height());
             break;
@@ -123,6 +126,9 @@ QPixmap ThemeRenderer::renderElement(Element element, const QSize &size) const
         case BlackStone:
             cacheName = QString("black_stone_%1x%2").arg(size.width()).arg(size.height());
             break;
+        case BlackStoneLast:
+            cacheName = QString("black_stone_last_%1x%2").arg(size.width()).arg(size.height());
+            break;
         case BlackStoneTransparent:
             cacheName = QString("black_stone_%1x%2_trans").arg(size.width()).arg(size.height());
             break;
@@ -153,6 +159,9 @@ QPixmap ThemeRenderer::renderElement(Element element, const QSize &size) const
             case WhiteStone:
                 m_renderer->render(&p, "white_stone");
                 break;
+            case WhiteStoneLast:
+                m_renderer->render(&p, "white_stone_last");
+                break;
             case WhiteStoneTransparent:
                 p.setOpacity(0.5);
                 m_renderer->render(&p, "white_stone");
@@ -163,6 +172,9 @@ QPixmap ThemeRenderer::renderElement(Element element, const QSize &size) const
             case BlackStone:
                 m_renderer->render(&p, "black_stone");
                 break;
+            case BlackStoneLast:
+                m_renderer->render(&p, "black_stone_last");
+                break;
             case BlackStoneTransparent:
                 p.setOpacity(0.5);
                 m_renderer->render(&p, "black_stone");
@@ -195,6 +207,9 @@ QSize ThemeRenderer::elementSize(Element element) const
         case WhiteStone:
             sizeRect = m_renderer->boundsOnElement("white_stone");
             break;
+        case WhiteStoneLast:
+            sizeRect = m_renderer->boundsOnElement("white_stone");
+            break;
         case WhiteStoneTransparent:
             sizeRect = m_renderer->boundsOnElement("white_stone");
             break;
@@ -204,6 +219,9 @@ QSize ThemeRenderer::elementSize(Element element) const
         case BlackStone:
             sizeRect = m_renderer->boundsOnElement("black_stone");
             break;
+        case BlackStoneLast:
+            sizeRect = m_renderer->boundsOnElement("black_stone");
+            break;
         case BlackStoneTransparent:
             sizeRect = m_renderer->boundsOnElement("black_stone");
             break;
diff --git a/src/gui/graphicsview/themerenderer.h b/src/gui/graphicsview/themerenderer.h
index b53da35..95d2100 100644
--- a/src/gui/graphicsview/themerenderer.h
+++ b/src/gui/graphicsview/themerenderer.h
@@ -61,9 +61,11 @@ public:
         Board,
         HandicapMark,
         WhiteStone,
+        WhiteStoneLast,
         WhiteStoneTransparent,
         WhiteTerritory,
         BlackStone,
+        BlackStoneLast,
         BlackStoneTransparent,
         BlackTerritory,
         PlacementMarker


More information about the kde-doc-english mailing list