diff options
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r-- | editor/editor_properties.cpp | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index eee610e9a8..8f9c92ea15 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); @@ -2983,8 +2983,16 @@ bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const String allowed_type = base_type; Dictionary drag_data = p_drag_data; - if (drag_data.has("type") && String(drag_data["type"]) == "resource") { - Ref<Resource> res = drag_data["resource"]; + + Ref<Resource> res; + if (drag_data.has("type") && String(drag_data["type"]) == "script_list_element") { + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(drag_data["script_list_element"]); + res = se->get_edited_resource(); + } else if (drag_data.has("type") && String(drag_data["type"]) == "resource") { + res = drag_data["resource"]; + } + + if (res.is_valid()) { for (int i = 0; i < allowed_type.get_slice_count(","); i++) { String at = allowed_type.get_slice(",", i).strip_edges(); if (res.is_valid() && ClassDB::is_parent_class(res->get_class(), at)) { @@ -3022,13 +3030,19 @@ void EditorPropertyResource::drop_data_fw(const Point2 &p_point, const Variant & ERR_FAIL_COND(!_is_drop_valid(p_data)); Dictionary drag_data = p_data; - if (drag_data.has("type") && String(drag_data["type"]) == "resource") { - Ref<Resource> res = drag_data["resource"]; - if (res.is_valid()) { - emit_changed(get_edited_property(), res); - update_property(); - return; - } + + Ref<Resource> res; + if (drag_data.has("type") && String(drag_data["type"]) == "script_list_element") { + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(drag_data["script_list_element"]); + res = se->get_edited_resource(); + } else if (drag_data.has("type") && String(drag_data["type"]) == "resource") { + res = drag_data["resource"]; + } + + if (res.is_valid()) { + emit_changed(get_edited_property(), res); + update_property(); + return; } if (drag_data.has("type") && String(drag_data["type"]) == "files") { @@ -3036,9 +3050,9 @@ void EditorPropertyResource::drop_data_fw(const Point2 &p_point, const Variant & if (files.size() == 1) { String file = files[0]; - RES res = ResourceLoader::load(file); - if (res.is_valid()) { - emit_changed(get_edited_property(), res); + RES file_res = ResourceLoader::load(file); + if (file_res.is_valid()) { + emit_changed(get_edited_property(), file_res); update_property(); return; } |