Godot 4 源码分析 - 命令行参数

 粗看Godot 4的源码,稍微调试一下,发现一大堆的命令行参数。在widechar_main中

Error err = Main::setup(argv_utf8[0], argc - 1, &argv_utf8[1]);

 Main::setup中,各命令行参数加入到List args中,并通过OS::get_singleton()->get_cmdline_platform_args()取得平台相关命令行参数,然后args逐项处理。

命令行参考

常规选项 - 显示命令行选项列表

-h--help/?

显示命令行选项列表。

if (I->get() == "-h" || I->get() == "--help" || I->get() == "/?") { // display help
	show_help = true;
	exit_code = ERR_HELP; // Hack to force an early exit in `main()` with a success code.
	goto error;

}

然后调用print_help

void Main::print_help(const char *p_binary) {
	print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE));
	OS::get_singleton()->print("Free and open source software under the terms of the MIT license.\n");
	OS::get_singleton()->print("(c) 2014-present Godot Engine contributors.\n");
	OS::get_singleton()->print("(c) 2007-2014 Juan Linietsky, Ariel Manzur.\n");
	OS::get_singleton()->print("\n");
	OS::get_singleton()->print("Usage: %s [options] [path to scene or 'project.godot' file]\n", p_binary);
	OS::get_singleton()->print("\n");

	OS::get_singleton()->print("General options:\n");
	OS::get_singleton()->print("  -h, --help                        Display this help message.\n");
	OS::get_singleton()->print("  --version                         Display the version string.\n");
	OS::get_singleton()->print("  -v, --verbose                     Use verbose stdout mode.\n");
	OS::get_singleton()->print("  -q, --quiet                       Quiet mode, silences stdout messages. Errors are still displayed.\n");
	OS::get_singleton()->print("\n");

	OS::get_singleton()->print("Run options:\n");
	OS::get_singleton()->print("  --, ++                            Separator for user-provided arguments. Following arguments are not used by the engine, but can be read from `OS.get_cmdline_user_args()`.\n");
#ifdef TOOLS_ENABLED
	OS::get_singleton()->print("  -e, --editor                      Start the editor instead of running the scene.\n");
	OS::get_singleton()->print("  -p, --project-manager             Start the project manager, even if a project is auto-detected.\n");
	OS::get_singleton()->print("  --debug-server               Start the editor debug server (://[:], e.g. tcp://127.0.0.1:6007)\n");
