Initial porting to the new component API.
[tagua/yd.git] / src / controllers / editgame.h
blob92909890a5e312a1d0f00b2c07fc9081d64a643e
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 EDITGAMECONTROLLER_H
12 #define EDITGAMECONTROLLER_H
14 #include <map>
15 #include <set>
16 #include <boost/shared_ptr.hpp>
17 #include <core/state_fwd.h>
18 #include "abstract.h"
19 #include "agentgroup.h"
21 class Entity;
22 class Engine;
23 class Agent;
24 class IColor;
25 class ICSConnection;
26 class UserEntity;
27 class GraphicalGame;
28 class GraphicalSystem;
29 class Variant;
32 /**
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,
38 * @code m_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;
47 protected:
48 virtual void onNavigation();
50 boost::shared_ptr<UserEntity> m_entity;
51 boost::shared_ptr<GraphicalSystem> m_graphical;
52 AgentGroup m_agents;
53 Variant* m_variant;
54 boost::shared_ptr<GraphicalGame> m_game;
55 virtual boost::shared_ptr<UserEntity> entity() const { return m_entity; }
56 Players m_players;
57 std::set<boost::shared_ptr<Entity> > m_entities;
59 bool detachAllPlayerEntities();
60 public:
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();
89 #endif