Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
GameSetup.h
Go to the documentation of this file.
1/* Copyright (C) 2026 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_GAMESETUP
19#define INCLUDED_GAMESETUP
20
21#include "ps/CStr.h"
22#include "ps/Input.h"
23
24#include <queue>
25#include <vector>
26
27class CmdLineArgs;
28class Paths;
29namespace Script { class Context; }
30namespace Script { class Interface; }
31
32/**
33 * initialize global modules that are be needed before Init.
34 * must be called from the very beginning of main.
35 **/
36extern void EarlyInit();
37
38extern void EndGame();
39
41{
42 // avoid setting a video mode / initializing OpenGL; assume that has
43 // already been done and everything is ready for rendering.
44 // needed by map editor because it creates its own window.
46
47 // skip initializing the in-game GUI.
48 // needed by map editor because it uses its own GUI.
50
51 // initialize the mod folders from command line parameters
53
54 // mount the public mod
55 // needed by the map editor as "mod" does not provide everything it needs
57};
58
59extern const std::vector<CStr>& GetMods(const CmdLineArgs& args, int flags);
60
61/**
62 * Mounts all files of the given mods in the global VFS.
63 * Make sure to call CacheEnabledModVersions after every call to this.
64 */
65extern void MountMods(const Paths& paths, const std::vector<CStr>& mods);
66
67void InitVfs(const CmdLineArgs& args);
68
69/**
70 * Returns true if successful, false if Init is aborted early (for instance if
71 * mods changed, or if we are using -dumpSchema).
72 * `ShutdownConfigAndSubsequent` has to be called later.
73 */
74extern bool Init(const CmdLineArgs& args, int flags);
75
76using InputHandlers = std::queue<Input::Handler<Input::Reaction(&)(const SDL_Event&)>>;
77[[nodiscard]] std::unique_ptr<InputHandlers> MakeInputHandlers();
78
79/**
80 * `ShutdownNetworkAndUI` has to be called later.
81 */
82[[nodiscard]] std::unique_ptr<InputHandlers> InitGraphics(const CmdLineArgs& args, int flags,
83 const std::vector<CStr>& installedMods, Script::Context& scriptContext,
84 Script::Interface& scriptInterface);
85
86/**
87 * `ShutdownNetworkAndUI` has to be called later.
88 */
89extern bool InitNonVisual(const CmdLineArgs& args);
90
91/**
92 * Has to be called before `ShutdownConfigAndSubsequent`.
93 */
96
97extern void CancelLoad(const CStrW& message);
98
99extern bool InDevelopmentCopy();
100
101#endif // INCLUDED_GAMESETUP
void MountMods(const Paths &paths, const std::vector< CStr > &mods)
Mounts all files of the given mods in the global VFS.
Definition: GameSetup.cpp:159
bool InitNonVisual(const CmdLineArgs &args)
ShutdownNetworkAndUI has to be called later.
Definition: GameSetup.cpp:661
void EarlyInit()
initialize global modules that are be needed before Init.
Definition: GameSetup.cpp:459
void EndGame()
Definition: GameSetup.cpp:315
bool Init(const CmdLineArgs &args, int flags)
Returns true if successful, false if Init is aborted early (for instance if mods changed,...
Definition: GameSetup.cpp:487
std::unique_ptr< InputHandlers > InitGraphics(const CmdLineArgs &args, int flags, const std::vector< CStr > &installedMods, Script::Context &scriptContext, Script::Interface &scriptInterface)
ShutdownNetworkAndUI has to be called later.
Definition: GameSetup.cpp:595
bool InDevelopmentCopy()
Definition: GameSetup.cpp:883
std::queue< Input::Handler< Input::Reaction(&)(const SDL_Event &)> > InputHandlers
Definition: GameSetup.h:76
void CancelLoad(const CStrW &message)
Definition: GameSetup.cpp:868
void ShutdownNetworkAndUI()
Has to be called before ShutdownConfigAndSubsequent.
Definition: GameSetup.cpp:328
std::unique_ptr< InputHandlers > MakeInputHandlers()
Definition: GameSetup.cpp:248
void InitVfs(const CmdLineArgs &args)
Definition: GameSetup.cpp:191
const std::vector< CStr > & GetMods(const CmdLineArgs &args, int flags)
InitFlags
Definition: GameSetup.h:41
@ INIT_MODS
Definition: GameSetup.h:52
@ INIT_MODS_PUBLIC
Definition: GameSetup.h:56
@ INIT_NO_GUI
Definition: GameSetup.h:49
@ INIT_HAVE_VMODE
Definition: GameSetup.h:45
void ShutdownConfigAndSubsequent()
Definition: GameSetup.cpp:362
Definition: CmdLineArgs.h:31
Usable type to register a handler to the associated Manager.
Definition: Input.h:180
Wrapper class for OS paths used by the game.
Definition: Paths.h:29
Definition: Context.h:51
Definition: Interface.h:93
Reaction
Definition: Input.h:39
Abstraction around a SpiderMonkey JSContext.
Definition: DapInterface.h:32