Some other refactoring work.
[tagua.git] / src / graphicalposition.h
blob7f8efd0455ecfc0d6ba8911722915ffd1bfe6ab8
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef GRAPHICALPOSITION_H
12 #define GRAPHICALPOSITION_H
14 #include <boost/shared_ptr.hpp>
15 #include "grid.h"
17 class PieceSprite;
18 namespace Canvas { class Abstract; }
20 /**
21 * @class GraphicalPosition <graphicalposition.h>
22 * @brief The graphical position interface exported to the variant specific code.
24 * This class provides the variant's animator the facilites requires to add/remove
25 * pieces to and from the board, creating and destroying the related sprites.
27 class GraphicalPosition {
28 protected:
29 virtual ~GraphicalPosition() {}
31 public:
32 typedef boost::shared_ptr<PieceSprite> SpritePtr;
34 /** Returns a settings relative to this position */
35 virtual int getIntSetting(const QString& key, int def_value) const = 0;
37 /** Returns a settings relative to this position */
38 virtual bool getBoolSetting(const QString& key, bool def_value) const = 0;
40 /** Returns a settings relative to this position */
41 virtual QString getStringSetting(const QString& key, const QString& def_value) const = 0;
43 /** Returns the piece sprite at the given position */
44 virtual SpritePtr getSprite(const Point& p) const = 0;
46 /** Puts a piece at the given position, creating a piece sprite if needed.
47 If @p usedrop is true, and a piece have just been dropped, it will be
48 used if possible (it has the correct id). The @p show parameter controls
49 if the new sprite will be showed. */
50 virtual SpritePtr setPiece(const Point& p, AbstractPiece::Ptr e,
51 bool usedrop = false, bool show = false) = 0;
53 /** Gets the piece/sprite at the given point */
54 virtual Element getElement(const Point& p) const = 0;
56 /** Sets the piece/sprite at the given point */
57 virtual void setElement(const Point& p, const Element& e) = 0;
59 /** Removes the piece/sprite at the given point */
60 virtual void removeElement(const Point& p) = 0;
62 /** Updates the pool accordingly to the given one. */
63 virtual void updatePool(AbstractPosition::PoolPtr pool) = 0;
65 /* NOTE: Question: should tags be piecesprites, this function returning the sprite? */
66 /** Adds a tag to the board */
67 virtual void addTag(const QString& name, Point, bool over=false) = 0;
69 /** Removes all tags with @p name */
70 virtual void clearTags(const QString& name) = 0;
72 /** Clears all tags with @p name, and creates the given ones */
73 virtual void setTags(const QString& name, Point p1 = Point::invalid(), Point p2 = Point::invalid(),
74 Point p3 = Point::invalid(), Point p4 = Point::invalid(),
75 Point p5 = Point::invalid(), Point p6 = Point::invalid() ) = 0;
77 /** Returns the first point, to enumerate the squares */
78 virtual Point first() const = 0;
80 /** Returns the last point, to enumerate the squares */
81 virtual Point last() const = 0;
83 /** Returns the next point, to enumerate the squares */
84 virtual Point next(const Point& p) const = 0;
86 /** Returns true if the point is not out of the board */
87 virtual bool valid(const Point& p) const = 0;
89 /** Checks if the piece/sprite data match (for debugging) */
90 virtual bool consistent() const = 0;
93 #endif // GRAPHICALPOSITION_H