summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/templates/thread_work_pool.h2
-rw-r--r--doc/classes/GraphEdit.xml12
-rw-r--r--editor/editor_node.cpp42
-rw-r--r--editor/editor_paths.cpp4
-rw-r--r--editor/editor_settings.cpp56
-rw-r--r--editor/editor_settings.h1
-rw-r--r--editor/plugins/theme_editor_plugin.cpp6
-rw-r--r--editor/project_manager.cpp42
-rw-r--r--main/main.cpp56
-rw-r--r--main/main.h1
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp5
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp10
-rw-r--r--platform/uwp/export/export.cpp6
-rw-r--r--scene/gui/graph_edit.cpp130
-rw-r--r--scene/gui/graph_edit.h26
15 files changed, 260 insertions, 139 deletions
diff --git a/core/templates/thread_work_pool.h b/core/templates/thread_work_pool.h
index 9f7a692cc5..b242648bc8 100644
--- a/core/templates/thread_work_pool.h
+++ b/core/templates/thread_work_pool.h
@@ -105,7 +105,7 @@ public:
}
bool is_done_dispatching() const {
- ERR_FAIL_COND_V(current_work == nullptr, false);
+ ERR_FAIL_COND_V(current_work == nullptr, true);
return index.load(std::memory_order_acquire) >= current_work->max_elements;
}
diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml
index b4536c0589..16fc1ca17a 100644
--- a/doc/classes/GraphEdit.xml
+++ b/doc/classes/GraphEdit.xml
@@ -197,6 +197,9 @@
<member name="scroll_offset" type="Vector2" setter="set_scroll_ofs" getter="get_scroll_ofs" default="Vector2( 0, 0 )">
The scroll offset.
</member>
+ <member name="show_zoom_label" type="bool" setter="set_show_zoom_label" getter="is_showing_zoom_label" default="false">
+ If [code]true[/code], makes a label with the current zoom level visible. The zoom value is displayed in percents.
+ </member>
<member name="snap_distance" type="int" setter="set_snap" getter="get_snap" default="20">
The snapping distance in pixels.
</member>
@@ -206,6 +209,15 @@
<member name="zoom" type="float" setter="set_zoom" getter="get_zoom" default="1.0">
The current zoom value.
</member>
+ <member name="zoom_max" type="float" setter="set_zoom_max" getter="get_zoom_max" default="2.0736">
+ The upper zoom limit.
+ </member>
+ <member name="zoom_min" type="float" setter="set_zoom_min" getter="get_zoom_min" default="0.232568">
+ The lower zoom limit.
+ </member>
+ <member name="zoom_step" type="float" setter="set_zoom_step" getter="get_zoom_step" default="1.2">
+ The step of each zoom level.
+ </member>
</members>
<signals>
<signal name="begin_node_move">
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index b6df9f6088..73bb1f3856 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -609,7 +609,7 @@ void EditorNode::_notification(int p_what) {
} break;
case NOTIFICATION_APPLICATION_FOCUS_IN: {
- // Restore the original FPS cap after focusing back on the editor
+ // Restore the original FPS cap after focusing back on the editor.
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec")));
EditorFileSystem::get_singleton()->scan_changes();
@@ -617,7 +617,12 @@ void EditorNode::_notification(int p_what) {
} break;
case NOTIFICATION_APPLICATION_FOCUS_OUT: {
- // Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused
+ // Save on focus loss before applying the FPS limit to avoid slowing down the saving process.
+ if (EDITOR_GET("interface/editor/save_on_focus_loss")) {
+ _menu_option_confirm(FILE_SAVE_SCENE, false);
+ }
+
+ // Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused.
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/unfocused_low_processor_mode_sleep_usec")));
} break;
@@ -5689,36 +5694,10 @@ EditorNode::EditorNode() {
int display_scale = EditorSettings::get_singleton()->get("interface/editor/display_scale");
switch (display_scale) {
- case 0: {
+ case 0:
// Try applying a suitable display scale automatically.
- // The code below is adapted in `editor/editor_settings.cpp` and `editor/project_manager.cpp`.
- // Make sure to update those when modifying the code below.
-#ifdef OSX_ENABLED
- editor_set_scale(DisplayServer::get_singleton()->screen_get_max_scale());
-#else
- const int screen = DisplayServer::get_singleton()->window_get_current_screen();
- // Use the smallest dimension to use a correct display scale on portait displays.
- const int smallest_dimension = MIN(DisplayServer::get_singleton()->screen_get_size(screen).x, DisplayServer::get_singleton()->screen_get_size(screen).y);
- float scale;
- if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && smallest_dimension >= 1400) {
- // hiDPI display.
- scale = 2.0;
- } else if (smallest_dimension >= 1700) {
- // Likely a hiDPI display, but we aren't certain due to the returned DPI.
- // Use an intermediate scale to handle this situation.
- scale = 1.5;
- } else if (smallest_dimension <= 800) {
- // Small loDPI display. Use a smaller display scale so that editor elements fit more easily.
- // Icons won't look great, but this is better than having editor elements overflow from its window.
- scale = 0.75;
- } else {
- scale = 1.0;
- }
-
- editor_set_scale(scale);
-#endif
- } break;
-
+ editor_set_scale(EditorSettings::get_singleton()->get_auto_display_scale());
+ break;
case 1:
editor_set_scale(0.75);
break;
@@ -5871,6 +5850,7 @@ EditorNode::EditorNode() {
EDITOR_DEF("run/output/always_open_output_on_play", true);
EDITOR_DEF("run/output/always_close_output_on_stop", true);
EDITOR_DEF("run/auto_save/save_before_running", true);
+ EDITOR_DEF("interface/editor/save_on_focus_loss", false);
EDITOR_DEF_RST("interface/editor/save_each_scene_on_quit", true);
EDITOR_DEF("interface/editor/show_update_spinner", false);
EDITOR_DEF("interface/editor/update_continuously", false);
diff --git a/editor/editor_paths.cpp b/editor/editor_paths.cpp
index 323707ec6c..c9817190dd 100644
--- a/editor/editor_paths.cpp
+++ b/editor/editor_paths.cpp
@@ -186,7 +186,7 @@ EditorPaths::EditorPaths() {
// Validate or create project-specific editor data dir (`res://.godot`),
// including shader cache subdir.
- if (Main::is_project_manager()) {
+ if (Main::is_project_manager() || Main::is_cmdline_tool()) {
// Nothing to create, use shared editor data dir for shader cache.
Engine::get_singleton()->set_shader_cache_path(data_dir);
} else {
@@ -209,6 +209,4 @@ EditorPaths::EditorPaths() {
dir_res->make_dir(ProjectSettings::IMPORTED_FILES_PATH);
}
}
-
- print_line("paths valid: " + itos((int)paths_valid));
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index d81c94bd35..3f66326b41 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -373,30 +373,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
// Editor
_initial_set("interface/editor/display_scale", 0);
// Display what the Auto display scale setting effectively corresponds to.
- // The code below is adapted in `editor/editor_node.cpp` and `editor/project_manager.cpp`.
- // Make sure to update those when modifying the code below.
-#ifdef OSX_ENABLED
- float scale = DisplayServer::get_singleton()->screen_get_max_scale();
-#else
- const int screen = DisplayServer::get_singleton()->window_get_current_screen();
- // Use the smallest dimension to use a correct display scale on portait displays.
- const int smallest_dimension = MIN(DisplayServer::get_singleton()->screen_get_size(screen).x, DisplayServer::get_singleton()->screen_get_size(screen).y);
- float scale;
- if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && smallest_dimension >= 1400) {
- // hiDPI display.
- scale = 2.0;
- } else if (smallest_dimension <= 1700) {
- // Likely a hiDPI display, but we aren't certain due to the returned DPI.
- // Use an intermediate scale to handle this situation.
- scale = 1.5;
- } else if (smallest_dimension <= 800) {
- // Small loDPI display. Use a smaller display scale so that editor elements fit more easily.
- // Icons won't look great, but this is better than having editor elements overflow from its window.
- scale = 0.75;
- } else {
- scale = 1.0;
- }
-#endif
+ float scale = get_auto_display_scale();
hints["interface/editor/display_scale"] = PropertyInfo(Variant::INT, "interface/editor/display_scale", PROPERTY_HINT_ENUM, vformat("Auto (%d%%),75%%,100%%,125%%,150%%,175%%,200%%,Custom", Math::round(scale * 100)), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/editor/custom_display_scale", 1.0f);
hints["interface/editor/custom_display_scale"] = PropertyInfo(Variant::FLOAT, "interface/editor/custom_display_scale", PROPERTY_HINT_RANGE, "0.5,3,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
@@ -423,8 +400,12 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["interface/editor/code_font"] = PropertyInfo(Variant::STRING, "interface/editor/code_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/editor/low_processor_mode_sleep_usec", 6900); // ~144 FPS
hints["interface/editor/low_processor_mode_sleep_usec"] = PropertyInfo(Variant::FLOAT, "interface/editor/low_processor_mode_sleep_usec", PROPERTY_HINT_RANGE, "1,100000,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
- _initial_set("interface/editor/unfocused_low_processor_mode_sleep_usec", 50000); // 20 FPS
- hints["interface/editor/unfocused_low_processor_mode_sleep_usec"] = PropertyInfo(Variant::FLOAT, "interface/editor/unfocused_low_processor_mode_sleep_usec", PROPERTY_HINT_RANGE, "1,100000,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ _initial_set("interface/editor/unfocused_low_processor_mode_sleep_usec", 100000); // 10 FPS
+ // Allow an unfocused FPS limit as low as 1 FPS for those who really need low power usage
+ // (but don't need to preview particles or shaders while the editor is unfocused).
+ // With very low FPS limits, the editor can take a small while to become usable after being focused again,
+ // so this should be used at the user's discretion.
+ hints["interface/editor/unfocused_low_processor_mode_sleep_usec"] = PropertyInfo(Variant::FLOAT, "interface/editor/unfocused_low_processor_mode_sleep_usec", PROPERTY_HINT_RANGE, "1,1000000,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/editor/separate_distraction_mode", false);
_initial_set("interface/editor/automatically_open_screenshots", true);
_initial_set("interface/editor/single_window_mode", false);
@@ -1447,6 +1428,29 @@ String EditorSettings::get_editor_layouts_config() const {
return EditorPaths::get_singleton()->get_config_dir().plus_file("editor_layouts.cfg");
}
+float EditorSettings::get_auto_display_scale() const {
+#ifdef OSX_ENABLED
+ return DisplayServer::get_singleton()->screen_get_max_scale();
+#else
+ const int screen = DisplayServer::get_singleton()->window_get_current_screen();
+ // Use the smallest dimension to use a correct display scale on portait displays.
+ const int smallest_dimension = MIN(DisplayServer::get_singleton()->screen_get_size(screen).x, DisplayServer::get_singleton()->screen_get_size(screen).y);
+ if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && smallest_dimension >= 1400) {
+ // hiDPI display.
+ return 2.0;
+ } else if (smallest_dimension >= 1700) {
+ // Likely a hiDPI display, but we aren't certain due to the returned DPI.
+ // Use an intermediate scale to handle this situation.
+ return 1.5;
+ } else if (smallest_dimension <= 800) {
+ // Small loDPI display. Use a smaller display scale so that editor elements fit more easily.
+ // Icons won't look great, but this is better than having editor elements overflow from its window.
+ return 0.75;
+ }
+ return 1.0;
+#endif
+}
+
// Shortcuts
void EditorSettings::add_shortcut(const String &p_name, Ref<Shortcut> &p_shortcut) {
diff --git a/editor/editor_settings.h b/editor/editor_settings.h
index d6a9a9d1b9..3a28c18b27 100644
--- a/editor/editor_settings.h
+++ b/editor/editor_settings.h
@@ -174,6 +174,7 @@ public:
Vector<String> get_script_templates(const String &p_extension, const String &p_custom_path = String());
String get_editor_layouts_config() const;
+ float get_auto_display_scale() const;
void add_shortcut(const String &p_name, Ref<Shortcut> &p_shortcut);
bool is_shortcut(const String &p_name, const Ref<InputEvent> &p_event) const;
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 6607bf6cad..22b39c59f5 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -1959,7 +1959,7 @@ VBoxContainer *ThemeTypeEditor::_create_item_list(Theme::DataType p_data_type) {
LineEdit *item_add_edit = memnew(LineEdit);
item_add_edit->set_h_size_flags(SIZE_EXPAND_FILL);
item_add_hb->add_child(item_add_edit);
- item_add_edit->connect("text_entered", callable_mp(this, &ThemeTypeEditor::_item_add_lineedit_cbk), varray(p_data_type, item_add_edit));
+ item_add_edit->connect("text_submitted", callable_mp(this, &ThemeTypeEditor::_item_add_lineedit_cbk), varray(p_data_type, item_add_edit));
Button *item_add_button = memnew(Button);
item_add_button->set_text(TTR("Add"));
item_add_hb->add_child(item_add_button);
@@ -2124,7 +2124,7 @@ HBoxContainer *ThemeTypeEditor::_create_property_control(Theme::DataType p_data_
item_name_edit->set_h_size_flags(SIZE_EXPAND_FILL);
item_name_edit->set_text(p_item_name);
item_name_container->add_child(item_name_edit);
- item_name_edit->connect("text_entered", callable_mp(this, &ThemeTypeEditor::_item_rename_entered), varray(p_data_type, p_item_name, item_name_container));
+ item_name_edit->connect("text_submitted", callable_mp(this, &ThemeTypeEditor::_item_rename_entered), varray(p_data_type, p_item_name, item_name_container));
item_name_edit->hide();
Button *item_rename_button = memnew(Button);
@@ -2894,7 +2894,7 @@ ThemeTypeEditor::ThemeTypeEditor() {
add_type_filter = memnew(LineEdit);
add_type_vb->add_child(add_type_filter);
add_type_filter->connect("text_changed", callable_mp(this, &ThemeTypeEditor::_add_type_filter_cbk));
- add_type_filter->connect("text_entered", callable_mp(this, &ThemeTypeEditor::_add_type_dialog_entered));
+ add_type_filter->connect("text_submitted", callable_mp(this, &ThemeTypeEditor::_add_type_dialog_entered));
Label *add_type_options_label = memnew(Label);
add_type_options_label->set_text(TTR("Node Types:"));
add_type_vb->add_child(add_type_options_label);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 5490fbbbc7..fdd114bb1e 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1924,9 +1924,6 @@ void ProjectManager::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
case KEY_ENTER: {
_open_selected_projects_ask();
} break;
- case KEY_DELETE: {
- _erase_project();
- } break;
case KEY_HOME: {
if (_project_list->get_project_count() > 0) {
_project_list->select_project(0);
@@ -2400,36 +2397,10 @@ ProjectManager::ProjectManager() {
int display_scale = EditorSettings::get_singleton()->get("interface/editor/display_scale");
switch (display_scale) {
- case 0: {
+ case 0:
// Try applying a suitable display scale automatically.
- // The code below is adapted in `editor/editor_settings.cpp` and `editor/editor_node.cpp`.
- // Make sure to update those when modifying the code below.
-#ifdef OSX_ENABLED
- editor_set_scale(DisplayServer::get_singleton()->screen_get_max_scale());
-#else
- const int screen = DisplayServer::get_singleton()->window_get_current_screen();
- // Use the smallest dimension to use a correct display scale on portait displays.
- const int smallest_dimension = MIN(DisplayServer::get_singleton()->screen_get_size(screen).x, DisplayServer::get_singleton()->screen_get_size(screen).y);
- float scale;
- if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && smallest_dimension >= 1400) {
- // hiDPI display.
- scale = 2.0;
- } else if (smallest_dimension >= 1700) {
- // Likely a hiDPI display, but we aren't certain due to the returned DPI.
- // Use an intermediate scale to handle this situation.
- scale = 1.5;
- } else if (smallest_dimension <= 800) {
- // Small loDPI display. Use a smaller display scale so that editor elements fit more easily.
- // Icons won't look great, but this is better than having editor elements overflow from its window.
- scale = 0.75;
- } else {
- scale = 1.0;
- }
-
- editor_set_scale(scale);
-#endif
- } break;
-
+ editor_set_scale(EditorSettings::get_singleton()->get_auto_display_scale());
+ break;
case 1:
editor_set_scale(0.75);
break;
@@ -2558,16 +2529,19 @@ ProjectManager::ProjectManager() {
Button *create = memnew(Button);
create->set_text(TTR("New Project"));
+ create->set_shortcut(ED_SHORTCUT("project_manager/new_project", TTR("New Project"), KEY_MASK_CMD | KEY_N));
create->connect("pressed", callable_mp(this, &ProjectManager::_new_project));
tree_vb->add_child(create);
Button *import = memnew(Button);
import->set_text(TTR("Import"));
+ import->set_shortcut(ED_SHORTCUT("project_manager/import_project", TTR("Import Project"), KEY_MASK_CMD | KEY_I));
import->connect("pressed", callable_mp(this, &ProjectManager::_import_project));
tree_vb->add_child(import);
Button *scan = memnew(Button);
scan->set_text(TTR("Scan"));
+ scan->set_shortcut(ED_SHORTCUT("project_manager/scan_projects", TTR("Scan Projects"), KEY_MASK_CMD | KEY_S));
scan->connect("pressed", callable_mp(this, &ProjectManager::_scan_projects));
tree_vb->add_child(scan);
@@ -2575,21 +2549,25 @@ ProjectManager::ProjectManager() {
open_btn = memnew(Button);
open_btn->set_text(TTR("Edit"));
+ open_btn->set_shortcut(ED_SHORTCUT("project_manager/edit_project", TTR("Edit Project"), KEY_MASK_CMD | KEY_E));
open_btn->connect("pressed", callable_mp(this, &ProjectManager::_open_selected_projects_ask));
tree_vb->add_child(open_btn);
run_btn = memnew(Button);
run_btn->set_text(TTR("Run"));
+ run_btn->set_shortcut(ED_SHORTCUT("project_manager/run_project", TTR("Run Project"), KEY_MASK_CMD | KEY_R));
run_btn->connect("pressed", callable_mp(this, &ProjectManager::_run_project));
tree_vb->add_child(run_btn);
rename_btn = memnew(Button);
rename_btn->set_text(TTR("Rename"));
+ rename_btn->set_shortcut(ED_SHORTCUT("project_manager/rename_project", TTR("Rename Project"), KEY_F2));
rename_btn->connect("pressed", callable_mp(this, &ProjectManager::_rename_project));
tree_vb->add_child(rename_btn);
erase_btn = memnew(Button);
erase_btn->set_text(TTR("Remove"));
+ erase_btn->set_shortcut(ED_SHORTCUT("project_manager/remove_project", TTR("Remove Project"), KEY_DELETE));
erase_btn->connect("pressed", callable_mp(this, &ProjectManager::_erase_project));
tree_vb->add_child(erase_btn);
diff --git a/main/main.cpp b/main/main.cpp
index f1905fc47b..667aebebae 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -137,6 +137,7 @@ static int audio_driver_idx = -1;
static bool single_window = false;
static bool editor = false;
static bool project_manager = false;
+static bool cmdline_tool = false;
static String locale;
static bool show_help = false;
static bool auto_quit = false;
@@ -185,6 +186,10 @@ bool Main::is_project_manager() {
return project_manager;
}
+bool Main::is_cmdline_tool() {
+ return cmdline_tool;
+}
+
static String unescape_cmdline(const String &p_str) {
return p_str.replace("%20", " ");
}
@@ -881,18 +886,25 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
auto_build_solutions = true;
editor = true;
+ cmdline_tool = true;
#ifdef DEBUG_METHODS_ENABLED
} else if (I->get() == "--gdnative-generate-json-api" || I->get() == "--gdnative-generate-json-builtin-api") {
// Register as an editor instance to use low-end fallback if relevant.
editor = true;
+ cmdline_tool = true;
// We still pass it to the main arguments since the argument handling itself is not done in this function
main_args.push_back(I->get());
#endif
} else if (I->get() == "--export" || I->get() == "--export-debug" ||
I->get() == "--export-pack") { // Export project
-
+ // Actually handling is done in start().
editor = true;
+ cmdline_tool = true;
+ main_args.push_back(I->get());
+ } else if (I->get() == "--doctool") {
+ // Actually handling is done in start().
+ cmdline_tool = true;
main_args.push_back(I->get());
#endif
} else if (I->get() == "--path") { // set path of project to start or edit
@@ -1125,8 +1137,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
if (!project_manager && !editor) {
- // Determine if the project manager should be requested
- project_manager = main_args.size() == 0 && !found_project;
+ // If we didn't find a project, we fall back to the project manager.
+ project_manager = !found_project && !cmdline_tool;
}
#endif
@@ -1452,7 +1464,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
#endif
#ifdef TOOLS_ENABLED
- if (editor || project_manager) {
+ if (editor || project_manager || cmdline_tool) {
EditorPaths::create();
}
#endif
@@ -1577,7 +1589,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
print_verbose("Using \"" + tablet_driver + "\" pen tablet driver...");
- /* Initialize Visual Server */
+ /* Initialize Rendering Server */
rendering_server = memnew(RenderingServerDefault(OS::get_singleton()->get_render_thread_mode() == OS::RENDER_SEPARATE_THREAD));
@@ -1828,13 +1840,13 @@ bool Main::start() {
ERR_FAIL_COND_V(!_start_success, false);
bool hasicon = false;
- String doc_tool_path;
String positional_arg;
String game_path;
String script;
bool check_only = false;
#ifdef TOOLS_ENABLED
+ String doc_tool_path;
bool doc_base = true;
String _export_preset;
bool export_debug = false;
@@ -1844,8 +1856,9 @@ bool Main::start() {
main_timer_sync.init(OS::get_singleton()->get_ticks_usec());
List<String> args = OS::get_singleton()->get_cmdline_args();
- // parameters that do not have an argument to the right
for (int i = 0; i < args.size(); i++) {
+ // First check parameters that do not have an argument to the right.
+
// Doctest Unit Testing Handler
// Designed to override and pass arguments to the unit test handler.
if (args[i] == "--check-only") {
@@ -1875,7 +1888,7 @@ bool Main::start() {
game_path = args[i];
}
}
- //parameters that have an argument to the right
+ // Then parameters that have an argument to the right.
else if (i < (args.size() - 1)) {
bool parsed_pair = true;
if (args[i] == "-s" || args[i] == "--script") {
@@ -1907,16 +1920,19 @@ bool Main::start() {
if (parsed_pair) {
i++;
}
- } else if (args[i] == "--doctool") {
- // Handle case where no path is given to --doctool.
+ }
+#ifdef TOOLS_ENABLED
+ // Handle case where no path is given to --doctool.
+ else if (args[i] == "--doctool") {
doc_tool_path = ".";
}
+#endif
}
#ifdef TOOLS_ENABLED
if (doc_tool_path != "") {
- Engine::get_singleton()->set_editor_hint(
- true); // Needed to instance editor-only classes for their default values
+ // Needed to instance editor-only classes for their default values
+ Engine::get_singleton()->set_editor_hint(true);
{
DirAccessRef da = DirAccess::open(doc_tool_path);
@@ -1988,17 +2004,26 @@ bool Main::start() {
return false;
}
-
#endif
if (script == "" && game_path == "" && String(GLOBAL_GET("application/run/main_scene")) != "") {
game_path = GLOBAL_GET("application/run/main_scene");
}
+#ifdef TOOLS_ENABLED
+ if (!editor && !project_manager && !cmdline_tool && script == "" && game_path == "") {
+ // If we end up here, it means we didn't manage to detect what we want to run.
+ // Let's throw an error gently. The code leading to this is pretty brittle so
+ // this might end up triggered by valid usage, in which case we'll have to
+ // fine-tune further.
+ ERR_FAIL_V_MSG(false, "Couldn't detect whether to run the editor, the project manager or a specific project. Aborting.");
+ }
+#endif
+
MainLoop *main_loop = nullptr;
if (editor) {
main_loop = memnew(SceneTree);
- };
+ }
String main_loop_type = GLOBAL_DEF("application/run/main_loop_type", "SceneTree");
if (script != "") {
@@ -2360,14 +2385,13 @@ bool Main::start() {
}
#ifdef TOOLS_ENABLED
- if (project_manager || (script == "" && game_path == "" && !editor)) {
+ if (project_manager) {
Engine::get_singleton()->set_editor_hint(true);
ProjectManager *pmanager = memnew(ProjectManager);
ProgressDialog *progress_dialog = memnew(ProgressDialog);
pmanager->add_child(progress_dialog);
sml->get_root()->add_child(pmanager);
DisplayServer::get_singleton()->set_context(DisplayServer::CONTEXT_PROJECTMAN);
- project_manager = true;
}
if (project_manager || editor) {
diff --git a/main/main.h b/main/main.h
index f4fff6b97e..84077137ba 100644
--- a/main/main.h
+++ b/main/main.h
@@ -45,6 +45,7 @@ class Main {
public:
static bool is_project_manager();
+ static bool is_cmdline_tool();
static int test_entrypoint(int argc, char *argv[], bool &tests_need_run);
static Error setup(const char *execpath, int argc, char *argv[], bool p_second_phase = true);
static Error setup2(Thread::ID p_main_tid_override = 0);
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index 9491373013..94260e8c13 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -362,7 +362,10 @@ void NetworkedMultiplayerENet::poll() {
// To myself and only myself
incoming_packets.push_back(packet);
} else if (!server_relay) {
- // No other destination is allowed when server is not relaying
+ // When relaying is disabled, other destinations will only be processed by the server.
+ if (target == 0 || target < -1) {
+ incoming_packets.push_back(packet);
+ }
continue;
} else if (target == 0) {
// Re-send to everyone but sender :|
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 7e17ac2f05..80551de1ba 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -1080,6 +1080,16 @@ void GridMapEditor::_notification(int p_what) {
options->set_icon(get_theme_icon("GridMap", "EditorIcons"));
search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
} break;
+
+ case NOTIFICATION_APPLICATION_FOCUS_OUT: {
+ if (input_action == INPUT_PAINT) {
+ // Simulate mouse released event to stop drawing when editor focus exists.
+ Ref<InputEventMouseButton> release;
+ release.instance();
+ release->set_button_index(MOUSE_BUTTON_LEFT);
+ forward_spatial_input_event(nullptr, release);
+ }
+ } break;
}
}
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index 1b14aac3da..a7edc6e6e5 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -1049,19 +1049,19 @@ public:
// Capabilities
const char **basic = uwp_capabilities;
while (*basic) {
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/" + String(*basic).camelcase_to_underscore(false)), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/" + String(*basic)), false));
basic++;
}
const char **uap = uwp_uap_capabilities;
while (*uap) {
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/" + String(*uap).camelcase_to_underscore(false)), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/" + String(*uap)), false));
uap++;
}
const char **device = uwp_device_capabilities;
while (*device) {
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/" + String(*device).camelcase_to_underscore(false)), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/" + String(*device)), false));
device++;
}
}
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 1e444e439d..57d395e894 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -40,16 +40,6 @@
#include "editor/editor_scale.h"
#endif
-#define ZOOM_SCALE 1.2
-
-// Allow dezooming 8 times from the default zoom level.
-// At low zoom levels, text is unreadable due to its small size and poor filtering,
-// but this is still useful for previewing purposes.
-#define MIN_ZOOM (1 / Math::pow(ZOOM_SCALE, 8))
-
-// Allow zooming 4 times from the default zoom level.
-#define MAX_ZOOM (1 * Math::pow(ZOOM_SCALE, 4))
-
#define MINIMAP_OFFSET 12
#define MINIMAP_PADDING 5
@@ -1328,9 +1318,9 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
}
if (b->get_button_index() == MOUSE_BUTTON_WHEEL_UP && Input::get_singleton()->is_key_pressed(KEY_CTRL)) {
- set_zoom_custom(zoom * ZOOM_SCALE, b->get_position());
+ set_zoom_custom(zoom * zoom_step, b->get_position());
} else if (b->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN && Input::get_singleton()->is_key_pressed(KEY_CTRL)) {
- set_zoom_custom(zoom / ZOOM_SCALE, b->get_position());
+ set_zoom_custom(zoom / zoom_step, b->get_position());
} else if (b->get_button_index() == MOUSE_BUTTON_WHEEL_UP && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() * b->get_factor() / 8);
} else if (b->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
@@ -1397,19 +1387,19 @@ void GraphEdit::set_zoom(float p_zoom) {
}
void GraphEdit::set_zoom_custom(float p_zoom, const Vector2 &p_center) {
- p_zoom = CLAMP(p_zoom, MIN_ZOOM, MAX_ZOOM);
+ p_zoom = CLAMP(p_zoom, zoom_min, zoom_max);
if (zoom == p_zoom) {
return;
}
- zoom_minus->set_disabled(zoom == MIN_ZOOM);
- zoom_plus->set_disabled(zoom == MAX_ZOOM);
-
Vector2 sbofs = (Vector2(h_scroll->get_value(), v_scroll->get_value()) + p_center) / zoom;
zoom = p_zoom;
top_layer->update();
+ zoom_minus->set_disabled(zoom == zoom_min);
+ zoom_plus->set_disabled(zoom == zoom_max);
+
_update_scroll();
minimap->update();
connections_layer->update();
@@ -1420,6 +1410,7 @@ void GraphEdit::set_zoom_custom(float p_zoom, const Vector2 &p_center) {
v_scroll->set_value(ofs.y);
}
+ _update_zoom_label();
update();
}
@@ -1427,6 +1418,61 @@ float GraphEdit::get_zoom() const {
return zoom;
}
+void GraphEdit::set_zoom_step(float p_zoom_step) {
+ p_zoom_step = abs(p_zoom_step);
+ if (zoom_step == p_zoom_step) {
+ return;
+ }
+
+ zoom_step = p_zoom_step;
+}
+
+float GraphEdit::get_zoom_step() const {
+ return zoom_step;
+}
+
+void GraphEdit::set_zoom_min(float p_zoom_min) {
+ ERR_FAIL_COND_MSG(p_zoom_min > zoom_max, "Cannot set min zoom level greater than max zoom level.");
+
+ if (zoom_min == p_zoom_min) {
+ return;
+ }
+
+ zoom_min = p_zoom_min;
+ set_zoom(zoom);
+}
+
+float GraphEdit::get_zoom_min() const {
+ return zoom_min;
+}
+
+void GraphEdit::set_zoom_max(float p_zoom_max) {
+ ERR_FAIL_COND_MSG(p_zoom_max < zoom_min, "Cannot set max zoom level lesser than min zoom level.");
+
+ if (zoom_max == p_zoom_max) {
+ return;
+ }
+
+ zoom_max = p_zoom_max;
+ set_zoom(zoom);
+}
+
+float GraphEdit::get_zoom_max() const {
+ return zoom_max;
+}
+
+void GraphEdit::set_show_zoom_label(bool p_enable) {
+ if (zoom_label->is_visible() == p_enable) {
+ return;
+ }
+
+ zoom_label->set_visible(p_enable);
+}
+
+bool GraphEdit::is_showing_zoom_label() const {
+ return zoom_label->is_visible();
+}
+
void GraphEdit::set_right_disconnects(bool p_enable) {
right_disconnects = p_enable;
}
@@ -1467,7 +1513,7 @@ Array GraphEdit::_get_connection_list() const {
}
void GraphEdit::_zoom_minus() {
- set_zoom(zoom / ZOOM_SCALE);
+ set_zoom(zoom / zoom_step);
}
void GraphEdit::_zoom_reset() {
@@ -1475,7 +1521,13 @@ void GraphEdit::_zoom_reset() {
}
void GraphEdit::_zoom_plus() {
- set_zoom(zoom * ZOOM_SCALE);
+ set_zoom(zoom * zoom_step);
+}
+
+void GraphEdit::_update_zoom_label() {
+ int zoom_percent = static_cast<int>(Math::round(zoom * 100));
+ String zoom_text = itos(zoom_percent) + "%";
+ zoom_label->set_text(zoom_text);
}
void GraphEdit::add_valid_connection_type(int p_type, int p_with_type) {
@@ -1616,6 +1668,18 @@ void GraphEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_zoom", "zoom"), &GraphEdit::set_zoom);
ClassDB::bind_method(D_METHOD("get_zoom"), &GraphEdit::get_zoom);
+ ClassDB::bind_method(D_METHOD("set_zoom_min", "zoom_min"), &GraphEdit::set_zoom_min);
+ ClassDB::bind_method(D_METHOD("get_zoom_min"), &GraphEdit::get_zoom_min);
+
+ ClassDB::bind_method(D_METHOD("set_zoom_max", "zoom_max"), &GraphEdit::set_zoom_max);
+ ClassDB::bind_method(D_METHOD("get_zoom_max"), &GraphEdit::get_zoom_max);
+
+ ClassDB::bind_method(D_METHOD("set_zoom_step", "zoom_step"), &GraphEdit::set_zoom_step);
+ ClassDB::bind_method(D_METHOD("get_zoom_step"), &GraphEdit::get_zoom_step);
+
+ ClassDB::bind_method(D_METHOD("set_show_zoom_label", "enable"), &GraphEdit::set_show_zoom_label);
+ ClassDB::bind_method(D_METHOD("is_showing_zoom_label"), &GraphEdit::is_showing_zoom_label);
+
ClassDB::bind_method(D_METHOD("set_snap", "pixels"), &GraphEdit::set_snap);
ClassDB::bind_method(D_METHOD("get_snap"), &GraphEdit::get_snap);
@@ -1650,9 +1714,18 @@ void GraphEdit::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scroll_offset"), "set_scroll_ofs", "get_scroll_ofs");
ADD_PROPERTY(PropertyInfo(Variant::INT, "snap_distance"), "set_snap", "get_snap");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_snap"), "set_use_snap", "is_using_snap");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "zoom"), "set_zoom", "get_zoom");
+
+ ADD_GROUP("Connection Lines", "connection_lines");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "connection_lines_thickness"), "set_connection_lines_thickness", "get_connection_lines_thickness");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "connection_lines_antialiased"), "set_connection_lines_antialiased", "is_connection_lines_antialiased");
+
+ ADD_GROUP("Zoom", "");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "zoom"), "set_zoom", "get_zoom");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "zoom_min"), "set_zoom_min", "get_zoom_min");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "zoom_max"), "set_zoom_max", "get_zoom_max");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "zoom_step"), "set_zoom_step", "get_zoom_step");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_zoom_label"), "set_show_zoom_label", "is_showing_zoom_label");
+
ADD_GROUP("Minimap", "minimap");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "minimap_enabled"), "set_minimap_enabled", "is_minimap_enabled");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "minimap_size"), "set_minimap_size", "get_minimap_size");
@@ -1677,6 +1750,13 @@ void GraphEdit::_bind_methods() {
GraphEdit::GraphEdit() {
set_focus_mode(FOCUS_ALL);
+ // Allow dezooming 8 times from the default zoom level.
+ // At low zoom levels, text is unreadable due to its small size and poor filtering,
+ // but this is still useful for previewing purposes.
+ zoom_min = (1 / Math::pow(zoom_step, 8));
+ // Allow zooming 4 times from the default zoom level.
+ zoom_max = (1 * Math::pow(zoom_step, 4));
+
top_layer = memnew(GraphEditFilter(this));
add_child(top_layer);
top_layer->set_mouse_filter(MOUSE_FILTER_PASS);
@@ -1713,6 +1793,18 @@ GraphEdit::GraphEdit() {
top_layer->add_child(zoom_hb);
zoom_hb->set_position(Vector2(10, 10));
+ zoom_label = memnew(Label);
+ zoom_hb->add_child(zoom_label);
+ zoom_label->set_visible(false);
+ zoom_label->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
+ zoom_label->set_align(Label::ALIGN_CENTER);
+#ifdef TOOLS_ENABLED
+ zoom_label->set_custom_minimum_size(Size2(48, 0) * EDSCALE);
+#else
+ zoom_label->set_custom_minimum_size(Size2(48, 0));
+#endif
+ _update_zoom_label();
+
zoom_minus = memnew(Button);
zoom_minus->set_flat(true);
zoom_hb->add_child(zoom_minus);
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index 8a51bcb11e..e8300f901c 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -34,6 +34,7 @@
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
#include "scene/gui/graph_node.h"
+#include "scene/gui/label.h"
#include "scene/gui/scroll_bar.h"
#include "scene/gui/slider.h"
#include "scene/gui/spin_box.h"
@@ -105,6 +106,7 @@ public:
};
private:
+ Label *zoom_label;
Button *zoom_minus;
Button *zoom_reset;
Button *zoom_plus;
@@ -114,10 +116,6 @@ private:
Button *minimap_button;
- void _zoom_minus();
- void _zoom_reset();
- void _zoom_plus();
-
HScrollBar *h_scroll;
VScrollBar *v_scroll;
@@ -144,6 +142,14 @@ private:
Vector2 drag_accum;
float zoom = 1.0;
+ float zoom_step = 1.2;
+ float zoom_min;
+ float zoom_max;
+
+ void _zoom_minus();
+ void _zoom_reset();
+ void _zoom_plus();
+ void _update_zoom_label();
bool box_selecting = false;
bool box_selection_mode_additive = false;
@@ -247,6 +253,18 @@ public:
void set_zoom_custom(float p_zoom, const Vector2 &p_center);
float get_zoom() const;
+ void set_zoom_min(float p_zoom_min);
+ float get_zoom_min() const;
+
+ void set_zoom_max(float p_zoom_max);
+ float get_zoom_max() const;
+
+ void set_zoom_step(float p_zoom_step);
+ float get_zoom_step() const;
+
+ void set_show_zoom_label(bool p_enable);
+ bool is_showing_zoom_label() const;
+
void set_minimap_size(Vector2 p_size);
Vector2 get_minimap_size() const;
void set_minimap_opacity(float p_opacity);