summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_track_editor.cpp16
-rw-r--r--editor/debugger/editor_debugger_inspector.cpp4
-rw-r--r--editor/debugger/editor_debugger_inspector.h2
-rw-r--r--editor/debugger/editor_debugger_node.h2
-rw-r--r--editor/editor_autoload_settings.cpp2
-rw-r--r--editor/editor_data.cpp2
-rw-r--r--editor/editor_data.h2
-rw-r--r--editor/editor_folding.cpp22
-rw-r--r--editor/editor_folding.h10
-rw-r--r--editor/editor_inspector.cpp2
-rw-r--r--editor/editor_inspector.h2
-rw-r--r--editor/editor_node.cpp30
-rw-r--r--editor/editor_node.h14
-rw-r--r--editor/editor_properties.cpp16
-rw-r--r--editor/editor_properties.h6
-rw-r--r--editor/editor_properties_array_dict.cpp2
-rw-r--r--editor/editor_resource_picker.cpp16
-rw-r--r--editor/editor_resource_picker.h6
-rw-r--r--editor/editor_resource_preview.cpp4
-rw-r--r--editor/editor_resource_preview.h4
-rw-r--r--editor/filesystem_dock.cpp2
-rw-r--r--editor/import/resource_importer_scene.cpp8
-rw-r--r--editor/import/resource_importer_scene.h4
-rw-r--r--editor/inspector_dock.cpp26
-rw-r--r--editor/inspector_dock.h2
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp6
-rw-r--r--editor/plugins/editor_preview_plugins.cpp22
-rw-r--r--editor/plugins/editor_preview_plugins.h22
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.cpp2
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.cpp2
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp10
-rw-r--r--editor/plugins/packed_scene_translation_parser_plugin.cpp2
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp16
-rw-r--r--editor/plugins/script_editor_plugin.cpp54
-rw-r--r--editor/plugins/script_editor_plugin.h28
-rw-r--r--editor/plugins/script_text_editor.cpp6
-rw-r--r--editor/plugins/script_text_editor.h4
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp6
-rw-r--r--editor/plugins/text_editor.cpp6
-rw-r--r--editor/plugins/text_editor.h4
-rw-r--r--editor/plugins/theme_editor_plugin.cpp20
-rw-r--r--editor/plugins/theme_editor_plugin.h2
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp16
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h2
-rw-r--r--editor/property_editor.cpp26
-rw-r--r--editor/property_editor.h4
-rw-r--r--editor/scene_tree_dock.cpp14
-rw-r--r--editor/scene_tree_dock.h8
-rw-r--r--editor/script_create_dialog.cpp2
-rw-r--r--editor/shader_create_dialog.cpp4
-rw-r--r--editor/shader_globals_editor.cpp2
51 files changed, 248 insertions, 248 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 462622fec5..c425613262 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -358,7 +358,7 @@ public:
setting = true;
undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS);
- RES prev = animation->audio_track_get_key_stream(track, key);
+ Ref<Resource> prev = animation->audio_track_get_key_stream(track, key);
undo_redo->add_do_method(animation.ptr(), "audio_track_set_key_stream", track, key, stream);
undo_redo->add_undo_method(animation.ptr(), "audio_track_set_key_stream", track, key, prev);
undo_redo->add_do_method(this, "_update_obj", animation);
@@ -992,7 +992,7 @@ public:
setting = true;
undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS);
}
- RES prev = animation->audio_track_get_key_stream(track, key);
+ Ref<Resource> prev = animation->audio_track_get_key_stream(track, key);
undo_redo->add_do_method(animation.ptr(), "audio_track_set_key_stream", track, key, stream);
undo_redo->add_undo_method(animation.ptr(), "audio_track_set_key_stream", track, key, prev);
update_obj = true;
@@ -2528,7 +2528,7 @@ bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant
return false;
}
- RES res;
+ Ref<Resource> res;
Vector<StringName> leftover_path;
Node *node = root->get_node_and_resource(animation->track_get_path(track), res, leftover_path);
@@ -2689,7 +2689,7 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const {
} break;
case Animation::TYPE_AUDIO: {
String stream_name = "null";
- RES stream = animation->audio_track_get_key_stream(track, key_idx);
+ Ref<Resource> stream = animation->audio_track_get_key_stream(track, key_idx);
if (stream.is_valid()) {
if (stream->get_path().is_resource_file()) {
stream_name = stream->get_path().get_file();
@@ -4114,7 +4114,7 @@ PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_b
return PropertyInfo();
}
- RES res;
+ Ref<Resource> res;
Vector<StringName> leftover_path;
Node *node = root->get_node_and_resource(path, res, leftover_path, true);
@@ -4410,7 +4410,7 @@ void AnimationTrackEditor::_update_tracks() {
NodePath path = animation->track_get_path(i);
if (root && root->has_node_and_resource(path)) {
- RES res;
+ Ref<Resource> res;
NodePath base_path;
Vector<StringName> leftover_path;
Node *node = root->get_node_and_resource(path, res, leftover_path, true);
@@ -5016,7 +5016,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
} break;
case Animation::TYPE_AUDIO: {
Dictionary ak;
- ak["stream"] = RES();
+ ak["stream"] = Ref<Resource>();
ak["start_offset"] = 0;
ak["end_offset"] = 0;
@@ -6015,7 +6015,7 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) {
Variant::Type valid_type = Variant::NIL;
Object *obj = nullptr;
- RES res;
+ Ref<Resource> res;
Vector<StringName> leftover_path;
Node *node = root->get_node_and_resource(p_animation->track_get_path(i), res, leftover_path);
diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp
index 936b8ca626..854c050793 100644
--- a/editor/debugger/editor_debugger_inspector.cpp
+++ b/editor/debugger/editor_debugger_inspector.cpp
@@ -157,7 +157,7 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
if (path.contains("::")) {
// built-in resource
String base_path = path.get_slice("::", 0);
- RES dependency = ResourceLoader::load(base_path);
+ Ref<Resource> dependency = ResourceLoader::load(base_path);
if (dependency.is_valid()) {
remote_dependencies.insert(dependency);
}
@@ -166,7 +166,7 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
if (pinfo.hint_string == "Script") {
if (debugObj->get_script() != var) {
- debugObj->set_script(REF());
+ debugObj->set_script(Ref<RefCounted>());
Ref<Script> script(var);
if (!script.is_null()) {
ScriptInstance *script_instance = script->placeholder_instance_create(debugObj);
diff --git a/editor/debugger/editor_debugger_inspector.h b/editor/debugger/editor_debugger_inspector.h
index 8f523bfbdc..2bf5bf3419 100644
--- a/editor/debugger/editor_debugger_inspector.h
+++ b/editor/debugger/editor_debugger_inspector.h
@@ -69,7 +69,7 @@ class EditorDebuggerInspector : public EditorInspector {
private:
ObjectID inspected_object_id;
Map<ObjectID, EditorDebuggerRemoteObject *> remote_objects;
- Set<RES> remote_dependencies;
+ Set<Ref<Resource>> remote_dependencies;
EditorDebuggerRemoteObject *variables = nullptr;
void _object_selected(ObjectID p_object);
diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h
index 36f99113ad..b4fbb90301 100644
--- a/editor/debugger/editor_debugger_node.h
+++ b/editor/debugger/editor_debugger_node.h
@@ -124,7 +124,7 @@ protected:
void _remote_object_requested(ObjectID p_id, int p_debugger);
void _save_node_requested(ObjectID p_id, const String &p_file, int p_debugger);
- void _clear_execution(REF p_script) {
+ void _clear_execution(Ref<RefCounted> p_script) {
emit_signal(SNAME("clear_execution"), p_script);
}
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index 49bf24f864..3b38ff9163 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -396,7 +396,7 @@ void EditorAutoloadSettings::_autoload_text_changed(const String p_name) {
}
Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
- RES res = ResourceLoader::load(p_path);
+ Ref<Resource> res = ResourceLoader::load(p_path);
ERR_FAIL_COND_V_MSG(res.is_null(), nullptr, "Can't autoload: " + p_path + ".");
Node *n = nullptr;
Ref<PackedScene> scn = res;
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index a58a279faa..7ce483d788 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -82,7 +82,7 @@ void EditorSelectionHistory::add_object(ObjectID p_object, const String &p_prope
RefCounted *r = Object::cast_to<RefCounted>(obj);
_Object o;
if (r) {
- o.ref = REF(r);
+ o.ref = Ref<RefCounted>(r);
}
o.object = p_object;
o.property = p_property;
diff --git a/editor/editor_data.h b/editor/editor_data.h
index 0a9f40b714..1e9b8af490 100644
--- a/editor/editor_data.h
+++ b/editor/editor_data.h
@@ -46,7 +46,7 @@ class EditorPlugin;
class EditorSelectionHistory {
// Stores the object & property (if relevant).
struct _Object {
- REF ref;
+ Ref<RefCounted> ref;
ObjectID object;
String property;
bool inspector_only = false;
diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp
index 548f05217e..76c7023b46 100644
--- a/editor/editor_folding.cpp
+++ b/editor/editor_folding.cpp
@@ -48,7 +48,7 @@ Vector<String> EditorFolding::_get_unfolds(const Object *p_object) {
return sections;
}
-void EditorFolding::save_resource_folding(const RES &p_resource, const String &p_path) {
+void EditorFolding::save_resource_folding(const Ref<Resource> &p_resource, const String &p_path) {
Ref<ConfigFile> config;
config.instantiate();
Vector<String> unfolds = _get_unfolds(p_resource.ptr());
@@ -68,7 +68,7 @@ void EditorFolding::_set_unfolds(Object *p_object, const Vector<String> &p_unfol
}
}
-void EditorFolding::load_resource_folding(RES p_resource, const String &p_path) {
+void EditorFolding::load_resource_folding(Ref<Resource> p_resource, const String &p_path) {
Ref<ConfigFile> config;
config.instantiate();
@@ -87,7 +87,7 @@ void EditorFolding::load_resource_folding(RES p_resource, const String &p_path)
_set_unfolds(p_resource.ptr(), unfolds);
}
-void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p_folds, Array &resource_folds, Array &nodes_folded, Set<RES> &resources) {
+void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p_folds, Array &resource_folds, Array &nodes_folded, Set<Ref<Resource>> &resources) {
if (p_root != p_node) {
if (!p_node->get_owner()) {
return; //not owned, bye
@@ -112,7 +112,7 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p
for (const PropertyInfo &E : plist) {
if (E.usage & PROPERTY_USAGE_EDITOR) {
if (E.type == Variant::OBJECT) {
- RES res = p_node->get(E.name);
+ Ref<Resource> res = p_node->get(E.name);
if (res.is_valid() && !resources.has(res) && !res->get_path().is_empty() && !res->get_path().is_resource_file()) {
Vector<String> res_unfolds = _get_unfolds(res.ptr());
resource_folds.push_back(res->get_path());
@@ -140,7 +140,7 @@ void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path
config.instantiate();
Array unfolds, res_unfolds;
- Set<RES> resources;
+ Set<Ref<Resource>> resources;
Array nodes_folded;
_fill_folds(p_scene, p_scene, unfolds, res_unfolds, nodes_folded, resources);
@@ -193,9 +193,9 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) {
for (int i = 0; i < res_unfolds.size(); i += 2) {
String path2 = res_unfolds[i];
- RES res;
+ Ref<Resource> res;
if (ResourceCache::has(path2)) {
- res = RES(ResourceCache::get(path2));
+ res = Ref<Resource>(ResourceCache::get(path2));
}
if (res.is_null()) {
continue;
@@ -220,7 +220,7 @@ bool EditorFolding::has_folding_data(const String &p_path) {
return FileAccess::exists(file);
}
-void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) {
+void EditorFolding::_do_object_unfolds(Object *p_object, Set<Ref<Resource>> &resources) {
List<PropertyInfo> plist;
p_object->get_property_list(&plist);
String group_base;
@@ -261,7 +261,7 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) {
}
if (E.type == Variant::OBJECT) {
- RES res = p_object->get(E.name);
+ Ref<Resource> res = p_object->get(E.name);
if (res.is_valid() && !resources.has(res) && !res->get_path().is_empty() && !res->get_path().is_resource_file()) {
resources.insert(res);
_do_object_unfolds(res.ptr(), resources);
@@ -275,7 +275,7 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) {
}
}
-void EditorFolding::_do_node_unfolds(Node *p_root, Node *p_node, Set<RES> &resources) {
+void EditorFolding::_do_node_unfolds(Node *p_root, Node *p_node, Set<Ref<Resource>> &resources) {
if (p_root != p_node) {
if (!p_node->get_owner()) {
return; //not owned, bye
@@ -293,7 +293,7 @@ void EditorFolding::_do_node_unfolds(Node *p_root, Node *p_node, Set<RES> &resou
}
void EditorFolding::unfold_scene(Node *p_scene) {
- Set<RES> resources;
+ Set<Ref<Resource>> resources;
_do_node_unfolds(p_scene, p_scene, resources);
}
diff --git a/editor/editor_folding.h b/editor/editor_folding.h
index 442d710d71..86f4643ed8 100644
--- a/editor/editor_folding.h
+++ b/editor/editor_folding.h
@@ -37,14 +37,14 @@ class EditorFolding {
Vector<String> _get_unfolds(const Object *p_object);
void _set_unfolds(Object *p_object, const Vector<String> &p_unfolds);
- void _fill_folds(const Node *p_root, const Node *p_node, Array &p_folds, Array &resource_folds, Array &nodes_folded, Set<RES> &resources);
+ void _fill_folds(const Node *p_root, const Node *p_node, Array &p_folds, Array &resource_folds, Array &nodes_folded, Set<Ref<Resource>> &resources);
- void _do_object_unfolds(Object *p_object, Set<RES> &resources);
- void _do_node_unfolds(Node *p_root, Node *p_node, Set<RES> &resources);
+ void _do_object_unfolds(Object *p_object, Set<Ref<Resource>> &resources);
+ void _do_node_unfolds(Node *p_root, Node *p_node, Set<Ref<Resource>> &resources);
public:
- void save_resource_folding(const RES &p_resource, const String &p_path);
- void load_resource_folding(RES p_resource, const String &p_path);
+ void save_resource_folding(const Ref<Resource> &p_resource, const String &p_path);
+ void load_resource_folding(Ref<Resource> p_resource, const String &p_path);
void save_scene_folding(const Node *p_scene, const String &p_path);
void load_scene_folding(Node *p_scene, const String &p_path);
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 9a30c6a1e3..076e5e3731 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -3472,7 +3472,7 @@ void EditorInspector::_object_id_selected(const String &p_path, ObjectID p_id) {
emit_signal(SNAME("object_id_selected"), p_id);
}
-void EditorInspector::_resource_selected(const String &p_path, RES p_resource) {
+void EditorInspector::_resource_selected(const String &p_path, Ref<Resource> p_resource) {
emit_signal(SNAME("resource_selected"), p_resource, p_path);
}
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index c5bcbe0725..75536a5a24 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -490,7 +490,7 @@ class EditorInspector : public ScrollContainer {
void _property_checked(const String &p_path, bool p_checked);
void _property_pinned(const String &p_path, bool p_pinned);
- void _resource_selected(const String &p_path, RES p_resource);
+ void _resource_selected(const String &p_path, Ref<Resource> p_resource);
void _property_selected(const String &p_path, int p_focusable);
void _object_id_selected(const String &p_path, ObjectID p_id);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 20128b3436..f4caa29a47 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1178,7 +1178,7 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d
Error err;
- RES res;
+ Ref<Resource> res;
if (ResourceLoader::exists(p_resource, "")) {
res = ResourceLoader::load(p_resource, "", ResourceFormatLoader::CACHE_MODE_REUSE, &err);
} else if (textfile_extensions.has(p_resource.get_extension())) {
@@ -1420,7 +1420,7 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) {
ERR_FAIL_COND_MSG(err != OK, "Cannot save config file to '" + path + "'.");
}
-bool EditorNode::_find_and_save_resource(RES p_res, Map<RES, bool> &processed, int32_t flags) {
+bool EditorNode::_find_and_save_resource(Ref<Resource> p_res, Map<Ref<Resource>, bool> &processed, int32_t flags) {
if (p_res.is_null()) {
return false;
}
@@ -1446,7 +1446,7 @@ bool EditorNode::_find_and_save_resource(RES p_res, Map<RES, bool> &processed, i
}
}
-bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> &processed, int32_t flags) {
+bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<Ref<Resource>, bool> &processed, int32_t flags) {
bool ret_changed = false;
List<PropertyInfo> pi;
obj->get_property_list(&pi);
@@ -1457,7 +1457,7 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool>
switch (E.type) {
case Variant::OBJECT: {
- RES res = obj->get(E.name);
+ Ref<Resource> res = obj->get(E.name);
if (_find_and_save_resource(res, processed, flags)) {
ret_changed = true;
@@ -1469,7 +1469,7 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool>
int len = varray.size();
for (int i = 0; i < len; i++) {
const Variant &v = varray.get(i);
- RES res = v;
+ Ref<Resource> res = v;
if (_find_and_save_resource(res, processed, flags)) {
ret_changed = true;
}
@@ -1482,7 +1482,7 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool>
d.get_key_list(&keys);
for (const Variant &F : keys) {
Variant v = d[F];
- RES res = v;
+ Ref<Resource> res = v;
if (_find_and_save_resource(res, processed, flags)) {
ret_changed = true;
}
@@ -1496,7 +1496,7 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool>
return ret_changed;
}
-void EditorNode::_save_edited_subresources(Node *scene, Map<RES, bool> &processed, int32_t flags) {
+void EditorNode::_save_edited_subresources(Node *scene, Map<Ref<Resource>, bool> &processed, int32_t flags) {
_find_and_save_edited_subresources(scene, processed, flags);
for (int i = 0; i < scene->get_child_count(); i++) {
@@ -1637,7 +1637,7 @@ static bool _find_edited_resources(const Ref<Resource> &p_resource, Set<Ref<Reso
for (const PropertyInfo &E : plist) {
if (E.type == Variant::OBJECT && E.usage & PROPERTY_USAGE_STORAGE && !(E.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT)) {
- RES res = p_resource->get(E.name);
+ Ref<Resource> res = p_resource->get(E.name);
if (res.is_null()) {
continue;
}
@@ -2043,7 +2043,7 @@ bool EditorNode::item_has_editor(Object *p_object) {
return editor_data.get_subeditors(p_object).size() > 0;
}
-void EditorNode::edit_item_resource(RES p_resource) {
+void EditorNode::edit_item_resource(Ref<Resource> p_resource) {
edit_item(p_resource.ptr());
}
@@ -2128,7 +2128,7 @@ void EditorNode::_save_default_environment() {
Ref<Environment> fallback = get_tree()->get_root()->get_world_3d()->get_fallback_environment();
if (fallback.is_valid() && fallback->get_path().is_resource_file()) {
- Map<RES, bool> processed;
+ Map<Ref<Resource>, bool> processed;
_find_and_save_edited_subresources(fallback.ptr(), processed, 0);
save_resource_in_path(fallback, fallback->get_path());
}
@@ -2166,7 +2166,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) {
ObjectID current = editor_history.get_current();
Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr;
- RES res = Object::cast_to<Resource>(current_obj);
+ Ref<Resource> res = Object::cast_to<Resource>(current_obj);
if (p_skip_foreign && res.is_valid()) {
if (res->get_path().find("::") > -1 && res->get_path().get_slice("::", 0) != editor_data.get_scene_path(get_current_tab())) {
// Trying to edit resource that belongs to another scene; abort.
@@ -3762,7 +3762,7 @@ void EditorNode::open_request(const String &p_path) {
load_scene(p_path); // As it will be opened in separate tab.
}
-void EditorNode::edit_foreign_resource(RES p_resource) {
+void EditorNode::edit_foreign_resource(Ref<Resource> p_resource) {
load_scene(p_resource->get_path().get_slice("::", 0));
InspectorDock::get_singleton()->call_deferred("edit_resource", p_resource);
}
@@ -5699,7 +5699,7 @@ void EditorNode::_rendering_driver_selected(int p_which) {
_update_rendering_driver_color();
}
-void EditorNode::_resource_saved(RES p_resource, const String &p_path) {
+void EditorNode::_resource_saved(Ref<Resource> p_resource, const String &p_path) {
if (EditorFileSystem::get_singleton()) {
EditorFileSystem::get_singleton()->update_file(p_path);
}
@@ -5707,7 +5707,7 @@ void EditorNode::_resource_saved(RES p_resource, const String &p_path) {
singleton->editor_folding.save_resource_folding(p_resource, p_path);
}
-void EditorNode::_resource_loaded(RES p_resource, const String &p_path) {
+void EditorNode::_resource_loaded(Ref<Resource> p_resource, const String &p_path) {
singleton->editor_folding.load_resource_folding(p_resource, p_path);
}
@@ -5905,7 +5905,7 @@ EditorNode::EditorNode() {
// Only if no touchscreen ui hint, disable emulation just in case.
id->set_emulate_touch_from_mouse(false);
}
- DisplayServer::get_singleton()->cursor_set_custom_image(RES());
+ DisplayServer::get_singleton()->cursor_set_custom_image(Ref<Resource>());
}
singleton = this;
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 0d1ca3a42d..bcbb4d734a 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -503,8 +503,8 @@ private:
static void _file_access_close_error_notify(const String &p_str);
static void _print_handler(void *p_this, const String &p_string, bool p_error);
- static void _resource_saved(RES p_resource, const String &p_path);
- static void _resource_loaded(RES p_resource, const String &p_path);
+ static void _resource_saved(Ref<Resource> p_resource, const String &p_path);
+ static void _resource_loaded(Ref<Resource> p_resource, const String &p_path);
void _build_icon_type_cache();
@@ -593,9 +593,9 @@ private:
void _remove_edited_scene(bool p_change_tab = true);
void _remove_scene(int index, bool p_change_tab = true);
- bool _find_and_save_resource(RES p_res, Map<RES, bool> &processed, int32_t flags);
- bool _find_and_save_edited_subresources(Object *obj, Map<RES, bool> &processed, int32_t flags);
- void _save_edited_subresources(Node *scene, Map<RES, bool> &processed, int32_t flags);
+ bool _find_and_save_resource(Ref<Resource> p_res, Map<Ref<Resource>, bool> &processed, int32_t flags);
+ bool _find_and_save_edited_subresources(Object *obj, Map<Ref<Resource>, bool> &processed, int32_t flags);
+ void _save_edited_subresources(Node *scene, Map<Ref<Resource>, bool> &processed, int32_t flags);
void _mark_unsaved_scenes();
void _find_node_types(Node *p_node, int &count_2d, int &count_3d);
@@ -755,14 +755,14 @@ public:
void push_item(Object *p_object, const String &p_property = "", bool p_inspector_only = false);
void edit_item(Object *p_object);
- void edit_item_resource(RES p_resource);
+ void edit_item_resource(Ref<Resource> p_resource);
bool item_has_editor(Object *p_object);
void hide_top_editors();
void select_editor_by_name(const String &p_name);
void open_request(const String &p_path);
- void edit_foreign_resource(RES p_resource);
+ void edit_foreign_resource(Ref<Resource> p_resource);
bool is_changing_scene() const;
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index d8fe545b25..9541033fe8 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -2974,7 +2974,7 @@ void EditorPropertyResource::_set_read_only(bool p_read_only) {
resource_picker->set_editable(!p_read_only);
};
-void EditorPropertyResource::_resource_selected(const RES &p_resource, bool p_edit) {
+void EditorPropertyResource::_resource_selected(const Ref<Resource> &p_resource, bool p_edit) {
if (p_resource->is_built_in() && !p_resource->get_path().is_empty()) {
String parent = p_resource->get_path().get_slice("::", 0);
List<String> extensions;
@@ -2996,7 +2996,7 @@ void EditorPropertyResource::_resource_selected(const RES &p_resource, bool p_ed
}
}
-void EditorPropertyResource::_resource_changed(const RES &p_resource) {
+void EditorPropertyResource::_resource_changed(const Ref<Resource> &p_resource) {
// Make visual script the correct type.
Ref<Script> s = p_resource;
if (get_edited_object() && s.is_valid()) {
@@ -3009,14 +3009,14 @@ void EditorPropertyResource::_resource_changed(const RES &p_resource) {
Resource *r = Object::cast_to<Resource>(get_edited_object());
if (r && r->get_path().is_resource_file()) {
EditorNode::get_singleton()->show_warning(TTR("Can't create a ViewportTexture on resources saved as a file.\nResource needs to belong to a scene."));
- emit_changed(get_edited_property(), RES());
+ emit_changed(get_edited_property(), Ref<Resource>());
update_property();
return;
}
if (r && !r->is_local_to_scene()) {
EditorNode::get_singleton()->show_warning(TTR("Can't create a ViewportTexture on this resource because it's not set as local to scene.\nPlease switch on the 'local to scene' property on it (and all resources containing it up to a node)."));
- emit_changed(get_edited_property(), RES());
+ emit_changed(get_edited_property(), Ref<Resource>());
update_property();
return;
}
@@ -3051,7 +3051,7 @@ void EditorPropertyResource::_sub_inspector_property_keyed(const String &p_prope
emit_signalp(SNAME("property_keyed_with_value"), argp, 3);
}
-void EditorPropertyResource::_sub_inspector_resource_selected(const RES &p_resource, const String &p_property) {
+void EditorPropertyResource::_sub_inspector_resource_selected(const Ref<Resource> &p_resource, const String &p_property) {
emit_signal(SNAME("resource_selected"), String(get_edited_property()) + ":" + p_property, p_resource);
}
@@ -3060,7 +3060,7 @@ void EditorPropertyResource::_sub_inspector_object_id_selected(int p_id) {
}
void EditorPropertyResource::_open_editor_pressed() {
- RES res = get_edited_object()->get(get_edited_property());
+ Ref<Resource> res = get_edited_object()->get(get_edited_property());
if (res.is_valid()) {
// May clear the editor so do it deferred.
EditorNode::get_singleton()->call_deferred(SNAME("edit_item_resource"), res);
@@ -3072,7 +3072,7 @@ void EditorPropertyResource::_fold_other_editors(Object *p_self) {
return;
}
- RES res = get_edited_object()->get(get_edited_property());
+ Ref<Resource> res = get_edited_object()->get(get_edited_property());
if (!res.is_valid()) {
return;
}
@@ -3218,7 +3218,7 @@ void EditorPropertyResource::setup(Object *p_object, const String &p_path, const
}
void EditorPropertyResource::update_property() {
- RES res = get_edited_object()->get(get_edited_property());
+ Ref<Resource> res = get_edited_object()->get(get_edited_property());
if (use_sub_inspector) {
if (res.is_valid() != resource_picker->is_toggle_mode()) {
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index 1f40a7fe7b..ebac984bbd 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -724,13 +724,13 @@ class EditorPropertyResource : public EditorProperty {
bool updating_theme = false;
bool opened_editor = false;
- void _resource_selected(const RES &p_resource, bool p_edit);
- void _resource_changed(const RES &p_resource);
+ void _resource_selected(const Ref<Resource> &p_resource, bool p_edit);
+ void _resource_changed(const Ref<Resource> &p_resource);
void _viewport_selected(const NodePath &p_path);
void _sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool p_advance);
- void _sub_inspector_resource_selected(const RES &p_resource, const String &p_property);
+ void _sub_inspector_resource_selected(const Ref<Resource> &p_resource, const String &p_property);
void _sub_inspector_object_id_selected(int p_id);
void _open_editor_pressed();
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index ffbe50285c..85f5ed848c 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -455,7 +455,7 @@ void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_d
for (int i = 0; i < files.size(); i++) {
String file = files[i];
- RES res = ResourceLoader::load(file);
+ Ref<Resource> res = ResourceLoader::load(file);
if (res.is_valid()) {
array.call("push_back", res);
}
diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp
index 3c68a715c3..3158c03dcc 100644
--- a/editor/editor_resource_picker.cpp
+++ b/editor/editor_resource_picker.cpp
@@ -50,7 +50,7 @@ void EditorResourcePicker::_update_resource() {
preview_rect->set_texture(Ref<Texture2D>());
assign_button->set_custom_minimum_size(Size2(1, 1));
- if (edited_resource == RES()) {
+ if (edited_resource == Ref<Resource>()) {
assign_button->set_icon(Ref<Texture2D>());
assign_button->set_text(TTR("[empty]"));
assign_button->set_tooltip("");
@@ -117,7 +117,7 @@ void EditorResourcePicker::_resource_selected() {
}
void EditorResourcePicker::_file_selected(const String &p_path) {
- RES loaded_resource = ResourceLoader::load(p_path);
+ Ref<Resource> loaded_resource = ResourceLoader::load(p_path);
ERR_FAIL_COND_MSG(loaded_resource.is_null(), "Cannot load resource from path '" + p_path + "'.");
if (!base_type.is_empty()) {
@@ -184,7 +184,7 @@ void EditorResourcePicker::_update_menu_items() {
}
// Add options to copy/paste resource.
- RES cb = EditorSettings::get_singleton()->get_resource_clipboard();
+ Ref<Resource> cb = EditorSettings::get_singleton()->get_resource_clipboard();
bool paste_valid = false;
if (cb.is_valid()) {
if (base_type.is_empty()) {
@@ -278,7 +278,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
} break;
case OBJ_MENU_CLEAR: {
- edited_resource = RES();
+ edited_resource = Ref<Resource>();
emit_signal(SNAME("resource_changed"), edited_resource);
_update_resource();
} break;
@@ -391,7 +391,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
EditorNode::get_editor_data().instantiate_object_properties(obj);
- edited_resource = RES(resp);
+ edited_resource = Ref<Resource>(resp);
emit_signal(SNAME("resource_changed"), edited_resource);
_update_resource();
} break;
@@ -809,9 +809,9 @@ Vector<String> EditorResourcePicker::get_allowed_types() const {
return types;
}
-void EditorResourcePicker::set_edited_resource(RES p_resource) {
+void EditorResourcePicker::set_edited_resource(Ref<Resource> p_resource) {
if (!p_resource.is_valid()) {
- edited_resource = RES();
+ edited_resource = Ref<Resource>();
_update_resource();
return;
}
@@ -837,7 +837,7 @@ void EditorResourcePicker::set_edited_resource(RES p_resource) {
_update_resource();
}
-RES EditorResourcePicker::get_edited_resource() {
+Ref<Resource> EditorResourcePicker::get_edited_resource() {
return edited_resource;
}
diff --git a/editor/editor_resource_picker.h b/editor/editor_resource_picker.h
index cd7e507984..e63280e3b6 100644
--- a/editor/editor_resource_picker.h
+++ b/editor/editor_resource_picker.h
@@ -45,7 +45,7 @@ class EditorResourcePicker : public HBoxContainer {
static HashMap<StringName, List<StringName>> allowed_types_cache;
String base_type;
- RES edited_resource;
+ Ref<Resource> edited_resource;
bool editable = true;
bool dropping = false;
@@ -113,8 +113,8 @@ public:
String get_base_type() const;
Vector<String> get_allowed_types() const;
- void set_edited_resource(RES p_resource);
- RES get_edited_resource();
+ void set_edited_resource(Ref<Resource> p_resource);
+ Ref<Resource> get_edited_resource();
void set_toggle_mode(bool p_enable);
bool is_toggle_mode() const;
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 8541918e88..6d5b20e591 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -48,7 +48,7 @@ bool EditorResourcePreviewGenerator::handles(const String &p_type) const {
ERR_FAIL_V_MSG(false, "EditorResourcePreviewGenerator::_handles needs to be overridden.");
}
-Ref<Texture2D> EditorResourcePreviewGenerator::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorResourcePreviewGenerator::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
Ref<Texture2D> preview;
if (GDVIRTUAL_CALL(_generate, p_from, p_size, preview)) {
return preview;
@@ -62,7 +62,7 @@ Ref<Texture2D> EditorResourcePreviewGenerator::generate_from_path(const String &
return preview;
}
- RES res = ResourceLoader::load(p_path);
+ Ref<Resource> res = ResourceLoader::load(p_path);
if (!res.is_valid()) {
return res;
}
diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h
index 938902a6ad..769340c36f 100644
--- a/editor/editor_resource_preview.h
+++ b/editor/editor_resource_preview.h
@@ -44,14 +44,14 @@ protected:
static void _bind_methods();
GDVIRTUAL1RC(bool, _handles, String)
- GDVIRTUAL2RC(Ref<Texture2D>, _generate, RES, Vector2i)
+ GDVIRTUAL2RC(Ref<Texture2D>, _generate, Ref<Resource>, Vector2i)
GDVIRTUAL2RC(Ref<Texture2D>, _generate_from_path, String, Vector2i)
GDVIRTUAL0RC(bool, _generate_small_preview_automatically)
GDVIRTUAL0RC(bool, _can_generate_small_preview)
public:
virtual bool handles(const String &p_type) const;
- virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const;
virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const;
virtual bool generate_small_preview_automatically() const;
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index e08e7343ba..41356c1d56 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -2080,7 +2080,7 @@ void FileSystemDock::_resource_created() {
}
EditorNode::get_singleton()->push_item(r);
- EditorNode::get_singleton()->save_resource_as(RES(r), fpath);
+ EditorNode::get_singleton()->save_resource_as(Ref<Resource>(r), fpath);
}
void FileSystemDock::_search_changed(const String &p_text, const Control *p_from) {
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index bdb0c3c493..34079d0a4b 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -181,7 +181,7 @@ Variant EditorScenePostImportPlugin::get_internal_option_update_view_required(In
return ret;
}
-void EditorScenePostImportPlugin::internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, RES p_resource, const Dictionary &p_options) {
+void EditorScenePostImportPlugin::internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, Ref<Resource> p_resource, const Dictionary &p_options) {
current_options_dict = &p_options;
GDVIRTUAL_CALL(_internal_process, p_category, p_base_scene, p_node, p_resource);
current_options_dict = nullptr;
@@ -736,7 +736,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
{
ObjectID node_id = p_node->get_instance_id();
for (int i = 0; i < post_importer_plugins.size(); i++) {
- post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_NODE, p_root, p_node, RES(), node_settings);
+ post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_NODE, p_root, p_node, Ref<Resource>(), node_settings);
if (ObjectDB::get_instance(node_id) == nullptr) { //may have been erased, so do not continue
break;
}
@@ -746,7 +746,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
if (Object::cast_to<ImporterMeshInstance3D>(p_node)) {
ObjectID node_id = p_node->get_instance_id();
for (int i = 0; i < post_importer_plugins.size(); i++) {
- post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE, p_root, p_node, RES(), node_settings);
+ post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE, p_root, p_node, Ref<Resource>(), node_settings);
if (ObjectDB::get_instance(node_id) == nullptr) { //may have been erased, so do not continue
break;
}
@@ -953,7 +953,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
}
for (int i = 0; i < post_importer_plugins.size(); i++) {
- post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE, p_root, p_node, RES(), node_settings);
+ post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE, p_root, p_node, Ref<Resource>(), node_settings);
}
bool use_optimizer = node_settings["optimizer/enabled"];
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index 368f68ae8f..ac72a8f39d 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -119,7 +119,7 @@ protected:
GDVIRTUAL1(_get_internal_import_options, int)
GDVIRTUAL3RC(Variant, _get_internal_option_visibility, int, bool, String)
GDVIRTUAL2RC(Variant, _get_internal_option_update_view_required, int, String)
- GDVIRTUAL4(_internal_process, int, Node *, Node *, RES)
+ GDVIRTUAL4(_internal_process, int, Node *, Node *, Ref<Resource>)
GDVIRTUAL1(_get_import_options, String)
GDVIRTUAL3RC(Variant, _get_option_visibility, String, bool, String)
GDVIRTUAL1(_pre_process, Node *)
@@ -136,7 +136,7 @@ public:
virtual Variant get_internal_option_visibility(InternalImportCategory p_category, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) const;
virtual Variant get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const;
- virtual void internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, RES p_resource, const Dictionary &p_options);
+ virtual void internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, Ref<Resource> p_resource, const Dictionary &p_options);
virtual void get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options);
virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) const;
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index f0fe48f4fc..a62d1af477 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -117,8 +117,8 @@ void InspectorDock::_menu_option_confirm(int p_option, bool p_confirmed) {
}
Variant v = current->get(E->get().name);
- REF ref = v;
- RES res = ref;
+ Ref<RefCounted> ref = v;
+ Ref<Resource> res = ref;
if (v.is_ref_counted() && ref.is_valid() && res.is_valid()) {
// Valid resource which would be duplicated if action is confirmed.
resource_propnames.append(E->get().name);
@@ -149,7 +149,7 @@ void InspectorDock::_menu_option_confirm(int p_option, bool p_confirmed) {
if (current) {
List<PropertyInfo> props;
current->get_property_list(&props);
- Map<RES, RES> duplicates;
+ Map<Ref<Resource>, Ref<Resource>> duplicates;
for (const PropertyInfo &prop_info : props) {
if (!(prop_info.usage & PROPERTY_USAGE_STORAGE)) {
continue;
@@ -157,9 +157,9 @@ void InspectorDock::_menu_option_confirm(int p_option, bool p_confirmed) {
Variant v = current->get(prop_info.name);
if (v.is_ref_counted()) {
- REF ref = v;
+ Ref<RefCounted> ref = v;
if (ref.is_valid()) {
- RES res = ref;
+ Ref<Resource> res = ref;
if (res.is_valid()) {
if (!duplicates.has(res)) {
duplicates[res] = res->duplicate();
@@ -231,7 +231,7 @@ void InspectorDock::_load_resource(const String &p_type) {
}
void InspectorDock::_resource_file_selected(String p_file) {
- RES res;
+ Ref<Resource> res;
if (ResourceLoader::exists(p_file, "")) {
res = ResourceLoader::load(p_file);
} else {
@@ -255,7 +255,7 @@ void InspectorDock::_save_resource(bool save_as) {
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
- RES current_res = RES(Object::cast_to<Resource>(current_obj));
+ Ref<Resource> current_res = Ref<Resource>(Object::cast_to<Resource>(current_obj));
if (save_as) {
EditorNode::get_singleton()->save_resource_as(current_res);
@@ -270,7 +270,7 @@ void InspectorDock::_unref_resource() {
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
- RES current_res = RES(Object::cast_to<Resource>(current_obj));
+ Ref<Resource> current_res = Ref<Resource>(Object::cast_to<Resource>(current_obj));
current_res->set_path("");
EditorNode::get_singleton()->edit_current();
}
@@ -281,20 +281,20 @@ void InspectorDock::_copy_resource() {
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
- RES current_res = RES(Object::cast_to<Resource>(current_obj));
+ Ref<Resource> current_res = Ref<Resource>(Object::cast_to<Resource>(current_obj));
EditorSettings::get_singleton()->set_resource_clipboard(current_res);
}
void InspectorDock::_paste_resource() {
- RES r = EditorSettings::get_singleton()->get_resource_clipboard();
+ Ref<Resource> r = EditorSettings::get_singleton()->get_resource_clipboard();
if (r.is_valid()) {
EditorNode::get_singleton()->push_item(EditorSettings::get_singleton()->get_resource_clipboard().ptr(), String());
}
}
void InspectorDock::_prepare_resource_extra_popup() {
- RES r = EditorSettings::get_singleton()->get_resource_clipboard();
+ Ref<Resource> r = EditorSettings::get_singleton()->get_resource_clipboard();
PopupMenu *popup = resource_extra_button->get_popup();
popup->set_item_disabled(popup->get_item_index(RESOURCE_EDIT_CLIPBOARD), r.is_null());
}
@@ -370,12 +370,12 @@ void InspectorDock::_resource_created() {
EditorNode::get_singleton()->push_item(r);
}
-void InspectorDock::_resource_selected(const RES &p_res, const String &p_property) {
+void InspectorDock::_resource_selected(const Ref<Resource> &p_res, const String &p_property) {
if (p_res.is_null()) {
return;
}
- RES r = p_res;
+ Ref<Resource> r = p_res;
EditorNode::get_singleton()->push_item(r.operator->(), p_property);
}
diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h
index 86733c992d..1f2d8afb7d 100644
--- a/editor/inspector_dock.h
+++ b/editor/inspector_dock.h
@@ -118,7 +118,7 @@ class InspectorDock : public VBoxContainer {
void _warning_pressed();
void _resource_created();
- void _resource_selected(const RES &p_res, const String &p_property);
+ void _resource_selected(const Ref<Resource> &p_res, const String &p_property);
void _edit_forward();
void _edit_back();
void _menu_collapseall();
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 09cca41bc9..5d1e9705d8 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -5393,7 +5393,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
bool add_preview = false;
for (int i = 0; i < files.size(); i++) {
String path = files[i];
- RES res = ResourceLoader::load(path);
+ Ref<Resource> res = ResourceLoader::load(path);
ERR_FAIL_COND(res.is_null());
Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
@@ -5588,7 +5588,7 @@ void CanvasItemEditorViewport::_perform_drop_data() {
for (int i = 0; i < selected_files.size(); i++) {
String path = selected_files[i];
- RES res = ResourceLoader::load(path);
+ Ref<Resource> res = ResourceLoader::load(path);
if (res.is_null()) {
continue;
}
@@ -5643,7 +5643,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
for (int i = 0; i < files.size(); i++) {
// Check if dragged files with texture or scene extension can be created at least once.
if (texture_extensions.find(files[i].get_extension()) || scene_extensions.find(files[i].get_extension())) {
- RES res = ResourceLoader::load(files[i]);
+ Ref<Resource> res = ResourceLoader::load(files[i]);
if (res.is_null()) {
continue;
}
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index a160ca463b..80fc1c64d0 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -79,7 +79,7 @@ bool EditorTexturePreviewPlugin::generate_small_preview_automatically() const {
return true;
}
-Ref<Texture2D> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorTexturePreviewPlugin::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
Ref<Image> img;
Ref<AtlasTexture> atex = p_from;
if (atex.is_valid()) {
@@ -145,7 +145,7 @@ bool EditorImagePreviewPlugin::handles(const String &p_type) const {
return p_type == "Image";
}
-Ref<Texture2D> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorImagePreviewPlugin::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
Ref<Image> img = p_from;
if (img.is_null() || img->is_empty()) {
@@ -194,7 +194,7 @@ bool EditorBitmapPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "BitMap");
}
-Ref<Texture2D> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorBitmapPreviewPlugin::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
Ref<BitMap> bm = p_from;
if (bm->get_size() == Size2()) {
@@ -261,7 +261,7 @@ bool EditorPackedScenePreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "PackedScene");
}
-Ref<Texture2D> EditorPackedScenePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorPackedScenePreviewPlugin::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
return generate_from_path(p_from->get_path(), p_size);
}
@@ -316,7 +316,7 @@ bool EditorMaterialPreviewPlugin::generate_small_preview_automatically() const {
return true;
}
-Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
Ref<Material> material = p_from;
ERR_FAIL_COND_V(material.is_null(), Ref<Texture2D>());
@@ -467,7 +467,7 @@ bool EditorScriptPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "Script");
}
-Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorScriptPreviewPlugin::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
Ref<Script> scr = p_from;
if (scr.is_null()) {
return Ref<Texture2D>();
@@ -609,7 +609,7 @@ bool EditorAudioStreamPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "AudioStream");
}
-Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
Ref<AudioStream> stream = p_from;
ERR_FAIL_COND_V(stream.is_null(), Ref<Texture2D>());
@@ -703,7 +703,7 @@ bool EditorMeshPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "Mesh"); // Any mesh.
}
-Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorMeshPreviewPlugin::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
Ref<Mesh> mesh = p_from;
ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture2D>());
@@ -816,7 +816,7 @@ bool EditorFontPreviewPlugin::handles(const String &p_type) const {
}
Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
- RES res = ResourceLoader::load(p_path);
+ Ref<Resource> res = ResourceLoader::load(p_path);
ERR_FAIL_COND_V(res.is_null(), Ref<Texture2D>());
Ref<Font> sampled_font;
if (res->is_class("Font")) {
@@ -877,7 +877,7 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path,
return ptex;
}
-Ref<Texture2D> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorFontPreviewPlugin::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
String path = p_from->get_path();
if (!FileAccess::exists(path)) {
return Ref<Texture2D>();
@@ -917,7 +917,7 @@ bool EditorGradientPreviewPlugin::generate_small_preview_automatically() const {
return true;
}
-Ref<Texture2D> EditorGradientPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorGradientPreviewPlugin::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
Ref<Gradient> gradient = p_from;
if (gradient.is_valid()) {
Ref<GradientTexture1D> ptex;
diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h
index 73eb90dd86..f548683b70 100644
--- a/editor/plugins/editor_preview_plugins.h
+++ b/editor/plugins/editor_preview_plugins.h
@@ -42,7 +42,7 @@ class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const override;
virtual bool generate_small_preview_automatically() const override;
- virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const override;
+ virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const override;
EditorTexturePreviewPlugin();
};
@@ -53,7 +53,7 @@ class EditorImagePreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const override;
virtual bool generate_small_preview_automatically() const override;
- virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const override;
+ virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const override;
EditorImagePreviewPlugin();
};
@@ -64,7 +64,7 @@ class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const override;
virtual bool generate_small_preview_automatically() const override;
- virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const override;
+ virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const override;
EditorBitmapPreviewPlugin();
};
@@ -72,7 +72,7 @@ public:
class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
- virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const;
virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const;
EditorPackedScenePreviewPlugin();
@@ -99,7 +99,7 @@ class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const override;
virtual bool generate_small_preview_automatically() const override;
- virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const override;
+ virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const override;
EditorMaterialPreviewPlugin();
~EditorMaterialPreviewPlugin();
@@ -108,7 +108,7 @@ public:
class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
- virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const;
EditorScriptPreviewPlugin();
};
@@ -116,7 +116,7 @@ public:
class EditorAudioStreamPreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
- virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const;
EditorAudioStreamPreviewPlugin();
};
@@ -140,7 +140,7 @@ class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const override;
- virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const override;
+ virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const override;
EditorMeshPreviewPlugin();
~EditorMeshPreviewPlugin();
@@ -160,7 +160,7 @@ class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const override;
- virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const override;
+ virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const override;
virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const override;
EditorFontPreviewPlugin();
@@ -177,7 +177,7 @@ class EditorTileMapPatternPreviewPlugin : public EditorResourcePreviewGenerator
public:
virtual bool handles(const String &p_type) const override;
- virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const override;
+ virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const override;
EditorTileMapPatternPreviewPlugin();
~EditorTileMapPatternPreviewPlugin();
@@ -189,7 +189,7 @@ class EditorGradientPreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const override;
virtual bool generate_small_preview_automatically() const override;
- virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const override;
+ virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const override;
EditorGradientPreviewPlugin();
};
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp
index 4fbc8188b9..e7ef65c32b 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.cpp
+++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp
@@ -96,7 +96,7 @@ void LightOccluder2DEditor::_create_resource() {
undo_redo->create_action(TTR("Create Occluder Polygon"));
undo_redo->add_do_method(node, "set_occluder_polygon", Ref<OccluderPolygon2D>(memnew(OccluderPolygon2D)));
- undo_redo->add_undo_method(node, "set_occluder_polygon", Variant(REF()));
+ undo_redo->add_undo_method(node, "set_occluder_polygon", Variant(Ref<RefCounted>()));
undo_redo->commit_action();
_menu_option(MODE_CREATE);
diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp
index 17eaf45bb5..8f3553b8cf 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.cpp
+++ b/editor/plugins/navigation_polygon_editor_plugin.cpp
@@ -106,7 +106,7 @@ void NavigationPolygonEditor::_create_resource() {
undo_redo->create_action(TTR("Create Navigation Polygon"));
undo_redo->add_do_method(node, "set_navigation_polygon", Ref<NavigationPolygon>(memnew(NavigationPolygon)));
- undo_redo->add_undo_method(node, "set_navigation_polygon", Variant(REF()));
+ undo_redo->add_undo_method(node, "set_navigation_polygon", Variant(Ref<RefCounted>()));
undo_redo->commit_action();
_menu_option(MODE_CREATE);
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 7e01593bda..344efb4f13 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -2990,7 +2990,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
bool current = view_menu->get_popup()->is_item_checked(idx);
current = !current;
if (current) {
- camera->set_environment(RES());
+ camera->set_environment(Ref<Resource>());
} else {
camera->set_environment(Node3DEditor::get_singleton()->get_viewport_environment());
}
@@ -3767,7 +3767,7 @@ Node *Node3DEditorViewport::_sanitize_preview_node(Node *p_node) const {
void Node3DEditorViewport::_create_preview(const Vector<String> &files) const {
for (int i = 0; i < files.size(); i++) {
String path = files[i];
- RES res = ResourceLoader::load(path);
+ Ref<Resource> res = ResourceLoader::load(path);
ERR_CONTINUE(res.is_null());
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
Ref<Mesh> mesh = Ref<Mesh>(Object::cast_to<Mesh>(*res));
@@ -3818,7 +3818,7 @@ bool Node3DEditorViewport::_cyclical_dependency_exists(const String &p_target_sc
}
bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Point2 &p_point) {
- RES res = ResourceLoader::load(path);
+ Ref<Resource> res = ResourceLoader::load(path);
ERR_FAIL_COND_V(res.is_null(), false);
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
@@ -3908,7 +3908,7 @@ void Node3DEditorViewport::_perform_drop_data() {
for (int i = 0; i < selected_files.size(); i++) {
String path = selected_files[i];
- RES res = ResourceLoader::load(path);
+ Ref<Resource> res = ResourceLoader::load(path);
if (res.is_null()) {
continue;
}
@@ -3951,7 +3951,7 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant
for (int i = 0; i < files.size(); i++) {
// Check if dragged files with mesh or scene extension can be created at least once.
if (mesh_extensions.find(files[i].get_extension()) || scene_extensions.find(files[i].get_extension())) {
- RES res = ResourceLoader::load(files[i]);
+ Ref<Resource> res = ResourceLoader::load(files[i]);
if (res.is_null()) {
continue;
}
diff --git a/editor/plugins/packed_scene_translation_parser_plugin.cpp b/editor/plugins/packed_scene_translation_parser_plugin.cpp
index 9a8584f4a2..8d083d28b2 100644
--- a/editor/plugins/packed_scene_translation_parser_plugin.cpp
+++ b/editor/plugins/packed_scene_translation_parser_plugin.cpp
@@ -43,7 +43,7 @@ Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path,
// These properties are translated with the tr() function in the C++ code when being set or updated.
Error err;
- RES loaded_res = ResourceLoader::load(p_path, "PackedScene", ResourceFormatLoader::CACHE_MODE_REUSE, &err);
+ Ref<Resource> loaded_res = ResourceLoader::load(p_path, "PackedScene", ResourceFormatLoader::CACHE_MODE_REUSE, &err);
if (err) {
ERR_PRINT("Failed to load " + p_path);
return err;
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index eafc53c72b..71d31aa1d7 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -50,7 +50,7 @@ void ResourcePreloaderEditor::_files_load_request(const Vector<String> &p_paths)
for (int i = 0; i < p_paths.size(); i++) {
String path = p_paths[i];
- RES resource;
+ Ref<Resource> resource;
resource = ResourceLoader::load(path);
if (resource.is_null()) {
@@ -113,7 +113,7 @@ void ResourcePreloaderEditor::_item_edited() {
return;
}
- RES samp = preloader->get_resource(old_name);
+ Ref<Resource> samp = preloader->get_resource(old_name);
undo_redo->create_action(TTR("Rename Resource"));
undo_redo->add_do_method(preloader, "remove_resource", old_name);
undo_redo->add_do_method(preloader, "add_resource", new_name, samp);
@@ -135,7 +135,7 @@ void ResourcePreloaderEditor::_remove_resource(const String &p_to_remove) {
}
void ResourcePreloaderEditor::_paste_pressed() {
- RES r = EditorSettings::get_singleton()->get_resource_clipboard();
+ Ref<Resource> r = EditorSettings::get_singleton()->get_resource_clipboard();
if (!r.is_valid()) {
dialog->set_text(TTR("Resource clipboard is empty!"));
dialog->set_title(TTR("Error!"));
@@ -190,7 +190,7 @@ void ResourcePreloaderEditor::_update_library() {
ti->set_text(0, E);
ti->set_metadata(0, E);
- RES r = preloader->get_resource(E);
+ Ref<Resource> r = preloader->get_resource(E);
ERR_CONTINUE(r.is_null());
@@ -222,7 +222,7 @@ void ResourcePreloaderEditor::_cell_button_pressed(Object *p_item, int p_column,
EditorInterface::get_singleton()->open_scene_from_path(rpath);
} else if (p_id == BUTTON_EDIT_RESOURCE) {
- RES r = preloader->get_resource(item->get_text(0));
+ Ref<Resource> r = preloader->get_resource(item->get_text(0));
EditorInterface::get_singleton()->edit_resource(r);
} else if (p_id == BUTTON_REMOVE) {
@@ -249,7 +249,7 @@ Variant ResourcePreloaderEditor::get_drag_data_fw(const Point2 &p_point, Control
String name = ti->get_metadata(0);
- RES res = preloader->get_resource(name);
+ Ref<Resource> res = preloader->get_resource(name);
if (!res.is_valid()) {
return Variant();
}
@@ -269,7 +269,7 @@ bool ResourcePreloaderEditor::can_drop_data_fw(const Point2 &p_point, const Vari
}
if (String(d["type"]) == "resource" && d.has("resource")) {
- RES r = d["resource"];
+ Ref<Resource> r = d["resource"];
return r.is_valid();
}
@@ -294,7 +294,7 @@ void ResourcePreloaderEditor::drop_data_fw(const Point2 &p_point, const Variant
}
if (String(d["type"]) == "resource" && d.has("resource")) {
- RES r = d["resource"];
+ Ref<Resource> r = d["resource"];
if (r.is_valid()) {
String basename;
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index a4bf28625d..0d33a7bdc6 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -232,7 +232,7 @@ void ScriptEditorBase::_bind_methods() {
class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache {
struct Cache {
uint64_t time_loaded = 0;
- RES cache;
+ Ref<Resource> cache;
};
Map<String, Cache> cached;
@@ -258,7 +258,7 @@ public:
}
}
- virtual RES get_cached_resource(const String &p_path) {
+ virtual Ref<Resource> get_cached_resource(const String &p_path) {
Map<String, Cache>::Element *E = cached.find(p_path);
if (!E) {
Cache c;
@@ -428,7 +428,7 @@ void ScriptEditor::_goto_script_line2(int p_line) {
}
}
-void ScriptEditor::_goto_script_line(REF p_script, int p_line) {
+void ScriptEditor::_goto_script_line(Ref<RefCounted> p_script, int p_line) {
Ref<Script> script = Object::cast_to<Script>(*p_script);
if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
if (edit(p_script, p_line, 0)) {
@@ -444,7 +444,7 @@ void ScriptEditor::_goto_script_line(REF p_script, int p_line) {
}
}
-void ScriptEditor::_set_execution(REF p_script, int p_line) {
+void ScriptEditor::_set_execution(Ref<RefCounted> p_script, int p_line) {
Ref<Script> script = Object::cast_to<Script>(*p_script);
if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
for (int i = 0; i < tab_container->get_tab_count(); i++) {
@@ -460,7 +460,7 @@ void ScriptEditor::_set_execution(REF p_script, int p_line) {
}
}
-void ScriptEditor::_clear_execution(REF p_script) {
+void ScriptEditor::_clear_execution(Ref<RefCounted> p_script) {
Ref<Script> script = Object::cast_to<Script>(*p_script);
if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
for (int i = 0; i < tab_container->get_tab_count(); i++) {
@@ -476,7 +476,7 @@ void ScriptEditor::_clear_execution(REF p_script) {
}
}
-void ScriptEditor::_set_breakpoint(REF p_script, int p_line, bool p_enabled) {
+void ScriptEditor::_set_breakpoint(Ref<RefCounted> p_script, int p_line, bool p_enabled) {
Ref<Script> script = Object::cast_to<Script>(*p_script);
if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
// Update if open.
@@ -758,7 +758,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tselected);
if (current) {
- RES file = current->get_edited_resource();
+ Ref<Resource> file = current->get_edited_resource();
if (p_save && file.is_valid()) {
// Do not try to save internal scripts, but prompt to save in-memory
// scripts which are not saved to disk yet (have empty path).
@@ -849,7 +849,7 @@ void ScriptEditor::_close_docs_tab() {
void ScriptEditor::_copy_script_path() {
ScriptEditorBase *se = _get_current_editor();
if (se) {
- RES script = se->get_edited_resource();
+ Ref<Resource> script = se->get_edited_resource();
DisplayServer::get_singleton()->clipboard_set(script->get_path());
}
}
@@ -906,7 +906,7 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
continue;
}
- RES script = se->get_edited_resource();
+ Ref<Resource> script = se->get_edited_resource();
if (script->is_built_in()) {
continue; //internal script, who cares
@@ -947,7 +947,7 @@ void ScriptEditor::_reload_scripts() {
continue;
}
- RES edited_res = se->get_edited_resource();
+ Ref<Resource> edited_res = se->get_edited_resource();
if (edited_res->is_built_in()) {
continue; //internal script, who cares
@@ -991,7 +991,7 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) {
continue;
}
- RES script = se->get_edited_resource();
+ Ref<Resource> script = se->get_edited_resource();
if (script == p_res) {
se->tag_saved_version();
@@ -1010,7 +1010,7 @@ void ScriptEditor::_scene_saved_callback(const String &p_path) {
continue;
}
- RES edited_res = se->get_edited_resource();
+ Ref<Resource> edited_res = se->get_edited_resource();
if (!edited_res->is_built_in()) {
continue; // External script, who cares.
@@ -1039,7 +1039,7 @@ void ScriptEditor::_live_auto_reload_running_scripts() {
EditorDebuggerNode::get_singleton()->reload_scripts();
}
-bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) {
+bool ScriptEditor::_test_script_times_on_disk(Ref<Resource> p_for_script) {
disk_changed_list->clear();
TreeItem *r = disk_changed_list->create_item();
disk_changed_list->set_hide_root(true);
@@ -1051,7 +1051,7 @@ bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) {
for (int i = 0; i < tab_container->get_tab_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
if (se) {
- RES edited_res = se->get_edited_resource();
+ Ref<Resource> edited_res = se->get_edited_resource();
if (p_for_script.is_valid() && edited_res.is_valid() && p_for_script != edited_res) {
continue;
}
@@ -1117,7 +1117,7 @@ void ScriptEditor::_file_dialog_action(String p_file) {
case FILE_SAVE_AS: {
ScriptEditorBase *current = _get_current_editor();
if (current) {
- RES resource = current->get_edited_resource();
+ Ref<Resource> resource = current->get_edited_resource();
String path = ProjectSettings::get_singleton()->localize_path(p_file);
Error err = _save_text_file(resource, path);
@@ -1323,7 +1323,7 @@ void ScriptEditor::_menu_option(int p_option) {
}
}
- RES resource = current->get_edited_resource();
+ Ref<Resource> resource = current->get_edited_resource();
Ref<TextFile> text_file = resource;
Ref<Script> script = resource;
@@ -1413,7 +1413,7 @@ void ScriptEditor::_menu_option(int p_option) {
_copy_script_path();
} break;
case SHOW_IN_FILE_SYSTEM: {
- const RES script = current->get_edited_resource();
+ const Ref<Resource> script = current->get_edited_resource();
String path = script->get_path();
if (!path.is_empty()) {
if (script->is_built_in()) {
@@ -2188,7 +2188,7 @@ Ref<TextFile> ScriptEditor::_load_text_file(const String &p_path, Error *r_error
Ref<TextFile> text_res(text_file);
Error err = text_file->load_text(path);
- ERR_FAIL_COND_V_MSG(err != OK, RES(), "Cannot load text file '" + path + "'.");
+ ERR_FAIL_COND_V_MSG(err != OK, Ref<Resource>(), "Cannot load text file '" + path + "'.");
text_file->set_file_path(local_path);
text_file->set_path(local_path, true);
@@ -2230,7 +2230,7 @@ Error ScriptEditor::_save_text_file(Ref<TextFile> p_text_file, const String &p_p
return OK;
}
-bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_grab_focus) {
+bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col, bool p_grab_focus) {
if (p_resource.is_null()) {
return false;
}
@@ -2447,7 +2447,7 @@ void ScriptEditor::save_current_script() {
}
}
- RES resource = current->get_edited_resource();
+ Ref<Resource> resource = current->get_edited_resource();
Ref<TextFile> text_file = resource;
Ref<Script> script = resource;
@@ -2516,7 +2516,7 @@ void ScriptEditor::save_all_scripts() {
continue;
}
- RES edited_res = se->get_edited_resource();
+ Ref<Resource> edited_res = se->get_edited_resource();
if (edited_res.is_valid()) {
se->apply_code();
}
@@ -2589,14 +2589,14 @@ void ScriptEditor::open_text_file_create_dialog(const String &p_base_path, const
open_textfile_after_create = false;
}
-RES ScriptEditor::open_file(const String &p_file) {
+Ref<Resource> ScriptEditor::open_file(const String &p_file) {
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
if (extensions.find(p_file.get_extension())) {
Ref<Script> scr = ResourceLoader::load(p_file);
if (!scr.is_valid()) {
EditorNode::get_singleton()->show_warning(TTR("Could not load file at:") + "\n\n" + p_file, TTR("Error!"));
- return RES();
+ return Ref<Resource>();
}
edit(scr);
@@ -2607,14 +2607,14 @@ RES ScriptEditor::open_file(const String &p_file) {
Ref<TextFile> text_file = _load_text_file(p_file, &error);
if (error != OK) {
EditorNode::get_singleton()->show_warning(TTR("Could not load file at:") + "\n\n" + p_file, TTR("Error!"));
- return RES();
+ return Ref<Resource>();
}
if (text_file.is_valid()) {
edit(text_file);
return text_file;
}
- return RES();
+ return Ref<Resource>();
}
void ScriptEditor::_editor_stop() {
@@ -2980,7 +2980,7 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
continue;
}
- RES res = open_file(file);
+ Ref<Resource> res = open_file(file);
if (res.is_valid()) {
if (tab_container->get_tab_count() > num_tabs_before) {
tab_container->move_child(tab_container->get_tab_control(tab_container->get_tab_count() - 1), new_index);
@@ -3533,7 +3533,7 @@ void ScriptEditor::_on_replace_in_files_requested(String text) {
void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_number, int begin, int end) {
if (ResourceLoader::exists(fpath)) {
- RES res = ResourceLoader::load(fpath);
+ Ref<Resource> res = ResourceLoader::load(fpath);
if (fpath.get_extension() == "gdshader") {
ShaderEditorPlugin *shader_editor = Object::cast_to<ShaderEditorPlugin>(EditorNode::get_singleton()->get_editor_data().get_editor("Shader"));
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index f0e7fccdea..41b311f745 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -53,7 +53,7 @@ class EditorSyntaxHighlighter : public SyntaxHighlighter {
GDCLASS(EditorSyntaxHighlighter, SyntaxHighlighter)
private:
- REF edited_resourse;
+ Ref<RefCounted> edited_resourse;
protected:
static void _bind_methods();
@@ -65,8 +65,8 @@ public:
virtual String _get_name() const;
virtual Array _get_supported_languages() const;
- void _set_edited_resource(const RES &p_res) { edited_resourse = p_res; }
- REF _get_edited_resource() { return edited_resourse; }
+ void _set_edited_resource(const Ref<Resource> &p_res) { edited_resourse = p_res; }
+ Ref<RefCounted> _get_edited_resource() { return edited_resourse; }
virtual Ref<EditorSyntaxHighlighter> _create() const;
};
@@ -136,9 +136,9 @@ public:
virtual void set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) = 0;
virtual void apply_code() = 0;
- virtual RES get_edited_resource() const = 0;
+ virtual Ref<Resource> get_edited_resource() const = 0;
virtual Vector<String> get_functions() = 0;
- virtual void set_edited_resource(const RES &p_res) = 0;
+ virtual void set_edited_resource(const Ref<Resource> &p_res) = 0;
virtual void enable_editor() = 0;
virtual void reload_text() = 0;
virtual String get_name() = 0;
@@ -179,7 +179,7 @@ public:
ScriptEditorBase() {}
};
-typedef ScriptEditorBase *(*CreateScriptEditorFunc)(const RES &p_resource);
+typedef ScriptEditorBase *(*CreateScriptEditorFunc)(const Ref<Resource> &p_resource);
class EditorScriptCodeCompletionCache;
class FindInFilesDialog;
@@ -330,7 +330,7 @@ class ScriptEditor : public PanelContainer {
void _resave_scripts(const String &p_str);
void _reload_scripts();
- bool _test_script_times_on_disk(RES p_for_script = Ref<Resource>());
+ bool _test_script_times_on_disk(Ref<Resource> p_for_script = Ref<Resource>());
void _add_recent_script(String p_path);
void _update_recent_scripts();
@@ -377,12 +377,12 @@ class ScriptEditor : public PanelContainer {
bool convert_indent_on_save;
void _goto_script_line2(int p_line);
- void _goto_script_line(REF p_script, int p_line);
- void _set_execution(REF p_script, int p_line);
- void _clear_execution(REF p_script);
+ void _goto_script_line(Ref<RefCounted> p_script, int p_line);
+ void _set_execution(Ref<RefCounted> p_script, int p_line);
+ void _clear_execution(Ref<RefCounted> p_script);
void _breaked(bool p_breaked, bool p_can_debug);
void _script_created(Ref<Script> p_script);
- void _set_breakpoint(REF p_scrpt, int p_line, bool p_enabled);
+ void _set_breakpoint(Ref<RefCounted> p_scrpt, int p_line, bool p_enabled);
void _clear_breakpoints();
Array _get_cached_breakpoints_for_script(const String &p_path) const;
@@ -481,12 +481,12 @@ public:
void apply_scripts() const;
void open_script_create_dialog(const String &p_base_name, const String &p_base_path);
void open_text_file_create_dialog(const String &p_base_path, const String &p_base_name = "");
- RES open_file(const String &p_file);
+ Ref<Resource> open_file(const String &p_file);
void ensure_select_current();
- _FORCE_INLINE_ bool edit(const RES &p_resource, bool p_grab_focus = true) { return edit(p_resource, -1, 0, p_grab_focus); }
- bool edit(const RES &p_resource, int p_line, int p_col, bool p_grab_focus = true);
+ _FORCE_INLINE_ bool edit(const Ref<Resource> &p_resource, bool p_grab_focus = true) { return edit(p_resource, -1, 0, p_grab_focus); }
+ bool edit(const Ref<Resource> &p_resource, int p_line, int p_col, bool p_grab_focus = true);
void get_breakpoints(List<String> *p_breakpoints);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index f581d6c928..981881fb9b 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -133,11 +133,11 @@ void ScriptTextEditor::apply_code() {
code_editor->get_text_editor()->get_syntax_highlighter()->update_cache();
}
-RES ScriptTextEditor::get_edited_resource() const {
+Ref<Resource> ScriptTextEditor::get_edited_resource() const {
return script;
}
-void ScriptTextEditor::set_edited_resource(const RES &p_res) {
+void ScriptTextEditor::set_edited_resource(const Ref<Resource> &p_res) {
ERR_FAIL_COND(script.is_valid());
ERR_FAIL_COND(p_res.is_null());
@@ -1998,7 +1998,7 @@ ScriptTextEditor::~ScriptTextEditor() {
}
}
-static ScriptEditorBase *create_editor(const RES &p_resource) {
+static ScriptEditorBase *create_editor(const Ref<Resource> &p_resource) {
if (Object::cast_to<Script>(*p_resource)) {
return memnew(ScriptTextEditor);
}
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index c1c4b0af54..b3e0c28bb1 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -205,8 +205,8 @@ public:
void update_toggle_scripts_button() override;
virtual void apply_code() override;
- virtual RES get_edited_resource() const override;
- virtual void set_edited_resource(const RES &p_res) override;
+ virtual Ref<Resource> get_edited_resource() const override;
+ virtual void set_edited_resource(const Ref<Resource> &p_res) override;
virtual void enable_editor() override;
virtual Vector<String> get_functions() override;
virtual void reload_text() override;
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 29beb8be84..7b6aeb3679 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1012,7 +1012,7 @@ Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
return Variant();
}
- RES frame = frames->get_frame(edited_anim, idx);
+ Ref<Resource> frame = frames->get_frame(edited_anim, idx);
if (frame.is_null()) {
return Variant();
@@ -1036,7 +1036,7 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
}
if (String(d["type"]) == "resource" && d.has("resource")) {
- RES r = d["resource"];
+ Ref<Resource> r = d["resource"];
Ref<Texture2D> texture = r;
@@ -1080,7 +1080,7 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
int at_pos = tree->get_item_at_position(p_point, true);
if (String(d["type"]) == "resource" && d.has("resource")) {
- RES r = d["resource"];
+ Ref<Resource> r = d["resource"];
Ref<Texture2D> texture = r;
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 34f3ec73c0..97ecc234e6 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -89,11 +89,11 @@ Ref<Texture2D> TextEditor::get_theme_icon() {
return EditorNode::get_singleton()->get_object_icon(text_file.ptr(), "");
}
-RES TextEditor::get_edited_resource() const {
+Ref<Resource> TextEditor::get_edited_resource() const {
return text_file;
}
-void TextEditor::set_edited_resource(const RES &p_res) {
+void TextEditor::set_edited_resource(const Ref<Resource> &p_res) {
ERR_FAIL_COND(text_file.is_valid());
ERR_FAIL_COND(p_res.is_null());
@@ -412,7 +412,7 @@ void TextEditor::_convert_case(CodeTextEditor::CaseStyle p_case) {
code_editor->convert_case(p_case);
}
-static ScriptEditorBase *create_editor(const RES &p_resource) {
+static ScriptEditorBase *create_editor(const Ref<Resource> &p_resource) {
if (Object::cast_to<TextFile>(*p_resource)) {
return memnew(TextEditor);
}
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index d03385d79e..9b6d568382 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -109,8 +109,8 @@ public:
virtual String get_name() override;
virtual Ref<Texture2D> get_theme_icon() override;
- virtual RES get_edited_resource() const override;
- virtual void set_edited_resource(const RES &p_res) override;
+ virtual Ref<Resource> get_edited_resource() const override;
+ virtual void set_edited_resource(const Ref<Resource> &p_res) override;
virtual void enable_editor() override;
virtual void reload_text() override;
virtual void apply_code() override;
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index e17bea0f2a..87f8c4b165 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -2537,7 +2537,7 @@ void ThemeTypeEditor::_update_type_items() {
if (edited_theme->has_font(E.key(), edited_type)) {
item_editor->set_edited_resource(edited_theme->get_font(E.key(), edited_type));
} else {
- item_editor->set_edited_resource(RES());
+ item_editor->set_edited_resource(Ref<Resource>());
}
item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item));
item_editor->connect("resource_changed", callable_mp(this, &ThemeTypeEditor::_font_item_changed), varray(E.key()));
@@ -2545,7 +2545,7 @@ void ThemeTypeEditor::_update_type_items() {
if (Theme::get_default()->has_font(E.key(), edited_type)) {
item_editor->set_edited_resource(Theme::get_default()->get_font(E.key(), edited_type));
} else {
- item_editor->set_edited_resource(RES());
+ item_editor->set_edited_resource(Ref<Resource>());
}
item_editor->set_editable(false);
}
@@ -2608,7 +2608,7 @@ void ThemeTypeEditor::_update_type_items() {
if (edited_theme->has_icon(E.key(), edited_type)) {
item_editor->set_edited_resource(edited_theme->get_icon(E.key(), edited_type));
} else {
- item_editor->set_edited_resource(RES());
+ item_editor->set_edited_resource(Ref<Resource>());
}
item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item));
item_editor->connect("resource_changed", callable_mp(this, &ThemeTypeEditor::_icon_item_changed), varray(E.key()));
@@ -2616,7 +2616,7 @@ void ThemeTypeEditor::_update_type_items() {
if (Theme::get_default()->has_icon(E.key(), edited_type)) {
item_editor->set_edited_resource(Theme::get_default()->get_icon(E.key(), edited_type));
} else {
- item_editor->set_edited_resource(RES());
+ item_editor->set_edited_resource(Ref<Resource>());
}
item_editor->set_editable(false);
}
@@ -2655,7 +2655,7 @@ void ThemeTypeEditor::_update_type_items() {
if (edited_theme->has_stylebox(leading_stylebox.item_name, edited_type)) {
item_editor->set_edited_resource(leading_stylebox.stylebox);
} else {
- item_editor->set_edited_resource(RES());
+ item_editor->set_edited_resource(Ref<Resource>());
}
item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item));
item_editor->connect("resource_changed", callable_mp(this, &ThemeTypeEditor::_stylebox_item_changed), varray(leading_stylebox.item_name));
@@ -2680,7 +2680,7 @@ void ThemeTypeEditor::_update_type_items() {
if (edited_theme->has_stylebox(E.key(), edited_type)) {
item_editor->set_edited_resource(edited_theme->get_stylebox(E.key(), edited_type));
} else {
- item_editor->set_edited_resource(RES());
+ item_editor->set_edited_resource(Ref<Resource>());
}
item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item));
item_editor->connect("resource_changed", callable_mp(this, &ThemeTypeEditor::_stylebox_item_changed), varray(E.key()));
@@ -2696,7 +2696,7 @@ void ThemeTypeEditor::_update_type_items() {
if (Theme::get_default()->has_stylebox(E.key(), edited_type)) {
item_editor->set_edited_resource(Theme::get_default()->get_stylebox(E.key(), edited_type));
} else {
- item_editor->set_edited_resource(RES());
+ item_editor->set_edited_resource(Ref<Resource>());
}
item_editor->set_editable(false);
}
@@ -3065,7 +3065,7 @@ void ThemeTypeEditor::_font_size_item_changed(float p_value, String p_item_name)
ur->commit_action();
}
-void ThemeTypeEditor::_edit_resource_item(RES p_resource, bool p_edit) {
+void ThemeTypeEditor::_edit_resource_item(Ref<Resource> p_resource, bool p_edit) {
EditorNode::get_singleton()->edit_resource(p_resource);
}
@@ -3131,7 +3131,7 @@ void ThemeTypeEditor::_change_pinned_stylebox() {
Ref<StyleBox> new_stylebox = edited_theme->get_stylebox(leading_stylebox.item_name, edited_type);
leading_stylebox.stylebox = new_stylebox;
- leading_stylebox.ref_stylebox = (new_stylebox.is_valid() ? new_stylebox->duplicate() : RES());
+ leading_stylebox.ref_stylebox = (new_stylebox.is_valid() ? new_stylebox->duplicate() : Ref<Resource>());
if (leading_stylebox.stylebox.is_valid()) {
new_stylebox->connect("changed", callable_mp(this, &ThemeTypeEditor::_update_stylebox_from_leading));
@@ -3169,7 +3169,7 @@ void ThemeTypeEditor::_pin_leading_stylebox(String p_item_name, Ref<StyleBox> p_
leader.pinned = true;
leader.item_name = p_item_name;
leader.stylebox = p_stylebox;
- leader.ref_stylebox = (p_stylebox.is_valid() ? p_stylebox->duplicate() : RES());
+ leader.ref_stylebox = (p_stylebox.is_valid() ? p_stylebox->duplicate() : Ref<Resource>());
leading_stylebox = leader;
if (p_stylebox.is_valid()) {
diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h
index 4b49fbb186..3894ca31e5 100644
--- a/editor/plugins/theme_editor_plugin.h
+++ b/editor/plugins/theme_editor_plugin.h
@@ -384,7 +384,7 @@ class ThemeTypeEditor : public MarginContainer {
void _color_item_changed(Color p_value, String p_item_name);
void _constant_item_changed(float p_value, String p_item_name);
void _font_size_item_changed(float p_value, String p_item_name);
- void _edit_resource_item(RES p_resource, bool p_edit);
+ void _edit_resource_item(Ref<Resource> p_resource, bool p_edit);
void _font_item_changed(Ref<Font> p_value, String p_item_name);
void _icon_item_changed(Ref<Texture2D> p_value, String p_item_name);
void _stylebox_item_changed(Ref<StyleBox> p_value, String p_item_name);
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 09a2b2ec92..f184049d41 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -5881,18 +5881,18 @@ public:
undo_redo->add_undo_property(node.ptr(), p_property, node->get(p_property));
if (p_value.get_type() == Variant::OBJECT) {
- RES prev_res = node->get(p_property);
- RES curr_res = p_value;
+ Ref<Resource> prev_res = node->get(p_property);
+ Ref<Resource> curr_res = p_value;
if (curr_res.is_null()) {
- undo_redo->add_do_method(this, "_open_inspector", (RES)parent_resource.ptr());
+ undo_redo->add_do_method(this, "_open_inspector", (Ref<Resource>)parent_resource.ptr());
} else {
- undo_redo->add_do_method(this, "_open_inspector", (RES)curr_res.ptr());
+ undo_redo->add_do_method(this, "_open_inspector", (Ref<Resource>)curr_res.ptr());
}
if (!prev_res.is_null()) {
- undo_redo->add_undo_method(this, "_open_inspector", (RES)prev_res.ptr());
+ undo_redo->add_undo_method(this, "_open_inspector", (Ref<Resource>)prev_res.ptr());
} else {
- undo_redo->add_undo_method(this, "_open_inspector", (RES)parent_resource.ptr());
+ undo_redo->add_undo_method(this, "_open_inspector", (Ref<Resource>)parent_resource.ptr());
}
}
if (p_property != "constant") {
@@ -5919,11 +5919,11 @@ public:
}
}
- void _resource_selected(const String &p_path, RES p_resource) {
+ void _resource_selected(const String &p_path, Ref<Resource> p_resource) {
_open_inspector(p_resource);
}
- void _open_inspector(RES p_resource) {
+ void _open_inspector(Ref<Resource> p_resource) {
InspectorDock::get_inspector_singleton()->edit(p_resource.ptr());
}
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 8db2cf07f9..540cb709b3 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -48,7 +48,7 @@ class VisualShaderNodePlugin : public RefCounted {
protected:
static void _bind_methods();
- GDVIRTUAL2RC(Object *, _create_editor, RES, Ref<VisualShaderNode>)
+ GDVIRTUAL2RC(Object *, _create_editor, Ref<Resource>, Ref<VisualShaderNode>)
public:
virtual Control *create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node);
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 52fb0d4f4e..f9c4fae405 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -85,7 +85,7 @@ bool EditorResourceConversionPlugin::handles(const Ref<Resource> &p_resource) co
}
Ref<Resource> EditorResourceConversionPlugin::convert(const Ref<Resource> &p_resource) const {
- RES ret;
+ Ref<Resource> ret;
if (GDVIRTUAL_CALL(_convert, p_resource, ret)) {
return ret;
}
@@ -151,7 +151,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
} break;
case OBJ_MENU_EDIT: {
- REF r = v;
+ Ref<RefCounted> r = v;
if (!r.is_null()) {
emit_signal(SNAME("resource_edit_request"));
@@ -223,7 +223,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
} break;
case OBJ_MENU_SHOW_IN_FILE_SYSTEM: {
- RES r = v;
+ Ref<Resource> r = v;
FileSystemDock *file_system_dock = FileSystemDock::get_singleton();
file_system_dock->navigate_to_path(r->get_path());
// Ensure that the FileSystem dock is visible.
@@ -234,7 +234,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
if (p_which >= CONVERT_BASE_ID) {
int to_type = p_which - CONVERT_BASE_ID;
- Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(RES(v));
+ Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(Ref<Resource>(v));
ERR_FAIL_INDEX(to_type, conversions.size());
@@ -928,19 +928,19 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
menu->add_item(TTR("Load"), OBJ_MENU_LOAD);
- if (!RES(v).is_null()) {
+ if (!Ref<Resource>(v).is_null()) {
menu->add_item(TTR("Edit"), OBJ_MENU_EDIT);
menu->add_item(TTR("Clear"), OBJ_MENU_CLEAR);
menu->add_item(TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE);
- RES r = v;
+ Ref<Resource> r = v;
if (r.is_valid() && r->get_path().is_resource_file()) {
menu->add_separator();
menu->add_item(TTR("Show in FileSystem"), OBJ_MENU_SHOW_IN_FILE_SYSTEM);
}
}
- RES cb = EditorSettings::get_singleton()->get_resource_clipboard();
+ Ref<Resource> cb = EditorSettings::get_singleton()->get_resource_clipboard();
bool paste_valid = false;
if (cb.is_valid()) {
if (hint_text.is_empty()) {
@@ -955,10 +955,10 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
}
}
- if (!RES(v).is_null() || paste_valid) {
+ if (!Ref<Resource>(v).is_null() || paste_valid) {
menu->add_separator();
- if (!RES(v).is_null()) {
+ if (!Ref<Resource>(v).is_null()) {
menu->add_item(TTR("Copy"), OBJ_MENU_COPY);
}
@@ -967,8 +967,8 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
}
}
- if (!RES(v).is_null()) {
- Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(RES(v));
+ if (!Ref<Resource>(v).is_null()) {
+ Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(Ref<Resource>(v));
if (conversions.size()) {
menu->add_separator();
}
@@ -1029,7 +1029,7 @@ void CustomPropertyEditor::_file_selected(String p_file) {
case Variant::OBJECT: {
String type = (hint == PROPERTY_HINT_RESOURCE_TYPE) ? hint_text : String();
- RES res = ResourceLoader::load(p_file, type);
+ Ref<Resource> res = ResourceLoader::load(p_file, type);
if (res.is_null()) {
error->set_text(TTR("Error loading file: Not a resource!"));
error->popup_centered();
@@ -1312,7 +1312,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
file->popup_file_dialog();
} else if (p_which == 2) {
- RES r = v;
+ Ref<Resource> r = v;
if (!r.is_null()) {
emit_signal(SNAME("resource_edit_request"));
diff --git a/editor/property_editor.h b/editor/property_editor.h
index ae623f1ad3..3230834d00 100644
--- a/editor/property_editor.h
+++ b/editor/property_editor.h
@@ -58,8 +58,8 @@ protected:
static void _bind_methods();
GDVIRTUAL0RC(String, _converts_to)
- GDVIRTUAL1RC(bool, _handles, RES)
- GDVIRTUAL1RC(RES, _convert, RES)
+ GDVIRTUAL1RC(bool, _handles, Ref<Resource>)
+ GDVIRTUAL1RC(Ref<Resource>, _convert, Ref<Resource>)
public:
virtual String converts_to() const;
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 3e8eb6b4ee..0ddcb1788a 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1153,7 +1153,7 @@ void SceneTreeDock::_property_selected(int p_idx) {
property_drop_node = nullptr;
}
-void SceneTreeDock::_perform_property_drop(Node *p_node, String p_property, RES p_res) {
+void SceneTreeDock::_perform_property_drop(Node *p_node, String p_property, Ref<Resource> p_res) {
editor_data->get_undo_redo().create_action(vformat(TTR("Set %s"), p_property));
editor_data->get_undo_redo().add_do_property(p_node, p_property, p_res);
editor_data->get_undo_redo().add_undo_property(p_node, p_property, p_node->get(p_property));
@@ -3056,14 +3056,14 @@ List<Node *> SceneTreeDock::paste_nodes() {
ur.create_action(TTR("Paste Node(s)"));
ur.add_do_method(editor_selection, "clear");
- Map<RES, RES> resource_remap;
+ Map<Ref<Resource>, Ref<Resource>> resource_remap;
String target_scene;
if (edited_scene) {
target_scene = edited_scene->get_scene_file_path();
}
if (target_scene != clipboard_source_scene) {
if (!clipboard_resource_remap.has(target_scene)) {
- Map<RES, RES> remap;
+ Map<Ref<Resource>, Ref<Resource>> remap;
for (Node *E : node_clipboard) {
_create_remap_for_node(E, remap);
}
@@ -3259,7 +3259,7 @@ void SceneTreeDock::_clear_clipboard() {
clipboard_resource_remap.clear();
}
-void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap) {
+void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<Ref<Resource>, Ref<Resource>> &r_remap) {
List<PropertyInfo> props;
p_node->get_property_list(&props);
@@ -3273,7 +3273,7 @@ void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap)
Variant v = p_node->get(E.name);
if (v.is_ref_counted()) {
- RES res = v;
+ Ref<Resource> res = v;
if (res.is_valid()) {
if (!states_stack_ready) {
states_stack = PropertyUtils::get_node_states_stack(p_node);
@@ -3298,7 +3298,7 @@ void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap)
}
}
-void SceneTreeDock::_create_remap_for_resource(RES p_resource, Map<RES, RES> &r_remap) {
+void SceneTreeDock::_create_remap_for_resource(Ref<Resource> p_resource, Map<Ref<Resource>, Ref<Resource>> &r_remap) {
r_remap[p_resource] = p_resource->duplicate();
List<PropertyInfo> props;
@@ -3311,7 +3311,7 @@ void SceneTreeDock::_create_remap_for_resource(RES p_resource, Map<RES, RES> &r_
Variant v = p_resource->get(E.name);
if (v.is_ref_counted()) {
- RES res = v;
+ Ref<Resource> res = v;
if (res.is_valid()) {
if (res->is_built_in() && !r_remap.has(res)) {
_create_remap_for_resource(res, r_remap);
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index 76067ef8be..a1d300d3d6 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -138,14 +138,14 @@ class SceneTreeDock : public VBoxContainer {
Node *property_drop_node = nullptr;
String resource_drop_path;
- void _perform_property_drop(Node *p_node, String p_property, RES p_res);
+ void _perform_property_drop(Node *p_node, String p_property, Ref<Resource> p_res);
EditorData *editor_data = nullptr;
EditorSelection *editor_selection = nullptr;
List<Node *> node_clipboard;
String clipboard_source_scene;
- HashMap<String, Map<RES, RES>> clipboard_resource_remap;
+ HashMap<String, Map<Ref<Resource>, Ref<Resource>>> clipboard_resource_remap;
ScriptCreateDialog *script_create_dialog = nullptr;
ShaderCreateDialog *shader_create_dialog = nullptr;
@@ -258,8 +258,8 @@ class SceneTreeDock : public VBoxContainer {
void _feature_profile_changed();
void _clear_clipboard();
- void _create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap);
- void _create_remap_for_resource(RES p_resource, Map<RES, RES> &r_remap);
+ void _create_remap_for_node(Node *p_node, Map<Ref<Resource>, Ref<Resource>> &r_remap);
+ void _create_remap_for_resource(Ref<Resource> p_resource, Map<Ref<Resource>, Ref<Resource>> &r_remap);
bool profile_allow_editing = true;
bool profile_allow_script_editing = true;
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index 7d063e13f9..9530a58eb2 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -398,7 +398,7 @@ void ScriptCreateDialog::_create_new() {
void ScriptCreateDialog::_load_exist() {
String path = file_path->get_text();
- RES p_script = ResourceLoader::load(path, "Script");
+ Ref<Resource> p_script = ResourceLoader::load(path, "Script");
if (p_script.is_null()) {
alert->set_text(vformat(TTR("Error loading script from %s"), path));
alert->popup_centered();
diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp
index f07ec161c2..3a2c4fb17b 100644
--- a/editor/shader_create_dialog.cpp
+++ b/editor/shader_create_dialog.cpp
@@ -135,7 +135,7 @@ void ShaderCreateDialog::ok_pressed() {
}
void ShaderCreateDialog::_create_new() {
- RES shader;
+ Ref<Resource> shader;
if (language_menu->get_selected() == int(SHADER_TYPE_TEXT)) {
Ref<Shader> text_shader;
@@ -205,7 +205,7 @@ void ShaderCreateDialog::_create_new() {
void ShaderCreateDialog::_load_exist() {
String path = file_path->get_text();
- RES p_shader = ResourceLoader::load(path, "Shader");
+ Ref<Resource> p_shader = ResourceLoader::load(path, "Shader");
if (p_shader.is_null()) {
alert->set_text(vformat(TTR("Error loading shader from %s"), path));
alert->popup_centered();
diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp
index 81e672c5c3..bfabf269bf 100644
--- a/editor/shader_globals_editor.cpp
+++ b/editor/shader_globals_editor.cpp
@@ -94,7 +94,7 @@ protected:
Dictionary gv;
gv["type"] = global_var_type_names[type];
if (type >= RS::GLOBAL_VAR_TYPE_SAMPLER2D) {
- RES res = p_value;
+ Ref<Resource> res = p_value;
if (res.is_valid()) {
gv["value"] = res->get_path();
} else {