ksquares
GameBoardScene Class Reference
#include <gameboardscene.h>

Detailed Description
Scene for displaying the game board.Created anew at the beginning of each game. Contains the visual representation of the board. Is used to interperet mouse clicks from the user (if the view is unlocked) Contains QGraphicsLineItems for lines, QGraphicsEllipseItems for the dots and QGraphicsRectItem for when a square is complete.
Definition at line 27 of file gameboardscene.h.
Public Slots | |
| void | disableEvents () |
| void | drawLine (int index, const QColor &colour) |
| void | drawSquare (int index, const QColor &colour) |
| void | enableEvents () |
| void | highlightLine (int index) |
Signals | |
| void | lineDrawn (int) |
| void | signalMoveRequest (int x1, int y1, int x2, int y2) |
Public Member Functions | |
| void | acknowledgeMove (int x1, int y1, int x2, int y2) |
| GameBoardScene (int newWidth, int newHeight, QObject *parent=0) | |
| const QSize | minimumSizeHint () const |
| ~GameBoardScene () | |
Protected Member Functions | |
| void | addLineToIndex (const QList< QGraphicsEllipseItem * > &pointPair) |
| QList< QGraphicsEllipseItem * > | getTwoNearestPoints (const QPointF &pos) const |
| int | indexFromPointPair (const QList< QGraphicsEllipseItem * > &pointPair) const |
| bool | isLineAlready (const QList< QGraphicsEllipseItem * > &pointPair) const |
| QLineF | lineFromIndex (int index) const |
| void | mouseMoveEvent (QGraphicsSceneMouseEvent *mouseEvent) |
| void | mouseReleaseEvent (QGraphicsSceneMouseEvent *mouseEvent) |
Protected Attributes | |
| bool | acceptEvents |
| int | height |
| QGraphicsLineItem * | indicatorLine |
| QList< bool > | lineList |
| int | QGraphicsEllipseItemType |
| int | spacing |
| int | width |
Constructor & Destructor Documentation
| GameBoardScene::GameBoardScene | ( | int | newWidth, | |
| int | newHeight, | |||
| QObject * | parent = 0 | |||
| ) |
Create a new gameboard scene with the appropriate size.
- Parameters:
-
newWidth the number of squares wide the board is newHeight the number of squares tall the board is parent passed to QGraphicsScene's constructor
Definition at line 22 of file gameboardscene.cpp.
| GameBoardScene::~GameBoardScene | ( | ) |
Member Function Documentation
| void GameBoardScene::acknowledgeMove | ( | int | x1, | |
| int | y1, | |||
| int | x2, | |||
| int | y2 | |||
| ) |
Definition at line 259 of file gameboardscene.cpp.
| void GameBoardScene::addLineToIndex | ( | const QList< QGraphicsEllipseItem * > & | pointPair | ) | [protected] |
Adds the line to the index for a specified pair of points.
- Parameters:
-
pointPair QList of (hopefully 2) QGraphicsEllipseItem*s
Definition at line 186 of file gameboardscene.cpp.
| void GameBoardScene::disableEvents | ( | ) | [inline, slot] |
| void GameBoardScene::drawLine | ( | int | index, | |
| const QColor & | colour | |||
| ) | [slot] |
Add the line to the scene so it shows up in the view.
- Parameters:
-
index the line-index of the line colour the colour of the line
Definition at line 83 of file gameboardscene.cpp.
| void GameBoardScene::drawSquare | ( | int | index, | |
| const QColor & | colour | |||
| ) | [slot] |
Fill a box to show it is owned be a particular player.
- Parameters:
-
index the square-index of the square colour the colour fill of the square
Definition at line 101 of file gameboardscene.cpp.
| void GameBoardScene::enableEvents | ( | ) | [inline, slot] |
| QList< QGraphicsEllipseItem * > GameBoardScene::getTwoNearestPoints | ( | const QPointF & | pos | ) | const [protected] |
Given a single location in the scene, gives the two nearest QGraphicsEllipseItem.
- Parameters:
-
pos the point in question
- Returns:
- QList of (hopefully 2) QGraphicsEllipseItem*s
Definition at line 195 of file gameboardscene.cpp.
| void GameBoardScene::highlightLine | ( | int | index | ) | [slot] |
Draw a temporary halo behind a line.
- Parameters:
-
index the line-index of the line
Definition at line 94 of file gameboardscene.cpp.
| int GameBoardScene::indexFromPointPair | ( | const QList< QGraphicsEllipseItem * > & | pointPair | ) | const [protected] |
Takes a pair of QGraphicsEllipseItems and finds the index that relates to the line that's between them.
- Parameters:
-
pointPair QList of (hopefully 2) QGraphicsEllipseItem*s
- Returns:
- the line-index
Definition at line 108 of file gameboardscene.cpp.
| bool GameBoardScene::isLineAlready | ( | const QList< QGraphicsEllipseItem * > & | pointPair | ) | const [protected] |
Given a pair of points, returns whether there is already a line there.
- Parameters:
-
pointPair QList of (hopefully 2) QGraphicsEllipseItem*s
- Returns:
- trur if there is a line there
Definition at line 177 of file gameboardscene.cpp.
| void GameBoardScene::lineDrawn | ( | int | ) | [signal] |
Emits the index of the closet (undrawn) line when a click is detected.
| QLineF GameBoardScene::lineFromIndex | ( | int | index | ) | const [protected] |
Takes a line-index and returns a QLineF located at that position.
- Parameters:
-
index the line-index
- Returns:
- line located at the correct position
Definition at line 148 of file gameboardscene.cpp.
| const QSize GameBoardScene::minimumSizeHint | ( | ) | const |
The smallest the view can be when 'auto-zoom' is off.
- Returns:
- the minimum size the view should be
Definition at line 216 of file gameboardscene.cpp.
| void GameBoardScene::mouseMoveEvent | ( | QGraphicsSceneMouseEvent * | mouseEvent | ) | [protected] |
| void GameBoardScene::mouseReleaseEvent | ( | QGraphicsSceneMouseEvent * | mouseEvent | ) | [protected] |
| void GameBoardScene::signalMoveRequest | ( | int | x1, | |
| int | y1, | |||
| int | x2, | |||
| int | y2 | |||
| ) | [signal] |
Emits a move request in a network game.
Member Data Documentation
bool GameBoardScene::acceptEvents [protected] |
This property holds whether mouse events are enabled for this widget.
Definition at line 121 of file gameboardscene.h.
int GameBoardScene::height [protected] |
QGraphicsLineItem* GameBoardScene::indicatorLine [protected] |
QList<bool> GameBoardScene::lineList [protected] |
int GameBoardScene::QGraphicsEllipseItemType [protected] |
int GameBoardScene::spacing [protected] |
int GameBoardScene::width [protected] |
The documentation for this class was generated from the following files:
KDE 4.1 API Reference