Fix debian/rules in places where the move to BUILD/ dir was not complete.
[tagua/yd.git] / src / graphicalgame.h
blob6636b705a5c3b692fe9f19a53969fe6c6a166d23
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
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 GRAPHICALGAME_H
12 #define GRAPHICALGAME_H
14 #include <QObject>
15 #include <QFlags>
16 #include <boost/weak_ptr.hpp>
17 #include "game.h"
18 #include "movelist_notifier.h"
20 class GraphicalSystem;
21 class CtrlAction;
22 class UserEntity;
23 class GraphicalGame;
24 class ActionStateObserver;
25 namespace MoveList { class Table; }
27 class GraphicalGame : public QObject, public Game, public MoveList::Notifier {
28 Q_OBJECT
29 public:
30 /**
31 * @brief State of GUI actions associated to a game.
33 enum ActionStateFlag {
34 UNDO = 0x1,
35 REDO = 0x2,
36 BEGIN = 0x4,
37 BACK = 0x8,
38 FORWARD = 0x10,
39 END = 0x20
41 Q_DECLARE_FLAGS(ActionState, ActionStateFlag)
42 private:
43 GraphicalSystem* m_graphical;
44 MoveList::Table* m_movelist;
45 bool m_anim_sequence;
46 int m_anim_sequence_max;
48 boost::shared_ptr<CtrlAction> m_ctrl;
49 boost::weak_ptr<UserEntity> m_listener_entity;
50 boost::shared_ptr<ActionStateObserver> m_action_state_observer;
51 ActionState m_action_state;
52 void updateActionState();
54 private Q_SLOTS:
55 void settingsChanged();
57 public:
58 GraphicalGame(GraphicalSystem* graphical, MoveList::Table* m);
59 ~GraphicalGame();
61 void onAddedInternal(const Index& i, bool confirm_promotion = false);
62 virtual void onAdded(const Index& i);
63 virtual void onRemoved(const Index& i);
64 virtual void onEntryChanged(const Index& at, int propagate=1);
65 virtual void onPromoteVariation(const Index& i, int v);
66 virtual void onSetComment(const Index& i, const QString& s);
67 virtual void onSetVComment(const Index& i, int v, const QString& s);
68 virtual void onCurrentIndexChanged(const Index& old_c);
69 virtual void onAvailableUndo(bool e);
70 virtual void onAvailableRedo(bool e);
71 virtual void onUserSelectMove(const Index& i);
72 virtual void onUserSetComment(const Index& i, QString s);
73 virtual void onUserSetVComment(const Index& i, int v, QString s);
74 virtual void onUserClearVariations(const Index& i);
75 virtual void onUserTruncate(const Index& i);
76 virtual void onUserPromoteVariation(const Index& i);
77 virtual void onUserRemoveVariation(const Index& i);
78 virtual void onUserUndo();
79 virtual void onUserRedo();
80 virtual void onDetachNotifier();
82 virtual void createCtrlAction();
83 virtual void destroyCtrlAction();
85 void setEntity(const boost::shared_ptr<UserEntity>& entity) { m_listener_entity = entity; }
86 void detachEntity() { m_listener_entity.reset(); }
87 void setActionStateObserver(const boost::shared_ptr<ActionStateObserver>& obs);
88 void onActionStateChange();
91 Q_DECLARE_OPERATORS_FOR_FLAGS(GraphicalGame::ActionState)
94 /**
95 * @brief An observer that is notified of changes in the ActionState flags.
97 class ActionStateObserver {
98 public:
99 virtual ~ActionStateObserver();
101 virtual void notifyActionStateChange(GraphicalGame::ActionState state) = 0;
104 #endif //GRAPHICALGAME_H