diff options
Diffstat (limited to 'editor')
180 files changed, 1409 insertions, 1324 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 9c8fec26a7..ff8b72274c 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -62,7 +62,7 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) { int right_limit = get_size().width; //selection may have altered the order of keys - Map<float, int> key_order; + RBMap<float, int> key_order; for (int i = 0; i < animation->track_get_key_count(p_track); i++) { float ofs = animation->track_get_key_time(p_track, i); @@ -73,7 +73,7 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) { key_order[ofs] = i; } - for (Map<float, int>::Element *E = key_order.front(); E; E = E->next()) { + for (RBMap<float, int>::Element *E = key_order.front(); E; E = E->next()) { int i = E->get(); if (!E->next()) { @@ -262,12 +262,12 @@ void AnimationBezierTrackEdit::_notification(int p_what) { int vofs = vsep; int margin = 0; - Map<int, Color> subtrack_colors; + RBMap<int, Color> subtrack_colors; Color selected_track_color; subtracks.clear(); subtrack_icons.clear(); - Map<String, Vector<int>> track_indices; + RBMap<String, Vector<int>> track_indices; int track_count = animation->get_track_count(); for (int i = 0; i < track_count; ++i) { if (animation->track_get_type(i) != Animation::TrackType::TYPE_BEZIER) { @@ -432,7 +432,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { Rect2 solo_rect = Rect2(solo_hpos, icon_start_height - solo->get_height() / 2, solo->get_width(), solo->get_height()); draw_texture(solo, solo_rect.position); - Map<int, Rect2> track_icons; + RBMap<int, Rect2> track_icons; track_icons[REMOVE_ICON] = remove_rect; track_icons[LOCK_ICON] = lock_rect; track_icons[VISIBILITY_ICON] = visible_rect; @@ -747,7 +747,7 @@ void AnimationBezierTrackEdit::_update_locked_tracks_after(int p_track) { } Vector<int> updated_locked_tracks; - for (Set<int>::Element *E = locked_tracks.front(); E; E = E->next()) { + for (RBSet<int>::Element *E = locked_tracks.front(); E; E = E->next()) { updated_locked_tracks.push_back(E->get()); } locked_tracks.clear(); @@ -766,7 +766,7 @@ void AnimationBezierTrackEdit::_update_hidden_tracks_after(int p_track) { } Vector<int> updated_hidden_tracks; - for (Set<int>::Element *E = hidden_tracks.front(); E; E = E->next()) { + for (RBSet<int>::Element *E = hidden_tracks.front(); E; E = E->next()) { updated_hidden_tracks.push_back(E->get()); } hidden_tracks.clear(); @@ -963,9 +963,9 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } } - for (const KeyValue<int, Map<int, Rect2>> &E : subtrack_icons) { + for (const KeyValue<int, RBMap<int, Rect2>> &E : subtrack_icons) { int track = E.key; - Map<int, Rect2> track_icons = E.value; + RBMap<int, Rect2> track_icons = E.value; for (const KeyValue<int, Rect2> &I : track_icons) { if (I.value.has_point(mb->get_position())) { if (I.key == REMOVE_ICON) { diff --git a/editor/animation_bezier_editor.h b/editor/animation_bezier_editor.h index f228f66771..cbbc3cc32a 100644 --- a/editor/animation_bezier_editor.h +++ b/editor/animation_bezier_editor.h @@ -61,7 +61,7 @@ class AnimationBezierTrackEdit : public Control { Ref<Texture2D> bezier_handle_icon; Ref<Texture2D> selected_icon; - Map<int, Rect2> subtracks; + RBMap<int, Rect2> subtracks; enum { REMOVE_ICON, @@ -70,9 +70,9 @@ class AnimationBezierTrackEdit : public Control { VISIBILITY_ICON }; - Map<int, Map<int, Rect2>> subtrack_icons; - Set<int> locked_tracks; - Set<int> hidden_tracks; + RBMap<int, RBMap<int, Rect2>> subtrack_icons; + RBSet<int> locked_tracks; + RBSet<int> hidden_tracks; int solo_track = -1; bool is_filtered = false; @@ -152,7 +152,7 @@ class AnimationBezierTrackEdit : public Control { } }; - typedef Set<IntPair, SelectionCompare> SelectionSet; + typedef RBSet<IntPair, SelectionCompare> SelectionSet; SelectionSet selection; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index a70e7011fd..7d8197bead 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1353,8 +1353,8 @@ public: Ref<Animation> animation; - Map<int, List<float>> key_ofs_map; - Map<int, NodePath> base_map; + RBMap<int, List<float>> key_ofs_map; + RBMap<int, NodePath> base_map; PropertyInfo hint; Node *root_path = nullptr; @@ -4382,7 +4382,7 @@ void AnimationTrackEditor::_update_tracks() { return; } - Map<String, VBoxContainer *> group_sort; + RBMap<String, VBoxContainer *> group_sort; bool use_grouping = !view_group->is_pressed(); bool use_filter = selected_filter->is_pressed(); @@ -5199,8 +5199,8 @@ void AnimationTrackEditor::_update_key_edit() { multi_key_edit = memnew(AnimationMultiTrackKeyEdit); multi_key_edit->animation = animation; - Map<int, List<float>> key_ofs_map; - Map<int, NodePath> base_map; + RBMap<int, List<float>> key_ofs_map; + RBMap<int, NodePath> base_map; int first_track = -1; for (const KeyValue<SelectedKey, KeyInfo> &E : selection) { int track = E.key.track; @@ -5261,11 +5261,11 @@ void AnimationTrackEditor::_move_selection_commit() { float motion = moving_selection_offset; // 1 - remove the keys. - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key); } // 2 - Remove overlapped keys. - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { float newtime = snap_time(E->get().pos + motion); int idx = animation->track_find_key(E->key().track, newtime, true); if (idx == -1) { @@ -5290,19 +5290,19 @@ void AnimationTrackEditor::_move_selection_commit() { } // 3 - Move the keys (Reinsert them). - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { float newpos = snap_time(E->get().pos + motion); undo_redo->add_do_method(animation.ptr(), "track_insert_key", E->key().track, newpos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key)); } // 4 - (Undo) Remove inserted keys. - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { float newpos = snap_time(E->get().pos + motion); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", E->key().track, newpos); } // 5 - (Undo) Reinsert keys. - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->key().track, E->get().pos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key)); } @@ -5315,7 +5315,7 @@ void AnimationTrackEditor::_move_selection_commit() { undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation); // 7 - Reselect. - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { float oldpos = E->get().pos; float newpos = snap_time(oldpos + motion); @@ -5488,7 +5488,7 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { if (selection.size() && animation.is_valid() && (!transpose || (_get_track_selected() >= 0 && _get_track_selected() < animation->get_track_count()))) { int top_track = 0x7FFFFFFF; float top_time = 1e10; - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { const SelectedKey &sk = E->key(); float t = animation->track_get_key_time(sk.track, sk.key); @@ -5509,7 +5509,7 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { List<Pair<int, float>> new_selection_values; - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { const SelectedKey &sk = E->key(); float t = animation->track_get_key_time(sk.track, sk.key); @@ -5544,7 +5544,7 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { // Reselect duplicated. - Map<SelectedKey, KeyInfo> new_selection; + RBMap<SelectedKey, KeyInfo> new_selection; for (const Pair<int, float> &E : new_selection_values) { int track = E.first; float time = E.second; @@ -5822,11 +5822,11 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { List<_AnimMoveRestore> to_restore; // 1 - Remove the keys. - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key); } // 2 - Remove overlapped keys. - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { float newtime = (E->get().pos - from_t) * s + from_t; int idx = animation->track_find_key(E->key().track, newtime, true); if (idx == -1) { @@ -5852,19 +5852,19 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { #define NEW_POS(m_ofs) (((s > 0) ? m_ofs : from_t + (len - (m_ofs - from_t))) - pivot) * ABS(s) + from_t // 3 - Move the keys (re insert them). - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { float newpos = NEW_POS(E->get().pos); undo_redo->add_do_method(animation.ptr(), "track_insert_key", E->key().track, newpos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key)); } // 4 - (Undo) Remove inserted keys. - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { float newpos = NEW_POS(E->get().pos); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", E->key().track, newpos); } // 5 - (Undo) Reinsert keys. - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->key().track, E->get().pos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key)); } @@ -5877,7 +5877,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation); // 7-reselect. - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { float oldpos = E->get().pos; float newpos = NEW_POS(oldpos); if (newpos >= 0) { @@ -5906,7 +5906,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { undo_redo->create_action(TTR("Anim Add RESET Keys")); Ref<Animation> reset = _create_and_get_reset_animation(); int reset_tracks = reset->get_track_count(); - Set<int> tracks_added; + RBSet<int> tracks_added; for (const KeyValue<SelectedKey, KeyInfo> &E : selection) { const SelectedKey &sk = E.key; @@ -5960,7 +5960,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { if (selection.size()) { undo_redo->create_action(TTR("Anim Delete Keys")); - for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key); undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->key().track, E->get().pos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key)); } diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 2773b48082..07c3ed9990 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -410,7 +410,7 @@ class AnimationTrackEditor : public VBoxContainer { float pos = 0; }; - Map<SelectedKey, KeyInfo> selection; + RBMap<SelectedKey, KeyInfo> selection; void _key_selected(int p_key, bool p_single, int p_track); void _key_deselected(int p_key, int p_track); diff --git a/editor/audio_stream_preview.h b/editor/audio_stream_preview.h index bcd80a7c03..307dd93b34 100644 --- a/editor/audio_stream_preview.h +++ b/editor/audio_stream_preview.h @@ -85,7 +85,7 @@ class AudioStreamPreviewGenerator : public Node { Preview() {} }; - Map<ObjectID, Preview> previews; + HashMap<ObjectID, Preview> previews; static void _preview_thread(void *p_preview); diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 5526181c13..4cff0ffd3d 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -1029,27 +1029,27 @@ void ConnectionsDock::update_tree() { String descr; bool found = false; - Map<StringName, Map<StringName, String>>::Element *G = descr_cache.find(base); + HashMap<StringName, HashMap<StringName, String>>::Iterator G = descr_cache.find(base); if (G) { - Map<StringName, String>::Element *F = G->get().find(signal_name); + HashMap<StringName, String>::Iterator F = G->value.find(signal_name); if (F) { found = true; - descr = F->get(); + descr = F->value; } } if (!found) { DocTools *dd = EditorHelp::get_doc_data(); - Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(base); + HashMap<String, DocData::ClassDoc>::Iterator F = dd->class_list.find(base); while (F && descr.is_empty()) { - for (int i = 0; i < F->get().signals.size(); i++) { - if (F->get().signals[i].name == signal_name.operator String()) { - descr = DTR(F->get().signals[i].description); + for (int i = 0; i < F->value.signals.size(); i++) { + if (F->value.signals[i].name == signal_name.operator String()) { + descr = DTR(F->value.signals[i].description); break; } } - if (!F->get().inherits.is_empty()) { - F = dd->class_list.find(F->get().inherits); + if (!F->value.inherits.is_empty()) { + F = dd->class_list.find(F->value.inherits); } else { break; } diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index f8f15b32af..88d52c83f2 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -197,7 +197,7 @@ class ConnectionsDock : public VBoxContainer { UndoRedo *undo_redo = nullptr; LineEdit *search_box = nullptr; - Map<StringName, Map<StringName, String>> descr_cache; + HashMap<StringName, HashMap<StringName, String>> descr_cache; void _filter_changed(const String &p_text); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index fbb61a1614..fb908ea573 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -125,7 +125,7 @@ bool CreateDialog::_should_hide_type(const String &p_type) const { return true; // Do not show editor nodes. } - if (p_type == base_type) { + if (p_type == base_type && !EditorNode::get_editor_data().get_custom_types().has(p_type)) { return true; // Root is already added. } @@ -138,7 +138,7 @@ bool CreateDialog::_should_hide_type(const String &p_type) const { return true; // Wrong inheritance. } - for (Set<StringName>::Element *E = type_blacklist.front(); E; E = E->next()) { + for (RBSet<StringName>::Element *E = type_blacklist.front(); E; E = E->next()) { if (ClassDB::is_parent_class(p_type, E->get())) { return true; // Parent type is blacklisted. } diff --git a/editor/create_dialog.h b/editor/create_dialog.h index 31761be6fe..6526116b09 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -64,7 +64,7 @@ class CreateDialog : public ConfirmationDialog { HashMap<String, String> custom_type_parents; HashMap<String, int> custom_type_indices; List<StringName> type_list; - Set<StringName> type_blacklist; + RBSet<StringName> type_blacklist; void _update_search(); bool _should_hide_type(const String &p_type) const; diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp index e7baeeeded..0caeb90108 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp @@ -381,12 +381,12 @@ Dictionary DebugAdapterParser::req_scopes(const Dictionary &p_params) const { DAP::StackFrame frame; frame.id = frame_id; - Map<DAP::StackFrame, List<int>>::Element *E = DebugAdapterProtocol::get_singleton()->stackframe_list.find(frame); + HashMap<DAP::StackFrame, List<int>, DAP::StackFrame>::Iterator E = DebugAdapterProtocol::get_singleton()->stackframe_list.find(frame); if (E) { - ERR_FAIL_COND_V(E->value().size() != 3, prepare_error_response(p_params, DAP::ErrorType::UNKNOWN)); + ERR_FAIL_COND_V(E->value.size() != 3, prepare_error_response(p_params, DAP::ErrorType::UNKNOWN)); for (int i = 0; i < 3; i++) { DAP::Scope scope; - scope.variablesReference = E->value()[i]; + scope.variablesReference = E->value[i]; switch (i) { case 0: scope.name = "Locals"; @@ -424,16 +424,16 @@ Dictionary DebugAdapterParser::req_variables(const Dictionary &p_params) const { Dictionary args = p_params["arguments"]; int variable_id = args["variablesReference"]; - Map<int, Array>::Element *E = DebugAdapterProtocol::get_singleton()->variable_list.find(variable_id); + HashMap<int, Array>::Iterator E = DebugAdapterProtocol::get_singleton()->variable_list.find(variable_id); if (E) { if (!DebugAdapterProtocol::get_singleton()->get_current_peer()->supportsVariableType) { - for (int i = 0; i < E->value().size(); i++) { - Dictionary variable = E->value()[i]; + for (int i = 0; i < E->value.size(); i++) { + Dictionary variable = E->value[i]; variable.erase("type"); } } - body["variables"] = E ? E->value() : Array(); + body["variables"] = E ? E->value : Array(); return response; } else { return Dictionary(); diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp index fea4c2b156..92ea0f15e9 100644 --- a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp @@ -918,11 +918,11 @@ void DebugAdapterProtocol::on_debug_stack_frame_vars(const int &p_size) { DAP::StackFrame frame; frame.id = _current_frame; ERR_FAIL_COND(!stackframe_list.has(frame)); - List<int> scope_ids = stackframe_list.find(frame)->value(); + List<int> scope_ids = stackframe_list.find(frame)->value; for (List<int>::Element *E = scope_ids.front(); E; E = E->next()) { int variable_id = E->get(); if (variable_list.has(variable_id)) { - variable_list.find(variable_id)->value().clear(); + variable_list.find(variable_id)->value.clear(); } else { variable_list.insert(variable_id, Array()); } @@ -937,7 +937,7 @@ void DebugAdapterProtocol::on_debug_stack_frame_var(const Array &p_data) { DAP::StackFrame frame; frame.id = _current_frame; - List<int> scope_ids = stackframe_list.find(frame)->value(); + List<int> scope_ids = stackframe_list.find(frame)->value; ERR_FAIL_COND(scope_ids.size() != 3); ERR_FAIL_INDEX(stack_var.type, 3); int variable_id = scope_ids[stack_var.type]; @@ -949,7 +949,7 @@ void DebugAdapterProtocol::on_debug_stack_frame_var(const Array &p_data) { variable.type = Variant::get_type_name(stack_var.value.get_type()); variable.variablesReference = parse_variant(stack_var.value); - variable_list.find(variable_id)->value().push_back(variable.to_json()); + variable_list.find(variable_id)->value.push_back(variable.to_json()); _remaining_vars--; } diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.h b/editor/debugger/debug_adapter/debug_adapter_protocol.h index 66db75c634..a17e550dfc 100644 --- a/editor/debugger/debug_adapter/debug_adapter_protocol.h +++ b/editor/debugger/debug_adapter/debug_adapter_protocol.h @@ -115,8 +115,8 @@ private: int stackframe_id = 0; int variable_id = 0; List<DAP::Breakpoint> breakpoint_list; - Map<DAP::StackFrame, List<int>> stackframe_list; - Map<int, Array> variable_list; + HashMap<DAP::StackFrame, List<int>, DAP::StackFrame> stackframe_list; + HashMap<int, Array> variable_list; public: friend class DebugAdapterServer; diff --git a/editor/debugger/debug_adapter/debug_adapter_types.h b/editor/debugger/debug_adapter/debug_adapter_types.h index 77b70909b3..4d77b6d51c 100644 --- a/editor/debugger/debug_adapter/debug_adapter_types.h +++ b/editor/debugger/debug_adapter/debug_adapter_types.h @@ -219,8 +219,11 @@ struct StackFrame { int line; int column; - bool operator<(const StackFrame &p_other) const { - return id < p_other.id; + static uint32_t hash(const StackFrame &p_frame) { + return hash_djb2_one_32(p_frame.id); + } + bool operator==(const StackFrame &p_other) const { + return id == p_other.id; } _FORCE_INLINE_ void from_json(const Dictionary &p_params) { diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index 854c050793..6d7f3f4ae2 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -146,7 +146,7 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { debugObj->prop_list.clear(); int new_props_added = 0; - Set<String> changed; + RBSet<String> changed; for (int i = 0; i < obj.properties.size(); i++) { PropertyInfo &pinfo = obj.properties[i].first; Variant &var = obj.properties[i].second; @@ -193,7 +193,7 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { if (old_prop_size == debugObj->prop_list.size() && new_props_added == 0) { //only some may have changed, if so, then update those, if exist - for (Set<String>::Element *E = changed.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = changed.front(); E; E = E->next()) { emit_signal(SNAME("object_property_updated"), debugObj->remote_object_id, E->get()); } } else { @@ -276,8 +276,8 @@ void EditorDebuggerInspector::clear_stack_variables() { } String EditorDebuggerInspector::get_stack_variable(const String &p_var) { - for (Map<StringName, Variant>::Element *E = variables->prop_values.front(); E; E = E->next()) { - String v = E->key().operator String(); + for (KeyValue<StringName, Variant> &E : variables->prop_values) { + String v = E.key.operator String(); if (v.get_slice("/", 1) == p_var) { return variables->get_variant(v); } diff --git a/editor/debugger/editor_debugger_inspector.h b/editor/debugger/editor_debugger_inspector.h index 2bf5bf3419..72b259c8b5 100644 --- a/editor/debugger/editor_debugger_inspector.h +++ b/editor/debugger/editor_debugger_inspector.h @@ -46,7 +46,7 @@ public: ObjectID remote_object_id; String type_name; List<PropertyInfo> prop_list; - Map<StringName, Variant> prop_values; + HashMap<StringName, Variant> prop_values; ObjectID get_remote_object_id() { return remote_object_id; }; String get_title(); @@ -68,8 +68,8 @@ class EditorDebuggerInspector : public EditorInspector { private: ObjectID inspected_object_id; - Map<ObjectID, EditorDebuggerRemoteObject *> remote_objects; - Set<Ref<Resource>> remote_dependencies; + HashMap<ObjectID, EditorDebuggerRemoteObject *> remote_objects; + RBSet<Ref<Resource>> remote_dependencies; EditorDebuggerRemoteObject *variables = nullptr; void _object_selected(ObjectID p_object); diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index c0685af572..de26b56ab6 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -118,7 +118,7 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() { } if (!debugger_plugins.is_empty()) { - for (Set<Ref<Script>>::Element *i = debugger_plugins.front(); i; i = i->next()) { + for (RBSet<Ref<Script>>::Element *i = debugger_plugins.front(); i; i = i->next()) { node->add_debugger_plugin(i->get()); } } diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index b4fbb90301..40e9cf47f9 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -70,6 +70,14 @@ private: String source; int line = 0; + static uint32_t hash(const Breakpoint &p_val) { + uint32_t h = HashMapHasherDefault::hash(p_val.source); + return hash_djb2_one_32(p_val.line, h); + } + bool operator==(const Breakpoint &p_b) const { + return (line == p_b.line && source == p_b.source); + } + bool operator<(const Breakpoint &p_b) const { if (line == p_b.line) { return source < p_b.source; @@ -102,9 +110,9 @@ private: bool debug_with_external_editor = false; bool hide_on_stop = true; CameraOverride camera_override = OVERRIDE_NONE; - Map<Breakpoint, bool> breakpoints; + HashMap<Breakpoint, bool, Breakpoint> breakpoints; - Set<Ref<Script>> debugger_plugins; + RBSet<Ref<Script>> debugger_plugins; ScriptEditorDebugger *_add_debugger(); EditorDebuggerRemoteObject *get_inspected_remote_object(); diff --git a/editor/debugger/editor_debugger_server.cpp b/editor/debugger/editor_debugger_server.cpp index bce131a5fe..63390825c6 100644 --- a/editor/debugger/editor_debugger_server.cpp +++ b/editor/debugger/editor_debugger_server.cpp @@ -122,7 +122,7 @@ Ref<RemoteDebuggerPeer> EditorDebuggerServerTCP::take_connection() { } /// EditorDebuggerServer -Map<StringName, EditorDebuggerServer::CreateServerFunc> EditorDebuggerServer::protocols; +HashMap<StringName, EditorDebuggerServer::CreateServerFunc> EditorDebuggerServer::protocols; EditorDebuggerServer *EditorDebuggerServer::create(const String &p_protocol) { ERR_FAIL_COND_V(!protocols.has(p_protocol), nullptr); diff --git a/editor/debugger/editor_debugger_server.h b/editor/debugger/editor_debugger_server.h index bda4a1ce7d..adf9a27c71 100644 --- a/editor/debugger/editor_debugger_server.h +++ b/editor/debugger/editor_debugger_server.h @@ -39,7 +39,7 @@ public: typedef EditorDebuggerServer *(*CreateServerFunc)(const String &p_uri); private: - static Map<StringName, CreateServerFunc> protocols; + static HashMap<StringName, CreateServerFunc> protocols; public: static void initialize(); diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h index 58af52b01f..8ba03367c9 100644 --- a/editor/debugger/editor_debugger_tree.h +++ b/editor/debugger/editor_debugger_tree.h @@ -48,7 +48,7 @@ private: ObjectID inspected_object_id; int debugger_id = 0; bool updating_scene_tree = false; - Set<ObjectID> unfold_cache; + RBSet<ObjectID> unfold_cache; PopupMenu *item_menu = nullptr; EditorFileDialog *file_dialog = nullptr; String last_filter; diff --git a/editor/debugger/editor_network_profiler.h b/editor/debugger/editor_network_profiler.h index 3a604f5564..d2e70a083d 100644 --- a/editor/debugger/editor_network_profiler.h +++ b/editor/debugger/editor_network_profiler.h @@ -50,7 +50,7 @@ private: Timer *frame_delay = nullptr; - Map<ObjectID, SceneDebugger::RPCNodeInfo> nodes_data; + HashMap<ObjectID, SceneDebugger::RPCNodeInfo> nodes_data; void _update_frame(); diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp index c821561ca6..897c5ae7da 100644 --- a/editor/debugger/editor_performance_profiler.cpp +++ b/editor/debugger/editor_performance_profiler.cpp @@ -97,9 +97,9 @@ void EditorPerformanceProfiler::_monitor_select() { void EditorPerformanceProfiler::_monitor_draw() { Vector<StringName> active; - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { - if (i.value().item->is_checked(0)) { - active.push_back(i.key()); + for (const KeyValue<StringName, Monitor> &E : monitors) { + if (E.value.item->is_checked(0)) { + active.push_back(E.key); } } @@ -203,23 +203,23 @@ void EditorPerformanceProfiler::_monitor_draw() { } void EditorPerformanceProfiler::_build_monitor_tree() { - Set<StringName> monitor_checked; - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { - if (i.value().item && i.value().item->is_checked(0)) { - monitor_checked.insert(i.key()); + RBSet<StringName> monitor_checked; + for (KeyValue<StringName, Monitor> &E : monitors) { + if (E.value.item && E.value.item->is_checked(0)) { + monitor_checked.insert(E.key); } } base_map.clear(); monitor_tree->get_root()->clear_children(); - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { - TreeItem *base = _get_monitor_base(i.value().base); - TreeItem *item = _create_monitor_item(i.value().name, base); - item->set_checked(0, monitor_checked.has(i.key())); - i.value().item = item; - if (!i.value().history.is_empty()) { - i.value().update_value(i.value().history.front()->get()); + for (KeyValue<StringName, Monitor> &E : monitors) { + TreeItem *base = _get_monitor_base(E.value.base); + TreeItem *item = _create_monitor_item(E.value.name, base); + item->set_checked(0, monitor_checked.has(E.key)); + E.value.item = item; + if (!E.value.history.is_empty()) { + E.value.update_value(E.value.history.front()->get()); } } } @@ -252,9 +252,9 @@ void EditorPerformanceProfiler::_marker_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { Vector<StringName> active; - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { - if (i.value().item->is_checked(0)) { - active.push_back(i.key()); + for (KeyValue<StringName, Monitor> &E : monitors) { + if (E.value.item->is_checked(0)) { + active.push_back(E.key); } } if (active.size() > 0) { @@ -293,12 +293,16 @@ void EditorPerformanceProfiler::_marker_input(const Ref<InputEvent> &p_event) { } void EditorPerformanceProfiler::reset() { - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { - if (String(i.key()).begins_with("custom:")) { - monitors.erase(i); + HashMap<StringName, Monitor>::Iterator E = monitors.begin(); + while (E != monitors.end()) { + HashMap<StringName, Monitor>::Iterator N = E; + ++N; + if (String(E->key).begins_with("custom:")) { + monitors.remove(E); } else { - i.value().reset(); + E->value.reset(); } + E = N; } _build_monitor_tree(); @@ -308,43 +312,49 @@ void EditorPerformanceProfiler::reset() { } void EditorPerformanceProfiler::update_monitors(const Vector<StringName> &p_names) { - OrderedHashMap<StringName, int> names; + HashMap<StringName, int> names; for (int i = 0; i < p_names.size(); i++) { names.insert("custom:" + p_names[i], Performance::MONITOR_MAX + i); } - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { - if (String(i.key()).begins_with("custom:")) { - if (!names.has(i.key())) { - monitors.erase(i); - } else { - i.value().frame_index = names[i.key()]; - names.erase(i.key()); + { + HashMap<StringName, Monitor>::Iterator E = monitors.begin(); + while (E != monitors.end()) { + HashMap<StringName, Monitor>::Iterator N = E; + ++N; + if (String(E->key).begins_with("custom:")) { + if (!names.has(E->key)) { + monitors.remove(E); + } else { + E->value.frame_index = names[E->key]; + names.erase(E->key); + } } + E = N; } } - for (OrderedHashMap<StringName, int>::Element i = names.front(); i; i = i.next()) { - String name = String(i.key()).replace_first("custom:", ""); + for (const KeyValue<StringName, int> &E : names) { + String name = String(E.key).replace_first("custom:", ""); String base = "Custom"; if (name.get_slice_count("/") == 2) { base = name.get_slicec('/', 0); name = name.get_slicec('/', 1); } - monitors.insert(i.key(), Monitor(name, base, i.value(), Performance::MONITOR_TYPE_QUANTITY, nullptr)); + monitors.insert(E.key, Monitor(name, base, E.value, Performance::MONITOR_TYPE_QUANTITY, nullptr)); } _build_monitor_tree(); } void EditorPerformanceProfiler::add_profile_frame(const Vector<float> &p_values) { - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { + for (KeyValue<StringName, Monitor> &E : monitors) { float data = 0.0f; - if (i.value().frame_index >= 0 && i.value().frame_index < p_values.size()) { - data = p_values[i.value().frame_index]; + if (E.value.frame_index >= 0 && E.value.frame_index < p_values.size()) { + data = p_values[E.value.frame_index]; } - i.value().history.push_front(data); - i.value().update_value(data); + E.value.history.push_front(data); + E.value.update_value(data); } marker_frame++; monitor_draw->update(); diff --git a/editor/debugger/editor_performance_profiler.h b/editor/debugger/editor_performance_profiler.h index ab0e43de2f..607de5a134 100644 --- a/editor/debugger/editor_performance_profiler.h +++ b/editor/debugger/editor_performance_profiler.h @@ -31,8 +31,8 @@ #ifndef EDITOR_PERFORMANCE_PROFILER_H #define EDITOR_PERFORMANCE_PROFILER_H -#include "core/templates/map.h" -#include "core/templates/ordered_hash_map.h" +#include "core/templates/hash_map.h" +#include "core/templates/rb_map.h" #include "main/performance.h" #include "scene/gui/control.h" #include "scene/gui/label.h" @@ -59,9 +59,9 @@ private: void reset(); }; - OrderedHashMap<StringName, Monitor> monitors; + HashMap<StringName, Monitor> monitors; - Map<StringName, TreeItem *> base_map; + HashMap<StringName, TreeItem *> base_map; Tree *monitor_tree = nullptr; Control *monitor_draw = nullptr; Label *info_message = nullptr; diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 50f3b19cc2..55c3c7af78 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -198,18 +198,18 @@ void EditorProfiler::_update_plot() { for (int i = 0; i < total_metrics; i++) { const Metric &m = _get_frame_metric(i); - for (Set<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) { - const Map<StringName, Metric::Category *>::Element *F = m.category_ptrs.find(E->get()); + for (RBSet<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) { + HashMap<StringName, Metric::Category *>::ConstIterator F = m.category_ptrs.find(E->get()); if (F) { - highest = MAX(F->get()->total_time, highest); + highest = MAX(F->value->total_time, highest); } - const Map<StringName, Metric::Category::Item *>::Element *G = m.item_ptrs.find(E->get()); + HashMap<StringName, Metric::Category::Item *>::ConstIterator G = m.item_ptrs.find(E->get()); if (G) { if (use_self) { - highest = MAX(G->get()->self, highest); + highest = MAX(G->value->self, highest); } else { - highest = MAX(G->get()->total, highest); + highest = MAX(G->value->total, highest); } } } @@ -225,7 +225,7 @@ void EditorProfiler::_update_plot() { int *column = columnv.ptrw(); - Map<StringName, int> prev_plots; + HashMap<StringName, int> prev_plots; for (int i = 0; i < total_metrics * w / frame_metrics.size() - 1; i++) { for (int j = 0; j < h * 4; j++) { @@ -234,32 +234,32 @@ void EditorProfiler::_update_plot() { int current = i * frame_metrics.size() / w; - for (Set<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) { + for (RBSet<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) { const Metric &m = _get_frame_metric(current); float value = 0; - const Map<StringName, Metric::Category *>::Element *F = m.category_ptrs.find(E->get()); + HashMap<StringName, Metric::Category *>::ConstIterator F = m.category_ptrs.find(E->get()); if (F) { - value = F->get()->total_time; + value = F->value->total_time; } - const Map<StringName, Metric::Category::Item *>::Element *G = m.item_ptrs.find(E->get()); + HashMap<StringName, Metric::Category::Item *>::ConstIterator G = m.item_ptrs.find(E->get()); if (G) { if (use_self) { - value = G->get()->self; + value = G->value->self; } else { - value = G->get()->total; + value = G->value->total; } } int plot_pos = CLAMP(int(value * h / highest), 0, h - 1); int prev_plot = plot_pos; - Map<StringName, int>::Element *H = prev_plots.find(E->get()); + HashMap<StringName, int>::Iterator H = prev_plots.find(E->get()); if (H) { - prev_plot = H->get(); - H->get() = plot_pos; + prev_plot = H->value; + H->value = plot_pos; } else { prev_plots[E->get()] = plot_pos; } @@ -515,7 +515,7 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const { } // Different metrics may contain different number of categories. - Set<StringName> possible_signatures; + RBSet<StringName> possible_signatures; for (int i = 0; i < frame_metrics.size(); i++) { const Metric &m = frame_metrics[i]; if (!m.valid) { @@ -530,11 +530,11 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const { } // Generate CSV header and cache indices. - Map<StringName, int> sig_map; + HashMap<StringName, int> sig_map; Vector<String> signatures; signatures.resize(possible_signatures.size()); int sig_index = 0; - for (const Set<StringName>::Element *E = possible_signatures.front(); E; E = E->next()) { + for (const RBSet<StringName>::Element *E = possible_signatures.front(); E; E = E->next()) { signatures.write[sig_index] = E->get(); sig_map[E->get()] = sig_index; sig_index++; diff --git a/editor/debugger/editor_profiler.h b/editor/debugger/editor_profiler.h index 2aef654a2f..77fbb254dc 100644 --- a/editor/debugger/editor_profiler.h +++ b/editor/debugger/editor_profiler.h @@ -73,8 +73,8 @@ public: Vector<Category> categories; - Map<StringName, Category *> category_ptrs; - Map<StringName, Category::Item *> item_ptrs; + HashMap<StringName, Category *> category_ptrs; + HashMap<StringName, Category::Item *> item_ptrs; }; enum DisplayMode { @@ -98,7 +98,7 @@ private: Tree *variables = nullptr; HSplitContainer *h_split = nullptr; - Set<StringName> plot_sigs; + RBSet<StringName> plot_sigs; OptionButton *display_mode = nullptr; OptionButton *display_time = nullptr; diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 90679657ba..44a7aade09 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -742,9 +742,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da bool parsed = false; const String cap = p_msg.substr(0, colon_index); - Map<StringName, Callable>::Element *element = captures.find(cap); + HashMap<StringName, Callable>::Iterator element = captures.find(cap); if (element) { - Callable &c = element->value(); + Callable &c = element->value; ERR_FAIL_COND_MSG(c.is_null(), "Invalid callable registered: " + cap); Variant cmd = p_msg.substr(colon_index + 1), data = p_data; const Variant *args[2] = { &cmd, &data }; @@ -1050,10 +1050,10 @@ int ScriptEditorDebugger::_get_node_path_cache(const NodePath &p_path) { } int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) { - Map<String, int>::Element *E = res_path_cache.find(p_path); + HashMap<String, int>::Iterator E = res_path_cache.find(p_path); if (E) { - return E->get(); + return E->value; } last_path_id++; diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h index ad90e63c16..d445fe48d1 100644 --- a/editor/debugger/script_editor_debugger.h +++ b/editor/debugger/script_editor_debugger.h @@ -131,7 +131,7 @@ private: // Each debugger should have it's tree in the future I guess. const Tree *editor_remote_tree = nullptr; - Map<int, String> profiler_signature; + HashMap<int, String> profiler_signature; Tree *vmem_tree = nullptr; Button *vmem_refresh = nullptr; @@ -147,7 +147,7 @@ private: HashMap<NodePath, int> node_path_cache; int last_path_id; - Map<String, int> res_path_cache; + HashMap<String, int> res_path_cache; EditorProfiler *profiler = nullptr; EditorVisualProfiler *visual_profiler = nullptr; @@ -163,9 +163,9 @@ private: EditorDebuggerNode::CameraOverride camera_override; - Map<Ref<Script>, EditorDebuggerPlugin *> debugger_plugins; + HashMap<Ref<Script>, EditorDebuggerPlugin *> debugger_plugins; - Map<StringName, Callable> captures; + HashMap<StringName, Callable> captures; void _stack_dump_frame_selected(); diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 54655f53b5..5b5e0203a3 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -40,7 +40,7 @@ #include "scene/gui/margin_container.h" void DependencyEditor::_searched(const String &p_path) { - Map<String, String> dep_rename; + HashMap<String, String> dep_rename; dep_rename[replacing] = p_path; ResourceLoader::rename_dependencies(editing, dep_rename); @@ -64,7 +64,7 @@ void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) { search->popup_file_dialog(); } -void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String>> &candidates) { +void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, HashMap<String, HashMap<String, String>> &candidates) { for (int i = 0; i < efsd->get_subdir_count(); i++) { _fix_and_find(efsd->get_subdir(i), candidates); } @@ -121,12 +121,12 @@ void DependencyEditor::_fix_all() { return; } - Map<String, Map<String, String>> candidates; + HashMap<String, HashMap<String, String>> candidates; for (const String &E : missing) { String base = E.get_file(); if (!candidates.has(base)) { - candidates[base] = Map<String, String>(); + candidates[base] = HashMap<String, String>(); } candidates[base][E] = ""; @@ -134,9 +134,9 @@ void DependencyEditor::_fix_all() { _fix_and_find(EditorFileSystem::get_singleton()->get_filesystem(), candidates); - Map<String, String> remaps; + HashMap<String, String> remaps; - for (KeyValue<String, Map<String, String>> &E : candidates) { + for (KeyValue<String, HashMap<String, String>> &E : candidates) { for (const KeyValue<String, String> &F : E.value) { if (!F.value.is_empty()) { remaps[F.key] = F.value; @@ -414,7 +414,7 @@ void DependencyRemoveDialog::_build_removed_dependency_tree(const Vector<Removed owners->clear(); owners->create_item(); // root - Map<String, TreeItem *> tree_items; + HashMap<String, TreeItem *> tree_items; for (int i = 0; i < p_removed.size(); i++) { RemovedDependency rd = p_removed[i]; diff --git a/editor/dependency_editor.h b/editor/dependency_editor.h index ea86f98193..585143fe0a 100644 --- a/editor/dependency_editor.h +++ b/editor/dependency_editor.h @@ -51,7 +51,7 @@ class DependencyEditor : public AcceptDialog { String editing; List<String> missing; - void _fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String>> &candidates); + void _fix_and_find(EditorFileSystemDirectory *efsd, HashMap<String, HashMap<String, String>> &candidates); void _searched(const String &p_path); void _load_pressed(Object *p_item, int p_cell, int p_button); @@ -98,7 +98,7 @@ class DependencyRemoveDialog : public ConfirmationDialog { Label *text = nullptr; Tree *owners = nullptr; - Map<String, String> all_remove_files; + HashMap<String, String> all_remove_files; Vector<String> dirs_to_delete; Vector<String> files_to_delete; diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index 16cbc0f34d..65216d7664 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -331,7 +331,7 @@ void DocTools::generate(bool p_basic_types) { bool skip_setter_getter_methods = true; while (classes.size()) { - Set<StringName> setters_getters; + RBSet<StringName> setters_getters; String name = classes.front()->get(); if (!ClassDB::is_class_exposed(name)) { @@ -1337,7 +1337,7 @@ static void _write_method_doc(Ref<FileAccess> f, const String &p_name, Vector<Do } } -Error DocTools::save_classes(const String &p_default_path, const Map<String, String> &p_class_path) { +Error DocTools::save_classes(const String &p_default_path, const HashMap<String, String> &p_class_path) { for (KeyValue<String, DocData::ClassDoc> &E : class_list) { DocData::ClassDoc &c = E.value; diff --git a/editor/doc_tools.h b/editor/doc_tools.h index 6c3a93de59..843cdf87a6 100644 --- a/editor/doc_tools.h +++ b/editor/doc_tools.h @@ -36,7 +36,7 @@ class DocTools { public: String version; - Map<String, DocData::ClassDoc> class_list; + HashMap<String, DocData::ClassDoc> class_list; static Error erase_classes(const String &p_dir); @@ -47,7 +47,7 @@ public: bool has_doc(const String &p_class_name); void generate(bool p_basic_types = false); Error load_classes(const String &p_dir); - Error save_classes(const String &p_default_path, const Map<String, String> &p_class_path); + Error save_classes(const String &p_default_path, const HashMap<String, String> &p_class_path); Error _load(Ref<XMLParser> parser); Error load_compressed(const uint8_t *p_data, int p_compressed_size, int p_uncompressed_size); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 7dcb9a4088..93b155bcd2 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -62,9 +62,10 @@ void EditorAssetInstaller::_check_propagated_to_item(Object *p_obj, int column) void EditorAssetInstaller::open(const String &p_path, int p_depth) { package_path = p_path; - Set<String> files_sorted; + RBSet<String> files_sorted; - zlib_filefunc_def io = zipio_create_io(); + Ref<FileAccess> io_fa; + zlib_filefunc_def io = zipio_create_io(&io_fa); unzFile pkg = unzOpen2(p_path.utf8().get_data(), &io); if (!pkg) { @@ -86,7 +87,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { ret = unzGoToNextFile(pkg); } - Map<String, Ref<Texture2D>> extension_guess; + HashMap<String, Ref<Texture2D>> extension_guess; { extension_guess["bmp"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); extension_guess["dds"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); @@ -149,11 +150,11 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { root->set_icon(0, tree->get_theme_icon(SNAME("folder"), SNAME("FileDialog"))); root->set_text(0, "res://"); root->set_editable(0, true); - Map<String, TreeItem *> dir_map; + HashMap<String, TreeItem *> dir_map; int num_file_conflicts = 0; - for (Set<String>::Element *E = files_sorted.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = files_sorted.front(); E; E = E->next()) { String path = E->get(); int depth = p_depth; bool skip = false; @@ -237,7 +238,8 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { } void EditorAssetInstaller::ok_pressed() { - zlib_filefunc_def io = zipio_create_io(); + Ref<FileAccess> io_fa; + zlib_filefunc_def io = zipio_create_io(&io_fa); unzFile pkg = unzOpen2(package_path.utf8().get_data(), &io); if (!pkg) { diff --git a/editor/editor_asset_installer.h b/editor/editor_asset_installer.h index deb320e7fa..c44f4c5d22 100644 --- a/editor/editor_asset_installer.h +++ b/editor/editor_asset_installer.h @@ -41,7 +41,7 @@ class EditorAssetInstaller : public ConfirmationDialog { String package_path; String asset_name; AcceptDialog *error = nullptr; - Map<String, TreeItem *> status_map; + HashMap<String, TreeItem *> status_map; bool updating = false; void _item_edited(); void _check_propagated_to_item(Object *p_obj, int column); diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 3b38ff9163..4c73e36269 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -428,7 +428,7 @@ void EditorAutoloadSettings::update_autoload() { updating_autoload = true; - Map<String, AutoloadInfo> to_remove; + HashMap<String, AutoloadInfo> to_remove; List<AutoloadInfo *> to_add; for (const AutoloadInfo &info : autoload_cache) { diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp index d13d1a6c68..e3cbd8ad50 100644 --- a/editor/editor_command_palette.cpp +++ b/editor/editor_command_palette.cpp @@ -57,20 +57,19 @@ float EditorCommandPalette::_score_path(const String &p_search, const String &p_ } void EditorCommandPalette::_update_command_search(const String &search_text) { - commands.get_key_list(&command_keys); - ERR_FAIL_COND(command_keys.is_empty()); + ERR_FAIL_COND(commands.size() == 0); - Map<String, TreeItem *> sections; + HashMap<String, TreeItem *> sections; TreeItem *first_section = nullptr; // Filter possible candidates. Vector<CommandEntry> entries; - for (int i = 0; i < command_keys.size(); i++) { + for (const KeyValue<String, Command> &E : commands) { CommandEntry r; - r.key_name = command_keys[i]; - r.display_name = commands[r.key_name].name; - r.shortcut_text = commands[r.key_name].shortcut; - r.last_used = commands[r.key_name].last_used; + r.key_name = E.key; + r.display_name = E.value.name; + r.shortcut_text = E.value.shortcut; + r.last_used = E.value.last_used; if (search_text.is_subsequence_ofn(r.display_name)) { if (!search_text.is_empty()) { @@ -180,7 +179,9 @@ void EditorCommandPalette::open_popup() { } void EditorCommandPalette::get_actions_list(List<String> *p_list) const { - commands.get_key_list(p_list); + for (const KeyValue<String, Command> &E : commands) { + p_list->push_back(E.key); + } } void EditorCommandPalette::remove_command(String p_key_name) { @@ -229,17 +230,14 @@ void EditorCommandPalette::execute_command(String &p_command_key) { } void EditorCommandPalette::register_shortcuts_as_command() { - const String *key = nullptr; - key = unregistered_shortcuts.next(key); - while (key != nullptr) { - String command_name = unregistered_shortcuts[*key].first; - Ref<Shortcut> shortcut = unregistered_shortcuts[*key].second; + for (const KeyValue<String, Pair<String, Ref<Shortcut>>> &E : unregistered_shortcuts) { + String command_name = E.value.first; + Ref<Shortcut> shortcut = E.value.second; Ref<InputEventShortcut> ev; ev.instantiate(); ev->set_shortcut(shortcut); String shortcut_text = String(shortcut->get_as_text()); - add_command(command_name, *key, callable_mp(EditorNode::get_singleton()->get_viewport(), &Viewport::push_unhandled_input), varray(ev, false), shortcut_text); - key = unregistered_shortcuts.next(key); + add_command(command_name, E.key, callable_mp(EditorNode::get_singleton()->get_viewport(), &Viewport::push_unhandled_input), varray(ev, false), shortcut_text); } unregistered_shortcuts.clear(); @@ -276,12 +274,10 @@ void EditorCommandPalette::_theme_changed() { void EditorCommandPalette::_save_history() const { Dictionary command_history; - List<String> command_keys; - commands.get_key_list(&command_keys); - for (const String &key : command_keys) { - if (commands[key].last_used > 0) { - command_history[key] = commands[key].last_used; + for (const KeyValue<String, Command> &E : commands) { + if (E.value.last_used > 0) { + command_history[E.key] = E.value.last_used; } } EditorSettings::get_singleton()->set_project_metadata("command_palette", "command_history", command_history); diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 7ce483d788..0bb48db09e 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -468,12 +468,12 @@ Variant EditorData::instance_custom_type(const String &p_type, const String &p_i } void EditorData::remove_custom_type(const String &p_type) { - for (Map<String, Vector<CustomType>>::Element *E = custom_types.front(); E; E = E->next()) { - for (int i = 0; i < E->get().size(); i++) { - if (E->get()[i].name == p_type) { - E->get().remove_at(i); - if (E->get().is_empty()) { - custom_types.erase(E->key()); + for (KeyValue<String, Vector<CustomType>> &E : custom_types) { + for (int i = 0; i < E.value.size(); i++) { + if (E.value[i].name == p_type) { + E.value.remove_at(i); + if (E.value.is_empty()) { + custom_types.erase(E.key); } return; } @@ -549,7 +549,7 @@ void EditorData::remove_scene(int p_idx) { edited_scene.remove_at(p_idx); } -bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> &checked_paths) { +bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, RBSet<String> &checked_paths) { Ref<SceneState> ss; if (p_node == p_root) { @@ -587,7 +587,7 @@ bool EditorData::check_and_update_scene(int p_idx) { return false; } - Set<String> checked_scenes; + RBSet<String> checked_scenes; bool must_reload = _find_updated_instances(edited_scene[p_idx].root, edited_scene[p_idx].root, checked_scenes); @@ -945,13 +945,10 @@ void EditorData::script_class_set_name(const String &p_path, const StringName &p } void EditorData::script_class_save_icon_paths() { - List<StringName> keys; - _script_class_icon_paths.get_key_list(&keys); - Dictionary d; - for (const StringName &E : keys) { - if (ScriptServer::is_global_class(E)) { - d[E] = _script_class_icon_paths[E]; + for (const KeyValue<StringName, String> &E : _script_class_icon_paths) { + if (ScriptServer::is_global_class(E.key)) { + d[E.key] = E.value; } } @@ -1157,7 +1154,7 @@ List<Node *> EditorSelection::get_full_selected_node_list() { void EditorSelection::clear() { while (!selection.is_empty()) { - remove_node(selection.front()->key()); + remove_node(selection.begin()->key); } changed = true; diff --git a/editor/editor_data.h b/editor/editor_data.h index 1e9b8af490..b9eb199c37 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -129,17 +129,17 @@ private: String name; Variant value; }; - Map<String, Vector<CustomType>> custom_types; + HashMap<String, Vector<CustomType>> custom_types; List<PropertyData> clipboard; UndoRedo undo_redo; Vector<Callable> undo_redo_callbacks; - Map<StringName, Callable> move_element_functions; + HashMap<StringName, Callable> move_element_functions; Vector<EditedScene> edited_scene; int current_edited_scene; - bool _find_updated_instances(Node *p_root, Node *p_node, Set<String> &checked_paths); + bool _find_updated_instances(Node *p_root, Node *p_node, RBSet<String> &checked_paths); HashMap<StringName, String> _script_class_icon_paths; HashMap<String, StringName> _script_class_file_to_path; @@ -181,7 +181,7 @@ public: void add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon); Variant instance_custom_type(const String &p_type, const String &p_inherits); void remove_custom_type(const String &p_type); - const Map<String, Vector<CustomType>> &get_custom_types() const { return custom_types; } + const HashMap<String, Vector<CustomType>> &get_custom_types() const { return custom_types; } void instantiate_object_properties(Object *p_object); @@ -247,7 +247,7 @@ class EditorSelection : public Object { // Contains the selected nodes and corresponding metadata. // Metadata objects come from calling _get_editor_data on the editor_plugins, passing the selected node. - Map<Node *, Object *> selection; + HashMap<Node *, Object *> selection; // Tracks whether the selection change signal has been emitted. // Prevents multiple signals being called in one frame. @@ -296,7 +296,7 @@ public: // Returns all the selected nodes (list version of "get_selected_nodes"). List<Node *> get_full_selected_node_list(); // Returns the map of selected objects and their metadata. - Map<Node *, Object *> &get_selection() { return selection; } + HashMap<Node *, Object *> &get_selection() { return selection; } EditorSelection(); ~EditorSelection(); diff --git a/editor/editor_dir_dialog.h b/editor/editor_dir_dialog.h index 9baa37793b..60abfeb66f 100644 --- a/editor/editor_dir_dialog.h +++ b/editor/editor_dir_dialog.h @@ -44,7 +44,7 @@ class EditorDirDialog : public ConfirmationDialog { AcceptDialog *mkdirerr = nullptr; Button *makedir = nullptr; - Set<String> opened_paths; + RBSet<String> opened_paths; Tree *tree = nullptr; bool updating = false; diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index a21ee46818..f0eea50d3a 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -95,7 +95,7 @@ Ref<EditorExportPlatform> EditorExportPreset::get_platform() const { void EditorExportPreset::update_files_to_export() { Vector<String> to_remove; - for (Set<String>::Element *E = selected_files.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = selected_files.front(); E; E = E->next()) { if (!FileAccess::exists(E->get())) { to_remove.push_back(E->get()); } @@ -107,7 +107,7 @@ void EditorExportPreset::update_files_to_export() { Vector<String> EditorExportPreset::get_files_to_export() const { Vector<String> files; - for (Set<String>::Element *E = selected_files.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = selected_files.front(); E; E = E->next()) { files.push_back(E->get()); } return files; @@ -446,7 +446,7 @@ Ref<EditorExportPreset> EditorExportPlatform::create_preset() { return preset; } -void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir, Set<String> &p_paths) { +void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir, RBSet<String> &p_paths) { for (int i = 0; i < p_dir->get_subdir_count(); i++) { _export_find_resources(p_dir->get_subdir(i), p_paths); } @@ -459,7 +459,7 @@ void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_d } } -void EditorExportPlatform::_export_find_dependencies(const String &p_path, Set<String> &p_paths) { +void EditorExportPlatform::_export_find_dependencies(const String &p_path, RBSet<String> &p_paths) { if (p_paths.has(p_path)) { return; } @@ -480,7 +480,7 @@ void EditorExportPlatform::_export_find_dependencies(const String &p_path, Set<S } } -void EditorExportPlatform::_edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, Set<String> &r_list, bool exclude) { +void EditorExportPlatform::_edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, RBSet<String> &r_list, bool exclude) { da->list_dir_begin(); String cur_dir = da->get_current_dir().replace("\\", "/"); if (!cur_dir.ends_with("/")) { @@ -528,7 +528,7 @@ void EditorExportPlatform::_edit_files_with_filter(Ref<DirAccess> &da, const Vec } } -void EditorExportPlatform::_edit_filter_list(Set<String> &r_list, const String &p_filter, bool exclude) { +void EditorExportPlatform::_edit_filter_list(RBSet<String> &r_list, const String &p_filter, bool exclude) { if (p_filter.is_empty()) { return; } @@ -648,10 +648,10 @@ void EditorExportPlugin::_export_end_script() { GDVIRTUAL_CALL(_export_end); } -void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) { +void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const RBSet<String> &p_features) { } -void EditorExportPlugin::_export_begin(const Set<String> &p_features, bool p_debug, const String &p_path, int p_flags) { +void EditorExportPlugin::_export_begin(const RBSet<String> &p_features, bool p_debug, const String &p_path, int p_flags) { } void EditorExportPlugin::skip() { @@ -739,7 +739,7 @@ EditorExportPlatform::ExportNotifier::~ExportNotifier() { Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &p_preset, bool p_debug, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func) { //figure out paths of files that will be exported - Set<String> paths; + RBSet<String> paths; Vector<String> path_remaps; if (p_preset->get_export_filter() == EditorExportPreset::EXPORT_ALL_RESOURCES) { @@ -872,14 +872,14 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } FeatureContainers feature_containers = get_feature_containers(p_preset, p_debug); - Set<String> &features = feature_containers.features; + RBSet<String> &features = feature_containers.features; Vector<String> &features_pv = feature_containers.features_pv; //store everything in the export medium int idx = 0; int total = paths.size(); - for (Set<String>::Element *E = paths.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = paths.front(); E; E = E->next()) { String path = E->get(); String type = ResourceLoader::get_resource_type(path); @@ -910,7 +910,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & List<String> remaps; config->get_section_keys("remap", &remaps); - Set<String> remap_features; + RBSet<String> remap_features; for (const String &F : remaps) { String remap = F; @@ -1334,7 +1334,8 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) { EditorProgress ep("savezip", TTR("Packing"), 102, true); - zlib_filefunc_def io = zipio_create_io(); + Ref<FileAccess> io_fa; + zlib_filefunc_def io = zipio_create_io(&io_fa); zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io); ZipData zd; @@ -1668,7 +1669,7 @@ void EditorExport::load_config() { } void EditorExport::update_export_presets() { - Map<StringName, List<EditorExportPlatform::ExportOption>> platform_options; + HashMap<StringName, List<EditorExportPlatform::ExportOption>> platform_options; for (int i = 0; i < export_platforms.size(); i++) { Ref<EditorExportPlatform> platform = export_platforms[i]; @@ -1690,7 +1691,7 @@ void EditorExport::update_export_presets() { List<EditorExportPlatform::ExportOption> options = platform_options[preset->get_platform()->get_name()]; // Copy the previous preset values - Map<StringName, Variant> previous_values = preset->values; + HashMap<StringName, Variant> previous_values = preset->values; // Clear the preset properties and values prior to reloading preset->properties.clear(); @@ -1933,7 +1934,7 @@ void EditorExportPlatformPC::get_platform_features(List<String> *r_features) { r_features->push_back(get_os_name().to_lower()); //OS name is a feature } -void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) { +void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, RBSet<String> &p_features) { if (p_features.has("bptc")) { if (p_preset->has("texture_format/no_bptc_fallbacks")) { p_features.erase("s3tc"); @@ -1951,7 +1952,7 @@ void EditorExportPlatformPC::set_chmod_flags(int p_flags) { /////////////////////// -void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) { +void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const RBSet<String> &p_features) { String extension = p_path.get_extension().to_lower(); if (extension != "tres" && extension != "tscn") { return; diff --git a/editor/editor_export.h b/editor/editor_export.h index 1aca140e79..3b8ff0f686 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -66,14 +66,14 @@ private: String export_path; String exporter; - Set<String> selected_files; + RBSet<String> selected_files; bool runnable = false; friend class EditorExport; friend class EditorExportPlatform; List<PropertyInfo> properties; - Map<StringName, Variant> values; + HashMap<StringName, Variant> values; String name; @@ -196,19 +196,19 @@ private: }; struct FeatureContainers { - Set<String> features; + RBSet<String> features; Vector<String> features_pv; }; - void _export_find_resources(EditorFileSystemDirectory *p_dir, Set<String> &p_paths); - void _export_find_dependencies(const String &p_path, Set<String> &p_paths); + void _export_find_resources(EditorFileSystemDirectory *p_dir, RBSet<String> &p_paths); + void _export_find_dependencies(const String &p_path, RBSet<String> &p_paths); void gen_debug_flags(Vector<String> &r_flags, int p_flags); static Error _save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); - void _edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, Set<String> &r_list, bool exclude); - void _edit_filter_list(Set<String> &r_list, const String &p_filter, bool exclude); + void _edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, RBSet<String> &r_list, bool exclude); + void _edit_filter_list(RBSet<String> &r_list, const String &p_filter, bool exclude); static Error _add_shared_object(void *p_userdata, const SharedObject &p_so); @@ -242,7 +242,7 @@ public: virtual void get_export_options(List<ExportOption> *r_options) = 0; virtual bool should_update_export_options() { return false; } - virtual bool get_export_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { return true; } + virtual bool get_export_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; } virtual String get_os_name() const = 0; virtual String get_name() const = 0; @@ -279,7 +279,7 @@ public: virtual Error export_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0); virtual Error export_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0); virtual void get_platform_features(List<String> *r_features) = 0; - virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) = 0; + virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, RBSet<String> &p_features) = 0; virtual String get_debug_protocol() const { return "tcp://"; } EditorExportPlatform(); @@ -349,8 +349,8 @@ protected: void skip(); - virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features); - virtual void _export_begin(const Set<String> &p_features, bool p_debug, const String &p_path, int p_flags); + virtual void _export_file(const String &p_path, const String &p_type, const RBSet<String> &p_features); + virtual void _export_begin(const RBSet<String> &p_features, bool p_debug, const String &p_path, int p_flags); static void _bind_methods(); @@ -454,7 +454,7 @@ public: void add_platform_feature(const String &p_feature); virtual void get_platform_features(List<String> *r_features) override; - virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) override; + virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, RBSet<String> &p_features) override; int get_chmod_flags() const; void set_chmod_flags(int p_flags); @@ -468,7 +468,7 @@ class EditorExportTextSceneToBinaryPlugin : public EditorExportPlugin { GDCLASS(EditorExportTextSceneToBinaryPlugin, EditorExportPlugin); public: - virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features) override; + virtual void _export_file(const String &p_path, const String &p_type, const RBSet<String> &p_features) override; EditorExportTextSceneToBinaryPlugin(); }; diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index a20f112b2a..7eb5aec5d0 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -101,7 +101,7 @@ bool EditorFeatureProfile::is_class_editor_disabled(const StringName &p_class) c void EditorFeatureProfile::set_disable_class_property(const StringName &p_class, const StringName &p_property, bool p_disabled) { if (p_disabled) { if (!disabled_properties.has(p_class)) { - disabled_properties[p_class] = Set<StringName>(); + disabled_properties[p_class] = RBSet<StringName>(); } disabled_properties[p_class].insert(p_property); @@ -166,14 +166,14 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) { Dictionary data; data["type"] = "feature_profile"; Array dis_classes; - for (Set<StringName>::Element *E = disabled_classes.front(); E; E = E->next()) { + for (RBSet<StringName>::Element *E = disabled_classes.front(); E; E = E->next()) { dis_classes.push_back(String(E->get())); } dis_classes.sort(); data["disabled_classes"] = dis_classes; Array dis_editors; - for (Set<StringName>::Element *E = disabled_editors.front(); E; E = E->next()) { + for (RBSet<StringName>::Element *E = disabled_editors.front(); E; E = E->next()) { dis_editors.push_back(String(E->get())); } dis_editors.sort(); @@ -181,8 +181,8 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) { Array dis_props; - for (KeyValue<StringName, Set<StringName>> &E : disabled_properties) { - for (Set<StringName>::Element *F = E.value.front(); F; F = F->next()) { + for (KeyValue<StringName, RBSet<StringName>> &E : disabled_properties) { + for (RBSet<StringName>::Element *F = E.value.front(); F; F = F->next()) { dis_props.push_back(String(E.key) + ":" + String(F->get())); } } @@ -556,9 +556,9 @@ void EditorFeatureProfileManager::_class_list_item_selected() { String class_description; DocTools *dd = EditorHelp::get_doc_data(); - Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(class_name); + HashMap<String, DocData::ClassDoc>::Iterator E = dd->class_list.find(class_name); if (E) { - class_description = DTR(E->get().brief_description); + class_description = DTR(E->value.brief_description); } description_bit->set_text(class_description); diff --git a/editor/editor_feature_profile.h b/editor/editor_feature_profile.h index 19df8a9686..479baf5205 100644 --- a/editor/editor_feature_profile.h +++ b/editor/editor_feature_profile.h @@ -56,11 +56,11 @@ public: }; private: - Set<StringName> disabled_classes; - Set<StringName> disabled_editors; - Map<StringName, Set<StringName>> disabled_properties; + RBSet<StringName> disabled_classes; + RBSet<StringName> disabled_editors; + HashMap<StringName, RBSet<StringName>> disabled_properties; - Set<StringName> collapsed_classes; + RBSet<StringName> collapsed_classes; bool features_disabled[FEATURE_MAX]; static const char *feature_names[FEATURE_MAX]; diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 099dfe69d5..36ac9afca8 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -514,7 +514,7 @@ bool EditorFileSystem::_scan_import_support(Vector<String> reimports) { if (import_support_queries.size() == 0) { return false; } - Map<String, int> import_support_test; + HashMap<String, int> import_support_test; Vector<bool> import_support_tested; import_support_tested.resize(import_support_queries.size()); for (int i = 0; i < import_support_queries.size(); i++) { @@ -532,9 +532,9 @@ bool EditorFileSystem::_scan_import_support(Vector<String> reimports) { } for (int i = 0; i < reimports.size(); i++) { - Map<String, int>::Element *E = import_support_test.find(reimports[i].get_extension()); + HashMap<String, int>::Iterator E = import_support_test.find(reimports[i].get_extension()); if (E) { - import_support_tested.write[E->get()] = true; + import_support_tested.write[E->value] = true; } } @@ -1458,7 +1458,7 @@ void EditorFileSystem::_save_late_updated_files() { String fscache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file("filesystem_update4"); Ref<FileAccess> f = FileAccess::open(fscache, FileAccess::WRITE); ERR_FAIL_COND_MSG(f.is_null(), "Cannot create file '" + fscache + "'. Check user write permissions."); - for (Set<String>::Element *E = late_update_files.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = late_update_files.front(); E; E = E->next()) { f->store_line(E->get()); } } @@ -1636,15 +1636,15 @@ void EditorFileSystem::update_file(const String &p_file) { _queue_update_script_classes(); } -Set<String> EditorFileSystem::get_valid_extensions() const { +RBSet<String> EditorFileSystem::get_valid_extensions() const { return valid_extensions; } Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector<String> &p_files) { String importer_name; - Map<String, Map<StringName, Variant>> source_file_options; - Map<String, String> base_paths; + HashMap<String, HashMap<StringName, Variant>> source_file_options; + HashMap<String, String> base_paths; for (int i = 0; i < p_files.size(); i++) { Ref<ConfigFile> config; config.instantiate(); @@ -1659,7 +1659,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector ERR_FAIL_V(ERR_FILE_CORRUPT); } - source_file_options[p_files[i]] = Map<StringName, Variant>(); + source_file_options[p_files[i]] = HashMap<StringName, Variant>(); importer_name = file_importer_name; if (importer_name == "keep") { @@ -1699,7 +1699,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector Error err = importer->import_group_file(p_group_file, source_file_options, base_paths); //all went well, overwrite config files with proper remaps and md5s - for (const KeyValue<String, Map<StringName, Variant>> &E : source_file_options) { + for (const KeyValue<String, HashMap<StringName, Variant>> &E : source_file_options) { const String &file = E.key; String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(file); Vector<String> dest_paths; @@ -1808,7 +1808,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector return err; } -void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName, Variant> *p_custom_options, const String &p_custom_importer) { +void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<StringName, Variant> *p_custom_options, const String &p_custom_importer) { EditorFileSystemDirectory *fs = nullptr; int cpos = -1; bool found = _find_file(p_file, &fs, cpos); @@ -1816,7 +1816,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName //try to obtain existing params - Map<StringName, Variant> params; + HashMap<StringName, Variant> params; String importer_name; //empty by default though if (!p_custom_importer.is_empty()) { @@ -2047,7 +2047,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName EditorResourcePreview::get_singleton()->check_for_invalidation(p_file); } -void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, Map<String, Vector<String>> &group_files, Set<String> &groups_to_reimport) { +void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, HashMap<String, Vector<String>> &group_files, RBSet<String> &groups_to_reimport) { int fc = efd->files.size(); const EditorFileSystemDirectory::FileInfo *const *files = efd->files.ptr(); for (int i = 0; i < fc; i++) { @@ -2064,7 +2064,7 @@ void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, Map<Str } } -void EditorFileSystem::reimport_file_with_custom_parameters(const String &p_file, const String &p_importer, const Map<StringName, Variant> &p_custom_params) { +void EditorFileSystem::reimport_file_with_custom_parameters(const String &p_file, const String &p_importer, const HashMap<StringName, Variant> &p_custom_params) { _reimport_file(p_file, &p_custom_params, p_importer); } @@ -2079,7 +2079,7 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { Vector<ImportFile> reimport_files; - Set<String> groups_to_reimport; + RBSet<String> groups_to_reimport; for (int i = 0; i < p_files.size(); i++) { String file = p_files[i]; @@ -2165,7 +2165,7 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { //reimport groups if (groups_to_reimport.size()) { - Map<String, Vector<String>> group_files; + HashMap<String, Vector<String>> group_files; _find_group_files(filesystem, group_files, groups_to_reimport); for (const KeyValue<String, Vector<String>> &E : group_files) { Error err = _reimport_group(E.key, E.value); @@ -2290,7 +2290,7 @@ ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const } } -static void _scan_extensions_dir(EditorFileSystemDirectory *d, Set<String> &extensions) { +static void _scan_extensions_dir(EditorFileSystemDirectory *d, RBSet<String> &extensions) { int fc = d->get_file_count(); for (int i = 0; i < fc; i++) { if (d->get_file_type(i) == SNAME("NativeExtension")) { @@ -2304,7 +2304,7 @@ static void _scan_extensions_dir(EditorFileSystemDirectory *d, Set<String> &exte } bool EditorFileSystem::_scan_extensions() { EditorFileSystemDirectory *d = get_filesystem(); - Set<String> extensions; + RBSet<String> extensions; _scan_extensions_dir(d, extensions); diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 81811d2eb0..743684a9ca 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -34,8 +34,8 @@ #include "core/io/dir_access.h" #include "core/os/thread.h" #include "core/os/thread_safe.h" +#include "core/templates/rb_set.h" #include "core/templates/safe_refcount.h" -#include "core/templates/set.h" #include "core/templates/thread_work_pool.h" #include "scene/main/node.h" @@ -180,7 +180,7 @@ class EditorFileSystem : public Node { void _scan_filesystem(); - Set<String> late_update_files; + RBSet<String> late_update_files; void _save_late_updated_files(); @@ -221,9 +221,9 @@ class EditorFileSystem : public Node { void _delete_internal_files(String p_file); - Set<String> textfile_extensions; - Set<String> valid_extensions; - Set<String> import_extensions; + RBSet<String> textfile_extensions; + RBSet<String> valid_extensions; + RBSet<String> import_extensions; void _scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAccess> &da, const ScanProgress &p_progress); @@ -240,7 +240,7 @@ class EditorFileSystem : public Node { void _update_extensions(); - void _reimport_file(const String &p_file, const Map<StringName, Variant> *p_custom_options = nullptr, const String &p_custom_importer = String()); + void _reimport_file(const String &p_file, const HashMap<StringName, Variant> *p_custom_options = nullptr, const String &p_custom_importer = String()); Error _reimport_group(const String &p_group_file, const Vector<String> &p_files); bool _test_for_reimport(const String &p_path, bool p_only_imported_files); @@ -269,11 +269,11 @@ class EditorFileSystem : public Node { bool using_fat32_or_exfat; // Workaround for projects in FAT32 or exFAT filesystem (pendrives, most of the time) - void _find_group_files(EditorFileSystemDirectory *efd, Map<String, Vector<String>> &group_files, Set<String> &groups_to_reimport); + void _find_group_files(EditorFileSystemDirectory *efd, HashMap<String, Vector<String>> &group_files, RBSet<String> &groups_to_reimport); void _move_group_files(EditorFileSystemDirectory *efd, const String &p_group_file, const String &p_new_location); - Set<String> group_file_cache; + RBSet<String> group_file_cache; ThreadWorkPool import_threads; @@ -306,7 +306,7 @@ public: void scan(); void scan_changes(); void update_file(const String &p_file); - Set<String> get_valid_extensions() const; + RBSet<String> get_valid_extensions() const; EditorFileSystemDirectory *get_filesystem_path(const String &p_path); String get_file_type(const String &p_file) const; @@ -314,7 +314,7 @@ public: void reimport_files(const Vector<String> &p_files); - void reimport_file_with_custom_parameters(const String &p_file, const String &p_importer, const Map<StringName, Variant> &p_custom_params); + void reimport_file_with_custom_parameters(const String &p_file, const String &p_importer, const HashMap<StringName, Variant> &p_custom_params); void update_script_classes(); diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index 76c7023b46..39dc253429 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -40,7 +40,7 @@ Vector<String> EditorFolding::_get_unfolds(const Object *p_object) { if (sections.size()) { String *w = sections.ptrw(); int idx = 0; - for (const Set<String>::Element *E = p_object->editor_get_section_folding().front(); E; E = E->next()) { + for (const RBSet<String>::Element *E = p_object->editor_get_section_folding().front(); E; E = E->next()) { w[idx++] = E->get(); } } @@ -87,7 +87,7 @@ void EditorFolding::load_resource_folding(Ref<Resource> p_resource, const String _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<Ref<Resource>> &resources) { +void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p_folds, Array &resource_folds, Array &nodes_folded, RBSet<Ref<Resource>> &resources) { if (p_root != p_node) { if (!p_node->get_owner()) { return; //not owned, bye @@ -140,7 +140,7 @@ void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path config.instantiate(); Array unfolds, res_unfolds; - Set<Ref<Resource>> resources; + RBSet<Ref<Resource>> resources; Array nodes_folded; _fill_folds(p_scene, p_scene, unfolds, res_unfolds, nodes_folded, resources); @@ -220,13 +220,13 @@ bool EditorFolding::has_folding_data(const String &p_path) { return FileAccess::exists(file); } -void EditorFolding::_do_object_unfolds(Object *p_object, Set<Ref<Resource>> &resources) { +void EditorFolding::_do_object_unfolds(Object *p_object, RBSet<Ref<Resource>> &resources) { List<PropertyInfo> plist; p_object->get_property_list(&plist); String group_base; String group; - Set<String> unfold_group; + RBSet<String> unfold_group; for (const PropertyInfo &E : plist) { if (E.usage & PROPERTY_USAGE_CATEGORY) { @@ -270,12 +270,12 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<Ref<Resource>> &res } } - for (Set<String>::Element *E = unfold_group.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = unfold_group.front(); E; E = E->next()) { p_object->editor_set_section_unfold(E->get(), true); } } -void EditorFolding::_do_node_unfolds(Node *p_root, Node *p_node, Set<Ref<Resource>> &resources) { +void EditorFolding::_do_node_unfolds(Node *p_root, Node *p_node, RBSet<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<Ref<Resourc } void EditorFolding::unfold_scene(Node *p_scene) { - Set<Ref<Resource>> resources; + RBSet<Ref<Resource>> resources; _do_node_unfolds(p_scene, p_scene, resources); } diff --git a/editor/editor_folding.h b/editor/editor_folding.h index 86f4643ed8..22df06280a 100644 --- a/editor/editor_folding.h +++ b/editor/editor_folding.h @@ -37,10 +37,10 @@ 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<Ref<Resource>> &resources); + void _fill_folds(const Node *p_root, const Node *p_node, Array &p_folds, Array &resource_folds, Array &nodes_folded, RBSet<Ref<Resource>> &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); + void _do_object_unfolds(Object *p_object, RBSet<Ref<Resource>> &resources); + void _do_node_unfolds(Node *p_root, Node *p_node, RBSet<Ref<Resource>> &resources); public: void save_resource_folding(const Ref<Resource> &p_resource, const String &p_path); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index dfd768d0d0..e33d160762 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -99,7 +99,7 @@ void EditorHelp::_class_desc_select(const String &p_select) { String link = p_select.substr(tag_end + 1, p_select.length()).lstrip(" "); String topic; - Map<String, int> *table = nullptr; + HashMap<String, int> *table = nullptr; if (tag == "method") { topic = "class_method"; @@ -123,37 +123,34 @@ void EditorHelp::_class_desc_select(const String &p_select) { return; } - if (link.contains(".")) { - emit_signal(SNAME("go_to_help"), topic + ":" + link.get_slice(".", 0) + ":" + link.get_slice(".", 1)); - } else { - if (table->has(link)) { - // Found in the current page - class_desc->scroll_to_paragraph((*table)[link]); - } else { - if (topic == "class_enum") { - // Try to find the enum in @GlobalScope - const DocData::ClassDoc &cd = doc->class_list["@GlobalScope"]; - - for (int i = 0; i < cd.constants.size(); i++) { - if (cd.constants[i].enumeration == link) { - // Found in @GlobalScope - emit_signal(SNAME("go_to_help"), topic + ":@GlobalScope:" + link); - break; - } - } - } else if (topic == "class_constant") { - // Try to find the constant in @GlobalScope - const DocData::ClassDoc &cd = doc->class_list["@GlobalScope"]; - - for (int i = 0; i < cd.constants.size(); i++) { - if (cd.constants[i].name == link) { - // Found in @GlobalScope - emit_signal(SNAME("go_to_help"), topic + ":@GlobalScope:" + link); - break; - } - } + // Case order is important here to correctly handle edge cases like Variant.Type in @GlobalScope. + if (table->has(link)) { + // Found in the current page. + class_desc->scroll_to_paragraph((*table)[link]); + } else if (topic == "class_enum") { + // Try to find the enum in @GlobalScope. + const DocData::ClassDoc &cd = doc->class_list["@GlobalScope"]; + + for (int i = 0; i < cd.constants.size(); i++) { + if (cd.constants[i].enumeration == link) { + // Found in @GlobalScope. + emit_signal(SNAME("go_to_help"), topic + ":@GlobalScope:" + link); + break; } } + } else if (topic == "class_constant") { + // Try to find the constant in @GlobalScope. + const DocData::ClassDoc &cd = doc->class_list["@GlobalScope"]; + + for (int i = 0; i < cd.constants.size(); i++) { + if (cd.constants[i].name == link) { + // Found in @GlobalScope. + emit_signal(SNAME("go_to_help"), topic + ":@GlobalScope:" + link); + break; + } + } + } else if (link.contains(".")) { + emit_signal(SNAME("go_to_help"), topic + ":" + link.get_slice(".", 0) + ":" + link.get_slice(".", 1)); } } else if (p_select.begins_with("http")) { OS::get_singleton()->shell_open(p_select); @@ -339,7 +336,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { description_line = 0; if (p_class == edited_class) { - return OK; //already there + return OK; // Already there. } edited_class = p_class; @@ -651,7 +648,7 @@ void EditorHelp::_update_doc() { } // Properties overview - Set<String> skip_methods; + RBSet<String> skip_methods; bool property_descr = false; bool has_properties = cd.properties.size() != 0; @@ -876,7 +873,7 @@ void EditorHelp::_update_doc() { class_desc->push_indent(1); String theme_data_type; - Map<String, String> data_type_names; + HashMap<String, String> data_type_names; data_type_names["color"] = TTR("Colors"); data_type_names["constant"] = TTR("Constants"); data_type_names["font"] = TTR("Fonts"); @@ -885,7 +882,7 @@ void EditorHelp::_update_doc() { data_type_names["style"] = TTR("Styles"); for (int i = 0; i < cd.theme_properties.size(); i++) { - theme_property_line[cd.theme_properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description + theme_property_line[cd.theme_properties[i].name] = class_desc->get_line_count() - 2; // Gets overridden if description. if (theme_data_type != cd.theme_properties[i].data_type) { theme_data_type = cd.theme_properties[i].data_type; @@ -970,7 +967,7 @@ void EditorHelp::_update_doc() { class_desc->push_indent(1); for (int i = 0; i < cd.signals.size(); i++) { - signal_line[cd.signals[i].name] = class_desc->get_line_count() - 2; //gets overridden if description + signal_line[cd.signals[i].name] = class_desc->get_line_count() - 2; // Gets overridden if description. class_desc->push_font(doc_code_font); // monofont class_desc->push_color(headline_color); @@ -1022,7 +1019,7 @@ void EditorHelp::_update_doc() { // Constants and enums if (!cd.constants.is_empty()) { - Map<String, Vector<DocData::ConstantDoc>> enums; + HashMap<String, Vector<DocData::ConstantDoc>> enums; Vector<DocData::ConstantDoc> constants; for (int i = 0; i < cd.constants.size(); i++) { @@ -1092,7 +1089,7 @@ void EditorHelp::_update_doc() { class_desc->push_indent(1); Vector<DocData::ConstantDoc> enum_list = E.value; - Map<String, int> enumValuesContainer; + HashMap<String, int> enumValuesContainer; int enumStartingLine = enum_line[E.key]; for (int i = 0; i < enum_list.size(); i++) { @@ -1100,7 +1097,7 @@ void EditorHelp::_update_doc() { enumValuesContainer[enum_list[i].name] = enumStartingLine; } - // Add the enum constant line to the constant_line map so we can locate it as a constant + // Add the enum constant line to the constant_line map so we can locate it as a constant. constant_line[enum_list[i].name] = class_desc->get_line_count() - 2; class_desc->push_font(doc_code_font); @@ -1288,7 +1285,7 @@ void EditorHelp::_update_doc() { // Script doc doesn't have setter, getter. if (!cd.is_script_doc) { - Map<String, DocData::MethodDoc> method_map; + HashMap<String, DocData::MethodDoc> method_map; for (int j = 0; j < methods.size(); j++) { method_map[methods[j].name] = methods[j]; } @@ -1417,7 +1414,7 @@ void EditorHelp::_help_callback(const String &p_topic) { name = p_topic.get_slice(":", 2); } - _request_help(clss); //first go to class + _request_help(clss); // First go to class. int line = 0; @@ -1453,15 +1450,15 @@ void EditorHelp::_help_callback(const String &p_topic) { } else if (method_line.has(name)) { line = method_line[name]; } else { - Map<String, Map<String, int>>::Element *iter = enum_values_line.front(); + HashMap<String, HashMap<String, int>>::Iterator iter = enum_values_line.begin(); while (true) { - if (iter->value().has(name)) { - line = iter->value()[name]; + if (iter->value.has(name)) { + line = iter->value[name]; break; - } else if (iter == enum_values_line.back()) { + } else if (iter == enum_values_line.last()) { break; } else { - iter = iter->next(); + ++iter; } } } @@ -1486,7 +1483,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { String bbcode = p_bbcode.dedent().replace("\t", "").replace("\r", "").strip_edges(); - // Select the correct code examples + // Select the correct code examples. switch ((int)EDITOR_GET("text_editor/help/class_reference_examples")) { case 0: // GDScript bbcode = bbcode.replace("[gdscript]", "[codeblock]"); @@ -1531,13 +1528,13 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { break; } - // Remove codeblocks (they would be printed otherwise) + // Remove codeblocks (they would be printed otherwise). bbcode = bbcode.replace("[codeblocks]\n", ""); bbcode = bbcode.replace("\n[/codeblocks]", ""); bbcode = bbcode.replace("[codeblocks]", ""); bbcode = bbcode.replace("[/codeblocks]", ""); - // remove extra new lines around code blocks + // Remove extra new lines around code blocks. bbcode = bbcode.replace("[codeblock]\n", "[codeblock]"); bbcode = bbcode.replace("\n[/codeblock]", "[/codeblock]"); @@ -1561,7 +1558,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } if (brk_pos == bbcode.length()) { - break; //nothing else to add + break; // Nothing else to add. } int brk_end = bbcode.find("]", brk_pos + 1); @@ -1627,45 +1624,45 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { pos = brk_end + 1; } else if (tag == "b") { - //use bold font + // Use bold font. p_rt->push_font(doc_bold_font); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "i") { - //use italics font + // Use italics font. p_rt->push_font(doc_italic_font); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "code" || tag == "codeblock") { - //use monospace font + // Use monospace font. p_rt->push_font(doc_code_font); p_rt->push_color(code_color); code_tag = true; pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "kbd") { - //use keyboard font with custom color + // Use keyboard font with custom color. p_rt->push_font(doc_kbd_font); p_rt->push_color(kbd_color); - code_tag = true; // though not strictly a code tag, logic is similar + code_tag = true; // Though not strictly a code tag, logic is similar. pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "center") { - //align to center + // Align to center. p_rt->push_paragraph(HORIZONTAL_ALIGNMENT_CENTER, Control::TEXT_DIRECTION_AUTO, ""); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "br") { - //force a line break + // Force a line break. p_rt->add_newline(); pos = brk_end + 1; } else if (tag == "u") { - //use underline + // Use underline. p_rt->push_underline(); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "s") { - //use strikethrough + // Use strikethrough. p_rt->push_strikethrough(); pos = brk_end + 1; tag_stack.push_front(tag); @@ -1741,7 +1738,7 @@ void EditorHelp::_wait_for_thread() { void EditorHelp::_gen_doc_thread(void *p_udata) { DocTools compdoc; compdoc.load_compressed(_doc_data_compressed, _doc_data_compressed_size, _doc_data_uncompressed_size); - doc->merge_from(compdoc); //ensure all is up to date + doc->merge_from(compdoc); // Ensure all is up to date. } static bool doc_gen_use_threads = true; @@ -1935,7 +1932,7 @@ void EditorHelpBit::_meta_clicked(String p_select) { String m = p_select.substr(1, p_select.length()); if (m.contains(".")) { - _go_to_help("class_method:" + m.get_slice(".", 0) + ":" + m.get_slice(".", 0)); //must go somewhere else + _go_to_help("class_method:" + m.get_slice(".", 0) + ":" + m.get_slice(".", 0)); // Must go somewhere else. } } } diff --git a/editor/editor_help.h b/editor/editor_help.h index e289f91414..b5410f6880 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -105,13 +105,13 @@ class EditorHelp : public VBoxContainer { String edited_class; Vector<Pair<String, int>> section_line; - Map<String, int> method_line; - Map<String, int> signal_line; - Map<String, int> property_line; - Map<String, int> theme_property_line; - Map<String, int> constant_line; - Map<String, int> enum_line; - Map<String, Map<String, int>> enum_values_line; + HashMap<String, int> method_line; + HashMap<String, int> signal_line; + HashMap<String, int> property_line; + HashMap<String, int> theme_property_line; + HashMap<String, int> constant_line; + HashMap<String, int> enum_line; + HashMap<String, HashMap<String, int>> enum_values_line; int description_line = 0; RichTextLabel *class_desc = nullptr; diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index c747ae326f..d6ed2297c7 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -313,7 +313,7 @@ bool EditorHelpSearch::Runner::_slice() { } bool EditorHelpSearch::Runner::_phase_match_classes_init() { - iterator_doc = EditorHelp::get_doc_data()->class_list.front(); + iterator_doc = EditorHelp::get_doc_data()->class_list.begin(); matches.clear(); matched_item = nullptr; match_highest_score = 0; @@ -322,7 +322,7 @@ bool EditorHelpSearch::Runner::_phase_match_classes_init() { } bool EditorHelpSearch::Runner::_phase_match_classes() { - DocData::ClassDoc &class_doc = iterator_doc->value(); + DocData::ClassDoc &class_doc = iterator_doc->value; if (!_is_class_disabled_by_feature_profile(class_doc.name)) { matches[class_doc.name] = ClassMatch(); ClassMatch &match = matches[class_doc.name]; @@ -404,12 +404,12 @@ bool EditorHelpSearch::Runner::_phase_match_classes() { matches[class_doc.name] = match; } - iterator_doc = iterator_doc->next(); + ++iterator_doc; return !iterator_doc; } bool EditorHelpSearch::Runner::_phase_class_items_init() { - iterator_match = matches.front(); + iterator_match = matches.begin(); results_tree->clear(); root_item = results_tree->create_item(); @@ -419,7 +419,7 @@ bool EditorHelpSearch::Runner::_phase_class_items_init() { } bool EditorHelpSearch::Runner::_phase_class_items() { - ClassMatch &match = iterator_match->value(); + ClassMatch &match = iterator_match->value; if (search_flags & SEARCH_SHOW_HIERARCHY) { if (match.required()) { @@ -431,18 +431,18 @@ bool EditorHelpSearch::Runner::_phase_class_items() { } } - iterator_match = iterator_match->next(); + ++iterator_match; return !iterator_match; } bool EditorHelpSearch::Runner::_phase_member_items_init() { - iterator_match = matches.front(); + iterator_match = matches.begin(); return true; } bool EditorHelpSearch::Runner::_phase_member_items() { - ClassMatch &match = iterator_match->value(); + ClassMatch &match = iterator_match->value; TreeItem *parent = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item; bool constructor_created = false; @@ -473,7 +473,7 @@ bool EditorHelpSearch::Runner::_phase_member_items() { _create_theme_property_item(parent, match.doc, match.theme_properties[i]); } - iterator_match = iterator_match->next(); + ++iterator_match; return !iterator_match; } diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h index d89bb0959c..7b7235145a 100644 --- a/editor/editor_help_search.h +++ b/editor/editor_help_search.h @@ -31,7 +31,7 @@ #ifndef EDITOR_HELP_SEARCH_H #define EDITOR_HELP_SEARCH_H -#include "core/templates/ordered_hash_map.h" +#include "core/templates/rb_map.h" #include "editor/code_editor.h" #include "editor/editor_help.h" #include "editor/editor_plugin.h" @@ -122,11 +122,11 @@ class EditorHelpSearch::Runner : public RefCounted { Ref<Texture2D> empty_icon; Color disabled_color; - Map<String, DocData::ClassDoc>::Element *iterator_doc = nullptr; - Map<String, ClassMatch> matches; - Map<String, ClassMatch>::Element *iterator_match = nullptr; + HashMap<String, DocData::ClassDoc>::Iterator iterator_doc; + HashMap<String, ClassMatch> matches; + HashMap<String, ClassMatch>::Iterator iterator_match; TreeItem *root_item = nullptr; - Map<String, TreeItem *> class_items; + HashMap<String, TreeItem *> class_items; TreeItem *matched_item = nullptr; float match_highest_score = 0; diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 5db1ef4b2b..f534130735 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -839,7 +839,7 @@ void EditorProperty::_update_pin_flags() { } pin_hidden = false; { - Set<StringName> storable_properties; + RBSet<StringName> storable_properties; node->get_storable_properties(storable_properties); if (storable_properties.has(node->get_property_store_alias(property))) { can_pin = true; @@ -2445,8 +2445,8 @@ void EditorInspector::update_tree() { object->get_property_list(&plist, true); _update_script_class_properties(*object, plist); - Map<VBoxContainer *, HashMap<String, VBoxContainer *>> vbox_per_path; - Map<String, EditorInspectorArray *> editor_inspector_array_per_prefix; + HashMap<VBoxContainer *, HashMap<String, VBoxContainer *>> vbox_per_path; + HashMap<String, EditorInspectorArray *> editor_inspector_array_per_prefix; Color sscolor = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); @@ -2563,9 +2563,9 @@ void EditorInspector::update_tree() { if (!class_descr_cache.has(type2)) { String descr; DocTools *dd = EditorHelp::get_doc_data(); - Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type2); + HashMap<String, DocData::ClassDoc>::Iterator E = dd->class_list.find(type2); if (E) { - descr = DTR(E->get().brief_description); + descr = DTR(E->value.brief_description); } class_descr_cache[type2] = descr; } @@ -2607,9 +2607,9 @@ void EditorInspector::update_tree() { // First check if we have an array that fits the prefix. String array_prefix = ""; int array_index = -1; - for (Map<String, EditorInspectorArray *>::Element *E = editor_inspector_array_per_prefix.front(); E; E = E->next()) { - if (p.name.begins_with(E->key()) && E->key().length() > array_prefix.length()) { - array_prefix = E->key(); + for (KeyValue<String, EditorInspectorArray *> &E : editor_inspector_array_per_prefix) { + if (p.name.begins_with(E.key) && E.key.length() > array_prefix.length()) { + array_prefix = E.key; } } @@ -2851,39 +2851,39 @@ void EditorInspector::update_tree() { bool found = false; // Search for the property description in the cache. - Map<StringName, Map<StringName, String>>::Element *E = descr_cache.find(classname); + HashMap<StringName, HashMap<StringName, String>>::Iterator E = descr_cache.find(classname); if (E) { - Map<StringName, String>::Element *F = E->get().find(propname); + HashMap<StringName, String>::Iterator F = E->value.find(propname); if (F) { found = true; - descr = F->get(); + descr = F->value; } } if (!found) { // Build the property description String and add it to the cache. DocTools *dd = EditorHelp::get_doc_data(); - Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(classname); + HashMap<String, DocData::ClassDoc>::Iterator F = dd->class_list.find(classname); while (F && descr.is_empty()) { - for (int i = 0; i < F->get().properties.size(); i++) { - if (F->get().properties[i].name == propname.operator String()) { - descr = DTR(F->get().properties[i].description); + for (int i = 0; i < F->value.properties.size(); i++) { + if (F->value.properties[i].name == propname.operator String()) { + descr = DTR(F->value.properties[i].description); break; } } Vector<String> slices = propname.operator String().split("/"); if (slices.size() == 2 && slices[0].begins_with("theme_override_")) { - for (int i = 0; i < F->get().theme_properties.size(); i++) { - if (F->get().theme_properties[i].name == slices[1]) { - descr = DTR(F->get().theme_properties[i].description); + for (int i = 0; i < F->value.theme_properties.size(); i++) { + if (F->value.theme_properties[i].name == slices[1]) { + descr = DTR(F->value.theme_properties[i].description); break; } } } - if (!F->get().inherits.is_empty()) { - F = dd->class_list.find(F->get().inherits); + if (!F->value.inherits.is_empty()) { + F = dd->class_list.find(F->value.inherits); } else { break; } @@ -3638,7 +3638,7 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li break; } - Set<StringName> added; + RBSet<StringName> added; for (const Ref<Script> &s : classes) { String path = s->get_path(); String name = EditorNode::get_editor_data().script_class_get_name(path); diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 75536a5a24..7609f4fdcc 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -117,7 +117,7 @@ private: mutable String tooltip_text; - Map<StringName, Variant> cache; + HashMap<StringName, Variant> cache; GDVIRTUAL0(_update_property) void _update_pin_flags(); @@ -435,9 +435,9 @@ class EditorInspector : public ScrollContainer { VBoxContainer *main_vbox = nullptr; //map use to cache the instantiated editors - Map<StringName, List<EditorProperty *>> editor_property_map; + HashMap<StringName, List<EditorProperty *>> editor_property_map; List<EditorInspectorSection *> sections; - Set<StringName> pending; + RBSet<StringName> pending; void _clear(); Object *object = nullptr; @@ -468,11 +468,11 @@ class EditorInspector : public ScrollContainer { int property_focusable; int update_scroll_request; - Map<StringName, Map<StringName, String>> descr_cache; - Map<StringName, String> class_descr_cache; - Set<StringName> restart_request_props; + HashMap<StringName, HashMap<StringName, String>> descr_cache; + HashMap<StringName, String> class_descr_cache; + RBSet<StringName> restart_request_props; - Map<ObjectID, int> scroll_cache; + HashMap<ObjectID, int> scroll_cache; String property_prefix; //used for sectioned inspector String object_class; @@ -496,7 +496,7 @@ class EditorInspector : public ScrollContainer { void _node_removed(Node *p_node); - Map<StringName, int> per_array_page; + HashMap<StringName, int> per_array_page; void _page_change_request(int p_new_page, const StringName &p_array_prefix); void _changed_callback(); diff --git a/editor/editor_log.h b/editor/editor_log.h index 267ad406d4..de0368501c 100644 --- a/editor/editor_log.h +++ b/editor/editor_log.h @@ -115,7 +115,7 @@ private: Vector<LogMessage> messages; // Maps MessageTypes to LogFilters for convenient access and storage (don't need 1 member per filter). - Map<MessageType, LogFilter *> type_filter_map; + HashMap<MessageType, LogFilter *> type_filter_map; RichTextLabel *log = nullptr; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 194021669f..0b96900053 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -215,12 +215,12 @@ static const String META_TEXT_TO_COPY = "text_to_copy"; void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vector<String> &r_filenames) { // Keep track of a list of "index sets," i.e. sets of indices // within disambiguated_scene_names which contain the same name. - Vector<Set<int>> index_sets; - Map<String, int> scene_name_to_set_index; + Vector<RBSet<int>> index_sets; + HashMap<String, int> scene_name_to_set_index; for (int i = 0; i < r_filenames.size(); i++) { String scene_name = r_filenames[i]; if (!scene_name_to_set_index.has(scene_name)) { - index_sets.append(Set<int>()); + index_sets.append(RBSet<int>()); scene_name_to_set_index.insert(r_filenames[i], index_sets.size() - 1); } index_sets.write[scene_name_to_set_index[scene_name]].insert(i); @@ -228,10 +228,10 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto // For each index set with a size > 1, we need to disambiguate. for (int i = 0; i < index_sets.size(); i++) { - Set<int> iset = index_sets[i]; + RBSet<int> iset = index_sets[i]; while (iset.size() > 1) { // Append the parent folder to each scene name. - for (Set<int>::Element *E = iset.front(); E; E = E->next()) { + for (RBSet<int>::Element *E = iset.front(); E; E = E->next()) { int set_idx = E->get(); String scene_name = r_filenames[set_idx]; String full_path = p_full_paths[set_idx]; @@ -266,11 +266,11 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto // Loop back through scene names and remove non-ambiguous names. bool can_proceed = false; - Set<int>::Element *E = iset.front(); + RBSet<int>::Element *E = iset.front(); while (E) { String scene_name = r_filenames[E->get()]; bool duplicate_found = false; - for (Set<int>::Element *F = iset.front(); F; F = F->next()) { + for (RBSet<int>::Element *F = iset.front(); F; F = F->next()) { if (E->get() == F->get()) { continue; } @@ -281,7 +281,7 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto } } - Set<int>::Element *to_erase = duplicate_found ? nullptr : E; + RBSet<int>::Element *to_erase = duplicate_found ? nullptr : E; // We need to check that we could actually append anymore names // if we wanted to for disambiguation. If we can't, then we have @@ -623,8 +623,6 @@ void EditorNode::_notification(int p_what) { ResourceImporterTexture::get_singleton()->update_imports(); - // if using a main thread only renderer, we need to update the resource previews - EditorResourcePreview::get_singleton()->update(); } break; case NOTIFICATION_ENTER_TREE: { @@ -802,7 +800,7 @@ void EditorNode::_notification(int p_what) { main_editor_buttons.write[i]->add_theme_font_size_override("font_size", gui_base->get_theme_font_size(SNAME("main_button_font_size"), SNAME("EditorFonts"))); } - Set<String> updated_textfile_extensions; + RBSet<String> updated_textfile_extensions; bool extensions_match = true; const Vector<String> textfile_ext = ((String)(EditorSettings::get_singleton()->get("docks/filesystem/textfile_extensions"))).split(",", false); for (const String &E : textfile_ext) { @@ -909,11 +907,11 @@ void EditorNode::_resources_changed(const Vector<String> &p_resources) { } void EditorNode::_fs_changed() { - for (Set<FileDialog *>::Element *E = file_dialogs.front(); E; E = E->next()) { + for (RBSet<FileDialog *>::Element *E = file_dialogs.front(); E; E = E->next()) { E->get()->invalidate(); } - for (Set<EditorFileDialog *>::Element *E = editor_file_dialogs.front(); E; E = E->next()) { + for (RBSet<EditorFileDialog *>::Element *E = editor_file_dialogs.front(); E; E = E->next()) { E->get()->invalidate(); } @@ -1187,7 +1185,7 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d if (!p_ignore_broken_deps && dependency_errors.has(p_resource)) { Vector<String> errors; - for (Set<String>::Element *E = dependency_errors[p_resource].front(); E; E = E->next()) { + for (RBSet<String>::Element *E = dependency_errors[p_resource].front(); E; E = E->next()) { errors.push_back(E->get()); } dependency_error->show(DependencyErrorDialog::MODE_RESOURCE, p_resource, errors); @@ -1419,7 +1417,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(Ref<Resource> p_res, Map<Ref<Resource>, bool> &processed, int32_t flags) { +bool EditorNode::_find_and_save_resource(Ref<Resource> p_res, HashMap<Ref<Resource>, bool> &processed, int32_t flags) { if (p_res.is_null()) { return false; } @@ -1445,7 +1443,7 @@ bool EditorNode::_find_and_save_resource(Ref<Resource> p_res, Map<Ref<Resource>, } } -bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<Ref<Resource>, bool> &processed, int32_t flags) { +bool EditorNode::_find_and_save_edited_subresources(Object *obj, HashMap<Ref<Resource>, bool> &processed, int32_t flags) { bool ret_changed = false; List<PropertyInfo> pi; obj->get_property_list(&pi); @@ -1495,7 +1493,7 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<Ref<Resourc return ret_changed; } -void EditorNode::_save_edited_subresources(Node *scene, Map<Ref<Resource>, bool> &processed, int32_t flags) { +void EditorNode::_save_edited_subresources(Node *scene, HashMap<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++) { @@ -1624,7 +1622,7 @@ bool EditorNode::_validate_scene_recursive(const String &p_filename, Node *p_nod return false; } -static bool _find_edited_resources(const Ref<Resource> &p_resource, Set<Ref<Resource>> &edited_resources) { +static bool _find_edited_resources(const Ref<Resource> &p_resource, RBSet<Ref<Resource>> &edited_resources) { if (p_resource->is_edited()) { edited_resources.insert(p_resource); return true; @@ -1661,7 +1659,7 @@ int EditorNode::_save_external_resources() { } flg |= ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS; - Set<Ref<Resource>> edited_subresources; + RBSet<Ref<Resource>> edited_subresources; int saved = 0; List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); @@ -1679,7 +1677,7 @@ int EditorNode::_save_external_resources() { // Clear later, because user may have put the same subresource in two different resources, // which will be shared until the next reload. - for (Set<Ref<Resource>>::Element *E = edited_subresources.front(); E; E = E->next()) { + for (RBSet<Ref<Resource>>::Element *E = edited_subresources.front(); E; E = E->next()) { Ref<Resource> res = E->get(); res->set_edited(false); } @@ -2127,7 +2125,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<Ref<Resource>, bool> processed; + HashMap<Ref<Resource>, bool> processed; _find_and_save_edited_subresources(fallback.ptr(), processed, 0); save_resource_in_path(fallback, fallback->get_path()); } @@ -2305,7 +2303,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) { if (main_plugin) { // Special case if use of external editor is true. Resource *current_res = Object::cast_to<Resource>(current_obj); - if (main_plugin->get_name() == "Script" && current_obj->is_class("VisualScript") && current_res && !current_res->is_built_in() && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { + if (main_plugin->get_name() == "Script" && !current_obj->is_class("VisualScript") && current_res && !current_res->is_built_in() && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { if (!changing_scene) { main_plugin->edit(current_obj); } @@ -3665,7 +3663,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b if (!p_ignore_broken_deps && dependency_errors.has(lpath)) { current_menu_option = -1; Vector<String> errors; - for (Set<String>::Element *E = dependency_errors[lpath].front(); E; E = E->next()) { + for (RBSet<String>::Element *E = dependency_errors[lpath].front(); E; E = E->next()) { errors.push_back(E->get()); } dependency_error->show(DependencyErrorDialog::MODE_SCENE, lpath, errors); @@ -3680,9 +3678,9 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b dependency_errors.erase(lpath); // At least not self path. - for (KeyValue<String, Set<String>> &E : dependency_errors) { + for (KeyValue<String, RBSet<String>> &E : dependency_errors) { String txt = vformat(TTR("Scene '%s' has broken dependencies:"), E.key) + "\n"; - for (Set<String>::Element *F = E.value.front(); F; F = F->next()) { + for (RBSet<String>::Element *F = E.value.front(); F; F = F->next()) { txt += "\t" + F->get() + "\n"; } add_io_error(txt); @@ -4145,7 +4143,7 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p } } - const Map<String, Vector<EditorData::CustomType>> &p_map = EditorNode::get_editor_data().get_custom_types(); + const HashMap<String, Vector<EditorData::CustomType>> &p_map = EditorNode::get_editor_data().get_custom_types(); for (const KeyValue<String, Vector<EditorData::CustomType>> &E : p_map) { const Vector<EditorData::CustomType> &ct = E.value; for (int i = 0; i < ct.size(); ++i) { diff --git a/editor/editor_node.h b/editor/editor_node.h index 0d154123b3..9cd96050e3 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -273,7 +273,7 @@ private: Vector<EditorPlugin *> editor_plugins; bool _initializing_plugins = false; - Map<String, EditorPlugin *> addon_name_to_plugin; + HashMap<String, EditorPlugin *> addon_name_to_plugin; PanelContainer *scene_root_parent = nullptr; Control *theme_base = nullptr; @@ -394,7 +394,7 @@ private: BackgroundProgress *progress_hb = nullptr; DependencyErrorDialog *dependency_error = nullptr; - Map<String, Set<String>> dependency_errors; + HashMap<String, RBSet<String>> dependency_errors; DependencyEditor *dependency_fixer = nullptr; OrphanResourcesDialog *orphan_resources = nullptr; ConfirmationDialog *open_imported = nullptr; @@ -470,15 +470,15 @@ private: String import_reload_fn; - Set<String> textfile_extensions; - Set<FileDialog *> file_dialogs; - Set<EditorFileDialog *> editor_file_dialogs; + RBSet<String> textfile_extensions; + RBSet<FileDialog *> file_dialogs; + RBSet<EditorFileDialog *> editor_file_dialogs; Vector<Ref<EditorResourceConversionPlugin>> resource_conversion_plugins; PrintHandlerList print_handler; - Map<String, Ref<Texture2D>> icon_type_cache; - Map<Ref<Script>, Ref<Texture>> script_icon_cache; + HashMap<String, Ref<Texture2D>> icon_type_cache; + HashMap<Ref<Script>, Ref<Texture>> script_icon_cache; static EditorBuildCallback build_callbacks[MAX_BUILD_CALLBACKS]; static EditorPluginInitializeCallback plugin_init_callbacks[MAX_INIT_CALLBACKS]; @@ -489,7 +489,7 @@ private: static void _dependency_error_report(void *ud, const String &p_path, const String &p_dep, const String &p_type) { EditorNode *en = static_cast<EditorNode *>(ud); if (!en->dependency_errors.has(p_path)) { - en->dependency_errors[p_path] = Set<String>(); + en->dependency_errors[p_path] = RBSet<String>(); } en->dependency_errors[p_path].insert(p_dep + "::" + p_type); } @@ -594,9 +594,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(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); + bool _find_and_save_resource(Ref<Resource> p_res, HashMap<Ref<Resource>, bool> &processed, int32_t flags); + bool _find_and_save_edited_subresources(Object *obj, HashMap<Ref<Resource>, bool> &processed, int32_t flags); + void _save_edited_subresources(Node *scene, HashMap<Ref<Resource>, bool> &processed, int32_t flags); void _mark_unsaved_scenes(); void _find_node_types(Node *p_node, int &count_2d, int &count_3d); diff --git a/editor/editor_property_name_processor.cpp b/editor/editor_property_name_processor.cpp index 1e222c02a3..489aad2802 100644 --- a/editor/editor_property_name_processor.cpp +++ b/editor/editor_property_name_processor.cpp @@ -57,16 +57,16 @@ bool EditorPropertyNameProcessor::is_localization_available() { } String EditorPropertyNameProcessor::_capitalize_name(const String &p_name) const { - const Map<String, String>::Element *cached = capitalize_string_cache.find(p_name); + HashMap<String, String>::ConstIterator cached = capitalize_string_cache.find(p_name); if (cached) { - return cached->value(); + return cached->value; } Vector<String> parts = p_name.split("_", false); for (int i = 0; i < parts.size(); i++) { - const Map<String, String>::Element *remap = capitalize_string_remaps.find(parts[i]); + HashMap<String, String>::ConstIterator remap = capitalize_string_remaps.find(parts[i]); if (remap) { - parts.write[i] = remap->get(); + parts.write[i] = remap->value; } else { parts.write[i] = parts[i].capitalize(); } diff --git a/editor/editor_property_name_processor.h b/editor/editor_property_name_processor.h index 351736550f..37d905c806 100644 --- a/editor/editor_property_name_processor.h +++ b/editor/editor_property_name_processor.h @@ -38,8 +38,8 @@ class EditorPropertyNameProcessor : public Node { static EditorPropertyNameProcessor *singleton; - mutable Map<String, String> capitalize_string_cache; - Map<String, String> capitalize_string_remaps; + mutable HashMap<String, String> capitalize_string_cache; + HashMap<String, String> capitalize_string_remaps; // Capitalizes property path segments. String _capitalize_name(const String &p_name) const; diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 3158c03dcc..41d769ad1f 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; + RBSet<String> valid_extensions; for (const String &E : extensions) { valid_extensions.insert(E); } @@ -253,7 +253,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { } file_dialog->clear_filters(); - for (Set<String>::Element *E = valid_extensions.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = valid_extensions.front(); E; E = E->next()) { file_dialog->add_filter("*." + E->get() + " ; " + E->get().to_upper()); } @@ -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; + RBSet<String> allowed_types; _get_allowed_types(false, &allowed_types); Vector<EditorData::CustomType> custom_resources; @@ -417,7 +417,7 @@ 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()) { + for (RBSet<String>::Element *E = allowed_types.front(); E; E = E->next()) { const String &t = E->get(); bool is_custom_resource = false; @@ -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, RBSet<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; + RBSet<String> allowed_types; _get_allowed_types(true, &allowed_types); if (res.is_valid() && _is_type_valid(res->get_class(), allowed_types)) { @@ -598,8 +598,8 @@ 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()) { +bool EditorResourcePicker::_is_type_valid(const String p_type_name, RBSet<String> p_allowed_types) const { + for (RBSet<String>::Element *E = p_allowed_types.front(); E; E = E->next()) { String at = E->get().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,12 +646,12 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ } if (dropped_resource.is_valid()) { - Set<String> allowed_types; + RBSet<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()) { + for (RBSet<String>::Element *E = allowed_types.front(); E; E = E->next()) { String at = E->get().strip_edges(); if (at == "BaseMaterial3D" && Ref<Texture2D>(dropped_resource).is_valid()) { @@ -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; + RBSet<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; + RBSet<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; + RBSet<String> allowed_types; _get_allowed_types(false, &allowed_types); Vector<String> types; @@ -802,7 +802,7 @@ 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++) { + for (RBSet<String>::Element *E = allowed_types.front(); E; E = E->next(), i++) { w[i] = E->get(); } @@ -817,7 +817,7 @@ void EditorResourcePicker::set_edited_resource(Ref<Resource> p_resource) { } if (!base_type.is_empty()) { - Set<String> allowed_types; + RBSet<String> allowed_types; _get_allowed_types(true, &allowed_types); StringName custom_class; diff --git a/editor/editor_resource_picker.h b/editor/editor_resource_picker.h index e63280e3b6..f2dc45513d 100644 --- a/editor/editor_resource_picker.h +++ b/editor/editor_resource_picker.h @@ -89,9 +89,9 @@ class EditorResourcePicker : public HBoxContainer { void _button_draw(); void _button_input(const Ref<InputEvent> &p_event); - void _get_allowed_types(bool p_with_convert, Set<String> *p_vector) const; + void _get_allowed_types(bool p_with_convert, RBSet<String> *p_vector) const; bool _is_drop_valid(const Dictionary &p_drag_data) const; - bool _is_type_valid(const String p_type_name, Set<String> p_allowed_types) const; + bool _is_type_valid(const String p_type_name, RBSet<String> p_allowed_types) const; Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 6d5b20e591..dffb378408 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -430,12 +430,8 @@ void EditorResourcePreview::check_for_invalidation(const String &p_path) { } void EditorResourcePreview::start() { - if (OS::get_singleton()->get_render_main_thread_mode() == OS::RENDER_ANY_THREAD) { - ERR_FAIL_COND_MSG(thread.is_started(), "Thread already started."); - thread.start(_thread_func, this); - } else { - _mainthread_only = true; - } + ERR_FAIL_COND_MSG(thread.is_started(), "Thread already started."); + thread.start(_thread_func, this); } void EditorResourcePreview::stop() { @@ -458,18 +454,3 @@ EditorResourcePreview::EditorResourcePreview() { EditorResourcePreview::~EditorResourcePreview() { stop(); } - -void EditorResourcePreview::update() { - if (!_mainthread_only) { - return; - } - - if (!exit.is_set()) { - // no need to even lock the mutex if the size is zero - // there is no problem if queue.size() is wrong, even if - // there was a race condition. - if (queue.size()) { - _iterate(); - } - } -} diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h index 769340c36f..820e22bdc8 100644 --- a/editor/editor_resource_preview.h +++ b/editor/editor_resource_preview.h @@ -81,11 +81,6 @@ class EditorResourcePreview : public Node { SafeFlag exit; SafeFlag exited; - // when running from GLES, we want to run the previews - // in the main thread using an update, rather than create - // a separate thread - bool _mainthread_only = false; - struct Item { Ref<Texture2D> preview; Ref<Texture2D> small_preview; @@ -96,7 +91,7 @@ class EditorResourcePreview : public Node { int order; - Map<String, Item> cache; + HashMap<String, Item> cache; void _preview_ready(const String &p_str, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud); void _generate_preview(Ref<ImageTexture> &r_texture, Ref<ImageTexture> &r_small_texture, const QueueItem &p_item, const String &cache_base); @@ -125,9 +120,6 @@ public: void start(); void stop(); - // for single threaded mode - void update(); - EditorResourcePreview(); ~EditorResourcePreview(); }; diff --git a/editor/editor_run_native.h b/editor/editor_run_native.h index 4cb5779350..798a0371a4 100644 --- a/editor/editor_run_native.h +++ b/editor/editor_run_native.h @@ -37,7 +37,7 @@ class EditorRunNative : public HBoxContainer { GDCLASS(EditorRunNative, HBoxContainer); - Map<int, MenuButton *> menus; + HashMap<int, MenuButton *> menus; bool first = true; int resume_idx; diff --git a/editor/editor_sectioned_inspector.h b/editor/editor_sectioned_inspector.h index 0ccffa0048..babd11eb69 100644 --- a/editor/editor_sectioned_inspector.h +++ b/editor/editor_sectioned_inspector.h @@ -45,7 +45,7 @@ class SectionedInspector : public HSplitContainer { Tree *sections = nullptr; SectionedInspectorFilter *filter = nullptr; - Map<String, TreeItem *> section_map; + HashMap<String, TreeItem *> section_map; EditorInspector *inspector = nullptr; LineEdit *search_box = nullptr; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index bdabff20f9..c276c922df 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -141,7 +141,7 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const { if (p_name == "shortcuts") { Array save_array; - const OrderedHashMap<String, List<Ref<InputEvent>>> &builtin_list = InputMap::get_singleton()->get_builtins(); + const HashMap<String, List<Ref<InputEvent>>> &builtin_list = InputMap::get_singleton()->get_builtins(); for (const KeyValue<String, Ref<Shortcut>> &shortcut_definition : shortcuts) { Ref<Shortcut> sc = shortcut_definition.value; @@ -244,18 +244,17 @@ struct _EVCSort { void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const { _THREAD_SAFE_METHOD_ - const String *k = nullptr; - Set<_EVCSort> vclist; + RBSet<_EVCSort> vclist; - while ((k = props.next(k))) { - const VariantContainer *v = props.getptr(*k); + for (const KeyValue<String, VariantContainer> &E : props) { + const VariantContainer *v = &E.value; if (v->hide_from_editor) { continue; } _EVCSort vc; - vc.name = *k; + vc.name = E.key; vc.order = v->order; vc.type = v->variant.get_type(); vc.save = v->save; @@ -269,7 +268,7 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const { vclist.insert(vc); } - for (Set<_EVCSort>::Element *E = vclist.front(); E; E = E->next()) { + for (RBSet<_EVCSort>::Element *E = vclist.front(); E; E = E->next()) { uint32_t pusage = PROPERTY_USAGE_NONE; if (E->get().save || !optimize_save) { pusage |= PROPERTY_USAGE_STORAGE; @@ -789,7 +788,11 @@ bool EditorSettings::_save_text_editor_theme(String p_file) { Ref<ConfigFile> cf = memnew(ConfigFile); // hex is better? List<String> keys; - props.get_key_list(&keys); + + for (const KeyValue<String, VariantContainer> &E : props) { + keys.push_back(E.key); + } + keys.sort(); for (const String &key : keys) { @@ -1396,35 +1399,35 @@ void EditorSettings::add_shortcut(const String &p_name, const Ref<Shortcut> &p_s } bool EditorSettings::is_shortcut(const String &p_name, const Ref<InputEvent> &p_event) const { - const Map<String, Ref<Shortcut>>::Element *E = shortcuts.find(p_name); + HashMap<String, Ref<Shortcut>>::ConstIterator E = shortcuts.find(p_name); ERR_FAIL_COND_V_MSG(!E, false, "Unknown Shortcut: " + p_name + "."); - return E->get()->matches_event(p_event); + return E->value->matches_event(p_event); } Ref<Shortcut> EditorSettings::get_shortcut(const String &p_name) const { - const Map<String, Ref<Shortcut>>::Element *SC = shortcuts.find(p_name); + HashMap<String, Ref<Shortcut>>::ConstIterator SC = shortcuts.find(p_name); if (SC) { - return SC->get(); + return SC->value; } // If no shortcut with the provided name is found in the list, check the built-in shortcuts. // Use the first item in the action list for the shortcut event, since a shortcut can only have 1 linked event. Ref<Shortcut> sc; - const Map<String, List<Ref<InputEvent>>>::Element *builtin_override = builtin_action_overrides.find(p_name); + HashMap<String, List<Ref<InputEvent>>>::ConstIterator builtin_override = builtin_action_overrides.find(p_name); if (builtin_override) { sc.instantiate(); - sc->set_events_list(&builtin_override->get()); + sc->set_events_list(&builtin_override->value); sc->set_name(InputMap::get_singleton()->get_builtin_display_name(p_name)); } // If there was no override, check the default builtins to see if it has an InputEvent for the provided name. if (sc.is_null()) { - const OrderedHashMap<String, List<Ref<InputEvent>>>::ConstElement builtin_default = InputMap::get_singleton()->get_builtins_with_feature_overrides_applied().find(p_name); + HashMap<String, List<Ref<InputEvent>>>::ConstIterator builtin_default = InputMap::get_singleton()->get_builtins_with_feature_overrides_applied().find(p_name); if (builtin_default) { sc.instantiate(); - sc->set_events_list(&builtin_default.get()); + sc->set_events_list(&builtin_default->value); sc->set_name(InputMap::get_singleton()->get_builtin_display_name(p_name)); } } @@ -1562,9 +1565,9 @@ void EditorSettings::set_builtin_action_override(const String &p_name, const Arr // Check if the provided event array is same as built-in. If it is, it does not need to be added to the overrides. // Note that event order must also be the same. bool same_as_builtin = true; - OrderedHashMap<String, List<Ref<InputEvent>>>::ConstElement builtin_default = InputMap::get_singleton()->get_builtins_with_feature_overrides_applied().find(p_name); + HashMap<String, List<Ref<InputEvent>>>::ConstIterator builtin_default = InputMap::get_singleton()->get_builtins_with_feature_overrides_applied().find(p_name); if (builtin_default) { - List<Ref<InputEvent>> builtin_events = builtin_default.get(); + const List<Ref<InputEvent>> &builtin_events = builtin_default->value; // In the editor we only care about key events. List<Ref<InputEventKey>> builtin_key_events; @@ -1603,11 +1606,11 @@ void EditorSettings::set_builtin_action_override(const String &p_name, const Arr } const Array EditorSettings::get_builtin_action_overrides(const String &p_name) const { - const Map<String, List<Ref<InputEvent>>>::Element *AO = builtin_action_overrides.find(p_name); + HashMap<String, List<Ref<InputEvent>>>::ConstIterator AO = builtin_action_overrides.find(p_name); if (AO) { Array event_array; - List<Ref<InputEvent>> events_list = AO->get(); + List<Ref<InputEvent>> events_list = AO->value; for (const Ref<InputEvent> &E : events_list) { event_array.push_back(E); } diff --git a/editor/editor_settings.h b/editor/editor_settings.h index d1b9cabfb7..e270a882e2 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -77,15 +77,15 @@ private: static Ref<EditorSettings> singleton; - Set<String> changed_settings; + RBSet<String> changed_settings; HashMap<String, PropertyInfo> hints; HashMap<String, VariantContainer> props; int last_order; Ref<Resource> clipboard; - mutable Map<String, Ref<Shortcut>> shortcuts; - Map<String, List<Ref<InputEvent>>> builtin_action_overrides; + mutable HashMap<String, Ref<Shortcut>> shortcuts; + HashMap<String, List<Ref<InputEvent>>> builtin_action_overrides; String config_file_path; diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index ab029c1d30..fd578bd365 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -248,11 +248,11 @@ void EditorSettingsDialog::_update_shortcut_events(const String &p_path, const A undo_redo->commit_action(); } -Array EditorSettingsDialog::_event_list_to_array_helper(List<Ref<InputEvent>> &p_events) { +Array EditorSettingsDialog::_event_list_to_array_helper(const List<Ref<InputEvent>> &p_events) { Array events; // Convert the list to an array, and only keep key events as this is for the editor. - for (List<Ref<InputEvent>>::Element *E = p_events.front(); E; E = E->next()) { + for (const List<Ref<InputEvent>>::Element *E = p_events.front(); E; E = E->next()) { Ref<InputEventKey> k = E->get(); if (k.is_valid()) { events.append(E->get()); @@ -327,7 +327,7 @@ void EditorSettingsDialog::_create_shortcut_treeitem(TreeItem *p_parent, const S void EditorSettingsDialog::_update_shortcuts() { // Before clearing the tree, take note of which categories are collapsed so that this state can be maintained when the tree is repopulated. - Map<String, bool> collapsed; + HashMap<String, bool> collapsed; if (shortcuts->get_root() && shortcuts->get_root()->get_first_child()) { TreeItem *ti = shortcuts->get_root()->get_first_child(); @@ -359,7 +359,7 @@ void EditorSettingsDialog::_update_shortcuts() { shortcuts->clear(); TreeItem *root = shortcuts->create_item(); - Map<String, TreeItem *> sections; + HashMap<String, TreeItem *> sections; // Set up section for Common/Built-in actions TreeItem *common_section = shortcuts->create_item(root); @@ -374,10 +374,9 @@ void EditorSettingsDialog::_update_shortcuts() { common_section->set_custom_bg_color(1, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); // Get the action map for the editor, and add each item to the "Common" section. - OrderedHashMap<StringName, InputMap::Action> action_map = InputMap::get_singleton()->get_action_map(); - for (OrderedHashMap<StringName, InputMap::Action>::Element E = action_map.front(); E; E = E.next()) { - String action_name = E.key(); - InputMap::Action action = E.get(); + for (const KeyValue<StringName, InputMap::Action> &E : InputMap::get_singleton()->get_action_map()) { + const String &action_name = E.key; + const InputMap::Action &action = E.value; Array events; // Need to get the list of events into an array so it can be set as metadata on the item. Vector<String> event_strings; @@ -387,10 +386,10 @@ void EditorSettingsDialog::_update_shortcuts() { continue; } - List<Ref<InputEvent>> all_default_events = InputMap::get_singleton()->get_builtins_with_feature_overrides_applied().find(action_name).value(); + const List<Ref<InputEvent>> &all_default_events = InputMap::get_singleton()->get_builtins_with_feature_overrides_applied().find(action_name)->value; List<Ref<InputEventKey>> key_default_events; // Remove all non-key events from the defaults. Only check keys, since we are in the editor. - for (List<Ref<InputEvent>>::Element *I = all_default_events.front(); I; I = I->next()) { + for (const List<Ref<InputEvent>>::Element *I = all_default_events.front(); I; I = I->next()) { Ref<InputEventKey> k = I->get(); if (k.is_valid()) { key_default_events.push_back(k); diff --git a/editor/editor_settings_dialog.h b/editor/editor_settings_dialog.h index 9a34eac7ef..294186a509 100644 --- a/editor/editor_settings_dialog.h +++ b/editor/editor_settings_dialog.h @@ -89,7 +89,7 @@ class EditorSettingsDialog : public AcceptDialog { void _event_config_confirmed(); void _create_shortcut_treeitem(TreeItem *p_parent, const String &p_shortcut_identifier, const String &p_display, Array &p_events, bool p_allow_revert, bool p_is_common, bool p_is_collapsed); - Array _event_list_to_array_helper(List<Ref<InputEvent>> &p_events); + Array _event_list_to_array_helper(const List<Ref<InputEvent>> &p_events); void _update_builtin_action(const String &p_name, const Array &p_events); void _update_shortcut_events(const String &p_path, const Array &p_events); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 0400aa74b5..a9c435a265 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -148,7 +148,7 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = // The names of the icons to never convert, even if one of their colors // are contained in the dictionary above. - Set<StringName> exceptions; + RBSet<StringName> exceptions; // Some of the colors below are listed for completeness sake. // This can be a basis for proper palette validation later. @@ -290,7 +290,7 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = // Use the accent color for some icons (checkbox, radio, toggle, etc.). Dictionary accent_color_icon_color_dictionary; - Set<StringName> accent_color_icons; + RBSet<StringName> accent_color_icons; const Color accent_color = p_theme->get_color(SNAME("accent_color"), SNAME("Editor")); accent_color_icon_color_dictionary[Color::html("699ce8")] = accent_color; diff --git a/editor/editor_toaster.h b/editor/editor_toaster.h index 791a146a8d..39db518258 100644 --- a/editor/editor_toaster.h +++ b/editor/editor_toaster.h @@ -80,7 +80,7 @@ private: String tooltip; int count = 0; }; - Map<Control *, Toast> toasts; + HashMap<Control *, Toast> toasts; bool is_processing_error = false; // Makes sure that we don't handle errors that are triggered within the EditorToaster error processing. diff --git a/editor/editor_translation_parser.cpp b/editor/editor_translation_parser.cpp index 27b8c3fd5d..13dff08c14 100644 --- a/editor/editor_translation_parser.cpp +++ b/editor/editor_translation_parser.cpp @@ -33,7 +33,7 @@ #include "core/error/error_macros.h" #include "core/io/file_access.h" #include "core/object/script_language.h" -#include "core/templates/set.h" +#include "core/templates/rb_set.h" EditorTranslationParser *EditorTranslationParser::singleton = nullptr; @@ -84,7 +84,7 @@ void EditorTranslationParserPlugin::_bind_methods() { ///////////////////////// void EditorTranslationParser::get_recognized_extensions(List<String> *r_extensions) const { - Set<String> extensions; + RBSet<String> extensions; List<String> temp; for (int i = 0; i < standard_parsers.size(); i++) { standard_parsers[i]->get_recognized_extensions(&temp); @@ -96,7 +96,7 @@ void EditorTranslationParser::get_recognized_extensions(List<String> *r_extensio for (int i = 0; i < temp.size(); i++) { extensions.insert(temp[i]); } - for (Set<String>::Element *E = extensions.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = extensions.front(); E; E = E->next()) { r_extensions->push_back(E->get()); } } diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 3526b4ce4c..50f03652ee 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -50,7 +50,7 @@ void ExportTemplateManager::_update_template_status() { Error err = da->change_dir(templates_dir); ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir + "'."); - Set<String> templates; + RBSet<String> templates; da->list_dir_begin(); if (err == OK) { String c = da->get_next(); @@ -97,7 +97,7 @@ void ExportTemplateManager::_update_template_status() { installed_table->clear(); TreeItem *installed_root = installed_table->create_item(); - for (Set<String>::Element *E = templates.back(); E; E = E->prev()) { + for (RBSet<String>::Element *E = templates.back(); E; E = E->prev()) { String version_string = E->get(); if (version_string == current_version) { continue; @@ -374,7 +374,8 @@ void ExportTemplateManager::_install_file() { } bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_skip_progress) { - zlib_filefunc_def io = zipio_create_io(); + Ref<FileAccess> io_fa; + zlib_filefunc_def io = zipio_create_io(&io_fa); unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io); if (!pkg) { @@ -676,7 +677,8 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_ // Uncompress source template. - zlib_filefunc_def io = zipio_create_io(); + Ref<FileAccess> io_fa; + zlib_filefunc_def io = zipio_create_io(&io_fa); unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io); ERR_FAIL_COND_V_MSG(!pkg, ERR_CANT_OPEN, "Android sources not in ZIP format."); @@ -692,7 +694,7 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_ ProgressDialog::get_singleton()->add_task("uncompress_src", TTR("Uncompressing Android Build Sources"), total_files); - Set<String> dirs_tested; + RBSet<String> dirs_tested; int idx = 0; while (ret == UNZ_OK) { // Get file path. diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp index 0a59ecf1b3..eed3917845 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -46,7 +46,7 @@ void EditorFileServer::_close_client(ClientData *cd) { cd->efs->to_wait.insert(cd->thread); } while (cd->files.size()) { - cd->files.erase(cd->files.front()); + cd->files.remove(cd->files.begin()); } memdelete(cd); } diff --git a/editor/fileserver/editor_file_server.h b/editor/fileserver/editor_file_server.h index 7e771db55f..21abbc3f8c 100644 --- a/editor/fileserver/editor_file_server.h +++ b/editor/fileserver/editor_file_server.h @@ -49,13 +49,13 @@ class EditorFileServer : public Object { struct ClientData { Thread *thread = nullptr; Ref<StreamPeerTCP> connection; - Map<int, Ref<FileAccess>> files; + HashMap<int, Ref<FileAccess>> files; EditorFileServer *efs = nullptr; bool quit = false; }; Ref<TCPServer> server; - Set<Thread *> to_wait; + RBSet<Thread *> to_wait; static void _close_client(ClientData *cd); static void _subthread_start(void *s); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index aae8cf25b6..4c4d38c074 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -726,7 +726,7 @@ void FileSystemDock::_sort_file_info_list(List<FileSystemDock::FileInfo> &r_file void FileSystemDock::_update_file_list(bool p_keep_selection) { // Register the previously selected items. - Set<String> cselection; + RBSet<String> cselection; if (p_keep_selection) { for (int i = 0; i < files->get_item_count(); i++) { if (files->is_selected(i)) { @@ -1161,7 +1161,7 @@ void FileSystemDock::_get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vect } } -void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd, const Map<String, String> &renames, Vector<String> &to_remaps) const { +void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd, const HashMap<String, String> &renames, Vector<String> &to_remaps) const { for (int i = 0; i < efsd->get_subdir_count(); i++) { _find_remaps(efsd->get_subdir(i), renames, to_remaps); } @@ -1177,7 +1177,7 @@ void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd, const Map<Str } void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_new_path, - Map<String, String> &p_file_renames, Map<String, String> &p_folder_renames) { + HashMap<String, String> &p_file_renames, HashMap<String, String> &p_folder_renames) { // Ensure folder paths end with "/". String old_path = (p_item.is_file || p_item.path.ends_with("/")) ? p_item.path : (p_item.path + "/"); String new_path = (p_item.is_file || p_new_path.ends_with("/")) ? p_new_path : (p_new_path + "/"); @@ -1301,7 +1301,7 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin } } -void FileSystemDock::_update_resource_paths_after_move(const Map<String, String> &p_renames) const { +void FileSystemDock::_update_resource_paths_after_move(const HashMap<String, String> &p_renames) const { // Rename all resources loaded, be it subresources or actual resources. List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); @@ -1346,7 +1346,7 @@ void FileSystemDock::_update_resource_paths_after_move(const Map<String, String> } } -void FileSystemDock::_update_dependencies_after_move(const Map<String, String> &p_renames) const { +void FileSystemDock::_update_dependencies_after_move(const HashMap<String, String> &p_renames) const { // The following code assumes that the following holds: // 1) EditorFileSystem contains the old paths/folder structure from before the rename/move. // 2) ResourceLoader can use the new paths without needing to call rescan. @@ -1367,9 +1367,9 @@ void FileSystemDock::_update_dependencies_after_move(const Map<String, String> & } } -void FileSystemDock::_update_project_settings_after_move(const Map<String, String> &p_renames) const { +void FileSystemDock::_update_project_settings_after_move(const HashMap<String, String> &p_renames) const { // Find all project settings of type FILE and replace them if needed. - const Map<StringName, PropertyInfo> prop_info = ProjectSettings::get_singleton()->get_custom_property_info(); + const HashMap<StringName, PropertyInfo> prop_info = ProjectSettings::get_singleton()->get_custom_property_info(); for (const KeyValue<StringName, PropertyInfo> &E : prop_info) { if (E.value.hint == PROPERTY_HINT_FILE) { String old_path = GLOBAL_GET(E.key); @@ -1398,7 +1398,7 @@ void FileSystemDock::_update_project_settings_after_move(const Map<String, Strin ProjectSettings::get_singleton()->save(); } -void FileSystemDock::_update_favorites_list_after_move(const Map<String, String> &p_files_renames, const Map<String, String> &p_folders_renames) const { +void FileSystemDock::_update_favorites_list_after_move(const HashMap<String, String> &p_files_renames, const HashMap<String, String> &p_folders_renames) const { Vector<String> favorites = EditorSettings::get_singleton()->get_favorites(); Vector<String> new_favorites; @@ -1416,7 +1416,7 @@ void FileSystemDock::_update_favorites_list_after_move(const Map<String, String> EditorSettings::get_singleton()->set_favorites(new_favorites); } -void FileSystemDock::_save_scenes_after_move(const Map<String, String> &p_renames) const { +void FileSystemDock::_save_scenes_after_move(const HashMap<String, String> &p_renames) const { Vector<String> remaps; _find_remaps(EditorFileSystem::get_singleton()->get_filesystem(), p_renames, remaps); Vector<String> new_filenames; @@ -1577,8 +1577,8 @@ void FileSystemDock::_rename_operation_confirm() { return; } - Map<String, String> file_renames; - Map<String, String> folder_renames; + HashMap<String, String> file_renames; + HashMap<String, String> folder_renames; _try_move_item(to_rename, new_path, file_renames, folder_renames); int current_tab = EditorNode::get_singleton()->get_current_tab(); @@ -1677,8 +1677,8 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_ove } } - Map<String, String> file_renames; - Map<String, String> folder_renames; + HashMap<String, String> file_renames; + HashMap<String, String> folder_renames; bool is_moved = false; for (int i = 0; i < to_move.size(); i++) { String old_path = to_move[i].path.ends_with("/") ? to_move[i].path.substr(0, to_move[i].path.length() - 1) : to_move[i].path; diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index fc24b3e9fd..df3dd3fd69 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -108,7 +108,7 @@ private: VSplitContainer *split_box = nullptr; VBoxContainer *file_list_vb = nullptr; - Set<String> favorites; + RBSet<String> favorites; Button *button_toggle_display_mode = nullptr; Button *button_reload = nullptr; @@ -217,14 +217,14 @@ private: void _update_import_dock(); void _get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const; - void _find_remaps(EditorFileSystemDirectory *efsd, const Map<String, String> &renames, Vector<String> &to_remaps) const; - void _try_move_item(const FileOrFolder &p_item, const String &p_new_path, Map<String, String> &p_file_renames, Map<String, String> &p_folder_renames); + void _find_remaps(EditorFileSystemDirectory *efsd, const HashMap<String, String> &renames, Vector<String> &to_remaps) const; + void _try_move_item(const FileOrFolder &p_item, const String &p_new_path, HashMap<String, String> &p_file_renames, HashMap<String, String> &p_folder_renames); void _try_duplicate_item(const FileOrFolder &p_item, const String &p_new_path) const; - void _update_dependencies_after_move(const Map<String, String> &p_renames) const; - void _update_resource_paths_after_move(const Map<String, String> &p_renames) const; - void _save_scenes_after_move(const Map<String, String> &p_renames) const; - void _update_favorites_list_after_move(const Map<String, String> &p_files_renames, const Map<String, String> &p_folders_renames) const; - void _update_project_settings_after_move(const Map<String, String> &p_renames) const; + void _update_dependencies_after_move(const HashMap<String, String> &p_renames) const; + void _update_resource_paths_after_move(const HashMap<String, String> &p_renames) const; + void _save_scenes_after_move(const HashMap<String, String> &p_renames) const; + void _update_favorites_list_after_move(const HashMap<String, String> &p_files_renames, const HashMap<String, String> &p_folders_renames) const; + void _update_project_settings_after_move(const HashMap<String, String> &p_renames) const; void _file_removed(String p_file); void _folder_removed(String p_folder); diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 41191271a1..aafaccf5be 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -99,7 +99,7 @@ void FindInFiles::set_folder(String folder) { _root_dir = folder; } -void FindInFiles::set_filter(const Set<String> &exts) { +void FindInFiles::set_filter(const RBSet<String> &exts) { _extension_filter = exts; } @@ -443,9 +443,9 @@ String FindInFilesDialog::get_folder() const { return text.strip_edges(); } -Set<String> FindInFilesDialog::get_filter() const { +RBSet<String> FindInFilesDialog::get_filter() const { // Could check the _filters_preferences but it might not have been generated yet. - Set<String> filters; + RBSet<String> filters; for (int i = 0; i < _filters_container->get_child_count(); ++i) { CheckBox *cb = static_cast<CheckBox *>(_filters_container->get_child(i)); if (cb->is_pressed()) { @@ -701,9 +701,9 @@ void FindInFilesPanel::_notification(int p_what) { void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin, int end, String text) { TreeItem *file_item; - Map<String, TreeItem *>::Element *E = _file_items.find(fpath); + HashMap<String, TreeItem *>::Iterator E = _file_items.find(fpath); - if (E == nullptr) { + if (!E) { file_item = _results_display->create_item(); file_item->set_text(0, fpath); file_item->set_metadata(0, fpath); @@ -715,7 +715,7 @@ void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin _file_items[fpath] = file_item; } else { - file_item = E->value(); + file_item = E->value; } int text_index = _with_replace ? 1 : 0; @@ -754,11 +754,11 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) { return; } - Map<TreeItem *, Result>::Element *E = _result_items.find(item); + HashMap<TreeItem *, Result>::Iterator E = _result_items.find(item); if (!E) { return; } - Result r = E->value(); + Result r = E->value; String item_text = item->get_text(_with_replace ? 1 : 0); Ref<Font> font = _results_display->get_theme_font(SNAME("font")); int font_size = _results_display->get_theme_font_size(SNAME("font_size")); @@ -818,12 +818,12 @@ void FindInFilesPanel::_on_cancel_button_clicked() { void FindInFilesPanel::_on_result_selected() { TreeItem *item = _results_display->get_selected(); - Map<TreeItem *, Result>::Element *E = _result_items.find(item); + HashMap<TreeItem *, Result>::Iterator E = _result_items.find(item); - if (E == nullptr) { + if (!E) { return; } - Result r = E->value(); + Result r = E->value; TreeItem *file_item = item->get_parent(); String fpath = file_item->get_metadata(0); @@ -850,9 +850,9 @@ void FindInFilesPanel::_on_replace_all_clicked() { continue; } - Map<TreeItem *, Result>::Element *F = _result_items.find(item); - ERR_FAIL_COND(F == nullptr); - locations.push_back(F->value()); + HashMap<TreeItem *, Result>::Iterator F = _result_items.find(item); + ERR_FAIL_COND(!F); + locations.push_back(F->value); } if (locations.size() != 0) { diff --git a/editor/find_in_files.h b/editor/find_in_files.h index 9def190b5b..8bc7b506d0 100644 --- a/editor/find_in_files.h +++ b/editor/find_in_files.h @@ -46,7 +46,7 @@ public: void set_whole_words(bool p_whole_word); void set_match_case(bool p_match_case); void set_folder(String folder); - void set_filter(const Set<String> &exts); + void set_filter(const RBSet<String> &exts); String get_search_text() const { return _pattern; } @@ -72,7 +72,7 @@ private: // Config String _pattern; - Set<String> _extension_filter; + RBSet<String> _extension_filter; String _root_dir; bool _whole_words = true; bool _match_case = true; @@ -115,7 +115,7 @@ public: bool is_match_case() const; bool is_whole_words() const; String get_folder() const; - Set<String> get_filter() const; + RBSet<String> get_filter() const; protected: void _notification(int p_what); @@ -208,8 +208,8 @@ private: Button *_refresh_button = nullptr; Button *_cancel_button = nullptr; ProgressBar *_progress_bar = nullptr; - Map<String, TreeItem *> _file_items; - Map<TreeItem *, Result> _result_items; + HashMap<String, TreeItem *> _file_items; + HashMap<TreeItem *, Result> _result_items; bool _with_replace = false; HBoxContainer *_replace_container = nullptr; diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index e68c5e9a22..71b5ddc216 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -1645,12 +1645,12 @@ void Collada::_parse_animation(XMLParser &parser) { return; } - Map<String, Vector<float>> float_sources; - Map<String, Vector<String>> string_sources; - Map<String, int> source_strides; - Map<String, Map<String, String>> samplers; - Map<String, Vector<String>> source_param_names; - Map<String, Vector<String>> source_param_types; + HashMap<String, Vector<float>> float_sources; + HashMap<String, Vector<String>> string_sources; + HashMap<String, int> source_strides; + HashMap<String, HashMap<String, String>> samplers; + HashMap<String, Vector<String>> source_param_names; + HashMap<String, Vector<String>> source_param_types; String id = ""; if (parser.has_attribute("id")) { @@ -1685,7 +1685,7 @@ void Collada::_parse_animation(XMLParser &parser) { } } else if (name == "sampler") { current_sampler = parser.get_attribute_value("id"); - samplers[current_sampler] = Map<String, String>(); + samplers[current_sampler] = HashMap<String, String>(); } else if (name == "param") { if (parser.has_attribute("name")) { source_param_names[current_source].push_back(parser.get_attribute_value("name")); @@ -1718,7 +1718,7 @@ void Collada::_parse_animation(XMLParser &parser) { String source = _uri_to_id(channel_sources[i]); String target = channel_targets[i]; ERR_CONTINUE(!samplers.has(source)); - Map<String, String> &sampler = samplers[source]; + HashMap<String, String> &sampler = samplers[source]; ERR_CONTINUE(!sampler.has("INPUT")); //no input semantic? wtf? String input_id = _uri_to_id(sampler["INPUT"]); @@ -2029,7 +2029,7 @@ void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) { NodeGeometry *gnode = static_cast<NodeGeometry *>(p_node); if (gnode->controller) { // recount skeletons used - Set<NodeSkeleton *> skeletons; + RBSet<NodeSkeleton *> skeletons; for (int i = 0; i < gnode->skeletons.size(); i++) { String nodeid = gnode->skeletons[i]; @@ -2049,7 +2049,7 @@ void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) { if (skeletons.size() > 1) { //do the merger!! - Set<NodeSkeleton *>::Element *E = skeletons.front(); + RBSet<NodeSkeleton *>::Element *E = skeletons.front(); NodeSkeleton *base = E->get(); for (E = E->next(); E; E = E->next()) { diff --git a/editor/import/collada.h b/editor/import/collada.h index df2b789081..6ac6181769 100644 --- a/editor/import/collada.h +++ b/editor/import/collada.h @@ -33,7 +33,7 @@ #include "core/config/project_settings.h" #include "core/io/xml_parser.h" -#include "core/templates/map.h" +#include "core/templates/rb_map.h" #include "scene/resources/material.h" class Collada { @@ -54,7 +54,7 @@ public: struct Effect { String name; - Map<String, Variant> params; + HashMap<String, Variant> params; struct Channel { int uv_idx = 0; @@ -131,13 +131,13 @@ public: int stride = 0; }; - Map<String, Source> sources; + HashMap<String, Source> sources; struct Vertices { - Map<String, String> sources; + HashMap<String, String> sources; }; - Map<String, Vertices> vertices; + HashMap<String, Vertices> vertices; struct Primitives { struct SourceRef { @@ -146,7 +146,7 @@ public: }; String material; - Map<String, SourceRef> sources; + HashMap<String, SourceRef> sources; Vector<float> polygons; Vector<float> indices; int count = 0; @@ -171,9 +171,9 @@ public: int stride = 0; }; - Map<String, Source> sources; + HashMap<String, Source> sources; - Map<String, String> control_vertices; + HashMap<String, String> control_vertices; CurveData() {} }; @@ -191,10 +191,10 @@ public: Source() {} }; - Map<String, Source> sources; + HashMap<String, Source> sources; struct Joints { - Map<String, String> sources; + HashMap<String, String> sources; } joints; struct Weights { @@ -204,13 +204,13 @@ public: }; String material; - Map<String, SourceRef> sources; + HashMap<String, SourceRef> sources; Vector<float> sets; Vector<float> indices; int count = 0; } weights; - Map<String, Transform3D> bone_rest_map; + HashMap<String, Transform3D> bone_rest_map; SkinControllerData() {} }; @@ -226,9 +226,9 @@ public: Source() {} }; - Map<String, Source> sources; + HashMap<String, Source> sources; - Map<String, String> targets; + HashMap<String, String> targets; MorphControllerData() {} }; @@ -382,7 +382,7 @@ public: String target; }; - Map<String, Material> material_map; + HashMap<String, Material> material_map; Vector<String> skeletons; NodeGeometry() { type = TYPE_GEOMETRY; } @@ -476,28 +476,28 @@ public: } } version; - Map<String, CameraData> camera_data_map; - Map<String, MeshData> mesh_data_map; - Map<String, LightData> light_data_map; - Map<String, CurveData> curve_data_map; + HashMap<String, CameraData> camera_data_map; + HashMap<String, MeshData> mesh_data_map; + HashMap<String, LightData> light_data_map; + HashMap<String, CurveData> curve_data_map; - Map<String, String> mesh_name_map; - Map<String, String> morph_name_map; - Map<String, String> morph_ownership_map; - Map<String, SkinControllerData> skin_controller_data_map; - Map<String, MorphControllerData> morph_controller_data_map; + HashMap<String, String> mesh_name_map; + HashMap<String, String> morph_name_map; + HashMap<String, String> morph_ownership_map; + HashMap<String, SkinControllerData> skin_controller_data_map; + HashMap<String, MorphControllerData> morph_controller_data_map; - Map<String, Image> image_map; - Map<String, Material> material_map; - Map<String, Effect> effect_map; + HashMap<String, Image> image_map; + HashMap<String, Material> material_map; + HashMap<String, Effect> effect_map; - Map<String, VisualScene> visual_scene_map; - Map<String, Node *> scene_map; - Set<String> idref_joints; - Map<String, String> sid_to_node_map; - //Map<String,NodeJoint*> bone_map; + HashMap<String, VisualScene> visual_scene_map; + HashMap<String, Node *> scene_map; + RBSet<String> idref_joints; + HashMap<String, String> sid_to_node_map; + //RBMap<String,NodeJoint*> bone_map; - Map<String, Transform3D> bone_rest_map; + HashMap<String, Transform3D> bone_rest_map; String local_path; String root_visual_scene; @@ -505,8 +505,8 @@ public: Vector<AnimationClip> animation_clips; Vector<AnimationTrack> animation_tracks; - Map<String, Vector<int>> referenced_tracks; - Map<String, Vector<int>> by_id_tracks; + HashMap<String, Vector<int>> referenced_tracks; + HashMap<String, Vector<int>> by_id_tracks; float animation_length = 0; @@ -524,7 +524,7 @@ public: int get_uv_channel(String p_name); private: // private stuff - Map<String, int> channel_map; + HashMap<String, int> channel_map; void _parse_asset(XMLParser &parser); void _parse_image(XMLParser &parser); diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index 451cb245dd..815366b279 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -45,8 +45,8 @@ class DynamicFontImportSettingsData : public RefCounted { GDCLASS(DynamicFontImportSettingsData, RefCounted) friend class DynamicFontImportSettings; - Map<StringName, Variant> settings; - Map<StringName, Variant> defaults; + HashMap<StringName, Variant> settings; + HashMap<StringName, Variant> defaults; List<ResourceImporter::ImportOption> options; DynamicFontImportSettings *owner = nullptr; @@ -581,10 +581,10 @@ void DynamicFontImportSettings::_variations_validate() { for (TreeItem *vars_item_b = vars_list_root->get_first_child(); vars_item_b; vars_item_b = vars_item_b->get_next()) { if (vars_item_b != vars_item_a) { bool match = true; - for (Map<StringName, Variant>::Element *E = import_variation_data_a->settings.front(); E; E = E->next()) { + for (const KeyValue<StringName, Variant> &E : import_variation_data_a->settings) { Ref<DynamicFontImportSettingsData> import_variation_data_b = vars_item_b->get_metadata(0); ERR_FAIL_NULL(import_variation_data_b); - match = match && (import_variation_data_b->settings[E->key()] == E->get()); + match = match && (import_variation_data_b->settings[E.key] == E.value); } if (match) { warn = TTR("Warning: Multiple configurations have identical settings. Duplicates will be ignored."); @@ -927,7 +927,7 @@ void DynamicFontImportSettings::_notification(int p_what) { } void DynamicFontImportSettings::_re_import() { - Map<StringName, Variant> main_settings; + HashMap<StringName, Variant> main_settings; main_settings["antialiased"] = import_settings_data->get("antialiased"); main_settings["generate_mipmaps"] = import_settings_data->get("generate_mipmaps"); @@ -950,11 +950,11 @@ void DynamicFontImportSettings::_re_import() { String name = vars_item->get_text(0); variation += ("name=" + name); - for (Map<StringName, Variant>::Element *E = import_variation_data->settings.front(); E; E = E->next()) { + for (const KeyValue<StringName, Variant> &E : import_variation_data->settings) { if (!variation.is_empty()) { variation += ","; } - variation += (String(E->key()) + "=" + String(E->get())); + variation += (String(E.key) + "=" + String(E.value)); } variations.push_back(variation); } @@ -991,7 +991,7 @@ void DynamicFontImportSettings::_re_import() { if (!selected_chars.is_empty()) { Vector<String> ranges; char32_t start = selected_chars.front()->get(); - for (Set<char32_t>::Element *E = selected_chars.front()->next(); E; E = E->next()) { + for (RBSet<char32_t>::Element *E = selected_chars.front()->next(); E; E = E->next()) { if (E->prev() && ((E->prev()->get() + 1) != E->get())) { ranges.push_back(String("0x") + String::num_int64(start, 16) + String("-0x") + String::num_int64(E->prev()->get(), 16)); start = E->get(); @@ -1004,7 +1004,7 @@ void DynamicFontImportSettings::_re_import() { if (!selected_glyphs.is_empty()) { Vector<String> ranges; int32_t start = selected_glyphs.front()->get(); - for (Set<int32_t>::Element *E = selected_glyphs.front()->next(); E; E = E->next()) { + for (RBSet<int32_t>::Element *E = selected_glyphs.front()->next(); E; E = E->next()) { if (E->prev() && ((E->prev()->get() + 1) != E->get())) { ranges.push_back(String("0x") + String::num_int64(start, 16) + String("-0x") + String::num_int64(E->prev()->get(), 16)); start = E->get(); @@ -1024,8 +1024,8 @@ void DynamicFontImportSettings::_re_import() { if (OS::get_singleton()->is_stdout_verbose()) { print_line("Import settings:"); - for (Map<StringName, Variant>::Element *E = main_settings.front(); E; E = E->next()) { - print_line(String(" ") + String(E->key()).utf8().get_data() + " == " + String(E->get()).utf8().get_data()); + for (const KeyValue<StringName, Variant> &E : main_settings) { + print_line(String(" ") + String(E.key).utf8().get_data() + " == " + String(E.value).utf8().get_data()); } } diff --git a/editor/import/dynamic_font_import_settings.h b/editor/import/dynamic_font_import_settings.h index c1e868403f..4e2135a13c 100644 --- a/editor/import/dynamic_font_import_settings.h +++ b/editor/import/dynamic_font_import_settings.h @@ -161,8 +161,8 @@ class DynamicFontImportSettings : public ConfirmationDialog { Ref<Font> font_preview; Ref<Font> font_main; - Set<char32_t> selected_chars; - Set<int32_t> selected_glyphs; + RBSet<char32_t> selected_chars; + RBSet<int32_t> selected_glyphs; void _re_import(); diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 013dcb5deb..8ee47cb6f4 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -67,34 +67,34 @@ struct ColladaImport { bool use_mesh_builtin_materials = false; float bake_fps = 15; - Map<String, NodeMap> node_map; //map from collada node to engine node - Map<String, String> node_name_map; //map from collada node to engine node - Map<String, Ref<ImporterMesh>> mesh_cache; - Map<String, Ref<Curve3D>> curve_cache; - Map<String, Ref<Material>> material_cache; - Map<Collada::Node *, Skeleton3D *> skeleton_map; + HashMap<String, NodeMap> node_map; //map from collada node to engine node + HashMap<String, String> node_name_map; //map from collada node to engine node + HashMap<String, Ref<ImporterMesh>> mesh_cache; + HashMap<String, Ref<Curve3D>> curve_cache; + HashMap<String, Ref<Material>> material_cache; + HashMap<Collada::Node *, Skeleton3D *> skeleton_map; - Map<Skeleton3D *, Map<String, int>> skeleton_bone_map; + HashMap<Skeleton3D *, HashMap<String, int>> skeleton_bone_map; - Set<String> valid_animated_nodes; + RBSet<String> valid_animated_nodes; Vector<int> valid_animated_properties; - Map<String, bool> bones_with_animation; + HashMap<String, bool> bones_with_animation; - Set<String> mesh_unique_names; - Set<String> material_unique_names; + RBSet<String> mesh_unique_names; + RBSet<String> material_unique_names; Error _populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent); Error _create_scene_skeletons(Collada::Node *p_node); Error _create_scene(Collada::Node *p_node, Node3D *p_parent); Error _create_resources(Collada::Node *p_node, bool p_use_compression); Error _create_material(const String &p_target); - Error _create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ImporterMesh>> p_morph_meshes = Vector<Ref<ImporterMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false); + Error _create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p_mesh, const HashMap<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ImporterMesh>> p_morph_meshes = Vector<Ref<ImporterMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false); Error load(const String &p_path, int p_flags, bool p_force_make_tangents = false, bool p_use_compression = false); void _fix_param_animation_tracks(); void create_animation(int p_clip, bool p_import_value_tracks); void create_animations(bool p_import_value_tracks); - Set<String> tracks_in_clips; + RBSet<String> tracks_in_clips; Vector<String> missing_textures; void _pre_process_lights(Collada::Node *p_node); @@ -467,7 +467,7 @@ Error ColladaImport::_create_material(const String &p_target) { return OK; } -Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ImporterMesh>> p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) { +Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p_mesh, const HashMap<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ImporterMesh>> p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) { bool local_xform_mirror = p_local_xform.basis.determinant() < 0; if (p_morph_data) { @@ -637,7 +637,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p /* ADD WEIGHTS IF EXIST */ /************************/ - Map<int, Vector<Collada::Vertex::Weight>> pre_weights; + HashMap<int, Vector<Collada::Vertex::Weight>> pre_weights; bool has_weights = false; @@ -727,7 +727,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p has_weights = true; } - Set<Collada::Vertex> vertex_set; //vertex set will be the vertices + RBSet<Collada::Vertex> vertex_set; //vertex set will be the vertices List<int> indices_list; //indices will be the indices /**************************/ @@ -875,7 +875,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p Vector<Collada::Vertex> vertex_array; //there we go, vertex array vertex_array.resize(vertex_set.size()); - for (Set<Collada::Vertex>::Element *F = vertex_set.front(); F; F = F->next()) { + for (RBSet<Collada::Vertex>::Element *F = vertex_set.front(); F; F = F->next()) { vertex_array.write[F->get().idx] = F->get(); } @@ -1127,7 +1127,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres Skeleton3D *sk = Object::cast_to<Skeleton3D>(nmsk.node); ERR_FAIL_COND_V(!sk, ERR_INVALID_DATA); ERR_FAIL_COND_V(!skeleton_bone_map.has(sk), ERR_INVALID_DATA); - Map<String, int> &bone_remap_map = skeleton_bone_map[sk]; + HashMap<String, int> &bone_remap_map = skeleton_bone_map[sk]; meshid = skin->base; @@ -1452,7 +1452,7 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) { //main anim } - Set<int> track_filter; + RBSet<int> track_filter; if (p_clip == -1) { for (int i = 0; i < collada.state.animation_clips.size(); i++) { @@ -1507,7 +1507,7 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) { bool tracks_found = false; - for (Set<String>::Element *E = valid_animated_nodes.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = valid_animated_nodes.front(); E; E = E->next()) { // take snapshots if (!collada.state.scene_map.has(E->get())) { @@ -1754,7 +1754,7 @@ void EditorSceneFormatImporterCollada::get_extensions(List<String> *r_extensions r_extensions->push_back("dae"); } -Node *EditorSceneFormatImporterCollada::import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { +Node *EditorSceneFormatImporterCollada::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { if (r_err) { *r_err = OK; } diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h index be3f74d821..e45db47440 100644 --- a/editor/import/editor_import_collada.h +++ b/editor/import/editor_import_collada.h @@ -39,7 +39,7 @@ class EditorSceneFormatImporterCollada : public EditorSceneFormatImporter { public: virtual uint32_t get_import_flags() const override; virtual void get_extensions(List<String> *r_extensions) const override; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr) override; + virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr) override; EditorSceneFormatImporterCollada(); }; diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp index f7d373ef60..e822b4963a 100644 --- a/editor/import/editor_import_plugin.cpp +++ b/editor/import/editor_import_plugin.cpp @@ -147,12 +147,12 @@ void EditorImportPlugin::get_import_options(const String &p_path, List<ResourceI ERR_FAIL_MSG("Unimplemented _get_import_options in add-on."); } -bool EditorImportPlugin::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool EditorImportPlugin::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { Dictionary d; - Map<StringName, Variant>::Element *E = p_options.front(); + HashMap<StringName, Variant>::ConstIterator E = p_options.begin(); while (E) { - d[E->key()] = E->get(); - E = E->next(); + d[E->key] = E->value; + ++E; } bool visible; if (GDVIRTUAL_CALL(_get_option_visibility, p_path, p_option, d, visible)) { @@ -162,14 +162,14 @@ bool EditorImportPlugin::get_option_visibility(const String &p_path, const Strin ERR_FAIL_V_MSG(false, "Unimplemented _get_option_visibility in add-on."); } -Error EditorImportPlugin::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error EditorImportPlugin::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { Dictionary options; Array platform_variants, gen_files; - Map<StringName, Variant>::Element *E = p_options.front(); + HashMap<StringName, Variant>::ConstIterator E = p_options.begin(); while (E) { - options[E->key()] = E->get(); - E = E->next(); + options[E->key] = E->value; + ++E; } int err; diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h index 6cff8fb917..44fbd41962 100644 --- a/editor/import/editor_import_plugin.h +++ b/editor/import/editor_import_plugin.h @@ -64,8 +64,8 @@ public: virtual float get_priority() const override; virtual int get_import_order() const override; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = nullptr) override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = nullptr) override; }; #endif //EDITOR_IMPORT_PLUGIN_H diff --git a/editor/import/resource_importer_bitmask.cpp b/editor/import/resource_importer_bitmask.cpp index 46d15e8989..966719dc48 100644 --- a/editor/import/resource_importer_bitmask.cpp +++ b/editor/import/resource_importer_bitmask.cpp @@ -55,7 +55,7 @@ String ResourceImporterBitMap::get_resource_type() const { return "BitMap"; } -bool ResourceImporterBitMap::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterBitMap::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; } @@ -72,7 +72,7 @@ void ResourceImporterBitMap::get_import_options(const String &p_path, List<Impor r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "threshold", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.5)); } -Error ResourceImporterBitMap::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error ResourceImporterBitMap::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { int create_from = p_options["create_from"]; float threshold = p_options["threshold"]; Ref<Image> image; diff --git a/editor/import/resource_importer_bitmask.h b/editor/import/resource_importer_bitmask.h index 6dd6843171..8682ab80a3 100644 --- a/editor/import/resource_importer_bitmask.h +++ b/editor/import/resource_importer_bitmask.h @@ -47,8 +47,8 @@ public: virtual String get_preset_name(int p_idx) const override; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; ResourceImporterBitMap(); ~ResourceImporterBitMap(); diff --git a/editor/import/resource_importer_bmfont.cpp b/editor/import/resource_importer_bmfont.cpp index 8a655fbc0c..8a40b113b9 100644 --- a/editor/import/resource_importer_bmfont.cpp +++ b/editor/import/resource_importer_bmfont.cpp @@ -55,7 +55,7 @@ String ResourceImporterBMFont::get_resource_type() const { return "FontData"; } -bool ResourceImporterBMFont::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterBMFont::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; } @@ -63,7 +63,7 @@ void ResourceImporterBMFont::get_import_options(const String &p_path, List<Impor r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true)); } -Error ResourceImporterBMFont::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error ResourceImporterBMFont::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { print_verbose("Importing BMFont font from: " + p_source_file); Ref<FontData> font; diff --git a/editor/import/resource_importer_bmfont.h b/editor/import/resource_importer_bmfont.h index e5a96e2c40..0711302bd5 100644 --- a/editor/import/resource_importer_bmfont.h +++ b/editor/import/resource_importer_bmfont.h @@ -46,9 +46,9 @@ public: virtual String get_resource_type() const override; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; ResourceImporterBMFont(); }; diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp index ee6500a643..0b3622e3c0 100644 --- a/editor/import/resource_importer_csv_translation.cpp +++ b/editor/import/resource_importer_csv_translation.cpp @@ -55,7 +55,7 @@ String ResourceImporterCSVTranslation::get_resource_type() const { return "Translation"; } -bool ResourceImporterCSVTranslation::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterCSVTranslation::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; } @@ -72,7 +72,7 @@ void ResourceImporterCSVTranslation::get_import_options(const String &p_path, Li r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "delimiter", PROPERTY_HINT_ENUM, "Comma,Semicolon,Tab"), 0)); } -Error ResourceImporterCSVTranslation::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error ResourceImporterCSVTranslation::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { bool compress = p_options["compress"]; String delimiter; diff --git a/editor/import/resource_importer_csv_translation.h b/editor/import/resource_importer_csv_translation.h index 8f6cf94984..306aafa843 100644 --- a/editor/import/resource_importer_csv_translation.h +++ b/editor/import/resource_importer_csv_translation.h @@ -47,9 +47,9 @@ public: virtual String get_preset_name(int p_idx) const override; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; ResourceImporterCSVTranslation(); }; diff --git a/editor/import/resource_importer_dynamic_font.cpp b/editor/import/resource_importer_dynamic_font.cpp index 2dc24c9d44..04f6a0b7af 100644 --- a/editor/import/resource_importer_dynamic_font.cpp +++ b/editor/import/resource_importer_dynamic_font.cpp @@ -67,7 +67,7 @@ String ResourceImporterDynamicFont::get_resource_type() const { return "FontData"; } -bool ResourceImporterDynamicFont::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterDynamicFont::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { if (p_option == "msdf_pixel_range" && !bool(p_options["multichannel_signed_distance_field"])) { return false; } @@ -176,7 +176,7 @@ void ResourceImporterDynamicFont::show_advanced_options(const String &p_path) { DynamicFontImportSettings::get_singleton()->open_settings(p_path); } -Error ResourceImporterDynamicFont::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error ResourceImporterDynamicFont::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { print_verbose("Importing dynamic font from: " + p_source_file); bool antialiased = p_options["antialiased"]; diff --git a/editor/import/resource_importer_dynamic_font.h b/editor/import/resource_importer_dynamic_font.h index 2761b418e1..c0b6c094b0 100644 --- a/editor/import/resource_importer_dynamic_font.h +++ b/editor/import/resource_importer_dynamic_font.h @@ -56,12 +56,12 @@ public: virtual String get_preset_name(int p_idx) const override; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; bool has_advanced_options() const override; void show_advanced_options(const String &p_path) override; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; ResourceImporterDynamicFont(); }; diff --git a/editor/import/resource_importer_image.cpp b/editor/import/resource_importer_image.cpp index 8514df76bb..fa7c4cd24f 100644 --- a/editor/import/resource_importer_image.cpp +++ b/editor/import/resource_importer_image.cpp @@ -55,7 +55,7 @@ String ResourceImporterImage::get_resource_type() const { return "Image"; } -bool ResourceImporterImage::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterImage::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; } @@ -70,7 +70,7 @@ String ResourceImporterImage::get_preset_name(int p_idx) const { void ResourceImporterImage::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const { } -Error ResourceImporterImage::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error ResourceImporterImage::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { Ref<FileAccess> f = FileAccess::open(p_source_file, FileAccess::READ); ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_OPEN, "Cannot open file from path '" + p_source_file + "'."); diff --git a/editor/import/resource_importer_image.h b/editor/import/resource_importer_image.h index 81aedc91e8..a1a345287e 100644 --- a/editor/import/resource_importer_image.h +++ b/editor/import/resource_importer_image.h @@ -48,9 +48,9 @@ public: virtual String get_preset_name(int p_idx) const override; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; ResourceImporterImage(); }; diff --git a/editor/import/resource_importer_imagefont.cpp b/editor/import/resource_importer_imagefont.cpp index 2b67a171cc..bbcd336575 100644 --- a/editor/import/resource_importer_imagefont.cpp +++ b/editor/import/resource_importer_imagefont.cpp @@ -55,7 +55,7 @@ String ResourceImporterImageFont::get_resource_type() const { return "FontData"; } -bool ResourceImporterImageFont::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterImageFont::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; } @@ -85,7 +85,7 @@ bool ResourceImporterImageFont::_decode_range(const String &p_token, int32_t &r_ } } -Error ResourceImporterImageFont::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error ResourceImporterImageFont::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { print_verbose("Importing image font from: " + p_source_file); int columns = p_options["columns"]; diff --git a/editor/import/resource_importer_imagefont.h b/editor/import/resource_importer_imagefont.h index c1116d5a83..f46bc8c19b 100644 --- a/editor/import/resource_importer_imagefont.h +++ b/editor/import/resource_importer_imagefont.h @@ -48,9 +48,9 @@ public: virtual String get_resource_type() const override; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; ResourceImporterImageFont(); }; diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp index 7c0c99cd29..bacd09592e 100644 --- a/editor/import/resource_importer_layered_texture.cpp +++ b/editor/import/resource_importer_layered_texture.cpp @@ -119,7 +119,7 @@ String ResourceImporterLayeredTexture::get_resource_type() const { ERR_FAIL_V(String()); } -bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { if (p_option == "compress/lossy_quality" && p_options.has("compress/mode")) { return int(p_options["compress/mode"]) == COMPRESS_LOSSY; } @@ -282,7 +282,7 @@ void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, cons } } -Error ResourceImporterLayeredTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error ResourceImporterLayeredTexture::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { int compress_mode = p_options["compress/mode"]; float lossy = p_options["compress/lossy_quality"]; int hdr_compression = p_options["compress/hdr_compression"]; diff --git a/editor/import/resource_importer_layered_texture.h b/editor/import/resource_importer_layered_texture.h index 5791914a9b..5a29010c3b 100644 --- a/editor/import/resource_importer_layered_texture.h +++ b/editor/import/resource_importer_layered_texture.h @@ -43,7 +43,7 @@ class LayeredTextureImport : public RefCounted { public: Image::CompressSource *csource = nullptr; String save_path; - Map<StringName, Variant> options; + HashMap<StringName, Variant> options; List<String> *platform_variants = nullptr; Ref<Image> image = nullptr; Array formats_imported; @@ -108,11 +108,11 @@ public: virtual String get_preset_name(int p_idx) const override; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; void _save_tex(Vector<Ref<Image>> p_images, const String &p_to_path, int p_compress_mode, float p_lossy, Image::CompressMode p_vram_compression, Image::CompressSource p_csource, Image::UsedChannels used_channels, bool p_mipmaps, bool p_force_po2); - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; virtual bool are_import_settings_valid(const String &p_path) const override; virtual String get_import_settings_string() const override; diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 88837d089a..6fbfecfdfa 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -43,7 +43,7 @@ uint32_t EditorOBJImporter::get_import_flags() const { return IMPORT_SCENE; } -static Error _parse_material_library(const String &p_path, Map<String, Ref<StandardMaterial3D>> &material_map, List<String> *r_missing_deps) { +static Error _parse_material_library(const String &p_path, HashMap<String, Ref<StandardMaterial3D>> &material_map, List<String> *r_missing_deps) { Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ); ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_OPEN, vformat("Couldn't open MTL file '%s', it may not exist or not be readable.", p_path)); @@ -219,7 +219,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ Vector<Vector2> uvs; String name; - Map<String, Map<String, Ref<StandardMaterial3D>>> material_map; + HashMap<String, HashMap<String, Ref<StandardMaterial3D>>> material_map; Ref<SurfaceTool> surf_tool = memnew(SurfaceTool); surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES); @@ -402,7 +402,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ current_material_library = l.replace("mtllib", "").strip_edges(); if (!material_map.has(current_material_library)) { - Map<String, Ref<StandardMaterial3D>> lib; + HashMap<String, Ref<StandardMaterial3D>> lib; String lib_path = current_material_library; if (lib_path.is_relative_path()) { lib_path = p_path.get_base_dir().plus_file(current_material_library); @@ -422,7 +422,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ return OK; } -Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { +Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { List<Ref<Mesh>> meshes; Error err = _parse_obj(p_path, meshes, false, p_flags & IMPORT_GENERATE_TANGENT_ARRAYS, false, Vector3(1, 1, 1), Vector3(0, 0, 0), r_missing_deps); @@ -505,11 +505,11 @@ void ResourceImporterOBJ::get_import_options(const String &p_path, List<ImportOp r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "optimize_mesh"), true)); } -bool ResourceImporterOBJ::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterOBJ::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; } -Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { List<Ref<Mesh>> meshes; Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], p_options["optimize_mesh"], p_options["scale_mesh"], p_options["offset_mesh"], nullptr); diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h index 1b5e8bbdc1..3da9f02adb 100644 --- a/editor/import/resource_importer_obj.h +++ b/editor/import/resource_importer_obj.h @@ -39,7 +39,7 @@ class EditorOBJImporter : public EditorSceneFormatImporter { public: virtual uint32_t get_import_flags() const override; virtual void get_extensions(List<String> *r_extensions) const override; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override; + virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override; EditorOBJImporter(); }; @@ -59,9 +59,9 @@ public: virtual String get_preset_name(int p_idx) const override; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; // Threaded import can currently cause deadlocks, see GH-48265. virtual bool can_import_threaded() const override { return false; } diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index ddde6bf144..647eb1344b 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -74,7 +74,7 @@ void EditorSceneFormatImporter::get_extensions(List<String> *r_extensions) const ERR_FAIL(); } -Node *EditorSceneFormatImporter::import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { +Node *EditorSceneFormatImporter::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { Dictionary options_dict; for (const KeyValue<StringName, Variant> &elem : p_options) { options_dict[elem.key] = elem.value; @@ -91,7 +91,7 @@ void EditorSceneFormatImporter::get_import_options(const String &p_path, List<Re GDVIRTUAL_CALL(_get_import_options, p_path); } -Variant EditorSceneFormatImporter::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) { +Variant EditorSceneFormatImporter::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) { Variant ret; GDVIRTUAL_CALL(_get_option_visibility, p_path, p_for_animation, p_option, ret); return ret; @@ -166,14 +166,14 @@ void EditorScenePostImportPlugin::get_internal_import_options(InternalImportCate GDVIRTUAL_CALL(_get_internal_import_options, p_category); current_option_list = nullptr; } -Variant EditorScenePostImportPlugin::get_internal_option_visibility(InternalImportCategory p_category, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) const { +Variant EditorScenePostImportPlugin::get_internal_option_visibility(InternalImportCategory p_category, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const { current_options = &p_options; Variant ret; GDVIRTUAL_CALL(_get_internal_option_visibility, p_category, p_for_animation, p_option, ret); current_options = nullptr; return ret; } -Variant EditorScenePostImportPlugin::get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const { +Variant EditorScenePostImportPlugin::get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const { current_options = &p_options; Variant ret; GDVIRTUAL_CALL(_get_internal_option_update_view_required, p_category, p_option, ret); @@ -192,7 +192,7 @@ void EditorScenePostImportPlugin::get_import_options(const String &p_path, List< GDVIRTUAL_CALL(_get_import_options, p_path); current_option_list = nullptr; } -Variant EditorScenePostImportPlugin::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) const { +Variant EditorScenePostImportPlugin::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const { current_options = &p_options; Variant ret; GDVIRTUAL_CALL(_get_option_visibility, p_path, p_for_animation, p_option, ret); @@ -200,12 +200,12 @@ Variant EditorScenePostImportPlugin::get_option_visibility(const String &p_path, return ret; } -void EditorScenePostImportPlugin::pre_process(Node *p_scene, const Map<StringName, Variant> &p_options) { +void EditorScenePostImportPlugin::pre_process(Node *p_scene, const HashMap<StringName, Variant> &p_options) { current_options = &p_options; GDVIRTUAL_CALL(_pre_process, p_scene); current_options = nullptr; } -void EditorScenePostImportPlugin::post_process(Node *p_scene, const Map<StringName, Variant> &p_options) { +void EditorScenePostImportPlugin::post_process(Node *p_scene, const HashMap<StringName, Variant> &p_options) { current_options = &p_options; GDVIRTUAL_CALL(_post_process, p_scene); current_options = nullptr; @@ -263,7 +263,7 @@ int ResourceImporterScene::get_format_version() const { return 1; } -bool ResourceImporterScene::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterScene::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { if (animation_importer) { if (p_option == "animation/import") { // Option ignored, animation always imported. return false; @@ -367,7 +367,7 @@ static void _pre_gen_shape_list(Ref<ImporterMesh> &mesh, Vector<Ref<Shape3D>> &r } } -Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &r_collision_map, Pair<PackedVector3Array, PackedInt32Array> *r_occluder_arrays, List<Pair<NodePath, Node *>> &r_node_renames) { +Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &r_collision_map, Pair<PackedVector3Array, PackedInt32Array> *r_occluder_arrays, List<Pair<NodePath, Node *>> &r_node_renames) { // Children first. for (int i = 0; i < p_node->get_child_count(); i++) { Node *r = _pre_fix_node(p_node->get_child(i), p_root, r_collision_map, r_occluder_arrays, r_node_renames); @@ -704,7 +704,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<I return p_node; } -Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Pair<PackedVector3Array, PackedInt32Array> &r_occluder_arrays, Set<Ref<ImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps) { +Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Pair<PackedVector3Array, PackedInt32Array> &r_occluder_arrays, RBSet<Ref<ImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps) { // children first for (int i = 0; i < p_node->get_child_count(); i++) { Node *r = _post_fix_node(p_node->get_child(i), p_root, collision_map, r_occluder_arrays, r_scanned_meshes, p_node_data, p_material_data, p_animation_data, p_animation_fps); @@ -1356,7 +1356,7 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p } } -bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const { if (p_options.has("import/skip_import") && p_option != "import/skip_import" && bool(p_options["import/skip_import"])) { return false; //if skip import } @@ -1475,7 +1475,7 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor return true; } -bool ResourceImporterScene::get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterScene::get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const { switch (p_category) { case INTERNAL_IMPORT_CATEGORY_NODE: { } break; @@ -1737,7 +1737,7 @@ void ResourceImporterScene::_optimize_track_usage(AnimationPlayer *p_player, Ani p_player->get_animation_list(&anims); Node *parent = p_player->get_parent(); ERR_FAIL_COND(parent == nullptr); - OrderedHashMap<NodePath, uint32_t> used_tracks[TRACK_CHANNEL_MAX]; + HashMap<NodePath, uint32_t> used_tracks[TRACK_CHANNEL_MAX]; bool tracks_to_add = false; static const Animation::TrackType track_types[TRACK_CHANNEL_MAX] = { Animation::TYPE_POSITION_3D, Animation::TYPE_ROTATION_3D, Animation::TYPE_SCALE_3D, Animation::TYPE_BLEND_SHAPE }; for (const StringName &I : anims) { @@ -1790,12 +1790,12 @@ void ResourceImporterScene::_optimize_track_usage(AnimationPlayer *p_player, Ani used_tracks[j][path] = pass; } - for (OrderedHashMap<NodePath, uint32_t>::Element J = used_tracks[j].front(); J; J = J.next()) { - if (J.get() == pass) { + for (const KeyValue<NodePath, uint32_t> &J : used_tracks[j]) { + if (J.value == pass) { continue; } - NodePath path = J.key(); + NodePath path = J.key; Node *n = parent->get_node(path); if (j == TRACK_CHANNEL_BLEND_SHAPE) { @@ -1909,19 +1909,19 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file) { ERR_FAIL_COND_V(!importer.is_valid(), nullptr); Error err = OK; - Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, Map<StringName, Variant>(), 15, nullptr, &err); + Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, HashMap<StringName, Variant>(), 15, nullptr, &err); if (!scene || err != OK) { return nullptr; } - Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> collision_map; + HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> collision_map; List<Pair<NodePath, Node *>> node_renames; _pre_fix_node(scene, scene, collision_map, nullptr, node_renames); return scene; } -Error ResourceImporterScene::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error ResourceImporterScene::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { const String &src_path = p_source_file; Ref<EditorSceneFormatImporter> importer; @@ -1994,8 +1994,8 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p animation_data = subresources["animations"]; } - Set<Ref<ImporterMesh>> scanned_meshes; - Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> collision_map; + RBSet<Ref<ImporterMesh>> scanned_meshes; + HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> collision_map; Pair<PackedVector3Array, PackedInt32Array> occluder_arrays; List<Pair<NodePath, Node *>> node_renames; @@ -2223,7 +2223,7 @@ void EditorSceneFormatImporterESCN::get_extensions(List<String> *r_extensions) c r_extensions->push_back("escn"); } -Node *EditorSceneFormatImporterESCN::import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { +Node *EditorSceneFormatImporterESCN::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { Error error; Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error); ERR_FAIL_COND_V_MSG(!ps.is_valid(), nullptr, "Cannot load scene as text resource from path '" + p_path + "'."); diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index ac72a8f39d..92bd267216 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -71,9 +71,9 @@ public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr); + virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr); 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); + virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options); EditorSceneFormatImporter() {} }; @@ -110,7 +110,7 @@ public: }; private: - mutable const Map<StringName, Variant> *current_options = nullptr; + mutable const HashMap<StringName, Variant> *current_options = nullptr; mutable const Dictionary *current_options_dict = nullptr; List<ResourceImporter::ImportOption> *current_option_list = nullptr; InternalImportCategory current_category = INTERNAL_IMPORT_CATEGORY_MAX; @@ -133,16 +133,16 @@ public: void add_import_option_advanced(Variant::Type p_type, const String &p_name, Variant p_default_value, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = String(), int p_usage_flags = PROPERTY_USAGE_DEFAULT); virtual void get_internal_import_options(InternalImportCategory p_category, List<ResourceImporter::ImportOption> *r_options); - 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 Variant get_internal_option_visibility(InternalImportCategory p_category, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const; + virtual Variant get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const; 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; + virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const; - virtual void pre_process(Node *p_scene, const Map<StringName, Variant> &p_options); - virtual void post_process(Node *p_scene, const Map<StringName, Variant> &p_options); + virtual void pre_process(Node *p_scene, const HashMap<StringName, Variant> &p_options); + virtual void post_process(Node *p_scene, const HashMap<StringName, Variant> &p_options); EditorScenePostImportPlugin() {} }; @@ -263,16 +263,16 @@ public: }; void get_internal_import_options(InternalImportCategory p_category, List<ImportOption> *r_options) const; - bool get_internal_option_visibility(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const; - bool get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const; + bool get_internal_option_visibility(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const; + bool get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; // Import scenes *after* everything else (such as textures). virtual int get_import_order() const override { return ResourceImporter::IMPORT_ORDER_SCENE; } - Node *_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &r_collision_map, Pair<PackedVector3Array, PackedInt32Array> *r_occluder_arrays, List<Pair<NodePath, Node *>> &r_node_renames); - Node *_post_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Pair<PackedVector3Array, PackedInt32Array> &r_occluder_arrays, Set<Ref<ImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps); + Node *_pre_fix_node(Node *p_node, Node *p_root, HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &r_collision_map, Pair<PackedVector3Array, PackedInt32Array> *r_occluder_arrays, List<Pair<NodePath, Node *>> &r_node_renames); + Node *_post_fix_node(Node *p_node, Node *p_root, HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Pair<PackedVector3Array, PackedInt32Array> &r_occluder_arrays, RBSet<Ref<ImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps); Ref<Animation> _save_animation_to_file(Ref<Animation> anim, bool p_save_to_file, String p_save_to_path, bool p_keep_custom_tracks); void _create_clips(AnimationPlayer *anim, const Array &p_clips, bool p_bake_all); @@ -280,7 +280,7 @@ public: void _compress_animations(AnimationPlayer *anim, int p_page_size_kb); Node *pre_import(const String &p_source_file); - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; virtual bool has_advanced_options() const override; virtual void show_advanced_options(const String &p_path) override; @@ -302,7 +302,7 @@ class EditorSceneFormatImporterESCN : public EditorSceneFormatImporter { public: virtual uint32_t get_import_flags() const override; virtual void get_extensions(List<String> *r_extensions) const override; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override; + virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override; }; #include "scene/resources/box_shape_3d.h" diff --git a/editor/import/resource_importer_shader_file.cpp b/editor/import/resource_importer_shader_file.cpp index 1d70a47daa..64839bf199 100644 --- a/editor/import/resource_importer_shader_file.cpp +++ b/editor/import/resource_importer_shader_file.cpp @@ -68,7 +68,7 @@ String ResourceImporterShaderFile::get_preset_name(int p_idx) const { void ResourceImporterShaderFile::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const { } -bool ResourceImporterShaderFile::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterShaderFile::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; } @@ -89,7 +89,7 @@ static String _include_function(const String &p_path, void *userpointer) { return file_inc->get_as_utf8_string(); } -Error ResourceImporterShaderFile::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error ResourceImporterShaderFile::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { /* STEP 1, Read shader code */ Error err; diff --git a/editor/import/resource_importer_shader_file.h b/editor/import/resource_importer_shader_file.h index 858c2e783c..9d0ef88b05 100644 --- a/editor/import/resource_importer_shader_file.h +++ b/editor/import/resource_importer_shader_file.h @@ -47,9 +47,9 @@ public: virtual String get_preset_name(int p_idx) const override; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; ResourceImporterShaderFile(); }; diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 6770eef543..5364b53b57 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -160,7 +160,7 @@ String ResourceImporterTexture::get_resource_type() const { return "CompressedTexture2D"; } -bool ResourceImporterTexture::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterTexture::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { if (p_option == "compress/lossy_quality") { int compress_mode = int(p_options["compress/mode"]); if (compress_mode != COMPRESS_LOSSY && compress_mode != COMPRESS_VRAM_COMPRESSED) { @@ -402,7 +402,7 @@ void ResourceImporterTexture::_save_ctex(const Ref<Image> &p_image, const String save_to_ctex_format(f, image, p_compress_mode, used_channels, p_vram_compression, p_lossy_quality); } -Error ResourceImporterTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error ResourceImporterTexture::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { CompressMode compress_mode = CompressMode(int(p_options["compress/mode"])); const float lossy = p_options["compress/lossy_quality"]; const int pack_channels = p_options["compress/channel_pack"]; diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index b932c598a2..7def2d4f77 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -65,7 +65,7 @@ protected: RS::TextureDetectRoughnessChannel channel_for_roughness = RS::TEXTURE_DETECT_ROUGHNESS_R; }; - Map<StringName, MakeInfo> make_flags; + HashMap<StringName, MakeInfo> make_flags; static void _texture_reimport_roughness(const Ref<CompressedTexture2D> &p_tex, const String &p_normal_path, RenderingServer::TextureDetectRoughnessChannel p_channel); static void _texture_reimport_3d(const Ref<CompressedTexture2D> &p_tex); @@ -96,9 +96,9 @@ public: virtual String get_preset_name(int p_idx) const override; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; void update_imports(); diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp index cd481e009e..aa338a6c0d 100644 --- a/editor/import/resource_importer_texture_atlas.cpp +++ b/editor/import/resource_importer_texture_atlas.cpp @@ -59,7 +59,7 @@ String ResourceImporterTextureAtlas::get_resource_type() const { return "Texture2D"; } -bool ResourceImporterTextureAtlas::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterTextureAtlas::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; } @@ -82,7 +82,7 @@ String ResourceImporterTextureAtlas::get_option_group_file() const { return "atlas_file"; } -Error ResourceImporterTextureAtlas::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error ResourceImporterTextureAtlas::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { /* If this happens, it's because the atlas_file field was not filled, so just import a broken texture */ //use an xpm because it's size independent, the editor images are vector and size dependent @@ -188,7 +188,7 @@ static void _plot_triangle(Vector2i *vertices, const Vector2i &p_offset, bool p_ } } -Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file, const Map<String, Map<StringName, Variant>> &p_source_file_options, const Map<String, String> &p_base_paths) { +Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file, const HashMap<String, HashMap<StringName, Variant>> &p_source_file_options, const HashMap<String, String> &p_base_paths) { ERR_FAIL_COND_V(p_source_file_options.size() == 0, ERR_BUG); //should never happen Vector<EditorAtlasPacker::Chart> charts; @@ -197,10 +197,10 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file pack_data_files.resize(p_source_file_options.size()); int idx = 0; - for (const Map<String, Map<StringName, Variant>>::Element *E = p_source_file_options.front(); E; E = E->next(), idx++) { + for (const KeyValue<String, HashMap<StringName, Variant>> &E : p_source_file_options) { PackData &pack_data = pack_data_files.write[idx]; - const String &source = E->key(); - const Map<StringName, Variant> &options = E->get(); + const String &source = E.key; + const HashMap<StringName, Variant> &options = E.value; Ref<Image> image; image.instantiate(); @@ -271,6 +271,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file pack_data.chart_vertices.push_back(polygons[j]); } } + idx++; } //pack the charts @@ -318,7 +319,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file //save the images idx = 0; - for (const Map<String, Map<StringName, Variant>>::Element *E = p_source_file_options.front(); E; E = E->next(), idx++) { + for (const KeyValue<String, HashMap<StringName, Variant>> &E : p_source_file_options) { PackData &pack_data = pack_data_files.write[idx]; Ref<Texture2D> texture; @@ -394,8 +395,9 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file //mesh } - String save_path = p_base_paths[E->key()] + ".res"; + String save_path = p_base_paths[E.key] + ".res"; ResourceSaver::save(save_path, texture); + idx++; } return OK; diff --git a/editor/import/resource_importer_texture_atlas.h b/editor/import/resource_importer_texture_atlas.h index a5e47dee99..971eb067df 100644 --- a/editor/import/resource_importer_texture_atlas.h +++ b/editor/import/resource_importer_texture_atlas.h @@ -61,11 +61,11 @@ public: virtual String get_preset_name(int p_idx) const override; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; virtual String get_option_group_file() const override; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; - virtual Error import_group_file(const String &p_group_file, const Map<String, Map<StringName, Variant>> &p_source_file_options, const Map<String, String> &p_base_paths) override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + virtual Error import_group_file(const String &p_group_file, const HashMap<String, HashMap<StringName, Variant>> &p_source_file_options, const HashMap<String, String> &p_base_paths) override; ResourceImporterTextureAtlas(); }; diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp index 154970f7ed..362940dc17 100644 --- a/editor/import/resource_importer_wav.cpp +++ b/editor/import/resource_importer_wav.cpp @@ -58,7 +58,7 @@ String ResourceImporterWAV::get_resource_type() const { return "AudioStreamSample"; } -bool ResourceImporterWAV::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { +bool ResourceImporterWAV::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { if (p_option == "force/max_rate_hz" && !bool(p_options["force/max_rate"])) { return false; } @@ -93,7 +93,7 @@ void ResourceImporterWAV::get_import_options(const String &p_path, List<ImportOp r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Disabled,RAM (Ima-ADPCM)"), 0)); } -Error ResourceImporterWAV::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { +Error ResourceImporterWAV::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { /* STEP 1, READ WAVE FILE */ Error err; diff --git a/editor/import/resource_importer_wav.h b/editor/import/resource_importer_wav.h index 2316ce80e5..739ec9b181 100644 --- a/editor/import/resource_importer_wav.h +++ b/editor/import/resource_importer_wav.h @@ -47,7 +47,7 @@ public: virtual String get_preset_name(int p_idx) const override; virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; static void _compress_ima_adpcm(const Vector<float> &p_data, Vector<uint8_t> &dst_data) { static const int16_t _ima_adpcm_step_table[89] = { @@ -140,7 +140,7 @@ public: } } - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; ResourceImporterWAV(); }; diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index 8866794505..3c68477564 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -43,9 +43,9 @@ class SceneImportSettingsData : public Object { GDCLASS(SceneImportSettingsData, Object) friend class SceneImportSettings; - Map<StringName, Variant> *settings = nullptr; - Map<StringName, Variant> current; - Map<StringName, Variant> defaults; + HashMap<StringName, Variant> *settings = nullptr; + HashMap<StringName, Variant> current; + HashMap<StringName, Variant> defaults; List<ResourceImporter::ImportOption> options; bool hide_options = false; String path; @@ -501,7 +501,7 @@ void SceneImportSettings::_update_camera() { camera->set_transform(xf); } -void SceneImportSettings::_load_default_subresource_settings(Map<StringName, Variant> &settings, const String &p_type, const String &p_import_id, ResourceImporterScene::InternalImportCategory p_category) { +void SceneImportSettings::_load_default_subresource_settings(HashMap<StringName, Variant> &settings, const String &p_type, const String &p_import_id, ResourceImporterScene::InternalImportCategory p_category) { if (base_subresource_settings.has(p_type)) { Dictionary d = base_subresource_settings[p_type]; if (d.has(p_import_id)) { @@ -852,7 +852,7 @@ void SceneImportSettings::_viewport_input(const Ref<InputEvent> &p_input) { } void SceneImportSettings::_re_import() { - Map<StringName, Variant> main_settings; + HashMap<StringName, Variant> main_settings; main_settings = defaults; main_settings.erase("_subresources"); diff --git a/editor/import/scene_import_settings.h b/editor/import/scene_import_settings.h index ec24a8a5a5..cbd105045a 100644 --- a/editor/import/scene_import_settings.h +++ b/editor/import/scene_import_settings.h @@ -103,9 +103,9 @@ class SceneImportSettings : public ConfirmationDialog { float cam_rot_y = -Math_PI / 4; float cam_zoom = 1; - Map<StringName, Variant> settings; + HashMap<StringName, Variant> settings; }; - Map<String, MaterialData> material_map; + HashMap<String, MaterialData> material_map; struct MeshData { bool has_import_id; @@ -116,31 +116,31 @@ class SceneImportSettings : public ConfirmationDialog { float cam_rot_x = -Math_PI / 4; float cam_rot_y = -Math_PI / 4; float cam_zoom = 1; - Map<StringName, Variant> settings; + HashMap<StringName, Variant> settings; }; - Map<String, MeshData> mesh_map; + HashMap<String, MeshData> mesh_map; struct AnimationData { Ref<Animation> animation; TreeItem *scene_node = nullptr; - Map<StringName, Variant> settings; + HashMap<StringName, Variant> settings; }; - Map<String, AnimationData> animation_map; + HashMap<String, AnimationData> animation_map; struct NodeData { Node *node = nullptr; TreeItem *scene_node = nullptr; - Map<StringName, Variant> settings; + HashMap<StringName, Variant> settings; }; - Map<String, NodeData> node_map; + HashMap<String, NodeData> node_map; void _fill_material(Tree *p_tree, const Ref<Material> &p_material, TreeItem *p_parent); void _fill_mesh(Tree *p_tree, const Ref<Mesh> &p_mesh, TreeItem *p_parent); void _fill_animation(Tree *p_tree, const Ref<Animation> &p_anim, const String &p_name, TreeItem *p_parent); void _fill_scene(Node *p_node, TreeItem *p_parent_item); - Set<Ref<Mesh>> mesh_set; - Set<Ref<Material>> material_set; + RBSet<Ref<Mesh>> mesh_set; + RBSet<Ref<Material>> material_set; String selected_type; String selected_id; @@ -156,7 +156,7 @@ class SceneImportSettings : public ConfirmationDialog { void _viewport_input(const Ref<InputEvent> &p_input); - Map<StringName, Variant> defaults; + HashMap<StringName, Variant> defaults; SceneImportSettingsData *scene_import_settings_data = nullptr; @@ -187,7 +187,7 @@ class SceneImportSettings : public ConfirmationDialog { Dictionary base_subresource_settings; - void _load_default_subresource_settings(Map<StringName, Variant> &settings, const String &p_type, const String &p_import_id, ResourceImporterScene::InternalImportCategory p_category); + void _load_default_subresource_settings(HashMap<StringName, Variant> &settings, const String &p_type, const String &p_import_id, ResourceImporterScene::InternalImportCategory p_category); bool editing_animation = false; diff --git a/editor/import_defaults_editor.cpp b/editor/import_defaults_editor.cpp index ff6b34dd36..9d96822aef 100644 --- a/editor/import_defaults_editor.cpp +++ b/editor/import_defaults_editor.cpp @@ -44,8 +44,8 @@ class ImportDefaultsEditorSettings : public Object { GDCLASS(ImportDefaultsEditorSettings, Object) friend class ImportDefaultsEditor; List<PropertyInfo> properties; - Map<StringName, Variant> values; - Map<StringName, Variant> default_values; + HashMap<StringName, Variant> values; + HashMap<StringName, Variant> default_values; Ref<ResourceImporter> importer; diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 4df46f2348..56b15c3b1a 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -39,11 +39,11 @@ class ImportDockParameters : public Object { GDCLASS(ImportDockParameters, Object); public: - Map<StringName, Variant> values; + HashMap<StringName, Variant> values; List<PropertyInfo> properties; Ref<ResourceImporter> importer; Vector<String> paths; - Set<StringName> checked; + RBSet<StringName> checked; bool checking; String base_options_path; @@ -193,8 +193,8 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { clear(); // Use the value that is repeated the most. - Map<String, Dictionary> value_frequency; - Set<String> extensions; + HashMap<String, Dictionary> value_frequency; + RBSet<String> extensions; for (int i = 0; i < p_paths.size(); i++) { Ref<ConfigFile> config; diff --git a/editor/import_dock.h b/editor/import_dock.h index f522b0bced..7f4aa1ddb3 100644 --- a/editor/import_dock.h +++ b/editor/import_dock.h @@ -51,7 +51,7 @@ class ImportDock : public VBoxContainer { EditorInspector *import_opts = nullptr; List<PropertyInfo> properties; - Map<StringName, Variant> property_values; + HashMap<StringName, Variant> property_values; ConfirmationDialog *reimport_confirm = nullptr; Label *label_warning = nullptr; diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index a62d1af477..c5dacd8d21 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -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<Ref<Resource>, Ref<Resource>> duplicates; + HashMap<Ref<Resource>, Ref<Resource>> duplicates; for (const PropertyInfo &prop_info : props) { if (!(prop_info.usage & PROPERTY_USAGE_STORAGE)) { continue; @@ -307,7 +307,7 @@ void InspectorDock::_prepare_history() { history_menu->get_popup()->clear(); Ref<Texture2D> base_icon = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); - Set<ObjectID> already; + RBSet<ObjectID> already; for (int i = editor_history->get_history_len() - 1; i >= history_to; i--) { ObjectID id = editor_history->get_history_obj(i); Object *obj = ObjectDB::get_instance(id); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 0b3164aada..da1594517f 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -557,8 +557,8 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano updating = true; - Set<String> paths; - HashMap<String, Set<String>> types; + RBSet<String> paths; + HashMap<String, RBSet<String>> types; { List<StringName> animations; player->get_animation_list(&animations); @@ -595,9 +595,9 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano filters->clear(); TreeItem *root = filters->create_item(); - Map<String, TreeItem *> parenthood; + HashMap<String, TreeItem *> parenthood; - for (Set<String>::Element *E = paths.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = paths.front(); E; E = E->next()) { NodePath path = E->get(); TreeItem *ti = nullptr; String accum; @@ -692,7 +692,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano //just a node, not a property track String types_text = "["; if (types.has(path)) { - Set<String>::Element *F = types[path].front(); + RBSet<String>::Element *F = types[path].front(); types_text += F->get(); while (F->next()) { F = F->next(); @@ -903,8 +903,8 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima } //update animations - for (Map<StringName, ProgressBar *>::Element *E = animations.front(); E; E = E->next()) { - if (E->key() == prev_name) { + for (const KeyValue<StringName, ProgressBar *> &E : animations) { + if (E.key == prev_name) { animations[new_name] = animations[prev_name]; animations.erase(prev_name); break; diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h index cacf8379f9..7e96e069c7 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.h +++ b/editor/plugins/animation_blend_tree_editor_plugin.h @@ -61,7 +61,7 @@ class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin { Tree *filters = nullptr; CheckBox *filter_enabled = nullptr; - Map<StringName, ProgressBar *> animations; + HashMap<StringName, ProgressBar *> animations; Vector<EditorProperty *> visible_properties; String to_node = ""; diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 920fe347ca..2b90b4cdd6 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -609,7 +609,7 @@ void AnimationNodeStateMachineEditor::_group_selected_nodes() { void AnimationNodeStateMachineEditor::_ungroup_selected_nodes() { bool find = false; - Set<StringName> new_selected_nodes; + RBSet<StringName> new_selected_nodes; for (const StringName &E : selected_nodes) { Ref<AnimationNodeStateMachine> group_sm = state_machine->get_node(E); diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h index 1247d99389..3db4d91367 100644 --- a/editor/plugins/animation_state_machine_editor.h +++ b/editor/plugins/animation_state_machine_editor.h @@ -64,7 +64,7 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin { PanelContainer *panel = nullptr; StringName selected_node; - Set<StringName> selected_nodes; + RBSet<StringName> selected_nodes; HScrollBar *h_scroll = nullptr; VScrollBar *v_scroll = nullptr; @@ -105,7 +105,7 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin { Point2 box_selecting_from; Point2 box_selecting_to; Rect2 box_selecting_rect; - Set<StringName> previous_selected; + RBSet<StringName> previous_selected; bool dragging_selected_attempt = false; bool dragging_selected = false; diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index 24d7c1d24c..af961e1403 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -252,7 +252,7 @@ class EditorAssetLibrary : public PanelContainer { }; int last_queue_id; - Map<int, ImageQueue> image_queue; + HashMap<int, ImageQueue> image_queue; void _image_update(bool use_cache, bool final, const PackedByteArray &p_data, int p_queue_id); void _image_request_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data, int p_queue_id); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index c129d705c9..54408e953e 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -4085,7 +4085,7 @@ void CanvasItemEditor::_button_tool_select(int p_index) { } void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, bool p_scale, bool p_on_existing) { - const Map<Node *, Object *> &selection = editor_selection->get_selection(); + const HashMap<Node *, Object *> &selection = editor_selection->get_selection(); for (const KeyValue<Node *, Object *> &E : selection) { CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); @@ -4396,7 +4396,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { case ANIM_COPY_POSE: { pose_clipboard.clear(); - const Map<Node *, Object *> &selection = editor_selection->get_selection(); + const HashMap<Node *, Object *> &selection = editor_selection->get_selection(); for (const KeyValue<Node *, Object *> &E : selection) { CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); @@ -4442,7 +4442,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case ANIM_CLEAR_POSE: { - Map<Node *, Object *> &selection = editor_selection->get_selection(); + HashMap<Node *, Object *> &selection = editor_selection->get_selection(); for (const KeyValue<Node *, Object *> &E : selection) { CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); @@ -4511,7 +4511,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case SKELETON_MAKE_BONES: { - Map<Node *, Object *> &selection = editor_selection->get_selection(); + HashMap<Node *, Object *> &selection = editor_selection->get_selection(); Node *editor_root = EditorNode::get_singleton()->get_edited_scene()->get_tree()->get_edited_scene_root(); undo_redo->create_action(TTR("Create Custom Bone2D(s) from Node(s)")); @@ -4559,7 +4559,7 @@ void CanvasItemEditor::_focus_selection(int p_op) { Rect2 rect; int count = 0; - const Map<Node *, Object *> &selection = editor_selection->get_selection(); + const HashMap<Node *, Object *> &selection = editor_selection->get_selection(); for (const KeyValue<Node *, Object *> &E : selection) { CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); if (!canvas_item) { diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 7a49041131..a4099079f3 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -283,7 +283,7 @@ private: } }; - Map<BoneKey, BoneList> bone_list; + HashMap<BoneKey, BoneList> bone_list; struct PoseClipboard { Vector2 pos; diff --git a/editor/plugins/control_editor_plugin.cpp b/editor/plugins/control_editor_plugin.cpp index 4ab03c123b..ebb0da1ad7 100644 --- a/editor/plugins/control_editor_plugin.cpp +++ b/editor/plugins/control_editor_plugin.cpp @@ -335,7 +335,7 @@ void EditorPropertySizeFlags::setup(const Vector<String> &p_options, bool p_vert return; } - Map<int, String> flags; + HashMap<int, String> flags; for (int i = 0, j = 0; i < p_options.size(); i++, j++) { Vector<String> text_split = p_options[i].split(":"); int64_t current_val = text_split[1].to_int(); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 80fc1c64d0..0560365a58 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -481,8 +481,8 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const Ref<Resource> &p_from, List<String> kwors; scr->get_language()->get_reserved_words(&kwors); - Set<String> control_flow_keywords; - Set<String> keywords; + RBSet<String> control_flow_keywords; + RBSet<String> keywords; for (const String &E : kwors) { if (scr->get_language()->is_control_flow_keyword(E)) { diff --git a/editor/plugins/gdextension_export_plugin.h b/editor/plugins/gdextension_export_plugin.h index 8ed72b1c42..28c37fed52 100644 --- a/editor/plugins/gdextension_export_plugin.h +++ b/editor/plugins/gdextension_export_plugin.h @@ -35,10 +35,10 @@ class GDExtensionExportPlugin : public EditorExportPlugin { protected: - virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features); + virtual void _export_file(const String &p_path, const String &p_type, const RBSet<String> &p_features); }; -void GDExtensionExportPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) { +void GDExtensionExportPlugin::_export_file(const String &p_path, const String &p_type, const RBSet<String> &p_features) { if (p_type != "NativeExtension") { return; } diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index 4b1081ed92..b022fcc1c9 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -42,7 +42,7 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3 if (emission_fill->get_selected() < 2) { float area_accum = 0; - Map<float, int> triangle_area_map; + RBMap<float, int> triangle_area_map; for (int i = 0; i < geometry.size(); i++) { float area = geometry[i].get_area(); @@ -63,9 +63,9 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3 for (int i = 0; i < emissor_count; i++) { float areapos = Math::random(0.0f, area_accum); - Map<float, int>::Element *E = triangle_area_map.find_closest(areapos); + RBMap<float, int>::Iterator E = triangle_area_map.find_closest(areapos); ERR_FAIL_COND_V(!E, false); - int index = E->get(); + int index = E->value; ERR_FAIL_INDEX_V(index, geometry.size(), false); // ok FINALLY get face diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index d33803213a..3094e24659 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -77,12 +77,14 @@ void MeshInstance3DEditor::_menu_option(int p_option) { StaticBody3D *body = memnew(StaticBody3D); body->add_child(cshape, true); - Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner(); + Node *owner = get_tree()->get_edited_scene_root(); ur->create_action(TTR("Create Static Trimesh Body")); ur->add_do_method(node, "add_child", body, true); ur->add_do_method(body, "set_owner", owner); ur->add_do_method(cshape, "set_owner", owner); + ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", body); + ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", cshape); ur->add_do_reference(body); ur->add_undo_method(node, "remove_child", body); ur->commit_action(); @@ -112,11 +114,13 @@ void MeshInstance3DEditor::_menu_option(int p_option) { StaticBody3D *body = memnew(StaticBody3D); body->add_child(cshape, true); - Node *owner = instance == get_tree()->get_edited_scene_root() ? instance : instance->get_owner(); + Node *owner = get_tree()->get_edited_scene_root(); ur->add_do_method(instance, "add_child", body, true); ur->add_do_method(body, "set_owner", owner); ur->add_do_method(cshape, "set_owner", owner); + ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", body); + ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", cshape); ur->add_do_reference(body); ur->add_undo_method(instance, "remove_child", body); } @@ -141,7 +145,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) { cshape->set_shape(shape); cshape->set_transform(node->get_transform()); - Node *owner = node->get_owner(); + Node *owner = get_tree()->get_edited_scene_root(); UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); @@ -150,6 +154,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) { ur->add_do_method(node->get_parent(), "add_child", cshape, true); ur->add_do_method(node->get_parent(), "move_child", cshape, node->get_index() + 1); ur->add_do_method(cshape, "set_owner", owner); + ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", cshape); ur->add_do_reference(cshape); ur->add_undo_method(node->get_parent(), "remove_child", cshape); ur->commit_action(); @@ -184,11 +189,12 @@ void MeshInstance3DEditor::_menu_option(int p_option) { cshape->set_shape(shape); cshape->set_transform(node->get_transform()); - Node *owner = node->get_owner(); + Node *owner = get_tree()->get_edited_scene_root(); ur->add_do_method(node->get_parent(), "add_child", cshape, true); ur->add_do_method(node->get_parent(), "move_child", cshape, node->get_index() + 1); ur->add_do_method(cshape, "set_owner", owner); + ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", cshape); ur->add_do_reference(cshape); ur->add_undo_method(node->get_parent(), "remove_child", cshape); @@ -217,14 +223,17 @@ void MeshInstance3DEditor::_menu_option(int p_option) { for (int i = 0; i < shapes.size(); i++) { CollisionShape3D *cshape = memnew(CollisionShape3D); + cshape->set_name("CollisionShape3D"); + cshape->set_shape(shapes[i]); cshape->set_transform(node->get_transform()); - Node *owner = node->get_owner(); + Node *owner = get_tree()->get_edited_scene_root(); ur->add_do_method(node->get_parent(), "add_child", cshape); ur->add_do_method(node->get_parent(), "move_child", cshape, node->get_index() + 1); ur->add_do_method(cshape, "set_owner", owner); + ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", cshape); ur->add_do_reference(cshape); ur->add_undo_method(node->get_parent(), "remove_child", cshape); } @@ -243,13 +252,14 @@ void MeshInstance3DEditor::_menu_option(int p_option) { NavigationRegion3D *nmi = memnew(NavigationRegion3D); nmi->set_navigation_mesh(nmesh); - Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner(); + Node *owner = get_tree()->get_edited_scene_root(); UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); ur->create_action(TTR("Create Navigation Mesh")); ur->add_do_method(node, "add_child", nmi, true); ur->add_do_method(nmi, "set_owner", owner); + ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", nmi); ur->add_do_reference(nmi); ur->add_undo_method(node, "remove_child", nmi); @@ -267,13 +277,52 @@ void MeshInstance3DEditor::_menu_option(int p_option) { return; } - Error err = mesh2->lightmap_unwrap(node->get_global_transform()); + String path = mesh2->get_path(); + int srpos = path.find("::"); + if (srpos != -1) { + String base = path.substr(0, srpos); + if (ResourceLoader::get_resource_type(base) == "PackedScene") { + if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) { + err_dialog->set_text(TTR("Mesh cannot unwrap UVs because it does not belong to the edited scene. Make it unique first.")); + err_dialog->popup_centered(); + return; + } + } else { + if (FileAccess::exists(path + ".import")) { + err_dialog->set_text(TTR("Mesh cannot unwrap UVs because it belongs to another resource which was imported from another file type. Make it unique first.")); + err_dialog->popup_centered(); + return; + } + } + } else { + if (FileAccess::exists(path + ".import")) { + err_dialog->set_text(TTR("Mesh cannot unwrap UVs because it was imported from another file type. Make it unique first.")); + err_dialog->popup_centered(); + return; + } + } + + Ref<ArrayMesh> unwrapped_mesh = mesh2->duplicate(false); + + Error err = unwrapped_mesh->lightmap_unwrap(node->get_global_transform()); if (err != OK) { err_dialog->set_text(TTR("UV Unwrap failed, mesh may not be manifold?")); err_dialog->popup_centered(); return; } + UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); + ur->create_action(TTR("Unwrap UV2")); + + ur->add_do_method(node, "set_mesh", unwrapped_mesh); + ur->add_do_reference(node); + ur->add_do_reference(mesh2.ptr()); + + ur->add_undo_method(node, "set_mesh", mesh2); + ur->add_undo_reference(unwrapped_mesh.ptr()); + + ur->commit_action(); + } break; case MENU_OPTION_DEBUG_UV1: { Ref<Mesh> mesh2 = node->get_mesh(); @@ -324,7 +373,7 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) { Ref<Mesh> mesh = node->get_mesh(); ERR_FAIL_COND(!mesh.is_valid()); - Set<MeshInstance3DEditorEdgeSort> edges; + RBSet<MeshInstance3DEditorEdgeSort> edges; uv_lines.clear(); for (int i = 0; i < mesh->get_surface_count(); i++) { if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) { @@ -418,10 +467,7 @@ void MeshInstance3DEditor::_create_outline_mesh() { MeshInstance3D *mi = memnew(MeshInstance3D); mi->set_mesh(mesho); - Node *owner = node->get_owner(); - if (get_tree()->get_edited_scene_root() == node) { - owner = node; - } + Node *owner = get_tree()->get_edited_scene_root(); UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); @@ -429,6 +475,7 @@ void MeshInstance3DEditor::_create_outline_mesh() { ur->add_do_method(node, "add_child", mi, true); ur->add_do_method(mi, "set_owner", owner); + ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", mi); ur->add_do_reference(mi); ur->add_undo_method(node, "remove_child", mi); diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 423ec5f4ed..914ccb54c1 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -71,7 +71,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, p_library->clear(); } - Map<int, MeshInstance3D *> mesh_instances; + HashMap<int, MeshInstance3D *> mesh_instances; for (int i = 0; i < p_scene->get_child_count(); i++) { Node *child = p_scene->get_child(i); diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index b54fa41e88..0fab3aed0d 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -141,7 +141,7 @@ void MultiMeshEditor::_populate() { const Face3 *r = faces.ptr(); float area_accum = 0; - Map<float, int> triangle_area_map; + RBMap<float, int> triangle_area_map; for (int i = 0; i < facecount; i++) { float area = r[i].get_area(); if (area < CMP_EPSILON) { @@ -180,9 +180,9 @@ void MultiMeshEditor::_populate() { for (int i = 0; i < instance_count; i++) { float areapos = Math::random(0.0f, area_accum); - Map<float, int>::Element *E = triangle_area_map.find_closest(areapos); + RBMap<float, int>::Iterator E = triangle_area_map.find_closest(areapos); ERR_FAIL_COND(!E); - int index = E->get(); + int index = E->value; ERR_FAIL_INDEX(index, facecount); // ok FINALLY get face diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 6829e25ef3..3002821082 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -3789,7 +3789,7 @@ void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->clear(); Vector<Vector3> lines; - Set<Vector2i> lines_found; + RBSet<Vector2i> lines_found; Vector<Vector3> points = data->get_capture_points(); if (points.size() == 0) { @@ -4755,7 +4755,7 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { return; } - Map<_EdgeKey, bool> edge_map; + HashMap<_EdgeKey, bool, _EdgeKey> edge_map; Vector<Vector3> tmeshfaces; tmeshfaces.resize(faces.size() * 3); @@ -4773,10 +4773,10 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { SWAP(ek.from, ek.to); } - Map<_EdgeKey, bool>::Element *F = edge_map.find(ek); + HashMap<_EdgeKey, bool, _EdgeKey>::Iterator F = edge_map.find(ek); if (F) { - F->get() = false; + F->value = false; } else { edge_map[ek] = true; diff --git a/editor/plugins/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h index f859ceda3b..a0d7715347 100644 --- a/editor/plugins/node_3d_editor_gizmos.h +++ b/editor/plugins/node_3d_editor_gizmos.h @@ -31,8 +31,8 @@ #ifndef NODE_3D_EDITOR_GIZMOS_H #define NODE_3D_EDITOR_GIZMOS_H +#include "core/templates/hash_map.h" #include "core/templates/local_vector.h" -#include "core/templates/ordered_hash_map.h" #include "scene/3d/camera_3d.h" #include "scene/3d/node_3d.h" #include "scene/3d/skeleton_3d.h" @@ -601,7 +601,13 @@ class NavigationRegion3DGizmoPlugin : public EditorNode3DGizmoPlugin { Vector3 from; Vector3 to; - bool operator<(const _EdgeKey &p_with) const { return from == p_with.from ? to < p_with.to : from < p_with.from; } + static uint32_t hash(const _EdgeKey &p_key) { + return HashMapHasherDefault::hash(p_key.from) ^ HashMapHasherDefault::hash(p_key.to); + } + + bool operator==(const _EdgeKey &p_with) const { + return HashMapComparatorDefault<Vector3>::compare(from, p_with.from) && HashMapComparatorDefault<Vector3>::compare(to, p_with.to); + } }; public: diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index d2af13d7fa..1d85e80331 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -369,7 +369,7 @@ Transform3D Node3DEditorViewport::to_camera_transform(const Cursor &p_cursor) co } int Node3DEditorViewport::get_selected_count() const { - const Map<Node *, Object *> &selection = editor_selection->get_selection(); + const HashMap<Node *, Object *> &selection = editor_selection->get_selection(); int count = 0; @@ -518,7 +518,7 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos) { } Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(pos, pos + ray * camera->get_far(), get_tree()->get_root()->get_world_3d()->get_scenario()); - Set<Ref<EditorNode3DGizmo>> found_gizmos; + RBSet<Ref<EditorNode3DGizmo>> found_gizmos; Node *edited_scene = get_tree()->get_edited_scene_root(); ObjectID closest; @@ -581,7 +581,7 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, Vector<_RayRe Vector3 pos = _get_ray_pos(p_pos); Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(pos, pos + ray * camera->get_far(), get_tree()->get_root()->get_world_3d()->get_scenario()); - Set<Node3D *> found_nodes; + RBSet<Node3D *> found_nodes; for (int i = 0; i < instances.size(); i++) { Node3D *spat = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i])); @@ -764,7 +764,7 @@ void Node3DEditorViewport::_select_region() { } Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world_3d()->get_scenario()); - Set<Node3D *> found_nodes; + RBSet<Node3D *> found_nodes; Vector<Node *> selected; Node *edited_scene = get_tree()->get_edited_scene_root(); @@ -2465,7 +2465,7 @@ void Node3DEditorViewport::_notification(int p_what) { _update_camera(delta); - const Map<Node *, Object *> &selection = editor_selection->get_selection(); + const HashMap<Node *, Object *> &selection = editor_selection->get_selection(); bool changed = false; bool exist = false; @@ -6685,8 +6685,8 @@ void Node3DEditor::_refresh_menu_icons() { } template <typename T> -Set<T *> _get_child_nodes(Node *parent_node) { - Set<T *> nodes = Set<T *>(); +RBSet<T *> _get_child_nodes(Node *parent_node) { + RBSet<T *> nodes = RBSet<T *>(); T *node = Node::cast_to<T>(parent_node); if (node) { nodes.insert(node); @@ -6694,8 +6694,8 @@ Set<T *> _get_child_nodes(Node *parent_node) { for (int i = 0; i < parent_node->get_child_count(); i++) { Node *child_node = parent_node->get_child(i); - Set<T *> child_nodes = _get_child_nodes<T>(child_node); - for (typename Set<T *>::Element *I = child_nodes.front(); I; I = I->next()) { + RBSet<T *> child_nodes = _get_child_nodes<T>(child_node); + for (typename RBSet<T *>::Element *I = child_nodes.front(); I; I = I->next()) { nodes.insert(I->get()); } } @@ -6703,14 +6703,14 @@ Set<T *> _get_child_nodes(Node *parent_node) { return nodes; } -Set<RID> _get_physics_bodies_rid(Node *node) { - Set<RID> rids = Set<RID>(); +RBSet<RID> _get_physics_bodies_rid(Node *node) { + RBSet<RID> rids = RBSet<RID>(); PhysicsBody3D *pb = Node::cast_to<PhysicsBody3D>(node); if (pb) { rids.insert(pb->get_rid()); } - Set<PhysicsBody3D *> child_nodes = _get_child_nodes<PhysicsBody3D>(node); - for (Set<PhysicsBody3D *>::Element *I = child_nodes.front(); I; I = I->next()) { + RBSet<PhysicsBody3D *> child_nodes = _get_child_nodes<PhysicsBody3D>(node); + for (RBSet<PhysicsBody3D *>::Element *I = child_nodes.front(); I; I = I->next()) { rids.insert(I->get()->get_rid()); } @@ -6728,13 +6728,13 @@ void Node3DEditor::snap_selected_nodes_to_floor() { Vector3 position_offset = Vector3(); // Priorities for snapping to floor are CollisionShapes, VisualInstances and then origin - Set<VisualInstance3D *> vi = _get_child_nodes<VisualInstance3D>(sp); - Set<CollisionShape3D *> cs = _get_child_nodes<CollisionShape3D>(sp); + RBSet<VisualInstance3D *> vi = _get_child_nodes<VisualInstance3D>(sp); + RBSet<CollisionShape3D *> cs = _get_child_nodes<CollisionShape3D>(sp); bool found_valid_shape = false; if (cs.size()) { AABB aabb; - Set<CollisionShape3D *>::Element *I = cs.front(); + RBSet<CollisionShape3D *>::Element *I = cs.front(); if (I->get()->get_shape().is_valid()) { CollisionShape3D *collision_shape = cs.front()->get(); aabb = collision_shape->get_global_transform().xform(collision_shape->get_shape()->get_debug_mesh()->get_aabb()); @@ -6755,7 +6755,7 @@ void Node3DEditor::snap_selected_nodes_to_floor() { } if (!found_valid_shape && vi.size()) { AABB aabb = vi.front()->get()->get_transformed_aabb(); - for (Set<VisualInstance3D *>::Element *I = vi.front(); I; I = I->next()) { + for (RBSet<VisualInstance3D *>::Element *I = vi.front(); I; I = I->next()) { aabb.merge_with(I->get()->get_transformed_aabb()); } Vector3 size = aabb.size * Vector3(0.5, 0.0, 0.5); @@ -6798,7 +6798,7 @@ void Node3DEditor::snap_selected_nodes_to_floor() { Dictionary d = snap_data[node]; Vector3 from = d["from"]; Vector3 to = from - Vector3(0.0, max_snap_height, 0.0); - Set<RID> excluded = _get_physics_bodies_rid(sp); + RBSet<RID> excluded = _get_physics_bodies_rid(sp); PhysicsDirectSpaceState3D::RayParameters ray_params; ray_params.from = from; @@ -6820,7 +6820,7 @@ void Node3DEditor::snap_selected_nodes_to_floor() { Dictionary d = snap_data[node]; Vector3 from = d["from"]; Vector3 to = from - Vector3(0.0, max_snap_height, 0.0); - Set<RID> excluded = _get_physics_bodies_rid(sp); + RBSet<RID> excluded = _get_physics_bodies_rid(sp); PhysicsDirectSpaceState3D::RayParameters ray_params; ray_params.from = from; diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index 43efdeec72..511135a5f1 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -461,7 +461,7 @@ public: RID sbox_instance_xray; RID sbox_instance_xray_offset; Ref<EditorNode3DGizmo> gizmo; - Map<int, Transform3D> subgizmos; // map ID -> initial transform + HashMap<int, Transform3D> subgizmos; // map ID -> initial transform Node3DEditorSelectedItem() { sp = nullptr; diff --git a/editor/plugins/packed_scene_translation_parser_plugin.h b/editor/plugins/packed_scene_translation_parser_plugin.h index ecd090b31b..9135498333 100644 --- a/editor/plugins/packed_scene_translation_parser_plugin.h +++ b/editor/plugins/packed_scene_translation_parser_plugin.h @@ -37,9 +37,9 @@ class PackedSceneEditorTranslationParserPlugin : public EditorTranslationParserP GDCLASS(PackedSceneEditorTranslationParserPlugin, EditorTranslationParserPlugin); // Scene Node's properties that contain translation strings. - Set<String> lookup_properties; + RBSet<String> lookup_properties; // Properties from specific Nodes that should be ignored. - Map<String, Vector<String>> exception_list; + HashMap<String, Vector<String>> exception_list; public: virtual Error parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural) override; diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index bfb672d694..b632b0d641 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -65,7 +65,7 @@ void EditorPropertyRootMotion::_node_assign() { return; } - Set<String> paths; + RBSet<String> paths; { List<StringName> animations; player->get_animation_list(&animations); @@ -81,9 +81,9 @@ void EditorPropertyRootMotion::_node_assign() { filters->clear(); TreeItem *root = filters->create_item(); - Map<String, TreeItem *> parenthood; + HashMap<String, TreeItem *> parenthood; - for (Set<String>::Element *E = paths.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = paths.front(); E; E = E->next()) { NodePath path = E->get(); TreeItem *ti = nullptr; String accum; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 5240fdf836..8e33afa3c6 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -119,9 +119,9 @@ void EditorStandardSyntaxHighlighter::_update_cache() { } /* Autoloads. */ - OrderedHashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list(); - for (OrderedHashMap<StringName, ProjectSettings::AutoloadInfo>::Element E = autoloads.front(); E; E = E.next()) { - const ProjectSettings::AutoloadInfo &info = E.value(); + HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list(); + for (const KeyValue<StringName, ProjectSettings::AutoloadInfo> &E : autoloads) { + const ProjectSettings::AutoloadInfo &info = E.value; if (info.is_singleton) { highlighter->add_keyword_color(info.name, usertype_color); } @@ -235,21 +235,21 @@ class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache { Ref<Resource> cache; }; - Map<String, Cache> cached; + HashMap<String, Cache> cached; public: uint64_t max_time_cache = 5 * 60 * 1000; //minutes, five - int max_cache_size = 128; + uint32_t max_cache_size = 128; void cleanup() { - List<Map<String, Cache>::Element *> to_clean; + List<String> to_clean; - Map<String, Cache>::Element *I = cached.front(); + HashMap<String, Cache>::Iterator I = cached.begin(); while (I) { - if ((OS::get_singleton()->get_ticks_msec() - I->get().time_loaded) > max_time_cache) { - to_clean.push_back(I); + if ((OS::get_singleton()->get_ticks_msec() - I->value.time_loaded) > max_time_cache) { + to_clean.push_back(I->key); } - I = I->next(); + ++I; } while (to_clean.front()) { @@ -259,34 +259,34 @@ public: } virtual Ref<Resource> get_cached_resource(const String &p_path) { - Map<String, Cache>::Element *E = cached.find(p_path); + HashMap<String, Cache>::Iterator E = cached.find(p_path); if (!E) { Cache c; c.cache = ResourceLoader::load(p_path); E = cached.insert(p_path, c); } - E->get().time_loaded = OS::get_singleton()->get_ticks_msec(); + E->value.time_loaded = OS::get_singleton()->get_ticks_msec(); if (cached.size() > max_cache_size) { uint64_t older; - Map<String, Cache>::Element *O = cached.front(); - older = O->get().time_loaded; - Map<String, Cache>::Element *I = O; + HashMap<String, Cache>::Iterator O = cached.begin(); + older = O->value.time_loaded; + HashMap<String, Cache>::Iterator I = O; while (I) { - if (I->get().time_loaded < older) { - older = I->get().time_loaded; + if (I->value.time_loaded < older) { + older = I->value.time_loaded; O = I; } - I = I->next(); + ++I; } if (O != E) { //should never happen.. - cached.erase(O); + cached.remove(O); } } - return E->get().cache; + return E->value.cache; } virtual ~EditorScriptCodeCompletionCache() {} @@ -1707,7 +1707,7 @@ void ScriptEditor::notify_script_changed(const Ref<Script> &p_script) { } void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { - Set<String> loaded_scripts; + RBSet<String> loaded_scripts; 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) { @@ -1792,7 +1792,7 @@ void ScriptEditor::ensure_select_current() { _update_selected_editor_menu(); } -void ScriptEditor::_find_scripts(Node *p_base, Node *p_current, Set<Ref<Script>> &used) { +void ScriptEditor::_find_scripts(Node *p_base, Node *p_current, RBSet<Ref<Script>> &used) { if (p_current != p_base && p_current->get_owner() != p_base) { return; } @@ -1972,7 +1972,7 @@ void ScriptEditor::_update_script_names() { return; } - Set<Ref<Script>> used; + RBSet<Ref<Script>> used; Node *edited = EditorNode::get_singleton()->get_edited_scene(); if (edited) { _find_scripts(edited, edited, used); @@ -3135,7 +3135,7 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { restoring_layout = true; - Set<String> loaded_scripts; + RBSet<String> loaded_scripts; List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("Script", &extensions); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 41b311f745..35cb24da70 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -415,7 +415,7 @@ class ScriptEditor : public PanelContainer { void _update_help_overview(); void _help_overview_selected(int p_idx); - void _find_scripts(Node *p_base, Node *p_current, Set<Ref<Script>> &used); + void _find_scripts(Node *p_base, Node *p_current, RBSet<Ref<Script>> &used); void _tree_changed(); @@ -455,7 +455,7 @@ class ScriptEditor : public PanelContainer { Ref<Script> _get_current_script(); Array _get_open_scripts() const; - Set<String> textfile_extensions; + RBSet<String> textfile_extensions; Ref<TextFile> _load_text_file(const String &p_path, Error *r_error) const; Error _save_text_file(Ref<TextFile> p_text_file, const String &p_path); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 981881fb9b..9c78f3f2e8 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -664,7 +664,7 @@ static Node *_find_node_for_script(Node *p_base, Node *p_current, const Ref<Scri return nullptr; } -static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_current, Set<Ref<Script>> &r_scripts) { +static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_current, RBSet<Ref<Script>> &r_scripts) { if (p_current->get_owner() != p_base && p_base != p_current) { return; } @@ -686,14 +686,14 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo ERR_FAIL_COND(!get_tree()); - Set<Ref<Script>> scripts; + RBSet<Ref<Script>> scripts; Node *base = get_tree()->get_edited_scene_root(); if (base) { _find_changed_scripts_for_external_editor(base, base, scripts); } - for (Set<Ref<Script>>::Element *E = scripts.front(); E; E = E->next()) { + for (RBSet<Ref<Script>>::Element *E = scripts.front(); E; E = E->next()) { Ref<Script> script = E->get(); if (p_for_script.is_valid() && p_for_script != script) { @@ -855,6 +855,21 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c emit_signal(SNAME("go_to_help"), "class_method:" + result.class_name + ":" + result.class_member); } break; + case ScriptLanguage::LOOKUP_RESULT_CLASS_SIGNAL: { + StringName cname = result.class_name; + + while (true) { + if (ClassDB::has_signal(cname, result.class_member)) { + result.class_name = cname; + cname = ClassDB::get_parent_class(cname); + } else { + break; + } + } + + emit_signal(SNAME("go_to_help"), "class_signal:" + result.class_name + ":" + result.class_member); + + } break; case ScriptLanguage::LOOKUP_RESULT_CLASS_ENUM: { StringName cname = result.class_name; StringName success; @@ -955,7 +970,7 @@ void ScriptTextEditor::_update_connected_methods() { } Vector<Node *> nodes = _find_all_node_for_script(base, base, script); - Set<StringName> methods_found; + RBSet<StringName> methods_found; for (int i = 0; i < nodes.size(); i++) { List<Connection> connections; nodes[i]->get_signals_connected_to_this(&connections); @@ -1356,11 +1371,11 @@ void ScriptTextEditor::add_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_hig void ScriptTextEditor::set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) { ERR_FAIL_COND(p_highlighter.is_null()); - Map<String, Ref<EditorSyntaxHighlighter>>::Element *el = highlighters.front(); - while (el != nullptr) { - int highlighter_index = highlighter_menu->get_item_idx_from_text(el->key()); - highlighter_menu->set_item_checked(highlighter_index, el->value() == p_highlighter); - el = el->next(); + HashMap<String, Ref<EditorSyntaxHighlighter>>::Iterator el = highlighters.begin(); + while (el) { + int highlighter_index = highlighter_menu->get_item_idx_from_text(el->key); + highlighter_menu->set_item_checked(highlighter_index, el->value == p_highlighter); + ++el; } CodeEdit *te = code_editor->get_text_editor(); diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index b3e0c28bb1..ff13b38832 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -64,7 +64,7 @@ class ScriptTextEditor : public ScriptEditorBase { Vector<String> functions; List<ScriptLanguage::Warning> warnings; List<ScriptLanguage::ScriptError> errors; - Set<int> safe_lines; + RBSet<int> safe_lines; List<Connection> missing_connections; @@ -175,7 +175,7 @@ protected: void _notification(int p_what); static void _bind_methods(); - Map<String, Ref<EditorSyntaxHighlighter>> highlighters; + HashMap<String, Ref<EditorSyntaxHighlighter>> highlighters; void _change_syntax_highlighter(int p_idx); void _edit_option(int p_op); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 1bf78cc107..c13d0dc197 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -47,7 +47,7 @@ static bool saved_warnings_enabled = false; static bool saved_treat_warning_as_errors = false; -static Map<ShaderWarning::Code, bool> saved_warnings; +static HashMap<ShaderWarning::Code, bool> saved_warnings; static uint32_t saved_warning_flags = 0U; void ShaderTextEditor::_notification(int p_what) { diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 1b703a097c..1ebdf466fe 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -357,7 +357,7 @@ void Skeleton3DEditor::pose_to_rest(const bool p_all_bones) { void Skeleton3DEditor::create_physical_skeleton() { UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); ERR_FAIL_COND(!get_tree()); - Node *owner = skeleton == get_tree()->get_edited_scene_root() ? skeleton : skeleton->get_owner(); + Node *owner = get_tree()->get_edited_scene_root(); const int bc = skeleton->get_bone_count(); @@ -368,37 +368,47 @@ void Skeleton3DEditor::create_physical_skeleton() { Vector<BoneInfo> bones_infos; bones_infos.resize(bc); - for (int bone_id = 0; bc > bone_id; ++bone_id) { - const int parent = skeleton->get_bone_parent(bone_id); + if (bc > 0) { + ur->create_action(TTR("Create physical bones"), UndoRedo::MERGE_ALL); + for (int bone_id = 0; bc > bone_id; ++bone_id) { + const int parent = skeleton->get_bone_parent(bone_id); - if (parent < 0) { - bones_infos.write[bone_id].relative_rest = skeleton->get_bone_rest(bone_id); - - } else { - const int parent_parent = skeleton->get_bone_parent(parent); - - bones_infos.write[bone_id].relative_rest = bones_infos[parent].relative_rest * skeleton->get_bone_rest(bone_id); - - // Create physical bone on parent. - if (!bones_infos[parent].physical_bone) { - bones_infos.write[parent].physical_bone = create_physical_bone(parent, bone_id, bones_infos); - - ur->create_action(TTR("Create physical bones"), UndoRedo::MERGE_ALL); - ur->add_do_method(skeleton, "add_child", bones_infos[parent].physical_bone); - ur->add_do_reference(bones_infos[parent].physical_bone); - ur->add_undo_method(skeleton, "remove_child", bones_infos[parent].physical_bone); - ur->commit_action(); + if (parent < 0) { + bones_infos.write[bone_id].relative_rest = skeleton->get_bone_rest(bone_id); + } else { + const int parent_parent = skeleton->get_bone_parent(parent); + + bones_infos.write[bone_id].relative_rest = bones_infos[parent].relative_rest * skeleton->get_bone_rest(bone_id); + + // Create physical bone on parent. + if (!bones_infos[parent].physical_bone) { + PhysicalBone3D *physical_bone = create_physical_bone(parent, bone_id, bones_infos); + if (physical_bone && physical_bone->get_child(0)) { + CollisionShape3D *collision_shape = Object::cast_to<CollisionShape3D>(physical_bone->get_child(0)); + if (collision_shape) { + bones_infos.write[parent].physical_bone = physical_bone; + + ur->add_do_method(skeleton, "add_child", physical_bone); + ur->add_do_method(physical_bone, "set_owner", owner); + ur->add_do_method(collision_shape, "set_owner", owner); + ur->add_do_property(physical_bone, "bone_name", skeleton->get_bone_name(parent)); + + // Create joint between parent of parent. + if (parent_parent != -1) { + ur->add_do_method(physical_bone, "set_joint_type", PhysicalBone3D::JOINT_TYPE_PIN); + } - bones_infos[parent].physical_bone->set_bone_name(skeleton->get_bone_name(parent)); - bones_infos[parent].physical_bone->set_owner(owner); - bones_infos[parent].physical_bone->get_child(0)->set_owner(owner); // set shape owner + ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", physical_bone); + ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", collision_shape); - // Create joint between parent of parent. - if (-1 != parent_parent) { - bones_infos[parent].physical_bone->set_joint_type(PhysicalBone3D::JOINT_TYPE_PIN); + ur->add_do_reference(physical_bone); + ur->add_undo_method(skeleton, "remove_child", physical_bone); + } + } } } } + ur->commit_action(); } } @@ -414,6 +424,7 @@ PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_chi CollisionShape3D *bone_shape = memnew(CollisionShape3D); bone_shape->set_shape(bone_shape_capsule); + bone_shape->set_name("CollisionShape3D"); Transform3D capsule_transform; capsule_transform.basis = Basis(Vector3(1, 0, 0), Vector3(0, 0, 1), Vector3(0, -1, 0)); @@ -577,7 +588,7 @@ void Skeleton3DEditor::update_joint_tree() { TreeItem *root = joint_tree->create_item(); - Map<int, TreeItem *> items; + HashMap<int, TreeItem *> items; items.insert(-1, root); @@ -589,7 +600,7 @@ void Skeleton3DEditor::update_joint_tree() { bones_to_process.erase(current_bone_idx); const int parent_idx = skeleton->get_bone_parent(current_bone_idx); - TreeItem *parent_item = items.find(parent_idx)->get(); + TreeItem *parent_item = items.find(parent_idx)->value; TreeItem *joint_item = joint_tree->create_item(parent_item); items.insert(current_bone_idx, joint_item); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 7b6aeb3679..cb8d59dfe4 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -125,7 +125,7 @@ void SpriteFramesEditor::_sheet_preview_draw() { Color accent = get_theme_color("accent_color", "Editor"); - for (Set<int>::Element *E = frames_selected.front(); E; E = E->next()) { + for (RBSet<int>::Element *E = frames_selected.front(); E; E = E->next()) { const int idx = E->get(); const int x = idx % frame_count.x; const int y = idx / frame_count.x; @@ -248,7 +248,7 @@ void SpriteFramesEditor::_sheet_add_frames() { int fc = frames->get_frame_count(edited_anim); - for (Set<int>::Element *E = frames_selected.front(); E; E = E->next()) { + for (RBSet<int>::Element *E = frames_selected.front(); E; E = E->next()) { int idx = E->get(); const Point2 frame_coords(idx % frame_count.x, idx / frame_count.x); diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h index 3230228fdd..6f16ff2bd1 100644 --- a/editor/plugins/sprite_frames_editor_plugin.h +++ b/editor/plugins/sprite_frames_editor_plugin.h @@ -103,8 +103,8 @@ class SpriteFramesEditor : public HSplitContainer { Button *split_sheet_zoom_reset = nullptr; Button *split_sheet_zoom_in = nullptr; EditorFileDialog *file_split_sheet = nullptr; - Set<int> frames_selected; - Set<int> frames_toggled_by_mouse_hover; + RBSet<int> frames_selected; + RBSet<int> frames_toggled_by_mouse_hover; int last_frame_selected = 0; float scale_ratio; diff --git a/editor/plugins/text_control_editor_plugin.cpp b/editor/plugins/text_control_editor_plugin.cpp index 4290888e94..2a5faba4a2 100644 --- a/editor/plugins/text_control_editor_plugin.cpp +++ b/editor/plugins/text_control_editor_plugin.cpp @@ -92,8 +92,8 @@ void TextControlEditor::_update_fonts_menu() { } int id = FONT_INFO_ID; - for (Map<String, Map<String, String>>::Element *E = fonts.front(); E; E = E->next()) { - font_list->add_item(E->key(), id++); + for (const KeyValue<String, HashMap<String, String>> &E : fonts) { + font_list->add_item(E.key, id++); } if (font_list->get_item_count() > 1) { @@ -107,8 +107,8 @@ void TextControlEditor::_update_styles_menu() { font_style_list->clear(); if ((font_list->get_selected_id() >= FONT_INFO_ID)) { const String &name = font_list->get_item_text(font_list->get_selected()); - for (Map<String, String>::Element *E = fonts[name].front(); E; E = E->next()) { - font_style_list->add_item(E->key()); + for (KeyValue<String, String> &E : fonts[name]) { + font_style_list->add_item(E.key); } } else if (font_list->get_selected() >= 0) { font_style_list->add_item("Default"); diff --git a/editor/plugins/text_control_editor_plugin.h b/editor/plugins/text_control_editor_plugin.h index a475f6eba3..cf069338b6 100644 --- a/editor/plugins/text_control_editor_plugin.h +++ b/editor/plugins/text_control_editor_plugin.h @@ -52,7 +52,7 @@ class TextControlEditor : public HBoxContainer { FONT_INFO_ID = 100, }; - Map<String, Map<String, String>> fonts; + HashMap<String, HashMap<String, String>> fonts; OptionButton *font_list = nullptr; SpinBox *font_size_list = nullptr; diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 97ecc234e6..7ca65c073d 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -43,11 +43,11 @@ void TextEditor::add_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlight void TextEditor::set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) { ERR_FAIL_COND(p_highlighter.is_null()); - Map<String, Ref<EditorSyntaxHighlighter>>::Element *el = highlighters.front(); - while (el != nullptr) { - int highlighter_index = highlighter_menu->get_item_idx_from_text(el->key()); - highlighter_menu->set_item_checked(highlighter_index, el->value() == p_highlighter); - el = el->next(); + HashMap<String, Ref<EditorSyntaxHighlighter>>::Iterator el = highlighters.begin(); + while (el) { + int highlighter_index = highlighter_menu->get_item_idx_from_text(el->key); + highlighter_menu->set_item_checked(highlighter_index, el->value == p_highlighter); + ++el; } CodeEdit *te = code_editor->get_text_editor(); diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h index 9b6d568382..4f0121da52 100644 --- a/editor/plugins/text_editor.h +++ b/editor/plugins/text_editor.h @@ -92,7 +92,7 @@ protected: void _text_edit_gui_input(const Ref<InputEvent> &ev); void _prepare_edit_menu(); - Map<String, Ref<EditorSyntaxHighlighter>> highlighters; + HashMap<String, Ref<EditorSyntaxHighlighter>> highlighters; void _change_syntax_highlighter(int p_idx); void _load_theme_settings(); diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h index 2493446303..2c4ab72743 100644 --- a/editor/plugins/texture_region_editor_plugin.h +++ b/editor/plugins/texture_region_editor_plugin.h @@ -89,7 +89,7 @@ class TextureRegionEditor : public VBoxContainer { Rect2 rect_prev; float prev_margin = 0.0f; int edited_margin; - Map<RID, List<Rect2>> cache_map; + HashMap<RID, List<Rect2>> cache_map; List<Rect2> autoslice_cache; bool autoslice_is_dirty; diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 87f8c4b165..41a599e933 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -2339,8 +2339,8 @@ void ThemeTypeEditor::_update_type_list_debounced() { update_debounce_timer->start(); } -OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_name, void (Theme::*get_list_func)(StringName, List<StringName> *) const, bool include_default) { - OrderedHashMap<StringName, bool> items; +HashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_name, void (Theme::*get_list_func)(StringName, List<StringName> *) const, bool include_default) { + HashMap<StringName, bool> items; List<StringName> names; if (include_default) { @@ -2367,12 +2367,12 @@ OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_ } List<StringName> keys; - for (OrderedHashMap<StringName, bool>::Element E = items.front(); E; E = E.next()) { - keys.push_back(E.key()); + for (const KeyValue<StringName, bool> &E : items) { + keys.push_back(E.key); } keys.sort_custom<StringName::AlphCompare>(); - OrderedHashMap<StringName, bool> ordered_items; + HashMap<StringName, bool> ordered_items; for (const StringName &E : keys) { ordered_items[E] = items[E]; } @@ -2464,18 +2464,18 @@ void ThemeTypeEditor::_update_type_items() { color_items_list->remove_child(node); } - OrderedHashMap<StringName, bool> color_items = _get_type_items(edited_type, &Theme::get_color_list, show_default); - for (OrderedHashMap<StringName, bool>::Element E = color_items.front(); E; E = E.next()) { - HBoxContainer *item_control = _create_property_control(Theme::DATA_TYPE_COLOR, E.key(), E.get()); + HashMap<StringName, bool> color_items = _get_type_items(edited_type, &Theme::get_color_list, show_default); + for (const KeyValue<StringName, bool> &E : color_items) { + HBoxContainer *item_control = _create_property_control(Theme::DATA_TYPE_COLOR, E.key, E.value); ColorPickerButton *item_editor = memnew(ColorPickerButton); item_editor->set_h_size_flags(SIZE_EXPAND_FILL); item_control->add_child(item_editor); - if (E.get()) { - item_editor->set_pick_color(edited_theme->get_color(E.key(), edited_type)); - item_editor->connect("color_changed", callable_mp(this, &ThemeTypeEditor::_color_item_changed), varray(E.key())); + if (E.value) { + item_editor->set_pick_color(edited_theme->get_color(E.key, edited_type)); + item_editor->connect("color_changed", callable_mp(this, &ThemeTypeEditor::_color_item_changed), varray(E.key)); } else { - item_editor->set_pick_color(Theme::get_default()->get_color(E.key(), edited_type)); + item_editor->set_pick_color(Theme::get_default()->get_color(E.key, edited_type)); item_editor->set_disabled(true); } @@ -2492,9 +2492,9 @@ void ThemeTypeEditor::_update_type_items() { constant_items_list->remove_child(node); } - OrderedHashMap<StringName, bool> constant_items = _get_type_items(edited_type, &Theme::get_constant_list, show_default); - for (OrderedHashMap<StringName, bool>::Element E = constant_items.front(); E; E = E.next()) { - HBoxContainer *item_control = _create_property_control(Theme::DATA_TYPE_CONSTANT, E.key(), E.get()); + HashMap<StringName, bool> constant_items = _get_type_items(edited_type, &Theme::get_constant_list, show_default); + for (const KeyValue<StringName, bool> &E : constant_items) { + HBoxContainer *item_control = _create_property_control(Theme::DATA_TYPE_CONSTANT, E.key, E.value); SpinBox *item_editor = memnew(SpinBox); item_editor->set_h_size_flags(SIZE_EXPAND_FILL); item_editor->set_min(-100000); @@ -2504,11 +2504,11 @@ void ThemeTypeEditor::_update_type_items() { item_editor->set_allow_greater(true); item_control->add_child(item_editor); - if (E.get()) { - item_editor->set_value(edited_theme->get_constant(E.key(), edited_type)); - item_editor->connect("value_changed", callable_mp(this, &ThemeTypeEditor::_constant_item_changed), varray(E.key())); + if (E.value) { + item_editor->set_value(edited_theme->get_constant(E.key, edited_type)); + item_editor->connect("value_changed", callable_mp(this, &ThemeTypeEditor::_constant_item_changed), varray(E.key)); } else { - item_editor->set_value(Theme::get_default()->get_constant(E.key(), edited_type)); + item_editor->set_value(Theme::get_default()->get_constant(E.key, edited_type)); item_editor->set_editable(false); } @@ -2525,25 +2525,25 @@ void ThemeTypeEditor::_update_type_items() { font_items_list->remove_child(node); } - OrderedHashMap<StringName, bool> font_items = _get_type_items(edited_type, &Theme::get_font_list, show_default); - for (OrderedHashMap<StringName, bool>::Element E = font_items.front(); E; E = E.next()) { - HBoxContainer *item_control = _create_property_control(Theme::DATA_TYPE_FONT, E.key(), E.get()); + HashMap<StringName, bool> font_items = _get_type_items(edited_type, &Theme::get_font_list, show_default); + for (const KeyValue<StringName, bool> &E : font_items) { + HBoxContainer *item_control = _create_property_control(Theme::DATA_TYPE_FONT, E.key, E.value); EditorResourcePicker *item_editor = memnew(EditorResourcePicker); item_editor->set_h_size_flags(SIZE_EXPAND_FILL); item_editor->set_base_type("Font"); item_control->add_child(item_editor); - if (E.get()) { - if (edited_theme->has_font(E.key(), edited_type)) { - item_editor->set_edited_resource(edited_theme->get_font(E.key(), edited_type)); + if (E.value) { + 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(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())); + item_editor->connect("resource_changed", callable_mp(this, &ThemeTypeEditor::_font_item_changed), varray(E.key)); } else { - if (Theme::get_default()->has_font(E.key(), edited_type)) { - item_editor->set_edited_resource(Theme::get_default()->get_font(E.key(), edited_type)); + 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(Ref<Resource>()); } @@ -2563,9 +2563,9 @@ void ThemeTypeEditor::_update_type_items() { font_size_items_list->remove_child(node); } - OrderedHashMap<StringName, bool> font_size_items = _get_type_items(edited_type, &Theme::get_font_size_list, show_default); - for (OrderedHashMap<StringName, bool>::Element E = font_size_items.front(); E; E = E.next()) { - HBoxContainer *item_control = _create_property_control(Theme::DATA_TYPE_FONT_SIZE, E.key(), E.get()); + HashMap<StringName, bool> font_size_items = _get_type_items(edited_type, &Theme::get_font_size_list, show_default); + for (const KeyValue<StringName, bool> &E : font_size_items) { + HBoxContainer *item_control = _create_property_control(Theme::DATA_TYPE_FONT_SIZE, E.key, E.value); SpinBox *item_editor = memnew(SpinBox); item_editor->set_h_size_flags(SIZE_EXPAND_FILL); item_editor->set_min(-100000); @@ -2575,11 +2575,11 @@ void ThemeTypeEditor::_update_type_items() { item_editor->set_allow_greater(true); item_control->add_child(item_editor); - if (E.get()) { - item_editor->set_value(edited_theme->get_font_size(E.key(), edited_type)); - item_editor->connect("value_changed", callable_mp(this, &ThemeTypeEditor::_font_size_item_changed), varray(E.key())); + if (E.value) { + item_editor->set_value(edited_theme->get_font_size(E.key, edited_type)); + item_editor->connect("value_changed", callable_mp(this, &ThemeTypeEditor::_font_size_item_changed), varray(E.key)); } else { - item_editor->set_value(Theme::get_default()->get_font_size(E.key(), edited_type)); + item_editor->set_value(Theme::get_default()->get_font_size(E.key, edited_type)); item_editor->set_editable(false); } @@ -2596,25 +2596,25 @@ void ThemeTypeEditor::_update_type_items() { icon_items_list->remove_child(node); } - OrderedHashMap<StringName, bool> icon_items = _get_type_items(edited_type, &Theme::get_icon_list, show_default); - for (OrderedHashMap<StringName, bool>::Element E = icon_items.front(); E; E = E.next()) { - HBoxContainer *item_control = _create_property_control(Theme::DATA_TYPE_ICON, E.key(), E.get()); + HashMap<StringName, bool> icon_items = _get_type_items(edited_type, &Theme::get_icon_list, show_default); + for (const KeyValue<StringName, bool> &E : icon_items) { + HBoxContainer *item_control = _create_property_control(Theme::DATA_TYPE_ICON, E.key, E.value); EditorResourcePicker *item_editor = memnew(EditorResourcePicker); item_editor->set_h_size_flags(SIZE_EXPAND_FILL); item_editor->set_base_type("Texture2D"); item_control->add_child(item_editor); - if (E.get()) { - if (edited_theme->has_icon(E.key(), edited_type)) { - item_editor->set_edited_resource(edited_theme->get_icon(E.key(), edited_type)); + if (E.value) { + 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(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())); + item_editor->connect("resource_changed", callable_mp(this, &ThemeTypeEditor::_icon_item_changed), varray(E.key)); } else { - if (Theme::get_default()->has_icon(E.key(), edited_type)) { - item_editor->set_edited_resource(Theme::get_default()->get_icon(E.key(), edited_type)); + 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(Ref<Resource>()); } @@ -2664,26 +2664,26 @@ void ThemeTypeEditor::_update_type_items() { stylebox_items_list->add_child(memnew(HSeparator)); } - OrderedHashMap<StringName, bool> stylebox_items = _get_type_items(edited_type, &Theme::get_stylebox_list, show_default); - for (OrderedHashMap<StringName, bool>::Element E = stylebox_items.front(); E; E = E.next()) { - if (leading_stylebox.pinned && leading_stylebox.item_name == E.key()) { + HashMap<StringName, bool> stylebox_items = _get_type_items(edited_type, &Theme::get_stylebox_list, show_default); + for (const KeyValue<StringName, bool> &E : stylebox_items) { + if (leading_stylebox.pinned && leading_stylebox.item_name == E.key) { continue; } - HBoxContainer *item_control = _create_property_control(Theme::DATA_TYPE_STYLEBOX, E.key(), E.get()); + HBoxContainer *item_control = _create_property_control(Theme::DATA_TYPE_STYLEBOX, E.key, E.value); EditorResourcePicker *item_editor = memnew(EditorResourcePicker); item_editor->set_h_size_flags(SIZE_EXPAND_FILL); item_editor->set_stretch_ratio(1.5); item_editor->set_base_type("StyleBox"); - if (E.get()) { - if (edited_theme->has_stylebox(E.key(), edited_type)) { - item_editor->set_edited_resource(edited_theme->get_stylebox(E.key(), edited_type)); + if (E.value) { + 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(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())); + item_editor->connect("resource_changed", callable_mp(this, &ThemeTypeEditor::_stylebox_item_changed), varray(E.key)); Button *pin_leader_button = memnew(Button); pin_leader_button->set_flat(true); @@ -2691,10 +2691,10 @@ void ThemeTypeEditor::_update_type_items() { pin_leader_button->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"))); pin_leader_button->set_tooltip(TTR("Pin this StyleBox as a main style. Editing its properties will update the same properties in all other StyleBoxes of this type.")); item_control->add_child(pin_leader_button); - pin_leader_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_on_pin_leader_button_pressed), varray(item_editor, E.key())); + pin_leader_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_on_pin_leader_button_pressed), varray(item_editor, E.key)); } else { - if (Theme::get_default()->has_stylebox(E.key(), edited_type)) { - item_editor->set_edited_resource(Theme::get_default()->get_stylebox(E.key(), edited_type)); + 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(Ref<Resource>()); } diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h index 3894ca31e5..323cfceb7e 100644 --- a/editor/plugins/theme_editor_plugin.h +++ b/editor/plugins/theme_editor_plugin.h @@ -73,7 +73,7 @@ class ThemeItemImportTree : public VBoxContainer { SELECT_IMPORT_FULL, }; - Map<ThemeItem, ItemCheckedState> selected_items; + RBMap<ThemeItem, ItemCheckedState> selected_items; LineEdit *import_items_filter = nullptr; @@ -363,7 +363,7 @@ class ThemeTypeEditor : public MarginContainer { VBoxContainer *_create_item_list(Theme::DataType p_data_type); void _update_type_list(); void _update_type_list_debounced(); - OrderedHashMap<StringName, bool> _get_type_items(String p_type_name, void (Theme::*get_list_func)(StringName, List<StringName> *) const, bool include_default); + HashMap<StringName, bool> _get_type_items(String p_type_name, void (Theme::*get_list_func)(StringName, List<StringName> *) const, bool include_default); HBoxContainer *_create_property_control(Theme::DataType p_data_type, String p_item_name, bool p_editable); void _add_focusable(Control *p_control); void _update_type_items(); diff --git a/editor/plugins/tiles/atlas_merging_dialog.cpp b/editor/plugins/tiles/atlas_merging_dialog.cpp index 086588f5a5..e37878ff98 100644 --- a/editor/plugins/tiles/atlas_merging_dialog.cpp +++ b/editor/plugins/tiles/atlas_merging_dialog.cpp @@ -62,7 +62,7 @@ void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atla int line_height = 0; for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) { Ref<TileSetAtlasSource> atlas_source = p_atlas_sources[source_index]; - merged_mapping.push_back(Map<Vector2i, Vector2i>()); + merged_mapping.push_back(HashMap<Vector2i, Vector2i>()); // Layout the tiles. Vector2i atlas_size; diff --git a/editor/plugins/tiles/atlas_merging_dialog.h b/editor/plugins/tiles/atlas_merging_dialog.h index 9502d93f6b..c54e259594 100644 --- a/editor/plugins/tiles/atlas_merging_dialog.h +++ b/editor/plugins/tiles/atlas_merging_dialog.h @@ -46,7 +46,7 @@ private: int commited_actions_count = 0; bool delete_original_atlases = true; Ref<TileSetAtlasSource> merged; - LocalVector<Map<Vector2i, Vector2i>> merged_mapping; + LocalVector<HashMap<Vector2i, Vector2i>> merged_mapping; Ref<TileSet> tile_set; UndoRedo *undo_redo = nullptr; diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp index 4de2f42fe0..3073c8a7f2 100644 --- a/editor/plugins/tiles/tile_atlas_view.cpp +++ b/editor/plugins/tiles/tile_atlas_view.cpp @@ -480,7 +480,7 @@ void TileAtlasView::_update_alternative_tiles_rect_cache() { // Update the rect. if (!alternative_tiles_rect_cache.has(tile_id)) { - alternative_tiles_rect_cache[tile_id] = Map<int, Rect2i>(); + alternative_tiles_rect_cache[tile_id] = HashMap<int, Rect2i>(); } alternative_tiles_rect_cache[tile_id][alternative_id] = current; @@ -494,7 +494,7 @@ void TileAtlasView::_update_alternative_tiles_rect_cache() { } Vector3i TileAtlasView::get_alternative_tile_at_pos(const Vector2 p_pos) const { - for (const KeyValue<Vector2, Map<int, Rect2i>> &E_coords : alternative_tiles_rect_cache) { + for (const KeyValue<Vector2, HashMap<int, Rect2i>> &E_coords : alternative_tiles_rect_cache) { for (const KeyValue<int, Rect2i> &E_alternative : E_coords.value) { if (E_alternative.value.has_point(p_pos)) { return Vector3i(E_coords.key.x, E_coords.key.y, E_alternative.key); diff --git a/editor/plugins/tiles/tile_atlas_view.h b/editor/plugins/tiles/tile_atlas_view.h index 6e74858b08..ff46b7871f 100644 --- a/editor/plugins/tiles/tile_atlas_view.h +++ b/editor/plugins/tiles/tile_atlas_view.h @@ -69,7 +69,7 @@ private: void _pan_callback(Vector2 p_scroll_vec); void _zoom_callback(Vector2 p_scroll_vec, Vector2 p_origin, bool p_alt); - Map<Vector2, Map<int, Rect2i>> alternative_tiles_rect_cache; + HashMap<Vector2, HashMap<int, Rect2i>> alternative_tiles_rect_cache; void _update_alternative_tiles_rect_cache(); MarginContainer *margin_container = nullptr; diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index 70bcd7e39a..eda05b1005 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -862,7 +862,7 @@ Variant TileDataDefaultEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_s return tile_data->get(property); } -void TileDataDefaultEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) { +void TileDataDefaultEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, HashMap<TileMapCell, Variant, TileMapCell> p_previous_values, Variant p_new_value) { for (const KeyValue<TileMapCell, Variant> &E : p_previous_values) { Vector2i coords = E.key.get_atlas_coords(); undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/%s", coords.x, coords.y, E.key.alternative_tile, property), E.value); @@ -882,7 +882,7 @@ void TileDataDefaultEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas_ rect.set_end(p_tile_atlas_view->get_atlas_tile_coords_at_pos(p_transform.affine_inverse().xform(p_canvas_item->get_local_mouse_position()))); rect = rect.abs(); - Set<TileMapCell> edited; + RBSet<TileMapCell> edited; for (int x = rect.get_position().x; x <= rect.get_end().x; x++) { for (int y = rect.get_position().y; y <= rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); @@ -897,7 +897,7 @@ void TileDataDefaultEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas_ } } - for (Set<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { + for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { Vector2i coords = E->get().get_atlas_coords(); p_canvas_item->draw_rect(p_tile_set_atlas_source->get_tile_texture_region(coords), selection_color, false); } @@ -1299,7 +1299,7 @@ Variant TileDataOcclusionShapeEditor::_get_value(TileSetAtlasSource *p_tile_set_ return tile_data->get_occluder(occlusion_layer); } -void TileDataOcclusionShapeEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) { +void TileDataOcclusionShapeEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, HashMap<TileMapCell, Variant, TileMapCell> p_previous_values, Variant p_new_value) { for (const KeyValue<TileMapCell, Variant> &E : p_previous_values) { Vector2i coords = E.key.get_atlas_coords(); undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/occlusion_layer_%d/polygon", coords.x, coords.y, E.key.alternative_tile, occlusion_layer), E.value); @@ -1479,7 +1479,7 @@ Variant TileDataCollisionEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas return dict; } -void TileDataCollisionEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) { +void TileDataCollisionEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, HashMap<TileMapCell, Variant, TileMapCell> p_previous_values, Variant p_new_value) { Array new_array = p_new_value; for (KeyValue<TileMapCell, Variant> &E : p_previous_values) { Array old_array = E.value; @@ -1740,7 +1740,7 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas rect.set_end(p_tile_atlas_view->get_atlas_tile_coords_at_pos(p_transform.affine_inverse().xform(p_canvas_item->get_local_mouse_position()))); rect = rect.abs(); - Set<TileMapCell> edited; + RBSet<TileMapCell> edited; for (int x = rect.get_position().x; x <= rect.get_end().x; x++) { for (int y = rect.get_position().y; y <= rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); @@ -1755,7 +1755,7 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas } } - for (Set<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { + for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { Vector2i coords = E->get().get_atlas_coords(); p_canvas_item->draw_rect(p_tile_set_atlas_source->get_tile_texture_region(coords), selection_color, false); } @@ -1770,7 +1770,7 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas rect.set_end(p_tile_atlas_view->get_atlas_tile_coords_at_pos(p_transform.affine_inverse().xform(p_canvas_item->get_local_mouse_position()))); rect = rect.abs(); - Set<TileMapCell> edited; + RBSet<TileMapCell> edited; for (int x = rect.get_position().x; x <= rect.get_end().x; x++) { for (int y = rect.get_position().y; y <= rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); @@ -1800,7 +1800,7 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas p_canvas_item->draw_set_transform_matrix(p_transform); - for (Set<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { + for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { Vector2i coords = E->get().get_atlas_coords(); Rect2i texture_region = p_tile_set_atlas_source->get_tile_texture_region(coords); @@ -2118,7 +2118,7 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_t rect.set_end(p_tile_atlas_view->get_atlas_tile_coords_at_pos(mb->get_position())); rect = rect.abs(); - Set<TileMapCell> edited; + RBSet<TileMapCell> edited; for (int x = rect.get_position().x; x <= rect.get_end().x; x++) { for (int y = rect.get_position().y; y <= rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); @@ -2133,7 +2133,7 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_t } } undo_redo->create_action(TTR("Painting Terrain Set")); - for (Set<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { + for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { Vector2i coords = E->get().get_atlas_coords(); TileData *tile_data = p_tile_set_atlas_source->get_tile_data(coords, 0); undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->get().alternative_tile), tile_data->get_terrain_set()); @@ -2195,7 +2195,7 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_t rect.set_end(p_tile_atlas_view->get_atlas_tile_coords_at_pos(mb->get_position())); rect = rect.abs(); - Set<TileMapCell> edited; + RBSet<TileMapCell> edited; for (int x = rect.get_position().x; x <= rect.get_end().x; x++) { for (int y = rect.get_position().y; y <= rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); @@ -2220,7 +2220,7 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_t mouse_pos_rect_polygon.push_back(Vector2(drag_start_pos.x, mb->get_position().y)); undo_redo->create_action(TTR("Painting Terrain")); - for (Set<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { + for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { Vector2i coords = E->get().get_atlas_coords(); TileData *tile_data = p_tile_set_atlas_source->get_tile_data(coords, 0); @@ -2571,7 +2571,7 @@ Variant TileDataNavigationEditor::_get_value(TileSetAtlasSource *p_tile_set_atla return tile_data->get_navigation_polygon(navigation_layer); } -void TileDataNavigationEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) { +void TileDataNavigationEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, HashMap<TileMapCell, Variant, TileMapCell> p_previous_values, Variant p_new_value) { for (const KeyValue<TileMapCell, Variant> &E : p_previous_values) { Vector2i coords = E.key.get_atlas_coords(); undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/navigation_layer_%d/polygon", coords.x, coords.y, E.key.alternative_tile, navigation_layer), E.value); diff --git a/editor/plugins/tiles/tile_data_editors.h b/editor/plugins/tiles/tile_data_editors.h index 2c849637f0..f9b8948d0a 100644 --- a/editor/plugins/tiles/tile_data_editors.h +++ b/editor/plugins/tiles/tile_data_editors.h @@ -71,7 +71,7 @@ public: class DummyObject : public Object { GDCLASS(DummyObject, Object) private: - Map<String, Variant> properties; + HashMap<String, Variant> properties; protected: bool _set(const StringName &p_name, const Variant &p_value); @@ -206,7 +206,7 @@ private: DragType drag_type = DRAG_TYPE_NONE; Vector2 drag_start_pos; Vector2 drag_last_pos; - Map<TileMapCell, Variant> drag_modified; + HashMap<TileMapCell, Variant, TileMapCell> drag_modified; Variant drag_painted_value; void _property_value_changed(StringName p_property, Variant p_value, StringName p_field); @@ -224,7 +224,7 @@ protected: virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile); virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value); virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile); - virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value); + virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, HashMap<TileMapCell, Variant, TileMapCell> p_previous_values, Variant p_new_value); public: virtual Control *get_toolbar() override { return toolbar; }; @@ -276,7 +276,7 @@ private: virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override; virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) override; + virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, HashMap<TileMapCell, Variant, TileMapCell> p_previous_values, Variant p_new_value) override; protected: UndoRedo *undo_redo = nullptr; @@ -301,7 +301,7 @@ class TileDataCollisionEditor : public TileDataDefaultEditor { // UI GenericTilePolygonEditor *polygon_editor = nullptr; DummyObject *dummy_object = memnew(DummyObject); - Map<StringName, EditorProperty *> property_editors; + HashMap<StringName, EditorProperty *> property_editors; void _property_value_changed(StringName p_property, Variant p_value, StringName p_field); void _property_selected(StringName p_path, int p_focusable); @@ -311,7 +311,7 @@ class TileDataCollisionEditor : public TileDataDefaultEditor { virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override; virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) override; + virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, HashMap<TileMapCell, Variant, TileMapCell> p_previous_values, Variant p_new_value) override; protected: UndoRedo *undo_redo = nullptr; @@ -348,7 +348,7 @@ private: DragType drag_type = DRAG_TYPE_NONE; Vector2 drag_start_pos; Vector2 drag_last_pos; - Map<TileMapCell, Variant> drag_modified; + HashMap<TileMapCell, Variant, TileMapCell> drag_modified; Variant drag_painted_value; // UI @@ -396,7 +396,7 @@ private: virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override; virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) override; + virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, HashMap<TileMapCell, Variant, TileMapCell> p_previous_values, Variant p_new_value) override; protected: UndoRedo *undo_redo = nullptr; diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index ac90333e1d..12e1f10750 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -501,7 +501,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p if (!tile_map_selection.is_empty()) { tile_map_clipboard.instantiate(); TypedArray<Vector2i> coords_array; - for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { coords_array.push_back(E->get()); } tile_map_clipboard = tile_map->get_pattern(tile_map_layer, coords_array); @@ -511,7 +511,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p // Delete selected tiles. if (!tile_map_selection.is_empty()) { undo_redo->create_action(TTR("Delete tiles")); - for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E->get(), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E->get(), tile_map->get_cell_source_id(tile_map_layer, E->get()), tile_map->get_cell_atlas_coords(tile_map_layer, E->get()), tile_map->get_cell_alternative_tile(tile_map_layer, E->get())); } @@ -542,7 +542,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p // Delete selected tiles. if (!tile_map_selection.is_empty()) { undo_redo->create_action(TTR("Delete tiles")); - for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E->get(), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E->get(), tile_map->get_cell_source_id(tile_map_layer, E->get()), tile_map->get_cell_atlas_coords(tile_map_layer, E->get()), tile_map->get_cell_alternative_tile(tile_map_layer, E->get())); } @@ -562,7 +562,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p switch (drag_type) { case DRAG_TYPE_PAINT: { - Map<Vector2i, TileMapCell> to_draw = _draw_line(drag_start_mouse_pos, drag_last_mouse_pos, mpos, drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_line(drag_start_mouse_pos, drag_last_mouse_pos, mpos, drag_erasing); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { continue; @@ -579,7 +579,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos)); for (int i = 0; i < line.size(); i++) { if (!drag_modified.has(line[i])) { - Map<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { continue; @@ -628,7 +628,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p _update_selection_pattern_from_tilemap_selection(); // Make sure the pattern is up to date before moving. drag_type = DRAG_TYPE_MOVE; drag_modified.clear(); - for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { Vector2i coords = E->get(); drag_modified.insert(coords, tile_map->get_cell(tile_map_layer, coords)); tile_map->set_cell(tile_map_layer, coords, TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); @@ -648,7 +648,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p drag_type = DRAG_TYPE_PAINT; drag_start_mouse_pos = mpos; drag_modified.clear(); - Map<Vector2i, TileMapCell> to_draw = _draw_line(drag_start_mouse_pos, mpos, mpos, drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_line(drag_start_mouse_pos, mpos, mpos, drag_erasing); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { continue; @@ -675,7 +675,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos)); for (int i = 0; i < line.size(); i++) { if (!drag_modified.has(line[i])) { - Map<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { continue; @@ -746,7 +746,7 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over // Handle the preview of the tiles to be placed. if ((tiles_bottom_panel->is_visible_in_tree() || patterns_bottom_panel->is_visible_in_tree()) && has_mouse) { // Only if the tilemap editor is opened and the viewport is hovered. - Map<Vector2i, TileMapCell> preview; + HashMap<Vector2i, TileMapCell> preview; Rect2i drawn_grid_rect; if (drag_type == DRAG_TYPE_PICK) { @@ -768,7 +768,7 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over // Draw the area being selected. Rect2i rect = Rect2i(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(drag_last_mouse_pos) - tile_map->world_to_map(drag_start_mouse_pos)).abs(); rect.size += Vector2i(1, 1); - Set<Vector2i> to_draw; + RBSet<Vector2i> to_draw; for (int x = rect.position.x; x < rect.get_end().x; x++) { for (int y = rect.position.y; y < rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); @@ -785,7 +785,7 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over if (!tile_map_selection.is_empty()) { top_left = tile_map_selection.front()->get(); } - for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { top_left = top_left.min(E->get()); } Vector2i offset = drag_start_mouse_pos - tile_map->map_to_world(top_left); @@ -832,7 +832,7 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over // Expand the grid if needed if (expand_grid && !preview.is_empty()) { - drawn_grid_rect = Rect2i(preview.front()->key(), Vector2i(1, 1)); + drawn_grid_rect = Rect2i(preview.begin()->key, Vector2i(1, 1)); for (const KeyValue<Vector2i, TileMapCell> &E : preview) { drawn_grid_rect.expand_to(E.key); } @@ -986,15 +986,15 @@ TileMapCell TileMapEditorTilesPlugin::_pick_random_tile(Ref<TileMapPattern> p_pa return TileMapCell(); } -Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_line(Vector2 p_start_drag_mouse_pos, Vector2 p_from_mouse_pos, Vector2 p_to_mouse_pos, bool p_erase) { +HashMap<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_line(Vector2 p_start_drag_mouse_pos, Vector2 p_from_mouse_pos, Vector2 p_to_mouse_pos, bool p_erase) { TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } Ref<TileSet> tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } // Get or create the pattern. @@ -1003,7 +1003,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_line(Vector2 p_start_ erase_pattern->set_cell(Vector2i(0, 0), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); Ref<TileMapPattern> pattern = p_erase ? erase_pattern : selection_pattern; - Map<Vector2i, TileMapCell> output; + HashMap<Vector2i, TileMapCell> output; if (!pattern->is_empty()) { // Paint the tiles on the tile map. if (!p_erase && random_tile_toggle->is_pressed()) { @@ -1035,15 +1035,15 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_line(Vector2 p_start_ return output; } -Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) { +HashMap<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) { TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } Ref<TileSet> tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } // Create the rect to draw. @@ -1056,7 +1056,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_rect(Vector2i p_start erase_pattern->set_cell(Vector2i(0, 0), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); Ref<TileMapPattern> pattern = p_erase ? erase_pattern : selection_pattern; - Map<Vector2i, TileMapCell> err_output; + HashMap<Vector2i, TileMapCell> err_output; ERR_FAIL_COND_V(pattern->is_empty(), err_output); // Compute the offset to align things to the bottom or right. @@ -1064,7 +1064,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_rect(Vector2i p_start bool valigned_bottom = p_end_cell.y < p_start_cell.y; Vector2i offset = Vector2i(aligned_right ? -(pattern->get_size().x - (rect.get_size().x % pattern->get_size().x)) : 0, valigned_bottom ? -(pattern->get_size().y - (rect.get_size().y % pattern->get_size().y)) : 0); - Map<Vector2i, TileMapCell> output; + HashMap<Vector2i, TileMapCell> output; if (!pattern->is_empty()) { if (!p_erase && random_tile_toggle->is_pressed()) { // Paint a random tile. @@ -1094,21 +1094,21 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_rect(Vector2i p_start return output; } -Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase) { +HashMap<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase) { TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } if (tile_map_layer < 0) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } - Map<Vector2i, TileMapCell> output; + HashMap<Vector2i, TileMapCell> output; ERR_FAIL_INDEX_V(tile_map_layer, tile_map->get_layers_count(), output); Ref<TileSet> tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } // Get or create the pattern. @@ -1128,7 +1128,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i if (p_contiguous) { // Replace continuous tiles like the source. - Set<Vector2i> already_checked; + RBSet<Vector2i> already_checked; List<Vector2i> to_check; to_check.push_back(p_coords); while (!to_check.is_empty()) { @@ -1278,7 +1278,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { if (!tile_map_selection.is_empty()) { top_left = tile_map_selection.front()->get(); } - for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { top_left = top_left.min(E->get()); } @@ -1290,7 +1290,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { // Build the list of cells to undo. Vector2i coords; - Map<Vector2i, TileMapCell> cells_undo; + HashMap<Vector2i, TileMapCell> cells_undo; for (int i = 0; i < selection_used_cells.size(); i++) { coords = tile_map->map_pattern(top_left, selection_used_cells[i], selection_pattern); cells_undo[coords] = TileMapCell(drag_modified[coords].source_id, drag_modified[coords].get_atlas_coords(), drag_modified[coords].alternative_tile); @@ -1299,7 +1299,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { } // Build the list of cells to do. - Map<Vector2i, TileMapCell> cells_do; + HashMap<Vector2i, TileMapCell> cells_do; for (int i = 0; i < selection_used_cells.size(); i++) { coords = tile_map->map_pattern(top_left, selection_used_cells[i], selection_pattern); cells_do[coords] = TileMapCell(); @@ -1311,11 +1311,11 @@ void TileMapEditorTilesPlugin::_stop_dragging() { // Move the tiles. undo_redo->create_action(TTR("Move tiles")); - for (Map<Vector2i, TileMapCell>::Element *E = cells_do.front(); E; E = E->next()) { - undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + for (const KeyValue<Vector2i, TileMapCell> &E : cells_do) { + undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } - for (Map<Vector2i, TileMapCell>::Element *E = cells_undo.front(); E; E = E->next()) { - undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + for (const KeyValue<Vector2i, TileMapCell> &E : cells_undo) { + undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } // Update the selection. @@ -1378,7 +1378,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { undo_redo->commit_action(false); } break; case DRAG_TYPE_LINE: { - Map<Vector2i, TileMapCell> to_draw = _draw_line(drag_start_mouse_pos, drag_start_mouse_pos, mpos, drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_line(drag_start_mouse_pos, drag_start_mouse_pos, mpos, drag_erasing); undo_redo->create_action(TTR("Paint tiles")); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { @@ -1390,7 +1390,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { undo_redo->commit_action(); } break; case DRAG_TYPE_RECT: { - Map<Vector2i, TileMapCell> to_draw = _draw_rect(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_rect(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); undo_redo->create_action(TTR("Paint tiles")); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { @@ -1476,7 +1476,7 @@ void TileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { } // Selection if needed. - for (Set<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) { + for (RBSet<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) { const TileMapCell *selected = &(E->get()); if (!tile_set->has_source(selected->source_id) || !tile_set->get_source(selected->source_id)->has_tile(selected->get_atlas_coords()) || @@ -1500,7 +1500,7 @@ void TileMapEditorTilesPlugin::_fix_invalid_tiles_in_tile_map_selection() { return; } - Set<Vector2i> to_remove; + RBSet<Vector2i> to_remove; for (Vector2i selected : tile_map_selection) { TileMapCell cell = tile_map->get_cell(tile_map_layer, selected); if (cell.source_id == TileSet::INVALID_SOURCE && cell.get_atlas_coords() == TileSetSource::INVALID_ATLAS_COORDS && cell.alternative_tile == TileSetAtlasSource::INVALID_TILE_ALTERNATIVE) { @@ -1534,7 +1534,7 @@ void TileMapEditorTilesPlugin::_update_selection_pattern_from_tilemap_selection( selection_pattern.instantiate(); TypedArray<Vector2i> coords_array; - for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { coords_array.push_back(E->get()); } selection_pattern = tile_map->get_pattern(tile_map_layer, coords_array); @@ -1558,8 +1558,8 @@ void TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_sele selection_pattern.instantiate(); // Group per source. - Map<int, List<const TileMapCell *>> per_source; - for (Set<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) { + HashMap<int, List<const TileMapCell *>> per_source; + for (RBSet<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) { per_source[E->get().source_id].push_back(&(E->get())); } @@ -1568,7 +1568,7 @@ void TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_sele // Per source. List<const TileMapCell *> unorganized; Rect2i encompassing_rect_coords; - Map<Vector2i, const TileMapCell *> organized_pattern; + HashMap<Vector2i, const TileMapCell *> organized_pattern; TileSetSource *source = *tile_set->get_source(E_source.key); TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source); @@ -1583,12 +1583,12 @@ void TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_sele } // Compute the encompassing rect for the organized pattern. - Map<Vector2i, const TileMapCell *>::Element *E_cell = organized_pattern.front(); + HashMap<Vector2i, const TileMapCell *>::Iterator E_cell = organized_pattern.begin(); if (E_cell) { - encompassing_rect_coords = Rect2i(E_cell->key(), Vector2i(1, 1)); - for (; E_cell; E_cell = E_cell->next()) { - encompassing_rect_coords.expand_to(E_cell->key() + Vector2i(1, 1)); - encompassing_rect_coords.expand_to(E_cell->key()); + encompassing_rect_coords = Rect2i(E_cell->key, Vector2i(1, 1)); + for (; E_cell; ++E_cell) { + encompassing_rect_coords.expand_to(E_cell->key + Vector2i(1, 1)); + encompassing_rect_coords.expand_to(E_cell->key); } } } else { @@ -1680,7 +1680,7 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() { // Draw the selection. Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color"); Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0); - for (Set<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) { + for (RBSet<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) { if (E->get().source_id == source_id && E->get().alternative_tile == 0) { for (int frame = 0; frame < atlas->get_tile_animation_frames_count(E->get().get_atlas_coords()); frame++) { Color color = selection_color; @@ -1711,7 +1711,7 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() { Rect2i region = Rect2i(start_tile, end_tile - start_tile).abs(); region.size += Vector2i(1, 1); - Set<Vector2i> to_draw; + RBSet<Vector2i> to_draw; for (int x = region.position.x; x < region.get_end().x; x++) { for (int y = region.position.y; y < region.get_end().y; y++) { Vector2i tile = atlas->get_tile_at_coords(Vector2i(x, y)); @@ -1721,7 +1721,7 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() { } } Color selection_rect_color = selection_color.lightened(0.2); - for (Set<Vector2i>::Element *E = to_draw.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = to_draw.front(); E; E = E->next()) { tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E->get()), selection_rect_color, false); } } @@ -1868,7 +1868,7 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_draw() { } // Draw the selection. - for (Set<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) { + for (RBSet<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) { if (E->get().source_id == source_id && E->get().get_atlas_coords() != TileSetSource::INVALID_ATLAS_COORDS && E->get().alternative_tile > 0) { Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E->get().get_atlas_coords(), E->get().alternative_tile); if (rect != Rect2i()) { @@ -1972,7 +1972,7 @@ void TileMapEditorTilesPlugin::_set_tile_map_selection(const TypedArray<Vector2i TypedArray<Vector2i> TileMapEditorTilesPlugin::_get_tile_map_selection() const { TypedArray<Vector2i> output; - for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { output.push_back(E->get()); } return output; @@ -2321,33 +2321,33 @@ Vector<TileMapEditorPlugin::TabData> TileMapEditorTerrainsPlugin::get_tabs() con return tabs; } -Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const Map<Vector2i, TileSet::TerrainsPattern> &p_to_paint, int p_terrain_set) const { +HashMap<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const HashMap<Vector2i, TileSet::TerrainsPattern> &p_to_paint, int p_terrain_set) const { TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } Ref<TileSet> tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } - Map<Vector2i, TileMapCell> output; + HashMap<Vector2i, TileMapCell> output; // Add the constraints from the added tiles. - Set<TileMap::TerrainConstraint> added_tiles_constraints_set; + RBSet<TileMap::TerrainConstraint> added_tiles_constraints_set; for (const KeyValue<Vector2i, TileSet::TerrainsPattern> &E_to_paint : p_to_paint) { Vector2i coords = E_to_paint.key; TileSet::TerrainsPattern terrains_pattern = E_to_paint.value; - Set<TileMap::TerrainConstraint> cell_constraints = tile_map->get_terrain_constraints_from_added_tile(coords, p_terrain_set, terrains_pattern); - for (Set<TileMap::TerrainConstraint>::Element *E = cell_constraints.front(); E; E = E->next()) { + RBSet<TileMap::TerrainConstraint> cell_constraints = tile_map->get_terrain_constraints_from_added_tile(coords, p_terrain_set, terrains_pattern); + for (RBSet<TileMap::TerrainConstraint>::Element *E = cell_constraints.front(); E; E = E->next()) { added_tiles_constraints_set.insert(E->get()); } } // Build the list of potential tiles to replace. - Set<Vector2i> potential_to_replace; + RBSet<Vector2i> potential_to_replace; for (const KeyValue<Vector2i, TileSet::TerrainsPattern> &E_to_paint : p_to_paint) { Vector2i coords = E_to_paint.key; for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) { @@ -2361,7 +2361,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const Map } // Set of tiles to replace - Set<Vector2i> to_replace; + RBSet<Vector2i> to_replace; // Add the central tiles to the one to replace. for (const KeyValue<Vector2i, TileSet::TerrainsPattern> &E_to_paint : p_to_paint) { @@ -2369,16 +2369,16 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const Map } // Add the constraints from the surroundings of the modified areas. - Set<TileMap::TerrainConstraint> removed_cells_constraints_set; + RBSet<TileMap::TerrainConstraint> removed_cells_constraints_set; bool to_replace_modified = true; while (to_replace_modified) { // Get the constraints from the removed cells. removed_cells_constraints_set = tile_map->get_terrain_constraints_from_removed_cells_list(tile_map_layer, to_replace, p_terrain_set, false); // Filter the sources to make sure they are in the potential_to_replace. - Map<TileMap::TerrainConstraint, Set<Vector2i>> per_constraint_tiles; - for (Set<TileMap::TerrainConstraint>::Element *E = removed_cells_constraints_set.front(); E; E = E->next()) { - Map<Vector2i, TileSet::CellNeighbor> sources_of_constraint = E->get().get_overlapping_coords_and_peering_bits(); + RBMap<TileMap::TerrainConstraint, RBSet<Vector2i>> per_constraint_tiles; + for (RBSet<TileMap::TerrainConstraint>::Element *E = removed_cells_constraints_set.front(); E; E = E->next()) { + HashMap<Vector2i, TileSet::CellNeighbor> sources_of_constraint = E->get().get_overlapping_coords_and_peering_bits(); for (const KeyValue<Vector2i, TileSet::CellNeighbor> &E_source_tile_of_constraint : sources_of_constraint) { if (potential_to_replace.has(E_source_tile_of_constraint.key)) { per_constraint_tiles[E->get()].insert(E_source_tile_of_constraint.key); @@ -2387,7 +2387,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const Map } to_replace_modified = false; - for (Set<TileMap::TerrainConstraint>::Element *E = added_tiles_constraints_set.front(); E; E = E->next()) { + for (RBSet<TileMap::TerrainConstraint>::Element *E = added_tiles_constraints_set.front(); E; E = E->next()) { TileMap::TerrainConstraint c = E->get(); // Check if we have a conflict in constraints. if (removed_cells_constraints_set.has(c) && removed_cells_constraints_set.find(c)->get().get_terrain() != c.get_terrain()) { @@ -2398,7 +2398,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const Map potential_to_replace.erase(to_add_to_remove); to_replace.insert(to_add_to_remove); to_replace_modified = true; - for (KeyValue<TileMap::TerrainConstraint, Set<Vector2i>> &E_source_tiles_of_constraint : per_constraint_tiles) { + for (KeyValue<TileMap::TerrainConstraint, RBSet<Vector2i>> &E_source_tiles_of_constraint : per_constraint_tiles) { E_source_tiles_of_constraint.value.erase(to_add_to_remove); } break; @@ -2408,8 +2408,8 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const Map } // Combine all constraints together. - Set<TileMap::TerrainConstraint> constraints = removed_cells_constraints_set; - for (Set<TileMap::TerrainConstraint>::Element *E = added_tiles_constraints_set.front(); E; E = E->next()) { + RBSet<TileMap::TerrainConstraint> constraints = removed_cells_constraints_set; + for (RBSet<TileMap::TerrainConstraint>::Element *E = added_tiles_constraints_set.front(); E; E = E->next()) { constraints.insert(E->get()); } @@ -2419,7 +2419,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const Map } // Run WFC to fill the holes with the constraints. - Map<Vector2i, TileSet::TerrainsPattern> wfc_output = tile_map->terrain_wave_function_collapse(to_replace, p_terrain_set, constraints); + HashMap<Vector2i, TileSet::TerrainsPattern> wfc_output = tile_map->terrain_wave_function_collapse(to_replace, p_terrain_set, constraints); // Actually paint the tiles. for (const KeyValue<Vector2i, TileSet::TerrainsPattern> &E_to_paint : p_to_paint) { @@ -2434,15 +2434,15 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const Map return output; } -Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_line(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) { +HashMap<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_line(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) { TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } Ref<TileSet> tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } TileSet::TerrainsPattern terrains_pattern; @@ -2453,22 +2453,22 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_line(Vector2i p_st } Vector<Vector2i> line = TileMapEditor::get_line(tile_map, p_start_cell, p_end_cell); - Map<Vector2i, TileSet::TerrainsPattern> to_draw; + HashMap<Vector2i, TileSet::TerrainsPattern> to_draw; for (int i = 0; i < line.size(); i++) { to_draw[line[i]] = terrains_pattern; } return _draw_terrains(to_draw, selected_terrain_set); } -Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) { +HashMap<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) { TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } Ref<TileSet> tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } TileSet::TerrainsPattern terrains_pattern; @@ -2483,7 +2483,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_rect(Vector2i p_st rect.set_end(p_end_cell); rect = rect.abs(); - Map<Vector2i, TileSet::TerrainsPattern> to_draw; + HashMap<Vector2i, TileSet::TerrainsPattern> to_draw; for (int x = rect.position.x; x <= rect.get_end().x; x++) { for (int y = rect.position.y; y <= rect.get_end().y; y++) { to_draw[Vector2i(x, y)] = terrains_pattern; @@ -2492,15 +2492,15 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_rect(Vector2i p_st return _draw_terrains(to_draw, selected_terrain_set); } -Set<Vector2i> TileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i p_coords, bool p_contiguous) { +RBSet<Vector2i> TileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i p_coords, bool p_contiguous) { TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Set<Vector2i>(); + return RBSet<Vector2i>(); } Ref<TileSet> tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Set<Vector2i>(); + return RBSet<Vector2i>(); } TileMapCell source_cell = tile_map->get_cell(tile_map_layer, p_coords); @@ -2514,7 +2514,7 @@ Set<Vector2i> TileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i p tile_data = atlas_source->get_tile_data(source_cell.get_atlas_coords(), source_cell.alternative_tile); } if (!tile_data) { - return Set<Vector2i>(); + return RBSet<Vector2i>(); } source_pattern = tile_data->get_terrains_pattern(); } @@ -2525,10 +2525,10 @@ Set<Vector2i> TileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i p boundaries = tile_map->get_used_rect(); } - Set<Vector2i> output; + RBSet<Vector2i> output; if (p_contiguous) { // Replace continuous tiles like the source. - Set<Vector2i> already_checked; + RBSet<Vector2i> already_checked; List<Vector2i> to_check; to_check.push_back(p_coords); while (!to_check.is_empty()) { @@ -2603,15 +2603,15 @@ Set<Vector2i> TileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i p return output; } -Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase) { +HashMap<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase) { TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } Ref<TileSet> tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Map<Vector2i, TileMapCell>(); + return HashMap<Vector2i, TileMapCell>(); } TileSet::TerrainsPattern terrains_pattern; @@ -2621,8 +2621,8 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_bucket_fill(Vector terrains_pattern = selected_terrains_pattern; } - Set<Vector2i> cells_to_draw = _get_cells_for_bucket_fill(p_coords, p_contiguous); - Map<Vector2i, TileSet::TerrainsPattern> to_draw; + RBSet<Vector2i> cells_to_draw = _get_cells_for_bucket_fill(p_coords, p_contiguous); + HashMap<Vector2i, TileSet::TerrainsPattern> to_draw; for (const Vector2i &coords : cells_to_draw) { to_draw[coords] = terrains_pattern; } @@ -2718,7 +2718,7 @@ void TileMapEditorTerrainsPlugin::_stop_dragging() { undo_redo->commit_action(false); } break; case DRAG_TYPE_LINE: { - Map<Vector2i, TileMapCell> to_draw = _draw_line(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_line(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); undo_redo->create_action(TTR("Paint terrain")); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { @@ -2730,7 +2730,7 @@ void TileMapEditorTerrainsPlugin::_stop_dragging() { undo_redo->commit_action(); } break; case DRAG_TYPE_RECT: { - Map<Vector2i, TileMapCell> to_draw = _draw_rect(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_rect(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); undo_redo->create_action(TTR("Paint terrain")); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { @@ -2829,7 +2829,7 @@ bool TileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref<InputEvent> switch (drag_type) { case DRAG_TYPE_PAINT: { if (selected_terrain_set >= 0) { - Map<Vector2i, TileMapCell> to_draw = _draw_line(tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_line(tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_modified.has(E.key)) { drag_modified[E.key] = tile_map->get_cell(tile_map_layer, E.key); @@ -2874,7 +2874,7 @@ bool TileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref<InputEvent> drag_modified.clear(); Vector2i cell = tile_map->world_to_map(mpos); - Map<Vector2i, TileMapCell> to_draw = _draw_line(cell, cell, drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_line(cell, cell, drag_erasing); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { drag_modified[E.key] = tile_map->get_cell(tile_map_layer, E.key); tile_map->set_cell(tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); @@ -2903,7 +2903,7 @@ bool TileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref<InputEvent> Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos)); for (int i = 0; i < line.size(); i++) { if (!drag_modified.has(line[i])) { - Map<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { continue; @@ -2959,7 +2959,7 @@ void TileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_o // Handle the preview of the tiles to be placed. if (main_vbox_container->is_visible_in_tree() && has_mouse) { // Only if the tilemap editor is opened and the viewport is hovered. - Set<Vector2i> preview; + RBSet<Vector2i> preview; Rect2i drawn_grid_rect; if (drag_type == DRAG_TYPE_PICK) { @@ -2996,7 +2996,7 @@ void TileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_o rect.set_end(tile_map->world_to_map(drag_last_mouse_pos)); rect = rect.abs(); - Map<Vector2i, TileSet::TerrainsPattern> to_draw; + HashMap<Vector2i, TileSet::TerrainsPattern> to_draw; for (int x = rect.position.x; x <= rect.get_end().x; x++) { for (int y = rect.position.y; y <= rect.get_end().y; y++) { preview.insert(Vector2i(x, y)); @@ -3192,9 +3192,9 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() { ERR_FAIL_INDEX(selected_terrain_id, tile_set->get_terrains_count(selected_terrain_set)); // Sort the items in a map by the number of corresponding terrains. - Map<int, Set<TileSet::TerrainsPattern>> sorted; + RBMap<int, RBSet<TileSet::TerrainsPattern>> sorted; - for (Set<TileSet::TerrainsPattern>::Element *E = per_terrain_terrains_patterns[selected_terrain_set][selected_terrain_id].front(); E; E = E->next()) { + for (RBSet<TileSet::TerrainsPattern>::Element *E = per_terrain_terrains_patterns[selected_terrain_set][selected_terrain_id].front(); E; E = E->next()) { // Count the number of matching sides/terrains. int count = 0; @@ -3207,8 +3207,8 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() { sorted[count].insert(E->get()); } - for (Map<int, Set<TileSet::TerrainsPattern>>::Element *E_set = sorted.back(); E_set; E_set = E_set->prev()) { - for (Set<TileSet::TerrainsPattern>::Element *E = E_set->get().front(); E; E = E->next()) { + for (RBMap<int, RBSet<TileSet::TerrainsPattern>>::Element *E_set = sorted.back(); E_set; E_set = E_set->prev()) { + for (RBSet<TileSet::TerrainsPattern>::Element *E = E_set->get().front(); E; E = E->next()) { TileSet::TerrainsPattern terrains_pattern = E->get(); // Get the icon. diff --git a/editor/plugins/tiles/tile_map_editor.h b/editor/plugins/tiles/tile_map_editor.h index f265052200..7158ebff59 100644 --- a/editor/plugins/tiles/tile_map_editor.h +++ b/editor/plugins/tiles/tile_map_editor.h @@ -120,22 +120,22 @@ private: bool drag_erasing = false; Vector2 drag_start_mouse_pos; Vector2 drag_last_mouse_pos; - Map<Vector2i, TileMapCell> drag_modified; + HashMap<Vector2i, TileMapCell> drag_modified; TileMapCell _pick_random_tile(Ref<TileMapPattern> p_pattern); - Map<Vector2i, TileMapCell> _draw_line(Vector2 p_start_drag_mouse_pos, Vector2 p_from_mouse_pos, Vector2 p_to_mouse_pos, bool p_erase); - Map<Vector2i, TileMapCell> _draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase); - Map<Vector2i, TileMapCell> _draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase); + HashMap<Vector2i, TileMapCell> _draw_line(Vector2 p_start_drag_mouse_pos, Vector2 p_from_mouse_pos, Vector2 p_to_mouse_pos, bool p_erase); + HashMap<Vector2i, TileMapCell> _draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase); + HashMap<Vector2i, TileMapCell> _draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase); void _stop_dragging(); ///// Selection system. ///// - Set<Vector2i> tile_map_selection; + RBSet<Vector2i> tile_map_selection; Ref<TileMapPattern> tile_map_clipboard; Ref<TileMapPattern> selection_pattern; void _set_tile_map_selection(const TypedArray<Vector2i> &p_selection); TypedArray<Vector2i> _get_tile_map_selection() const; - Set<TileMapCell> tile_set_selection; + RBSet<TileMapCell> tile_set_selection; void _update_selection_pattern_from_tilemap_selection(); void _update_selection_pattern_from_tileset_tiles_selection(); @@ -265,14 +265,14 @@ private: bool drag_erasing = false; Vector2 drag_start_mouse_pos; Vector2 drag_last_mouse_pos; - Map<Vector2i, TileMapCell> drag_modified; + HashMap<Vector2i, TileMapCell> drag_modified; // Painting - Map<Vector2i, TileMapCell> _draw_terrains(const Map<Vector2i, TileSet::TerrainsPattern> &p_to_paint, int p_terrain_set) const; - Map<Vector2i, TileMapCell> _draw_line(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase); - Map<Vector2i, TileMapCell> _draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase); - Set<Vector2i> _get_cells_for_bucket_fill(Vector2i p_coords, bool p_contiguous); - Map<Vector2i, TileMapCell> _draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase); + HashMap<Vector2i, TileMapCell> _draw_terrains(const HashMap<Vector2i, TileSet::TerrainsPattern> &p_to_paint, int p_terrain_set) const; + HashMap<Vector2i, TileMapCell> _draw_line(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase); + HashMap<Vector2i, TileMapCell> _draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase); + RBSet<Vector2i> _get_cells_for_bucket_fill(Vector2i p_coords, bool p_contiguous); + HashMap<Vector2i, TileMapCell> _draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase); void _stop_dragging(); int selected_terrain_set = -1; @@ -284,7 +284,7 @@ private: ItemList *terrains_tile_list = nullptr; // Cache. - LocalVector<LocalVector<Set<TileSet::TerrainsPattern>>> per_terrain_terrains_patterns; + LocalVector<LocalVector<RBSet<TileSet::TerrainsPattern>>> per_terrain_terrains_patterns; // Update functions. void _update_terrains_cache(); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 44b18f48fc..dc3fa87565 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -270,7 +270,7 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_na // Other properties. bool any_valid = false; - for (Set<TileSelection>::Element *E = tiles.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = tiles.front(); E; E = E->next()) { const Vector2i &coords = E->get().tile; const int &alternative = E->get().alternative; @@ -354,7 +354,7 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_get(const StringName &p_na } } - for (Set<TileSelection>::Element *E = tiles.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = tiles.front(); E; E = E->next()) { // Return the first tile with a property matching the name. // Note: It's a little bit annoying, but the behavior is the same the one in MultiNodeEdit. const Vector2i &coords = E->get().tile; @@ -426,10 +426,10 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro int uses = 0; PropertyInfo property_info; }; - Map<PropertyId, PLData> usage; + RBMap<PropertyId, PLData> usage; List<PLData *> data_list; - for (Set<TileSelection>::Element *E = tiles.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = tiles.front(); E; E = E->next()) { const Vector2i &coords = E->get().tile; const int &alternative = E->get().alternative; @@ -439,7 +439,7 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro List<PropertyInfo> list; tile_data->get_property_list(&list); - Map<String, int> counts; // Counts the number of time a property appears (useful for groups that may appear more than once) + HashMap<String, int> counts; // Counts the number of time a property appears (useful for groups that may appear more than once) for (List<PropertyInfo>::Element *E_property = list.front(); E_property; E_property = E_property->next()) { const String &property_string = E_property->get().name; if (!tile_data->is_allowing_transform() && (property_string == "flip_h" || property_string == "flip_v" || property_string == "transpose")) { @@ -473,16 +473,16 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro } } -void TileSetAtlasSourceEditor::AtlasTileProxyObject::edit(TileSetAtlasSource *p_tile_set_atlas_source, Set<TileSelection> p_tiles) { +void TileSetAtlasSourceEditor::AtlasTileProxyObject::edit(TileSetAtlasSource *p_tile_set_atlas_source, RBSet<TileSelection> p_tiles) { ERR_FAIL_COND(!p_tile_set_atlas_source); ERR_FAIL_COND(p_tiles.is_empty()); - for (Set<TileSelection>::Element *E = p_tiles.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = p_tiles.front(); E; E = E->next()) { ERR_FAIL_COND(E->get().tile == TileSetSource::INVALID_ATLAS_COORDS); ERR_FAIL_COND(E->get().alternative < 0); } // Disconnect to changes. - for (Set<TileSelection>::Element *E = tiles.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = tiles.front(); E; E = E->next()) { const Vector2i &coords = E->get().tile; const int &alternative = E->get().alternative; @@ -495,10 +495,10 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::edit(TileSetAtlasSource *p_ } tile_set_atlas_source = p_tile_set_atlas_source; - tiles = Set<TileSelection>(p_tiles); + tiles = RBSet<TileSelection>(p_tiles); // Connect to changes. - for (Set<TileSelection>::Element *E = p_tiles.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = p_tiles.front(); E; E = E->next()) { const Vector2i &coords = E->get().tile; const int &alternative = E->get().alternative; @@ -541,7 +541,7 @@ void TileSetAtlasSourceEditor::_update_source_inspector() { void TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() { // Fix selected. - for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { TileSelection selected = E->get(); if (!tile_set_atlas_source->has_tile(selected.tile) || !tile_set_atlas_source->has_alternative_tile(selected.tile, selected.alternative)) { selection.erase(E); @@ -1313,7 +1313,7 @@ void TileSetAtlasSourceEditor::_end_dragging() { switch (drag_type) { case DRAG_TYPE_CREATE_TILES: undo_redo->create_action(TTR("Create tiles")); - for (Set<Vector2i>::Element *E = drag_modified_tiles.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = drag_modified_tiles.front(); E; E = E->next()) { undo_redo->add_do_method(tile_set_atlas_source, "create_tile", E->get()); undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", E->get()); } @@ -1328,9 +1328,9 @@ void TileSetAtlasSourceEditor::_end_dragging() { case DRAG_TYPE_REMOVE_TILES: { List<PropertyInfo> list; tile_set_atlas_source->get_property_list(&list); - Map<Vector2i, List<const PropertyInfo *>> per_tile = _group_properties_per_tiles(list, tile_set_atlas_source); + HashMap<Vector2i, List<const PropertyInfo *>> per_tile = _group_properties_per_tiles(list, tile_set_atlas_source); undo_redo->create_action(TTR("Remove tiles")); - for (Set<Vector2i>::Element *E = drag_modified_tiles.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = drag_modified_tiles.front(); E; E = E->next()) { Vector2i coords = E->get(); undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", coords); undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", coords); @@ -1370,9 +1370,9 @@ void TileSetAtlasSourceEditor::_end_dragging() { area.set_end((area.get_end() + Vector2i(1, 1)).min(tile_set_atlas_source->get_atlas_grid_size())); List<PropertyInfo> list; tile_set_atlas_source->get_property_list(&list); - Map<Vector2i, List<const PropertyInfo *>> per_tile = _group_properties_per_tiles(list, tile_set_atlas_source); + HashMap<Vector2i, List<const PropertyInfo *>> per_tile = _group_properties_per_tiles(list, tile_set_atlas_source); - Set<Vector2i> to_delete; + RBSet<Vector2i> to_delete; for (int x = area.get_position().x; x < area.get_end().x; x++) { for (int y = area.get_position().y; y < area.get_end().y; y++) { Vector2i coords = tile_set_atlas_source->get_tile_at_coords(Vector2i(x, y)); @@ -1384,7 +1384,7 @@ void TileSetAtlasSourceEditor::_end_dragging() { undo_redo->create_action(TTR("Remove tiles")); undo_redo->add_do_method(this, "_set_selection_from_array", Array()); - for (Set<Vector2i>::Element *E = to_delete.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = to_delete.front(); E; E = E->next()) { Vector2i coords = E->get(); undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", coords); undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", coords); @@ -1523,9 +1523,9 @@ void TileSetAtlasSourceEditor::_end_dragging() { tile_atlas_control->set_default_cursor_shape(CURSOR_ARROW); } -Map<Vector2i, List<const PropertyInfo *>> TileSetAtlasSourceEditor::_group_properties_per_tiles(const List<PropertyInfo> &r_list, const TileSetAtlasSource *p_atlas) { +HashMap<Vector2i, List<const PropertyInfo *>> TileSetAtlasSourceEditor::_group_properties_per_tiles(const List<PropertyInfo> &r_list, const TileSetAtlasSource *p_atlas) { // Group properties per tile. - Map<Vector2i, List<const PropertyInfo *>> per_tile; + HashMap<Vector2i, List<const PropertyInfo *>> per_tile; for (const List<PropertyInfo>::Element *E_property = r_list.front(); E_property; E_property = E_property->next()) { Vector<String> components = String(E_property->get().name).split("/", true, 1); if (components.size() >= 1) { @@ -1544,12 +1544,12 @@ void TileSetAtlasSourceEditor::_menu_option(int p_option) { case TILE_DELETE: { List<PropertyInfo> list; tile_set_atlas_source->get_property_list(&list); - Map<Vector2i, List<const PropertyInfo *>> per_tile = _group_properties_per_tiles(list, tile_set_atlas_source); + HashMap<Vector2i, List<const PropertyInfo *>> per_tile = _group_properties_per_tiles(list, tile_set_atlas_source); undo_redo->create_action(TTR("Remove tile")); // Remove tiles - Set<Vector2i> removed; - for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) { + RBSet<Vector2i> removed; + for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { TileSelection selected = E->get(); if (selected.alternative == 0) { // Remove a tile. @@ -1569,7 +1569,7 @@ void TileSetAtlasSourceEditor::_menu_option(int p_option) { } // Remove alternatives - for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { TileSelection selected = E->get(); if (selected.alternative > 0 && !removed.has(selected.tile)) { // Remove an alternative tile. @@ -1608,7 +1608,7 @@ void TileSetAtlasSourceEditor::_menu_option(int p_option) { case TILE_CREATE_ALTERNATIVE: { undo_redo->create_action(TTR("Create tile alternatives")); Array array; - for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { if (E->get().alternative == 0) { int next_id = tile_set_atlas_source->get_next_alternative_tile_id(E->get().tile); undo_redo->add_do_method(tile_set_atlas_source, "create_alternative_tile", E->get().tile, next_id); @@ -1658,7 +1658,7 @@ void TileSetAtlasSourceEditor::_set_selection_from_array(Array p_selection) { Array TileSetAtlasSourceEditor::_get_selection_as_array() { Array output; - for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { output.push_back(E->get().tile); output.push_back(E->get().alternative); } @@ -1672,7 +1672,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { // Draw the selected tile. if (tools_button_group->get_pressed_button() == tool_select_button) { - for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { TileSelection selected = E->get(); if (selected.alternative == 0) { // Draw the rect. @@ -1722,7 +1722,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { if (drag_type == DRAG_TYPE_REMOVE_TILES) { // Draw the tiles to be removed. - for (Set<Vector2i>::Element *E = drag_modified_tiles.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = drag_modified_tiles.front(); E; E = E->next()) { for (int frame = 0; frame < tile_set_atlas_source->get_tile_animation_frames_count(E->get()); frame++) { tile_atlas_control->draw_rect(tile_set_atlas_source->get_tile_texture_region(E->get(), frame), Color(0.0, 0.0, 0.0), false); } @@ -1739,7 +1739,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { color = selection_color.lightened(0.2); } - Set<Vector2i> to_paint; + RBSet<Vector2i> to_paint; for (int x = area.get_position().x; x < area.get_end().x; x++) { for (int y = area.get_position().y; y < area.get_end().y; y++) { Vector2i coords = tile_set_atlas_source->get_tile_at_coords(Vector2i(x, y)); @@ -1749,7 +1749,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { } } - for (Set<Vector2i>::Element *E = to_paint.front(); E; E = E->next()) { + for (RBSet<Vector2i>::Element *E = to_paint.front(); E; E = E->next()) { Vector2i coords = E->get(); tile_atlas_control->draw_rect(tile_set_atlas_source->get_tile_texture_region(coords), color, false); } @@ -1837,7 +1837,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw() { // Draw the selection on top of other. if (tools_button_group->get_pressed_button() == tool_select_button) { - for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { if (E->get().alternative != 0) { continue; } @@ -1962,7 +1962,7 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() { } // Draw selected tile. - for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { TileSelection selected = E->get(); if (selected.alternative >= 1) { Rect2i rect = tile_atlas_view->get_alternative_tile_rect(selected.tile, selected.alternative); @@ -2005,7 +2005,7 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw() { // Draw the selection on top of other. if (tools_button_group->get_pressed_button() == tool_select_button) { - for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { if (E->get().alternative == 0) { continue; } @@ -2222,7 +2222,7 @@ void TileSetAtlasSourceEditor::_auto_remove_tiles() { List<PropertyInfo> list; tile_set_atlas_source->get_property_list(&list); - Map<Vector2i, List<const PropertyInfo *>> per_tile = _group_properties_per_tiles(list, tile_set_atlas_source); + HashMap<Vector2i, List<const PropertyInfo *>> per_tile = _group_properties_per_tiles(list, tile_set_atlas_source); for (int i = 0; i < tile_set_atlas_source->get_tiles_count(); i++) { Vector2i coords = tile_set_atlas_source->get_tile_id(i); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h index b26b7edbfa..738fe1044d 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.h +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h @@ -88,7 +88,7 @@ public: TileSetAtlasSourceEditor *tiles_set_atlas_source_editor = nullptr; TileSetAtlasSource *tile_set_atlas_source = nullptr; - Set<TileSelection> tiles = Set<TileSelection>(); + RBSet<TileSelection> tiles = RBSet<TileSelection>(); protected: bool _set(const StringName &p_name, const Variant &p_value); @@ -99,10 +99,10 @@ public: public: TileSetAtlasSource *get_edited_tile_set_atlas_source() const { return tile_set_atlas_source; }; - Set<TileSelection> get_edited_tiles() const { return tiles; }; + RBSet<TileSelection> get_edited_tiles() const { return tiles; }; // Update the proxyed object. - void edit(TileSetAtlasSource *p_tile_set_atlas_source, Set<TileSelection> p_tiles = Set<TileSelection>()); + void edit(TileSetAtlasSource *p_tile_set_atlas_source, RBSet<TileSelection> p_tiles = RBSet<TileSelection>()); AtlasTileProxyObject(TileSetAtlasSourceEditor *p_tiles_set_atlas_source_editor) { tiles_set_atlas_source_editor = p_tiles_set_atlas_source_editor; @@ -130,7 +130,7 @@ private: // -- Tile data editors -- String current_property; Control *current_tile_data_editor_toolbar = nullptr; - Map<String, TileDataEditor *> tile_data_editors; + HashMap<String, TileDataEditor *> tile_data_editors; TileDataEditor *current_tile_data_editor = nullptr; void _tile_data_editors_tree_selected(); @@ -182,10 +182,10 @@ private: Vector2i drag_current_tile; Rect2i drag_start_tile_shape; - Set<Vector2i> drag_modified_tiles; + RBSet<Vector2i> drag_modified_tiles; void _end_dragging(); - Map<Vector2i, List<const PropertyInfo *>> _group_properties_per_tiles(const List<PropertyInfo> &r_list, const TileSetAtlasSource *p_atlas); + HashMap<Vector2i, List<const PropertyInfo *>> _group_properties_per_tiles(const List<PropertyInfo> &r_list, const TileSetAtlasSource *p_atlas); // Popup functions. enum MenuOptions { @@ -215,7 +215,7 @@ private: MenuButton *tool_advanced_menu_buttom = nullptr; // Selection. - Set<TileSelection> selection; + RBSet<TileSelection> selection; void _set_selection_from_array(Array p_selection); Array _get_selection_as_array(); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index b0844828df..85238ce4a5 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -324,7 +324,7 @@ void VisualShaderGraphPlugin::make_dirty(bool p_enabled) { } void VisualShaderGraphPlugin::register_link(VisualShader::Type p_type, int p_id, VisualShaderNode *p_visual_node, GraphNode *p_graph_node) { - links.insert(p_id, { p_type, p_visual_node, p_graph_node, p_visual_node->get_output_port_for_preview() != -1, -1, Map<int, InputPort>(), Map<int, Port>(), nullptr, nullptr, nullptr, { nullptr, nullptr, nullptr } }); + links.insert(p_id, { p_type, p_visual_node, p_graph_node, p_visual_node->get_output_port_for_preview() != -1, -1, HashMap<int, InputPort>(), HashMap<int, Port>(), nullptr, nullptr, nullptr, { nullptr, nullptr, nullptr } }); } void VisualShaderGraphPlugin::register_output_port(int p_node_id, int p_port, TextureButton *p_button) { @@ -1359,7 +1359,7 @@ void VisualShaderEditor::_update_options_menu() { static bool low_driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name") == "opengl3"; - Map<String, TreeItem *> folders; + HashMap<String, TreeItem *> folders; int current_func = -1; @@ -1659,7 +1659,7 @@ void VisualShaderEditor::_update_uniforms(bool p_update_refs) { } } -void VisualShaderEditor::_update_uniform_refs(Set<String> &p_deleted_names) { +void VisualShaderEditor::_update_uniform_refs(RBSet<String> &p_deleted_names) { for (int i = 0; i < VisualShader::TYPE_MAX; i++) { VisualShader::Type type = VisualShader::Type(i); @@ -2277,7 +2277,7 @@ void VisualShaderEditor::_uniform_line_edit_changed(const String &p_text, int p_ undo_redo->add_do_method(this, "_update_uniforms", true); undo_redo->add_undo_method(this, "_update_uniforms", true); - Set<String> changed_names; + RBSet<String> changed_names; changed_names.insert(node->get_uniform_name()); _update_uniform_refs(changed_names); @@ -3097,7 +3097,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { } } - Set<String> uniform_names; + RBSet<String> uniform_names; for (const int &F : p_nodes) { Ref<VisualShaderNode> node = visual_shader->get_node(type, F); @@ -3201,10 +3201,10 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) { undo_redo->create_action(TTR("Convert Uniform Node(s) To Constant(s)")); } - const Set<int> ¤t_set = p_vice_versa ? selected_uniforms : selected_constants; - Set<String> deleted_names; + const RBSet<int> ¤t_set = p_vice_versa ? selected_uniforms : selected_constants; + RBSet<String> deleted_names; - for (Set<int>::Element *E = current_set.front(); E; E = E->next()) { + for (RBSet<int>::Element *E = current_set.front(); E; E = E->next()) { int node_id = E->get(); Ref<VisualShaderNode> node = visual_shader->get_node(type_id, node_id); bool caught = false; @@ -3771,7 +3771,7 @@ void VisualShaderEditor::_dup_copy_nodes(int p_type, List<CopyItem> &r_items, Li selection_center.x = 0.0f; selection_center.y = 0.0f; - Set<int> nodes; + RBSet<int> nodes; for (int i = 0; i < graph->get_child_count(); i++) { GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i)); @@ -3850,9 +3850,9 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, List<CopyItem> &r_items, c int base_id = visual_shader->get_valid_node_id(type); int id_from = base_id; - Map<int, int> connection_remap; - Set<int> unsupported_set; - Set<int> added_set; + HashMap<int, int> connection_remap; + RBSet<int> unsupported_set; + RBSet<int> added_set; for (CopyItem &item : r_items) { if (item.disabled) { @@ -4801,7 +4801,7 @@ VisualShaderEditor::VisualShaderEditor() { /////////////////////////////////////// preview_window = memnew(Window); - preview_window->set_title(TTR("Generated shader code")); + preview_window->set_title(TTR("Generated Shader Code")); preview_window->set_visible(preview_showed); preview_window->connect("close_requested", callable_mp(this, &VisualShaderEditor::_preview_close_requested)); preview_window->connect("size_changed", callable_mp(this, &VisualShaderEditor::_preview_size_changed)); @@ -5938,7 +5938,7 @@ public: } } - void setup(Ref<Resource> p_parent_resource, Vector<EditorProperty *> p_properties, const Vector<StringName> &p_names, const Map<StringName, String> &p_overrided_names, Ref<VisualShaderNode> p_node) { + void setup(Ref<Resource> p_parent_resource, Vector<EditorProperty *> p_properties, const Vector<StringName> &p_names, const HashMap<StringName, String> &p_overrided_names, Ref<VisualShaderNode> p_node) { parent_resource = p_parent_resource; updating = false; node = p_node; diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index 540cb709b3..1a3a1d799f 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -72,8 +72,8 @@ private: GraphNode *graph_node = nullptr; bool preview_visible = false; int preview_pos = 0; - Map<int, InputPort> input_ports; - Map<int, Port> output_ports; + HashMap<int, InputPort> input_ports; + HashMap<int, Port> output_ports; VBoxContainer *preview_box = nullptr; LineEdit *uniform_name = nullptr; CodeEdit *expression_edit = nullptr; @@ -81,7 +81,7 @@ private: }; Ref<VisualShader> visual_shader; - Map<int, Link> links; + HashMap<int, Link> links; List<VisualShader::Connection> connections; bool dirty = false; @@ -358,8 +358,8 @@ class VisualShaderEditor : public VBoxContainer { int from_node = -1; int from_slot = -1; - Set<int> selected_constants; - Set<int> selected_uniforms; + RBSet<int> selected_constants; + RBSet<int> selected_uniforms; int selected_comment = -1; int selected_float_constant = -1; @@ -468,7 +468,7 @@ class VisualShaderEditor : public VBoxContainer { bool _is_available(int p_mode); void _update_created_node(GraphNode *node); void _update_uniforms(bool p_update_refs); - void _update_uniform_refs(Set<String> &p_names); + void _update_uniform_refs(RBSet<String> &p_names); void _update_varyings(); void _visibility_changed(); diff --git a/editor/pot_generator.cpp b/editor/pot_generator.cpp index 0835d0212f..c46a4f5a86 100644 --- a/editor/pot_generator.cpp +++ b/editor/pot_generator.cpp @@ -39,14 +39,14 @@ POTGenerator *POTGenerator::singleton = nullptr; #ifdef DEBUG_POT void POTGenerator::_print_all_translation_strings() { - for (OrderedHashMap<String, Vector<POTGenerator::MsgidData>>::Element E = all_translation_strings.front(); E; E = E.next()) { + for (HashMap<String, Vector<POTGenerator::MsgidData>>::Element E = all_translation_strings.front(); E; E = E.next()) { Vector<MsgidData> v_md = all_translation_strings[E.key()]; for (int i = 0; i < v_md.size(); i++) { print_line("++++++"); print_line("msgid: " + E.key()); print_line("context: " + v_md[i].ctx); print_line("msgid_plural: " + v_md[i].plural); - for (Set<String>::Element *F = v_md[i].locations.front(); F; F = F->next()) { + for (RBSet<String>::Element *F = v_md[i].locations.front(); F; F = F->next()) { print_line("location: " + F->get()); } } @@ -121,19 +121,19 @@ void POTGenerator::_write_to_pot(const String &p_file) { file->store_string(header); - for (OrderedHashMap<String, Vector<MsgidData>>::Element E_pair = all_translation_strings.front(); E_pair; E_pair = E_pair.next()) { - String msgid = E_pair.key(); - Vector<MsgidData> v_msgid_data = E_pair.value(); + for (const KeyValue<String, Vector<MsgidData>> &E_pair : all_translation_strings) { + String msgid = E_pair.key; + const Vector<MsgidData> &v_msgid_data = E_pair.value; for (int i = 0; i < v_msgid_data.size(); i++) { String context = v_msgid_data[i].ctx; String plural = v_msgid_data[i].plural; - const Set<String> &locations = v_msgid_data[i].locations; + const RBSet<String> &locations = v_msgid_data[i].locations; // Put the blank line at the start, to avoid a double at the end when closing the file. file->store_line(""); // Write file locations. - for (Set<String>::Element *E = locations.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = locations.front(); E; E = E->next()) { file->store_line("#: " + E->get().trim_prefix("res://")); } diff --git a/editor/pot_generator.h b/editor/pot_generator.h index e7a5f90cee..b24eadfd95 100644 --- a/editor/pot_generator.h +++ b/editor/pot_generator.h @@ -32,8 +32,8 @@ #define POT_GENERATOR_H #include "core/io/file_access.h" -#include "core/templates/ordered_hash_map.h" -#include "core/templates/set.h" +#include "core/templates/hash_map.h" +#include "core/templates/rb_set.h" //#define DEBUG_POT @@ -43,10 +43,10 @@ class POTGenerator { struct MsgidData { String ctx; String plural; - Set<String> locations; + RBSet<String> locations; }; // Store msgid as key and the additional data around the msgid - if it's under a context, has plurals and its file locations. - OrderedHashMap<String, Vector<MsgidData>> all_translation_strings; + HashMap<String, Vector<MsgidData>> all_translation_strings; void _write_to_pot(const String &p_file); void _write_msgid(Ref<FileAccess> r_file, const String &p_id, bool p_plural); diff --git a/editor/progress_dialog.h b/editor/progress_dialog.h index 23a77ea201..a29696cc0d 100644 --- a/editor/progress_dialog.h +++ b/editor/progress_dialog.h @@ -47,8 +47,8 @@ class BackgroundProgress : public HBoxContainer { ProgressBar *progress = nullptr; }; - Map<String, Task> tasks; - Map<String, int> updates; + HashMap<String, Task> tasks; + HashMap<String, int> updates; void _update(); protected: @@ -77,7 +77,7 @@ class ProgressDialog : public PopupPanel { HBoxContainer *cancel_hb = nullptr; Button *cancel = nullptr; - Map<String, Task> tasks; + HashMap<String, Task> tasks; VBoxContainer *main = nullptr; uint64_t last_progress_tick; diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 1344afbd3a..839378dad2 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -346,7 +346,7 @@ void ProjectExportDialog::_update_feature_list() { Ref<EditorExportPreset> current = get_current_preset(); ERR_FAIL_COND(current.is_null()); - Set<String> fset; + RBSet<String> fset; List<String> features; current->get_platform()->get_platform_features(&features); @@ -366,7 +366,7 @@ void ProjectExportDialog::_update_feature_list() { } custom_feature_display->clear(); - for (Set<String>::Element *E = fset.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = fset.front(); E; E = E->next()) { String f = E->get(); if (E->next()) { f += ", "; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 9c745e6a41..d74cfe4ec0 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -186,7 +186,8 @@ private: if (mode == MODE_IMPORT || mode == MODE_RENAME) { if (!valid_path.is_empty() && !d->file_exists("project.godot")) { if (valid_path.ends_with(".zip")) { - zlib_filefunc_def io = zipio_create_io(); + Ref<FileAccess> io_fa; + zlib_filefunc_def io = zipio_create_io(&io_fa); unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io); if (!pkg) { @@ -499,7 +500,8 @@ private: zip_path = project_path->get_text(); } - zlib_filefunc_def io = zipio_create_io(); + Ref<FileAccess> io_fa; + zlib_filefunc_def io = zipio_create_io(&io_fa); unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io); if (!pkg) { @@ -1062,7 +1064,7 @@ public: void select_first_visible_project(); void erase_selected_projects(bool p_delete_project_contents); Vector<Item> get_selected_projects() const; - const Set<String> &get_selected_project_keys() const; + const RBSet<String> &get_selected_project_keys() const; void ensure_project_visible(int p_index); int get_single_selected_index() const; bool is_any_project_missing() const; @@ -1088,7 +1090,7 @@ private: String _search_term; FilterOption _order_option; - Set<String> _selected_project_keys; + RBSet<String> _selected_project_keys; String _last_clicked; // Project key VBoxContainer *_scroll_children; int _icon_load_index; @@ -1256,7 +1258,7 @@ void ProjectList::load_projects() { List<PropertyInfo> properties; EditorSettings::get_singleton()->get_property_list(&properties); - Set<String> favorites; + RBSet<String> favorites; // Find favourites... for (const PropertyInfo &E : properties) { String property_key = E.name; @@ -1401,7 +1403,7 @@ void ProjectList::create_project_item_control(int p_index) { title->set_clip_text(true); title_hb->add_child(title); - String unsupported_features_str = Variant(item.unsupported_features).operator String().trim_prefix("[").trim_suffix("]"); + String unsupported_features_str = String(", ").join(item.unsupported_features); int length = unsupported_features_str.length(); if (length > 0) { Label *unsupported_label = memnew(Label(unsupported_features_str)); @@ -1502,7 +1504,7 @@ void ProjectList::sort_projects() { update_dock_menu(); } -const Set<String> &ProjectList::get_selected_project_keys() const { +const RBSet<String> &ProjectList::get_selected_project_keys() const { // Faster if that's all you need return _selected_project_keys; } @@ -2095,9 +2097,9 @@ void ProjectManager::_open_selected_projects() { // This is especially important for the HTML5 project manager. loading_label->set_modulate(Color(1, 1, 1)); - const Set<String> &selected_list = _project_list->get_selected_project_keys(); + const RBSet<String> &selected_list = _project_list->get_selected_project_keys(); - for (const Set<String>::Element *E = selected_list.front(); E; E = E->next()) { + for (const RBSet<String>::Element *E = selected_list.front(); E; E = E->next()) { const String &selected = E->get(); String path = EditorSettings::get_singleton()->get("projects/" + selected); String conf = path.plus_file("project.godot"); @@ -2144,7 +2146,7 @@ void ProjectManager::_open_selected_projects() { } void ProjectManager::_open_selected_projects_ask() { - const Set<String> &selected_list = _project_list->get_selected_project_keys(); + const RBSet<String> &selected_list = _project_list->get_selected_project_keys(); if (selected_list.size() < 1) { return; @@ -2207,7 +2209,7 @@ void ProjectManager::_open_selected_projects_ask() { } } if (!unsupported_features.is_empty()) { - String unsupported_features_str = Variant(unsupported_features).operator String().trim_prefix("[").trim_suffix("]"); + String unsupported_features_str = String(", ").join(unsupported_features); warning_message += vformat(TTR("Warning: This project uses the following features not supported by this build of Godot:\n\n%s\n\n"), unsupported_features_str); } warning_message += TTR("Open anyway? Project will be modified."); @@ -2259,7 +2261,7 @@ void ProjectManager::_run_project_confirm() { } void ProjectManager::_run_project() { - const Set<String> &selected_list = _project_list->get_selected_project_keys(); + const RBSet<String> &selected_list = _project_list->get_selected_project_keys(); if (selected_list.size() < 1) { return; @@ -2319,13 +2321,13 @@ void ProjectManager::_import_project() { } void ProjectManager::_rename_project() { - const Set<String> &selected_list = _project_list->get_selected_project_keys(); + const RBSet<String> &selected_list = _project_list->get_selected_project_keys(); if (selected_list.size() == 0) { return; } - for (Set<String>::Element *E = selected_list.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = selected_list.front(); E; E = E->next()) { const String &selected = E->get(); String path = EditorSettings::get_singleton()->get("projects/" + selected); npdialog->set_project_path(path); @@ -2345,7 +2347,7 @@ void ProjectManager::_erase_missing_projects_confirm() { } void ProjectManager::_erase_project() { - const Set<String> &selected_list = _project_list->get_selected_project_keys(); + const RBSet<String> &selected_list = _project_list->get_selected_project_keys(); if (selected_list.size() == 0) { return; @@ -2402,7 +2404,7 @@ void ProjectManager::_files_dropped(PackedStringArray p_files) { _install_project(p_files[0], file.substr(0, file.length() - 4).capitalize()); return; } - Set<String> folders_set; + RBSet<String> folders_set; Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); for (int i = 0; i < p_files.size(); i++) { String file = p_files[i]; @@ -2410,7 +2412,7 @@ void ProjectManager::_files_dropped(PackedStringArray p_files) { } if (folders_set.size() > 0) { PackedStringArray folders; - for (Set<String>::Element *E = folders_set.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = folders_set.front(); E; E = E->next()) { folders.push_back(E->get()); } diff --git a/editor/project_manager.h b/editor/project_manager.h index a68cc4350c..93a6e1c405 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -50,7 +50,7 @@ enum FilterOption { class ProjectManager : public Control { GDCLASS(ProjectManager, Control); - Map<String, Ref<Texture2D>> icon_type_cache; + HashMap<String, Ref<Texture2D>> icon_type_cache; void _build_icon_type_cache(Ref<Theme> p_theme); static ProjectManager *singleton; diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index f684c0e0c9..bd0affbcc3 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -249,7 +249,7 @@ String ProjectSettingsEditor::_get_setting_name() const { } void ProjectSettingsEditor::_add_feature_overrides() { - Set<String> presets; + RBSet<String> presets; presets.insert("bptc"); presets.insert("s3tc"); @@ -292,7 +292,7 @@ void ProjectSettingsEditor::_add_feature_overrides() { feature_box->clear(); feature_box->add_item(TTR("(All)"), 0); // So it is always on top. int id = 1; - for (Set<String>::Element *E = presets.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = presets.front(); E; E = E->next()) { feature_box->add_item(E->get(), id++); } } @@ -420,7 +420,7 @@ void ProjectSettingsEditor::_action_reordered(const String &p_action_name, const Variant target_value = ps->get(target_name); List<PropertyInfo> props; - OrderedHashMap<String, Variant> action_values; + HashMap<String, Variant> action_values; ProjectSettings::get_singleton()->get_property_list(&props); undo_redo->create_action(TTR("Update Input Action Order")); @@ -437,9 +437,9 @@ void ProjectSettingsEditor::_action_reordered(const String &p_action_name, const undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", prop.name); } - for (OrderedHashMap<String, Variant>::Element E = action_values.front(); E; E = E.next()) { - String name = E.key(); - Variant value = E.get(); + for (const KeyValue<String, Variant> &E : action_values) { + String name = E.key; + const Variant &value = E.value; if (name == target_name) { if (p_before) { diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 5effdf0b36..71cdcc2580 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -137,13 +137,13 @@ void CustomPropertyEditor::_menu_option(int p_which) { ResourceLoader::get_recognized_extensions_for_type(type.get_slice(",", i), &extensions); } - Set<String> valid_extensions; + RBSet<String> valid_extensions; for (const String &E : extensions) { valid_extensions.insert(E); } file->clear_filters(); - for (Set<String>::Element *E = valid_extensions.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = valid_extensions.front(); E; E = E->next()) { file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); } @@ -875,7 +875,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: for (int i = 0; i < hint_text.get_slice_count(","); i++) { String base = hint_text.get_slice(",", i); - Set<String> valid_inheritors; + RBSet<String> valid_inheritors; valid_inheritors.insert(base); List<StringName> inheritors; ClassDB::get_inheriters_from_class(base.strip_edges(), &inheritors); @@ -890,7 +890,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: E = E->next(); } - for (Set<String>::Element *j = valid_inheritors.front(); j; j = j->next()) { + for (RBSet<String>::Element *j = valid_inheritors.front(); j; j = j->next()) { const String &t = j->get(); bool is_custom_resource = false; diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 1ac15a0a9d..c136eae1bc 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -366,11 +366,11 @@ void PropertySelector::_item_selected() { String text; if (properties) { while (!class_type.is_empty()) { - Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(class_type); + HashMap<String, DocData::ClassDoc>::Iterator E = dd->class_list.find(class_type); if (E) { - for (int i = 0; i < E->get().properties.size(); i++) { - if (E->get().properties[i].name == name) { - text = DTR(E->get().properties[i].description); + for (int i = 0; i < E->value.properties.size(); i++) { + if (E->value.properties[i].name == name) { + text = DTR(E->value.properties[i].description); break; } } @@ -385,11 +385,11 @@ void PropertySelector::_item_selected() { } } else { while (!class_type.is_empty()) { - Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(class_type); + HashMap<String, DocData::ClassDoc>::Iterator E = dd->class_list.find(class_type); if (E) { - for (int i = 0; i < E->get().methods.size(); i++) { - if (E->get().methods[i].name == name) { - text = DTR(E->get().methods[i].description); + for (int i = 0; i < E->value.methods.size(); i++) { + if (E->value.methods[i].name == name) { + text = DTR(E->value.methods[i].description); break; } } diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp index 8879085d86..38d909038f 100644 --- a/editor/reparent_dialog.cpp +++ b/editor/reparent_dialog.cpp @@ -57,7 +57,7 @@ void ReparentDialog::_reparent() { } } -void ReparentDialog::set_current(const Set<Node *> &p_selection) { +void ReparentDialog::set_current(const RBSet<Node *> &p_selection) { tree->set_marked(p_selection, false, false); //tree->set_selected(p_node->get_parent()); } diff --git a/editor/reparent_dialog.h b/editor/reparent_dialog.h index 121a86e9f0..a5a9818e7f 100644 --- a/editor/reparent_dialog.h +++ b/editor/reparent_dialog.h @@ -52,7 +52,7 @@ protected: static void _bind_methods(); public: - void set_current(const Set<Node *> &p_selection); + void set_current(const RBSet<Node *> &p_selection); ReparentDialog(); ~ReparentDialog(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index b385460232..afb3ac7c15 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -460,7 +460,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { selection.sort_custom<Node::Comparator>(); for (Node *node : selection) { - Map<const Node *, Node *> duplimap; + HashMap<const Node *, Node *> duplimap; Node *dup = node->duplicate_from_editor(duplimap); ERR_CONTINUE(!dup); @@ -658,7 +658,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { List<Node *> owned; node->get_owned_by(node->get_owner(), &owned); - Map<const Node *, Node *> duplimap; + HashMap<const Node *, Node *> duplimap; Node *dup = node->duplicate_from_editor(duplimap); ERR_CONTINUE(!dup); @@ -717,7 +717,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } List<Node *> nodes = editor_selection->get_selected_node_list(); - Set<Node *> nodeset; + RBSet<Node *> nodeset; for (Node *E : nodes) { nodeset.insert(E); } @@ -1402,7 +1402,7 @@ void SceneTreeDock::_set_owners(Node *p_owner, const Array &p_nodes) { } } -void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, Map<Node *, NodePath> *p_renames) { +void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, HashMap<Node *, NodePath> *p_renames) { base_path.push_back(p_node->get_name()); if (new_base_path.size()) { new_base_path.push_back(p_node->get_name()); @@ -1420,7 +1420,7 @@ void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<Stri } } -void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, Map<Node *, NodePath> *p_renames) { +void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, HashMap<Node *, NodePath> *p_renames) { Vector<StringName> base_path; Node *n = p_node->get_parent(); while (n) { @@ -1443,24 +1443,24 @@ void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, Map<Node _fill_path_renames(base_path, new_base_path, p_node, p_renames); } -bool SceneTreeDock::_update_node_path(Node *p_root_node, NodePath &r_node_path, Map<Node *, NodePath> *p_renames) const { +bool SceneTreeDock::_update_node_path(Node *p_root_node, NodePath &r_node_path, HashMap<Node *, NodePath> *p_renames) const { Node *target_node = p_root_node->get_node_or_null(r_node_path); ERR_FAIL_NULL_V_MSG(target_node, false, "Found invalid node path '" + String(r_node_path) + "' on node '" + String(scene_root->get_path_to(p_root_node)) + "'"); // Try to find the target node in modified node paths. - Map<Node *, NodePath>::Element *found_node_path = p_renames->find(target_node); + HashMap<Node *, NodePath>::Iterator found_node_path = p_renames->find(target_node); if (found_node_path) { - Map<Node *, NodePath>::Element *found_root_path = p_renames->find(p_root_node); - NodePath root_path_new = found_root_path ? found_root_path->get() : p_root_node->get_path(); - r_node_path = root_path_new.rel_path_to(found_node_path->get()); + HashMap<Node *, NodePath>::Iterator found_root_path = p_renames->find(p_root_node); + NodePath root_path_new = found_root_path ? found_root_path->value : p_root_node->get_path(); + r_node_path = root_path_new.rel_path_to(found_node_path->value); return true; } // Update the path if the base node has changed and has not been deleted. - Map<Node *, NodePath>::Element *found_root_path = p_renames->find(p_root_node); + HashMap<Node *, NodePath>::Iterator found_root_path = p_renames->find(p_root_node); if (found_root_path) { - NodePath root_path_new = found_root_path->get(); + NodePath root_path_new = found_root_path->value; if (!root_path_new.is_empty()) { NodePath old_abs_path = NodePath(String(p_root_node->get_path()).plus_file(r_node_path)); old_abs_path.simplify(); @@ -1473,7 +1473,7 @@ bool SceneTreeDock::_update_node_path(Node *p_root_node, NodePath &r_node_path, return false; } -bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_variant, Map<Node *, NodePath> *p_renames) const { +bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_variant, HashMap<Node *, NodePath> *p_renames) const { switch (r_variant.get_type()) { case Variant::NODE_PATH: { NodePath node_path = r_variant; @@ -1528,8 +1528,8 @@ bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_var return false; } -void SceneTreeDock::perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims) { - Map<Ref<Animation>, Set<int>> rem_anims; +void SceneTreeDock::perform_node_renames(Node *p_base, HashMap<Node *, NodePath> *p_renames, HashMap<Ref<Animation>, RBSet<int>> *r_rem_anims) { + HashMap<Ref<Animation>, RBSet<int>> rem_anims; if (!r_rem_anims) { r_rem_anims = &rem_anims; } @@ -1543,8 +1543,8 @@ void SceneTreeDock::perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_ } // No renaming if base node is deleted. - Map<Node *, NodePath>::Element *found_base_path = p_renames->find(p_base); - if (found_base_path && found_base_path->get().is_empty()) { + HashMap<Node *, NodePath>::Iterator found_base_path = p_renames->find(p_base); + if (found_base_path && found_base_path->value.is_empty()) { return; } @@ -1575,20 +1575,20 @@ void SceneTreeDock::perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_ Node *root = ap->get_node(ap->get_root()); if (root) { - Map<Node *, NodePath>::Element *found_root_path = p_renames->find(root); - NodePath new_root_path = found_root_path ? found_root_path->get() : root->get_path(); + HashMap<Node *, NodePath>::Iterator found_root_path = p_renames->find(root); + NodePath new_root_path = found_root_path ? found_root_path->value : root->get_path(); if (!new_root_path.is_empty()) { // No renaming if root node is deleted. for (const StringName &E : anims) { Ref<Animation> anim = ap->get_animation(E); if (!r_rem_anims->has(anim)) { - r_rem_anims->insert(anim, Set<int>()); - Set<int> &ran = r_rem_anims->find(anim)->get(); + r_rem_anims->insert(anim, RBSet<int>()); + RBSet<int> &ran = r_rem_anims->find(anim)->value; for (int i = 0; i < anim->get_track_count(); i++) { ran.insert(i); } } - Set<int> &ran = r_rem_anims->find(anim)->get(); + RBSet<int> &ran = r_rem_anims->find(anim)->value; if (anim.is_null()) { continue; @@ -1605,13 +1605,13 @@ void SceneTreeDock::perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_ continue; //channel was removed } - Map<Node *, NodePath>::Element *found_path = p_renames->find(n); + HashMap<Node *, NodePath>::Iterator found_path = p_renames->find(n); if (found_path) { - if (found_path->get() == NodePath()) { + if (found_path->value == NodePath()) { //will be erased int idx = 0; - Set<int>::Element *EI = ran.front(); + RBSet<int>::Element *EI = ran.front(); ERR_FAIL_COND(!EI); //bug while (EI->get() != i) { idx++; @@ -1631,7 +1631,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_ } else { //will be renamed - NodePath rel_path = new_root_path.rel_path_to(found_path->get()); + NodePath rel_path = new_root_path.rel_path_to(found_path->value); NodePath new_path = NodePath(rel_path.get_names(), track_np.get_subnames(), false); if (new_path == track_np) { @@ -1653,7 +1653,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_ } void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) { - Map<Node *, NodePath> path_renames; + HashMap<Node *, NodePath> path_renames; Vector<StringName> base_path; Node *n = p_node->get_parent(); @@ -1774,7 +1774,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V editor_data->get_undo_redo().create_action(TTR("Reparent Node")); - Map<Node *, NodePath> path_renames; + HashMap<Node *, NodePath> path_renames; Vector<StringName> former_names; int inc = 0; @@ -1811,9 +1811,9 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V // Name was modified, fix the path renames. if (old_name.casecmp_to(new_name) != 0) { // Fix the to name to have the new name. - Map<Node *, NodePath>::Element *found_path = path_renames.find(node); + HashMap<Node *, NodePath>::Iterator found_path = path_renames.find(node); if (found_path) { - NodePath old_new_name = found_path->get(); + NodePath old_new_name = found_path->value; Vector<StringName> unfixed_new_names = old_new_name.get_names(); Vector<StringName> fixed_new_names; @@ -2058,7 +2058,7 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { } else { remove_list.sort_custom<Node::Comparator>(); //sort nodes to keep positions - Map<Node *, NodePath> path_renames; + HashMap<Node *, NodePath> path_renames; //delete from animation for (Node *n : remove_list) { @@ -2148,7 +2148,7 @@ void SceneTreeDock::_selection_changed() { //automatically turn on multi-edit _tool_selected(TOOL_MULTI_EDIT); } else if (selection_size == 1) { - _push_item(editor_selection->get_selection().front()->key()); + _push_item(editor_selection->get_selection().begin()->key); } else if (selection_size == 0) { _push_item(nullptr); } @@ -2407,7 +2407,7 @@ void SceneTreeDock::_new_scene_from(String p_file) { Node *base = selection.front()->get(); - Map<const Node *, Node *> duplimap; + HashMap<const Node *, Node *> duplimap; Node *copy = base->duplicate_from_editor(duplimap); if (copy) { @@ -3038,14 +3038,14 @@ List<Node *> SceneTreeDock::paste_nodes() { ur.create_action(TTR("Paste Node(s)")); ur.add_do_method(editor_selection, "clear"); - Map<Ref<Resource>, Ref<Resource>> resource_remap; + HashMap<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<Ref<Resource>, Ref<Resource>> remap; + HashMap<Ref<Resource>, Ref<Resource>> remap; for (Node *E : node_clipboard) { _create_remap_for_node(E, remap); } @@ -3055,7 +3055,7 @@ List<Node *> SceneTreeDock::paste_nodes() { } for (Node *node : node_clipboard) { - Map<const Node *, Node *> duplimap; + HashMap<const Node *, Node *> duplimap; Node *dup = node->duplicate_from_editor(duplimap, resource_remap); ERR_CONTINUE(!dup); @@ -3241,7 +3241,7 @@ void SceneTreeDock::_clear_clipboard() { clipboard_resource_remap.clear(); } -void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<Ref<Resource>, Ref<Resource>> &r_remap) { +void SceneTreeDock::_create_remap_for_node(Node *p_node, HashMap<Ref<Resource>, Ref<Resource>> &r_remap) { List<PropertyInfo> props; p_node->get_property_list(&props); @@ -3280,7 +3280,7 @@ void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<Ref<Resource>, Ref< } } -void SceneTreeDock::_create_remap_for_resource(Ref<Resource> p_resource, Map<Ref<Resource>, Ref<Resource>> &r_remap) { +void SceneTreeDock::_create_remap_for_resource(Ref<Resource> p_resource, HashMap<Ref<Resource>, Ref<Resource>> &r_remap) { r_remap[p_resource] = p_resource->duplicate(); List<PropertyInfo> props; diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index a1d300d3d6..1e58a7a66a 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -145,7 +145,7 @@ class SceneTreeDock : public VBoxContainer { List<Node *> node_clipboard; String clipboard_source_scene; - HashMap<String, Map<Ref<Resource>, Ref<Resource>>> clipboard_resource_remap; + HashMap<String, HashMap<Ref<Resource>, Ref<Resource>>> clipboard_resource_remap; ScriptCreateDialog *script_create_dialog = nullptr; ShaderCreateDialog *shader_create_dialog = nullptr; @@ -232,7 +232,7 @@ class SceneTreeDock : public VBoxContainer { void _selection_changed(); void _update_script_button(); - void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, Map<Node *, NodePath> *p_renames); + void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, HashMap<Node *, NodePath> *p_renames); void _normalize_drop(Node *&to_node, int &to_pos, int p_type); @@ -258,16 +258,16 @@ class SceneTreeDock : public VBoxContainer { void _feature_profile_changed(); void _clear_clipboard(); - 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); + void _create_remap_for_node(Node *p_node, HashMap<Ref<Resource>, Ref<Resource>> &r_remap); + void _create_remap_for_resource(Ref<Resource> p_resource, HashMap<Ref<Resource>, Ref<Resource>> &r_remap); bool profile_allow_editing = true; bool profile_allow_script_editing = true; static void _update_configuration_warning(); - bool _update_node_path(Node *p_root_node, NodePath &r_node_path, Map<Node *, NodePath> *p_renames) const; - bool _check_node_path_recursive(Node *p_root_node, Variant &r_variant, Map<Node *, NodePath> *p_renames) const; + bool _update_node_path(Node *p_root_node, NodePath &r_node_path, HashMap<Node *, NodePath> *p_renames) const; + bool _check_node_path_recursive(Node *p_root_node, Variant &r_variant, HashMap<Node *, NodePath> *p_renames) const; private: static SceneTreeDock *singleton; @@ -292,8 +292,8 @@ public: void instantiate(const String &p_file); void instantiate_scenes(const Vector<String> &p_files, Node *p_parent = nullptr); void set_selected(Node *p_node, bool p_emit_selected = false); - void fill_path_renames(Node *p_node, Node *p_new_parent, Map<Node *, NodePath> *p_renames); - void perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims = nullptr); + void fill_path_renames(Node *p_node, Node *p_new_parent, HashMap<Node *, NodePath> *p_renames); + void perform_node_renames(Node *p_base, HashMap<Node *, NodePath> *p_renames, HashMap<Ref<Animation>, RBSet<int>> *r_rem_anims = nullptr); SceneTreeEditor *get_tree_editor() { return scene_tree; } EditorData *get_editor_data() { return editor_data; } @@ -317,7 +317,9 @@ public: List<Node *> paste_nodes(); List<Node *> get_node_clipboard() const; - ScriptCreateDialog *get_script_create_dialog() { return script_create_dialog; } + ScriptCreateDialog *get_script_create_dialog() { + return script_create_dialog; + } SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selection, EditorData &p_editor_data); ~SceneTreeDock(); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index b588c01bce..afb42efa76 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -279,15 +279,26 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll Array arr; arr.push_back(num_connections); msg_temp += TTRN("Node has one connection.", "Node has {num} connections.", num_connections).format(arr, "{num}"); - msg_temp += " "; + if (num_groups >= 1) { + msg_temp += "\n"; + } } if (num_groups >= 1) { - Array arr; - arr.push_back(num_groups); - msg_temp += TTRN("Node is in one group.", "Node is in {num} groups.", num_groups).format(arr, "{num}"); + msg_temp += TTRN("Node is in this group:", "Node is in the following groups:", num_groups) + "\n"; + + List<GroupInfo> groups; + p_node->get_groups(&groups); + for (const GroupInfo &E : groups) { + if (E.persistent) { + msg_temp += String::utf8("• ") + String(E.name) + "\n"; + } + } } if (num_connections >= 1 || num_groups >= 1) { - msg_temp += "\n" + TTR("Click to show signals dock."); + if (num_groups < 1) { + msg_temp += "\n"; + } + msg_temp += TTR("Click to show signals dock."); } Ref<Texture2D> icon_temp; @@ -863,7 +874,7 @@ Node *SceneTreeEditor::get_selected() { return selected; } -void SceneTreeEditor::set_marked(const Set<Node *> &p_marked, bool p_selectable, bool p_children_selectable) { +void SceneTreeEditor::set_marked(const RBSet<Node *> &p_marked, bool p_selectable, bool p_children_selectable) { if (tree_dirty) { _update_tree(); } @@ -874,7 +885,7 @@ void SceneTreeEditor::set_marked(const Set<Node *> &p_marked, bool p_selectable, } void SceneTreeEditor::set_marked(Node *p_marked, bool p_selectable, bool p_children_selectable) { - Set<Node *> s; + RBSet<Node *> s; if (p_marked) { s.insert(p_marked); } diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h index 3d88081ab1..604d77cf76 100644 --- a/editor/scene_tree_editor.h +++ b/editor/scene_tree_editor.h @@ -99,7 +99,7 @@ class SceneTreeEditor : public Control { void _renamed(); UndoRedo *undo_redo = nullptr; - Set<Node *> marked; + RBSet<Node *> marked; bool marked_selectable = false; bool marked_children_selectable = false; bool display_foreign = false; @@ -140,7 +140,7 @@ public: void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }; void set_display_foreign_nodes(bool p_display); - void set_marked(const Set<Node *> &p_marked, bool p_selectable = false, bool p_children_selectable = true); + void set_marked(const RBSet<Node *> &p_marked, bool p_selectable = false, bool p_children_selectable = true); void set_marked(Node *p_marked, bool p_selectable = false, bool p_children_selectable = true); void set_selected(Node *p_node, bool p_emit_selected = true); Node *get_selected(); diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp index 3a2c4fb17b..046e8fcdfc 100644 --- a/editor/shader_create_dialog.cpp +++ b/editor/shader_create_dialog.cpp @@ -382,7 +382,7 @@ String ShaderCreateDialog::_validate_path(const String &p_path) { } String extension = p.get_extension(); - Set<String> extensions; + RBSet<String> extensions; for (int i = 0; i < SHADER_TYPE_MAX; i++) { for (const String &ext : language_data[i].extensions) { |