Skip to content

Commit

Permalink
Add CLI parameter for running without graphics
Browse files Browse the repository at this point in the history
Resolves #1547.
  • Loading branch information
tslocum committed Sep 24, 2023
1 parent 145576d commit fb531fc
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions copying.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ _the openage authors_ are:
| Derek Frogget | FoggyLight | fro22003 à byui dawt edu |
| Martin | Starman | mstarman à seznam dawt cz |
| Zoltán Ács | zoli111 | acszoltan111 à gmail dawt com |
| Trevor Slocum | tslocum | trevor à rocket9labs dawt com |

If you're a first-time committer, add yourself to the above list. This is not
just for legal reasons, but also to keep an overview of all those nicknames.
Expand Down
6 changes: 5 additions & 1 deletion libopenage/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ int run_game(const main_arguments &args) {
auto cvar_manager = std::make_shared<cvar::CVarManager>(args.root_path["cfg"]);
cvar_manager->load_all();

// TODO: select run_mode by launch argument
// set engine run_mode
openage::engine::Engine::mode run_mode = openage::engine::Engine::mode::FULL;
if (args.headless) {
run_mode = openage::engine::Engine::mode::HEADLESS;
}

openage::engine::Engine engine{run_mode, args.root_path, args.mods};

engine.loop();
Expand Down
2 changes: 2 additions & 0 deletions libopenage/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ namespace openage {
* Path root_path
* int32_t fps_limit
* bool gl_debug
* bool headless
* vector[string] mods
*/
struct main_arguments {
util::Path root_path;
int32_t fps_limit;
bool gl_debug;
bool headless;
std::vector<std::string> mods;
};

Expand Down
4 changes: 4 additions & 0 deletions openage/game/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def init_subparser(cli: ArgumentParser) -> None:
"--gl-debug", action='store_true',
help="throw exceptions directly from the OpenGL calls")

cli.add_argument(
"--headless", action='store_true',
help="run without displaying graphics")

cli.add_argument(
"--modpacks", nargs="+", type=bytes,
help="list of modpacks to load")
Expand Down
3 changes: 3 additions & 0 deletions openage/game/main_cpp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def run_game(args, root_path):
# opengl debugging
args_cpp.gl_debug = args.gl_debug

# headless mode
args_cpp.headless = args.headless

# run the game!
with nogil:
result = run_game_cpp(args_cpp)
Expand Down
4 changes: 4 additions & 0 deletions openage/main/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def init_subparser(cli: ArgumentParser):
"--gl-debug", action='store_true',
help="throw exceptions directly from the OpenGL calls")

cli.add_argument(
"--headless", action='store_true',
help="run without displaying graphics")

cli.add_argument(
"--modpacks", nargs="+",
help="list of modpacks to load")
Expand Down
3 changes: 3 additions & 0 deletions openage/main/main_cpp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def run_game(args, root_path):
# opengl debugging
args_cpp.gl_debug = args.gl_debug

# headless mode
args_cpp.headless = args.headless

# mods
if args.modpacks is not None:
args_cpp.mods = args.modpacks
Expand Down

0 comments on commit fb531fc

Please sign in to comment.