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
;
24 class ActionStateObserver
;
25 namespace MoveList
{ class Table
; }
27 class GraphicalGame
: public QObject
, public Game
, public MoveList::Notifier
{
31 * @brief State of GUI actions associated to a game.
33 enum ActionStateFlag
{
41 Q_DECLARE_FLAGS(ActionState
, ActionStateFlag
)
43 GraphicalSystem
* m_graphical
;
44 MoveList::Table
* m_movelist
;
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();
55 void settingsChanged();
58 GraphicalGame(GraphicalSystem
* graphical
, MoveList::Table
* m
);
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
)
95 * @brief An observer that is notified of changes in the ActionState flags.
97 class ActionStateObserver
{
99 virtual ~ActionStateObserver();
101 virtual void notifyActionStateChange(GraphicalGame::ActionState state
) = 0;
104 #endif //GRAPHICALGAME_H