Initial implementation of the new abstraction architecture.
[tagua.git] / src / graphicalsystem.h
blobac3d20c3f13b58c51b2bacd2063fefb3f637b8f2
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 GRAPHICALSYSTEM_H
12 #define GRAPHICALSYSTEM_H
14 #include <boost/shared_ptr.hpp>
15 #include <QObject>
16 #include "graphicalapi.h"
18 class ChessTable;
19 class Board;
20 class UserEntity;
22 class GraphicalSystem : public QObject, private GraphicalAPI {
23 Q_OBJECT
25 public:
27 /** The current chess table */
28 ChessTable* m_view;
30 /** The current board */
31 Board* m_board;
33 /** The position data */
34 AbstractPosition::Ptr m_pos;
36 /** The variant specific animator */
37 AbstractAnimator::Ptr m_animator;
39 /** The current variant */
40 VariantInfo* m_variant;
42 /** @a GraphicalPosition interface function implementation */
43 // virtual void addTag(const QString& name, Point, bool over = false);
45 /** @a GraphicalPosition interface function implementation */
46 // virtual void clearTags(const QString& name);
48 /** @a GraphicalPosition interface function implementation */
49 // virtual void setTags(const QString& name, Point p1 = Point::invalid(), Point p2 = Point::invalid(),
50 // Point p3 = Point::invalid(), Point p4 = Point::invalid(),
51 // Point p5 = Point::invalid(), Point p6 = Point::invalid() );
53 private slots:
54 /** internal function to listen at setting changes */
55 void settingsChanged();
57 /**
58 * \return the current abstract position. (interface for GraphicalAPI)
60 virtual const PointConverter* converter() const;
62 /**
63 * \return the current abstract position. (interface for GraphicalAPI)
65 virtual AbstractPosition::Ptr position() const;
67 /**
68 * \return a sprite at the position \a index in the graphical pool. (interface for GraphicalAPI)
70 virtual SpritePtr getSprite(const Point& p);
72 /**
73 * Removes a sprite at the position \a index in the graphical pool. (interface for GraphicalAPI)
74 * \return the newly created sprite.
76 virtual SpritePtr takeSprite(const Point& p);
78 /**
79 * Sets the sprite at the position \a index in the graphical pool. (interface for GraphicalAPI)
80 * \return the newly created sprite.
82 virtual SpritePtr setSprite(const Point& p, const AbstractPiece* piece, bool use_drop, bool show);
84 /**
85 * \return how many sprites are contained in the pool
87 virtual int poolSize(int pool) = 0;
89 /**
90 * \return the sprite at the position \a index in the graphical pool. (interface for GraphicalAPI)
92 virtual SpritePtr getPoolSprite(int pool, int index);
94 /**
95 * Removes the sprite at the position \a index in the graphical pool. (interface for GraphicalAPI)
96 * \return the removed sprite.
98 virtual SpritePtr takePoolSprite(int pool, int index);
101 * Inserts a sprite at the position \a index in the graphical pool. (interface for GraphicalAPI)
102 * \return the newly created sprite.
104 virtual SpritePtr insertPoolSprite(int pool, int index, const AbstractPiece* piece);
107 public:
108 /** Constructor */
109 GraphicalSystem(ChessTable* view, AbstractPosition::Ptr startingPosition,
110 VariantInfo* variant);
111 virtual ~GraphicalSystem();
113 /** Sets the reference entity */
114 void setup(const boost::shared_ptr<UserEntity>& entity);
116 /** Goes forward playing a move, that has to be legal and checked */
117 void forward(const AbstractMove::Ptr& move,
118 const AbstractPosition::Ptr& pos,
119 const SpritePtr& = SpritePtr());
121 /** Goes back undoing a move, that has to be legal and checked */
122 void back(const AbstractMove::Ptr& lastMove,
123 const AbstractMove::Ptr& move,
124 const AbstractPosition::Ptr& pos);
126 /** Warps to a new position */
127 void warp(const AbstractMove::Ptr& lastMove,
128 const AbstractPosition::Ptr& pos);
130 /** Adjusts a sprite to the correct position */
131 void adjustSprite(const Point& p);
133 /** Sets the current turn */
134 void setTurn(int turn);
138 #endif //GRAPHICALSYSTEM_H