diff options
Diffstat (limited to 'editor/editor_resource_picker.cpp')
-rw-r--r-- | editor/editor_resource_picker.cpp | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 3158c03dcc..34aa7217fa 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -240,7 +240,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { ResourceLoader::get_recognized_extensions_for_type(base, &extensions); } - Set<String> valid_extensions; + HashSet<String> valid_extensions; for (const String &E : extensions) { valid_extensions.insert(E); } @@ -253,8 +253,8 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { } file_dialog->clear_filters(); - for (Set<String>::Element *E = valid_extensions.front(); E; E = E->next()) { - file_dialog->add_filter("*." + E->get() + " ; " + E->get().to_upper()); + for (const String &E : valid_extensions) { + file_dialog->add_filter("*." + E + " ; " + E.to_upper()); } file_dialog->popup_file_dialog(); @@ -409,7 +409,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) { if (!base_type.is_empty()) { int idx = 0; - Set<String> allowed_types; + HashSet<String> allowed_types; _get_allowed_types(false, &allowed_types); Vector<EditorData::CustomType> custom_resources; @@ -417,8 +417,8 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) { custom_resources = EditorNode::get_editor_data().get_custom_types()["Resource"]; } - for (Set<String>::Element *E = allowed_types.front(); E; E = E->next()) { - const String &t = E->get(); + for (const String &E : allowed_types) { + const String &t = E; bool is_custom_resource = false; Ref<Texture2D> icon; @@ -491,7 +491,7 @@ void EditorResourcePicker::_button_input(const Ref<InputEvent> &p_event) { } } -void EditorResourcePicker::_get_allowed_types(bool p_with_convert, Set<String> *p_vector) const { +void EditorResourcePicker::_get_allowed_types(bool p_with_convert, HashSet<String> *p_vector) const { Vector<String> allowed_types = base_type.split(","); int size = allowed_types.size(); @@ -568,7 +568,7 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { res = drag_data["resource"]; } - Set<String> allowed_types; + HashSet<String> allowed_types; _get_allowed_types(true, &allowed_types); if (res.is_valid() && _is_type_valid(res->get_class(), allowed_types)) { @@ -598,9 +598,9 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { return false; } -bool EditorResourcePicker::_is_type_valid(const String p_type_name, Set<String> p_allowed_types) const { - for (Set<String>::Element *E = p_allowed_types.front(); E; E = E->next()) { - String at = E->get().strip_edges(); +bool EditorResourcePicker::_is_type_valid(const String p_type_name, HashSet<String> p_allowed_types) const { + for (const String &E : p_allowed_types) { + String at = E.strip_edges(); if (p_type_name == at || ClassDB::is_parent_class(p_type_name, at) || EditorNode::get_editor_data().script_class_is_parent(p_type_name, at)) { return true; } @@ -646,13 +646,13 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ } if (dropped_resource.is_valid()) { - Set<String> allowed_types; + HashSet<String> allowed_types; _get_allowed_types(false, &allowed_types); // If the accepted dropped resource is from the extended list, it requires conversion. if (!_is_type_valid(dropped_resource->get_class(), allowed_types)) { - for (Set<String>::Element *E = allowed_types.front(); E; E = E->next()) { - String at = E->get().strip_edges(); + for (const String &E : allowed_types) { + String at = E.strip_edges(); if (at == "BaseMaterial3D" && Ref<Texture2D>(dropped_resource).is_valid()) { // Use existing resource if possible and only replace its data. @@ -768,7 +768,7 @@ void EditorResourcePicker::set_base_type(const String &p_base_type) { // There is a possibility that the new base type is conflicting with the existing value. // Keep the value, but warn the user that there is a potential mistake. if (!base_type.is_empty() && edited_resource.is_valid()) { - Set<String> allowed_types; + HashSet<String> allowed_types; _get_allowed_types(true, &allowed_types); StringName custom_class; @@ -784,7 +784,7 @@ void EditorResourcePicker::set_base_type(const String &p_base_type) { } } else { // Call the method to build the cache immediately. - Set<String> allowed_types; + HashSet<String> allowed_types; _get_allowed_types(false, &allowed_types); } } @@ -794,7 +794,7 @@ String EditorResourcePicker::get_base_type() const { } Vector<String> EditorResourcePicker::get_allowed_types() const { - Set<String> allowed_types; + HashSet<String> allowed_types; _get_allowed_types(false, &allowed_types); Vector<String> types; @@ -802,8 +802,9 @@ Vector<String> EditorResourcePicker::get_allowed_types() const { int i = 0; String *w = types.ptrw(); - for (Set<String>::Element *E = allowed_types.front(); E; E = E->next(), i++) { - w[i] = E->get(); + for (const String &E : allowed_types) { + w[i] = E; + i++; } return types; @@ -817,7 +818,7 @@ void EditorResourcePicker::set_edited_resource(Ref<Resource> p_resource) { } if (!base_type.is_empty()) { - Set<String> allowed_types; + HashSet<String> allowed_types; _get_allowed_types(true, &allowed_types); StringName custom_class; |