diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/array_property_edit.cpp | 11 | ||||
-rw-r--r-- | editor/editor_node.cpp | 6 | ||||
-rw-r--r-- | editor/editor_properties.cpp | 24 | ||||
-rw-r--r-- | editor/editor_properties_array_dict.cpp | 54 | ||||
-rw-r--r-- | editor/editor_properties_array_dict.h | 3 | ||||
-rw-r--r-- | editor/import/resource_importer_texture.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/animation_blend_space_2d_editor.cpp | 15 | ||||
-rw-r--r-- | editor/plugins/animation_blend_space_2d_editor.h | 1 | ||||
-rw-r--r-- | editor/script_editor_debugger.cpp | 1 |
9 files changed, 103 insertions, 14 deletions
diff --git a/editor/array_property_edit.cpp b/editor/array_property_edit.cpp index a32a71262f..245c9273ff 100644 --- a/editor/array_property_edit.cpp +++ b/editor/array_property_edit.cpp @@ -30,6 +30,7 @@ #include "array_property_edit.h" +#include "core/io/marshalls.h" #include "editor_node.h" #define ITEMS_PER_PAGE 100 @@ -202,6 +203,11 @@ bool ArrayPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const { int idx = pn.get_slicec('/', 1).to_int(); bool valid; r_ret = arr.get(idx, &valid); + + if (r_ret.get_type() == Variant::OBJECT && Object::cast_to<EncodedObjectAsID>(r_ret)) { + r_ret = Object::cast_to<EncodedObjectAsID>(r_ret)->get_object_id(); + } + return valid; } } @@ -232,6 +238,11 @@ void ArrayPropertyEdit::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::INT, "indices/" + itos(i + offset) + "_type", PROPERTY_HINT_ENUM, vtypes)); } + if (v.get_type() == Variant::OBJECT && Object::cast_to<EncodedObjectAsID>(v)) { + p_list->push_back(PropertyInfo(Variant::INT, "indices/" + itos(i + offset), PROPERTY_HINT_OBJECT_ID, "Object")); + continue; + } + if (is_typed || v.get_type() != Variant::NIL) { PropertyInfo pi(v.get_type(), "indices/" + itos(i + offset)); if (subtype != Variant::NIL) { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 1b77b04a05..5d29acff75 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2568,6 +2568,12 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled) return; } + //errors in the script cause the base_type to be "" + if (String(script->get_instance_base_type()) == "") { + show_warning(vformat(TTR("Unable to load addon script from path: '%s' There seems to be an error in the code, please check the syntax."), path)); + return; + } + //could check inheritance.. if (String(script->get_instance_base_type()) != "EditorPlugin") { show_warning(vformat(TTR("Unable to load addon script from path: '%s' Base type is not EditorPlugin."), path)); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 4534eda012..57c6fa3547 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -1802,14 +1802,26 @@ void EditorPropertyNodePath::_node_selected(const NodePath &p_path) { NodePath path = p_path; Node *base_node = Object::cast_to<Node>(get_edited_object()); - if (base_node == NULL) { - if (Object::cast_to<Resource>(get_edited_object())) { - Node *to_node = get_node(p_path); - path = get_tree()->get_edited_scene_root()->get_path_to(to_node); - } else if (get_edited_object()->has_method("get_root_path")) { - base_node = get_edited_object()->call("get_root_path"); + if (!base_node) { + //try a base node within history + if (EditorNode::get_singleton()->get_editor_history()->get_path_size() > 0) { + Object *base = ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_history()->get_path_object(0)); + if (base) { + base_node = Object::cast_to<Node>(base); + } } } + + if (!base_node && get_edited_object()->has_method("get_root_path")) { + base_node = get_edited_object()->call("get_root_path"); + } + + if (!base_node && Object::cast_to<Reference>(get_edited_object())) { + Node *to_node = get_node(p_path); + ERR_FAIL_COND(!to_node); + path = get_tree()->get_edited_scene_root()->get_path_to(to_node); + } + if (base_node) { // for AnimationTrackKeyEdit path = base_node->get_path().rel_path_to(p_path); } diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 24360813a2..431f608f46 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -29,9 +29,9 @@ /*************************************************************************/ #include "editor_properties_array_dict.h" +#include "core/io/marshalls.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; @@ -54,6 +54,10 @@ bool EditorPropertyArrayObject::_get(const StringName &p_name, Variant &r_ret) c int idx = pn.get_slicec('/', 1).to_int(); bool valid; r_ret = array.get(idx, &valid); + if (r_ret.get_type() == Variant::OBJECT && Object::cast_to<EncodedObjectAsID>(r_ret)) { + r_ret = Object::cast_to<EncodedObjectAsID>(r_ret)->get_object_id(); + } + return valid; } @@ -120,6 +124,10 @@ bool EditorPropertyDictionaryObject::_get(const StringName &p_name, Variant &r_r int idx = pn.get_slicec('/', 1).to_int(); Variant key = dict.get_key_at_index(idx); r_ret = dict[key]; + if (r_ret.get_type() == Variant::OBJECT && Object::cast_to<EncodedObjectAsID>(r_ret)) { + r_ret = Object::cast_to<EncodedObjectAsID>(r_ret)->get_object_id(); + } + return true; } @@ -198,6 +206,10 @@ void EditorPropertyArray::_change_type_menu(int p_index) { update_property(); } +void EditorPropertyArray::_object_id_selected(const String &p_property, ObjectID p_id) { + emit_signal("object_id_selected", p_property, p_id); +} + void EditorPropertyArray::update_property() { Variant array = get_edited_object()->get(get_edited_property()); @@ -431,9 +443,19 @@ void EditorPropertyArray::update_property() { } break; case Variant::OBJECT: { - EditorPropertyResource *editor = memnew(EditorPropertyResource); - editor->setup("Resource"); - prop = editor; + + if (Object::cast_to<EncodedObjectAsID>(value)) { + + EditorPropertyObjectID *editor = memnew(EditorPropertyObjectID); + editor->setup("Object"); + prop = editor; + + } else { + + EditorPropertyResource *editor = memnew(EditorPropertyResource); + editor->setup("Resource"); + prop = editor; + } } break; case Variant::DICTIONARY: { @@ -497,6 +519,7 @@ void EditorPropertyArray::update_property() { prop->set_label(itos(i + offset)); prop->set_selectable(false); prop->connect("property_changed", this, "_property_changed"); + prop->connect("object_id_selected", this, "_object_id_selected"); if (array.get_type() == Variant::ARRAY) { HBoxContainer *hb = memnew(HBoxContainer); vbox->add_child(hb); @@ -578,6 +601,7 @@ void EditorPropertyArray::_bind_methods() { ClassDB::bind_method("_property_changed", &EditorPropertyArray::_property_changed, DEFVAL(false)); ClassDB::bind_method("_change_type", &EditorPropertyArray::_change_type); ClassDB::bind_method("_change_type_menu", &EditorPropertyArray::_change_type_menu); + ClassDB::bind_method("_object_id_selected", &EditorPropertyArray::_object_id_selected); } EditorPropertyArray::EditorPropertyArray() { @@ -893,9 +917,19 @@ void EditorPropertyDictionary::update_property() { } break; case Variant::OBJECT: { - EditorPropertyResource *editor = memnew(EditorPropertyResource); - editor->setup("Resource"); - prop = editor; + + if (Object::cast_to<EncodedObjectAsID>(value)) { + + EditorPropertyObjectID *editor = memnew(EditorPropertyObjectID); + editor->setup("Object"); + prop = editor; + + } else { + + EditorPropertyResource *editor = memnew(EditorPropertyResource); + editor->setup("Resource"); + prop = editor; + } } break; case Variant::DICTIONARY: { @@ -986,6 +1020,7 @@ void EditorPropertyDictionary::update_property() { prop->set_selectable(false); prop->connect("property_changed", this, "_property_changed"); + prop->connect("object_id_selected", this, "_object_id_selected"); HBoxContainer *hb = memnew(HBoxContainer); if (add_vbox) { @@ -1022,6 +1057,10 @@ void EditorPropertyDictionary::update_property() { #endif } +void EditorPropertyDictionary::_object_id_selected(const String &p_property, ObjectID p_id) { + emit_signal("object_id_selected", p_property, p_id); +} + void EditorPropertyDictionary::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { @@ -1055,6 +1094,7 @@ void EditorPropertyDictionary::_bind_methods() { 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); + ClassDB::bind_method("_object_id_selected", &EditorPropertyDictionary::_object_id_selected); } EditorPropertyDictionary::EditorPropertyDictionary() { diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index d2bd849f30..d5eecd9106 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -101,6 +101,8 @@ class EditorPropertyArray : public EditorProperty { void _change_type(Object *p_button, int p_index); void _change_type_menu(int p_index); + void _object_id_selected(const String &p_property, ObjectID p_id); + protected: static void _bind_methods(); void _notification(int p_what); @@ -134,6 +136,7 @@ class EditorPropertyDictionary : public EditorProperty { void _change_type_menu(int p_index); void _add_key_value(); + void _object_id_selected(const String &p_property, ObjectID p_id); protected: static void _bind_methods(); diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 8e91a88adb..b38f4c4f14 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -216,7 +216,7 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "stream"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "size_limit", PROPERTY_HINT_RANGE, "0,4096,1"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "detect_3d"), p_preset == PRESET_DETECT)); - r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "svg/scale", PROPERTY_HINT_RANGE, "0.001,100,0.1"), 1.0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "svg/scale", PROPERTY_HINT_RANGE, "0.001,100,0.001"), 1.0)); } void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_force_rgbe, bool p_detect_normal, bool p_force_normal) { diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 394b888d0e..e2fe9a91d8 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -607,6 +607,8 @@ void AnimationNodeBlendSpace2DEditor::_update_space() { auto_triangles->set_pressed(blend_space->get_auto_triangles()); + interpolation->select(blend_space->get_blend_mode()); + max_x_value->set_value(blend_space->get_max_space().x); max_y_value->set_value(blend_space->get_max_space().y); @@ -636,6 +638,8 @@ void AnimationNodeBlendSpace2DEditor::_config_changed(double) { undo_redo->add_undo_method(blend_space.ptr(), "set_min_space", blend_space->get_min_space()); undo_redo->add_do_method(blend_space.ptr(), "set_snap", Vector2(snap_x->get_value(), snap_y->get_value())); undo_redo->add_undo_method(blend_space.ptr(), "set_snap", blend_space->get_snap()); + undo_redo->add_do_method(blend_space.ptr(), "set_blend_mode", interpolation->get_selected()); + undo_redo->add_undo_method(blend_space.ptr(), "set_blend_mode", blend_space->get_blend_mode()); undo_redo->add_do_method(this, "_update_space"); undo_redo->add_undo_method(this, "_update_space"); undo_redo->commit_action(); @@ -752,6 +756,10 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { snap->set_icon(get_icon("SnapGrid", "EditorIcons")); open_editor->set_icon(get_icon("Edit", "EditorIcons")); auto_triangles->set_icon(get_icon("AutoTriangle", "EditorIcons")); + interpolation->clear(); + interpolation->add_icon_item(get_icon("TrackContinuous", "EditorIcons"), "", 0); + interpolation->add_icon_item(get_icon("TrackDiscrete", "EditorIcons"), "", 1); + interpolation->add_icon_item(get_icon("TrackCapture", "EditorIcons"), "", 2); } if (p_what == NOTIFICATION_PROCESS) { @@ -914,6 +922,13 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() { snap_y->set_step(0.01); snap_y->set_max(1000); + top_hb->add_child(memnew(VSeparator)); + + top_hb->add_child(memnew(Label(TTR("Blend:")))); + interpolation = memnew(OptionButton); + top_hb->add_child(interpolation); + interpolation->connect("item_selected", this, "_config_changed"); + edit_hb = memnew(HBoxContainer); top_hb->add_child(edit_hb); edit_hb->add_child(memnew(VSeparator)); diff --git a/editor/plugins/animation_blend_space_2d_editor.h b/editor/plugins/animation_blend_space_2d_editor.h index 613289e4d8..603fa1cd19 100644 --- a/editor/plugins/animation_blend_space_2d_editor.h +++ b/editor/plugins/animation_blend_space_2d_editor.h @@ -60,6 +60,7 @@ class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin { ToolButton *snap; SpinBox *snap_x; SpinBox *snap_y; + OptionButton *interpolation; ToolButton *auto_triangles; diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index faa561ad54..559ab32505 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -602,6 +602,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da String n = p_data[ofs + i * 2 + 0]; Variant v = p_data[ofs + i * 2 + 1]; + PropertyHint h = PROPERTY_HINT_NONE; String hs = String(); |