summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/debugger/editor_performance_profiler.cpp394
-rw-r--r--editor/debugger/editor_performance_profiler.h90
-rw-r--r--editor/debugger/script_editor_debugger.cpp265
-rw-r--r--editor/debugger/script_editor_debugger.h12
-rw-r--r--editor/editor_file_system.cpp6
-rw-r--r--editor/editor_help_search.cpp19
-rw-r--r--editor/editor_node.cpp6
-rw-r--r--editor/editor_plugin_settings.cpp2
-rw-r--r--editor/editor_properties.cpp10
-rw-r--r--editor/editor_resource_preview.cpp6
-rw-r--r--editor/editor_spin_slider.cpp4
-rw-r--r--editor/filesystem_dock.cpp8
-rw-r--r--editor/plugins/script_editor_plugin.cpp4
-rw-r--r--editor/plugins/shader_editor_plugin.cpp2
-rw-r--r--editor/plugins/shader_file_editor_plugin.cpp2
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp2
-rw-r--r--editor/property_editor.cpp8
-rw-r--r--editor/scene_tree_dock.cpp46
18 files changed, 587 insertions, 299 deletions
diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp
new file mode 100644
index 0000000000..47fe282758
--- /dev/null
+++ b/editor/debugger/editor_performance_profiler.cpp
@@ -0,0 +1,394 @@
+/*************************************************************************/
+/* editor_performance_profiler.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "editor_performance_profiler.h"
+
+#include "editor/editor_scale.h"
+#include "editor/editor_settings.h"
+#include "main/performance.h"
+
+EditorPerformanceProfiler::Monitor::Monitor() {}
+
+EditorPerformanceProfiler::Monitor::Monitor(String p_name, String p_base, int p_frame_index, Performance::MonitorType p_type, TreeItem *p_item) {
+ type = p_type;
+ item = p_item;
+ frame_index = p_frame_index;
+ name = p_name;
+ base = p_base;
+}
+
+void EditorPerformanceProfiler::Monitor::update_value(float p_value) {
+ ERR_FAIL_COND(!item);
+ String label = EditorPerformanceProfiler::_create_label(p_value, type);
+ String tooltip = label;
+ switch (type) {
+ case Performance::MONITOR_TYPE_MEMORY: {
+ tooltip = label;
+ } break;
+ case Performance::MONITOR_TYPE_TIME: {
+ tooltip = label;
+ } break;
+ default: {
+ tooltip += " " + item->get_text(0);
+ } break;
+ }
+ item->set_text(1, label);
+ item->set_tooltip(1, tooltip);
+
+ if (p_value > max) {
+ max = p_value;
+ }
+}
+
+void EditorPerformanceProfiler::Monitor::reset() {
+ history.clear();
+ max = 0.0f;
+ if (item) {
+ item->set_text(1, "");
+ item->set_tooltip(1, "");
+ }
+}
+
+String EditorPerformanceProfiler::_create_label(float p_value, Performance::MonitorType p_type) {
+ switch (p_type) {
+ case Performance::MONITOR_TYPE_MEMORY: {
+ return String::humanize_size(p_value);
+ }
+ case Performance::MONITOR_TYPE_TIME: {
+ return rtos(p_value * 1000).pad_decimals(2) + " ms";
+ }
+ default: {
+ return rtos(p_value);
+ }
+ }
+}
+
+void EditorPerformanceProfiler::_monitor_select() {
+ monitor_draw->update();
+}
+
+void EditorPerformanceProfiler::_monitor_draw() {
+ Vector<StringName> active;
+ for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) {
+ if (i.value().item->is_checked(0)) {
+ active.push_back(i.key());
+ }
+ }
+
+ if (active.empty()) {
+ info_message->show();
+ return;
+ }
+
+ info_message->hide();
+
+ Ref<StyleBox> graph_style_box = get_theme_stylebox("normal", "TextEdit");
+ Ref<Font> graph_font = get_theme_font("font", "TextEdit");
+
+ int columns = int(Math::ceil(Math::sqrt(float(active.size()))));
+ int rows = int(Math::ceil(float(active.size()) / float(columns)));
+ if (active.size() == 1) {
+ rows = 1;
+ }
+ Size2i cell_size = Size2i(monitor_draw->get_size()) / Size2i(columns, rows);
+ float spacing = float(POINT_SEPARATION) / float(columns);
+ float value_multiplier = EditorSettings::get_singleton()->is_dark_theme() ? 1.4f : 0.55f;
+ float hue_shift = 1.0f / float(monitors.size());
+
+ for (int i = 0; i < active.size(); i++) {
+ Monitor &current = monitors[active[i]];
+ Rect2i rect(Point2i(i % columns, i / columns) * cell_size + Point2i(MARGIN, MARGIN), cell_size - Point2i(MARGIN, MARGIN) * 2);
+ monitor_draw->draw_style_box(graph_style_box, rect);
+
+ rect.position += graph_style_box->get_offset();
+ rect.size -= graph_style_box->get_minimum_size();
+ Color draw_color = get_theme_color("accent_color", "Editor");
+ draw_color.set_hsv(Math::fmod(hue_shift * float(current.frame_index), 0.9f), draw_color.get_s() * 0.9f, draw_color.get_v() * value_multiplier, 0.6f);
+ monitor_draw->draw_string(graph_font, rect.position + Point2(0, graph_font->get_ascent()), current.item->get_text(0), draw_color, rect.size.x);
+
+ draw_color.a = 0.9f;
+ float value_position = rect.size.width - graph_font->get_string_size(current.item->get_text(1)).width;
+ if (value_position < 0) {
+ value_position = 0;
+ }
+ monitor_draw->draw_string(graph_font, rect.position + Point2(value_position, graph_font->get_ascent()), current.item->get_text(1), draw_color, rect.size.x);
+
+ rect.position.y += graph_font->get_height();
+ rect.size.height -= graph_font->get_height();
+
+ int line_count = rect.size.height / (graph_font->get_height() * 2);
+ if (line_count > 5) {
+ line_count = 5;
+ }
+ if (line_count > 0) {
+ Color horizontal_line_color;
+ horizontal_line_color.set_hsv(draw_color.get_h(), draw_color.get_s() * 0.5f, draw_color.get_v() * 0.5f, 0.3f);
+ monitor_draw->draw_line(rect.position, rect.position + Vector2(rect.size.width, 0), horizontal_line_color, Math::round(EDSCALE));
+ monitor_draw->draw_string(graph_font, rect.position + Vector2(0, graph_font->get_ascent()), _create_label(current.max, current.type), horizontal_line_color, rect.size.width);
+
+ for (int j = 0; j < line_count; j++) {
+ Vector2 y_offset = Vector2(0, rect.size.height * (1.0f - float(j) / float(line_count)));
+ monitor_draw->draw_line(rect.position + y_offset, rect.position + Vector2(rect.size.width, 0) + y_offset, horizontal_line_color, Math::round(EDSCALE));
+ monitor_draw->draw_string(graph_font, rect.position - Vector2(0, graph_font->get_descent()) + y_offset, _create_label(current.max * float(j) / float(line_count), current.type), horizontal_line_color, rect.size.width);
+ }
+ }
+
+ float from = rect.size.width;
+ float prev = -1.0f;
+ int count = 0;
+ List<float>::Element *e = current.history.front();
+
+ while (from >= 0 && e) {
+ float m = current.max;
+ float h2 = 0;
+ if (m != 0) {
+ h2 = (e->get() / m);
+ }
+ h2 = (1.0f - h2) * float(rect.size.y);
+ if (e != current.history.front()) {
+ monitor_draw->draw_line(rect.position + Point2(from, h2), rect.position + Point2(from + spacing, prev), draw_color, Math::round(EDSCALE));
+ }
+
+ if (marker_key == active[i] && count == marker_frame) {
+ Color line_color;
+ line_color.set_hsv(draw_color.get_h(), draw_color.get_s() * 0.8f, draw_color.get_v(), 0.5f);
+ monitor_draw->draw_line(rect.position + Point2(from, 0), rect.position + Point2(from, rect.size.y), line_color, Math::round(EDSCALE));
+
+ String label = _create_label(e->get(), current.type);
+ Size2 size = graph_font->get_string_size(label);
+ Vector2 text_top_left_position = Vector2(from, h2) - (size + Vector2(MARKER_MARGIN, MARKER_MARGIN));
+ if (text_top_left_position.x < 0) {
+ text_top_left_position.x = from + MARKER_MARGIN;
+ }
+ if (text_top_left_position.y < 0) {
+ text_top_left_position.y = h2 + MARKER_MARGIN;
+ }
+ monitor_draw->draw_string(graph_font, rect.position + text_top_left_position + Point2(0, graph_font->get_ascent()), label, line_color, rect.size.x);
+ }
+ prev = h2;
+ e = e->next();
+ from -= spacing;
+ count++;
+ }
+ }
+}
+
+void EditorPerformanceProfiler::_build_monitor_tree() {
+ Set<StringName> monitor_checked;
+ for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) {
+ if (i.value().item && i.value().item->is_checked(0)) {
+ monitor_checked.insert(i.key());
+ }
+ }
+
+ base_map.clear();
+ monitor_tree->get_root()->clear_children();
+
+ for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) {
+ TreeItem *base = _get_monitor_base(i.value().base);
+ TreeItem *item = _create_monitor_item(i.value().name, base);
+ item->set_checked(0, monitor_checked.has(i.key()));
+ i.value().item = item;
+ if (!i.value().history.empty()) {
+ i.value().update_value(i.value().history.front()->get());
+ }
+ }
+}
+
+TreeItem *EditorPerformanceProfiler::_get_monitor_base(const StringName &p_base_name) {
+ if (base_map.has(p_base_name)) {
+ return base_map[p_base_name];
+ }
+
+ TreeItem *base = monitor_tree->create_item(monitor_tree->get_root());
+ base->set_text(0, p_base_name);
+ base->set_editable(0, false);
+ base->set_selectable(0, false);
+ base->set_expand_right(0, true);
+ base_map.insert(p_base_name, base);
+ return base;
+}
+
+TreeItem *EditorPerformanceProfiler::_create_monitor_item(const StringName &p_monitor_name, TreeItem *p_base) {
+ TreeItem *item = monitor_tree->create_item(p_base);
+ item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ item->set_editable(0, true);
+ item->set_selectable(0, false);
+ item->set_selectable(1, false);
+ item->set_text(0, p_monitor_name);
+ return item;
+}
+
+void EditorPerformanceProfiler::_marker_input(const Ref<InputEvent> &p_event) {
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ Vector<StringName> active;
+ for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) {
+ if (i.value().item->is_checked(0)) {
+ active.push_back(i.key());
+ }
+ }
+ if (active.size() > 0) {
+ int columns = int(Math::ceil(Math::sqrt(float(active.size()))));
+ int rows = int(Math::ceil(float(active.size()) / float(columns)));
+ if (active.size() == 1) {
+ rows = 1;
+ }
+ Size2i cell_size = Size2i(monitor_draw->get_size()) / Size2i(columns, rows);
+ Vector2i index = mb->get_position() / cell_size;
+ Rect2i rect(index * cell_size + Point2i(MARGIN, MARGIN), cell_size - Point2i(MARGIN, MARGIN) * 2);
+ if (rect.has_point(mb->get_position())) {
+ if (index.x + index.y * columns < active.size()) {
+ marker_key = active[index.x + index.y * columns];
+ } else {
+ marker_key = "";
+ }
+ Ref<StyleBox> graph_style_box = get_theme_stylebox("normal", "TextEdit");
+ rect.position += graph_style_box->get_offset();
+ rect.size -= graph_style_box->get_minimum_size();
+ Vector2 point = mb->get_position() - rect.position;
+ if (point.x >= rect.size.x) {
+ marker_frame = 0;
+ } else {
+ int point_sep = 5;
+ float spacing = float(point_sep) / float(columns);
+ marker_frame = (rect.size.x - point.x) / spacing;
+ }
+ monitor_draw->update();
+ return;
+ }
+ }
+ marker_key = "";
+ monitor_draw->update();
+ }
+}
+
+void EditorPerformanceProfiler::reset() {
+ for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) {
+ if (String(i.key()).begins_with("custom:")) {
+ monitors.erase(i);
+ } else {
+ i.value().reset();
+ }
+ }
+
+ _build_monitor_tree();
+ marker_key = "";
+ marker_frame = 0;
+ monitor_draw->update();
+}
+
+void EditorPerformanceProfiler::update_monitors(const Vector<StringName> &p_names) {
+ OrderedHashMap<StringName, int> names;
+ for (int i = 0; i < p_names.size(); i++) {
+ names.insert("custom:" + p_names[i], Performance::MONITOR_MAX + i);
+ }
+
+ for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) {
+ if (String(i.key()).begins_with("custom:")) {
+ if (!names.has(i.key())) {
+ monitors.erase(i);
+ } else {
+ i.value().frame_index = names[i.key()];
+ names.erase(i.key());
+ }
+ }
+ }
+
+ for (OrderedHashMap<StringName, int>::Element i = names.front(); i; i = i.next()) {
+ String name = String(i.key()).replace_first("custom:", "");
+ String base = "Custom";
+ if (name.get_slice_count("/") == 2) {
+ base = name.get_slicec('/', 0);
+ name = name.get_slicec('/', 1);
+ }
+ monitors.insert(i.key(), Monitor(name, base, i.value(), Performance::MONITOR_TYPE_QUANTITY, nullptr));
+ }
+
+ _build_monitor_tree();
+}
+
+void EditorPerformanceProfiler::add_profile_frame(const Vector<float> &p_values) {
+ for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) {
+ float data = 0.0f;
+ if (i.value().frame_index >= 0 && i.value().frame_index < p_values.size()) {
+ data = p_values[i.value().frame_index];
+ }
+ i.value().history.push_front(data);
+ i.value().update_value(data);
+ }
+ marker_frame++;
+ monitor_draw->update();
+}
+
+List<float> *EditorPerformanceProfiler::get_monitor_data(const StringName &p_name) {
+ if (monitors.has(p_name)) {
+ return &monitors[p_name].history;
+ }
+ return nullptr;
+}
+
+EditorPerformanceProfiler::EditorPerformanceProfiler() {
+ set_name(TTR("Monitors"));
+ set_split_offset(340 * EDSCALE);
+
+ monitor_tree = memnew(Tree);
+ monitor_tree->set_columns(2);
+ monitor_tree->set_column_title(0, TTR("Monitor"));
+ monitor_tree->set_column_title(1, TTR("Value"));
+ monitor_tree->set_column_titles_visible(true);
+ monitor_tree->connect("item_edited", callable_mp(this, &EditorPerformanceProfiler::_monitor_select));
+ monitor_tree->create_item();
+ monitor_tree->set_hide_root(true);
+ add_child(monitor_tree);
+
+ monitor_draw = memnew(Control);
+ monitor_draw->set_clip_contents(true);
+ monitor_draw->connect("draw", callable_mp(this, &EditorPerformanceProfiler::_monitor_draw));
+ monitor_draw->connect("gui_input", callable_mp(this, &EditorPerformanceProfiler::_marker_input));
+ add_child(monitor_draw);
+
+ info_message = memnew(Label);
+ info_message->set_text(TTR("Pick one or more items from the list to display the graph."));
+ info_message->set_valign(Label::VALIGN_CENTER);
+ info_message->set_align(Label::ALIGN_CENTER);
+ info_message->set_autowrap(true);
+ info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
+ info_message->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
+ monitor_draw->add_child(info_message);
+
+ for (int i = 0; i < Performance::MONITOR_MAX; i++) {
+ String base = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)).get_slicec('/', 0).capitalize();
+ String name = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)).get_slicec('/', 1).capitalize();
+ monitors.insert(Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)), Monitor(name, base, i, Performance::get_singleton()->get_monitor_type(Performance::Monitor(i)), nullptr));
+ }
+
+ _build_monitor_tree();
+}
diff --git a/editor/debugger/editor_performance_profiler.h b/editor/debugger/editor_performance_profiler.h
new file mode 100644
index 0000000000..144dd34103
--- /dev/null
+++ b/editor/debugger/editor_performance_profiler.h
@@ -0,0 +1,90 @@
+/*************************************************************************/
+/* editor_performance_profiler.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef EDITOR_PERFORMANCE_PROFILER_H
+#define EDITOR_PERFORMANCE_PROFILER_H
+
+#include "core/map.h"
+#include "core/ordered_hash_map.h"
+#include "main/performance.h"
+#include "scene/gui/control.h"
+#include "scene/gui/label.h"
+#include "scene/gui/split_container.h"
+#include "scene/gui/tree.h"
+
+class EditorPerformanceProfiler : public HSplitContainer {
+ GDCLASS(EditorPerformanceProfiler, HSplitContainer);
+
+private:
+ class Monitor {
+ public:
+ String name;
+ String base;
+ List<float> history;
+ float max = 0.0f;
+ TreeItem *item = nullptr;
+ Performance::MonitorType type = Performance::MONITOR_TYPE_QUANTITY;
+ int frame_index = 0;
+
+ Monitor();
+ Monitor(String p_name, String p_base, int p_frame_index, Performance::MonitorType p_type, TreeItem *p_item);
+ void update_value(float p_value);
+ void reset();
+ };
+
+ OrderedHashMap<StringName, Monitor> monitors;
+
+ Map<StringName, TreeItem *> base_map;
+ Tree *monitor_tree;
+ Control *monitor_draw;
+ Label *info_message;
+ StringName marker_key;
+ int marker_frame;
+ const int MARGIN = 4;
+ const int POINT_SEPARATION = 5;
+ const int MARKER_MARGIN = 2;
+
+ static String _create_label(float p_value, Performance::MonitorType p_type);
+ void _monitor_select();
+ void _monitor_draw();
+ void _build_monitor_tree();
+ TreeItem *_get_monitor_base(const StringName &p_base_name);
+ TreeItem *_create_monitor_item(const StringName &p_monitor_name, TreeItem *p_base);
+ void _marker_input(const Ref<InputEvent> &p_event);
+
+public:
+ void reset();
+ void update_monitors(const Vector<StringName> &p_names);
+ void add_profile_frame(const Vector<float> &p_values);
+ List<float> *get_monitor_data(const StringName &p_name);
+ EditorPerformanceProfiler();
+};
+
+#endif // EDITOR_PERFORMANCE_PROFILER_H
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index 6b010fbfb5..a828e29558 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -36,6 +36,7 @@
#include "core/project_settings.h"
#include "core/ustring.h"
#include "editor/debugger/editor_network_profiler.h"
+#include "editor/debugger/editor_performance_profiler.h"
#include "editor/debugger/editor_profiler.h"
#include "editor/debugger/editor_visual_profiler.h"
#include "editor/editor_log.h"
@@ -172,14 +173,25 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) {
file->store_csv_line(line);
// values
- List<Vector<float>>::Element *E = perf_history.back();
- while (E) {
- Vector<float> &perf_data = E->get();
- for (int i = 0; i < perf_data.size(); i++) {
- line.write[i] = String::num_real(perf_data[i]);
+ Vector<List<float>::Element *> iterators;
+ iterators.resize(Performance::MONITOR_MAX);
+ bool continue_iteration = false;
+ for (int i = 0; i < Performance::MONITOR_MAX; i++) {
+ iterators.write[i] = performance_profiler->get_monitor_data(Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)))->back();
+ continue_iteration = continue_iteration || iterators[i];
+ }
+ while (continue_iteration) {
+ continue_iteration = false;
+ for (int i = 0; i < Performance::MONITOR_MAX; i++) {
+ if (iterators[i]) {
+ line.write[i] = String::num_real(iterators[i]->get());
+ iterators.write[i] = iterators[i]->prev();
+ } else {
+ line.write[i] = "";
+ }
+ continue_iteration = continue_iteration || iterators[i];
}
file->store_csv_line(line);
- E = E->prev();
}
file->store_string("\n");
@@ -409,37 +421,12 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
EditorNode::get_log()->add_message(output_strings[i], msg_type);
}
} else if (p_msg == "performance:profile_frame") {
- Vector<float> p;
- p.resize(p_data.size());
+ Vector<float> frame_data;
+ frame_data.resize(p_data.size());
for (int i = 0; i < p_data.size(); i++) {
- p.write[i] = p_data[i];
- if (i < perf_items.size()) {
- const float value = p[i];
- String label = rtos(value);
- String tooltip = label;
- switch (Performance::MonitorType((int)perf_items[i]->get_metadata(1))) {
- case Performance::MONITOR_TYPE_MEMORY: {
- label = String::humanize_size(value);
- tooltip = label;
- } break;
- case Performance::MONITOR_TYPE_TIME: {
- label = rtos(value * 1000).pad_decimals(2) + " ms";
- tooltip = label;
- } break;
- default: {
- tooltip += " " + perf_items[i]->get_text(0);
- } break;
- }
-
- perf_items[i]->set_text(1, label);
- perf_items[i]->set_tooltip(1, tooltip);
- if (p[i] > perf_max[i]) {
- perf_max.write[i] = p[i];
- }
- }
+ frame_data.write[i] = p_data[i];
}
- perf_history.push_front(p);
- perf_draw->update();
+ performance_profiler->add_profile_frame(frame_data);
} else if (p_msg == "visual:profile_frame") {
DebuggerMarshalls::VisualProfilerFrame frame;
@@ -704,6 +691,15 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
emit_signal("stop_requested");
_stop_and_notify();
+ } else if (p_msg == "performance:profile_names") {
+ Vector<StringName> monitors;
+ monitors.resize(p_data.size());
+ for (int i = 0; i < p_data.size(); i++) {
+ ERR_FAIL_COND(p_data[i].get_type() != Variant::STRING_NAME);
+ monitors.set(i, p_data[i]);
+ }
+ performance_profiler->update_monitors(monitors);
+
} else {
WARN_PRINT("unknown message " + p_msg);
}
@@ -724,141 +720,6 @@ void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType
reason->set_tooltip(p_reason.word_wrap(80));
}
-void ScriptEditorDebugger::_performance_select() {
- perf_draw->update();
-}
-
-void ScriptEditorDebugger::_performance_draw() {
- Vector<int> which;
- for (int i = 0; i < perf_items.size(); i++) {
- if (perf_items[i]->is_checked(0)) {
- which.push_back(i);
- }
- }
-
- if (which.empty()) {
- info_message->show();
- return;
- }
-
- info_message->hide();
-
- const Ref<StyleBox> graph_sb = get_theme_stylebox("normal", "TextEdit");
- const Ref<Font> graph_font = get_theme_font("font", "TextEdit");
-
- const int cols = Math::ceil(Math::sqrt((float)which.size()));
- int rows = Math::ceil((float)which.size() / cols);
- if (which.size() == 1) {
- rows = 1;
- }
-
- const int margin = 3;
- const int point_sep = 5;
- const Size2i s = Size2i(perf_draw->get_size()) / Size2i(cols, rows);
-
- for (int i = 0; i < which.size(); i++) {
- Point2i p(i % cols, i / cols);
- Rect2i r(p * s, s);
- r.position += Point2(margin, margin);
- r.size -= Point2(margin, margin) * 2.0;
- perf_draw->draw_style_box(graph_sb, r);
- r.position += graph_sb->get_offset();
- r.size -= graph_sb->get_minimum_size();
- const int pi = which[i];
-
- // Draw horizontal lines with labels.
-
- int nb_lines = 5;
- // Draw less lines if the monitor isn't tall enough to display 5 labels.
- if (r.size.height <= 160 * EDSCALE) {
- nb_lines = 3;
- } else if (r.size.height <= 240 * EDSCALE) {
- nb_lines = 4;
- }
-
- const float inv_nb_lines = 1.0 / nb_lines;
-
- for (int line = 0; line < nb_lines; line += 1) {
- const int from_x = r.position.x;
- const int to_x = r.position.x + r.size.width;
- const int y = r.position.y + (r.size.height * inv_nb_lines + line * inv_nb_lines * r.size.height);
- perf_draw->draw_line(
- Point2(from_x, y),
- Point2i(to_x, y),
- Color(0.5, 0.5, 0.5, 0.25),
- Math::round(EDSCALE));
-
- String label;
- switch (Performance::MonitorType((int)perf_items[pi]->get_metadata(1))) {
- case Performance::MONITOR_TYPE_MEMORY: {
- label = String::humanize_size(Math::ceil((1 - inv_nb_lines - inv_nb_lines * line) * perf_max[pi]));
- } break;
- case Performance::MONITOR_TYPE_TIME: {
- label = rtos((1 - inv_nb_lines - inv_nb_lines * line) * perf_max[pi] * 1000).pad_decimals(2) + " ms";
- } break;
- default: {
- label = itos(Math::ceil((1 - inv_nb_lines - inv_nb_lines * line) * perf_max[pi]));
- } break;
- }
-
- perf_draw->draw_string(
- graph_font,
- Point2(from_x, y - graph_font->get_ascent() * 0.25),
- label,
- Color(0.5, 0.5, 0.5, 1.0));
- }
-
- const float h = (float)which[i] / (float)(perf_items.size());
- // Use a darker color on light backgrounds for better visibility.
- const float value_multiplier = EditorSettings::get_singleton()->is_dark_theme() ? 1.4 : 0.55;
- Color color = get_theme_color("accent_color", "Editor");
- color.set_hsv(Math::fmod(h + 0.4, 0.9), color.get_s() * 0.9, color.get_v() * value_multiplier);
-
- // Draw the monitor name in the top-left corner.
- color.a = 0.6;
- perf_draw->draw_string(
- graph_font,
- r.position + Point2(0, graph_font->get_ascent()),
- perf_items[pi]->get_text(0),
- color,
- r.size.x);
-
- // Draw the monitor value in the top-left corner, just below the name.
- color.a = 0.9;
- perf_draw->draw_string(
- graph_font,
- r.position + Point2(0, graph_font->get_ascent() + graph_font->get_height()),
- perf_items[pi]->get_text(1),
- color,
- r.size.y);
-
- const float spacing = point_sep / float(cols);
- float from = r.size.width;
-
- const List<Vector<float>>::Element *E = perf_history.front();
- float prev = -1;
- while (from >= 0 && E) {
- float m = perf_max[pi];
- if (m == 0) {
- m = 0.00001;
- }
- float h2 = E->get()[pi] / m;
- h2 = (1.0 - h2) * r.size.y;
-
- if (E != perf_history.front()) {
- perf_draw->draw_line(
- r.position + Point2(from, h2),
- r.position + Point2(from + spacing, prev),
- color,
- Math::round(EDSCALE));
- }
- prev = h2;
- E = E->next();
- from -= spacing;
- }
- }
-}
-
void ScriptEditorDebugger::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -976,10 +837,7 @@ void ScriptEditorDebugger::start(Ref<RemoteDebuggerPeer> p_peer) {
peer = p_peer;
ERR_FAIL_COND(p_peer.is_null());
- perf_history.clear();
- for (int i = 0; i < Performance::MONITOR_MAX; i++) {
- perf_max.write[i] = 0;
- }
+ performance_profiler->reset();
set_process(true);
breaked = false;
@@ -1727,63 +1585,8 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
}
{ //monitors
-
- HSplitContainer *hsp = memnew(HSplitContainer);
-
- perf_monitors = memnew(Tree);
- perf_monitors->set_columns(2);
- perf_monitors->set_column_title(0, TTR("Monitor"));
- perf_monitors->set_column_title(1, TTR("Value"));
- perf_monitors->set_column_titles_visible(true);
- perf_monitors->connect("item_edited", callable_mp(this, &ScriptEditorDebugger::_performance_select));
- hsp->add_child(perf_monitors);
-
- perf_draw = memnew(Control);
- perf_draw->set_clip_contents(true);
- perf_draw->connect("draw", callable_mp(this, &ScriptEditorDebugger::_performance_draw));
- hsp->add_child(perf_draw);
-
- hsp->set_name(TTR("Monitors"));
- hsp->set_split_offset(340 * EDSCALE);
- tabs->add_child(hsp);
- perf_max.resize(Performance::MONITOR_MAX);
-
- Map<String, TreeItem *> bases;
- TreeItem *root = perf_monitors->create_item();
- perf_monitors->set_hide_root(true);
- for (int i = 0; i < Performance::MONITOR_MAX; i++) {
- String n = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i));
- Performance::MonitorType mtype = Performance::get_singleton()->get_monitor_type(Performance::Monitor(i));
- String base = n.get_slice("/", 0);
- String name = n.get_slice("/", 1);
- if (!bases.has(base)) {
- TreeItem *b = perf_monitors->create_item(root);
- b->set_text(0, base.capitalize());
- b->set_editable(0, false);
- b->set_selectable(0, false);
- b->set_expand_right(0, true);
- bases[base] = b;
- }
-
- TreeItem *it = perf_monitors->create_item(bases[base]);
- it->set_metadata(1, mtype);
- it->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
- it->set_editable(0, true);
- it->set_selectable(0, false);
- it->set_selectable(1, false);
- it->set_text(0, name.capitalize());
- perf_items.push_back(it);
- perf_max.write[i] = 0;
- }
-
- info_message = memnew(Label);
- info_message->set_text(TTR("Pick one or more items from the list to display the graph."));
- info_message->set_valign(Label::VALIGN_CENTER);
- info_message->set_align(Label::ALIGN_CENTER);
- info_message->set_autowrap(true);
- info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
- info_message->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
- perf_draw->add_child(info_message);
+ performance_profiler = memnew(EditorPerformanceProfiler);
+ tabs->add_child(performance_profiler);
}
{ //vmem inspect
diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h
index 2984051aa1..12fb82cc6f 100644
--- a/editor/debugger/script_editor_debugger.h
+++ b/editor/debugger/script_editor_debugger.h
@@ -52,6 +52,7 @@ class ItemList;
class EditorProfiler;
class EditorVisualProfiler;
class EditorNetworkProfiler;
+class EditorPerformanceProfiler;
class SceneDebuggerTree;
class ScriptEditorDebugger : public MarginContainer {
@@ -113,16 +114,8 @@ private:
// Each debugger should have it's tree in the future I guess.
const Tree *editor_remote_tree = nullptr;
- List<Vector<float>> perf_history;
- Vector<float> perf_max;
- Vector<TreeItem *> perf_items;
-
Map<int, String> profiler_signature;
- Tree *perf_monitors;
- Control *perf_draw;
- Label *info_message;
-
Tree *vmem_tree;
Button *vmem_refresh;
Button *vmem_export;
@@ -141,6 +134,7 @@ private:
EditorProfiler *profiler;
EditorVisualProfiler *visual_profiler;
EditorNetworkProfiler *network_profiler;
+ EditorPerformanceProfiler *performance_profiler;
EditorNode *editor;
@@ -152,8 +146,6 @@ private:
EditorDebuggerNode::CameraOverride camera_override;
- void _performance_draw();
- void _performance_select();
void _stack_dump_frame_selected();
void _file_selected(const String &p_file);
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index d88c61d7b2..9ca3d387d9 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -233,9 +233,9 @@ void EditorFileSystem::_scan_filesystem() {
FileCache fc;
fc.type = split[1];
- fc.modification_time = split[2].to_int64();
- fc.import_modification_time = split[3].to_int64();
- fc.import_valid = split[4].to_int64() != 0;
+ fc.modification_time = split[2].to_int();
+ fc.import_modification_time = split[3].to_int();
+ fc.import_valid = split[4].to_int() != 0;
fc.import_group_file = split[5].strip_edges();
fc.script_class_name = split[6].get_slice("<>", 0);
fc.script_class_extends = split[6].get_slice("<>", 1);
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp
index d2b9405552..4392538737 100644
--- a/editor/editor_help_search.cpp
+++ b/editor/editor_help_search.cpp
@@ -332,17 +332,10 @@ bool EditorHelpSearch::Runner::_phase_match_classes() {
if (search_flags & SEARCH_METHODS) {
for (int i = 0; i < class_doc.methods.size(); i++) {
String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.methods[i].name : class_doc.methods[i].name.to_lower();
- String aux_term = (search_flags & SEARCH_CASE_SENSITIVE) ? term : term.to_lower();
-
- if (aux_term.begins_with(".")) {
- aux_term = aux_term.right(1);
- }
-
- if (aux_term.ends_with("(")) {
- aux_term = aux_term.left(aux_term.length() - 1).strip_edges();
- }
-
- if (aux_term.is_subsequence_of(method_name)) {
+ if (method_name.find(term) > -1 ||
+ (term.begins_with(".") && method_name.begins_with(term.right(1))) ||
+ (term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) ||
+ (term.begins_with(".") && term.ends_with("(") && method_name == term.substr(1, term.length() - 2).strip_edges())) {
match.methods.push_back(const_cast<DocData::MethodDoc *>(&class_doc.methods[i]));
}
}
@@ -448,9 +441,9 @@ bool EditorHelpSearch::Runner::_phase_select_match() {
bool EditorHelpSearch::Runner::_match_string(const String &p_term, const String &p_string) const {
if (search_flags & SEARCH_CASE_SENSITIVE) {
- return p_term.is_subsequence_of(p_string);
+ return p_string.find(p_term) > -1;
} else {
- return p_term.is_subsequence_ofi(p_string);
+ return p_string.findn(p_term) > -1;
}
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 5da19abac3..80a1da7827 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -360,7 +360,7 @@ void EditorNode::_notification(int p_what) {
bool dof_jitter = GLOBAL_GET("rendering/quality/depth_of_field/depth_of_field_use_jitter");
RS::get_singleton()->camera_effects_set_dof_blur_quality(dof_quality, dof_jitter);
RS::get_singleton()->environment_set_ssao_quality(RS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size"));
- RS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_enable"), GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_amount"), GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_limit"));
+ RS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_enabled"), GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_amount"), GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_limit"));
bool glow_bicubic = int(GLOBAL_GET("rendering/quality/glow/upscale_mode")) > 0;
RS::get_singleton()->environment_glow_set_use_bicubic_upscale(glow_bicubic);
RS::EnvironmentSSRRoughnessQuality ssr_roughness_quality = RS::EnvironmentSSRRoughnessQuality(int(GLOBAL_GET("rendering/quality/screen_space_reflection/roughness_quality")));
@@ -435,14 +435,14 @@ void EditorNode::_notification(int p_what) {
/* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */
} break;
- case NOTIFICATION_WM_FOCUS_IN: {
+ case NOTIFICATION_APPLICATION_FOCUS_IN: {
// 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();
} break;
- case NOTIFICATION_WM_FOCUS_OUT: {
+ case NOTIFICATION_APPLICATION_FOCUS_OUT: {
// 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;
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index b5f1133a9e..fe49198e8f 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -39,7 +39,7 @@
#include "scene/gui/margin_container.h"
void EditorPluginSettings::_notification(int p_what) {
- if (p_what == NOTIFICATION_WM_FOCUS_IN) {
+ if (p_what == NOTIFICATION_WM_WINDOW_FOCUS_IN) {
update_plugins();
} else if (p_what == Node::NOTIFICATION_READY) {
plugin_config_dialog->connect_compat("plugin_ready", EditorNode::get_singleton(), "_on_plugin_ready");
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index eee610e9a8..23db6ebb4e 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -377,13 +377,13 @@ void EditorPropertyMember::_property_select() {
selector->select_method_from_base_type(hint_text, current);
} else if (hint == MEMBER_METHOD_OF_INSTANCE) {
- Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
selector->select_method_from_instance(instance, current);
}
} else if (hint == MEMBER_METHOD_OF_SCRIPT) {
- Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
selector->select_method_from_script(Object::cast_to<Script>(obj), current);
}
@@ -408,13 +408,13 @@ void EditorPropertyMember::_property_select() {
selector->select_property_from_base_type(hint_text, current);
} else if (hint == MEMBER_PROPERTY_OF_INSTANCE) {
- Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
selector->select_property_from_instance(instance, current);
}
} else if (hint == MEMBER_PROPERTY_OF_SCRIPT) {
- Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
selector->select_property_from_script(Object::cast_to<Script>(obj), current);
}
@@ -488,7 +488,7 @@ void EditorPropertyEnum::setup(const Vector<String> &p_options) {
for (int i = 0; i < p_options.size(); i++) {
Vector<String> text_split = p_options[i].split(":");
if (text_split.size() != 1) {
- current_val = text_split[1].to_int64();
+ current_val = text_split[1].to_int();
}
options->add_item(text_split[0]);
options->set_item_metadata(i, current_val);
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 7ac8fae156..d2250fed7a 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -110,7 +110,7 @@ void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Textur
uint64_t modified_time = 0;
if (p_str.begins_with("ID:")) {
- hash = uint32_t(p_str.get_slicec(':', 2).to_int64());
+ hash = uint32_t(p_str.get_slicec(':', 2).to_int());
path = "ID:" + p_str.get_slicec(':', 1);
} else {
modified_time = FileAccess::get_modified_time(path);
@@ -257,9 +257,9 @@ void EditorResourcePreview::_thread() {
_generate_preview(texture, small_texture, item, cache_base);
} else {
uint64_t modtime = FileAccess::get_modified_time(item.path);
- int tsize = f->get_line().to_int64();
+ int tsize = f->get_line().to_int();
bool has_small_texture = f->get_line().to_int();
- uint64_t last_modtime = f->get_line().to_int64();
+ uint64_t last_modtime = f->get_line().to_int();
bool cache_valid = true;
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index 67d92c4839..d76a3d2da7 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -182,8 +182,8 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) {
}
void EditorSpinSlider::_notification(int p_what) {
- if (p_what == NOTIFICATION_WM_FOCUS_OUT ||
- p_what == NOTIFICATION_WM_FOCUS_IN ||
+ if (p_what == NOTIFICATION_WM_WINDOW_FOCUS_OUT ||
+ p_what == NOTIFICATION_WM_WINDOW_FOCUS_IN ||
p_what == NOTIFICATION_EXIT_TREE) {
if (grabbing_spinner) {
grabber->hide();
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index c700fdccad..e1f55bd8a8 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -2508,10 +2508,10 @@ void FileSystemDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_tree_thumbnail_done"), &FileSystemDock::_tree_thumbnail_done);
ClassDB::bind_method(D_METHOD("_select_file"), &FileSystemDock::_select_file);
- ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &FileSystemDock::get_drag_data_fw);
- ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &FileSystemDock::can_drop_data_fw);
- ClassDB::bind_method(D_METHOD("drop_data_fw"), &FileSystemDock::drop_data_fw);
- ClassDB::bind_method(D_METHOD("navigate_to_path"), &FileSystemDock::navigate_to_path);
+ ClassDB::bind_method(D_METHOD("get_drag_data_fw", "position", "from"), &FileSystemDock::get_drag_data_fw);
+ ClassDB::bind_method(D_METHOD("can_drop_data_fw", "position", "data", "from"), &FileSystemDock::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("drop_data_fw", "position", "data", "from"), &FileSystemDock::drop_data_fw);
+ ClassDB::bind_method(D_METHOD("navigate_to_path", "path"), &FileSystemDock::navigate_to_path);
ClassDB::bind_method(D_METHOD("_update_import_dock"), &FileSystemDock::_update_import_dock);
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 96079d5418..72d287c35c 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -538,7 +538,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (current) {
if (p_save) {
- apply_scripts();
+ _menu_option(FILE_SAVE);
}
Ref<Script> script = current->get_edited_resource();
@@ -1337,7 +1337,7 @@ void ScriptEditor::_notification(int p_what) {
editor->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop));
} break;
- case NOTIFICATION_WM_FOCUS_IN: {
+ case NOTIFICATION_WM_WINDOW_FOCUS_IN: {
_test_script_times_on_disk();
_update_modified_scripts_for_external_editor();
} break;
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 0c3a44e4cd..7dd0b8a238 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -338,7 +338,7 @@ void ShaderEditor::_menu_option(int p_option) {
}
void ShaderEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_WM_FOCUS_IN) {
+ if (p_what == NOTIFICATION_WM_WINDOW_FOCUS_IN) {
_check_for_external_edit();
}
}
diff --git a/editor/plugins/shader_file_editor_plugin.cpp b/editor/plugins/shader_file_editor_plugin.cpp
index 0ac29f68f6..f15a801530 100644
--- a/editor/plugins/shader_file_editor_plugin.cpp
+++ b/editor/plugins/shader_file_editor_plugin.cpp
@@ -200,7 +200,7 @@ void ShaderFileEditor::_update_options() {
}
void ShaderFileEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_WM_FOCUS_IN) {
+ if (p_what == NOTIFICATION_WM_WINDOW_FOCUS_IN) {
if (is_visible_in_tree() && shader_file.is_valid()) {
_update_options();
}
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 3a92818779..762f42abeb 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -780,7 +780,7 @@ void TextureRegionEditor::_notification(int p_what) {
_update_autoslice();
}
} break;
- case NOTIFICATION_WM_FOCUS_IN: {
+ case NOTIFICATION_WM_WINDOW_FOCUS_IN: {
// This happens when the user leaves the Editor and returns,
// they could have changed the textures, so the cache is cleared.
cache_map.clear();
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 49b9ca167b..f4838d336f 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -597,7 +597,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_METHOD_OF_INSTANCE) {
MAKE_PROPSELECT
- Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
property_select->select_method_from_instance(instance, v);
}
@@ -607,7 +607,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_METHOD_OF_SCRIPT) {
MAKE_PROPSELECT
- Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
property_select->select_method_from_script(Object::cast_to<Script>(obj), v);
}
@@ -646,7 +646,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE) {
MAKE_PROPSELECT
- Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
property_select->select_property_from_instance(instance, v);
}
@@ -657,7 +657,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) {
MAKE_PROPSELECT
- Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
property_select->select_property_from_script(Object::cast_to<Script>(obj), v);
}
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index dd42ed9760..9831f1bd31 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -350,17 +350,22 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (!profile_allow_editing) {
break;
}
- String preferred = "";
- Node *current_edited_scene_root = EditorNode::get_singleton()->get_edited_scene();
+ // Prefer nodes that inherit from the current scene root.
+ Node *current_edited_scene_root = EditorNode::get_singleton()->get_edited_scene();
if (current_edited_scene_root) {
- if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Node2D")) {
- preferred = "Node2D";
- } else if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Node3D")) {
- preferred = "Node3D";
+ static const String preferred_types[] = { "Node2D", "Node3D", "Control" };
+
+ StringName root_class = current_edited_scene_root->get_class_name();
+
+ for (int i = 0; i < preferred_types->size(); i++) {
+ if (ClassDB::is_parent_class(root_class, preferred_types[i])) {
+ create_dialog->set_preferred_search_result_type(preferred_types[i]);
+ break;
+ }
}
}
- create_dialog->set_preferred_search_result_type(preferred);
+
create_dialog->popup_create(true);
} break;
case TOOL_INSTANCE: {
@@ -736,17 +741,28 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
_delete_confirm();
} else {
- if (remove_list.size() >= 2) {
- delete_dialog->set_text(vformat(TTR("Delete %d nodes?"), remove_list.size()));
- } else if (remove_list.size() == 1 && remove_list[0] == editor_data->get_edited_scene_root()) {
- delete_dialog->set_text(vformat(TTR("Delete the root node \"%s\"?"), remove_list[0]->get_name()));
- } else if (remove_list.size() == 1 && remove_list[0]->get_filename() == "" && remove_list[0]->get_child_count() >= 1) {
- // Display this message only for non-instanced scenes
- delete_dialog->set_text(vformat(TTR("Delete node \"%s\" and its children?"), remove_list[0]->get_name()));
+ String msg;
+ if (remove_list.size() > 1) {
+ bool any_children = false;
+ for (int i = 0; !any_children && i < remove_list.size(); i++) {
+ any_children = remove_list[i]->get_child_count() > 0;
+ }
+
+ msg = vformat(any_children ? TTR("Delete %d nodes and any children?") : TTR("Delete %d nodes?"), remove_list.size());
} else {
- delete_dialog->set_text(vformat(TTR("Delete node \"%s\"?"), remove_list[0]->get_name()));
+ Node *node = remove_list[0];
+ if (node == editor_data->get_edited_scene_root()) {
+ msg = vformat(TTR("Delete the root node \"%s\"?"), node->get_name());
+ } else if (node->get_filename() == "" && node->get_child_count() > 0) {
+ // Display this message only for non-instanced scenes
+ msg = vformat(TTR("Delete node \"%s\" and its children?"), node->get_name());
+ } else {
+ msg = vformat(TTR("Delete node \"%s\"?"), node->get_name());
+ }
}
+ delete_dialog->set_text(msg);
+
// Resize the dialog to its minimum size.
// This prevents the dialog from being too wide after displaying
// a deletion confirmation for a node with a long name.