summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/bind/core_bind.cpp7
-rw-r--r--core/bind/core_bind.h2
-rw-r--r--core/engine.h3
-rw-r--r--doc/base/classes.xml7
-rw-r--r--editor/code_editor.cpp12
-rw-r--r--editor/editor_export.cpp36
-rw-r--r--editor/editor_node.cpp51
-rw-r--r--editor/editor_run.cpp38
-rw-r--r--editor/editor_settings.cpp1
-rw-r--r--editor/project_manager.cpp7
-rw-r--r--editor/run_settings_dialog.cpp2
-rw-r--r--main/main.cpp340
-rw-r--r--modules/gdnative/godot/string.h2
-rw-r--r--modules/visual_script/visual_script.cpp11
-rw-r--r--platform/android/export/export.cpp28
-rw-r--r--platform/android/godot_android.cpp1
-rw-r--r--platform/android/java/src/org/godotengine/godot/Godot.java12
-rw-r--r--platform/android/java_glue.cpp4
-rw-r--r--platform/iphone/view_controller.mm2
-rw-r--r--platform/uwp/app.cpp2
-rw-r--r--platform/uwp/export/export.cpp2
-rw-r--r--scene/gui/label.cpp5
-rw-r--r--scene/gui/scroll_bar.cpp54
-rw-r--r--scene/gui/scroll_bar.h7
-rw-r--r--scene/gui/text_edit.cpp87
-rw-r--r--scene/gui/text_edit.h7
-rw-r--r--scene/resources/style_box.cpp15
27 files changed, 391 insertions, 354 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 273ef78669..a3812e41b7 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);
}
@@ -2578,8 +2573,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 61c80aaba3..45416f5fd8 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 16dfb77593..fc3e151540 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;
@@ -67,8 +66,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 f21fa2c7c0..2912a3f0a4 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -14960,13 +14960,6 @@
<description>
</description>
<methods>
- <method name="get_custom_level" qualifiers="const">
- <return type="String">
- </return>
- <description>
- Returns the value of the commandline argument "-level".
- </description>
- </method>
<method name="get_frames_drawn">
<return type="int">
</return>
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 07c0945114..c33340ce69 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -1087,6 +1087,7 @@ void CodeTextEditor::update_editor_settings() {
text_editor->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
text_editor->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_breakpoint_gutter"));
text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
+ text_editor->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/open_scripts/smooth_scrolling"));
}
void CodeTextEditor::set_error(const String &p_error) {
@@ -1222,10 +1223,11 @@ CodeTextEditor::CodeTextEditor() {
error = memnew(Label);
status_bar->add_child(error);
error->hide();
+ error->set_clip_text(true); //do not change, or else very long errors can push the whole container to the right
error->set_valign(Label::VALIGN_CENTER);
error->add_color_override("font_color", Color(1, 0.7, 0.6, 0.9));
-
- status_bar->add_spacer();
+ error->set_h_size_flags(SIZE_EXPAND_FILL); //required for it to display, given now it's clipping contents, do not touch
+ //status_bar->add_spacer();
Label *line_txt = memnew(Label);
status_bar->add_child(line_txt);
@@ -1238,7 +1240,8 @@ CodeTextEditor::CodeTextEditor() {
status_bar->add_child(line_nb);
line_nb->set_valign(Label::VALIGN_CENTER);
line_nb->set_v_size_flags(SIZE_FILL);
- line_nb->set_autowrap(true); // workaround to prevent resizing the label on each change
+ line_nb->set_autowrap(true); // workaround to prevent resizing the label on each change, do not touch
+ line_nb->set_clip_text(true); // workaround to prevent resizing the label on each change, do not touch
line_nb->set_custom_minimum_size(Size2(40, 1) * EDSCALE);
Label *col_txt = memnew(Label);
@@ -1252,7 +1255,8 @@ CodeTextEditor::CodeTextEditor() {
status_bar->add_child(col_nb);
col_nb->set_valign(Label::VALIGN_CENTER);
col_nb->set_v_size_flags(SIZE_FILL);
- col_nb->set_autowrap(true); // workaround to prevent resizing the label on each change
+ col_nb->set_autowrap(true); // workaround to prevent resizing the label on each change, do not touch
+ col_nb->set_clip_text(true); // workaround to prevent resizing the label on each change, do not touch
col_nb->set_custom_minimum_size(Size2(40, 1) * EDSCALE);
text_editor->connect("gui_input", this, "_text_editor_gui_input");
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index fe1dfa281c..d8d3554612 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -229,17 +229,17 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &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<String> &r_flags, int p_flags)
if (breakpoints.size()) {
- r_flags.push_back("-bp");
+ r_flags.push_back("--breakpoints");
String bpoints;
for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) {
@@ -263,12 +263,12 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &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<String> &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<String> &r_flags, int p_flags
if (breakpoints.size()) {
- r_flags.push_back("-bp");
+ r_flags.push_back("--breakpoints");
String bpoints;
for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) {
@@ -748,12 +748,12 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &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<String> &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<String> &r_flags, int p_flags
if (breakpoints.size()) {
- r_flags.push_back("-bp");
+ r_flags.push_back("--breakpoints");
String bpoints;
for(const List<String>::Element *E=breakpoints.front();E;E=E->next()) {
@@ -2267,12 +2267,12 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &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 a5f0478854..9199ff825e 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1850,47 +1850,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<Ref<Resource> > cached;
- ResourceCache::get_cached_resources(&cached);
-
- for(List<Ref<Resource> >::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));
@@ -1914,8 +1873,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: {
@@ -2736,8 +2693,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();
-
}
@@ -2823,9 +2778,9 @@ void EditorNode::_discard_changes(const String &p_str) {
String exec = OS::get_singleton()->get_executable_path();
List<String> args;
- args.push_back("-path");
+ args.push_back("--path");
args.push_back(exec.get_base_dir());
- args.push_back("-pm");
+ args.push_back("--project-manager");
OS::ProcessID pid = 0;
Error err = OS::get_singleton()->execute(exec, args, false, &pid);
@@ -3327,8 +3282,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<PackedScene> sdata = ResourceLoader::load(lpath, "", true);
diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp
index 4954b1f741..28907ccf51 100644
--- a/editor/editor_run.cpp
+++ b/editor/editor_run.cpp
@@ -45,28 +45,27 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li
int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
if (resource_path != "") {
- args.push_back("-path");
+ args.push_back("--path");
args.push_back(resource_path.replace(" ", "%20"));
}
if (true) {
- args.push_back("-rdebug");
+ args.push_back("--remote-debug");
args.push_back(remote_host + ":" + String::num(remote_port));
}
- args.push_back("-epid");
+ args.push_back("--editor-pid");
args.push_back(String::num(OS::get_singleton()->get_process_id()));
if (debug_collisions) {
- args.push_back("-debugcol");
+ args.push_back("--debug-collisions");
}
if (debug_navigation) {
- args.push_back("-debugnav");
+ args.push_back("--debug-navigation");
}
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: { // default
- args.push_back("-p");
+ args.push_back("--position");
args.push_back(itos(screen_rect.position.x) + "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(itos(pos.x) + "x" + itos(pos.y));
+ 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(itos(pos.x) + "x" + itos(pos.y));
+ 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(itos(pos.x) + "x" + itos(pos.y));
- args.push_back("-mx");
+ args.push_back("--position");
+ args.push_back(itos(pos.x) + "," + itos(pos.y));
+ args.push_back("--maximized");
} break;
case 4: { // force fullscreen
Vector2 pos = screen_rect.position;
- args.push_back("-p");
- args.push_back(itos(pos.x) + "x" + itos(pos.y));
- args.push_back("-f");
+ args.push_back("--position");
+ args.push_back(itos(pos.x) + "," + itos(pos.y));
+ args.push_back("--fullscreen");
} break;
}
if (p_breakpoints.size()) {
- args.push_back("-bp");
+ args.push_back("--breakpoints");
String bpoints;
for (const List<String>::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<String>::Element *E = args.front(); E; E = E->next()) {
printf(" %ls", E->get().c_str());
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 70367f1e07..8494c7199e 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -615,6 +615,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("text_editor/line_numbers/line_length_guideline_column", 80);
hints["text_editor/line_numbers/line_length_guideline_column"] = PropertyInfo(Variant::INT, "text_editor/line_numbers/line_length_guideline_column", PROPERTY_HINT_RANGE, "20, 160, 10");
+ set("text_editor/open_scripts/smooth_scrolling", true);
set("text_editor/open_scripts/show_members_overview", true);
set("text_editor/files/trim_trailing_whitespace_on_save", false);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index dc0c888eea..769cf250c4 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -929,10 +929,10 @@ void ProjectManager::_open_project_confirm() {
List<String> args;
- args.push_back("-path");
+ args.push_back("--path");
args.push_back(path);
- args.push_back("-editor");
+ args.push_back("--editor");
String exec = OS::get_singleton()->get_executable_path();
@@ -969,7 +969,6 @@ void ProjectManager::_run_project_confirm() {
return;
}
-
const String &selected = E->key();
String path = EditorSettings::get_singleton()->get("projects/" + selected);
@@ -983,7 +982,7 @@ void ProjectManager::_run_project_confirm() {
List<String> args;
- args.push_back("-path");
+ args.push_back("--path");
args.push_back(path);
String exec = OS::get_singleton()->get_executable_path();
diff --git a/editor/run_settings_dialog.cpp b/editor/run_settings_dialog.cpp
index 4548ae0939..dfb152d40b 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 e00a482bde..14b6ac29ec 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -110,6 +110,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 String unescape_cmdline(const String &p_str) {
@@ -126,63 +127,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("Usage: %s [options] [scene]\n", p_binary);
- OS::get_singleton()->print("Options:\n");
- OS::get_singleton()->print("\t-path [dir] : Path to a game, containing project.godot\n");
-#ifdef TOOLS_ENABLED
- OS::get_singleton()->print("\t-e,-editor : Bring up the editor instead of running the scene.\n");
-#endif
- OS::get_singleton()->print("\t-test [test] : Run a test.\n");
- OS::get_singleton()->print("\t\t(");
- const char **test_names = tests_get_names();
- const char *coma = "";
- while (*test_names) {
+ 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("\n");
- OS::get_singleton()->print("%s%s", coma, *test_names);
- test_names++;
- coma = ", ";
- }
- OS::get_singleton()->print(")\n");
-
- OS::get_singleton()->print("\t-r WIDTHxHEIGHT\t : Request Window Resolution\n");
- OS::get_singleton()->print("\t-p XxY\t : Request Window Position\n");
- OS::get_singleton()->print("\t-f\t\t : Request Fullscreen\n");
- OS::get_singleton()->print("\t-mx\t\t Request Maximized\n");
- OS::get_singleton()->print("\t-w\t\t Request Windowed\n");
- OS::get_singleton()->print("\t-vd DRIVER\t : Video Driver (");
- for (int i = 0; i < OS::get_singleton()->get_video_driver_count(); i++) {
+ OS::get_singleton()->print("General options:\n");
+ OS::get_singleton()->print(" -h, --help Display this help message.\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 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(" -l, --language <locale> Use a specific locale (<locale> being a two-letter code).\n");
+ OS::get_singleton()->print(" --path <directory> Path to a project (<directory> must contain a 'project.godot' file).\n");
+ OS::get_singleton()->print(" --main-pack <file> Path to a pack (.pck) file to load.\n");
+ OS::get_singleton()->print(" --render-thread <mode> Render thread mode ('unsafe', 'safe', 'separate').\n");
+ OS::get_singleton()->print(" --remote-fs <address> Remote filesystem (<host/IP>[:<port>] address).\n");
+ OS::get_singleton()->print(" --remote-fs-password <password> Password for remote filesystem.\n");
+ OS::get_singleton()->print(" --audio-driver <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_video_driver_name(i));
+ OS::get_singleton()->print("'%s'", OS::get_singleton()->get_audio_driver_name(i));
}
- OS::get_singleton()->print(")\n");
- OS::get_singleton()->print("\t-ldpi\t : Force low-dpi mode (OSX Only)\n");
-
- OS::get_singleton()->print("\t-ad DRIVER\t : Audio Driver (");
- for (int i = 0; i < OS::get_singleton()->get_audio_driver_count(); i++) {
-
+ OS::get_singleton()->print(").\n");
+ OS::get_singleton()->print(" --video-driver <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_audio_driver_name(i));
+ OS::get_singleton()->print("'%s'", OS::get_singleton()->get_video_driver_name(i));
}
- OS::get_singleton()->print(")\n");
- OS::get_singleton()->print("\t-rthread <mode>\t : Render Thread Mode ('unsafe', 'safe', 'separate').\n");
- OS::get_singleton()->print("\t-s,-script [script] : Run a script.\n");
- OS::get_singleton()->print("\t-d,-debug : Debug (local stdout debugger).\n");
- OS::get_singleton()->print("\t-rdebug ADDRESS : Remote debug (<ip>:<port> host address).\n");
- OS::get_singleton()->print("\t-fdelay [msec]: Simulate high CPU load (delay each frame by [msec]).\n");
- OS::get_singleton()->print("\t-timescale [msec]: Simulate high CPU load (delay each frame by [msec]).\n");
- OS::get_singleton()->print("\t-bp : breakpoint list as source::line comma separated pairs, no spaces (%%20,%%2C,etc instead).\n");
- OS::get_singleton()->print("\t-v : Verbose stdout mode\n");
- OS::get_singleton()->print("\t-lang [locale]: Use a specific locale\n");
- OS::get_singleton()->print("\t-rfs <host/ip>[:<port>] : Remote FileSystem.\n");
- OS::get_singleton()->print("\t-rfs_pass <password> : Password for Remote FileSystem.\n");
+ OS::get_singleton()->print(").\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(" --resolution <W>x<H> Request window resolution.\n");
+ OS::get_singleton()->print(" --position <X>,<Y> Request window position.\n");
+ OS::get_singleton()->print(" --low-dpi Force low-DPI mode (macOS only).\n");
+ OS::get_singleton()->print(" --no-window Disable window creation (Windows only). Useful together with --script.\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, %%2C, etc. instead).\n");
+ OS::get_singleton()->print(" --profiling Enable profiling in the script debugger.\n");
+ OS::get_singleton()->print(" --remote-debug <address> Remote debug (<host/IP>:<port> address).\n");
+#ifdef DEBUG_ENABLED
+ OS::get_singleton()->print(" --debug-collisions Show collisions shapes when running the scene.\n");
+ OS::get_singleton()->print(" --debug-navigation Show navigation polygons when running the scene.\n");
+#endif
+ OS::get_singleton()->print(" --frame-delay <ms> Simulate high CPU load (delay each frame by <ms> milliseconds).\n");
+ OS::get_singleton()->print(" --time-scale <scale> Force time scale (higher values are faster, 1.0 is normal speed).\n");
+ OS::get_singleton()->print("\n");
+
+ OS::get_singleton()->print("Standalone tools:\n");
+ OS::get_singleton()->print(" -s, --script <script> Run a script.\n");
#ifdef TOOLS_ENABLED
- OS::get_singleton()->print("\t-doctool FILE: Dump the whole engine api to FILE in XML format. If FILE exists, it will be merged.\n");
- OS::get_singleton()->print("\t-nodocbase: Disallow dump the base types (used with -doctool).\n");
- OS::get_singleton()->print("\t-export [target] Export the project using given export target.\n");
+ OS::get_singleton()->print(" --export <target> Export the project using the given export target.\n");
+ OS::get_singleton()->print(" --export-debug Use together with --export, enables debug mode for the template.\n");
+ OS::get_singleton()->print(" --doctool <file> Dump the whole engine API to <file> in XML format. If <file> exists, it will be merged.\n");
+ OS::get_singleton()->print(" --no-docbase Disallow dumping the base types (used with --doctool).\n");
+#ifdef DEBUG_METHODS_ENABLED
+ OS::get_singleton()->print(" --gdnative-generate-json-api Generate JSON dump of the Godot API for GDNative bindings.\n");
+#endif
+ OS::get_singleton()->print(" --test <test> Run a unit test (");
+ const char **test_names = tests_get_names();
+ const char *comma = "";
+ while (*test_names) {
+ OS::get_singleton()->print("%s'%s'", comma, *test_names);
+ test_names++;
+ comma = ", ";
+ }
+ OS::get_singleton()->print(").\n");
#endif
}
@@ -252,9 +278,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
String remotefs;
String remotefs_pass;
- String screen = "";
-
- List<String> pack_list;
Vector<String> breakpoints;
bool use_custom_res = true;
bool force_res = false;
@@ -281,14 +304,12 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
List<String>::Element *N = I->next();
- if (I->get() == "-noop") {
-
- // no op
- } else if (I->get() == "-h" || I->get() == "--help" || I->get() == "/?") { // resolution
+ if (I->get() == "-h" || I->get() == "--help" || I->get() == "/?") { // display help
+ show_help = true;
goto error;
- } else if (I->get() == "-r") { // resolution
+ } else if (I->get() == "--resolution") { // force resolution
if (I->next()) {
@@ -296,16 +317,16 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
if (vm.find("x") == -1) { // invalid parameter format
- OS::get_singleton()->print("Invalid -r argument: %s\n", vm.utf8().get_data());
+ OS::get_singleton()->print("Invalid resolution '%s', it should be e.g. '1280x720'.\n", vm.utf8().get_data());
goto error;
}
int w = vm.get_slice("x", 0).to_int();
int h = vm.get_slice("x", 1).to_int();
- if (w == 0 || h == 0) {
+ if (w <= 0 || h <= 0) {
- OS::get_singleton()->print("Invalid -r resolution, x and y must be >0\n");
+ OS::get_singleton()->print("Invalid resolution '%s', width and height must be above 0.\n", vm.utf8().get_data());
goto error;
}
@@ -315,84 +336,86 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
N = I->next()->next();
} else {
- OS::get_singleton()->print("Invalid -p argument, needs resolution\n");
+ OS::get_singleton()->print("Missing resolution argument, aborting.\n");
goto error;
}
- } else if (I->get() == "-p") { // position
+ } else if (I->get() == "--position") { // set window position
if (I->next()) {
String vm = I->next()->get();
- if (vm.find("x") == -1) { // invalid parameter format
+ if (vm.find(",") == -1) { // invalid parameter format
- OS::get_singleton()->print("Invalid -p argument: %s\n", vm.utf8().get_data());
+ OS::get_singleton()->print("Invalid position '%s', it should be e.g. '80,128'.\n", vm.utf8().get_data());
goto error;
}
- int x = vm.get_slice("x", 0).to_int();
- int y = vm.get_slice("x", 1).to_int();
+ int x = vm.get_slice(",", 0).to_int();
+ int y = vm.get_slice(",", 1).to_int();
init_custom_pos = Point2(x, y);
init_use_custom_pos = true;
N = I->next()->next();
} else {
- OS::get_singleton()->print("Invalid -r argument, needs position\n");
+ OS::get_singleton()->print("Missing position argument, aborting.\n");
goto error;
}
- } else if (I->get() == "-mx") { // video driver
+ } else if (I->get() == "-m" || I->get() == "--maximized") { // force maximized window
init_maximized = true;
- } else if (I->get() == "-w") { // video driver
+ } else if (I->get() == "-w" || I->get() == "--windowed") { // force windowed window
init_windowed = true;
- } else if (I->get() == "-profile") { // video driver
+ } else if (I->get() == "--profiling") { // enable profiling
use_debug_profiler = true;
- } else if (I->get() == "-vd") { // video driver
+ } else if (I->get() == "--video-driver") { // force video driver
if (I->next()) {
video_driver = I->next()->get();
N = I->next()->next();
} else {
- OS::get_singleton()->print("Invalid -cd argument, needs driver name\n");
+ OS::get_singleton()->print("Missing video driver argument, aborting.\n");
goto error;
}
- } else if (I->get() == "-lang") { // language
+ } else if (I->get() == "-l" || I->get() == "--language") { // language
if (I->next()) {
locale = I->next()->get();
N = I->next()->next();
} else {
- OS::get_singleton()->print("Invalid -lang argument, needs language code\n");
+ OS::get_singleton()->print("Missing language argument, aborting.\n");
goto error;
}
- } else if (I->get() == "-ldpi") { // language
+ } else if (I->get() == "--low-dpi") { // force low DPI (macOS only)
force_lowdpi = true;
- } else if (I->get() == "-rfs") { // language
+ } else if (I->get() == "--remote-fs") { // remote filesystem
if (I->next()) {
remotefs = I->next()->get();
N = I->next()->next();
} else {
+ OS::get_singleton()->print("Missing remote filesystem address, aborting.\n");
goto error;
}
- } else if (I->get() == "-rfs_pass") { // language
+ } else if (I->get() == "--remote-fs-password") { // remote filesystem password
if (I->next()) {
remotefs_pass = I->next()->get();
N = I->next()->next();
} else {
+ OS::get_singleton()->print("Missing remote filesystem password, aborting.\n");
goto error;
}
- } else if (I->get() == "-rthread") { // language
+ } else if (I->get() == "--render-thread") { // render thread mode
if (I->next()) {
@@ -405,35 +428,37 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
N = I->next()->next();
} else {
+ OS::get_singleton()->print("Missing render thread mode argument, aborting.\n");
goto error;
}
- } else if (I->get() == "-ad") { // video driver
+ } else if (I->get() == "--audio-driver") { // audio driver
if (I->next()) {
audio_driver = I->next()->get();
N = I->next()->next();
} else {
+ OS::get_singleton()->print("Missing audio driver argument, aborting.\n");
goto error;
}
- } else if (I->get() == "-f") { // fullscreen
+ } else if (I->get() == "-f" || I->get() == "--fullscreen") { // force fullscreen
//video_mode.fullscreen=false;
init_fullscreen = true;
- } else if (I->get() == "-e" || I->get() == "-editor") { // fonud editor
+ } else if (I->get() == "-e" || I->get() == "--editor") { // starts editor
editor = true;
- } else if (I->get() == "-nowindow") { // fullscreen
+ } else if (I->get() == "--no-window") { // disable window creation, Windows only
OS::get_singleton()->set_no_window_mode(true);
- } else if (I->get() == "-quiet") { // fullscreen
+ } else if (I->get() == "--quiet") { // quieter output
quiet_stdout = true;
- } else if (I->get() == "-v") { // fullscreen
+ } else if (I->get() == "-v" || I->get() == "--verbose") { // verbose output
OS::get_singleton()->_verbose_stdout = true;
- } else if (I->get() == "-path") { // resolution
+ } else if (I->get() == "--path") { // set path of project to start or edit
if (I->next()) {
@@ -445,6 +470,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
N = I->next()->next();
} else {
+ OS::get_singleton()->print("Missing relative or absolute path, aborting.\n");
goto error;
}
} else if (I->get().ends_with("project.godot")) {
@@ -464,7 +490,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#ifdef TOOLS_ENABLED
editor = true;
#endif
- } else if (I->get() == "-bp") { // /breakpoints
+ } else if (I->get() == "-b" || I->get() == "--breakpoints") { // add breakpoints
if (I->next()) {
@@ -472,88 +498,73 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
breakpoints = bplist.split(",");
N = I->next()->next();
} else {
+ OS::get_singleton()->print("Missing list of breakpoints, aborting.\n");
goto error;
}
- } else if (I->get() == "-fdelay") { // resolution
+ } else if (I->get() == "--frame-delay") { // force frame delay
if (I->next()) {
frame_delay = I->next()->get().to_int();
N = I->next()->next();
} else {
+ OS::get_singleton()->print("Missing frame delay argument, aborting.\n");
goto error;
}
- } else if (I->get() == "-timescale") { // resolution
+ } else if (I->get() == "--time-scale") { // force time scale
if (I->next()) {
Engine::get_singleton()->set_time_scale(I->next()->get().to_double());
N = I->next()->next();
} else {
+ OS::get_singleton()->print("Missing time scale argument, aborting.\n");
goto error;
}
- } else if (I->get() == "-pack") {
-
- if (I->next()) {
-
- pack_list.push_back(I->next()->get());
- N = I->next()->next();
- } else {
-
- goto error;
- };
-
- } else if (I->get() == "-main_pack") {
+ } else if (I->get() == "--main-pack") {
if (I->next()) {
main_pack = I->next()->get();
N = I->next()->next();
} else {
-
+ OS::get_singleton()->print("Missing path to main pack file, aborting.\n");
goto error;
};
- } else if (I->get() == "-debug" || I->get() == "-d") {
+ } else if (I->get() == "-d" || I->get() == "--debug") {
debug_mode = "local";
#ifdef DEBUG_ENABLED
- } else if (I->get() == "-debugcol" || I->get() == "-dc") {
+ } else if (I->get() == "--debug-collisions") {
debug_collisions = true;
- } else if (I->get() == "-debugnav" || I->get() == "-dn") {
+ } else if (I->get() == "--debug-navigation") {
debug_navigation = true;
#endif
- } else if (I->get() == "-editor_scene") {
-
- if (I->next()) {
-
- ProjectSettings::get_singleton()->set("editor_scene", game_path = I->next()->get());
- } else {
- goto error;
- }
-
- } else if (I->get() == "-rdebug") {
+ } else if (I->get() == "--remote-debug") {
if (I->next()) {
debug_mode = "remote";
debug_host = I->next()->get();
- if (debug_host.find(":") == -1) { //wrong host
- OS::get_singleton()->print("Invalid debug host string\n");
+ if (debug_host.find(":") == -1) { // wrong address
+ OS::get_singleton()->print("Invalid debug host address, it should be of the form <host/IP>:<port>.\n");
goto error;
}
N = I->next()->next();
} else {
+ OS::get_singleton()->print("Missing remote debug host address, aborting.\n");
goto error;
}
- } else if (I->get() == "-epid") {
+ } else if (I->get() == "--editor-pid") { // not exposed to user
if (I->next()) {
int editor_pid = I->next()->get().to_int();
ProjectSettings::get_singleton()->set("editor_pid", editor_pid);
N = I->next()->next();
} else {
+ OS::get_singleton()->print("Missing editor PID argument, aborting.\n");
goto error;
}
} else {
@@ -617,7 +628,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
Error err = file_access_network_client->connect(remotefs, port, remotefs_pass);
if (err) {
- OS::get_singleton()->printerr("Could not connect to remotefs: %s:%i\n", remotefs.utf8().get_data(), port);
+ OS::get_singleton()->printerr("Could not connect to remotefs: %s:%i.\n", remotefs.utf8().get_data(), port);
goto error;
}
@@ -653,14 +664,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#ifdef TOOLS_ENABLED
editor = false;
#else
- OS::get_singleton()->print("error: Couldn't load game path '%s'\n", game_path.ascii().get_data());
+ OS::get_singleton()->print("Error: Could not load game path '%s'.\n", game_path.ascii().get_data());
goto error;
#endif
}
if (editor) {
- main_args.push_back("-editor");
+ main_args.push_back("--editor");
init_maximized = true;
use_custom_res = false;
}
@@ -742,11 +753,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->_render_thread_mode = OS::RenderThreadMode(rtm);
}
- /* Determine Video Driver */
-
- if (audio_driver == "") { // specified in project.godot
- audio_driver = GLOBAL_DEF("audio/driver", OS::get_singleton()->get_audio_driver_name(0));
- }
+ /* Determine audio and video drivers */
for (int i = 0; i < OS::get_singleton()->get_video_driver_count(); i++) {
@@ -764,6 +771,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
//goto error;
}
+ if (audio_driver == "") { // specified in project.godot
+ audio_driver = GLOBAL_DEF("audio/driver", OS::get_singleton()->get_audio_driver_name(0));
+ }
+
for (int i = 0; i < OS::get_singleton()->get_audio_driver_count(); i++) {
if (audio_driver == OS::get_singleton()->get_audio_driver_name(i)) {
@@ -831,7 +842,8 @@ error:
args.clear();
main_args.clear();
- print_help(execpath);
+ if (show_help)
+ print_help(execpath);
if (performance)
memdelete(performance);
@@ -1047,23 +1059,18 @@ bool Main::start() {
String game_path;
String script;
String test;
- String screen;
String _export_preset;
- String _import;
- String _import_script;
- bool noquit = false;
bool export_debug = false;
bool project_manager_request = false;
+
List<String> args = OS::get_singleton()->get_cmdline_args();
for (int i = 0; i < args.size(); i++) {
//parameters that do not have an argument to the right
- if (args[i] == "-nodocbase") {
+ if (args[i] == "--no-docbase") {
doc_base = false;
- } else if (args[i] == "-noquit") {
- noquit = true;
- } else if (args[i] == "-editor" || args[i] == "-e") {
+ } else if (args[i] == "-e" || args[i] == "--editor") {
editor = true;
- } else if (args[i] == "-pm" || args[i] == "-project_manager") {
+ } else if (args[i] == "-p" || args[i] == "--project-manager") {
project_manager_request = true;
} else if (args[i].length() && args[i][0] != '-' && game_path == "") {
game_path = args[i];
@@ -1071,29 +1078,21 @@ bool Main::start() {
//parameters that have an argument to the right
else if (i < (args.size() - 1)) {
bool parsed_pair = true;
- if (args[i] == "-doctool") {
+ if (args[i] == "--doctool") {
doc_tool = args[i + 1];
for (int j = i + 2; j < args.size(); j++)
removal_docs.push_back(args[j]);
- } else if (args[i] == "-script" || args[i] == "-s") {
+ } else if (args[i] == "-s" || args[i] == "--script") {
script = args[i + 1];
- } else if (args[i] == "-level" || args[i] == "-l") {
- Engine::get_singleton()->_custom_level = args[i + 1];
- } else if (args[i] == "-test") {
+ } else if (args[i] == "--test") {
test = args[i + 1];
- } else if (args[i] == "-export") {
+ } else if (args[i] == "--export") {
editor = true; //needs editor
_export_preset = args[i + 1];
- } else if (args[i] == "-export_debug") {
+ } else if (args[i] == "--export-debug") {
editor = true; //needs editor
_export_preset = args[i + 1];
export_debug = true;
- } else if (args[i] == "-import") {
- editor = true; //needs editor
- _import = args[i + 1];
- } else if (args[i] == "-import_script") {
- editor = true; //needs editor
- _import_script = args[i + 1];
} else {
// The parameter does not match anything known, don't skip the next argument
parsed_pair = false;
@@ -1139,7 +1138,7 @@ bool Main::start() {
if (_export_preset != "") {
if (game_path == "") {
String err = "Command line param ";
- err += export_debug ? "-export_debug" : "-export";
+ err += export_debug ? "--export-debug" : "--export";
err += " passed but no destination path given.\n";
err += "Please specify the binary's file path to export to. Aborting export.";
ERR_PRINT(err.utf8().get_data());
@@ -1199,7 +1198,7 @@ bool Main::start() {
if (!main_loop) {
if (!ClassDB::class_exists(main_loop_type)) {
- OS::get_singleton()->alert("godot: error: MainLoop type doesn't exist: " + main_loop_type);
+ OS::get_singleton()->alert("Error: MainLoop type doesn't exist: " + main_loop_type);
return false;
} else {
@@ -1349,19 +1348,8 @@ bool Main::start() {
#ifdef TOOLS_ENABLED
if (editor) {
- if (_import != "") {
-
- //editor_node->import_scene(_import,local_game_path,_import_script);
- if (!noquit)
- sml->quit();
- game_path = ""; //no load anything
- } else {
-
- Error serr = editor_node->load_scene(local_game_path);
- }
+ Error serr = editor_node->load_scene(local_game_path);
OS::get_singleton()->set_context(OS::CONTEXT_EDITOR);
-
- //editor_node->set_edited_scene(game);
}
#endif
}
@@ -1435,7 +1423,6 @@ bool Main::start() {
n->set_name(name);
//defer so references are all valid on _ready()
- //sml->get_root()->add_child(n);
to_add.push_back(n);
if (global_var) {
@@ -1460,7 +1447,6 @@ bool Main::start() {
ERR_EXPLAIN("Failed loading scene: " + local_game_path);
ERR_FAIL_COND_V(!scene, false)
- //sml->get_root()->add_child(scene);
sml->add_current_scene(scene);
String iconpath = GLOBAL_DEF("application/config/icon", "Variant()");
@@ -1474,27 +1460,6 @@ bool Main::start() {
}
#ifdef TOOLS_ENABLED
-
- /*if (_export_platform!="") {
-
- sml->quit();
- }*/
-
- /*
- if (sml->get_root_node()) {
-
- Console *console = memnew( Console );
-
- sml->get_root_node()->cast_to<RootNode>()->set_console(console);
- if (GLOBAL_DEF("console/visible_default",false).operator bool()) {
-
- console->show();
- } else {P
-
- console->hide();
- };
- }
-*/
if (project_manager_request || (script == "" && test == "" && game_path == "" && !editor)) {
ProjectManager *pmanager = memnew(ProjectManager);
@@ -1503,7 +1468,6 @@ bool Main::start() {
sml->get_root()->add_child(pmanager);
OS::get_singleton()->set_context(OS::CONTEXT_PROJECTMAN);
}
-
#endif
}
@@ -1584,10 +1548,6 @@ bool Main::iteration() {
time_accum -= frame_slice;
message_queue->flush();
- /*
- if (AudioServer::get_singleton())
- AudioServer::get_singleton()->update();
- */
fixed_process_ticks = MAX(fixed_process_ticks, OS::get_singleton()->get_ticks_usec() - fixed_begin); // keep the largest one for reference
fixed_process_max = MAX(OS::get_singleton()->get_ticks_usec() - fixed_begin, fixed_process_max);
@@ -1636,7 +1596,6 @@ bool Main::iteration() {
script_debugger->idle_poll();
}
- //x11_delay_usec(10000);
frames++;
Engine::get_singleton()->_idle_frames++;
@@ -1738,7 +1697,6 @@ void Main::cleanup() {
unregister_core_driver_types();
unregister_core_types();
- //PerformanceMetrics::finish();
OS::get_singleton()->clear_last_error();
OS::get_singleton()->finalize_core();
}
diff --git a/modules/gdnative/godot/string.h b/modules/gdnative/godot/string.h
index c901ce36e6..7695cd7931 100644
--- a/modules/gdnative/godot/string.h
+++ b/modules/gdnative/godot/string.h
@@ -172,7 +172,7 @@ void GDAPI godot_string_utf8(godot_string *p_self, char *result);
godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8);
godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len);
godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8);
-godot_string GDAPI godot_string_chars_utf8_with_len(const char *p_utf8, godot_int p_len);
+godot_string GDAPI godot_string_chars_to_utf8_with_len(const char *p_utf8, godot_int p_len);
uint32_t GDAPI godot_string_hash(const godot_string *p_self);
uint64_t GDAPI godot_string_hash64(const godot_string *p_self);
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index d1cf0f1dce..8cbfb8f3fd 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -1578,12 +1578,15 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
VisualScriptNodeInstance::StartMode start_mode;
{
- if (p_resuming_yield)
+ if (p_resuming_yield) {
start_mode = VisualScriptNodeInstance::START_MODE_RESUME_YIELD;
- else if (!flow_stack || !(flow_stack[flow_stack_pos] & VisualScriptNodeInstance::FLOW_STACK_PUSHED_BIT)) //if there is a push bit, it means we are continuing a sequence
- start_mode = VisualScriptNodeInstance::START_MODE_BEGIN_SEQUENCE;
- else
+ p_resuming_yield = false; // should resume only the first time
+ } else if (flow_stack && (flow_stack[flow_stack_pos] & VisualScriptNodeInstance::FLOW_STACK_PUSHED_BIT)) {
+ //if there is a push bit, it means we are continuing a sequence
start_mode = VisualScriptNodeInstance::START_MODE_CONTINUE_SEQUENCE;
+ } else {
+ start_mode = VisualScriptNodeInstance::START_MODE_BEGIN_SEQUENCE;
+ }
}
VSDEBUG("STEP - STARTSEQ: " + itos(start_mode));
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 3c52834d92..ee93c29577 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -1220,10 +1220,10 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
/*String host = EditorSettings::get_singleton()->get("filesystem/file_server/host");
int port = EditorSettings::get_singleton()->get("filesystem/file_server/post");
String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password");
- cl.push_back("-rfs");
+ cl.push_back("--remote-fs");
cl.push_back(host+":"+itos(port));
if (passwd!="") {
- cl.push_back("-rfs_pass");
+ cl.push_back("--remote-fs-password");
cl.push_back(passwd);
}*/
@@ -1243,10 +1243,10 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
err = save_pack(pf);
memdelete(pf);
- cl.push_back("-use_apk_expansion");
- cl.push_back("-apk_expansion_md5");
+ cl.push_back("--use_apk_expansion");
+ cl.push_back("--apk_expansion_md5");
cl.push_back(FileAccess::get_md5(fullpath));
- cl.push_back("-apk_expansion_key");
+ cl.push_back("--apk_expansion_key");
cl.push_back(apk_expansion_pkey.strip_edges());
} else {
@@ -1262,10 +1262,10 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
}
if (use_32_fb)
- cl.push_back("-use_depth_32");
+ cl.push_back("--use_depth_32");
if (immersive)
- cl.push_back("-use_immersive");
+ cl.push_back("--use_immersive");
if (cl.size()) {
//add comandline
@@ -3330,10 +3330,10 @@ public:
/*String host = EditorSettings::get_singleton()->get("filesystem/file_server/host");
int port = EditorSettings::get_singleton()->get("filesystem/file_server/post");
String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password");
- cl.push_back("-rfs");
+ cl.push_back("--remote-fs");
cl.push_back(host+":"+itos(port));
if (passwd!="") {
- cl.push_back("-rfs_pass");
+ cl.push_back("--remote-fs-password");
cl.push_back(passwd);
}*/
@@ -3350,10 +3350,10 @@ public:
return OK;
}
- cl.push_back("-use_apk_expansion");
- cl.push_back("-apk_expansion_md5");
+ cl.push_back("--use_apk_expansion");
+ cl.push_back("--apk_expansion_md5");
cl.push_back(FileAccess::get_md5(fullpath));
- cl.push_back("-apk_expansion_key");
+ cl.push_back("--apk_expansion_key");
cl.push_back(apk_expansion_pkey.strip_edges());
} else {
@@ -3367,10 +3367,10 @@ public:
}
if (use_32_fb)
- cl.push_back("-use_depth_32");
+ cl.push_back("--use_depth_32");
if (immersive)
- cl.push_back("-use_immersive");
+ cl.push_back("--use_immersive");
if (cl.size()) {
//add comandline
diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp
index 6fbd42d7b3..5933b83d06 100644
--- a/platform/android/godot_android.cpp
+++ b/platform/android/godot_android.cpp
@@ -616,7 +616,6 @@ static void engine_handle_cmd(struct android_app *app, int32_t cmd) {
//do initialization here, when there's OpenGL! hackish but the only way
engine->os = new OS_Android(_gfx_init, engine);
- //char *args[]={"-test","gui",NULL};
__android_log_print(ANDROID_LOG_INFO, "godot", "pre asdasd setup...");
#if 0
Error err = Main::setup("apk",2,args);
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java
index d620b2b9c4..d444d37c2f 100644
--- a/platform/android/java/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/src/org/godotengine/godot/Godot.java
@@ -387,7 +387,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
new_cmdline = new String[ 2 ];
}
- new_cmdline[cll]="-main_pack";
+ new_cmdline[cll]="--main_pack";
new_cmdline[cll+1]=expansion_pack_path;
command_line=new_cmdline;
}
@@ -452,9 +452,9 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
for(int i=0;i<command_line.length;i++) {
boolean has_extra = i< command_line.length -1;
- if (command_line[i].equals("-use_depth_32")) {
+ if (command_line[i].equals("--use_depth_32")) {
use_32_bits=true;
- } else if (command_line[i].equals("-use_immersive")) {
+ } else if (command_line[i].equals("--use_immersive")) {
use_immersive=true;
if(Build.VERSION.SDK_INT >= 19.0){ // check if the application runs on an android 4.4+
window.getDecorView().setSystemUiVisibility(
@@ -467,12 +467,12 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
UiChangeListener();
}
- } else if (command_line[i].equals("-use_apk_expansion")) {
+ } else if (command_line[i].equals("--use_apk_expansion")) {
use_apk_expansion=true;
- } else if (has_extra && command_line[i].equals("-apk_expansion_md5")) {
+ } else if (has_extra && command_line[i].equals("--apk_expansion_md5")) {
main_pack_md5=command_line[i+1];
i++;
- } else if (has_extra && command_line[i].equals("-apk_expansion_key")) {
+ } else if (has_extra && command_line[i].equals("--apk_expansion_key")) {
main_pack_key=command_line[i+1];
SharedPreferences prefs = getSharedPreferences("app_data_keys", MODE_PRIVATE);
Editor editor = prefs.edit();
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp
index 683e1cfb22..eb139fb471 100644
--- a/platform/android/java_glue.cpp
+++ b/platform/android/java_glue.cpp
@@ -844,7 +844,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
} else {
//__android_log_print(ANDROID_LOG_INFO,"godot","cmdline arg %i is: %s\n",i,rawString);
- if (strcmp(rawString, "-main_pack") == 0)
+ if (strcmp(rawString, "--main_pack") == 0)
use_apk_expansion = true;
}
@@ -867,7 +867,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
__android_log_print(ANDROID_LOG_INFO, "godot", "**SETUP");
#if 0
- char *args[]={"-test","render",NULL};
+ char *args[]={"--test","render",NULL};
__android_log_print(ANDROID_LOG_INFO,"godot","pre asdasd setup...");
Error err = Main::setup("apk",2,args,false);
#else
diff --git a/platform/iphone/view_controller.mm b/platform/iphone/view_controller.mm
index 574598e1d3..921ef8f607 100644
--- a/platform/iphone/view_controller.mm
+++ b/platform/iphone/view_controller.mm
@@ -42,7 +42,7 @@ int add_path(int p_argc, char **p_args) {
if (!str)
return p_argc;
- p_args[p_argc++] = "-path";
+ p_args[p_argc++] = "--path";
[str retain]; // memory leak lol (maybe make it static here and delete it in ViewController destructor? @todo
p_args[p_argc++] = (char *)[str cString];
p_args[p_argc] = NULL;
diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp
index c773c0b746..8824d1c1d0 100644
--- a/platform/uwp/app.cpp
+++ b/platform/uwp/app.cpp
@@ -512,7 +512,7 @@ void App::UpdateWindowSize(Size size) {
char **App::get_command_line(unsigned int *out_argc) {
- static char *fail_cl[] = { "-path", "game", NULL };
+ static char *fail_cl[] = { "--path", "game", NULL };
*out_argc = 2;
FILE *f = _wfopen(L"__cl__.cl", L"rb");
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index 39717196aa..68307c4e90 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -1330,7 +1330,7 @@ public:
}
if (!(p_flags & DEBUG_FLAG_DUMB_CLIENT)) {
- cl.push_back("-path");
+ cl.push_back("--path");
cl.push_back("game");
}
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index b2afca8766..84074f96a8 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -493,7 +493,10 @@ void Label::regenerate_word_cache() {
minsize.height = (font->get_height() * line_count) + (line_spacing * (line_count - 1));
}
- minimum_size_changed();
+ if (!autowrap || !clip) {
+ //helps speed up some labels that may change a lot, as no resizing is requested. Do not change.
+ minimum_size_changed();
+ }
word_cache_dirty = false;
}
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index 2ccdbb05a9..6519cde6d3 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -98,7 +98,18 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
if (ofs < grabber_ofs) {
- set_value(get_value() - get_page());
+ if (scrolling) {
+ target_scroll = target_scroll - get_page();
+ } else {
+ target_scroll = get_value() - get_page();
+ }
+
+ if (smooth_scroll_enabled) {
+ scrolling = true;
+ set_fixed_process(true);
+ } else {
+ set_value(target_scroll);
+ }
return;
}
@@ -111,8 +122,18 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
drag.value_at_click = get_as_ratio();
update();
} else {
+ if (scrolling) {
+ target_scroll = target_scroll + get_page();
+ } else {
+ target_scroll = get_value() + get_page();
+ }
- set_value(get_value() + get_page());
+ if (smooth_scroll_enabled) {
+ scrolling = true;
+ set_fixed_process(true);
+ } else {
+ set_value(target_scroll);
+ }
}
} else {
@@ -311,7 +332,22 @@ void ScrollBar::_notification(int p_what) {
if (p_what == NOTIFICATION_FIXED_PROCESS) {
- if (drag_slave_touching) {
+ if (scrolling) {
+ if (get_value() != target_scroll) {
+ double target = target_scroll - get_value();
+ double dist = sqrt(target * target);
+ double vel = ((target / dist) * 500) * get_fixed_process_delta_time();
+
+ if (vel >= dist) {
+ set_value(target_scroll);
+ } else {
+ set_value(get_value() + vel);
+ }
+ } else {
+ scrolling = false;
+ set_fixed_process(false);
+ }
+ } else if (drag_slave_touching) {
if (drag_slave_touching_deaccel) {
@@ -639,6 +675,14 @@ NodePath ScrollBar::get_drag_slave() const {
return drag_slave_path;
}
+void ScrollBar::set_smooth_scroll_enabled(bool p_enable) {
+ smooth_scroll_enabled = p_enable;
+}
+
+bool ScrollBar::is_smooth_scroll_enabled() const {
+ return smooth_scroll_enabled;
+}
+
#if 0
void ScrollBar::mouse_button(const Point2& p_pos, int b->get_button_index(),bool b->is_pressed(),int p_modifier_mask) {
@@ -795,6 +839,10 @@ ScrollBar::ScrollBar(Orientation p_orientation) {
drag_slave_touching = false;
drag_slave_touching_deaccel = false;
+ scrolling = false;
+ target_scroll = 0;
+ smooth_scroll_enabled = false;
+
if (focus_by_default)
set_focus_mode(FOCUS_ALL);
set_step(0);
diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h
index 8310e12590..e22d4da46d 100644
--- a/scene/gui/scroll_bar.h
+++ b/scene/gui/scroll_bar.h
@@ -83,6 +83,10 @@ class ScrollBar : public Range {
bool drag_slave_touching_deaccel;
bool click_handled;
+ bool scrolling;
+ double target_scroll;
+ bool smooth_scroll_enabled;
+
void _drag_slave_exit();
void _drag_slave_input(const Ref<InputEvent> &p_input);
@@ -100,6 +104,9 @@ public:
void set_drag_slave(const NodePath &p_path);
NodePath get_drag_slave() const;
+ void set_smooth_scroll_enabled(bool p_enable);
+ bool is_smooth_scroll_enabled() const;
+
virtual Size2 get_minimum_size() const;
ScrollBar(Orientation p_orientation = VERTICAL);
~ScrollBar();
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 2b111c50a6..650fdfbc5f 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -338,6 +338,11 @@ void TextEdit::_update_scrollbars() {
v_scroll->show();
v_scroll->set_max(total_rows);
v_scroll->set_page(visible_rows);
+ if (smooth_scroll_enabled) {
+ v_scroll->set_step(0.25);
+ } else {
+ v_scroll->set_step(1);
+ }
if (fabs(v_scroll->get_value() - (double)cursor.line_ofs) >= 1) {
v_scroll->set_value(cursor.line_ofs);
@@ -420,6 +425,24 @@ void TextEdit::_notification(int p_what) {
draw_caret = false;
update();
} break;
+ case NOTIFICATION_FIXED_PROCESS: {
+ if (scrolling && v_scroll->get_value() != target_v_scroll) {
+ double target_y = target_v_scroll - v_scroll->get_value();
+ double dist = sqrt(target_y * target_y);
+ double vel = ((target_y / dist) * 50) * get_fixed_process_delta_time();
+
+ if (vel >= dist) {
+ v_scroll->set_value(target_v_scroll);
+ scrolling = false;
+ set_fixed_process(false);
+ } else {
+ v_scroll->set_value(v_scroll->get_value() + vel);
+ }
+ } else {
+ scrolling = false;
+ set_fixed_process(false);
+ }
+ } break;
case NOTIFICATION_DRAW: {
if ((!has_focus() && !menu->has_focus()) || !window_has_focus) {
@@ -454,6 +477,7 @@ void TextEdit::_notification(int p_what) {
_update_scrollbars();
RID ci = get_canvas_item();
+ VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
int xmargin_beg = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width;
int xmargin_end = cache.size.width - cache.style_normal->get_margin(MARGIN_RIGHT);
//let's do it easy for now:
@@ -674,7 +698,11 @@ void TextEdit::_notification(int p_what) {
int char_margin = xmargin_beg - cursor.x_ofs;
int char_ofs = 0;
- int ofs_y = i * get_row_height() + cache.line_spacing / 2;
+ int ofs_y = (i * get_row_height() + cache.line_spacing / 2);
+ if (smooth_scroll_enabled) {
+ ofs_y -= (v_scroll->get_value() - cursor.line_ofs) * get_row_height();
+ }
+
bool prev_is_char = false;
bool prev_is_number = false;
bool in_keyword = false;
@@ -1500,7 +1528,7 @@ void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) co
float rows = p_mouse.y;
rows -= cache.style_normal->get_margin(MARGIN_TOP);
rows /= get_row_height();
- int row = cursor.line_ofs + rows;
+ int row = cursor.line_ofs + (rows + (v_scroll->get_value() - cursor.line_ofs));
if (row < 0)
row = 0;
@@ -1566,10 +1594,43 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (mb->is_pressed()) {
if (mb->get_button_index() == BUTTON_WHEEL_UP && !mb->get_command()) {
- v_scroll->set_value(v_scroll->get_value() - (3 * mb->get_factor()));
+ if (scrolling) {
+ target_v_scroll = (target_v_scroll - (3 * mb->get_factor()));
+ } else {
+ target_v_scroll = (v_scroll->get_value() - (3 * mb->get_factor()));
+ }
+
+ if (smooth_scroll_enabled) {
+ if (target_v_scroll <= 0) {
+ target_v_scroll = 0;
+ }
+ scrolling = true;
+ set_fixed_process(true);
+ } else {
+ v_scroll->set_value(target_v_scroll);
+ }
}
if (mb->get_button_index() == BUTTON_WHEEL_DOWN && !mb->get_command()) {
- v_scroll->set_value(v_scroll->get_value() + (3 * mb->get_factor()));
+ if (scrolling) {
+ target_v_scroll = (target_v_scroll + (3 * mb->get_factor()));
+ } else {
+ target_v_scroll = (v_scroll->get_value() + (3 * mb->get_factor()));
+ }
+
+ if (smooth_scroll_enabled) {
+ int max_v_scroll = get_line_count() - 1;
+ if (!scroll_past_end_of_file_enabled) {
+ max_v_scroll -= get_visible_rows() - 1;
+ }
+
+ if (target_v_scroll > max_v_scroll) {
+ target_v_scroll = max_v_scroll;
+ }
+ scrolling = true;
+ set_fixed_process(true);
+ } else {
+ v_scroll->set_value(target_v_scroll);
+ }
}
if (mb->get_button_index() == BUTTON_WHEEL_LEFT) {
h_scroll->set_value(h_scroll->get_value() - (100 * mb->get_factor()));
@@ -3092,7 +3153,7 @@ int TextEdit::get_visible_rows() const {
int total = cache.size.height;
total -= cache.style_normal->get_minimum_size().height;
total /= get_row_height();
- return total;
+ return total + 1;
}
void TextEdit::adjust_viewport_to_cursor() {
@@ -4194,6 +4255,15 @@ void TextEdit::set_h_scroll(int p_scroll) {
h_scroll->set_value(p_scroll);
}
+void TextEdit::set_smooth_scroll_enabled(bool p_enable) {
+ v_scroll->set_smooth_scroll_enabled(p_enable);
+ smooth_scroll_enabled = p_enable;
+}
+
+bool TextEdit::is_smooth_scroll_enabled() const {
+ return smooth_scroll_enabled;
+}
+
void TextEdit::set_completion(bool p_enabled, const Vector<String> &p_prefixes) {
completion_prefixes.clear();
@@ -4694,6 +4764,9 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_syntax_coloring", "enable"), &TextEdit::set_syntax_coloring);
ClassDB::bind_method(D_METHOD("is_syntax_coloring_enabled"), &TextEdit::is_syntax_coloring_enabled);
+ ClassDB::bind_method(D_METHOD("set_smooth_scroll_enable", "enable"), &TextEdit::set_smooth_scroll_enabled);
+ ClassDB::bind_method(D_METHOD("is_smooth_scroll_enabled"), &TextEdit::is_smooth_scroll_enabled);
+
ClassDB::bind_method(D_METHOD("add_keyword_color", "keyword", "color"), &TextEdit::add_keyword_color);
ClassDB::bind_method(D_METHOD("add_color_region", "begin_key", "end_key", "color", "line_only"), &TextEdit::add_color_region, DEFVAL(false));
ClassDB::bind_method(D_METHOD("clear_colors"), &TextEdit::clear_colors);
@@ -4703,6 +4776,7 @@ void TextEdit::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), "set_syntax_coloring", "is_syntax_coloring_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), "set_show_line_numbers", "is_show_line_numbers_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), "set_highlight_all_occurrences", "is_highlight_all_occurrences_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_scrolling"), "set_smooth_scroll_enable", "is_smooth_scroll_enabled");
ADD_GROUP("Caret", "caret_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_block_mode"), "cursor_set_block_mode", "cursor_is_block_mode");
@@ -4839,6 +4913,9 @@ TextEdit::TextEdit() {
insert_mode = false;
window_has_focus = true;
select_identifiers_enabled = false;
+ smooth_scroll_enabled = false;
+ scrolling = false;
+ target_v_scroll = 0;
raised_from_completion = false;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 4c17347a5d..c4e0700531 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -256,6 +256,10 @@ class TextEdit : public Control {
bool insert_mode;
bool select_identifiers_enabled;
+ bool smooth_scroll_enabled;
+ bool scrolling;
+ float target_v_scroll;
+
bool raised_from_completion;
String highlighted_word;
@@ -487,6 +491,9 @@ public:
int get_h_scroll() const;
void set_h_scroll(int p_scroll);
+ void set_smooth_scroll_enabled(bool p_enable);
+ bool is_smooth_scroll_enabled() const;
+
uint32_t get_version() const;
uint32_t get_saved_version() const;
void tag_saved_version();
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 67bc5b30ff..d6a730647f 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -463,7 +463,7 @@ bool StyleBoxFlat::is_anti_aliased() const {
}
void StyleBoxFlat::set_aa_size(const int &p_aa_size) {
- aa_size = p_aa_size;
+ aa_size = CLAMP(p_aa_size, 1, 5);
emit_changed();
}
int StyleBoxFlat::get_aa_size() const {
@@ -471,7 +471,7 @@ int StyleBoxFlat::get_aa_size() const {
}
void StyleBoxFlat::set_corner_detail(const int &p_corner_detail) {
- corner_detail = p_corner_detail;
+ corner_detail = CLAMP(p_corner_detail, 1, 128);
emit_changed();
}
int StyleBoxFlat::get_corner_detail() const {
@@ -514,6 +514,7 @@ inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color
if (!vert_offset) {
vert_offset = 0;
}
+ int adapted_corner_detail = (corner_radius[0] == 0 && corner_radius[1] == 0 && corner_radius[2] == 0 && corner_radius[3] == 0) ? 1 : corner_detail;
int rings = (border_width[0] == 0 && border_width[1] == 0 && border_width[2] == 0 && border_width[3] == 0) ? 1 : 2;
rings = 2;
@@ -540,7 +541,7 @@ inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color
//calculate the vert array
for (int corner_index = 0; corner_index < 4; corner_index++) {
- for (int detail = 0; detail <= corner_detail; detail++) {
+ for (int detail = 0; detail <= adapted_corner_detail; detail++) {
for (int inner_outer = (2 - rings); inner_outer < 2; inner_outer++) {
float radius;
Color color;
@@ -554,8 +555,8 @@ inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color
color = *outer_color;
corner_point = outer_points[corner_index];
}
- float x = radius * (float)cos((double)corner_index * Math_PI / 2.0 + (double)detail / (double)corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.x;
- float y = radius * (float)sin((double)corner_index * Math_PI / 2.0 + (double)detail / (double)corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.y;
+ float x = radius * (float)cos((double)corner_index * Math_PI / 2.0 + (double)detail / (double)adapted_corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.x;
+ float y = radius * (float)sin((double)corner_index * Math_PI / 2.0 + (double)detail / (double)adapted_corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.y;
verts.push_back(Vector2(x, y));
colors.push_back(color);
}
@@ -563,7 +564,7 @@ inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color
}
if (rings == 2) {
- int vert_count = (corner_detail + 1) * 4 * rings;
+ int vert_count = (adapted_corner_detail + 1) * 4 * rings;
//fill the indices and the colors for the border
for (int i = 0; i < vert_count; i++) {
//poly 1
@@ -776,7 +777,7 @@ void StyleBoxFlat::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_bottom_right", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_BOTTOM_RIGHT);
ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_bottom_left", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_BOTTOM_LEFT);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "corner_detail"), "set_corner_detail", "get_corner_detail");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "corner_detail", PROPERTY_HINT_RANGE, "1,128,1"), "set_corner_detail", "get_corner_detail");
ADD_GROUP("Expand Margin", "expand_margin_");
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_LEFT);