2
Copyright 2008 Sascha Peilicke <sasch.pe@gmx.de>
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License or (at your option) version 3 or any later version
8
accepted by the membership of KDE e.V. (or its successor approved
9
by the membership of KDE e.V.), which shall act as a proxy
10
defined in Section 14 of version 3 of the license.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#ifndef KIGO_GAMESCENE_H
22
#define KIGO_GAMESCENE_H
24
#include <KGamePopupItem>
26
#include <QGraphicsScene>
33
* This class provides a graphical representation of the go game using
36
* It displays the go board in its current state, receives mouse events,
37
* translates them and interacts with the Game. It also drives the game
38
* flow, i.e. tells game when to make the next move.
40
* @author Sascha Peilicke <sasch.pe@gmx.de>
43
class GameScene : public QGraphicsScene
48
explicit GameScene(Game *game, QObject *parent = 0);
51
void cursorPixmapChanged(const QPixmap &);
54
void resizeScene(int width, int height);
55
void showLabels(bool show);
56
void showHint(bool show);
57
void showMoveNumbers(bool show);
58
void showMessage(const QString &message, int msecs = 2000);
59
void showPlacementMarker(bool show);
60
void showTerritory(bool show);
63
void updateStoneItems();
64
void updateHintItems();
65
void updateTerritoryItems();
66
void changeBoardSize(int size);
67
void hideHint() { showHint(false); }
71
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
72
void mousePressEvent(QGraphicsSceneMouseEvent *event);
73
void drawBackground(QPainter *painter, const QRectF &);
75
Game *m_game; ///< Go game
77
KGamePopupItem m_gamePopup;
78
bool m_showLabels; ///< Show board labels or not
80
bool m_showMoveNumbers;
81
bool m_showPlacementMarker;
83
QRectF m_boardRect; ///< Position of board in the scene
84
QRectF m_mouseRect; ///< Board mouse interaction rect
85
QRectF m_gridRect; ///< Board grid rect
86
int m_cellSize; ///< Width of board grid cell
87
QSize m_stonePixmapSize; ///< Size of Go stone pixmap
88
QSize m_placementMarkerPixmapSize;
89
int m_boardSize; ///< Go board size (9, 13, 19, ..)
90
QGraphicsPixmapItem *m_placementMarkerItem;
92
QList<QGraphicsPixmapItem *> m_stoneItems;
93
QList<QGraphicsPixmapItem *> m_hintItems;
94
QList<QGraphicsPixmapItem *> m_territoryItems;
97
} // End of namespace Kigo