/
doomsdayapp.h
133 lines (109 loc) · 3.67 KB
/
doomsdayapp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/** @file doomsdayapp.h Common application-level state and components.
*
* @authors Copyright (c) 2015 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/
#ifndef LIBDOOMSDAY_DOOMSDAYAPP_H
#define LIBDOOMSDAY_DOOMSDAYAPP_H
#include "plugins.h"
#include "busymode.h"
#include "gameapi.h"
#include "players.h"
#include <de/NativePath>
#include <de/Info>
#include <string>
namespace res { class Bundles; }
class Games;
class Game;
/**
* Common application-level state and components.
*
* Both the server and client applications have an instance of DoomsdayApp
* to manage the common state and subsystems.
*/
class LIBDOOMSDAY_PUBLIC DoomsdayApp
{
public:
/**
* Notified before the current game is unloaded.
*/
DENG2_DEFINE_AUDIENCE2(GameUnload, void aboutToUnloadGame(Game const &gameBeingUnloaded))
/**
* Notified after the current game has been changed.
*/
DENG2_DEFINE_AUDIENCE2(GameChange, void currentGameChanged(Game const &newGame))
/**
* Notified when console variables and commands should be registered.
*/
DENG2_DEFINE_AUDIENCE2(ConsoleRegistration, void consoleRegistration())
public:
DoomsdayApp(Players::Constructor playerConstructor);
/**
* Initialize application state.
*/
void initialize();
void identifyDataBundles();
void determineGlobalPaths();
bool isUsingUserDir() const;
#ifdef WIN32
void *moduleHandle() const;
#endif
void setDoomsdayBasePath(de::NativePath const &path);
void setDoomsdayRuntimePath(de::NativePath const &path);
std::string const &doomsdayBasePath() const;
std::string const &doomsdayRuntimePath() const;
public:
static DoomsdayApp &app();
static res::Bundles &bundles();
static Plugins &plugins();
static Games &games();
static Players &players();
static Game ¤tGame();
static BusyMode &busyMode();
static de::NativePath steamBasePath();
/**
* Sets the currently active game. DoomsdayApp does not take ownership of
* the provided Game instance.
*
* @param game Game instance. Must not be deleted until another Game is
* used as the current one.
*/
static void setGame(Game &game);
/**
* Returns the currently active game.
*/
static Game &game();
//protected: // TODO: after changeGame() is moved here, make protected again
/**
* Called just before a game change is about to begin. The GameUnload
* audience has already been notified.
*
* @param upcomingGame Upcoming game that we will be changing to.
*/
virtual void unloadGame(Game const &upcomingGame);
virtual void makeGameCurrent(Game &newGame);
/**
* Clears all allocated resources and subsystems. This is called when
* a game is being unloaded.
*/
virtual void reset();
private:
DENG2_PRIVATE(d)
};
/**
* Returns @c true if a game module is presently loaded.
*/
LIBDOOMSDAY_PUBLIC bool App_GameLoaded();
#endif // LIBDOOMSDAY_DOOMSDAYAPP_H