xoreos  0.0.5
campaign.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_WITCHER_CAMPAIGN_H
26 #define ENGINES_WITCHER_CAMPAIGN_H
27 
28 #include <list>
29 
30 #include "src/common/scopedptr.h"
31 #include "src/common/ustring.h"
32 
33 #include "src/aurora/locstring.h"
34 
35 #include "src/events/types.h"
36 
37 namespace Common {
38  class SeekableReadStream;
39 }
40 
41 namespace Engines {
42 
43 class Console;
44 
45 namespace Witcher {
46 
47 class Module;
48 class Creature;
49 
50 class Campaign {
51 public:
52  Campaign(::Engines::Console &console);
53  ~Campaign();
54 
56  void clear();
57 
58  // .--- Campaign management
60  bool isLoaded() const;
62  bool isRunning() const;
63 
65  void load(const Common::UString &campaign);
67  void loadModule(const Common::UString &module);
69  void usePC(const Common::UString &utc);
71  void exit();
72  // '---
73 
74  // .--- Information about the current campaign
76  const Aurora::LocString &getName() const;
78  const Aurora::LocString &getDescription() const;
79  // '---
80 
81  // .--- Elements of the current campaign
83  Module &getModule();
84  // '---
85 
86  // .--- Interact with the current campaign
88  void refreshLocalized();
89  // '---
90 
91  // .--- Static utility methods
92  static Common::UString getName(const Common::UString &campaign);
93  static Common::UString getDescription(const Common::UString &campaign);
94  // '---
95 
96  // .--- Campaign main loop (called by the Game class)
98  void enter();
100  void leave();
101 
103  void addEvent(const Events::Event &event);
105  void processEventQueue();
106  // '---
107 
108 private:
109  typedef std::list<Events::Event> EventQueue;
110 
111 
113 
115  bool _running;
116  bool _exit;
117 
122 
124  std::list<Common::UString> _modules;
127 
130 
133 
138 
140 
141 
148  void unload(bool completeUnload = true);
149 
150  void unloadPC();
151 
153  void loadCampaign(const Common::UString &campaign, bool standalone);
155  void changeCampaign(const Common::UString &campaign, bool standalone);
157  void replaceCampaign();
158 
160  void loadCampaignFile(const Common::UString &campaign);
162  void setupStandaloneModule(const Common::UString &module);
163 
164  void handleEvents();
165 
166 
168  static Common::UString getDirectory(const Common::UString &campaign);
170  static Common::SeekableReadStream *openMMD(const Common::UString &campaign);
171 };
172 
173 } // End of namespace Witcher
174 
175 } // End of namespace Engines
176 
177 #endif // ENGINES_WITCHER_CAMPAIGN_H
void load(const Common::UString &campaign)
Load a campaign.
Definition: campaign.cpp:115
Basic event types.
void changeCampaign(const Common::UString &campaign, bool standalone)
Schedule a change to a new campaign.
Definition: campaign.cpp:303
Aurora::LocString _name
The name of the currently loaded campaign.
Definition: campaign.h:119
Common::UString _startModule
The module the current campaign starts in.
Definition: campaign.h:126
Definition: 2dafile.h:39
::Engines::Console * _console
Definition: campaign.h:112
A class holding an UTF-8 string.
Definition: ustring.h:48
const Aurora::LocString & getName() const
Return the name of the current campaign.
Definition: campaign.cpp:67
A localized string.
Definition: locstring.h:43
bool _exit
Should we exit the campaign?
Definition: campaign.h:116
bool isLoaded() const
Is a campaign currently loaded and ready to run?
Definition: campaign.cpp:81
void exit()
Exit the currently running campaign.
Definition: campaign.cpp:232
void addEvent(const Events::Event &event)
Add a single event for consideration into the event queue.
Definition: campaign.cpp:257
void processEventQueue()
Process the current event queue.
Definition: campaign.cpp:261
void clear()
Clear the whole context.
Definition: campaign.cpp:63
A simple scoped smart pointer template.
SDL_Event Event
Definition: types.h:42
void loadCampaign(const Common::UString &campaign, bool standalone)
Load a new campaign.
Definition: campaign.cpp:198
const Aurora::LocString & getDescription() const
Return the description of the current campaign.
Definition: campaign.cpp:71
void loadCampaignFile(const Common::UString &campaign)
Load the actual campaign resources.
Definition: campaign.cpp:165
Module & getModule()
Return the currently running module.
Definition: campaign.cpp:75
bool _running
Are we currently running a campaign?
Definition: campaign.h:115
void refreshLocalized()
Refresh all localized strings.
Definition: campaign.cpp:319
Common::ScopedPtr< Module > _module
The current module of the current campaign.
Definition: campaign.h:129
void enter()
Enter the loaded campaign, starting it.
Definition: campaign.cpp:236
void setupStandaloneModule(const Common::UString &module)
Set up the loading of a singular, stand-alone module.
Definition: campaign.cpp:189
static Common::SeekableReadStream * openMMD(const Common::UString &campaign)
Open the MMD campaign file for this campaign.
Definition: campaign.cpp:139
Common::ScopedPtr< Creature > _pc
The player character we use.
Definition: campaign.h:132
bool _newCampaignStandalone
Is the campaign to change to a stand-alone module?
Definition: campaign.h:137
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
Aurora::LocString _description
The description of the currently loaded campaign.
Definition: campaign.h:121
Handling BioWare&#39;s localized strings.
void unload(bool completeUnload=true)
Unload the whole shebang.
Definition: campaign.cpp:89
Unicode string handling.
static Common::UString getDirectory(const Common::UString &campaign)
Return the actual real directory for this campaign.
Definition: campaign.cpp:152
void replaceCampaign()
Actually replace the currently running campaign.
Definition: campaign.cpp:308
Campaign(::Engines::Console &console)
Definition: campaign.cpp:50
void usePC(const Common::UString &utc)
Use this character as the player character.
Definition: campaign.cpp:218
bool _hasCampaign
Do we have a campaign?
Definition: campaign.h:114
std::list< Events::Event > EventQueue
Definition: campaign.h:109
Common::UString _newCampaign
The campaign we should change to.
Definition: campaign.h:135
std::list< Common::UString > _modules
All modules used by the current campaign.
Definition: campaign.h:124
bool isRunning() const
Is a campaign currently running?
Definition: campaign.cpp:85
void leave()
Leave the running campaign, quitting it.
Definition: campaign.cpp:250
Interface for a seekable & readable data stream.
Definition: readstream.h:265
void loadModule(const Common::UString &module)
Load a stand-alone module as a campaign.
Definition: campaign.cpp:127