From 93f1fb1c2f74de3ff996895761d083fadd257397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 19 Aug 2017 16:45:03 +0200 Subject: [PATCH] Fixes for new two-dash long command line arguments - Fixes some single-dash leftovers that were missed in the previous commit - Reorder the help output for clarity, and document missing options - Drop obsolete options: --noop, --pack, --editor-scene, --level, --import, --import-script, --no-quit - Improve error message on malformed arguments and do not display help on error - Always use long form of arguments when starting a new Godot process from C++, for clarity and easy grepping - Cleanup obsolete code here and there --- core/bind/core_bind.cpp | 7 - core/bind/core_bind.h | 2 - core/engine.h | 3 - doc/base/classes.xml | 7 - editor/editor_export.cpp | 36 +-- editor/editor_node.cpp | 47 --- editor/editor_run.cpp | 24 +- editor/run_settings_dialog.cpp | 2 - main/main.cpp | 272 ++++++++---------- platform/android/export/export.cpp | 28 +- platform/android/godot_android.cpp | 1 - .../java/src/org/godotengine/godot/Godot.java | 12 +- platform/android/java_glue.cpp | 4 +- platform/iphone/view_controller.mm | 2 +- platform/uwp/app.cpp | 2 +- platform/uwp/export/export.cpp | 2 +- 16 files changed, 169 insertions(+), 282 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 185c2e670cb..1c9eef3d167 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -2534,11 +2534,6 @@ float _Engine::get_frames_per_second() const { return Engine::get_singleton()->get_frames_per_second(); } -String _Engine::get_custom_level() const { - - return Engine::get_singleton()->get_custom_level(); -} - void _Engine::set_time_scale(float p_scale) { Engine::get_singleton()->set_time_scale(p_scale); } @@ -2588,8 +2583,6 @@ void _Engine::_bind_methods() { ClassDB::bind_method(D_METHOD("set_time_scale", "time_scale"), &_Engine::set_time_scale); ClassDB::bind_method(D_METHOD("get_time_scale"), &_Engine::get_time_scale); - ClassDB::bind_method(D_METHOD("get_custom_level"), &_Engine::get_custom_level); - ClassDB::bind_method(D_METHOD("get_frames_drawn"), &_Engine::get_frames_drawn); ClassDB::bind_method(D_METHOD("get_frames_per_second"), &_Engine::get_frames_per_second); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 71038cd5a6d..d3314cc3b36 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -639,8 +639,6 @@ public: void set_time_scale(float p_scale); float get_time_scale(); - String get_custom_level() const; - MainLoop *get_main_loop() const; Dictionary get_version_info() const; diff --git a/core/engine.h b/core/engine.h index 1a07f5d1dfe..c46ae1cb642 100644 --- a/core/engine.h +++ b/core/engine.h @@ -39,7 +39,6 @@ class Engine { friend class Main; - String _custom_level; uint64_t frames_drawn; uint32_t _frame_delay; uint64_t _frame_ticks; @@ -70,8 +69,6 @@ public: virtual float get_frames_per_second() const { return _fps; } - String get_custom_level() const { return _custom_level; } - uint64_t get_frames_drawn(); uint64_t get_fixed_frames() const { return _fixed_frames; } diff --git a/doc/base/classes.xml b/doc/base/classes.xml index f21fa2c7c06..2912a3f0a4a 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -14960,13 +14960,6 @@ - - - - - Returns the value of the commandline argument "-level". - - diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index fe1dfa281c0..d8d35546125 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -229,17 +229,17 @@ void EditorExportPlatform::gen_debug_flags(Vector &r_flags, int p_flags) if (p_flags & DEBUG_FLAG_DUMB_CLIENT) { int port = EditorSettings::get_singleton()->get("filesystem/file_server/port"); String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password"); - r_flags.push_back("-rfs"); + r_flags.push_back("--remote-fs"); r_flags.push_back(host + ":" + itos(port)); if (passwd != "") { - r_flags.push_back("-rfs_pass"); + r_flags.push_back("--remote-fs-password"); r_flags.push_back(passwd); } } if (p_flags & DEBUG_FLAG_REMOTE_DEBUG) { - r_flags.push_back("-rdebug"); + r_flags.push_back("--remote-debug"); r_flags.push_back(host + ":" + String::num(remote_port)); @@ -248,7 +248,7 @@ void EditorExportPlatform::gen_debug_flags(Vector &r_flags, int p_flags) if (breakpoints.size()) { - r_flags.push_back("-bp"); + r_flags.push_back("--breakpoints"); String bpoints; for (const List::Element *E = breakpoints.front(); E; E = E->next()) { @@ -263,12 +263,12 @@ void EditorExportPlatform::gen_debug_flags(Vector &r_flags, int p_flags) if (p_flags & DEBUG_FLAG_VIEW_COLLISONS) { - r_flags.push_back("-debugcol"); + r_flags.push_back("--debug-collisions"); } if (p_flags & DEBUG_FLAG_VIEW_NAVIGATION) { - r_flags.push_back("-debugnav"); + r_flags.push_back("--debug-navigation"); } } @@ -714,17 +714,17 @@ void EditorExportPlatform::gen_export_flags(Vector &r_flags, int p_flags if (p_flags & DEBUG_FLAG_DUMB_CLIENT) { int port = EditorSettings::get_singleton()->get("filesystem/file_server/port"); String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password"); - r_flags.push_back("-rfs"); + r_flags.push_back("--remote-fs"); r_flags.push_back(host + ":" + itos(port)); if (passwd != "") { - r_flags.push_back("-rfs_pass"); + r_flags.push_back("--remote-fs-password"); r_flags.push_back(passwd); } } if (p_flags & DEBUG_FLAG_REMOTE_DEBUG) { - r_flags.push_back("-rdebug"); + r_flags.push_back("--remote-debug"); r_flags.push_back(host + ":" + String::num(remote_port)); @@ -733,7 +733,7 @@ void EditorExportPlatform::gen_export_flags(Vector &r_flags, int p_flags if (breakpoints.size()) { - r_flags.push_back("-bp"); + r_flags.push_back("--breakpoints"); String bpoints; for (const List::Element *E = breakpoints.front(); E; E = E->next()) { @@ -748,12 +748,12 @@ void EditorExportPlatform::gen_export_flags(Vector &r_flags, int p_flags if (p_flags & DEBUG_FLAG_VIEW_COLLISONS) { - r_flags.push_back("-debugcol"); + r_flags.push_back("--debug-collisions"); } if (p_flags & DEBUG_FLAG_VIEW_NAVIGATION) { - r_flags.push_back("-debugnav"); + r_flags.push_back("--debug-navigation"); } } EditorExportPlatform::EditorExportPlatform() { @@ -2231,17 +2231,17 @@ void EditorExportPlatform::gen_export_flags(Vector &r_flags, int p_flags if (p_flags&EXPORT_DUMB_CLIENT) { int port = EditorSettings::get_singleton()->get("filesystem/file_server/port"); String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password"); - r_flags.push_back("-rfs"); + r_flags.push_back("--remote-fs"); r_flags.push_back(host+":"+itos(port)); if (passwd!="") { - r_flags.push_back("-rfs_pass"); + r_flags.push_back("--remote-fs-password"); r_flags.push_back(passwd); } } if (p_flags&EXPORT_REMOTE_DEBUG) { - r_flags.push_back("-rdebug"); + r_flags.push_back("--remote-debug"); r_flags.push_back(host+":"+String::num(remote_port)); @@ -2251,7 +2251,7 @@ void EditorExportPlatform::gen_export_flags(Vector &r_flags, int p_flags if (breakpoints.size()) { - r_flags.push_back("-bp"); + r_flags.push_back("--breakpoints"); String bpoints; for(const List::Element *E=breakpoints.front();E;E=E->next()) { @@ -2267,12 +2267,12 @@ void EditorExportPlatform::gen_export_flags(Vector &r_flags, int p_flags if (p_flags&EXPORT_VIEW_COLLISONS) { - r_flags.push_back("-debugcol"); + r_flags.push_back("--debug-collisions"); } if (p_flags&EXPORT_VIEW_NAVIGATION) { - r_flags.push_back("-debugnav"); + r_flags.push_back("--debug-navigation"); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index adf6d8e06fa..6f29a8695cd 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1851,47 +1851,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) { _playing_edited = p_current; } -void EditorNode::_cleanup_scene() { - -#if 0 - Node *scene = editor_data.get_edited_scene_root(); - editor_selection->clear(); - editor_data.clear_editor_states(); - editor_history.clear(); - _hide_top_editors(); - animation_editor->cleanup(); - property_editor->edit(NULL); - resources_dock->cleanup(); - scene_import_metadata.unref(); - //set_edited_scene(NULL); - if (scene) { - if (scene->get_filename()!="") { - previous_scenes.push_back(scene->get_filename()); - } - - memdelete(scene); - } - editor_data.get_undo_redo().clear_history(); - saved_version=editor_data.get_undo_redo().get_version(); - run_settings_dialog->set_run_mode(0); - run_settings_dialog->set_custom_arguments("-l $scene"); - - List > cached; - ResourceCache::get_cached_resources(&cached); - - for(List >::Element *E=cached.front();E;E=E->next()) { - - String path = E->get()->get_path(); - if (path.is_resource_file()) { - ERR_PRINT(("Stray resource not cleaned:"+path).utf8().get_data()); - } - - } - - _update_title(); -#endif -} - void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { //print_line("option "+itos(p_option)+" confirm "+itos(p_confirmed)); @@ -1915,8 +1874,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { _scene_tab_changed(idx); editor_data.clear_editor_states(); - //_cleanup_scene(); - } break; case FILE_NEW_INHERITED_SCENE: case FILE_OPEN_SCENE: { @@ -2737,8 +2694,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { import_reload_fn = scene->get_filename(); _save_scene(import_reload_fn); - _cleanup_scene(); - } @@ -3328,8 +3283,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b _scene_tab_changed(idx); } - //_cleanup_scene(); // i'm sorry but this MUST happen to avoid modified resources to not be reloaded. - dependency_errors.clear(); Ref sdata = ResourceLoader::load(lpath, "", true); diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 979aa351e1b..9a0731eb557 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -58,7 +58,7 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li args.push_back(itos(OS::get_singleton()->get_process_id())); if (debug_collisions) { - args.push_back("--debug-collision"); + args.push_back("--debug-collisions"); } if (debug_navigation) { @@ -66,7 +66,6 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li } int screen = EditorSettings::get_singleton()->get("run/window_placement/screen"); - if (screen == 0) { screen = OS::get_singleton()->get_current_screen(); } else { @@ -78,7 +77,6 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li screen_rect.size = OS::get_singleton()->get_screen_size(screen); Size2 desired_size; - desired_size.x = ProjectSettings::get_singleton()->get("display/window/size/width"); desired_size.y = ProjectSettings::get_singleton()->get("display/window/size/height"); @@ -95,39 +93,39 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li switch (window_placement) { case 0: { // top left - args.push_back("-p"); - args.push_back(itos(screen_rect.position.x) + "x" + itos(screen_rect.position.y)); + args.push_back("--position"); + args.push_back(itos(screen_rect.position.x) + "," + itos(screen_rect.position.y)); } break; case 1: { // centered Vector2 pos = screen_rect.position + ((screen_rect.size - desired_size) / 2).floor(); - args.push_back("-p"); + args.push_back("--position"); args.push_back(itos(pos.x) + "," + itos(pos.y)); } break; case 2: { // custom pos Vector2 pos = EditorSettings::get_singleton()->get("run/window_placement/rect_custom_position"); pos += screen_rect.position; - args.push_back("-p"); + args.push_back("--position"); args.push_back(itos(pos.x) + "," + itos(pos.y)); } break; case 3: { // force maximized Vector2 pos = screen_rect.position; - args.push_back("-p"); + args.push_back("--position"); args.push_back(itos(pos.x) + "," + itos(pos.y)); - args.push_back("-m"); + args.push_back("--maximized"); } break; case 4: { // force fullscreen Vector2 pos = screen_rect.position; - args.push_back("-p"); + args.push_back("--position"); args.push_back(itos(pos.x) + "," + itos(pos.y)); - args.push_back("-f"); + args.push_back("--fullscreen"); } break; } if (p_breakpoints.size()) { - args.push_back("-b"); + args.push_back("--breakpoints"); String bpoints; for (const List::Element *E = p_breakpoints.front(); E; E = E->next()) { @@ -152,7 +150,7 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li String exec = OS::get_singleton()->get_executable_path(); - printf("running: %ls", exec.c_str()); + printf("Running: %ls", exec.c_str()); for (List::Element *E = args.front(); E; E = E->next()) { printf(" %ls", E->get().c_str()); diff --git a/editor/run_settings_dialog.cpp b/editor/run_settings_dialog.cpp index 4548ae0939f..dfb152d40bc 100644 --- a/editor/run_settings_dialog.cpp +++ b/editor/run_settings_dialog.cpp @@ -88,7 +88,5 @@ RunSettingsDialog::RunSettingsDialog() { get_ok()->set_text(TTR("Close")); //get_cancel()->set_text("Close"); - arguments->set_text("-l $scene"); - set_title(TTR("Scene Run Settings")); } diff --git a/main/main.cpp b/main/main.cpp index a09fd694737..e49c66dddfb 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "main.h" + #include "app_icon.gen.h" #include "core/register_core_types.h" #include "drivers/register_driver_types.h" @@ -110,6 +111,7 @@ static bool force_lowdpi = false; static int init_screen = -1; static bool use_vsync = true; static bool editor = false; +static bool show_help = false; static OS::ProcessID allow_focus_steal_pid = 0; @@ -128,63 +130,88 @@ static String unescape_cmdline(const String &p_str) { void Main::print_help(const char *p_binary) { - OS::get_singleton()->print(VERSION_FULL_NAME " (c) 2008-2017 Juan Linietsky, Ariel Manzur.\n"); + OS::get_singleton()->print(VERSION_FULL_NAME " - https://godotengine.org\n"); + OS::get_singleton()->print("(c) 2007-2017 Juan Linietsky, Ariel Manzur.\n"); + OS::get_singleton()->print("(c) 2014-2017 Godot Engine contributors.\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("Options:\n"); + 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(" --path Path to the project ( must contain a 'project.godot' file).\n"); + OS::get_singleton()->print(" -v, --verbose Use verbose stdout mode.\n"); + OS::get_singleton()->print(" --quiet Quiet mode, silences stdout messages. Errors are still displayed.\n"); + OS::get_singleton()->print("\n"); + + OS::get_singleton()->print("Run options:\n"); #ifdef TOOLS_ENABLED - OS::get_singleton()->print(" -e, --editor Bring up the editor instead of running the scene.\n"); + 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"); #endif - OS::get_singleton()->print(" --test Run a test ("); - const char **test_names = tests_get_names(); - const char *coma = ""; - while (*test_names) { - - OS::get_singleton()->print("%s'%s'", coma, *test_names); - test_names++; - coma = ", "; - } - OS::get_singleton()->print(").\n"); - - OS::get_singleton()->print(" -r, --resolution x Request window resolution.\n"); - OS::get_singleton()->print(" -p, --position , Request window position.\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(" --video-driver Video driver ("); - for (int i = 0; i < OS::get_singleton()->get_video_driver_count(); i++) { - - if (i != 0) - OS::get_singleton()->print(", "); - OS::get_singleton()->print("'%s'", OS::get_singleton()->get_video_driver_name(i)); - } - OS::get_singleton()->print(").\n"); - OS::get_singleton()->print(" --low-dpi Force low-DPI mode (macOS only).\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(" --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 < OS::get_singleton()->get_audio_driver_count(); i++) { - if (i != 0) OS::get_singleton()->print(", "); OS::get_singleton()->print("'%s'", OS::get_singleton()->get_audio_driver_name(i)); } OS::get_singleton()->print(").\n"); - OS::get_singleton()->print(" --render-thread Render thread mode ('unsafe', 'safe', 'separate').\n"); - OS::get_singleton()->print(" -s, --script