forked from EasyRPG/Player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.h
495 lines (388 loc) · 11 KB
/
player.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
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
/*
* This file is part of EasyRPG Player.
*
* EasyRPG Player 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.
*
* EasyRPG Player 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 EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EP_PLAYER_H
#define EP_PLAYER_H
// Headers
#include "fileext_guesser.h"
#include "meta.h"
#include "translation.h"
#include "game_clock.h"
#include "game_config.h"
#include "game_config_game.h"
#include <vector>
#include <memory>
#include <cstdint>
/**
* Player namespace.
*/
namespace Player {
/** Bitmask for type of emulated engine */
enum EngineType {
EngineNone = 0,
/** All versions of RPG Maker 2000 */
EngineRpg2k = 1,
/** All versions of RPG Maker 2003 */
EngineRpg2k3 = 2,
/** RPG Maker 2000 v1.50 or newer, 2003 v1.05 or newer */
EngineMajorUpdated = 4,
/** Official English translation (RPG Maker 2003 v1.10 or newer,
* or RPG Maker 2000 v.1.61 or newer) */
EngineEnglish = 8
};
/** Bitmask for activated patches */
enum PatchType {
PatchNone = 0,
/** DynRPG */
PatchDynRpg = 1,
/** ManiacPatch */
PatchManiac = 1 << 1,
/** Patches specified on command line, no autodetect */
PatchOverride = 1 << 16
};
/**
* Initializes EasyRPG Player.
*
* @param arguments Array of command line arguments
*/
void Init(std::vector<std::string> arguments);
/**
* Runs the game engine.
*/
void Run();
/**
* Runs the game loop.
*/
void MainLoop();
/**
* Pauses the game engine.
*/
void Pause();
/**
* Resumes the game engine.
*/
void Resume();
/**
* Updates EasyRPG Player.
*
* @param update_scene Whether to update the current scene.
*/
void Update(bool update_scene = true);
/**
* Process input events
*/
void UpdateInput();
/**
* Renders EasyRPG Player state to the screen
*/
void Draw();
/**
* Returns executed game frames since player start.
* Should be 60 fps when game ran fast enough.
*
* @return Update frames since player start
*/
int GetFrames();
/**
* Increment the frame counters.
*/
void IncFrame();
/**
* Exits EasyRPG Player.
*/
void Exit();
/**
* Parses the command line arguments.
*/
Game_Config ParseCommandLine();
/**
* Initializes all game objects
*/
void CreateGameObjects();
/**
* Change the resolution of the Player
*
* @param width new width
* @param height new height
* @return Whether the resolution change was successful
*/
bool ChangeResolution(int width, int height);
/**
* Restore the resolution of the Player on the base resolution (usually 320x240)
*/
void RestoreBaseResolution();
/**
* Resets all game objects. Faster then CreateGameObjects because
* the database is not reparsed.
*/
void ResetGameObjects();
/**
* Determine if the LDB and LMT files are not present, and if so, guess
* if they may have been renamed. Populates fileext_map.
*/
void GuessNonStandardExtensions();
/**
* Loads all databases.
*/
void LoadDatabase();
/**
* Loads the default fonts for text rendering.
*/
void LoadFonts();
/**
* Loads savegame data.
*
* @param save_file Savegame file to load
* @param save_id ID of the savegame to load
*/
void LoadSavegame(const std::string& save_file, int save_id = 0);
/**
* Starts a new game
*/
void SetupNewGame();
/**
* Starts a new game
*/
void SetupBattleTest();
/**
* Moves the player to the start map.
*/
void SetupPlayerSpawn();
/**
* Gets current codepage.
*
* @return current codepage
*/
std::string GetEncoding();
/** @return If engine is any version of RPG2k */
bool IsRPG2k();
/** @return If engine is any version of RPG2k3 */
bool IsRPG2k3();
/** @return If engine is RPG2k <= 1.10 */
bool IsRPG2kLegacy();
/** @return If engine is RPG2k3 <= v1.04 */
bool IsRPG2k3Legacy();
/** @return If engine is RPG2k >= 1.50 */
bool IsRPG2kUpdated();
/** @return If engine is RPG2k3 >= 1.05 */
bool IsRPG2k3Updated();
/**
* @return If engine is the official English RM2k release v.1.61 or newer.
* False if engine is RM2k3, Japanese, unofficial or v.1.60.
*/
bool IsRPG2kE();
/** @return If engine is the official English RM2k3 release (v1.10) or newer. */
bool IsRPG2k3E();
/** @return If engine is RPG2kLegacy() or RPG2k3Legacy() */
bool IsLegacy();
/** @return If engine is RPG2kUpdated() or RPG2k3Updated() */
bool IsMajorUpdatedVersion();
/**
* @return If engine is the official English release (and not RM2k v.1.60,
* which is hard to detect).
*/
bool IsEnglish();
/**
* @return true if encoding is CP932 (Shift-JIS, used for Japanese),
* false if not
*/
bool IsCP932();
/**
* @return true if encoding is CP949 (used for Korean), false if
* not
*/
bool IsCP949();
/**
* @return true if encoding is Big5 (CP950, used for Traditional
* Chinese), false if not
*/
bool IsBig5();
/**
* @return true if encoding is CP936 (used for Simplified Chinese)
* or false if not
*/
bool IsCP936();
/**
* @return true if game is in Chinese, Japanese, or Korean
* (based on the encoding), false otherwise
*/
bool IsCJK();
/**
* @return true if encoding is CP1251 (used for languages written in
* Cyrillic script) or false if not
*/
bool IsCP1251();
/** @return true when engine is 2k3 or the 2k3-commands patch is enabled */
bool IsRPG2k3Commands();
/** @return true when engine is 2k3e or the 2k3-commands patch is enabled */
bool IsRPG2k3ECommands();
/**
* @return True when the DynRPG patch is active
*/
bool IsPatchDynRpg();
/**
* @return True when the Maniac Patch is active
*/
bool IsPatchManiac();
/**
* @return True when Ineluki Key Patch is active
*/
bool IsPatchKeyPatch();
/**
* @return True when EasyRpg extensions are on
*/
bool HasEasyRpgExtensions();
/**
* @return Running engine version. 2000 for RPG2k and 2003 for RPG2k3
*/
int EngineVersion();
std::string GetEngineVersion();
/** @return full version string */
std::string GetFullVersionString();
/** Output program usage information on stdout */
void PrintUsage();
/** Set the desired rendering frames per second */
void SetTargetFps(int fps);
/** Exit code (optionally indicting an error) when program terminates. */
extern int exit_code;
/** Exit flag, if true will exit application on next Player::Update. */
extern bool exit_flag;
/** Reset flag, if true will restart game on next Player::Update. */
extern bool reset_flag;
/** Debug flag, if true will run game in debug mode. */
extern bool debug_flag;
/** Hide Title flag, if true title scene will run without image and music. */
extern bool hide_title_flag;
/** The width of the screen */
extern int screen_width;
/** The height of the screen */
extern int screen_height;
/** The X offset used to center UI in custom resolutions */
extern int menu_offset_x;
/** The Y offset used to center UI in custom resolutions */
extern int menu_offset_y;
/** The X offset used to center the MessageBox in custom resolutions */
extern int message_box_offset_x;
/** Whether the game uses a custom WinW/WinH resolution */
extern bool has_custom_resolution;
/** Overwrite party x position */
extern int party_x_position;
/** Overwrite party y position */
extern int party_y_position;
/** Overwrite starting party members */
extern std::vector<int> party_members;
/** Overwrite start map */
extern int start_map_id;
/** If set, savegame is loaded directly */
extern int load_game_id;
/** Prevent adding of RTP paths to the file finder */
extern bool no_rtp_flag;
/** Mutes audio playback */
extern bool no_audio_flag;
/** Is this project using EasyRPG files, or the RPG_RT format? */
extern bool is_easyrpg_project;
/** Encoding used */
extern std::string encoding;
/** Backslash recoded to utf8 string */
extern std::string escape_symbol;
/** Backslash recoded to character */
extern uint32_t escape_char;
/** Path to replay input log from */
extern std::string replay_input_path;
/** Path to record input log to */
extern std::string record_input_path;
/** The concatenated command line */
extern std::string command_line;
/** Game title. */
extern std::string game_title;
/** Meta class containing additional external data for this game. */
extern std::shared_ptr<Meta> meta;
/** File extension rewriter, for non-standard extensions. */
extern FileExtGuesser::RPG2KFileExtRemap fileext_map;
/** Language to use on game start (set via command line) */
extern std::string startup_language;
/** Translation manager, including list of languages and current translation. */
extern Translation translation;
/**
* The default speed modifier applied when the speed up button is pressed
* Only used for configuring the speedup, don't read this var directly use
* GetSpeedModifier() instead.
*/
extern int speed_modifier_a;
extern int speed_modifier_b;
/**
* The engine game logic configuration
*/
extern Game_ConfigPlayer player_config;
/** game specific configuration */
extern Game_ConfigGame game_config;
#ifdef EMSCRIPTEN
/** Name of game emscripten uses */
extern std::string emscripten_game_name;
#endif
}
inline bool Player::IsRPG2k() {
return (game_config.engine & EngineRpg2k) == EngineRpg2k;
}
inline bool Player::IsRPG2k3() {
return (game_config.engine & EngineRpg2k3) == EngineRpg2k3;
}
inline bool Player::IsRPG2kLegacy() {
return game_config.engine == EngineRpg2k;
}
inline bool Player::IsRPG2k3Legacy() {
return game_config.engine == EngineRpg2k3;
}
inline bool Player::IsLegacy() {
return IsRPG2kLegacy() || IsRPG2k3Legacy();
}
inline bool Player::IsMajorUpdatedVersion() {
return (game_config.engine & EngineMajorUpdated) == EngineMajorUpdated;
}
inline bool Player::IsEnglish() {
return (game_config.engine & EngineEnglish) == EngineEnglish;
}
inline bool Player::IsRPG2kUpdated() {
return (IsRPG2k() && IsMajorUpdatedVersion());
}
inline bool Player::IsRPG2k3Updated() {
return (IsRPG2k3() && IsMajorUpdatedVersion());
}
inline bool Player::IsRPG2kE() {
return (IsRPG2k() && IsEnglish());
}
inline bool Player::IsRPG2k3E() {
return (IsRPG2k3() && IsEnglish());
}
inline bool Player::IsRPG2k3Commands() {
return (IsRPG2k3() || game_config.patch_rpg2k3_commands.Get());
}
inline bool Player::IsRPG2k3ECommands() {
return (IsRPG2k3E() || game_config.patch_rpg2k3_commands.Get());
}
inline bool Player::IsPatchDynRpg() {
return game_config.patch_dynrpg.Get();
}
inline bool Player::IsPatchManiac() {
return game_config.patch_maniac.Get() > 0;
}
inline bool Player::IsPatchKeyPatch() {
return game_config.patch_key_patch.Get();
}
inline bool Player::HasEasyRpgExtensions() {
return game_config.patch_easyrpg.Get();
}
#endif