#endif
	OS::get_singleton()->print("  --quit                            Quit after the first iteration.\n");
	OS::get_singleton()->print("  -l, --language            Use a specific locale ( being a two-letter code).\n");
	OS::get_singleton()->print("  --path                 Path to a project ( must contain a 'project.godot' file).\n");
	OS::get_singleton()->print("  -u, --upwards                     Scan folders upwards for project.godot file.\n");
	OS::get_singleton()->print("  --main-pack                 Path to a pack (.pck) file to load.\n");
	OS::get_singleton()->print("  --render-thread             Render thread mode ['unsafe', 'safe', 'separate'].\n");
	OS::get_singleton()->print("  --remote-fs 
Remote filesystem ([:] address).\n"); OS::get_singleton()->print(" --remote-fs-password Password for remote filesystem.\n"); OS::get_singleton()->print(" --audio-driver Audio driver ["); for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) { if (i > 0) { OS::get_singleton()->print(", "); } OS::get_singleton()->print("'%s'", AudioDriverManager::get_driver(i)->get_name()); } OS::get_singleton()->print("].\n"); OS::get_singleton()->print(" --display-driver Display driver (and rendering driver) ["); for (int i = 0; i < DisplayServer::get_create_function_count(); i++) { if (i > 0) { OS::get_singleton()->print(", "); } OS::get_singleton()->print("'%s' (", DisplayServer::get_create_function_name(i)); Vector rd = DisplayServer::get_create_function_rendering_drivers(i); for (int j = 0; j < rd.size(); j++) { if (j > 0) { OS::get_singleton()->print(", "); } OS::get_singleton()->print("'%s'", rd[j].utf8().get_data()); } OS::get_singleton()->print(")"); } OS::get_singleton()->print("].\n"); OS::get_singleton()->print(" --rendering-method Renderer name. Requires driver support.\n"); OS::get_singleton()->print(" --rendering-driver Rendering driver (depends on display driver).\n"); OS::get_singleton()->print(" --gpu-index Use a specific GPU (run with --verbose to get available device list).\n"); OS::get_singleton()->print(" --text-driver Text driver (Fonts, BiDi, shaping).\n"); OS::get_singleton()->print(" --tablet-driver Pen tablet input driver.\n"); OS::get_singleton()->print(" --headless Enable headless mode (--display-driver headless --audio-driver Dummy). Useful for servers and with --script.\n"); OS::get_singleton()->print(" --write-movie Writes a video to the specified path (usually with .avi or .png extension).\n"); OS::get_singleton()->print(" --fixed-fps is forced when enabled, but it can be used to change movie FPS.\n"); OS::get_singleton()->print(" --disable-vsync can speed up movie writing but makes interaction more difficult.\n"); OS::get_singleton()->print("\n"); OS::get_singleton()->print("Display options:\n"); OS::get_singleton()->print(" -f, --fullscreen Request fullscreen mode.\n"); OS::get_singleton()->print(" -m, --maximized Request a maximized window.\n"); OS::get_singleton()->print(" -w, --windowed Request windowed mode.\n"); OS::get_singleton()->print(" -t, --always-on-top Request an always-on-top window.\n"); OS::get_singleton()->print(" --resolution x Request window resolution.\n"); OS::get_singleton()->print(" --position , Request window position (if set, screen argument is ignored).\n"); OS::get_singleton()->print(" --screen Request window screen.\n"); OS::get_singleton()->print(" --single-window Use a single window (no separate subwindows).\n"); OS::get_singleton()->print(" --xr-mode Select XR (Extended Reality) mode ['default', 'off', 'on'].\n"); OS::get_singleton()->print("\n"); OS::get_singleton()->print("Debug options:\n"); OS::get_singleton()->print(" -d, --debug Debug (local stdout debugger).\n"); OS::get_singleton()->print(" -b, --breakpoints Breakpoint list as source::line comma-separated pairs, no spaces (use %%20 instead).\n"); OS::get_singleton()->print(" --profiling Enable profiling in the script debugger.\n"); OS::get_singleton()->print(" --gpu-profile Show a GPU profile of the tasks that took the most time during frame rendering.\n"); OS::get_singleton()->print(" --gpu-validation Enable graphics API validation layers for debugging.\n"); #if DEBUG_ENABLED OS::get_singleton()->print(" --gpu-abort Abort on graphics API usage errors (usually validation layer errors). May help see the problem if your system freezes.\n"); #endif OS::get_singleton()->print(" --remote-debug Remote debug (://[:], e.g. tcp://127.0.0.1:6007).\n"); #if defined(DEBUG_ENABLED) OS::get_singleton()->print(" --debug-collisions Show collision shapes when running the scene.\n"); OS::get_singleton()->print(" --debug-paths Show path lines when running the scene.\n"); OS::get_singleton()->print(" --debug-navigation Show navigation polygons when running the scene.\n"); OS::get_singleton()->print(" --debug-stringnames Print all StringName allocations to stdout when the engine quits.\n"); #endif OS::get_singleton()->print(" --frame-delay Simulate high CPU load (delay each frame by milliseconds).\n"); OS::get_singleton()->print(" --time-scale Force time scale (higher values are faster, 1.0 is normal speed).\n"); OS::get_singleton()->print(" --disable-vsync Forces disabling of vertical synchronization, even if enabled in the project settings. Does not override driver-level V-Sync enforcement.\n"); OS::get_singleton()->print(" --disable-render-loop Disable render loop so rendering only occurs when called explicitly from script.\n"); OS::get_singleton()->print(" --disable-crash-handler Disable crash handler when supported by the platform code.\n"); OS::get_singleton()->print(" --fixed-fps Force a fixed number of frames per second. This setting disables real-time synchronization.\n"); OS::get_singleton()->print(" --print-fps Print the frames per second to the stdout.\n"); OS::get_singleton()->print("\n"); OS::get_singleton()->print("Standalone tools:\n"); OS::get_singleton()->print(" -s, --script

你可能感兴趣的:(godot,游戏引擎)