forked from Spore-Community/Spore-ModAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIGameModeManager.h
More file actions
251 lines (209 loc) · 8.28 KB
/
IGameModeManager.h
File metadata and controls
251 lines (209 loc) · 8.28 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/****************************************************************************
* Copyright (C) 2019 Eric Mor
*
* This file is part of Spore ModAPI.
*
* Spore ModAPI 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 3 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/>.
****************************************************************************/
#pragma once
#include <Spore\App\IGameMode.h>
#include <Spore\App\ICameraManager.h>
#include <Spore\App\StandardMessage.h>
#include <Spore\App\cViewer.h>
/// Access the active game mode manager.
#define GameModeManager (*App::IGameModeManager::Get())
// Access the active game camera manager.
#define CameraManager (*App::IGameModeManager::Get()->GetCameraManager())
#define IGameModeManagerPtr eastl::intrusive_ptr<App::IGameModeManager>
namespace App
{
enum GameModeManagerMessageIDs
{
kMsgAddRef = 1,
kMsgRelease = 2,
/// Called when the current mode is exited. The message data is the App::OnModeExitMessage class.
kMsgOnModeExit = 0x212D3E7,
/// Called after the current mode is entered. The message data is the App::OnModeEnterMessage class.
kMsgOnModeEnter = 0x22D1ADC,
// Changes the current game mode. The message data is the App::SetGameModeMessage class.
kMsgSetGameModeByName = 0xE11333,
// 0xD3C602
};
// not public, so user can't access the fields
class OnModeExitMessage : StandardMessage
{
public:
static const uint32_t ID = kMsgOnModeExit;
/// Returns the current mode ID after this change.
inline uint32_t GetModeID() {
return params[0].uint32;
}
/// Returns the pevious mode ID before this change.
inline uint32_t GetPreviousModeID() {
return params[1].uint32;
}
};
class OnModeEnterMessage : StandardMessage
{
public:
static const uint32_t ID = kMsgOnModeEnter;
/// Returns the current mode ID after this change.
inline uint32_t GetModeID() {
return params[0].uint32;
}
/// Returns the pevious mode ID before this change.
inline uint32_t GetPreviousModeID() {
return params[1].uint32;
}
};
class SetGameModeMessage : StandardMessage
{
public:
static const uint32_t ID = kMsgSetGameModeByName;
inline SetGameModeMessage(const char* gameModeName)
{
id = ID;
SetString(0, gameModeName);
}
inline const eastl::string& GetGameModeName() {
return params[0].str->value;
}
};
///
/// A manager that takes care of game modes; check IGameMode for more information.
/// The manager has a vector with all the modes and keeps track of the active mode.
/// The active mode can be set by either ID or name.
///
/// The manager also controls the active ICameraManager and Viewer, which control all the calculations related with
/// camera and view projections used for rendering.
///
class IGameModeManager
{
public:
/* 00h */ virtual int AddRef() = 0;
/* 04h */ virtual int Release() = 0;
/* 08h */ virtual ~IGameModeManager() {};
/* 0Ch */ virtual bool Initialize() = 0;
/* 10h */ virtual bool Dispose() = 0;
/* 14h */ virtual bool func14h() = 0;
///
/// Calls the IGameMode::Initialize() method on all the modes in this manager.
///
/* 18h */ virtual bool InitializeModes() = 0;
///
/// Sets the active game mode to nullptr. The IGameMode::OnExit() method will be called on the active context,
/// and the messages kMsgOnModeExit and kMsgOnModeEnter will be generated.
/// @returns True if there was an active context, false otherwise.
///
/* 1Ch */ virtual bool ClearActiveMode() = 0;
///
/// Adds the given game mode to this manager under the modeID specified.
/// @param pMode The IGameMode to add.
/// @param modeID The ID that uniquely identifies this game mode, and that can be used to access it.
/// @param pName The name of this mode.
///
/* 20h */ virtual void AddGameMode(IGameMode* pMode, uint32_t modeID, const char* pName) = 0;
///
/// Removes the game mode with the ID specified from this manager. This will call the IGameMode::Dispose() method on the mode.
/// @param modeID The ID of the mode to remove.
/// @returns True if the game mode was removed, false if it was not in this manager.
///
/* 24h */ virtual bool RemoveGameMode(uint32_t modeID) = 0;
///
/// Sets the active game mode to be the one with the specified ID. If there's already an active mode,
/// the method IGameMode::OnExit(). The method IGameMode::OnEnter() will be called on
/// the mode with the specified ID. A message with ID kMsgOnModeEnter will be generated.
/// @param modeID The ID of the game mode to set as active.
/// @returns True if the mode was found and set active, false otherwise.
///
/* 28h */ virtual bool SetActiveMode(uint32_t modeID) = 0;
///
/// Returns the game mode that is currently in action.
///
/* 2Ch */ virtual IGameMode* GetActiveMode() = 0;
///
/// Gets the game mode in this manager with the specified ID.
/// @param modeID The ID of the mode.
/// @returns The IGameMode with that ID, or nullptr if there is none.
///
/* 30h */ virtual IGameMode* GetGameMode(uint32_t modeID) = 0;
///
/// Gets the modeID at the specified index.
/// @param index The index of the game modes array.
/// @returns The ID of the game mode at that index, or 0 if the index is out of bounds.
///
/* 34h */ virtual uint32_t GetModeIDAt(size_t index) = 0;
///
/// Gets the modeID of the currently active IGameMode.
/// @returns The ID of the active game mode, or 0 if no mode is active.
///
/* 38h */ virtual uint32_t GetActiveModeID() = 0;
///
/// Gets the number of game modes contained in this manager.
///
/* 3Ch */ virtual size_t GetModeCount() = 0;
///
/// Sets the active game mode to be the one at the specified index. If there's already an active mode,
/// the method IGameMode::OnExit() will be called on it. The method IGameMode::OnEnter() will be called on
/// the mode at the specified index. A message with ID kMsgOnModeEnter will be generated.
/// @param index The index of the game mode to set as active.
/// @returns True if the mode was found and set active, false otherwise.
///
/* 40h */ virtual bool SetActiveModeAt(size_t index) = 0;
///
/// Gets the IGameMode at the specified index.
/// @param index The index of the game modes array.
/// @returns A pointer to the IGameMode at that index, or nullptr if the index is out of bounds.
///
/* 44h */ virtual IGameMode* GetGameModeAt(size_t index) = 0;
/* 48h */ virtual int func48h(int) = 0;
///
/// Sets the active game mode to be the one with the specified name. If there's already an active mode,
/// the method IGameMode::OnExit() will be called on it. The method IGameMode::OnEnter() will be called on
/// the moed at the specified index. A message with ID kMsgOnModeEnter will be generated.
/// @param pName The name of the game mode to set as active.
/// @returns True if the mode was found and set active, false otherwise.
///
/* 4Ch */ virtual bool SetActiveModeByName(const char* pName) = 0;
///
/// Gets the ICameraManager instance used in this mode manager, and that manages the active camera of the active game mode.
///
/* 50h */ virtual ICameraManager* GetCameraManager() = 0;
///
/// Sets the Viewer instance that is used for rendering the main game frame.
/// @param pViewer The Viewer instance.
///
/* 54h */ virtual void SetViewer(cViewer* pViewer) = 0;
///
/// Returns the Viewer instance that is being used for rendering the main game frame.
///
/* 58h */ virtual cViewer* GetViewer() = 0;
///
/// Gets the active game mode manager.
///
static IGameModeManager* Get();
};
inline cViewer* GetViewer()
{
auto mgr = IGameModeManager::Get();
return mgr ? mgr->GetViewer() : nullptr;
}
/////////////////////////////////
//// INTERNAL IMPLEMENTATION ////
/////////////////////////////////
namespace Addresses(IGameModeManager)
{
DeclareAddress(Get);
}
}