summaryrefslogtreecommitdiff
path: root/editor/editor_folding.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_folding.cpp')
-rw-r--r--editor/editor_folding.cpp41
1 files changed, 17 insertions, 24 deletions
diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp
index 475f16f12f..a7e76e9b2b 100644
--- a/editor/editor_folding.cpp
+++ b/editor/editor_folding.cpp
@@ -34,12 +34,11 @@
#include "editor_inspector.h"
#include "editor_settings.h"
-PoolVector<String> EditorFolding::_get_unfolds(const Object *p_object) {
-
- PoolVector<String> sections;
+Vector<String> EditorFolding::_get_unfolds(const Object *p_object) {
+ Vector<String> sections;
sections.resize(p_object->editor_get_section_folding().size());
if (sections.size()) {
- PoolVector<String>::Write w = sections.write();
+ String *w = sections.ptrw();
int idx = 0;
for (const Set<String>::Element *E = p_object->editor_get_section_folding().front(); E; E = E->next()) {
w[idx++] = E->get();
@@ -52,7 +51,7 @@ PoolVector<String> EditorFolding::_get_unfolds(const Object *p_object) {
void EditorFolding::save_resource_folding(const RES &p_resource, const String &p_path) {
Ref<ConfigFile> config;
config.instance();
- PoolVector<String> unfolds = _get_unfolds(p_resource.ptr());
+ Vector<String> unfolds = _get_unfolds(p_resource.ptr());
config->set_value("folding", "sections_unfolded", unfolds);
String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg";
@@ -60,10 +59,9 @@ void EditorFolding::save_resource_folding(const RES &p_resource, const String &p
config->save(file);
}
-void EditorFolding::_set_unfolds(Object *p_object, const PoolVector<String> &p_unfolds) {
-
+void EditorFolding::_set_unfolds(Object *p_object, const Vector<String> &p_unfolds) {
int uc = p_unfolds.size();
- PoolVector<String>::Read r = p_unfolds.read();
+ const String *r = p_unfolds.ptr();
p_object->editor_clear_section_folding();
for (int i = 0; i < uc; i++) {
p_object->editor_set_section_unfold(r[i], true);
@@ -71,7 +69,6 @@ void EditorFolding::_set_unfolds(Object *p_object, const PoolVector<String> &p_u
}
void EditorFolding::load_resource_folding(RES p_resource, const String &p_path) {
-
Ref<ConfigFile> config;
config.instance();
@@ -82,7 +79,7 @@ void EditorFolding::load_resource_folding(RES p_resource, const String &p_path)
return;
}
- PoolVector<String> unfolds;
+ Vector<String> unfolds;
if (config->has_section_key("folding", "sections_unfolded")) {
unfolds = config->get_value("folding", "sections_unfolded");
@@ -103,7 +100,7 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p
if (p_node->is_displayed_folded()) {
nodes_folded.push_back(p_root->get_path_to(p_node));
}
- PoolVector<String> unfolds = _get_unfolds(p_node);
+ Vector<String> unfolds = _get_unfolds(p_node);
if (unfolds.size()) {
p_folds.push_back(p_root->get_path_to(p_node));
@@ -117,8 +114,7 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p
if (E->get().type == Variant::OBJECT) {
RES res = p_node->get(E->get().name);
if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) {
-
- PoolVector<String> res_unfolds = _get_unfolds(res.ptr());
+ Vector<String> res_unfolds = _get_unfolds(res.ptr());
resource_folds.push_back(res->get_path());
resource_folds.push_back(res_unfolds);
resources.insert(res);
@@ -131,11 +127,14 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p
_fill_folds(p_root, p_node->get_child(i), p_folds, resource_folds, nodes_folded, resources);
}
}
+
void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path) {
+ ERR_FAIL_NULL(p_scene);
FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
- if (!file_check->file_exists(p_path)) //This can happen when creating scene from FilesystemDock. It has path, but no file.
+ if (!file_check->file_exists(p_path)) { //This can happen when creating scene from FilesystemDock. It has path, but no file.
return;
+ }
Ref<ConfigFile> config;
config.instance();
@@ -153,8 +152,8 @@ void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path
file = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(file);
config->save(file);
}
-void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) {
+void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) {
Ref<ConfigFile> config;
config.instance();
@@ -184,7 +183,7 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) {
for (int i = 0; i < unfolds.size(); i += 2) {
NodePath path2 = unfolds[i];
- PoolVector<String> un = unfolds[i + 1];
+ Vector<String> un = unfolds[i + 1];
Node *node = p_scene->get_node_or_null(path2);
if (!node) {
continue;
@@ -202,7 +201,7 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) {
continue;
}
- PoolVector<String> unfolds2 = res_unfolds[i + 1];
+ Vector<String> unfolds2 = res_unfolds[i + 1];
_set_unfolds(res.ptr(), unfolds2);
}
@@ -216,14 +215,12 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) {
}
bool EditorFolding::has_folding_data(const String &p_path) {
-
String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg";
file = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(file);
return FileAccess::exists(file);
}
void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) {
-
List<PropertyInfo> plist;
p_object->get_property_list(&plist);
String group_base;
@@ -232,7 +229,6 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) {
Set<String> unfold_group;
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
-
if (E->get().usage & PROPERTY_USAGE_CATEGORY) {
group = "";
group_base = "";
@@ -247,7 +243,6 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) {
//can unfold
if (E->get().usage & PROPERTY_USAGE_EDITOR) {
-
if (group != "") { //group
if (group_base == String() || E->get().name.begins_with(group_base)) {
bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name);
@@ -256,7 +251,7 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) {
}
}
} else { //path
- int last = E->get().name.find_last("/");
+ int last = E->get().name.rfind("/");
if (last != -1) {
bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name);
if (can_revert) {
@@ -269,7 +264,6 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) {
if (E->get().type == Variant::OBJECT) {
RES res = p_object->get(E->get().name);
if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) {
-
resources.insert(res);
_do_object_unfolds(res.ptr(), resources);
}
@@ -299,7 +293,6 @@ void EditorFolding::_do_node_unfolds(Node *p_root, Node *p_node, Set<RES> &resou
}
void EditorFolding::unfold_scene(Node *p_scene) {
-
Set<RES> resources;
_do_node_unfolds(p_scene, p_scene, resources);
}