xoreos  0.0.5
campaigns.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef ENGINES_DRAGONAGE_CAMPAIGNS_H
26 #define ENGINES_DRAGONAGE_CAMPAIGNS_H
27 
28 #include <vector>
29 #include <list>
30 
31 #include "src/common/scopedptr.h"
32 #include "src/common/ptrvector.h"
33 #include "src/common/ustring.h"
34 
35 #include "src/events/types.h"
36 
37 namespace Engines {
38 
39 class Console;
40 
41 namespace DragonAge {
42 
43 class Game;
44 class Campaign;
45 class Creature;
46 
47 class Campaigns {
48 public:
49  Campaigns(::Engines::Console &console, Game &game);
50  ~Campaigns();
51 
52  // .--- Available campaigns and addins
55 
57  const PlayableCampaigns &getCampaigns() const;
59  const AddinContent &getAddins() const;
60 
62  const Campaign *findCampaign(const Common::UString &uid) const;
64  const Campaign *findAddin(const Common::UString &uid) const;
65  // '---
66 
67  // .--- Campaign management
69  bool isLoaded() const;
71  bool isRunning() const;
72 
74  void load(const Campaign &campaign);
76  void usePC(Creature *pc);
78  void exit();
80  void unload();
81  // '---
82 
83  // .--- The current campaign
87  Creature *getPC() const;
88  // '---
89 
90  // .--- Interact with the current campaign
92  void refreshLocalized();
93  // '---
94 
95  // .--- Campaign main loop (called by the Game class)
97  void enter();
99  void leave();
100 
102  void addEvent(const Events::Event &event);
104  void processEventQueue();
105  // '---
106 
107 private:
108  typedef std::list<Events::Event> EventQueue;
109 
110 
113 
115  bool _running;
116  bool _exit;
117 
122 
125 
128 
131 
133 
134 
135  void clean();
136 
143  void unload(bool completeUnload);
144 
145  void unloadPC();
146 
148  void loadCampaign(const Campaign &campaign);
150  void changeCampaign(const Campaign &campaign);
152  void replaceCampaign();
153 
154  void findCampaigns();
155  void addCampaign(Campaign *campaign);
156  Campaign *readCampaign(const Common::UString &cifPath = "", const Common::UString &manifestPath = "",
157  const Common::UString &addinBase = "");
158 
159  Campaign *getCampaign(const Common::UString &uid);
160  Campaign *getAddin(const Common::UString &uid);
161 
162  void handleEvents();
163 };
164 
165 } // End of namespace DragonAge
166 
167 } // End of namespace Engines
168 
169 #endif // ENGINES_DRAGONAGE_CAMPAIGNS_H
Basic event types.
void changeCampaign(const Campaign &campaign)
Schedule a change to a new campaign.
Definition: campaigns.cpp:319
bool _exit
Should we exit the campaign?
Definition: campaigns.h:116
A class holding an UTF-8 string.
Definition: ustring.h:48
void addCampaign(Campaign *campaign)
Definition: campaigns.cpp:144
bool isLoaded() const
Is a campaign currently loaded and ready to run?
Definition: campaigns.cpp:105
Common::PtrVector< Campaign > PlayableCampaigns
Definition: campaigns.h:53
const PlayableCampaigns & getCampaigns() const
Return all playable campaigns.
Definition: campaigns.cpp:65
void leave()
Leave the running campaign, quitting it.
Definition: campaigns.cpp:255
Campaigns(::Engines::Console &console, Game &game)
Definition: campaigns.cpp:47
Common::PtrVector< Campaign > AddinContent
Definition: campaigns.h:54
std::list< Events::Event > EventQueue
Definition: campaigns.h:108
const Campaign * findAddin(const Common::UString &uid) const
Find a specific add-in by UID and return it, or 0 if not found.
Definition: campaigns.cpp:81
A simple scoped smart pointer template.
void unload()
Completely unload the currently loaded campaign.
Definition: campaigns.cpp:191
SDL_Event Event
Definition: types.h:42
Campaign * readCampaign(const Common::UString &cifPath="", const Common::UString &manifestPath="", const Common::UString &addinBase="")
Definition: campaigns.cpp:156
bool _running
Are we currently running a campaign?
Definition: campaigns.h:115
const AddinContent & getAddins() const
Return all add-in content for other campaigns.
Definition: campaigns.cpp:69
void exit()
Exit the currently running campaign.
Definition: campaigns.cpp:187
void addEvent(const Events::Event &event)
Add a single event for consideration into the event queue.
Definition: campaigns.cpp:263
void load(const Campaign &campaign)
Load a campaign.
Definition: campaigns.cpp:175
Common::UString _newCampaign
The UID of the campaign we should change to.
Definition: campaigns.h:130
Campaign * getCampaign(const Common::UString &uid)
Definition: campaigns.cpp:89
Creature * getPC() const
Return the currently playing PC.
Definition: campaigns.cpp:315
Common::ScopedPtr< Creature > _pc
The player character we use.
Definition: campaigns.h:127
void usePC(Creature *pc)
Use this character as the player character.
Definition: campaigns.cpp:238
void refreshLocalized()
Refresh all localized strings.
Definition: campaigns.cpp:337
A vector storing pointer to objects, with automatic deletion.
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
void enter()
Enter the loaded campaign, starting it.
Definition: campaigns.cpp:242
void replaceCampaign()
Actually replace the currently running campaign.
Definition: campaigns.cpp:323
Campaign * getAddin(const Common::UString &uid)
Definition: campaigns.cpp:97
Campaign * getCurrentCampaign() const
Return the currently running campaign.
Definition: campaigns.cpp:311
PlayableCampaigns _campaigns
All campaigns we know about.
Definition: campaigns.h:119
Unicode string handling.
bool _hasCampaign
Do we have a campaign?
Definition: campaigns.h:114
void loadCampaign(const Campaign &campaign)
Load a new campaign.
Definition: campaigns.cpp:217
AddinContent _addins
All add-in content we know about.
Definition: campaigns.h:121
Campaign * _currentCampaign
The currently loaded campaign.
Definition: campaigns.h:124
void processEventQueue()
Process the current event queue.
Definition: campaigns.cpp:267
const Campaign * findCampaign(const Common::UString &uid) const
Find a specific campaign by UID and return it, or 0 if not found.
Definition: campaigns.cpp:73
::Engines::Console * _console
Definition: campaigns.h:111
bool isRunning() const
Is a campaign currently running?
Definition: campaigns.cpp:109