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 EDITGAMECONTROLLER_H
12 #define EDITGAMECONTROLLER_H
16 #include <boost/shared_ptr.hpp>
17 #include <core/state_fwd.h>
19 #include "agentgroup.h"
28 class GraphicalSystem
;
33 * @brief A controller to edit or play games.
35 * EditGameController is used to play games, either locally or
36 * on an ICS server. A pair of entities @code m_players, representing
37 * the two players, is mantained as well as a set of additional entities,
39 * If an entity needs to be notified about how the game progresses, one
40 * should register it as an agent, adding it to @code m_agents.
42 class EditGameController
: public Controller
{
43 void init(const StatePtr
& state
);
44 boost::shared_ptr
<Agent
> m_clock_agent
;
45 boost::shared_ptr
<Agent
> m_update_agent
;
46 typedef std::map
<const IColor
*, boost::shared_ptr
<Entity
> > Players
;
48 virtual void onNavigation();
50 boost::shared_ptr
<UserEntity
> m_entity
;
51 boost::shared_ptr
<GraphicalSystem
> m_graphical
;
54 boost::shared_ptr
<GraphicalGame
> m_game
;
55 virtual boost::shared_ptr
<UserEntity
> entity() const { return m_entity
; }
57 std::set
<boost::shared_ptr
<Entity
> > m_entities
;
59 bool detachAllPlayerEntities();
61 EditGameController(ChessTable
*, Variant
* variant
,
62 const StatePtr
& startingPos
= StatePtr());
63 ~EditGameController();
65 virtual ActionCollection
* variantActions() const;
66 virtual QString
variant() const;
67 EntityToken
addPlayingEngine(const IColor
* side
, const boost::shared_ptr
<Engine
>& engine
);
68 // EntityToken addAnalysingEngine(const boost::shared_ptr<Engine>& engine);
69 void removeEntity(const EntityToken
& token
);
70 bool addICSPlayer(const IColor
* side
, int game_number
,
71 const boost::shared_ptr
<ICSConnection
>& connection
);
72 bool setExaminationMode(int game_number
, const boost::shared_ptr
<ICSConnection
>& connection
);
73 bool setObserveMode(int game_number
, const boost::shared_ptr
<ICSConnection
>& connection
);
75 virtual void loadPGN(const PGN
&);
77 virtual void createCtrlAction();
78 virtual void destroyCtrlAction();
80 virtual boost::shared_ptr
<Controller
> end();
81 virtual void detach();
83 virtual void reloadSettings();
84 virtual void setUI(UI
& ui
);
85 virtual void activate();