summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_autoload_settings.cpp193
-rw-r--r--editor/editor_autoload_settings.h10
-rw-r--r--editor/editor_help.cpp22
-rw-r--r--editor/editor_help.h2
-rw-r--r--editor/editor_inspector.cpp18
-rw-r--r--editor/editor_inspector.h5
-rw-r--r--editor/editor_properties.cpp42
-rw-r--r--editor/editor_properties.h9
-rw-r--r--editor/editor_properties_array_dict.cpp999
-rw-r--r--editor/editor_properties_array_dict.h115
-rw-r--r--editor/filesystem_dock.cpp8
-rw-r--r--editor/find_in_files.cpp11
-rw-r--r--editor/icons/icon_oriented_path_follow.svg5
-rw-r--r--editor/import/editor_import_collada.cpp2
-rw-r--r--editor/import_dock.cpp1
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp17
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp3
-rw-r--r--editor/plugins/curve_editor_plugin.cpp4
-rw-r--r--editor/plugins/script_editor_plugin.cpp3
-rw-r--r--editor/project_manager.cpp17
-rw-r--r--editor/scene_tree_dock.cpp2
-rw-r--r--editor/script_editor_debugger.cpp5
22 files changed, 1392 insertions, 101 deletions
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index 708bff252a..de9203232c 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -52,6 +52,13 @@ void EditorAutoloadSettings::_notification(int p_what) {
file_dialog->add_filter("*." + E->get());
}
+
+ for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) {
+ AutoLoadInfo &info = E->get();
+ if (info.node && info.in_editor) {
+ get_tree()->get_root()->call_deferred("add_child", info.node);
+ }
+ }
}
}
@@ -291,6 +298,36 @@ void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) {
autoload_add_name->set_text(p_path.get_file().get_basename());
}
+Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
+ RES res = ResourceLoader::load(p_path);
+ ERR_EXPLAIN("Can't autoload: " + p_path);
+ ERR_FAIL_COND_V(res.is_null(), NULL);
+ Node *n = NULL;
+ if (res->is_class("PackedScene")) {
+ Ref<PackedScene> ps = res;
+ n = ps->instance();
+ } else if (res->is_class("Script")) {
+ Ref<Script> s = res;
+ StringName ibt = s->get_instance_base_type();
+ bool valid_type = ClassDB::is_parent_class(ibt, "Node");
+ ERR_EXPLAIN("Script does not inherit a Node: " + p_path);
+ ERR_FAIL_COND_V(!valid_type, NULL);
+
+ Object *obj = ClassDB::instance(ibt);
+
+ ERR_EXPLAIN("Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt));
+ ERR_FAIL_COND_V(obj == NULL, NULL);
+
+ n = Object::cast_to<Node>(obj);
+ n->set_script(s.get_ref_ptr());
+ }
+
+ ERR_EXPLAIN("Path in autoload not a node or script: " + p_path);
+ ERR_FAIL_COND_V(!n, NULL);
+
+ return n;
+}
+
void EditorAutoloadSettings::update_autoload() {
if (updating_autoload)
@@ -299,15 +336,11 @@ void EditorAutoloadSettings::update_autoload() {
updating_autoload = true;
Map<String, AutoLoadInfo> to_remove;
- Map<String, AutoLoadInfo> to_remove_singleton;
- List<AutoLoadInfo> to_add;
- List<String> to_add_singleton; // Only for when the node is still the same
+ List<AutoLoadInfo *> to_add;
for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) {
- to_remove.insert(E->get().name, E->get());
- if (E->get().is_singleton) {
- to_remove_singleton.insert(E->get().name, E->get());
- }
+ AutoLoadInfo &info = E->get();
+ to_remove.insert(info.name, info);
}
autoload_cache.clear();
@@ -331,11 +364,6 @@ void EditorAutoloadSettings::update_autoload() {
if (name.empty())
continue;
- AutoLoadInfo old_info;
- if (to_remove.has(name)) {
- old_info = to_remove[name];
- }
-
AutoLoadInfo info;
info.is_singleton = path.begins_with("*");
@@ -347,28 +375,31 @@ void EditorAutoloadSettings::update_autoload() {
info.path = path;
info.order = ProjectSettings::get_singleton()->get_order(pi.name);
- if (old_info.name == info.name) {
+ bool need_to_add = true;
+ if (to_remove.has(name)) {
+ AutoLoadInfo &old_info = to_remove[name];
if (old_info.path == info.path) {
- // Still the same resource, check singleton status
- to_remove.erase(name);
- if (info.is_singleton) {
- if (old_info.is_singleton) {
- to_remove_singleton.erase(name);
+ // Still the same resource, check status
+ info.node = old_info.node;
+ if (info.node) {
+ Ref<Script> scr = info.node->get_script();
+ info.in_editor = scr.is_valid() && scr->is_tool();
+ if (info.is_singleton == old_info.is_singleton && info.in_editor == old_info.in_editor) {
+ to_remove.erase(name);
+ need_to_add = false;
} else {
- to_add_singleton.push_back(name);
+ info.node = NULL;
}
}
- } else {
- // Resource changed
- to_add.push_back(info);
}
- } else {
- // New autoload
- to_add.push_back(info);
}
autoload_cache.push_back(info);
+ if (need_to_add) {
+ to_add.push_back(&(autoload_cache.back()->get()));
+ }
+
TreeItem *item = tree->create_item(root);
item->set_text(0, name);
item->set_editable(0, true);
@@ -387,71 +418,54 @@ void EditorAutoloadSettings::update_autoload() {
item->set_selectable(3, false);
}
- // Remove autoload constants
- for (Map<String, AutoLoadInfo>::Element *E = to_remove_singleton.front(); E; E = E->next()) {
- for (int i = 0; i < ScriptServer::get_language_count(); i++) {
- ScriptServer::get_language(i)->remove_named_global_constant(E->get().name);
- }
- }
-
- // Remove obsolete nodes from the tree
+ // Remove deleted/changed autoloads
for (Map<String, AutoLoadInfo>::Element *E = to_remove.front(); E; E = E->next()) {
AutoLoadInfo &info = E->get();
- Node *al = get_node("/root/" + info.name);
- ERR_CONTINUE(!al);
- get_tree()->get_root()->remove_child(al);
- memdelete(al);
- }
+ if (info.is_singleton) {
+ for (int i = 0; i < ScriptServer::get_language_count(); i++) {
+ ScriptServer::get_language(i)->remove_named_global_constant(info.name);
+ }
+ }
+ if (info.in_editor) {
+ ERR_CONTINUE(!info.node);
+ get_tree()->get_root()->remove_child(info.node);
+ }
- // Register new singletons already in the tree
- for (List<String>::Element *E = to_add_singleton.front(); E; E = E->next()) {
- Node *al = get_node("/root/" + E->get());
- ERR_CONTINUE(!al);
- for (int i = 0; i < ScriptServer::get_language_count(); i++) {
- ScriptServer::get_language(i)->add_named_global_constant(E->get(), al);
+ if (info.node) {
+ memdelete(info.node);
+ info.node = NULL;
}
}
- // Add new nodes to the tree
+ // Load new/changed autoloads
List<Node *> nodes_to_add;
- for (List<AutoLoadInfo>::Element *E = to_add.front(); E; E = E->next()) {
- AutoLoadInfo &info = E->get();
+ for (List<AutoLoadInfo *>::Element *E = to_add.front(); E; E = E->next()) {
+ AutoLoadInfo *info = E->get();
- RES res = ResourceLoader::load(info.path);
- ERR_EXPLAIN("Can't autoload: " + info.path);
- ERR_CONTINUE(res.is_null());
- Node *n = NULL;
- if (res->is_class("PackedScene")) {
- Ref<PackedScene> ps = res;
- n = ps->instance();
- } else if (res->is_class("Script")) {
- Ref<Script> s = res;
- StringName ibt = s->get_instance_base_type();
- bool valid_type = ClassDB::is_parent_class(ibt, "Node");
- ERR_EXPLAIN("Script does not inherit a Node: " + info.path);
- ERR_CONTINUE(!valid_type);
-
- Object *obj = ClassDB::instance(ibt);
-
- ERR_EXPLAIN("Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt));
- ERR_CONTINUE(obj == NULL);
-
- n = Object::cast_to<Node>(obj);
- n->set_script(s.get_ref_ptr());
- }
+ info->node = _create_autoload(info->path);
- ERR_EXPLAIN("Path in autoload not a node or script: " + info.path);
- ERR_CONTINUE(!n);
- n->set_name(info.name);
+ ERR_CONTINUE(!info->node);
+ info->node->set_name(info->name);
- //defer so references are all valid on _ready()
- nodes_to_add.push_back(n);
+ Ref<Script> scr = info->node->get_script();
+ info->in_editor = scr.is_valid() && scr->is_tool();
- if (info.is_singleton) {
+ if (info->in_editor) {
+ //defer so references are all valid on _ready()
+ nodes_to_add.push_back(info->node);
+ }
+
+ if (info->is_singleton) {
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
- ScriptServer::get_language(i)->add_named_global_constant(info.name, n);
+ ScriptServer::get_language(i)->add_named_global_constant(info->name, info->node);
}
}
+
+ if (!info->in_editor && !info->is_singleton) {
+ // No reason to keep this node
+ memdelete(info->node);
+ info->node = NULL;
+ }
}
for (List<Node *>::Element *E = nodes_to_add.front(); E; E = E->next()) {
@@ -728,6 +742,24 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
info.name = name;
info.path = path;
info.order = ProjectSettings::get_singleton()->get_order(pi.name);
+ info.node = _create_autoload(path);
+
+ if (info.node) {
+ Ref<Script> scr = info.node->get_script();
+ info.in_editor = scr.is_valid() && scr->is_tool();
+ info.node->set_name(info.name);
+ }
+
+ if (info.is_singleton) {
+ for (int i = 0; i < ScriptServer::get_language_count(); i++) {
+ ScriptServer::get_language(i)->add_named_global_constant(info.name, info.node);
+ }
+ }
+
+ if (!info.is_singleton && !info.in_editor) {
+ memdelete(info.node);
+ info.node = NULL;
+ }
autoload_cache.push_back(info);
}
@@ -796,3 +828,12 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
add_child(tree, true);
}
+
+EditorAutoloadSettings::~EditorAutoloadSettings() {
+ for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) {
+ AutoLoadInfo &info = E->get();
+ if (info.node && !info.in_editor) {
+ memdelete(info.node);
+ }
+ }
+}
diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h
index 1797c10e61..0b75faa009 100644
--- a/editor/editor_autoload_settings.h
+++ b/editor/editor_autoload_settings.h
@@ -52,11 +52,19 @@ class EditorAutoloadSettings : public VBoxContainer {
String name;
String path;
bool is_singleton;
+ bool in_editor;
int order;
+ Node *node;
bool operator==(const AutoLoadInfo &p_info) {
return order == p_info.order;
}
+
+ AutoLoadInfo() {
+ is_singleton = false;
+ in_editor = false;
+ node = NULL;
+ }
};
List<AutoLoadInfo> autoload_cache;
@@ -78,6 +86,7 @@ class EditorAutoloadSettings : public VBoxContainer {
void _autoload_activated();
void _autoload_open(const String &fpath);
void _autoload_file_callback(const String &p_path);
+ Node *_create_autoload(const String &p_path);
Variant get_drag_data_fw(const Point2 &p_point, Control *p_control);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) const;
@@ -93,6 +102,7 @@ public:
void autoload_remove(const String &p_name);
EditorAutoloadSettings();
+ ~EditorAutoloadSettings();
};
#endif
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index f9b104cdae..b49c2d26d0 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -1978,8 +1978,27 @@ FindBar::FindBar() {
}
void FindBar::popup_search() {
+
show();
- search_text->grab_focus();
+ bool grabbed_focus = false;
+ if (!search_text->has_focus()) {
+ search_text->grab_focus();
+ grabbed_focus = true;
+ }
+
+ if (!search_text->get_text().empty()) {
+ search_text->select_all();
+ search_text->set_cursor_position(search_text->get_text().length());
+ if (grabbed_focus) {
+ _search();
+ }
+ }
+
+ call_deferred("_update_size");
+}
+
+void FindBar::_update_size() {
+
container->set_custom_minimum_size(Size2(0, hbc->get_size().height));
}
@@ -2016,6 +2035,7 @@ void FindBar::_bind_methods() {
ClassDB::bind_method("_search_next", &FindBar::search_next);
ClassDB::bind_method("_search_prev", &FindBar::search_prev);
ClassDB::bind_method("_hide_pressed", &FindBar::_hide_bar);
+ ClassDB::bind_method("_update_size", &FindBar::_update_size);
ADD_SIGNAL(MethodInfo("search"));
}
diff --git a/editor/editor_help.h b/editor/editor_help.h
index 35d98d274c..514169dc19 100644
--- a/editor/editor_help.h
+++ b/editor/editor_help.h
@@ -148,6 +148,8 @@ class FindBar : public HBoxContainer {
void _search_text_changed(const String &p_text);
void _search_text_entered(const String &p_text);
+ void _update_size();
+
protected:
void _notification(int p_what);
void _unhandled_input(const Ref<InputEvent> &p_event);
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index c2d2f7ddcc..f94b7cd6ee 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -520,6 +520,8 @@ bool EditorProperty::is_draw_red() const {
void EditorProperty::_focusable_focused(int p_index) {
+ if (!selectable)
+ return;
bool already_selected = selected;
selected = true;
selected_focusable = p_index;
@@ -596,7 +598,7 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
- if (!selected) {
+ if (!selected && selectable) {
selected = true;
emit_signal("selected", property, -1);
update();
@@ -681,6 +683,19 @@ void EditorProperty::expand_all_folding() {
void EditorProperty::collapse_all_folding() {
}
+void EditorProperty::set_selectable(bool p_selectable) {
+ selectable = p_selectable;
+}
+
+bool EditorProperty::is_selectable() const {
+ return selectable;
+}
+
+void EditorProperty::set_object_and_property(Object *p_object, const StringName &p_property) {
+ object = p_object;
+ property = p_property;
+}
+
void EditorProperty::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_label", "text"), &EditorProperty::set_label);
@@ -729,6 +744,7 @@ void EditorProperty::_bind_methods() {
EditorProperty::EditorProperty() {
+ selectable = true;
text_size = 0;
read_only = false;
checkable = false;
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index 14387c46df..a6b183799f 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -72,6 +72,7 @@ private:
bool _get_instanced_node_original_property(const StringName &p_prop, Variant &value);
void _focusable_focused(int p_index);
+ bool selectable;
bool selected;
int selected_focusable;
@@ -130,6 +131,10 @@ public:
virtual Variant get_drag_data(const Point2 &p_point);
+ void set_selectable(bool p_selectable);
+ bool is_selectable() const;
+
+ void set_object_and_property(Object *p_object, const StringName &p_property);
EditorProperty();
};
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 812e461a14..c6d3a43f4e 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -31,7 +31,20 @@
#include "editor_properties.h"
#include "editor/editor_resource_preview.h"
#include "editor_node.h"
+#include "editor_properties_array_dict.h"
#include "scene/main/viewport.h"
+
+///////////////////// NULL /////////////////////////
+
+void EditorPropertyNil::update_property() {
+}
+
+EditorPropertyNil::EditorPropertyNil() {
+ Label *label = memnew(Label);
+ label->set_text("[null]");
+ add_child(label);
+}
+
///////////////////// TEXT /////////////////////////
void EditorPropertyText::_text_changed(const String &p_string) {
if (updating)
@@ -487,7 +500,7 @@ public:
virtual String get_tooltip(const Point2 &p_pos) const {
for (int i = 0; i < flag_rects.size(); i++) {
- if (flag_rects[i].has_point(p_pos) && i < names.size()) {
+ if (i < names.size() && flag_rects[i].has_point(p_pos)) {
return names[i];
}
}
@@ -1509,7 +1522,8 @@ EditorPropertyColor::EditorPropertyColor() {
void EditorPropertyNodePath::_node_selected(const NodePath &p_path) {
- emit_signal("property_changed", get_edited_property(), p_path);
+ Node *base_node = Object::cast_to<Node>(get_edited_object());
+ emit_signal("property_changed", get_edited_property(), base_node->get_path().rel_path_to(p_path));
update_property();
}
@@ -2273,6 +2287,10 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
switch (p_type) {
// atomic types
+ case Variant::NIL: {
+ EditorPropertyNil *editor = memnew(EditorPropertyNil);
+ add_property_editor(p_path, editor);
+ } break;
case Variant::BOOL: {
EditorPropertyCheck *editor = memnew(EditorPropertyCheck);
add_property_editor(p_path, editor);
@@ -2631,24 +2649,40 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} break;
case Variant::DICTIONARY: {
+ EditorPropertyDictionary *editor = memnew(EditorPropertyDictionary);
+ add_property_editor(p_path, editor);
} break;
case Variant::ARRAY: {
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ add_property_editor(p_path, editor);
} break;
-
- // arrays
case Variant::POOL_BYTE_ARRAY: {
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ add_property_editor(p_path, editor);
} break; // 20
case Variant::POOL_INT_ARRAY: {
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ add_property_editor(p_path, editor);
} break;
case Variant::POOL_REAL_ARRAY: {
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ add_property_editor(p_path, editor);
} break;
case Variant::POOL_STRING_ARRAY: {
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ add_property_editor(p_path, editor);
} break;
case Variant::POOL_VECTOR2_ARRAY: {
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ add_property_editor(p_path, editor);
} break;
case Variant::POOL_VECTOR3_ARRAY: {
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ add_property_editor(p_path, editor);
} break; // 25
case Variant::POOL_COLOR_ARRAY: {
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ add_property_editor(p_path, editor);
} break;
default: {}
}
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index 19884cc9dc..03e72b4ec2 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -39,6 +39,15 @@
#include "editor/scene_tree_editor.h"
#include "scene/gui/color_picker.h"
+class EditorPropertyNil : public EditorProperty {
+ GDCLASS(EditorPropertyNil, EditorProperty)
+ LineEdit *text;
+
+public:
+ virtual void update_property();
+ EditorPropertyNil();
+};
+
class EditorPropertyText : public EditorProperty {
GDCLASS(EditorPropertyText, EditorProperty)
LineEdit *text;
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
new file mode 100644
index 0000000000..90f8d0e157
--- /dev/null
+++ b/editor/editor_properties_array_dict.cpp
@@ -0,0 +1,999 @@
+#include "editor_properties_array_dict.h"
+#include "editor/editor_scale.h"
+#include "editor_properties.h"
+
+bool EditorPropertyArrayObject::_set(const StringName &p_name, const Variant &p_value) {
+
+ String pn = p_name;
+
+ if (pn.begins_with("indices")) {
+ int idx = pn.get_slicec('/', 1).to_int();
+ array.set(idx, p_value);
+ return true;
+ }
+
+ return false;
+}
+
+bool EditorPropertyArrayObject::_get(const StringName &p_name, Variant &r_ret) const {
+
+ String pn = p_name;
+
+ if (pn.begins_with("indices")) {
+
+ int idx = pn.get_slicec('/', 1).to_int();
+ bool valid;
+ r_ret = array.get(idx, &valid);
+ return valid;
+ }
+
+ return false;
+}
+
+void EditorPropertyArrayObject::set_array(const Variant &p_array) {
+ array = p_array;
+}
+
+Variant EditorPropertyArrayObject::get_array() {
+ return array;
+}
+
+EditorPropertyArrayObject::EditorPropertyArrayObject() {
+}
+
+///////////////////
+
+bool EditorPropertyDictionaryObject::_set(const StringName &p_name, const Variant &p_value) {
+
+ String pn = p_name;
+
+ if (pn == "new_item_key") {
+
+ new_item_key = p_value;
+ return true;
+ }
+
+ if (pn == "new_item_value") {
+
+ new_item_value = p_value;
+ return true;
+ }
+
+ if (pn.begins_with("indices")) {
+ int idx = pn.get_slicec('/', 1).to_int();
+ Variant key = dict.get_key_at_index(idx);
+ dict[key] = p_value;
+ return true;
+ }
+
+ return false;
+}
+
+bool EditorPropertyDictionaryObject::_get(const StringName &p_name, Variant &r_ret) const {
+
+ String pn = p_name;
+
+ if (pn == "new_item_key") {
+
+ r_ret = new_item_key;
+ return true;
+ }
+
+ if (pn == "new_item_value") {
+
+ r_ret = new_item_value;
+ return true;
+ }
+
+ if (pn.begins_with("indices")) {
+
+ int idx = pn.get_slicec('/', 1).to_int();
+ Variant key = dict.get_key_at_index(idx);
+ r_ret = dict[key];
+ return true;
+ }
+
+ return false;
+}
+
+void EditorPropertyDictionaryObject::set_dict(const Dictionary &p_dict) {
+ dict = p_dict;
+}
+
+Dictionary EditorPropertyDictionaryObject::get_dict() {
+ return dict;
+}
+
+void EditorPropertyDictionaryObject::set_new_item_key(const Variant &p_new_item) {
+ new_item_key = p_new_item;
+}
+
+Variant EditorPropertyDictionaryObject::get_new_item_key() {
+ return new_item_key;
+}
+
+void EditorPropertyDictionaryObject::set_new_item_value(const Variant &p_new_item) {
+ new_item_value = p_new_item;
+}
+
+Variant EditorPropertyDictionaryObject::get_new_item_value() {
+ return new_item_value;
+}
+
+EditorPropertyDictionaryObject::EditorPropertyDictionaryObject() {
+}
+
+///////////////////// ARRAY ///////////////////////////
+
+void EditorPropertyArray::_property_changed(const String &p_prop, Variant p_value) {
+
+ if (p_prop.begins_with("indices")) {
+ int idx = p_prop.get_slice("/", 1).to_int();
+ Variant array = object->get_array();
+ array.set(idx, p_value);
+ emit_signal("property_changed", get_edited_property(), array);
+
+ if (array.get_type() == Variant::ARRAY) {
+ array = array.call("duplicate"); //dupe, so undo/redo works better
+ }
+ object->set_array(array);
+ }
+}
+
+void EditorPropertyArray::_change_type(Object *p_button, int p_index) {
+
+ Button *button = Object::cast_to<Button>(p_button);
+
+ Rect2 rect = button->get_global_rect();
+ change_type->set_as_minsize();
+ change_type->set_global_position(rect.position + rect.size - Vector2(change_type->get_combined_minimum_size().x, 0));
+ change_type->popup();
+ changing_type_idx = p_index;
+}
+
+void EditorPropertyArray::_change_type_menu(int p_index) {
+
+ Variant value;
+ Variant::CallError ce;
+ value = Variant::construct(Variant::Type(p_index), NULL, 0, ce);
+ Variant array = object->get_array();
+ array.set(changing_type_idx, value);
+
+ emit_signal("property_changed", get_edited_property(), array);
+
+ if (array.get_type() == Variant::ARRAY) {
+ array = array.call("duplicate"); //dupe, so undo/redo works better
+ }
+ object->set_array(array);
+ update_property();
+}
+
+void EditorPropertyArray::update_property() {
+
+ Variant array = get_edited_object()->get(get_edited_property());
+
+ if ((!array.is_array()) != edit->is_disabled()) {
+
+ if (array.is_array()) {
+ edit->set_disabled(false);
+ edit->set_pressed(false);
+
+ } else {
+ edit->set_disabled(true);
+ if (vbox) {
+ memdelete(vbox);
+ }
+ }
+ }
+
+ if (!array.is_array()) {
+ return;
+ }
+
+ String arrtype;
+ switch (array.get_type()) {
+ case Variant::ARRAY: {
+
+ arrtype = "Array";
+
+ } break;
+
+ // arrays
+ case Variant::POOL_BYTE_ARRAY: {
+ arrtype = "ByteArray";
+
+ } break;
+ case Variant::POOL_INT_ARRAY: {
+ arrtype = "IntArray";
+
+ } break;
+ case Variant::POOL_REAL_ARRAY: {
+
+ arrtype = "FltArray";
+ } break;
+ case Variant::POOL_STRING_ARRAY: {
+
+ arrtype = "StrArray";
+ } break;
+ case Variant::POOL_VECTOR2_ARRAY: {
+
+ arrtype = "Vec2Array";
+ } break;
+ case Variant::POOL_VECTOR3_ARRAY: {
+ arrtype = "Vec3Array";
+
+ } break;
+ case Variant::POOL_COLOR_ARRAY: {
+ arrtype = "ColArray";
+ } break;
+ default: {}
+ }
+
+ edit->set_text(arrtype + "[" + itos(array.call("size")) + "]");
+
+#ifdef TOOLS_ENABLED
+
+ bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property());
+ if (edit->is_pressed() != unfolded) {
+ edit->set_pressed(unfolded);
+ }
+
+ if (unfolded) {
+
+ updating = true;
+
+ if (!vbox) {
+
+ vbox = memnew(VBoxContainer);
+ add_child(vbox);
+ set_bottom_editor(vbox);
+ HBoxContainer *hbc = memnew(HBoxContainer);
+ vbox->add_child(hbc);
+ Label *label = memnew(Label(TTR("Size: ")));
+ label->set_h_size_flags(SIZE_EXPAND_FILL);
+ hbc->add_child(label);
+ length = memnew(EditorSpinSlider);
+ length->set_step(1);
+ length->set_max(1000000);
+ length->set_h_size_flags(SIZE_EXPAND_FILL);
+ hbc->add_child(length);
+ length->connect("value_changed", this, "_length_changed");
+
+ page_hb = memnew(HBoxContainer);
+ vbox->add_child(page_hb);
+ label = memnew(Label(TTR("Page: ")));
+ label->set_h_size_flags(SIZE_EXPAND_FILL);
+ page_hb->add_child(label);
+ page = memnew(EditorSpinSlider);
+ page->set_step(1);
+ page_hb->add_child(page);
+ page->set_h_size_flags(SIZE_EXPAND_FILL);
+ page->connect("value_changed", this, "_page_changed");
+ } else {
+ //bye bye children of the box
+ while (vbox->get_child_count() > 2) {
+ memdelete(vbox->get_child(2));
+ }
+ }
+
+ int len = array.call("size");
+
+ length->set_value(len);
+
+ int pages = MAX(0, len - 1) / page_len + 1;
+
+ page->set_max(pages);
+ page_idx = MIN(page_idx, pages - 1);
+ page->set_value(page_idx);
+ page_hb->set_visible(pages > 1);
+
+ int offset = page_idx * page_len;
+
+ int amount = MIN(len - offset, page_len);
+
+ if (array.get_type() == Variant::ARRAY) {
+ array = array.call("duplicate");
+ }
+
+ object->set_array(array);
+
+ for (int i = 0; i < amount; i++) {
+ String prop_name = "indices/" + itos(i + offset);
+
+ EditorProperty *prop = NULL;
+ Variant value = array.get(i + offset);
+
+ switch (value.get_type()) {
+ case Variant::NIL: {
+ prop = memnew(EditorPropertyNil);
+
+ } break;
+
+ // atomic types
+ case Variant::BOOL: {
+
+ prop = memnew(EditorPropertyCheck);
+
+ } break;
+ case Variant::INT: {
+ EditorPropertyInteger *ed = memnew(EditorPropertyInteger);
+ ed->setup(-100000, 100000, true, true);
+ prop = ed;
+
+ } break;
+ case Variant::REAL: {
+
+ EditorPropertyFloat *ed = memnew(EditorPropertyFloat);
+ ed->setup(-100000, 100000, 0.001, true, false, true, true);
+ prop = ed;
+ } break;
+ case Variant::STRING: {
+
+ prop = memnew(EditorPropertyText);
+
+ } break;
+
+ // math types
+
+ case Variant::VECTOR2: {
+
+ EditorPropertyVector2 *ed = memnew(EditorPropertyVector2);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::RECT2: {
+
+ EditorPropertyRect2 *ed = memnew(EditorPropertyRect2);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::VECTOR3: {
+
+ EditorPropertyVector3 *ed = memnew(EditorPropertyVector3);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::TRANSFORM2D: {
+
+ EditorPropertyTransform2D *ed = memnew(EditorPropertyTransform2D);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::PLANE: {
+
+ EditorPropertyPlane *ed = memnew(EditorPropertyPlane);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::QUAT: {
+
+ EditorPropertyQuat *ed = memnew(EditorPropertyQuat);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::AABB: {
+
+ EditorPropertyAABB *ed = memnew(EditorPropertyAABB);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::BASIS: {
+ EditorPropertyBasis *ed = memnew(EditorPropertyBasis);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::TRANSFORM: {
+ EditorPropertyTransform *ed = memnew(EditorPropertyTransform);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+
+ // misc types
+ case Variant::COLOR: {
+ prop = memnew(EditorPropertyColor);
+
+ } break;
+ case Variant::NODE_PATH: {
+ prop = memnew(EditorPropertyNodePath);
+
+ } break;
+ case Variant::_RID: {
+ prop = memnew(EditorPropertyNil);
+
+ } break;
+ case Variant::OBJECT: {
+
+ prop = memnew(EditorPropertyResource);
+
+ } break;
+ case Variant::DICTIONARY: {
+ prop = memnew(EditorPropertyDictionary);
+
+ } break;
+ case Variant::ARRAY: {
+
+ prop = memnew(EditorPropertyArray);
+
+ } break;
+
+ // arrays
+ case Variant::POOL_BYTE_ARRAY: {
+ prop = memnew(EditorPropertyArray);
+
+ } break;
+ case Variant::POOL_INT_ARRAY: {
+ prop = memnew(EditorPropertyArray);
+
+ } break;
+ case Variant::POOL_REAL_ARRAY: {
+
+ prop = memnew(EditorPropertyArray);
+ } break;
+ case Variant::POOL_STRING_ARRAY: {
+
+ prop = memnew(EditorPropertyArray);
+ } break;
+ case Variant::POOL_VECTOR2_ARRAY: {
+
+ prop = memnew(EditorPropertyArray);
+ } break;
+ case Variant::POOL_VECTOR3_ARRAY: {
+ prop = memnew(EditorPropertyArray);
+
+ } break;
+ case Variant::POOL_COLOR_ARRAY: {
+ prop = memnew(EditorPropertyArray);
+
+ } break;
+ default: {}
+ }
+
+ prop->set_object_and_property(object.ptr(), prop_name);
+ prop->set_label(itos(i + offset));
+ prop->set_selectable(false);
+ prop->connect("property_changed", this, "_property_changed");
+ if (array.get_type() == Variant::ARRAY) {
+ HBoxContainer *hb = memnew(HBoxContainer);
+ vbox->add_child(hb);
+ hb->add_child(prop);
+ prop->set_h_size_flags(SIZE_EXPAND_FILL);
+ Button *edit = memnew(Button);
+ edit->set_icon(get_icon("Edit", "EditorIcons"));
+ hb->add_child(edit);
+ edit->connect("pressed", this, "_change_type", varray(edit, i + offset));
+ } else {
+ vbox->add_child(prop);
+ }
+
+ prop->update_property();
+ }
+
+ updating = false;
+
+ } else {
+ if (vbox) {
+ set_bottom_editor(NULL);
+ memdelete(vbox);
+ vbox = NULL;
+ }
+ }
+#endif
+}
+
+void EditorPropertyArray::_notification(int p_what) {
+
+ if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
+ }
+}
+void EditorPropertyArray::_edit_pressed() {
+
+ get_edited_object()->editor_set_section_unfold(get_edited_property(), edit->is_pressed());
+ update_property();
+}
+
+void EditorPropertyArray::_page_changed(double p_page) {
+ if (updating)
+ return;
+ page_idx = p_page;
+ update_property();
+}
+
+void EditorPropertyArray::_length_changed(double p_page) {
+ if (updating)
+ return;
+
+ Variant array = object->get_array();
+ array.call("resize", int(p_page));
+ emit_signal("property_changed", get_edited_property(), array);
+
+ if (array.get_type() == Variant::ARRAY) {
+ array = array.call("duplicate"); //dupe, so undo/redo works better
+ }
+ object->set_array(array);
+ update_property();
+}
+
+void EditorPropertyArray::_bind_methods() {
+ ClassDB::bind_method("_edit_pressed", &EditorPropertyArray::_edit_pressed);
+ ClassDB::bind_method("_page_changed", &EditorPropertyArray::_page_changed);
+ ClassDB::bind_method("_length_changed", &EditorPropertyArray::_length_changed);
+ ClassDB::bind_method("_property_changed", &EditorPropertyArray::_property_changed);
+ ClassDB::bind_method("_change_type", &EditorPropertyArray::_change_type);
+ ClassDB::bind_method("_change_type_menu", &EditorPropertyArray::_change_type_menu);
+}
+
+EditorPropertyArray::EditorPropertyArray() {
+
+ object.instance();
+ page_idx = 0;
+ page_len = 10;
+ edit = memnew(Button);
+ edit->set_flat(true);
+ edit->set_h_size_flags(SIZE_EXPAND_FILL);
+ edit->set_clip_text(true);
+ edit->connect("pressed", this, "_edit_pressed");
+ edit->set_toggle_mode(true);
+ add_child(edit);
+ add_focusable(edit);
+ vbox = NULL;
+ page = NULL;
+ length = NULL;
+ updating = false;
+ change_type = memnew(PopupMenu);
+ add_child(change_type);
+ change_type->connect("id_pressed", this, "_change_type_menu");
+ changing_type_idx = -1;
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
+ String type = Variant::get_type_name(Variant::Type(i));
+ change_type->add_item(type, i);
+ }
+ changing_type_idx = -1;
+}
+
+///////////////////// DICTIONARY ///////////////////////////
+
+void EditorPropertyDictionary::_property_changed(const String &p_prop, Variant p_value) {
+
+ if (p_prop == "new_item_key") {
+
+ object->set_new_item_key(p_value);
+ } else if (p_prop == "new_item_value") {
+
+ object->set_new_item_value(p_value);
+ } else if (p_prop.begins_with("indices")) {
+ int idx = p_prop.get_slice("/", 1).to_int();
+ Dictionary dict = object->get_dict();
+ Variant key = dict.get_key_at_index(idx);
+ dict[key] = p_value;
+
+ emit_signal("property_changed", get_edited_property(), dict);
+
+ dict = dict.duplicate(); //dupe, so undo/redo works better
+ object->set_dict(dict);
+ }
+}
+
+void EditorPropertyDictionary::_change_type(Object *p_button, int p_index) {
+
+ Button *button = Object::cast_to<Button>(p_button);
+
+ Rect2 rect = button->get_global_rect();
+ change_type->set_as_minsize();
+ change_type->set_global_position(rect.position + rect.size - Vector2(change_type->get_combined_minimum_size().x, 0));
+ change_type->popup();
+ changing_type_idx = p_index;
+}
+
+void EditorPropertyDictionary::_add_key_value() {
+
+ Dictionary dict = object->get_dict();
+ dict[object->get_new_item_key()] = object->get_new_item_value();
+ object->set_new_item_key(Variant());
+ object->set_new_item_value(Variant());
+
+ emit_signal("property_changed", get_edited_property(), dict);
+
+ dict = dict.duplicate(); //dupe, so undo/redo works better
+ object->set_dict(dict);
+ update_property();
+}
+
+void EditorPropertyDictionary::_change_type_menu(int p_index) {
+
+ if (changing_type_idx < 0) {
+ Variant value;
+ Variant::CallError ce;
+ value = Variant::construct(Variant::Type(p_index), NULL, 0, ce);
+ if (changing_type_idx == -1) {
+ object->set_new_item_key(value);
+ } else {
+ object->set_new_item_value(value);
+ }
+ update_property();
+ return;
+ }
+
+ Dictionary dict = object->get_dict();
+
+ if (p_index < Variant::VARIANT_MAX) {
+
+ Variant value;
+ Variant::CallError ce;
+ value = Variant::construct(Variant::Type(p_index), NULL, 0, ce);
+ Variant key = dict.get_key_at_index(changing_type_idx);
+ dict[key] = value;
+ } else {
+ Variant key = dict.get_key_at_index(changing_type_idx);
+ dict.erase(key);
+ }
+
+ emit_signal("property_changed", get_edited_property(), dict);
+
+ dict = dict.duplicate(); //dupe, so undo/redo works better
+ object->set_dict(dict);
+ update_property();
+}
+
+void EditorPropertyDictionary::update_property() {
+
+ Dictionary dict = get_edited_object()->get(get_edited_property());
+
+ edit->set_text("Dict[" + itos(dict.size()) + "]");
+
+#ifdef TOOLS_ENABLED
+
+ bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property());
+ if (edit->is_pressed() != unfolded) {
+ edit->set_pressed(unfolded);
+ }
+
+ if (unfolded) {
+
+ updating = true;
+
+ if (!vbox) {
+
+ vbox = memnew(VBoxContainer);
+ add_child(vbox);
+ set_bottom_editor(vbox);
+
+ page_hb = memnew(HBoxContainer);
+ vbox->add_child(page_hb);
+ Label *label = memnew(Label(TTR("Page: ")));
+ label->set_h_size_flags(SIZE_EXPAND_FILL);
+ page_hb->add_child(label);
+ page = memnew(EditorSpinSlider);
+ page->set_step(1);
+ page_hb->add_child(page);
+ page->set_h_size_flags(SIZE_EXPAND_FILL);
+ page->connect("value_changed", this, "_page_changed");
+ } else {
+ //bye bye children of the box
+ while (vbox->get_child_count() > 1) {
+ memdelete(vbox->get_child(1));
+ }
+ }
+
+ int len = dict.size();
+
+ int pages = MAX(0, len - 1) / page_len + 1;
+
+ page->set_max(pages);
+ page_idx = MIN(page_idx, pages - 1);
+ page->set_value(page_idx);
+ page_hb->set_visible(pages > 1);
+
+ int offset = page_idx * page_len;
+
+ int amount = MIN(len - offset, page_len);
+
+ dict = dict.duplicate();
+
+ object->set_dict(dict);
+ VBoxContainer *add_vbox = NULL;
+
+ for (int i = 0; i < amount + 2; i++) {
+ String prop_name;
+ Variant key;
+ Variant value;
+
+ if (i < amount) {
+ prop_name = "indices/" + itos(i + offset);
+ key = dict.get_key_at_index(i + offset);
+ value = dict.get_value_at_index(i + offset);
+ } else if (i == amount) {
+ prop_name = "new_item_key";
+ value = object->get_new_item_key();
+ } else if (i == amount + 1) {
+ prop_name = "new_item_value";
+ value = object->get_new_item_value();
+ }
+
+ EditorProperty *prop = NULL;
+
+ switch (value.get_type()) {
+ case Variant::NIL: {
+ prop = memnew(EditorPropertyNil);
+
+ } break;
+
+ // atomic types
+ case Variant::BOOL: {
+
+ prop = memnew(EditorPropertyCheck);
+
+ } break;
+ case Variant::INT: {
+ EditorPropertyInteger *ed = memnew(EditorPropertyInteger);
+ ed->setup(-100000, 100000, true, true);
+ prop = ed;
+
+ } break;
+ case Variant::REAL: {
+
+ EditorPropertyFloat *ed = memnew(EditorPropertyFloat);
+ ed->setup(-100000, 100000, 0.001, true, false, true, true);
+ prop = ed;
+ } break;
+ case Variant::STRING: {
+
+ prop = memnew(EditorPropertyText);
+
+ } break;
+
+ // math types
+
+ case Variant::VECTOR2: {
+
+ EditorPropertyVector2 *ed = memnew(EditorPropertyVector2);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::RECT2: {
+
+ EditorPropertyRect2 *ed = memnew(EditorPropertyRect2);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::VECTOR3: {
+
+ EditorPropertyVector3 *ed = memnew(EditorPropertyVector3);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::TRANSFORM2D: {
+
+ EditorPropertyTransform2D *ed = memnew(EditorPropertyTransform2D);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::PLANE: {
+
+ EditorPropertyPlane *ed = memnew(EditorPropertyPlane);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::QUAT: {
+
+ EditorPropertyQuat *ed = memnew(EditorPropertyQuat);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::AABB: {
+
+ EditorPropertyAABB *ed = memnew(EditorPropertyAABB);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::BASIS: {
+ EditorPropertyBasis *ed = memnew(EditorPropertyBasis);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+ case Variant::TRANSFORM: {
+ EditorPropertyTransform *ed = memnew(EditorPropertyTransform);
+ ed->setup(-100000, 100000, 0.001, true);
+ prop = ed;
+
+ } break;
+
+ // misc types
+ case Variant::COLOR: {
+ prop = memnew(EditorPropertyColor);
+
+ } break;
+ case Variant::NODE_PATH: {
+ prop = memnew(EditorPropertyNodePath);
+
+ } break;
+ case Variant::_RID: {
+ prop = memnew(EditorPropertyNil);
+
+ } break;
+ case Variant::OBJECT: {
+
+ prop = memnew(EditorPropertyResource);
+
+ } break;
+ case Variant::DICTIONARY: {
+ prop = memnew(EditorPropertyDictionary);
+
+ } break;
+ case Variant::ARRAY: {
+
+ prop = memnew(EditorPropertyArray);
+
+ } break;
+
+ // arrays
+ case Variant::POOL_BYTE_ARRAY: {
+ prop = memnew(EditorPropertyArray);
+
+ } break;
+ case Variant::POOL_INT_ARRAY: {
+ prop = memnew(EditorPropertyArray);
+
+ } break;
+ case Variant::POOL_REAL_ARRAY: {
+
+ prop = memnew(EditorPropertyArray);
+ } break;
+ case Variant::POOL_STRING_ARRAY: {
+
+ prop = memnew(EditorPropertyArray);
+ } break;
+ case Variant::POOL_VECTOR2_ARRAY: {
+
+ prop = memnew(EditorPropertyArray);
+ } break;
+ case Variant::POOL_VECTOR3_ARRAY: {
+ prop = memnew(EditorPropertyArray);
+
+ } break;
+ case Variant::POOL_COLOR_ARRAY: {
+ prop = memnew(EditorPropertyArray);
+
+ } break;
+ default: {}
+ }
+
+ if (i == amount) {
+ PanelContainer *pc = memnew(PanelContainer);
+ vbox->add_child(pc);
+ Ref<StyleBoxFlat> flat;
+ flat.instance();
+ for (int j = 0; j < 4; j++) {
+ flat->set_default_margin(Margin(j), 2 * EDSCALE);
+ }
+ flat->set_bg_color(get_color("prop_subsection", "Editor"));
+
+ pc->add_style_override("panel", flat);
+ add_vbox = memnew(VBoxContainer);
+ pc->add_child(add_vbox);
+ }
+ prop->set_object_and_property(object.ptr(), prop_name);
+ int change_index;
+
+ if (i < amount) {
+ String cs = key.get_construct_string();
+ prop->set_label(key.get_construct_string());
+ prop->set_tooltip(cs);
+ change_index = i + offset;
+ } else if (i == amount) {
+ prop->set_label(TTR("New Key:"));
+ change_index = -1;
+ } else if (i == amount + 1) {
+ prop->set_label(TTR("New Value:"));
+ change_index = -2;
+ }
+
+ prop->set_selectable(false);
+ prop->connect("property_changed", this, "_property_changed");
+
+ HBoxContainer *hb = memnew(HBoxContainer);
+ if (add_vbox) {
+ add_vbox->add_child(hb);
+ } else {
+ vbox->add_child(hb);
+ }
+ hb->add_child(prop);
+ prop->set_h_size_flags(SIZE_EXPAND_FILL);
+ Button *edit = memnew(Button);
+ edit->set_icon(get_icon("Edit", "EditorIcons"));
+ hb->add_child(edit);
+ edit->connect("pressed", this, "_change_type", varray(edit, change_index));
+
+ prop->update_property();
+
+ if (i == amount + 1) {
+ Button *add_item = memnew(Button);
+ add_item->set_text(TTR("Add Key/Value Pair"));
+ add_vbox->add_child(add_item);
+ add_item->connect("pressed", this, "_add_key_value");
+ }
+ }
+
+ updating = false;
+
+ } else {
+ if (vbox) {
+ set_bottom_editor(NULL);
+ memdelete(vbox);
+ vbox = NULL;
+ }
+ }
+#endif
+}
+
+void EditorPropertyDictionary::_notification(int p_what) {
+
+ if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
+ }
+}
+void EditorPropertyDictionary::_edit_pressed() {
+
+ get_edited_object()->editor_set_section_unfold(get_edited_property(), edit->is_pressed());
+ update_property();
+}
+
+void EditorPropertyDictionary::_page_changed(double p_page) {
+ if (updating)
+ return;
+ page_idx = p_page;
+ update_property();
+}
+
+void EditorPropertyDictionary::_bind_methods() {
+ ClassDB::bind_method("_edit_pressed", &EditorPropertyDictionary::_edit_pressed);
+ ClassDB::bind_method("_page_changed", &EditorPropertyDictionary::_page_changed);
+ ClassDB::bind_method("_property_changed", &EditorPropertyDictionary::_property_changed);
+ ClassDB::bind_method("_change_type", &EditorPropertyDictionary::_change_type);
+ ClassDB::bind_method("_change_type_menu", &EditorPropertyDictionary::_change_type_menu);
+ ClassDB::bind_method("_add_key_value", &EditorPropertyDictionary::_add_key_value);
+}
+
+EditorPropertyDictionary::EditorPropertyDictionary() {
+
+ object.instance();
+ page_idx = 0;
+ page_len = 10;
+ edit = memnew(Button);
+ edit->set_flat(true);
+ edit->set_h_size_flags(SIZE_EXPAND_FILL);
+ edit->set_clip_text(true);
+ edit->connect("pressed", this, "_edit_pressed");
+ edit->set_toggle_mode(true);
+ add_child(edit);
+ add_focusable(edit);
+ vbox = NULL;
+ page = NULL;
+ updating = false;
+ change_type = memnew(PopupMenu);
+ add_child(change_type);
+ change_type->connect("id_pressed", this, "_change_type_menu");
+ changing_type_idx = -1;
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
+ String type = Variant::get_type_name(Variant::Type(i));
+ change_type->add_item(type, i);
+ }
+ change_type->add_separator();
+ change_type->add_item(TTR("Remove Item"), Variant::VARIANT_MAX);
+ changing_type_idx = -1;
+}
diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h
new file mode 100644
index 0000000000..7f6203ee88
--- /dev/null
+++ b/editor/editor_properties_array_dict.h
@@ -0,0 +1,115 @@
+#ifndef EDITOR_PROPERTIES_ARRAY_DICT_H
+#define EDITOR_PROPERTIES_ARRAY_DICT_H
+
+#include "editor/editor_inspector.h"
+#include "editor/editor_spin_slider.h"
+#include "scene/gui/button.h"
+
+class EditorPropertyArrayObject : public Reference {
+
+ GDCLASS(EditorPropertyArrayObject, Reference);
+
+ Variant array;
+
+protected:
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+
+public:
+ void set_array(const Variant &p_array);
+ Variant get_array();
+
+ EditorPropertyArrayObject();
+};
+
+class EditorPropertyDictionaryObject : public Reference {
+
+ GDCLASS(EditorPropertyDictionaryObject, Reference);
+
+ Variant new_item_key;
+ Variant new_item_value;
+ Dictionary dict;
+
+protected:
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+
+public:
+ void set_dict(const Dictionary &p_dict);
+ Dictionary get_dict();
+
+ void set_new_item_key(const Variant &p_new_item);
+ Variant get_new_item_key();
+
+ void set_new_item_value(const Variant &p_new_item);
+ Variant get_new_item_value();
+
+ EditorPropertyDictionaryObject();
+};
+
+class EditorPropertyArray : public EditorProperty {
+ GDCLASS(EditorPropertyArray, EditorProperty)
+
+ PopupMenu *change_type;
+ bool updating;
+
+ Ref<EditorPropertyArrayObject> object;
+ int page_len;
+ int page_idx;
+ int changing_type_idx;
+ Button *edit;
+ VBoxContainer *vbox;
+ EditorSpinSlider *length;
+ EditorSpinSlider *page;
+ HBoxContainer *page_hb;
+
+ void _page_changed(double p_page);
+ void _length_changed(double p_page);
+ void _edit_pressed();
+ void _property_changed(const String &p_prop, Variant p_value);
+ void _change_type(Object *p_button, int p_index);
+ void _change_type_menu(int p_index);
+
+protected:
+ static void _bind_methods();
+ void _notification(int p_what);
+
+public:
+ virtual void update_property();
+ EditorPropertyArray();
+};
+
+class EditorPropertyDictionary : public EditorProperty {
+ GDCLASS(EditorPropertyDictionary, EditorProperty)
+
+ PopupMenu *change_type;
+ bool updating;
+
+ Ref<EditorPropertyDictionaryObject> object;
+ int page_len;
+ int page_idx;
+ int changing_type_idx;
+ Button *edit;
+ VBoxContainer *vbox;
+ EditorSpinSlider *length;
+ EditorSpinSlider *page;
+ HBoxContainer *page_hb;
+
+ void _page_changed(double p_page);
+ void _edit_pressed();
+ void _property_changed(const String &p_prop, Variant p_value);
+ void _change_type(Object *p_button, int p_index);
+ void _change_type_menu(int p_index);
+
+ void _add_key_value();
+
+protected:
+ static void _bind_methods();
+ void _notification(int p_what);
+
+public:
+ virtual void update_property();
+ EditorPropertyDictionary();
+};
+
+#endif // EDITOR_PROPERTIES_ARRAY_DICT_H
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index e7741c7926..297373d299 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -383,11 +383,11 @@ void FileSystemDock::_update_file_display_toggle_button() {
if (button_display_mode->is_pressed()) {
display_mode = DISPLAY_LIST;
button_display_mode->set_icon(get_icon("FileThumbnail", "EditorIcons"));
- button_display_mode->set_tooltip(TTR("View items as a grid of thumbnails"));
+ button_display_mode->set_tooltip(TTR("View items as a grid of thumbnails."));
} else {
display_mode = DISPLAY_THUMBNAILS;
button_display_mode->set_icon(get_icon("FileList", "EditorIcons"));
- button_display_mode->set_tooltip(TTR("View items as a list"));
+ button_display_mode->set_tooltip(TTR("View items as a list."));
}
}
@@ -1860,7 +1860,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
button_favorite->set_flat(true);
button_favorite->set_toggle_mode(true);
button_favorite->connect("pressed", this, "_favorites_pressed");
- button_favorite->set_tooltip(TTR("Toggle folder status as Favorite"));
+ button_favorite->set_tooltip(TTR("Toggle folder status as Favorite."));
button_favorite->set_focus_mode(FOCUS_NONE);
toolbar_hbc->add_child(button_favorite);
@@ -1916,11 +1916,13 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
file_list_vb->add_child(path_hb);
button_tree = memnew(ToolButton);
+ button_tree->set_tooltip(TTR("Enter tree-view."));
button_tree->hide();
path_hb->add_child(button_tree);
search_box = memnew(LineEdit);
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
+ search_box->set_placeholder(TTR("Search files"));
search_box->connect("text_changed", this, "_search_changed");
path_hb->add_child(search_box);
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index 74ea46838b..004a49e2b4 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -109,6 +109,7 @@ void FindInFiles::start() {
_current_dir = "";
PoolStringArray init_folder;
init_folder.append(_root_dir);
+ _folders_stack.clear();
_folders_stack.push_back(init_folder);
_initial_files_count = 0;
@@ -127,11 +128,12 @@ void FindInFiles::_process() {
// This part can be moved to a thread if needed
OS &os = *OS::get_singleton();
- float duration = 0.0;
- while (duration < 1.0 / 120.0) {
- float time_before = os.get_ticks_msec();
+ float time_before = os.get_ticks_msec();
+ while (is_processing()) {
_iterate();
- duration += (os.get_ticks_msec() - time_before);
+ float elapsed = (os.get_ticks_msec() - time_before);
+ if (elapsed > 1000.0 / 120.0)
+ break;
}
}
@@ -428,6 +430,7 @@ FindInFilesDialog::FindInFilesDialog() {
void FindInFilesDialog::set_search_text(String text) {
_search_text_line_edit->set_text(text);
+ _on_search_text_modified(text);
}
String FindInFilesDialog::get_search_text() const {
diff --git a/editor/icons/icon_oriented_path_follow.svg b/editor/icons/icon_oriented_path_follow.svg
new file mode 100644
index 0000000000..bd3f585e54
--- /dev/null
+++ b/editor/icons/icon_oriented_path_follow.svg
@@ -0,0 +1,5 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m13 0l-3 4h1.9473c-0.1385 1.3203-0.5583 1.9074-1.084 2.2754-0.64426 0.451-1.7129 0.60547-2.9629 0.73047s-2.6814 0.22053-3.9121 1.082c-0.89278 0.62493-1.5321 1.6522-1.8184 3.0957a2 2 0 0 0 -1.1699 1.8164 2 2 0 0 0 2 2 2 2 0 0 0 2 -2 2 2 0 0 0 -0.84961 -1.6328c0.19235-0.88496 0.55306-1.3373 0.98633-1.6406 0.64426-0.451 1.7129-0.60547 2.9629-0.73047s2.6814-0.22053 3.9121-1.082c1.0528-0.73697 1.7552-2.032 1.9375-3.9141h2.0508l-3-4z" fill="#fc9c9c" fill-opacity=".99608"/>
+</g>
+</svg>
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 1d7545f182..2fb3bf7b1e 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -339,7 +339,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
NodeMap nm;
nm.node = node;
node_map[p_node->id] = nm;
- node_name_map[p_node->name] = p_node->id;
+ node_name_map[node->get_name()] = p_node->id;
Transform xf = p_node->default_transform;
xf = collada.fix_transform(xf) * p_node->post_transform;
diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp
index 128196be5a..f91802b352 100644
--- a/editor/import_dock.cpp
+++ b/editor/import_dock.cpp
@@ -407,6 +407,7 @@ ImportDock::ImportDock() {
set_name("Import");
imported = memnew(Label);
imported->add_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_stylebox("normal", "LineEdit"));
+ imported->set_clip_text(true);
add_child(imported);
HBoxContainer *hb = memnew(HBoxContainer);
add_margin_child(TTR("Import As:"), hb);
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index d21c84eb61..d595d4dd98 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -705,7 +705,18 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByt
int len = image_data.size();
PoolByteArray::Read r = image_data.read();
- Ref<Image> image = Ref<Image>(memnew(Image(r.ptr(), len)));
+ Ref<Image> image = Ref<Image>(memnew(Image));
+
+ uint8_t png_signature[8] = { 137, 80, 78, 71, 13, 10, 26, 10 };
+ uint8_t jpg_signature[3] = { 255, 216, 255 };
+
+ if (r.ptr()) {
+ if (memcmp(&r[0], &png_signature[0], 8) == 0) {
+ image->copy_internals_from(Image::_png_mem_loader_func(r.ptr(), len));
+ } else if (memcmp(&r[0], &jpg_signature[0], 3) == 0) {
+ image->copy_internals_from(Image::_jpg_mem_loader_func(r.ptr(), len));
+ }
+ }
if (!image->empty()) {
switch (image_queue[p_queue_id].image_type) {
@@ -750,7 +761,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons
ERR_FAIL_COND(!image_queue.has(p_queue_id));
- if (p_status == HTTPRequest::RESULT_SUCCESS) {
+ if (p_status == HTTPRequest::RESULT_SUCCESS && p_code < HTTPClient::RESPONSE_BAD_REQUEST) {
if (p_code != HTTPClient::RESPONSE_NOT_MODIFIED) {
for (int i = 0; i < headers.size(); i++) {
@@ -781,7 +792,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons
_image_update(p_code == HTTPClient::RESPONSE_NOT_MODIFIED, true, p_data, p_queue_id);
} else {
- WARN_PRINTS("Error getting PNG file from URL: " + image_queue[p_queue_id].image_url);
+ // WARN_PRINTS("Error getting image file from URL: " + image_queue[p_queue_id].image_url);
Object *obj = ObjectDB::get_instance(image_queue[p_queue_id].target);
if (obj) {
obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_icon("DefaultProjectIcon", "EditorIcons"));
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 488f687515..ca5aa7039d 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -2689,6 +2689,9 @@ void CanvasItemEditor::_draw_bones() {
continue;
Node2D *from_node = Object::cast_to<Node2D>(ObjectDB::get_instance(E->key().from));
+ if (!from_node->is_visible_in_tree())
+ continue;
+
Vector<Color> colors;
if (from_node->has_meta("_edit_ik_")) {
colors.push_back(bone_ik_color);
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index 29720b3cdb..49c54ad67d 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -794,13 +794,13 @@ Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from) {
img_ref.instance();
Image &im = **img_ref;
- im.create(thumbnail_size, thumbnail_size, 0, Image::FORMAT_RGBA8);
+ im.create(thumbnail_size, thumbnail_size / 2, 0, Image::FORMAT_RGBA8);
im.lock();
Color bg_color(0.1, 0.1, 0.1, 1.0);
for (int i = 0; i < thumbnail_size; i++) {
- for (int j = 0; j < thumbnail_size; j++) {
+ for (int j = 0; j < thumbnail_size / 2; j++) {
im.set_pixel(i, j, bg_color);
}
}
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 422d19c0e4..94dcbd8e18 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1404,6 +1404,7 @@ void ScriptEditor::_update_members_overview_visibility() {
ScriptEditorBase *se = _get_current_editor();
if (!se) {
+ members_overview_buttons_hbox->set_visible(false);
members_overview->set_visible(false);
return;
}
@@ -2681,7 +2682,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
members_overview_vbox->add_child(members_overview_buttons_hbox);
members_overview_alphabeta_sort_button = memnew(ToolButton);
- members_overview_alphabeta_sort_button->set_tooltip(TTR("Sort alphabetically"));
+ members_overview_alphabeta_sort_button->set_tooltip(TTR("Toggle alphabetical sorting of the method list."));
members_overview_alphabeta_sort_button->set_toggle_mode(true);
members_overview_alphabeta_sort_button->set_pressed(EditorSettings::get_singleton()->get("text_editor/tools/sort_members_outline_alphabetically"));
members_overview_alphabeta_sort_button->connect("toggled", this, "_toggle_members_overview_alpha_sort");
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 97d3a070ab..0d06b71420 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -199,6 +199,7 @@ private:
sp = TTR("Imported Project");
project_name->set_text(sp);
+ _text_changed(sp);
}
}
@@ -222,6 +223,7 @@ private:
}
String sp = p.simplify_path();
project_path->set_text(sp);
+ _path_text_changed(sp);
get_ok()->call_deferred("grab_focus");
}
@@ -230,6 +232,7 @@ private:
String p = p_path;
String sp = p.simplify_path();
project_path->set_text(sp);
+ _path_text_changed(sp);
get_ok()->call_deferred("grab_focus");
}
@@ -263,7 +266,9 @@ private:
if (d->make_dir(project_name->get_text()) == OK) {
d->change_dir(project_name->get_text());
- project_path->set_text(d->get_current_dir());
+ String dir_str = d->get_current_dir();
+ project_path->set_text(dir_str);
+ _path_text_changed(dir_str);
created_folder_path = d->get_current_dir();
create_dir->set_disabled(true);
} else {
@@ -475,7 +480,9 @@ private:
_remove_created_folder();
project_path->clear();
+ _path_text_changed("");
project_name->clear();
+ _text_changed("");
if (status_rect->get_texture() == get_icon("StatusError", "EditorIcons"))
msg->show();
@@ -540,7 +547,9 @@ public:
msg->show();
get_ok()->set_disabled(true);
} else if (current->has_setting("application/config/name")) {
- project_name->set_text(current->get("application/config/name"));
+ String proj = current->get("application/config/name");
+ project_name->set_text(proj);
+ _text_changed(proj);
}
project_name->call_deferred("grab_focus");
@@ -559,7 +568,9 @@ public:
fdialog->set_current_dir(d->get_current_dir());
memdelete(d);
}
- project_name->set_text(TTR("New Game Project"));
+ String proj = TTR("New Game Project");
+ project_name->set_text(proj);
+ _text_changed(proj);
project_path->set_editable(true);
browse->set_disabled(false);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index b82a036130..32b4e7f962 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -113,7 +113,7 @@ void SceneTreeDock::instance(const String &p_file) {
Node *parent = scene_tree->get_selected();
if (!parent) {
- Node *parent = edited_scene;
+ parent = edited_scene;
};
if (!edited_scene) {
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index 9ce4305683..62848a6035 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -872,7 +872,7 @@ void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType
reason->add_color_override("font_color", get_color("success_color", "Editor"));
}
reason->set_text(p_reason);
- reason->set_tooltip(p_reason);
+ reason->set_tooltip(p_reason.word_wrap(80));
}
void ScriptEditorDebugger::_performance_select() {
@@ -1877,6 +1877,9 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
reason->set_text("");
hbc->add_child(reason);
reason->set_h_size_flags(SIZE_EXPAND_FILL);
+ reason->set_autowrap(true);
+ reason->set_max_lines_visible(3);
+ reason->set_mouse_filter(Control::MOUSE_FILTER_PASS);
hbc->add_child(memnew(VSeparator));