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 #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 #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
;
53 Components
* m_components
;
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
*, const StatePtr
& startingPos
= StatePtr());
62 ~EditGameController();
64 virtual ActionCollection
* variantActions() const;
65 virtual QString
variant() const;
66 EntityToken
addPlayingEngine(const IColor
* side
, const boost::shared_ptr
<Engine
>& engine
);
67 // EntityToken addAnalysingEngine(const boost::shared_ptr<Engine>& engine);
68 void removeEntity(const EntityToken
& token
);
69 bool addICSPlayer(const IColor
* side
, int game_number
,
70 const boost::shared_ptr
<ICSConnection
>& connection
);
71 bool setExaminationMode(int game_number
, const boost::shared_ptr
<ICSConnection
>& connection
);
72 bool setObserveMode(int game_number
, const boost::shared_ptr
<ICSConnection
>& connection
);
74 virtual void loadPGN(const PGN
&);
76 virtual void createCtrlAction();
77 virtual void destroyCtrlAction();
79 virtual boost::shared_ptr
<Controller
> end();
80 virtual void detach();
82 virtual void reloadSettings();
83 virtual void setUI(UI
& ui
);
84 virtual void activate();