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_NWN2_CAMPAIGN_H
26 #define ENGINES_NWN2_CAMPAIGN_H
27 
28 #include <list>
29 
30 #include "src/common/scopedptr.h"
31 #include "src/common/ustring.h"
32 #include "src/common/changeid.h"
33 
35 
36 #include "src/events/types.h"
37 
38 namespace Engines {
39 
40 class Console;
41 
42 namespace NWN2 {
43 
44 class Module;
45 class Creature;
46 
48 public:
49  Campaign(::Engines::Console &console);
50  ~Campaign();
51 
53  void clear();
54 
55  // .--- Campaign management
57  bool isLoaded() const;
59  bool isRunning() const;
60 
62  void load(const Common::UString &campaign);
64  void loadModule(const Common::UString &module);
66  void usePC(const Common::UString &bic, bool local);
68  void exit();
69  // '---
70 
71  // .--- Information about the current campaign
73  const Common::UString &getName() const;
75  const Common::UString &getDescription() const;
76  // '---
77 
78  // .--- Elements of the current campaign
80  Module &getModule();
81  // '---
82 
83  // .--- Static utility methods
84  static Common::UString getName(const Common::UString &campaign);
85  static Common::UString getDescription(const Common::UString &campaign);
86  // '---
87 
88  // .--- Campaign main loop (called by the Game class)
90  void enter();
92  void leave();
93 
95  void addEvent(const Events::Event &event);
97  void processEventQueue();
98  // '---
99 
100 private:
101  typedef std::list<Events::Event> EventQueue;
102 
103 
105 
107  bool _running;
108  bool _exit;
109 
114 
116  std::list<Common::UString> _modules;
119 
122 
125 
128 
133 
135 
136 
143  void unload(bool completeUnload = true);
144 
145  void unloadPC();
146 
148  void loadCampaign(const Common::UString &campaign, bool standalone);
150  void changeCampaign(const Common::UString &campaign, bool standalone);
152  void replaceCampaign();
153 
155  void loadCampaignResource(const Common::UString &campaign);
157  void setupStandaloneModule(const Common::UString &module);
158 
159  void handleEvents();
160 
161 
163  static Common::UString getDirectory(const Common::UString &campaign, bool relative);
164 };
165 
166 } // End of namespace NWN2
167 
168 } // End of namespace Engines
169 
170 #endif // ENGINES_NWN2_CAMPAIGN_H
Basic event types.
Common::UString _startModule
The module the current campaign starts in.
Definition: campaign.h:118
void exit()
Exit the currently running campaign.
Definition: campaign.cpp:165
void unload(bool completeUnload=true)
Unload the whole shebang.
Definition: campaign.cpp:95
A class holding an UTF-8 string.
Definition: ustring.h:48
::Engines::Console * _console
Definition: campaign.h:104
bool _hasCampaign
Do we have a campaign?
Definition: campaign.h:106
Common::ScopedPtr< Module > _module
The current module of the current campaign.
Definition: campaign.h:124
void changeCampaign(const Common::UString &campaign, bool standalone)
Schedule a change to a new campaign.
Definition: campaign.cpp:298
std::list< Common::UString > _modules
All modules used by the current campaign.
Definition: campaign.h:116
void loadCampaign(const Common::UString &campaign, bool standalone)
Load a new campaign.
Definition: campaign.cpp:211
A simple scoped smart pointer template.
void loadCampaignResource(const Common::UString &campaign)
Load the actual campaign resources.
Definition: campaign.cpp:169
SDL_Event Event
Definition: types.h:42
void loadModule(const Common::UString &module)
Load a stand-alone module as a campaign.
Definition: campaign.cpp:137
std::list< Events::Event > EventQueue
Definition: campaign.h:101
void addEvent(const Events::Event &event)
Add a single event for consideration into the event queue.
Definition: campaign.cpp:252
void processEventQueue()
Process the current event queue.
Definition: campaign.cpp:256
bool _newCampaignStandalone
Is the campaign to change to a stand-alone module?
Definition: campaign.h:132
Helper class to represent an undoable change.
const Common::UString & getDescription() const
Return the description of the current campaign.
Definition: campaign.cpp:77
void load(const Common::UString &campaign)
Load a campaign.
Definition: campaign.cpp:125
Campaign(::Engines::Console &console)
Definition: campaign.cpp:56
Module & getModule()
Return the currently running module.
Definition: campaign.cpp:81
void leave()
Leave the running campaign, quitting it.
Definition: campaign.cpp:245
Common::UString _name
The name of the currently loaded campaign.
Definition: campaign.h:111
const Common::UString & getName() const
Return the name of the current campaign.
Definition: campaign.cpp:73
Common::UString _newCampaign
The campaign we should change to.
Definition: campaign.h:130
void setupStandaloneModule(const Common::UString &module)
Set up the loading of a singular, stand-alone module.
Definition: campaign.cpp:205
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
void replaceCampaign()
Actually replace the currently running campaign.
Definition: campaign.cpp:303
An NWScript variable container.
Common::ChangeID _resCampaign
Resources added by the campaign.
Definition: campaign.h:121
bool _running
Are we currently running a campaign?
Definition: campaign.h:107
Unicode string handling.
static Common::UString getDirectory(const Common::UString &campaign, bool relative)
Return the actual real directory for this campaign.
Definition: campaign.cpp:314
Common::ScopedPtr< Creature > _pc
The player character we use.
Definition: campaign.h:127
A class representing an undoable change.
Definition: changeid.h:35
bool _exit
Should we exit the campaign?
Definition: campaign.h:108
void usePC(const Common::UString &bic, bool local)
Use this character as the player character.
Definition: campaign.cpp:149
void clear()
Clear the whole context.
Definition: campaign.cpp:69
bool isRunning() const
Is a campaign currently running?
Definition: campaign.cpp:91
bool isLoaded() const
Is a campaign currently loaded and ready to run?
Definition: campaign.cpp:87
void enter()
Enter the loaded campaign, starting it.
Definition: campaign.cpp:231
Common::UString _description
The description of the currently loaded campaign.
Definition: campaign.h:113
EventQueue _eventQueue
Definition: campaign.h:134