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.
11 #ifndef GRAPHICALGAME_H
12 #define GRAPHICALGAME_H
16 #include <boost/weak_ptr.hpp>
18 #include "movelist_notifier.h"
20 class GraphicalSystem
;
22 class IMoveSerializer
;
25 class ActionStateObserver
;
26 namespace MoveList
{ class Table
; }
28 class GraphicalGame
: public QObject
, public Game
, public MoveList::Notifier
{
32 * @brief State of GUI actions associated to a game.
34 enum ActionStateFlag
{
42 Q_DECLARE_FLAGS(ActionState
, ActionStateFlag
)
44 GraphicalSystem
* m_graphical
;
45 MoveList::Table
* m_movelist
;
47 int m_anim_sequence_max
;
49 IMoveSerializer
* m_decorator
;
51 boost::shared_ptr
<CtrlAction
> m_ctrl
;
52 boost::weak_ptr
<UserEntity
> m_listener_entity
;
53 boost::shared_ptr
<ActionStateObserver
> m_action_state_observer
;
54 ActionState m_action_state
;
55 void updateActionState();
58 void settingsChanged();
61 GraphicalGame(GraphicalSystem
* graphical
, MoveList::Table
* m
);
64 void onAddedInternal(const Index
& i
, bool confirm_promotion
= false);
65 virtual void onAdded(const Index
& i
);
66 virtual void onRemoved(const Index
& i
);
67 virtual void onEntryChanged(const Index
& at
, int propagate
=1);
68 virtual void onPromoteVariation(const Index
& i
, int v
);
69 virtual void onSetComment(const Index
& i
, const QString
& s
);
70 virtual void onSetVComment(const Index
& i
, int v
, const QString
& s
);
71 virtual void onCurrentIndexChanged(const Index
& old_c
);
72 virtual void onAvailableUndo(bool e
);
73 virtual void onAvailableRedo(bool e
);
74 virtual void onUserSelectMove(const Index
& i
);
75 virtual void onUserSetComment(const Index
& i
, QString s
);
76 virtual void onUserSetVComment(const Index
& i
, int v
, QString s
);
77 virtual void onUserClearVariations(const Index
& i
);
78 virtual void onUserTruncate(const Index
& i
);
79 virtual void onUserPromoteVariation(const Index
& i
);
80 virtual void onUserRemoveVariation(const Index
& i
);
81 virtual void onUserUndo();
82 virtual void onUserRedo();
83 virtual void onDetachNotifier();
85 virtual void createCtrlAction();
86 virtual void destroyCtrlAction();
88 void setEntity(const boost::shared_ptr
<UserEntity
>& entity
) { m_listener_entity
= entity
; }
89 void detachEntity() { m_listener_entity
.reset(); }
90 void setActionStateObserver(const boost::shared_ptr
<ActionStateObserver
>& obs
);
91 void onActionStateChange();
94 Q_DECLARE_OPERATORS_FOR_FLAGS(GraphicalGame::ActionState
)
98 * @brief An observer that is notified of changes in the ActionState flags.
100 class ActionStateObserver
{
102 virtual ~ActionStateObserver();
104 virtual void notifyActionStateChange(GraphicalGame::ActionState state
) = 0;
107 #endif //GRAPHICALGAME_H