diff options
Diffstat (limited to 'editor')
101 files changed, 968 insertions, 587 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index ff8b72274c..f0650ee446 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -747,8 +747,8 @@ void AnimationBezierTrackEdit::_update_locked_tracks_after(int p_track) { } Vector<int> updated_locked_tracks; - for (RBSet<int>::Element *E = locked_tracks.front(); E; E = E->next()) { - updated_locked_tracks.push_back(E->get()); + for (const int &E : locked_tracks) { + updated_locked_tracks.push_back(E); } locked_tracks.clear(); for (int i = 0; i < updated_locked_tracks.size(); ++i) { @@ -766,8 +766,8 @@ void AnimationBezierTrackEdit::_update_hidden_tracks_after(int p_track) { } Vector<int> updated_hidden_tracks; - for (RBSet<int>::Element *E = hidden_tracks.front(); E; E = E->next()) { - updated_hidden_tracks.push_back(E->get()); + for (const int &E : hidden_tracks) { + updated_hidden_tracks.push_back(E); } hidden_tracks.clear(); for (int i = 0; i < updated_hidden_tracks.size(); ++i) { @@ -792,8 +792,8 @@ void AnimationBezierTrackEdit::_clear_selection() { void AnimationBezierTrackEdit::_change_selected_keys_handle_mode(Animation::HandleMode p_mode) { undo_redo->create_action(TTR("Update Selected Key Handles")); double ratio = timeline->get_zoom_scale() * v_zoom; - for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { - const IntPair track_key_pair = E->get(); + for (const IntPair &E : selection) { + const IntPair track_key_pair = E; undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_handle_mode", track_key_pair.first, track_key_pair.second, animation->bezier_track_get_key_handle_mode(track_key_pair.first, track_key_pair.second), ratio); undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_handle_mode", track_key_pair.first, track_key_pair.second, p_mode, ratio); } @@ -851,14 +851,14 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { focused_keys.insert(key_pair); } } else { - for (SelectionSet::Element *E = selection.front(); E; E = E->next()) { - focused_keys.insert(E->get()); - if (E->get().second > 0) { - IntPair previous_key = IntPair(E->get().first, E->get().second - 1); + for (const IntPair &E : selection) { + focused_keys.insert(E); + if (E.second > 0) { + IntPair previous_key = IntPair(E.first, E.second - 1); focused_keys.insert(previous_key); } - if (E->get().second < animation->track_get_key_count(E->get().first) - 1) { - IntPair next_key = IntPair(E->get().first, E->get().second + 1); + if (E.second < animation->track_get_key_count(E.first) - 1) { + IntPair next_key = IntPair(E.first, E.second + 1); focused_keys.insert(next_key); } } @@ -873,8 +873,8 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { float minimum_value = INFINITY; float maximum_value = -INFINITY; - for (SelectionSet::Element *E = focused_keys.front(); E; E = E->next()) { - IntPair key_pair = E->get(); + for (const IntPair &E : selection) { + IntPair key_pair = E; float time = animation->track_get_key_time(key_pair.first, key_pair.second); float value = animation->bezier_track_get_key_value(key_pair.first, key_pair.second); diff --git a/editor/animation_bezier_editor.h b/editor/animation_bezier_editor.h index cbbc3cc32a..22b58a6703 100644 --- a/editor/animation_bezier_editor.h +++ b/editor/animation_bezier_editor.h @@ -32,6 +32,7 @@ #define ANIMATION_BEZIER_EDITOR_H #include "animation_track_editor.h" +#include "core/templates/rb_set.h" class ViewPanner; @@ -71,8 +72,8 @@ class AnimationBezierTrackEdit : public Control { }; RBMap<int, RBMap<int, Rect2>> subtrack_icons; - RBSet<int> locked_tracks; - RBSet<int> hidden_tracks; + HashSet<int> locked_tracks; + HashSet<int> hidden_tracks; int solo_track = -1; bool is_filtered = false; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index b676704347..fa4f32a351 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -560,30 +560,30 @@ public: if (use_fps && animation->get_step() > 0) { float max_frame = animation->get_length() / animation->get_step(); - p_list->push_back(PropertyInfo(Variant::FLOAT, "frame", PROPERTY_HINT_RANGE, "0," + rtos(max_frame) + ",1")); + p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("frame"), PROPERTY_HINT_RANGE, "0," + rtos(max_frame) + ",1")); } else { - p_list->push_back(PropertyInfo(Variant::FLOAT, "time", PROPERTY_HINT_RANGE, "0," + rtos(animation->get_length()) + ",0.01")); + p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("time"), PROPERTY_HINT_RANGE, "0," + rtos(animation->get_length()) + ",0.01")); } switch (animation->track_get_type(track)) { case Animation::TYPE_POSITION_3D: { - p_list->push_back(PropertyInfo(Variant::VECTOR3, "position")); + p_list->push_back(PropertyInfo(Variant::VECTOR3, PNAME("position"))); } break; case Animation::TYPE_ROTATION_3D: { - p_list->push_back(PropertyInfo(Variant::QUATERNION, "rotation")); + p_list->push_back(PropertyInfo(Variant::QUATERNION, PNAME("rotation"))); } break; case Animation::TYPE_SCALE_3D: { - p_list->push_back(PropertyInfo(Variant::VECTOR3, "scale")); + p_list->push_back(PropertyInfo(Variant::VECTOR3, PNAME("scale"))); } break; case Animation::TYPE_BLEND_SHAPE: { - p_list->push_back(PropertyInfo(Variant::FLOAT, "value")); + p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("value"))); } break; case Animation::TYPE_VALUE: { Variant v = animation->track_get_key_value(track, key); if (hint.type != Variant::NIL) { PropertyInfo pi = hint; - pi.name = "value"; + pi.name = PNAME("value"); p_list->push_back(pi); } else { PropertyHint val_hint = PROPERTY_HINT_NONE; @@ -599,14 +599,14 @@ public: } if (v.get_type() != Variant::NIL) { - p_list->push_back(PropertyInfo(v.get_type(), "value", val_hint, val_hint_string)); + p_list->push_back(PropertyInfo(v.get_type(), PNAME("value"), val_hint, val_hint_string)); } } } break; case Animation::TYPE_METHOD: { - p_list->push_back(PropertyInfo(Variant::STRING_NAME, "name")); - p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,32,1,or_greater")); + p_list->push_back(PropertyInfo(Variant::STRING_NAME, PNAME("name"))); + p_list->push_back(PropertyInfo(Variant::INT, PNAME("arg_count"), PROPERTY_HINT_RANGE, "0,32,1,or_greater")); Dictionary d = animation->track_get_key_value(track, key); ERR_FAIL_COND(!d.has("args")); @@ -620,24 +620,24 @@ public: } for (int i = 0; i < args.size(); i++) { - p_list->push_back(PropertyInfo(Variant::INT, "args/" + itos(i) + "/type", PROPERTY_HINT_ENUM, vtypes)); + p_list->push_back(PropertyInfo(Variant::INT, vformat("%s/%d/%s", PNAME("args"), i, PNAME("type")), PROPERTY_HINT_ENUM, vtypes)); if (args[i].get_type() != Variant::NIL) { - p_list->push_back(PropertyInfo(args[i].get_type(), "args/" + itos(i) + "/value")); + p_list->push_back(PropertyInfo(args[i].get_type(), vformat("%s/%d/%s", PNAME("args"), i, PNAME("value")))); } } } break; case Animation::TYPE_BEZIER: { - p_list->push_back(PropertyInfo(Variant::FLOAT, "value")); - p_list->push_back(PropertyInfo(Variant::VECTOR2, "in_handle")); - p_list->push_back(PropertyInfo(Variant::VECTOR2, "out_handle")); - p_list->push_back(PropertyInfo(Variant::INT, "handle_mode", PROPERTY_HINT_ENUM, "Free,Balanced")); + p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("value"))); + p_list->push_back(PropertyInfo(Variant::VECTOR2, PNAME("in_handle"))); + p_list->push_back(PropertyInfo(Variant::VECTOR2, PNAME("out_handle"))); + p_list->push_back(PropertyInfo(Variant::INT, PNAME("handle_mode"), PROPERTY_HINT_ENUM, "Free,Balanced")); } break; case Animation::TYPE_AUDIO: { - p_list->push_back(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream")); - p_list->push_back(PropertyInfo(Variant::FLOAT, "start_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater")); - p_list->push_back(PropertyInfo(Variant::FLOAT, "end_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater")); + p_list->push_back(PropertyInfo(Variant::OBJECT, PNAME("stream"), PROPERTY_HINT_RESOURCE_TYPE, "AudioStream")); + p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("start_offset"), PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater")); + p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("end_offset"), PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater")); } break; case Animation::TYPE_ANIMATION: { @@ -663,13 +663,13 @@ public: } animations += "[stop]"; - p_list->push_back(PropertyInfo(Variant::STRING_NAME, "animation", PROPERTY_HINT_ENUM, animations)); + p_list->push_back(PropertyInfo(Variant::STRING_NAME, PNAME("animation"), PROPERTY_HINT_ENUM, animations)); } break; } if (animation->track_get_type(track) == Animation::TYPE_VALUE) { - p_list->push_back(PropertyInfo(Variant::FLOAT, "easing", PROPERTY_HINT_EXP_EASING)); + p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("easing"), PROPERTY_HINT_EXP_EASING)); } } @@ -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(); - RBSet<int> tracks_added; + HashSet<int> tracks_added; for (const KeyValue<SelectedKey, KeyInfo> &E : selection) { const SelectedKey &sk = E.key; diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index fb908ea573..3469e96a0a 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -138,8 +138,8 @@ bool CreateDialog::_should_hide_type(const String &p_type) const { return true; // Wrong inheritance. } - for (RBSet<StringName>::Element *E = type_blacklist.front(); E; E = E->next()) { - if (ClassDB::is_parent_class(p_type, E->get())) { + for (const StringName &E : type_blacklist) { + if (ClassDB::is_parent_class(p_type, E)) { return true; // Parent type is blacklisted. } } diff --git a/editor/create_dialog.h b/editor/create_dialog.h index 6526116b09..3ab27ea58c 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; - RBSet<StringName> type_blacklist; + HashSet<StringName> type_blacklist; void _update_search(); bool _should_hide_type(const String &p_type) const; diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index 6d7f3f4ae2..c5093494c6 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; - RBSet<String> changed; + HashSet<String> changed; for (int i = 0; i < obj.properties.size(); i++) { PropertyInfo &pinfo = obj.properties[i].first; Variant &var = obj.properties[i].second; @@ -193,8 +193,8 @@ 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 (RBSet<String>::Element *E = changed.front(); E; E = E->next()) { - emit_signal(SNAME("object_property_updated"), debugObj->remote_object_id, E->get()); + for (const String &E : changed) { + emit_signal(SNAME("object_property_updated"), debugObj->remote_object_id, E); } } else { //full update, because props were added or removed diff --git a/editor/debugger/editor_debugger_inspector.h b/editor/debugger/editor_debugger_inspector.h index 72b259c8b5..0e73928558 100644 --- a/editor/debugger/editor_debugger_inspector.h +++ b/editor/debugger/editor_debugger_inspector.h @@ -69,7 +69,7 @@ class EditorDebuggerInspector : public EditorInspector { private: ObjectID inspected_object_id; HashMap<ObjectID, EditorDebuggerRemoteObject *> remote_objects; - RBSet<Ref<Resource>> remote_dependencies; + HashSet<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 de26b56ab6..bc28b11a71 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -118,8 +118,8 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() { } if (!debugger_plugins.is_empty()) { - for (RBSet<Ref<Script>>::Element *i = debugger_plugins.front(); i; i = i->next()) { - node->add_debugger_plugin(i->get()); + for (const Ref<Script> &i : debugger_plugins) { + node->add_debugger_plugin(i); } } diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index 40e9cf47f9..87457fc09a 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -112,7 +112,7 @@ private: CameraOverride camera_override = OVERRIDE_NONE; HashMap<Breakpoint, bool, Breakpoint> breakpoints; - RBSet<Ref<Script>> debugger_plugins; + HashSet<Ref<Script>> debugger_plugins; ScriptEditorDebugger *_add_debugger(); EditorDebuggerRemoteObject *get_inspected_remote_object(); diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h index 8ba03367c9..4e38f00ffa 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; - RBSet<ObjectID> unfold_cache; + HashSet<ObjectID> unfold_cache; PopupMenu *item_menu = nullptr; EditorFileDialog *file_dialog = nullptr; String last_filter; diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp index 897c5ae7da..ed451ed68e 100644 --- a/editor/debugger/editor_performance_profiler.cpp +++ b/editor/debugger/editor_performance_profiler.cpp @@ -203,7 +203,7 @@ void EditorPerformanceProfiler::_monitor_draw() { } void EditorPerformanceProfiler::_build_monitor_tree() { - RBSet<StringName> monitor_checked; + HashSet<StringName> monitor_checked; for (KeyValue<StringName, Monitor> &E : monitors) { if (E.value.item && E.value.item->is_checked(0)) { monitor_checked.insert(E.key); diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 55c3c7af78..f2bb63e528 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -198,13 +198,13 @@ void EditorProfiler::_update_plot() { for (int i = 0; i < total_metrics; i++) { const Metric &m = _get_frame_metric(i); - for (RBSet<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) { - HashMap<StringName, Metric::Category *>::ConstIterator F = m.category_ptrs.find(E->get()); + for (const StringName &E : plot_sigs) { + HashMap<StringName, Metric::Category *>::ConstIterator F = m.category_ptrs.find(E); if (F) { highest = MAX(F->value->total_time, highest); } - HashMap<StringName, Metric::Category::Item *>::ConstIterator G = m.item_ptrs.find(E->get()); + HashMap<StringName, Metric::Category::Item *>::ConstIterator G = m.item_ptrs.find(E); if (G) { if (use_self) { highest = MAX(G->value->self, highest); @@ -234,17 +234,17 @@ void EditorProfiler::_update_plot() { int current = i * frame_metrics.size() / w; - for (RBSet<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) { + for (const StringName &E : plot_sigs) { const Metric &m = _get_frame_metric(current); float value = 0; - HashMap<StringName, Metric::Category *>::ConstIterator F = m.category_ptrs.find(E->get()); + HashMap<StringName, Metric::Category *>::ConstIterator F = m.category_ptrs.find(E); if (F) { value = F->value->total_time; } - HashMap<StringName, Metric::Category::Item *>::ConstIterator G = m.item_ptrs.find(E->get()); + HashMap<StringName, Metric::Category::Item *>::ConstIterator G = m.item_ptrs.find(E); if (G) { if (use_self) { value = G->value->self; @@ -256,12 +256,12 @@ void EditorProfiler::_update_plot() { int plot_pos = CLAMP(int(value * h / highest), 0, h - 1); int prev_plot = plot_pos; - HashMap<StringName, int>::Iterator H = prev_plots.find(E->get()); + HashMap<StringName, int>::Iterator H = prev_plots.find(E); if (H) { prev_plot = H->value; H->value = plot_pos; } else { - prev_plots[E->get()] = plot_pos; + prev_plots[E] = plot_pos; } plot_pos = h - plot_pos - 1; @@ -271,7 +271,7 @@ void EditorProfiler::_update_plot() { SWAP(prev_plot, plot_pos); } - Color col = _get_color_from_signature(E->get()); + Color col = _get_color_from_signature(E); for (int j = prev_plot; j <= plot_pos; j++) { column[j * 4 + 0] += Math::fast_ftoi(CLAMP(col.r * 255, 0, 255)); @@ -515,7 +515,7 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const { } // Different metrics may contain different number of categories. - RBSet<StringName> possible_signatures; + HashSet<StringName> possible_signatures; for (int i = 0; i < frame_metrics.size(); i++) { const Metric &m = frame_metrics[i]; if (!m.valid) { @@ -534,9 +534,9 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const { Vector<String> signatures; signatures.resize(possible_signatures.size()); int sig_index = 0; - 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; + for (const StringName &E : possible_signatures) { + signatures.write[sig_index] = E; + sig_map[E] = sig_index; sig_index++; } res.push_back(signatures); diff --git a/editor/debugger/editor_profiler.h b/editor/debugger/editor_profiler.h index 77fbb254dc..cb01a1819f 100644 --- a/editor/debugger/editor_profiler.h +++ b/editor/debugger/editor_profiler.h @@ -98,7 +98,7 @@ private: Tree *variables = nullptr; HSplitContainer *h_split = nullptr; - RBSet<StringName> plot_sigs; + HashSet<StringName> plot_sigs; OptionButton *display_mode = nullptr; OptionButton *display_time = nullptr; diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index 65216d7664..e6cd1e0b48 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()) { - RBSet<StringName> setters_getters; + HashSet<StringName> setters_getters; String name = classes.front()->get(); if (!ClassDB::is_class_exposed(name)) { diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index cd5a4f16e4..88ad2633c0 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -161,7 +161,7 @@ EditorAbout::EditorAbout() { TabContainer *tc = memnew(TabContainer); tc->set_tab_alignment(TabBar::ALIGNMENT_CENTER); - tc->set_custom_minimum_size(Size2(950, 400) * EDSCALE); + tc->set_custom_minimum_size(Size2(400, 200) * EDSCALE); tc->set_v_size_flags(Control::SIZE_EXPAND_FILL); vbc->add_child(tc); @@ -196,6 +196,7 @@ EditorAbout::EditorAbout() { // License _license_text = memnew(RichTextLabel); + _license_text->set_threaded(true); _license_text->set_name(TTR("License")); _license_text->set_h_size_flags(Control::SIZE_EXPAND_FILL); _license_text->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -272,6 +273,7 @@ EditorAbout::EditorAbout() { tpl_hbc->add_child(_tpl_tree); _tpl_text = memnew(RichTextLabel); + _tpl_text->set_threaded(true); _tpl_text->set_h_size_flags(Control::SIZE_EXPAND_FILL); _tpl_text->set_v_size_flags(Control::SIZE_EXPAND_FILL); tpl_hbc->add_child(_tpl_text); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 93b155bcd2..ef29448854 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -62,7 +62,7 @@ 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; - RBSet<String> files_sorted; + HashSet<String> files_sorted; Ref<FileAccess> io_fa; zlib_filefunc_def io = zipio_create_io(&io_fa); @@ -154,8 +154,8 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { int num_file_conflicts = 0; - for (RBSet<String>::Element *E = files_sorted.front(); E; E = E->next()) { - String path = E->get(); + for (const String &E : files_sorted) { + String path = E; int depth = p_depth; bool skip = false; while (depth > 0) { @@ -224,7 +224,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { ti->set_metadata(0, res_path); } - status_map[E->get()] = ti; + status_map[E] = ti; } if (num_file_conflicts >= 1) { diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 0bb48db09e..64c234a07c 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -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, RBSet<String> &checked_paths) { +bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, HashSet<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; } - RBSet<String> checked_scenes; + HashSet<String> checked_scenes; bool must_reload = _find_updated_instances(edited_scene[p_idx].root, edited_scene[p_idx].root, checked_scenes); diff --git a/editor/editor_data.h b/editor/editor_data.h index b9eb199c37..351c63f4b9 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -139,7 +139,7 @@ private: Vector<EditedScene> edited_scene; int current_edited_scene; - bool _find_updated_instances(Node *p_root, Node *p_node, RBSet<String> &checked_paths); + bool _find_updated_instances(Node *p_root, Node *p_node, HashSet<String> &checked_paths); HashMap<StringName, String> _script_class_icon_paths; HashMap<String, StringName> _script_class_file_to_path; diff --git a/editor/editor_dir_dialog.h b/editor/editor_dir_dialog.h index 60abfeb66f..95ca0d32b9 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; - RBSet<String> opened_paths; + HashSet<String> opened_paths; Tree *tree = nullptr; bool updating = false; diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index f0eea50d3a..f4a81521df 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -95,9 +95,9 @@ Ref<EditorExportPlatform> EditorExportPreset::get_platform() const { void EditorExportPreset::update_files_to_export() { Vector<String> to_remove; - for (RBSet<String>::Element *E = selected_files.front(); E; E = E->next()) { - if (!FileAccess::exists(E->get())) { - to_remove.push_back(E->get()); + for (const String &E : selected_files) { + if (!FileAccess::exists(E)) { + to_remove.push_back(E); } } for (int i = 0; i < to_remove.size(); ++i) { @@ -107,8 +107,8 @@ void EditorExportPreset::update_files_to_export() { Vector<String> EditorExportPreset::get_files_to_export() const { Vector<String> files; - for (RBSet<String>::Element *E = selected_files.front(); E; E = E->next()) { - files.push_back(E->get()); + for (const String &E : selected_files) { + files.push_back(E); } return files; } @@ -446,7 +446,7 @@ Ref<EditorExportPreset> EditorExportPlatform::create_preset() { return preset; } -void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir, RBSet<String> &p_paths) { +void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir, HashSet<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, RBSet<String> &p_paths) { +void EditorExportPlatform::_export_find_dependencies(const String &p_path, HashSet<String> &p_paths) { if (p_paths.has(p_path)) { return; } @@ -480,7 +480,7 @@ void EditorExportPlatform::_export_find_dependencies(const String &p_path, RBSet } } -void EditorExportPlatform::_edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, RBSet<String> &r_list, bool exclude) { +void EditorExportPlatform::_edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, HashSet<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(RBSet<String> &r_list, const String &p_filter, bool exclude) { +void EditorExportPlatform::_edit_filter_list(HashSet<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 RBSet<String> &p_features) { +void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) { } -void EditorExportPlugin::_export_begin(const RBSet<String> &p_features, bool p_debug, const String &p_path, int p_flags) { +void EditorExportPlugin::_export_begin(const HashSet<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 - RBSet<String> paths; + HashSet<String> paths; Vector<String> path_remaps; if (p_preset->get_export_filter() == EditorExportPreset::EXPORT_ALL_RESOURCES) { @@ -872,15 +872,15 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } FeatureContainers feature_containers = get_feature_containers(p_preset, p_debug); - RBSet<String> &features = feature_containers.features; + HashSet<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 (RBSet<String>::Element *E = paths.front(); E; E = E->next()) { - String path = E->get(); + for (const String &E : paths) { + String path = E; String type = ResourceLoader::get_resource_type(path); if (FileAccess::exists(path + ".import")) { @@ -910,7 +910,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & List<String> remaps; config->get_section_keys("remap", &remaps); - RBSet<String> remap_features; + HashSet<String> remap_features; for (const String &F : remaps) { String remap = F; @@ -1934,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, RBSet<String> &p_features) { +void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) { if (p_features.has("bptc")) { if (p_preset->has("texture_format/no_bptc_fallbacks")) { p_features.erase("s3tc"); @@ -1952,7 +1952,7 @@ void EditorExportPlatformPC::set_chmod_flags(int p_flags) { /////////////////////// -void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const RBSet<String> &p_features) { +void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const HashSet<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 3b8ff0f686..daf6d8ef23 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -66,7 +66,7 @@ private: String export_path; String exporter; - RBSet<String> selected_files; + HashSet<String> selected_files; bool runnable = false; friend class EditorExport; @@ -196,19 +196,19 @@ private: }; struct FeatureContainers { - RBSet<String> features; + HashSet<String> features; Vector<String> features_pv; }; - void _export_find_resources(EditorFileSystemDirectory *p_dir, RBSet<String> &p_paths); - void _export_find_dependencies(const String &p_path, RBSet<String> &p_paths); + void _export_find_resources(EditorFileSystemDirectory *p_dir, HashSet<String> &p_paths); + void _export_find_dependencies(const String &p_path, HashSet<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, RBSet<String> &r_list, bool exclude); - void _edit_filter_list(RBSet<String> &r_list, const String &p_filter, bool exclude); + void _edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, HashSet<String> &r_list, bool exclude); + void _edit_filter_list(HashSet<String> &r_list, const String &p_filter, bool exclude); static Error _add_shared_object(void *p_userdata, const SharedObject &p_so); @@ -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, RBSet<String> &p_features) = 0; + virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<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 RBSet<String> &p_features); - virtual void _export_begin(const RBSet<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 HashSet<String> &p_features); + virtual void _export_begin(const HashSet<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, RBSet<String> &p_features) override; + virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<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 RBSet<String> &p_features) override; + virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) override; EditorExportTextSceneToBinaryPlugin(); }; diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 7eb5aec5d0..f8fc28c31c 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] = RBSet<StringName>(); + disabled_properties[p_class] = HashSet<StringName>(); } disabled_properties[p_class].insert(p_property); @@ -166,24 +166,24 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) { Dictionary data; data["type"] = "feature_profile"; Array dis_classes; - for (RBSet<StringName>::Element *E = disabled_classes.front(); E; E = E->next()) { - dis_classes.push_back(String(E->get())); + for (const StringName &E : disabled_classes) { + dis_classes.push_back(String(E)); } dis_classes.sort(); data["disabled_classes"] = dis_classes; Array dis_editors; - for (RBSet<StringName>::Element *E = disabled_editors.front(); E; E = E->next()) { - dis_editors.push_back(String(E->get())); + for (const StringName &E : disabled_editors) { + dis_editors.push_back(String(E)); } dis_editors.sort(); data["disabled_editors"] = dis_editors; Array dis_props; - 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())); + for (KeyValue<StringName, HashSet<StringName>> &E : disabled_properties) { + for (const StringName &F : E.value) { + dis_props.push_back(String(E.key) + ":" + String(F)); } } diff --git a/editor/editor_feature_profile.h b/editor/editor_feature_profile.h index 479baf5205..dab6c951e4 100644 --- a/editor/editor_feature_profile.h +++ b/editor/editor_feature_profile.h @@ -56,11 +56,11 @@ public: }; private: - RBSet<StringName> disabled_classes; - RBSet<StringName> disabled_editors; - HashMap<StringName, RBSet<StringName>> disabled_properties; + HashSet<StringName> disabled_classes; + HashSet<StringName> disabled_editors; + HashMap<StringName, HashSet<StringName>> disabled_properties; - RBSet<StringName> collapsed_classes; + HashSet<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 56edb03184..f9a4c14c48 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1458,8 +1458,8 @@ 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 (RBSet<String>::Element *E = late_update_files.front(); E; E = E->next()) { - f->store_line(E->get()); + for (const String &E : late_update_files) { + f->store_line(E); } } @@ -1636,7 +1636,7 @@ void EditorFileSystem::update_file(const String &p_file) { _queue_update_script_classes(); } -RBSet<String> EditorFileSystem::get_valid_extensions() const { +HashSet<String> EditorFileSystem::get_valid_extensions() const { return valid_extensions; } @@ -2047,7 +2047,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<String EditorResourcePreview::get_singleton()->check_for_invalidation(p_file); } -void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, HashMap<String, Vector<String>> &group_files, RBSet<String> &groups_to_reimport) { +void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, HashMap<String, Vector<String>> &group_files, HashSet<String> &groups_to_reimport) { int fc = efd->files.size(); const EditorFileSystemDirectory::FileInfo *const *files = efd->files.ptr(); for (int i = 0; i < fc; i++) { @@ -2079,7 +2079,7 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { Vector<ImportFile> reimport_files; - RBSet<String> groups_to_reimport; + HashSet<String> groups_to_reimport; for (int i = 0; i < p_files.size(); i++) { String file = p_files[i]; @@ -2290,7 +2290,7 @@ ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const } } -static void _scan_extensions_dir(EditorFileSystemDirectory *d, RBSet<String> &extensions) { +static void _scan_extensions_dir(EditorFileSystemDirectory *d, HashSet<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, RBSet<String> &ex } bool EditorFileSystem::_scan_extensions() { EditorFileSystemDirectory *d = get_filesystem(); - RBSet<String> extensions; + HashSet<String> extensions; _scan_extensions_dir(d, extensions); diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 743684a9ca..07b1132046 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -34,7 +34,7 @@ #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/hash_set.h" #include "core/templates/safe_refcount.h" #include "core/templates/thread_work_pool.h" #include "scene/main/node.h" @@ -180,7 +180,7 @@ class EditorFileSystem : public Node { void _scan_filesystem(); - RBSet<String> late_update_files; + HashSet<String> late_update_files; void _save_late_updated_files(); @@ -221,9 +221,9 @@ class EditorFileSystem : public Node { void _delete_internal_files(String p_file); - RBSet<String> textfile_extensions; - RBSet<String> valid_extensions; - RBSet<String> import_extensions; + HashSet<String> textfile_extensions; + HashSet<String> valid_extensions; + HashSet<String> import_extensions; void _scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAccess> &da, const ScanProgress &p_progress); @@ -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, HashMap<String, Vector<String>> &group_files, RBSet<String> &groups_to_reimport); + void _find_group_files(EditorFileSystemDirectory *efd, HashMap<String, Vector<String>> &group_files, HashSet<String> &groups_to_reimport); void _move_group_files(EditorFileSystemDirectory *efd, const String &p_group_file, const String &p_new_location); - RBSet<String> group_file_cache; + HashSet<String> group_file_cache; ThreadWorkPool import_threads; @@ -306,7 +306,7 @@ public: void scan(); void scan_changes(); void update_file(const String &p_file); - RBSet<String> get_valid_extensions() const; + HashSet<String> get_valid_extensions() const; EditorFileSystemDirectory *get_filesystem_path(const String &p_path); String get_file_type(const String &p_file) const; diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index 39dc253429..9e1b361f64 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -40,8 +40,8 @@ Vector<String> EditorFolding::_get_unfolds(const Object *p_object) { if (sections.size()) { String *w = sections.ptrw(); int idx = 0; - for (const RBSet<String>::Element *E = p_object->editor_get_section_folding().front(); E; E = E->next()) { - w[idx++] = E->get(); + for (const String &E : p_object->editor_get_section_folding()) { + w[idx++] = E; } } @@ -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, RBSet<Ref<Resource>> &resources) { +void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p_folds, Array &resource_folds, Array &nodes_folded, HashSet<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; - RBSet<Ref<Resource>> resources; + HashSet<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, RBSet<Ref<Resource>> &resources) { +void EditorFolding::_do_object_unfolds(Object *p_object, HashSet<Ref<Resource>> &resources) { List<PropertyInfo> plist; p_object->get_property_list(&plist); String group_base; String group; - RBSet<String> unfold_group; + HashSet<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, RBSet<Ref<Resource>> &r } } - for (RBSet<String>::Element *E = unfold_group.front(); E; E = E->next()) { - p_object->editor_set_section_unfold(E->get(), true); + for (const String &E : unfold_group) { + p_object->editor_set_section_unfold(E, true); } } -void EditorFolding::_do_node_unfolds(Node *p_root, Node *p_node, RBSet<Ref<Resource>> &resources) { +void EditorFolding::_do_node_unfolds(Node *p_root, Node *p_node, HashSet<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, RBSet<Ref<Resou } void EditorFolding::unfold_scene(Node *p_scene) { - RBSet<Ref<Resource>> resources; + HashSet<Ref<Resource>> resources; _do_node_unfolds(p_scene, p_scene, resources); } diff --git a/editor/editor_folding.h b/editor/editor_folding.h index 22df06280a..9a2aa37b80 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, RBSet<Ref<Resource>> &resources); + void _fill_folds(const Node *p_root, const Node *p_node, Array &p_folds, Array &resource_folds, Array &nodes_folded, HashSet<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); + void _do_object_unfolds(Object *p_object, HashSet<Ref<Resource>> &resources); + void _do_node_unfolds(Node *p_root, Node *p_node, HashSet<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 e33d160762..dba0864fcb 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -127,30 +127,35 @@ void EditorHelp::_class_desc_select(const String &p_select) { 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 { + // Look for link in @GlobalScope. + // Note that a link like @GlobalScope.enum_name will not be found in this section, only enum_name will be. + if (topic == "class_enum") { + 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); + return; + } } - } - } 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 (topic == "class_constant") { + 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); + return; + } } } - } else if (link.contains(".")) { - emit_signal(SNAME("go_to_help"), topic + ":" + link.get_slice(".", 0) + ":" + link.get_slice(".", 1)); + + if (link.contains(".")) { + int class_end = link.find("."); + emit_signal(SNAME("go_to_help"), topic + ":" + link.substr(0, class_end) + ":" + link.substr(class_end + 1, link.length())); + } } } else if (p_select.begins_with("http")) { OS::get_singleton()->shell_open(p_select); @@ -235,7 +240,7 @@ String EditorHelp::_fix_constant(const String &p_constant) const { } void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview) { - method_line[p_method.name] = class_desc->get_line_count() - 2; //gets overridden if description + method_line[p_method.name] = class_desc->get_paragraph_count() - 2; //gets overridden if description const bool is_vararg = p_method.qualifiers.contains("vararg"); @@ -593,8 +598,8 @@ void EditorHelp::_update_doc() { // Class description if (!cd.description.is_empty()) { - section_line.push_back(Pair<String, int>(TTR("Description"), class_desc->get_line_count() - 2)); - description_line = class_desc->get_line_count() - 2; + section_line.push_back(Pair<String, int>(TTR("Description"), class_desc->get_paragraph_count() - 2)); + description_line = class_desc->get_paragraph_count() - 2; class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Description")); @@ -648,7 +653,7 @@ void EditorHelp::_update_doc() { } // Properties overview - RBSet<String> skip_methods; + HashSet<String> skip_methods; bool property_descr = false; bool has_properties = cd.properties.size() != 0; @@ -664,7 +669,7 @@ void EditorHelp::_update_doc() { } if (has_properties) { - section_line.push_back(Pair<String, int>(TTR("Properties"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Properties"), class_desc->get_paragraph_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Properties")); @@ -682,7 +687,7 @@ void EditorHelp::_update_doc() { if (cd.properties[i].name.begins_with("_") && cd.properties[i].description.is_empty()) { continue; } - property_line[cd.properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description + property_line[cd.properties[i].name] = class_desc->get_paragraph_count() - 2; //gets overridden if description // Property type. class_desc->push_cell(); @@ -828,7 +833,7 @@ void EditorHelp::_update_doc() { cd.constructors.sort(); } - section_line.push_back(Pair<String, int>(TTR("Constructors"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Constructors"), class_desc->get_paragraph_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Constructors")); @@ -839,7 +844,7 @@ void EditorHelp::_update_doc() { if (sort_methods) { methods.sort(); } - section_line.push_back(Pair<String, int>(TTR("Methods"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Methods"), class_desc->get_paragraph_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Methods")); @@ -851,7 +856,7 @@ void EditorHelp::_update_doc() { cd.operators.sort(); } - section_line.push_back(Pair<String, int>(TTR("Operators"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Operators"), class_desc->get_paragraph_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Operators")); @@ -860,7 +865,7 @@ void EditorHelp::_update_doc() { // Theme properties if (!cd.theme_properties.is_empty()) { - section_line.push_back(Pair<String, int>(TTR("Theme Properties"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Theme Properties"), class_desc->get_paragraph_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Theme Properties")); @@ -882,7 +887,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_paragraph_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; @@ -954,7 +959,7 @@ void EditorHelp::_update_doc() { cd.signals.sort(); } - section_line.push_back(Pair<String, int>(TTR("Signals"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Signals"), class_desc->get_paragraph_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Signals")); @@ -967,7 +972,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_paragraph_count() - 2; // Gets overridden if description. class_desc->push_font(doc_code_font); // monofont class_desc->push_color(headline_color); @@ -1040,7 +1045,7 @@ void EditorHelp::_update_doc() { // Enums if (enums.size()) { - section_line.push_back(Pair<String, int>(TTR("Enumerations"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Enumerations"), class_desc->get_paragraph_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Enumerations")); @@ -1051,7 +1056,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); for (KeyValue<String, Vector<DocData::ConstantDoc>> &E : enums) { - enum_line[E.key] = class_desc->get_line_count() - 2; + enum_line[E.key] = class_desc->get_paragraph_count() - 2; class_desc->push_font(doc_code_font); class_desc->push_color(title_color); @@ -1098,7 +1103,7 @@ void EditorHelp::_update_doc() { } // 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; + constant_line[enum_list[i].name] = class_desc->get_paragraph_count() - 2; class_desc->push_font(doc_code_font); class_desc->push_color(headline_color); @@ -1144,7 +1149,7 @@ void EditorHelp::_update_doc() { // Constants if (constants.size()) { - section_line.push_back(Pair<String, int>(TTR("Constants"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Constants"), class_desc->get_paragraph_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Constants")); @@ -1155,7 +1160,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); for (int i = 0; i < constants.size(); i++) { - constant_line[constants[i].name] = class_desc->get_line_count() - 2; + constant_line[constants[i].name] = class_desc->get_paragraph_count() - 2; class_desc->push_font(doc_code_font); if (constants[i].value.begins_with("Color(") && constants[i].value.ends_with(")")) { @@ -1205,7 +1210,7 @@ void EditorHelp::_update_doc() { // Property descriptions if (property_descr) { - section_line.push_back(Pair<String, int>(TTR("Property Descriptions"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Property Descriptions"), class_desc->get_paragraph_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Property Descriptions")); @@ -1220,7 +1225,7 @@ void EditorHelp::_update_doc() { continue; } - property_line[cd.properties[i].name] = class_desc->get_line_count() - 2; + property_line[cd.properties[i].name] = class_desc->get_paragraph_count() - 2; class_desc->push_table(2); class_desc->set_table_column_expand(1, true); @@ -1371,7 +1376,7 @@ void EditorHelp::_update_doc() { // Constructor descriptions if (constructor_descriptions) { - section_line.push_back(Pair<String, int>(TTR("Constructor Descriptions"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Constructor Descriptions"), class_desc->get_paragraph_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Constructor Descriptions")); @@ -1380,7 +1385,7 @@ void EditorHelp::_update_doc() { // Method descriptions if (method_descriptions) { - section_line.push_back(Pair<String, int>(TTR("Method Descriptions"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Method Descriptions"), class_desc->get_paragraph_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Method Descriptions")); @@ -1389,7 +1394,7 @@ void EditorHelp::_update_doc() { // Operator descriptions if (operator_descriptions) { - section_line.push_back(Pair<String, int>(TTR("Operator Descriptions"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Operator Descriptions"), class_desc->get_paragraph_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Operator Descriptions")); @@ -1868,6 +1873,7 @@ EditorHelp::EditorHelp() { class_desc = memnew(RichTextLabel); add_child(class_desc); + class_desc->set_threaded(true); class_desc->set_v_size_flags(SIZE_EXPAND_FILL); class_desc->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4)); diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index b85147fddf..f454ba2c41 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -333,7 +333,7 @@ bool EditorHelpSearch::Runner::_phase_match_classes() { // Match class name. if (search_flags & SEARCH_CLASSES) { // If the search term is empty, add any classes which are not script docs or which don't start with - // a double-quotation. This will ensure that only C++ classes and explictly named classes will + // a double-quotation. This will ensure that only C++ classes and explicitly named classes will // be added. match.name = (term.is_empty() && (!class_doc.is_script_doc || class_doc.name[0] != '\"')) || _match_string(term, class_doc.name); } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index f534130735..4bc37456d5 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -839,7 +839,7 @@ void EditorProperty::_update_pin_flags() { } pin_hidden = false; { - RBSet<StringName> storable_properties; + HashSet<StringName> storable_properties; node->get_storable_properties(storable_properties); if (storable_properties.has(node->get_property_store_alias(property))) { can_pin = true; @@ -3543,7 +3543,7 @@ void EditorInspector::_notification(int p_what) { } else { while (pending.size()) { - StringName prop = pending.front()->get(); + StringName prop = *pending.begin(); if (editor_property_map.has(prop)) { for (EditorProperty *E : editor_property_map[prop]) { E->update_property(); @@ -3551,7 +3551,7 @@ void EditorInspector::_notification(int p_what) { E->update_cache(); } } - pending.erase(pending.front()); + pending.remove(pending.begin()); } } @@ -3638,7 +3638,7 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li break; } - RBSet<StringName> added; + HashSet<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 7609f4fdcc..30c0cffe40 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -437,7 +437,7 @@ class EditorInspector : public ScrollContainer { //map use to cache the instantiated editors HashMap<StringName, List<EditorProperty *>> editor_property_map; List<EditorInspectorSection *> sections; - RBSet<StringName> pending; + HashSet<StringName> pending; void _clear(); Object *object = nullptr; @@ -470,7 +470,7 @@ class EditorInspector : public ScrollContainer { HashMap<StringName, HashMap<StringName, String>> descr_cache; HashMap<StringName, String> class_descr_cache; - RBSet<StringName> restart_request_props; + HashSet<StringName> restart_request_props; HashMap<ObjectID, int> scroll_cache; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 0b96900053..4998cc82e8 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -231,8 +231,8 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto RBSet<int> iset = index_sets[i]; while (iset.size() > 1) { // Append the parent folder to each scene name. - for (RBSet<int>::Element *E = iset.front(); E; E = E->next()) { - int set_idx = E->get(); + for (const int &E : iset) { + int set_idx = E; String scene_name = r_filenames[set_idx]; String full_path = p_full_paths[set_idx]; @@ -270,11 +270,11 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto while (E) { String scene_name = r_filenames[E->get()]; bool duplicate_found = false; - for (RBSet<int>::Element *F = iset.front(); F; F = F->next()) { - if (E->get() == F->get()) { + for (const int &F : iset) { + if (E->get() == F) { continue; } - String other_scene_name = r_filenames[F->get()]; + String other_scene_name = r_filenames[F]; if (other_scene_name == scene_name) { duplicate_found = true; break; @@ -800,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"))); } - RBSet<String> updated_textfile_extensions; + HashSet<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) { @@ -907,12 +907,12 @@ void EditorNode::_resources_changed(const Vector<String> &p_resources) { } void EditorNode::_fs_changed() { - for (RBSet<FileDialog *>::Element *E = file_dialogs.front(); E; E = E->next()) { - E->get()->invalidate(); + for (FileDialog *E : file_dialogs) { + E->invalidate(); } - for (RBSet<EditorFileDialog *>::Element *E = editor_file_dialogs.front(); E; E = E->next()) { - E->get()->invalidate(); + for (EditorFileDialog *E : editor_file_dialogs) { + E->invalidate(); } _mark_unsaved_scenes(); @@ -1185,8 +1185,8 @@ 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 (RBSet<String>::Element *E = dependency_errors[p_resource].front(); E; E = E->next()) { - errors.push_back(E->get()); + for (const String &E : dependency_errors[p_resource]) { + errors.push_back(E); } dependency_error->show(DependencyErrorDialog::MODE_RESOURCE, p_resource, errors); dependency_errors.erase(p_resource); @@ -1622,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, RBSet<Ref<Resource>> &edited_resources) { +static bool _find_edited_resources(const Ref<Resource> &p_resource, HashSet<Ref<Resource>> &edited_resources) { if (p_resource->is_edited()) { edited_resources.insert(p_resource); return true; @@ -1659,7 +1659,7 @@ int EditorNode::_save_external_resources() { } flg |= ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS; - RBSet<Ref<Resource>> edited_subresources; + HashSet<Ref<Resource>> edited_subresources; int saved = 0; List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); @@ -1677,8 +1677,8 @@ 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 (RBSet<Ref<Resource>>::Element *E = edited_subresources.front(); E; E = E->next()) { - Ref<Resource> res = E->get(); + for (const Ref<Resource> &E : edited_subresources) { + Ref<Resource> res = E; res->set_edited(false); } @@ -3663,8 +3663,8 @@ 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 (RBSet<String>::Element *E = dependency_errors[lpath].front(); E; E = E->next()) { - errors.push_back(E->get()); + for (const String &E : dependency_errors[lpath]) { + errors.push_back(E); } dependency_error->show(DependencyErrorDialog::MODE_SCENE, lpath, errors); opening_prev = false; @@ -3678,10 +3678,10 @@ 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, RBSet<String>> &E : dependency_errors) { + for (KeyValue<String, HashSet<String>> &E : dependency_errors) { String txt = vformat(TTR("Scene '%s' has broken dependencies:"), E.key) + "\n"; - for (RBSet<String>::Element *F = E.value.front(); F; F = F->next()) { - txt += "\t" + F->get() + "\n"; + for (const String &F : E.value) { + txt += "\t" + F + "\n"; } add_io_error(txt); } diff --git a/editor/editor_node.h b/editor/editor_node.h index 9cd96050e3..48df767562 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -394,7 +394,7 @@ private: BackgroundProgress *progress_hb = nullptr; DependencyErrorDialog *dependency_error = nullptr; - HashMap<String, RBSet<String>> dependency_errors; + HashMap<String, HashSet<String>> dependency_errors; DependencyEditor *dependency_fixer = nullptr; OrphanResourcesDialog *orphan_resources = nullptr; ConfirmationDialog *open_imported = nullptr; @@ -470,9 +470,9 @@ private: String import_reload_fn; - RBSet<String> textfile_extensions; - RBSet<FileDialog *> file_dialogs; - RBSet<EditorFileDialog *> editor_file_dialogs; + HashSet<String> textfile_extensions; + HashSet<FileDialog *> file_dialogs; + HashSet<EditorFileDialog *> editor_file_dialogs; Vector<Ref<EditorResourceConversionPlugin>> resource_conversion_plugins; PrintHandlerList print_handler; @@ -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] = RBSet<String>(); + en->dependency_errors[p_path] = HashSet<String>(); } en->dependency_errors[p_path].insert(p_dep + "::" + p_type); } diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 9541033fe8..880e51660b 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2229,8 +2229,8 @@ void EditorPropertyPlane::setup(double p_min, double p_max, double p_step, bool spin[i]->set_hide_slider(p_no_slider); spin[i]->set_allow_greater(true); spin[i]->set_allow_lesser(true); - spin[i]->set_suffix(p_suffix); } + spin[3]->set_suffix(p_suffix); } EditorPropertyPlane::EditorPropertyPlane(bool p_force_wide) { @@ -2322,6 +2322,8 @@ void EditorPropertyQuaternion::setup(double p_min, double p_max, double p_step, spin[i]->set_hide_slider(p_no_slider); spin[i]->set_allow_greater(true); spin[i]->set_allow_lesser(true); + // Quaternion is inherently unitless, however someone may want to use it as + // a generic way to store 4 values, so we'll still respect the suffix. spin[i]->set_suffix(p_suffix); } } @@ -2506,7 +2508,9 @@ void EditorPropertyTransform2D::setup(double p_min, double p_max, double p_step, spin[i]->set_hide_slider(p_no_slider); spin[i]->set_allow_greater(true); spin[i]->set_allow_lesser(true); - spin[i]->set_suffix(p_suffix); + if (i % 3 == 2) { + spin[i]->set_suffix(p_suffix); + } } } @@ -2596,6 +2600,8 @@ void EditorPropertyBasis::setup(double p_min, double p_max, double p_step, bool spin[i]->set_hide_slider(p_no_slider); spin[i]->set_allow_greater(true); spin[i]->set_allow_lesser(true); + // Basis is inherently unitless, however someone may want to use it as + // a generic way to store 9 values, so we'll still respect the suffix. spin[i]->set_suffix(p_suffix); } } @@ -2692,7 +2698,9 @@ void EditorPropertyTransform3D::setup(double p_min, double p_max, double p_step, spin[i]->set_hide_slider(p_no_slider); spin[i]->set_allow_greater(true); spin[i]->set_allow_lesser(true); - spin[i]->set_suffix(p_suffix); + if (i % 4 == 3) { + spin[i]->set_suffix(p_suffix); + } } } @@ -2752,7 +2760,13 @@ void EditorPropertyColor::_picker_opening() { last_color = picker->get_pick_color(); } -void EditorPropertyColor::_bind_methods() { +void EditorPropertyColor::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + picker->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); + } break; + } } void EditorPropertyColor::update_property() { @@ -3346,7 +3360,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, const Varian } struct EditorPropertyRangeHint { - bool angle_in_degrees = false; bool greater = true; bool lesser = true; double min = -99999.0; diff --git a/editor/editor_properties.h b/editor/editor_properties.h index ebac984bbd..5ee0ba1a6d 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -667,7 +667,7 @@ class EditorPropertyColor : public EditorProperty { protected: virtual void _set_read_only(bool p_read_only) override; - static void _bind_methods(); + void _notification(int p_what); public: virtual void update_property() override; diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 25016c7f82..608121d806 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -607,11 +607,16 @@ void EditorPropertyArray::_reorder_button_gui_input(const Ref<InputEvent> &p_eve Variant array = object->get_array(); int size = array.call("size"); - if ((reorder_to_index == 0 && mm->get_relative().y < 0.0f) || (reorder_to_index == size - 1 && mm->get_relative().y > 0.0f)) { + // Cumulate the mouse delta, many small changes (dragging slowly) should result in reordering at some point. + reorder_mouse_y_delta += mm->get_relative().y; + + // Reordering is done by moving the dragged element by +1/-1 index at a time based on the cumulated mouse delta so if + // already at the array bounds make sure to ignore the remaining out of bounds drag (by resetting the cumulated delta). + if ((reorder_to_index == 0 && reorder_mouse_y_delta < 0.0f) || (reorder_to_index == size - 1 && reorder_mouse_y_delta > 0.0f)) { + reorder_mouse_y_delta = 0.0f; return; } - reorder_mouse_y_delta += mm->get_relative().y; float required_y_distance = 20.0f * EDSCALE; if (ABS(reorder_mouse_y_delta) > required_y_distance) { int direction = reorder_mouse_y_delta > 0.0f ? 1 : -1; diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 41d769ad1f..34aa7217fa 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -240,7 +240,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { ResourceLoader::get_recognized_extensions_for_type(base, &extensions); } - RBSet<String> valid_extensions; + HashSet<String> valid_extensions; for (const String &E : extensions) { valid_extensions.insert(E); } @@ -253,8 +253,8 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { } file_dialog->clear_filters(); - for (RBSet<String>::Element *E = valid_extensions.front(); E; E = E->next()) { - file_dialog->add_filter("*." + E->get() + " ; " + E->get().to_upper()); + for (const String &E : valid_extensions) { + file_dialog->add_filter("*." + E + " ; " + E.to_upper()); } file_dialog->popup_file_dialog(); @@ -409,7 +409,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) { if (!base_type.is_empty()) { int idx = 0; - RBSet<String> allowed_types; + HashSet<String> allowed_types; _get_allowed_types(false, &allowed_types); Vector<EditorData::CustomType> custom_resources; @@ -417,8 +417,8 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) { custom_resources = EditorNode::get_editor_data().get_custom_types()["Resource"]; } - for (RBSet<String>::Element *E = allowed_types.front(); E; E = E->next()) { - const String &t = E->get(); + for (const String &E : allowed_types) { + const String &t = E; bool is_custom_resource = false; Ref<Texture2D> icon; @@ -491,7 +491,7 @@ void EditorResourcePicker::_button_input(const Ref<InputEvent> &p_event) { } } -void EditorResourcePicker::_get_allowed_types(bool p_with_convert, RBSet<String> *p_vector) const { +void EditorResourcePicker::_get_allowed_types(bool p_with_convert, HashSet<String> *p_vector) const { Vector<String> allowed_types = base_type.split(","); int size = allowed_types.size(); @@ -568,7 +568,7 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { res = drag_data["resource"]; } - RBSet<String> allowed_types; + HashSet<String> allowed_types; _get_allowed_types(true, &allowed_types); if (res.is_valid() && _is_type_valid(res->get_class(), allowed_types)) { @@ -598,9 +598,9 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { return false; } -bool EditorResourcePicker::_is_type_valid(const String p_type_name, 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(); +bool EditorResourcePicker::_is_type_valid(const String p_type_name, HashSet<String> p_allowed_types) const { + for (const String &E : p_allowed_types) { + String at = E.strip_edges(); if (p_type_name == at || ClassDB::is_parent_class(p_type_name, at) || EditorNode::get_editor_data().script_class_is_parent(p_type_name, at)) { return true; } @@ -646,13 +646,13 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ } if (dropped_resource.is_valid()) { - RBSet<String> allowed_types; + HashSet<String> allowed_types; _get_allowed_types(false, &allowed_types); // If the accepted dropped resource is from the extended list, it requires conversion. if (!_is_type_valid(dropped_resource->get_class(), allowed_types)) { - for (RBSet<String>::Element *E = allowed_types.front(); E; E = E->next()) { - String at = E->get().strip_edges(); + for (const String &E : allowed_types) { + String at = E.strip_edges(); if (at == "BaseMaterial3D" && Ref<Texture2D>(dropped_resource).is_valid()) { // Use existing resource if possible and only replace its data. @@ -768,7 +768,7 @@ void EditorResourcePicker::set_base_type(const String &p_base_type) { // There is a possibility that the new base type is conflicting with the existing value. // Keep the value, but warn the user that there is a potential mistake. if (!base_type.is_empty() && edited_resource.is_valid()) { - RBSet<String> allowed_types; + HashSet<String> allowed_types; _get_allowed_types(true, &allowed_types); StringName custom_class; @@ -784,7 +784,7 @@ void EditorResourcePicker::set_base_type(const String &p_base_type) { } } else { // Call the method to build the cache immediately. - RBSet<String> allowed_types; + HashSet<String> allowed_types; _get_allowed_types(false, &allowed_types); } } @@ -794,7 +794,7 @@ String EditorResourcePicker::get_base_type() const { } Vector<String> EditorResourcePicker::get_allowed_types() const { - RBSet<String> allowed_types; + HashSet<String> allowed_types; _get_allowed_types(false, &allowed_types); Vector<String> types; @@ -802,8 +802,9 @@ Vector<String> EditorResourcePicker::get_allowed_types() const { int i = 0; String *w = types.ptrw(); - for (RBSet<String>::Element *E = allowed_types.front(); E; E = E->next(), i++) { - w[i] = E->get(); + for (const String &E : allowed_types) { + w[i] = E; + i++; } return types; @@ -817,7 +818,7 @@ void EditorResourcePicker::set_edited_resource(Ref<Resource> p_resource) { } if (!base_type.is_empty()) { - RBSet<String> allowed_types; + HashSet<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 f2dc45513d..8e26e1f4c0 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, RBSet<String> *p_vector) const; + void _get_allowed_types(bool p_with_convert, HashSet<String> *p_vector) const; bool _is_drop_valid(const Dictionary &p_drag_data) const; - bool _is_type_valid(const String p_type_name, RBSet<String> p_allowed_types) const; + bool _is_type_valid(const String p_type_name, HashSet<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_settings.cpp b/editor/editor_settings.cpp index e251a66610..1eaf60cda3 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -268,25 +268,25 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const { vclist.insert(vc); } - for (RBSet<_EVCSort>::Element *E = vclist.front(); E; E = E->next()) { + for (const _EVCSort &E : vclist) { uint32_t pusage = PROPERTY_USAGE_NONE; - if (E->get().save || !optimize_save) { + if (E.save || !optimize_save) { pusage |= PROPERTY_USAGE_STORAGE; } - if (!E->get().name.begins_with("_") && !E->get().name.begins_with("projects/")) { + if (!E.name.begins_with("_") && !E.name.begins_with("projects/")) { pusage |= PROPERTY_USAGE_EDITOR; } else { pusage |= PROPERTY_USAGE_STORAGE; //hiddens must always be saved } - PropertyInfo pi(E->get().type, E->get().name); + PropertyInfo pi(E.type, E.name); pi.usage = pusage; - if (hints.has(E->get().name)) { - pi = hints[E->get().name]; + if (hints.has(E.name)) { + pi = hints[E.name]; } - if (E->get().restart_if_changed) { + if (E.restart_if_changed) { pi.usage |= PROPERTY_USAGE_RESTART_IF_CHANGED; } @@ -609,9 +609,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // Use a lower default FOV for the 3D camera compared to the // Camera3D node as the 3D viewport doesn't span the whole screen. // This means it's technically viewed from a further distance, which warrants a narrower FOV. - EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/default_fov", 70.0, "1,179,0.1") - EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/default_z_near", 0.05, "0.01,10,0.01,or_greater") - EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/default_z_far", 4000.0, "0.1,4000,0.1,or_greater") + EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/default_fov", 70.0, "1,179,0.1,degrees") + EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/default_z_near", 0.05, "0.01,10,0.01,or_greater,suffix:m") + EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/default_z_far", 4000.0, "0.1,4000,0.1,or_greater,suffix:m") // 3D: Navigation _initial_set("editors/3d/navigation/invert_x_axis", false); diff --git a/editor/editor_settings.h b/editor/editor_settings.h index e270a882e2..43f90f9258 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -34,6 +34,7 @@ #include "core/io/config_file.h" #include "core/io/resource.h" #include "core/os/thread_safe.h" +#include "core/templates/rb_set.h" class EditorPlugin; class InputEvent; @@ -77,7 +78,7 @@ private: static Ref<EditorSettings> singleton; - RBSet<String> changed_settings; + HashSet<String> changed_settings; HashMap<String, PropertyInfo> hints; HashMap<String, VariantContainer> props; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 3b159d9f3d..11fe62b84f 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. - RBSet<StringName> exceptions; + HashSet<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; - RBSet<StringName> accent_color_icons; + HashSet<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; @@ -535,6 +535,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("scale", "Editor", EDSCALE); theme->set_constant("thumb_size", "Editor", thumb_size); theme->set_constant("dark_theme", "Editor", dark_theme); + theme->set_constant("color_picker_button_height", "Editor", 28 * EDSCALE); // Register icons + font diff --git a/editor/editor_translation_parser.cpp b/editor/editor_translation_parser.cpp index 13dff08c14..eb4df3b630 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/rb_set.h" +#include "core/templates/hash_set.h" EditorTranslationParser *EditorTranslationParser::singleton = nullptr; @@ -84,7 +84,7 @@ void EditorTranslationParserPlugin::_bind_methods() { ///////////////////////// void EditorTranslationParser::get_recognized_extensions(List<String> *r_extensions) const { - RBSet<String> extensions; + HashSet<String> extensions; List<String> temp; for (int i = 0; i < standard_parsers.size(); i++) { standard_parsers[i]->get_recognized_extensions(&temp); @@ -96,8 +96,8 @@ void EditorTranslationParser::get_recognized_extensions(List<String> *r_extensio for (int i = 0; i < temp.size(); i++) { extensions.insert(temp[i]); } - for (RBSet<String>::Element *E = extensions.front(); E; E = E->next()) { - r_extensions->push_back(E->get()); + for (const String &E : extensions) { + r_extensions->push_back(E); } } diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 50f03652ee..c6d3843b06 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -35,6 +35,7 @@ #include "core/io/json.h" #include "core/io/zip_io.h" #include "core/os/keyboard.h" +#include "core/templates/rb_set.h" #include "core/version.h" #include "editor/editor_node.h" #include "editor/editor_paths.h" @@ -694,7 +695,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); - RBSet<String> dirs_tested; + HashSet<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 eed3917845..718bcb24cc 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -282,7 +282,7 @@ void EditorFileServer::_thread_start(void *s) { self->wait_mutex.lock(); while (self->to_wait.size()) { - Thread *w = self->to_wait.front()->get(); + Thread *w = *self->to_wait.begin(); self->to_wait.erase(w); self->wait_mutex.unlock(); w->wait_to_finish(); diff --git a/editor/fileserver/editor_file_server.h b/editor/fileserver/editor_file_server.h index 21abbc3f8c..03b6ededab 100644 --- a/editor/fileserver/editor_file_server.h +++ b/editor/fileserver/editor_file_server.h @@ -55,7 +55,7 @@ class EditorFileServer : public Object { }; Ref<TCPServer> server; - RBSet<Thread *> to_wait; + HashSet<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 4c4d38c074..8a995eaa8f 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. - RBSet<String> cselection; + HashSet<String> cselection; if (p_keep_selection) { for (int i = 0; i < files->get_item_count(); i++) { if (files->is_selected(i)) { diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index df3dd3fd69..40e8b1b7c8 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; - RBSet<String> favorites; + HashSet<String> favorites; Button *button_toggle_display_mode = nullptr; Button *button_reload = nullptr; diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index aafaccf5be..d60e336f0f 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 RBSet<String> &exts) { +void FindInFiles::set_filter(const HashSet<String> &exts) { _extension_filter = exts; } @@ -443,9 +443,9 @@ String FindInFilesDialog::get_folder() const { return text.strip_edges(); } -RBSet<String> FindInFilesDialog::get_filter() const { +HashSet<String> FindInFilesDialog::get_filter() const { // Could check the _filters_preferences but it might not have been generated yet. - RBSet<String> filters; + HashSet<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()) { diff --git a/editor/find_in_files.h b/editor/find_in_files.h index 8bc7b506d0..c57a084779 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 RBSet<String> &exts); + void set_filter(const HashSet<String> &exts); String get_search_text() const { return _pattern; } @@ -72,7 +72,7 @@ private: // Config String _pattern; - RBSet<String> _extension_filter; + HashSet<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; - RBSet<String> get_filter() const; + HashSet<String> get_filter() const; protected: void _notification(int p_what); diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index 71b5ddc216..f4d19fe8b6 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -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 - RBSet<NodeSkeleton *> skeletons; + HashSet<NodeSkeleton *> skeletons; for (int i = 0; i < gnode->skeletons.size(); i++) { String nodeid = gnode->skeletons[i]; @@ -2049,11 +2049,11 @@ void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) { if (skeletons.size() > 1) { //do the merger!! - RBSet<NodeSkeleton *>::Element *E = skeletons.front(); - NodeSkeleton *base = E->get(); + HashSet<NodeSkeleton *>::Iterator E = skeletons.begin(); + NodeSkeleton *base = *E; - for (E = E->next(); E; E = E->next()) { - NodeSkeleton *merged = E->get(); + for (++E; E; ++E) { + NodeSkeleton *merged = *E; _remove_node(p_vscene, merged); for (int i = 0; i < merged->children.size(); i++) { _joint_set_owner(merged->children[i], base); diff --git a/editor/import/collada.h b/editor/import/collada.h index 6ac6181769..f1d9c5593f 100644 --- a/editor/import/collada.h +++ b/editor/import/collada.h @@ -493,7 +493,7 @@ public: HashMap<String, VisualScene> visual_scene_map; HashMap<String, Node *> scene_map; - RBSet<String> idref_joints; + HashSet<String> idref_joints; HashMap<String, String> sid_to_node_map; //RBMap<String,NodeJoint*> bone_map; diff --git a/editor/import/dynamic_font_import_settings.h b/editor/import/dynamic_font_import_settings.h index 4e2135a13c..154f347b77 100644 --- a/editor/import/dynamic_font_import_settings.h +++ b/editor/import/dynamic_font_import_settings.h @@ -33,6 +33,7 @@ #include "editor/import/resource_importer_dynamic_font.h" +#include "core/templates/rb_set.h" #include "scene/gui/dialogs.h" #include "scene/gui/item_list.h" #include "scene/gui/option_button.h" diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 8ee47cb6f4..8d44329022 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -76,12 +76,12 @@ struct ColladaImport { HashMap<Skeleton3D *, HashMap<String, int>> skeleton_bone_map; - RBSet<String> valid_animated_nodes; + HashSet<String> valid_animated_nodes; Vector<int> valid_animated_properties; HashMap<String, bool> bones_with_animation; - RBSet<String> mesh_unique_names; - RBSet<String> material_unique_names; + HashSet<String> mesh_unique_names; + HashSet<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); @@ -94,7 +94,7 @@ struct ColladaImport { void create_animation(int p_clip, bool p_import_value_tracks); void create_animations(bool p_import_value_tracks); - RBSet<String> tracks_in_clips; + HashSet<String> tracks_in_clips; Vector<String> missing_textures; void _pre_process_lights(Collada::Node *p_node); @@ -875,8 +875,8 @@ 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 (RBSet<Collada::Vertex>::Element *F = vertex_set.front(); F; F = F->next()) { - vertex_array.write[F->get().idx] = F->get(); + for (const Collada::Vertex &F : vertex_set) { + vertex_array.write[F.idx] = F; } if (has_weights) { @@ -1452,7 +1452,7 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) { //main anim } - RBSet<int> track_filter; + HashSet<int> track_filter; if (p_clip == -1) { for (int i = 0; i < collada.state.animation_clips.size(); i++) { @@ -1507,14 +1507,14 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) { bool tracks_found = false; - for (RBSet<String>::Element *E = valid_animated_nodes.front(); E; E = E->next()) { + for (const String &E : valid_animated_nodes) { // take snapshots - if (!collada.state.scene_map.has(E->get())) { + if (!collada.state.scene_map.has(E)) { continue; } - NodeMap &nm = node_map[E->get()]; + NodeMap &nm = node_map[E]; String path = scene->get_path_to(nm.node); if (nm.bone >= 0) { @@ -1525,7 +1525,7 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) { bool found_anim = false; - Collada::Node *cn = collada.state.scene_map[E->get()]; + Collada::Node *cn = collada.state.scene_map[E]; if (cn->ignore_anim) { continue; } @@ -1665,7 +1665,7 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) { if (nm.bone >= 0) { if (found_anim) { - bones_with_animation[E->get()] = true; + bones_with_animation[E] = true; } } diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 4f666730d5..80230bc316 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -704,7 +704,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, HashMap<R return p_node; } -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) { +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, HashSet<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); @@ -1994,7 +1994,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p animation_data = subresources["animations"]; } - RBSet<Ref<ImporterMesh>> scanned_meshes; + HashSet<Ref<ImporterMesh>> scanned_meshes; HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> collision_map; Pair<PackedVector3Array, PackedInt32Array> occluder_arrays; List<Pair<NodePath, Node *>> node_renames; diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index 92bd267216..16cf3d651d 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -272,7 +272,7 @@ public: virtual int get_import_order() const override { return ResourceImporter::IMPORT_ORDER_SCENE; } 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); + Node *_post_fix_node(Node *p_node, Node *p_root, HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Pair<PackedVector3Array, PackedInt32Array> &r_occluder_arrays, HashSet<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); diff --git a/editor/import/scene_import_settings.h b/editor/import/scene_import_settings.h index cbd105045a..a4008582ce 100644 --- a/editor/import/scene_import_settings.h +++ b/editor/import/scene_import_settings.h @@ -139,8 +139,8 @@ class SceneImportSettings : public ConfirmationDialog { 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); - RBSet<Ref<Mesh>> mesh_set; - RBSet<Ref<Material>> material_set; + HashSet<Ref<Mesh>> mesh_set; + HashSet<Ref<Material>> material_set; String selected_type; String selected_id; diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 56b15c3b1a..9eb2706d8a 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -43,7 +43,7 @@ public: List<PropertyInfo> properties; Ref<ResourceImporter> importer; Vector<String> paths; - RBSet<StringName> checked; + HashSet<StringName> checked; bool checking; String base_options_path; @@ -194,7 +194,7 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { // Use the value that is repeated the most. HashMap<String, Dictionary> value_frequency; - RBSet<String> extensions; + HashSet<String> extensions; for (int i = 0; i < p_paths.size(); i++) { Ref<ConfigFile> config; diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index c5dacd8d21..934d3a82b4 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -307,7 +307,7 @@ void InspectorDock::_prepare_history() { history_menu->get_popup()->clear(); Ref<Texture2D> base_icon = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); - RBSet<ObjectID> already; + HashSet<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/multi_node_edit.cpp b/editor/multi_node_edit.cpp index 432d1ee4cc..a694b8d754 100644 --- a/editor/multi_node_edit.cpp +++ b/editor/multi_node_edit.cpp @@ -87,8 +87,6 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value, ur->add_undo_property(n, name, n->get(name)); } - ur->add_do_method(InspectorDock::get_inspector_singleton(), "refresh"); - ur->add_undo_method(InspectorDock::get_inspector_singleton(), "refresh"); ur->commit_action(); return true; diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 08df704f44..8c8505283c 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -563,7 +563,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano updating = true; - RBSet<String> paths; + HashSet<String> paths; HashMap<String, RBSet<String>> types; { List<StringName> animations; @@ -603,8 +603,8 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano HashMap<String, TreeItem *> parenthood; - for (RBSet<String>::Element *E = paths.front(); E; E = E->next()) { - NodePath path = E->get(); + for (const String &E : paths) { + NodePath path = E; TreeItem *ti = nullptr; String accum; for (int i = 0; i < path.get_name_count(); i++) { @@ -698,11 +698,12 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano //just a node, not a property track String types_text = "["; if (types.has(path)) { - RBSet<String>::Element *F = types[path].front(); - types_text += F->get(); - while (F->next()) { - F = F->next(); - types_text += " / " + F->get(); + RBSet<String>::Iterator F = types[path].begin(); + types_text += *F; + while (F) { + types_text += " / " + *F; + ; + ++F; } } types_text += "]"; diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 2b90b4cdd6..bd9b89cbb7 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -494,7 +494,7 @@ Control::CursorShape AnimationNodeStateMachineEditor::get_cursor_shape(const Poi void AnimationNodeStateMachineEditor::_group_selected_nodes() { if (!selected_nodes.is_empty()) { - if (selected_nodes.size() == 1 && (selected_nodes.front()->get() == state_machine->start_node || selected_nodes.front()->get() == state_machine->end_node)) + if (selected_nodes.size() == 1 && (*selected_nodes.begin() == state_machine->start_node || *selected_nodes.begin() == state_machine->end_node)) return; Ref<AnimationNodeStateMachine> group_sm = memnew(AnimationNodeStateMachine); @@ -609,7 +609,7 @@ void AnimationNodeStateMachineEditor::_group_selected_nodes() { void AnimationNodeStateMachineEditor::_ungroup_selected_nodes() { bool find = false; - RBSet<StringName> new_selected_nodes; + HashSet<StringName> new_selected_nodes; for (const StringName &E : selected_nodes) { Ref<AnimationNodeStateMachine> group_sm = state_machine->get_node(E); @@ -1846,7 +1846,7 @@ void AnimationNodeStateMachineEditor::_update_mode() { if (tool_select->is_pressed()) { tool_erase_hb->show(); bool nothing_selected = selected_nodes.is_empty() && selected_transition_from == StringName() && selected_transition_to == StringName(); - bool start_end_selected = selected_nodes.size() == 1 && (selected_nodes.front()->get() == state_machine->start_node || selected_nodes.front()->get() == state_machine->end_node); + bool start_end_selected = selected_nodes.size() == 1 && (*selected_nodes.begin() == state_machine->start_node || *selected_nodes.begin() == state_machine->end_node); tool_erase->set_disabled(nothing_selected || start_end_selected); if (selected_nodes.is_empty() || start_end_selected) { @@ -1854,7 +1854,7 @@ void AnimationNodeStateMachineEditor::_update_mode() { tool_group->set_visible(true); tool_ungroup->set_visible(false); } else { - Ref<AnimationNodeStateMachine> ansm = state_machine->get_node(selected_nodes.front()->get()); + Ref<AnimationNodeStateMachine> ansm = state_machine->get_node(*selected_nodes.begin()); if (selected_nodes.size() == 1 && ansm.is_valid()) { tool_group->set_disabled(true); diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h index 3db4d91367..ea16abd64c 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; - RBSet<StringName> selected_nodes; + HashSet<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; - RBSet<StringName> previous_selected; + HashSet<StringName> previous_selected; bool dragging_selected_attempt = false; bool dragging_selected = false; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index ab7afc5349..d7061a420a 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -1379,6 +1379,10 @@ void EditorAssetLibrary::disable_community_support() { support->get_popup()->set_item_checked(SUPPORT_COMMUNITY, false); } +void EditorAssetLibrary::set_columns(const int p_columns) { + asset_items->set_columns(p_columns); +} + void EditorAssetLibrary::_bind_methods() { ADD_SIGNAL(MethodInfo("install_asset", PropertyInfo(Variant::STRING, "zip_path"), PropertyInfo(Variant::STRING, "name"))); } @@ -1446,6 +1450,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { search_hb2->add_child(sort); sort->set_h_size_flags(Control::SIZE_EXPAND_FILL); + sort->set_clip_text(true); sort->connect("item_selected", callable_mp(this, &EditorAssetLibrary::_rerun_search)); search_hb2->add_child(memnew(VSeparator)); @@ -1455,6 +1460,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { categories->add_item(TTR("All")); search_hb2->add_child(categories); categories->set_h_size_flags(Control::SIZE_EXPAND_FILL); + categories->set_clip_text(true); categories->connect("item_selected", callable_mp(this, &EditorAssetLibrary::_rerun_search)); search_hb2->add_child(memnew(VSeparator)); @@ -1468,6 +1474,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { search_hb2->add_child(repository); repository->set_h_size_flags(Control::SIZE_EXPAND_FILL); + repository->set_clip_text(true); search_hb2->add_child(memnew(VSeparator)); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index af961e1403..e09700b646 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -311,6 +311,7 @@ protected: public: void disable_community_support(); + void set_columns(int p_columns); EditorAssetLibrary(bool p_templates_only = false); }; diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 0560365a58..bb0cfcba25 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); - RBSet<String> control_flow_keywords; - RBSet<String> keywords; + HashSet<String> control_flow_keywords; + HashSet<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 28c37fed52..c17e02e1fd 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 RBSet<String> &p_features); + virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features); }; -void GDExtensionExportPlugin::_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 HashSet<String> &p_features) { if (p_type != "NativeExtension") { return; } diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index 3094e24659..d85087b5ea 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -349,12 +349,13 @@ struct MeshInstance3DEditorEdgeSort { Vector2 a; Vector2 b; - bool operator<(const MeshInstance3DEditorEdgeSort &p_b) const { - if (a == p_b.a) { - return b < p_b.b; - } else { - return a < p_b.a; - } + static uint32_t hash(const MeshInstance3DEditorEdgeSort &p_edge) { + uint32_t h = hash_djb2_one_32(HashMapHasherDefault::hash(p_edge.a)); + return hash_djb2_one_32(HashMapHasherDefault::hash(p_edge.b), h); + } + + bool operator==(const MeshInstance3DEditorEdgeSort &p_b) const { + return a == p_b.a && b == p_b.b; } MeshInstance3DEditorEdgeSort() {} @@ -373,7 +374,7 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) { Ref<Mesh> mesh = node->get_mesh(); ERR_FAIL_COND(!mesh.is_valid()); - RBSet<MeshInstance3DEditorEdgeSort> edges; + HashSet<MeshInstance3DEditorEdgeSort, 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) { diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 58cdf3533c..37922dd5c9 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -3799,7 +3799,7 @@ void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->clear(); Vector<Vector3> lines; - RBSet<Vector2i> lines_found; + HashSet<Vector2i> lines_found; Vector<Vector3> points = data->get_capture_points(); if (points.size() == 0) { diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 1d85e80331..cbdb1e520a 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -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()); - RBSet<Ref<EditorNode3DGizmo>> found_gizmos; + HashSet<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()); - RBSet<Node3D *> found_nodes; + HashSet<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()); - RBSet<Node3D *> found_nodes; + HashSet<Node3D *> found_nodes; Vector<Node *> selected; Node *edited_scene = get_tree()->get_edited_scene_root(); @@ -6685,8 +6685,8 @@ void Node3DEditor::_refresh_menu_icons() { } template <typename T> -RBSet<T *> _get_child_nodes(Node *parent_node) { - RBSet<T *> nodes = RBSet<T *>(); +HashSet<T *> _get_child_nodes(Node *parent_node) { + HashSet<T *> nodes = HashSet<T *>(); T *node = Node::cast_to<T>(parent_node); if (node) { nodes.insert(node); @@ -6694,24 +6694,24 @@ RBSet<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); - 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()); + HashSet<T *> child_nodes = _get_child_nodes<T>(child_node); + for (T *I : child_nodes) { + nodes.insert(I); } } return nodes; } -RBSet<RID> _get_physics_bodies_rid(Node *node) { - RBSet<RID> rids = RBSet<RID>(); +HashSet<RID> _get_physics_bodies_rid(Node *node) { + HashSet<RID> rids = HashSet<RID>(); PhysicsBody3D *pb = Node::cast_to<PhysicsBody3D>(node); if (pb) { rids.insert(pb->get_rid()); } - 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()); + HashSet<PhysicsBody3D *> child_nodes = _get_child_nodes<PhysicsBody3D>(node); + for (const PhysicsBody3D *I : child_nodes) { + rids.insert(I->get_rid()); } return rids; @@ -6728,20 +6728,21 @@ void Node3DEditor::snap_selected_nodes_to_floor() { Vector3 position_offset = Vector3(); // Priorities for snapping to floor are CollisionShapes, VisualInstances and then origin - RBSet<VisualInstance3D *> vi = _get_child_nodes<VisualInstance3D>(sp); - RBSet<CollisionShape3D *> cs = _get_child_nodes<CollisionShape3D>(sp); + HashSet<VisualInstance3D *> vi = _get_child_nodes<VisualInstance3D>(sp); + HashSet<CollisionShape3D *> cs = _get_child_nodes<CollisionShape3D>(sp); bool found_valid_shape = false; if (cs.size()) { AABB aabb; - RBSet<CollisionShape3D *>::Element *I = cs.front(); - if (I->get()->get_shape().is_valid()) { - CollisionShape3D *collision_shape = cs.front()->get(); + HashSet<CollisionShape3D *>::Iterator I = cs.begin(); + if ((*I)->get_shape().is_valid()) { + CollisionShape3D *collision_shape = *cs.begin(); aabb = collision_shape->get_global_transform().xform(collision_shape->get_shape()->get_debug_mesh()->get_aabb()); found_valid_shape = true; } - for (I = I->next(); I; I = I->next()) { - CollisionShape3D *col_shape = I->get(); + + for (++I; I; ++I) { + CollisionShape3D *col_shape = *I; if (col_shape->get_shape().is_valid()) { aabb.merge_with(col_shape->get_global_transform().xform(col_shape->get_shape()->get_debug_mesh()->get_aabb())); found_valid_shape = true; @@ -6754,9 +6755,9 @@ void Node3DEditor::snap_selected_nodes_to_floor() { } } if (!found_valid_shape && vi.size()) { - AABB aabb = vi.front()->get()->get_transformed_aabb(); - for (RBSet<VisualInstance3D *>::Element *I = vi.front(); I; I = I->next()) { - aabb.merge_with(I->get()->get_transformed_aabb()); + AABB aabb = (*vi.begin())->get_transformed_aabb(); + for (const VisualInstance3D *I : vi) { + aabb.merge_with(I->get_transformed_aabb()); } Vector3 size = aabb.size * Vector3(0.5, 0.0, 0.5); from = aabb.position + size; @@ -6798,7 +6799,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); - RBSet<RID> excluded = _get_physics_bodies_rid(sp); + HashSet<RID> excluded = _get_physics_bodies_rid(sp); PhysicsDirectSpaceState3D::RayParameters ray_params; ray_params.from = from; @@ -6820,7 +6821,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); - RBSet<RID> excluded = _get_physics_bodies_rid(sp); + HashSet<RID> excluded = _get_physics_bodies_rid(sp); PhysicsDirectSpaceState3D::RayParameters ray_params; ray_params.from = from; @@ -6949,6 +6950,10 @@ void Node3DEditor::_update_theme() { sun_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); environ_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); + + sun_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); + environ_sky_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); + environ_ground_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); } void Node3DEditor::_notification(int p_what) { diff --git a/editor/plugins/packed_scene_translation_parser_plugin.h b/editor/plugins/packed_scene_translation_parser_plugin.h index 9135498333..1bfb500933 100644 --- a/editor/plugins/packed_scene_translation_parser_plugin.h +++ b/editor/plugins/packed_scene_translation_parser_plugin.h @@ -37,7 +37,7 @@ class PackedSceneEditorTranslationParserPlugin : public EditorTranslationParserP GDCLASS(PackedSceneEditorTranslationParserPlugin, EditorTranslationParserPlugin); // Scene Node's properties that contain translation strings. - RBSet<String> lookup_properties; + HashSet<String> lookup_properties; // Properties from specific Nodes that should be ignored. HashMap<String, Vector<String>> exception_list; diff --git a/editor/plugins/replication_editor_plugin.cpp b/editor/plugins/replication_editor_plugin.cpp index 2a7b3c7a55..6992b5443b 100644 --- a/editor/plugins/replication_editor_plugin.cpp +++ b/editor/plugins/replication_editor_plugin.cpp @@ -37,6 +37,129 @@ #include "scene/gui/tree.h" #include "scene/multiplayer/multiplayer_synchronizer.h" +void ReplicationEditor::_pick_node_filter_text_changed(const String &p_newtext) { + TreeItem *root_item = pick_node->get_scene_tree()->get_scene_tree()->get_root(); + + Vector<Node *> select_candidates; + Node *to_select = nullptr; + + String filter = pick_node->get_filter_line_edit()->get_text(); + + _pick_node_select_recursive(root_item, filter, select_candidates); + + if (!select_candidates.is_empty()) { + for (int i = 0; i < select_candidates.size(); ++i) { + Node *candidate = select_candidates[i]; + + if (((String)candidate->get_name()).to_lower().begins_with(filter.to_lower())) { + to_select = candidate; + break; + } + } + + if (!to_select) { + to_select = select_candidates[0]; + } + } + + pick_node->get_scene_tree()->set_selected(to_select); +} + +void ReplicationEditor::_pick_node_select_recursive(TreeItem *p_item, const String &p_filter, Vector<Node *> &p_select_candidates) { + if (!p_item) { + return; + } + + NodePath np = p_item->get_metadata(0); + Node *node = get_node(np); + + if (!p_filter.is_empty() && ((String)node->get_name()).findn(p_filter) != -1) { + p_select_candidates.push_back(node); + } + + TreeItem *c = p_item->get_first_child(); + + while (c) { + _pick_node_select_recursive(c, p_filter, p_select_candidates); + c = c->get_next(); + } +} + +void ReplicationEditor::_pick_node_filter_input(const Ref<InputEvent> &p_ie) { + Ref<InputEventKey> k = p_ie; + + if (k.is_valid()) { + switch (k->get_keycode()) { + case Key::UP: + case Key::DOWN: + case Key::PAGEUP: + case Key::PAGEDOWN: { + pick_node->get_scene_tree()->get_scene_tree()->gui_input(k); + pick_node->get_filter_line_edit()->accept_event(); + } break; + default: + break; + } + } +} + +void ReplicationEditor::_pick_node_selected(NodePath p_path) { + Node *root = current->get_node(current->get_root_path()); + ERR_FAIL_COND(!root); + Node *node = get_node(p_path); + ERR_FAIL_COND(!node); + NodePath path_to = root->get_path_to(node); + adding_node_path = path_to; + prop_selector->select_property_from_instance(node); +} + +void ReplicationEditor::_pick_new_property() { + if (current == nullptr) { + EditorNode::get_singleton()->show_warning(TTR("Select a replicator node in order to pick a property to add to it.")); + return; + } + Node *root = current->get_node(current->get_root_path()); + if (!root) { + EditorNode::get_singleton()->show_warning(TTR("Not possible to add a new property to synchronize without a root.")); + return; + } + pick_node->popup_scenetree_dialog(); + pick_node->get_filter_line_edit()->clear(); + pick_node->get_filter_line_edit()->grab_focus(); +} + +void ReplicationEditor::_add_sync_property(String p_path) { + config = current->get_replication_config(); + + if (config.is_valid() && config->has_property(p_path)) { + EditorNode::get_singleton()->show_warning(TTR("Property is already being synchronized.")); + return; + } + + UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); + undo_redo->create_action(TTR("Add property to synchronizer")); + + if (config.is_null()) { + config.instantiate(); + current->set_replication_config(config); + undo_redo->add_do_method(current, "set_replication_config", config); + undo_redo->add_undo_method(current, "set_replication_config", Ref<SceneReplicationConfig>()); + _update_config(); + } + + undo_redo->add_do_method(config.ptr(), "add_property", p_path); + undo_redo->add_undo_method(config.ptr(), "remove_property", p_path); + undo_redo->add_do_method(this, "_update_config"); + undo_redo->add_undo_method(this, "_update_config"); + undo_redo->commit_action(); +} + +void ReplicationEditor::_pick_node_property_selected(String p_name) { + String adding_prop_path = String(adding_node_path) + ":" + p_name; + + _add_sync_property(adding_prop_path); +} + /// ReplicationEditor ReplicationEditor::ReplicationEditor() { set_v_size_flags(SIZE_EXPAND_FILL); @@ -56,16 +179,44 @@ ReplicationEditor::ReplicationEditor() { vb->set_v_size_flags(SIZE_EXPAND_FILL); add_child(vb); + pick_node = memnew(SceneTreeDialog); + add_child(pick_node); + pick_node->register_text_enter(pick_node->get_filter_line_edit()); + pick_node->set_title(TTR("Pick a node to synchronize:")); + pick_node->connect("selected", callable_mp(this, &ReplicationEditor::_pick_node_selected)); + pick_node->get_filter_line_edit()->connect("text_changed", callable_mp(this, &ReplicationEditor::_pick_node_filter_text_changed)); + pick_node->get_filter_line_edit()->connect("gui_input", callable_mp(this, &ReplicationEditor::_pick_node_filter_input)); + + prop_selector = memnew(PropertySelector); + add_child(prop_selector); + prop_selector->connect("selected", callable_mp(this, &ReplicationEditor::_pick_node_property_selected)); + HBoxContainer *hb = memnew(HBoxContainer); vb->add_child(hb); + + add_pick_button = memnew(Button); + add_pick_button->connect("pressed", callable_mp(this, &ReplicationEditor::_pick_new_property)); + add_pick_button->set_text(TTR("Add property to sync..")); + hb->add_child(add_pick_button); + VSeparator *vs = memnew(VSeparator); + vs->set_custom_minimum_size(Size2(30 * EDSCALE, 0)); + hb->add_child(vs); + hb->add_child(memnew(Label(TTR("Path:")))); np_line_edit = memnew(LineEdit); np_line_edit->set_placeholder(":property"); np_line_edit->set_h_size_flags(SIZE_EXPAND_FILL); hb->add_child(np_line_edit); - add_button = memnew(Button); - add_button->connect("pressed", callable_mp(this, &ReplicationEditor::_add_pressed)); - add_button->set_text(TTR("Add")); - hb->add_child(add_button); + add_from_path_button = memnew(Button); + add_from_path_button->connect("pressed", callable_mp(this, &ReplicationEditor::_add_pressed)); + add_from_path_button->set_text(TTR("Add from path")); + hb->add_child(add_from_path_button); + vs = memnew(VSeparator); + vs->set_custom_minimum_size(Size2(30 * EDSCALE, 0)); + hb->add_child(vs); + pin = memnew(Button); + pin->set_flat(true); + pin->set_toggle_mode(true); + hb->add_child(pin); tree = memnew(Tree); tree->set_hide_root(true); @@ -85,19 +236,88 @@ ReplicationEditor::ReplicationEditor() { tree->connect("item_edited", callable_mp(this, &ReplicationEditor::_tree_item_edited)); tree->set_v_size_flags(SIZE_EXPAND_FILL); vb->add_child(tree); + + drop_label = memnew(Label); + drop_label->set_text(TTR("Add properties using the buttons above or\ndrag them them from the inspector and drop them here.")); + drop_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); + drop_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER); + tree->add_child(drop_label); + drop_label->set_anchors_and_offsets_preset(Control::PRESET_WIDE); + + tree->set_drag_forwarding(this); } void ReplicationEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_update_config"), &ReplicationEditor::_update_config); ClassDB::bind_method(D_METHOD("_update_checked", "property", "column", "checked"), &ReplicationEditor::_update_checked); + ClassDB::bind_method("_can_drop_data_fw", &ReplicationEditor::_can_drop_data_fw); + ClassDB::bind_method("_drop_data_fw", &ReplicationEditor::_drop_data_fw); + ADD_SIGNAL(MethodInfo("keying_changed")); } +bool ReplicationEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { + Dictionary d = p_data; + if (!d.has("type")) { + return false; + } + String t = d["type"]; + if (t != "obj_property") { + return false; + } + Object *obj = d["object"]; + if (!obj) { + return false; + } + Node *node = Object::cast_to<Node>(obj); + if (!node) { + return false; + } + + return true; +} + +void ReplicationEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { + if (current == nullptr) { + EditorNode::get_singleton()->show_warning(TTR("Select a replicator node in order to pick a property to add to it.")); + return; + } + Node *root = current->get_node(current->get_root_path()); + if (!root) { + EditorNode::get_singleton()->show_warning(TTR("Not possible to add a new property to synchronize without a root.")); + return; + } + + Dictionary d = p_data; + if (!d.has("type")) { + return; + } + String t = d["type"]; + if (t != "obj_property") { + return; + } + Object *obj = d["object"]; + if (!obj) { + return; + } + Node *node = Object::cast_to<Node>(obj); + if (!node) { + return; + } + + String path = root->get_path_to(node); + path += ":" + String(d["property"]); + + _add_sync_property(path); +} + void ReplicationEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); + add_pick_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + pin->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"))); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -236,11 +456,15 @@ void ReplicationEditor::_update_config() { deleting = NodePath(); tree->clear(); tree->create_item(); + drop_label->set_visible(true); if (!config.is_valid()) { update_keying(); return; } TypedArray<NodePath> props = config->get_properties(); + if (props.size()) { + drop_label->set_visible(false); + } for (int i = 0; i < props.size(); i++) { const NodePath path = props[i]; _add_property(path, config->property_get_spawn(path), config->property_get_sync(path)); @@ -341,7 +565,9 @@ void ReplicationEditor::property_keyed(const String &p_property) { /// ReplicationEditorPlugin ReplicationEditorPlugin::ReplicationEditorPlugin() { repl_editor = memnew(ReplicationEditor); - EditorNode::get_singleton()->add_bottom_panel_item(TTR("Replication"), repl_editor); + button = EditorNode::get_singleton()->add_bottom_panel_item(TTR("Replication"), repl_editor); + button->hide(); + repl_editor->get_pin()->connect("pressed", callable_mp(this, &ReplicationEditorPlugin::_pinned)); } ReplicationEditorPlugin::~ReplicationEditorPlugin() { @@ -378,6 +604,17 @@ void ReplicationEditorPlugin::_node_removed(Node *p_node) { if (repl_editor->is_visible_in_tree()) { EditorNode::get_singleton()->hide_bottom_panel(); } + button->hide(); + repl_editor->get_pin()->set_pressed(false); + } +} + +void ReplicationEditorPlugin::_pinned() { + if (!repl_editor->get_pin()->is_pressed()) { + if (repl_editor->is_visible_in_tree()) { + EditorNode::get_singleton()->hide_bottom_panel(); + } + button->hide(); } } @@ -391,6 +628,14 @@ bool ReplicationEditorPlugin::handles(Object *p_object) const { void ReplicationEditorPlugin::make_visible(bool p_visible) { if (p_visible) { + //editor->hide_animation_player_editors(); + //editor->animation_panel_make_visible(true); + button->show(); EditorNode::get_singleton()->make_bottom_panel_item_visible(repl_editor); + } else if (!repl_editor->get_pin()->is_pressed()) { + if (repl_editor->is_visible_in_tree()) { + EditorNode::get_singleton()->hide_bottom_panel(); + } + button->hide(); } } diff --git a/editor/plugins/replication_editor_plugin.h b/editor/plugins/replication_editor_plugin.h index 08e86d1617..b6de08a3a8 100644 --- a/editor/plugins/replication_editor_plugin.h +++ b/editor/plugins/replication_editor_plugin.h @@ -34,6 +34,10 @@ #include "editor/editor_plugin.h" #include "scene/resources/scene_replication_config.h" +#include "editor/editor_spin_slider.h" +#include "editor/property_editor.h" +#include "editor/property_selector.h" + class ConfirmationDialog; class MultiplayerSynchronizer; class Tree; @@ -46,14 +50,23 @@ private: AcceptDialog *error_dialog = nullptr; ConfirmationDialog *delete_dialog = nullptr; - Button *add_button = nullptr; + Button *add_pick_button = nullptr; + Button *add_from_path_button = nullptr; LineEdit *np_line_edit = nullptr; + Label *drop_label = nullptr; + Ref<SceneReplicationConfig> config; NodePath deleting; Tree *tree = nullptr; bool keying = false; + PropertySelector *prop_selector = nullptr; + SceneTreeDialog *pick_node = nullptr; + NodePath adding_node_path; + + Button *pin = nullptr; + Ref<Texture2D> _get_class_icon(const Node *p_node); void _add_pressed(); @@ -64,6 +77,19 @@ private: void _dialog_closed(bool p_confirmed); void _add_property(const NodePath &p_property, bool p_spawn = true, bool p_sync = true); + void _pick_node_filter_text_changed(const String &p_newtext); + void _pick_node_select_recursive(TreeItem *p_item, const String &p_filter, Vector<Node *> &p_select_candidates); + void _pick_node_filter_input(const Ref<InputEvent> &p_ie); + void _pick_node_selected(NodePath p_path); + + void _pick_new_property(); + void _pick_node_property_selected(String p_name); + + bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; + void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); + + void _add_sync_property(String p_path); + protected: static void _bind_methods(); @@ -76,6 +102,7 @@ public: MultiplayerSynchronizer *get_current() const { return current; } void property_keyed(const String &p_property); + Button *get_pin() { return pin; } ReplicationEditor(); ~ReplicationEditor() {} }; @@ -84,12 +111,15 @@ class ReplicationEditorPlugin : public EditorPlugin { GDCLASS(ReplicationEditorPlugin, EditorPlugin); private: + Button *button = nullptr; ReplicationEditor *repl_editor = nullptr; void _node_removed(Node *p_node); void _keying_changed(); void _property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance); + void _pinned(); + protected: void _notification(int p_what); diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index b632b0d641..681dd476e3 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; } - RBSet<String> paths; + HashSet<String> paths; { List<StringName> animations; player->get_animation_list(&animations); @@ -83,8 +83,8 @@ void EditorPropertyRootMotion::_node_assign() { HashMap<String, TreeItem *> parenthood; - for (RBSet<String>::Element *E = paths.front(); E; E = E->next()) { - NodePath path = E->get(); + for (const String &E : paths) { + NodePath path = E; TreeItem *ti = nullptr; String accum; for (int i = 0; i < path.get_name_count(); i++) { diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 115c6f43dd..99b810be44 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1715,7 +1715,7 @@ void ScriptEditor::notify_script_changed(const Ref<Script> &p_script) { } void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { - RBSet<String> loaded_scripts; + HashSet<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) { @@ -1800,7 +1800,7 @@ void ScriptEditor::ensure_select_current() { _update_selected_editor_menu(); } -void ScriptEditor::_find_scripts(Node *p_base, Node *p_current, RBSet<Ref<Script>> &used) { +void ScriptEditor::_find_scripts(Node *p_base, Node *p_current, HashSet<Ref<Script>> &used) { if (p_current != p_base && p_current->get_owner() != p_base) { return; } @@ -1980,7 +1980,7 @@ void ScriptEditor::_update_script_names() { return; } - RBSet<Ref<Script>> used; + HashSet<Ref<Script>> used; Node *edited = EditorNode::get_singleton()->get_edited_scene(); if (edited) { _find_scripts(edited, edited, used); @@ -3143,7 +3143,7 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { restoring_layout = true; - RBSet<String> loaded_scripts; + HashSet<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 ff71c8b484..9f088aac49 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -414,7 +414,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, RBSet<Ref<Script>> &used); + void _find_scripts(Node *p_base, Node *p_current, HashSet<Ref<Script>> &used); void _tree_changed(); @@ -454,7 +454,7 @@ class ScriptEditor : public PanelContainer { Ref<Script> _get_current_script(); Array _get_open_scripts() const; - RBSet<String> textfile_extensions; + HashSet<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 9df99dcce4..a4bccf30e3 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, RBSet<Ref<Script>> &r_scripts) { +static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_current, HashSet<Ref<Script>> &r_scripts) { if (p_current->get_owner() != p_base && p_base != p_current) { return; } @@ -686,15 +686,15 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo ERR_FAIL_COND(!get_tree()); - RBSet<Ref<Script>> scripts; + HashSet<Ref<Script>> scripts; Node *base = get_tree()->get_edited_scene_root(); if (base) { _find_changed_scripts_for_external_editor(base, base, scripts); } - for (RBSet<Ref<Script>>::Element *E = scripts.front(); E; E = E->next()) { - Ref<Script> script = E->get(); + for (const Ref<Script> &E : scripts) { + Ref<Script> script = E; if (p_for_script.is_valid() && p_for_script != script) { continue; @@ -970,7 +970,7 @@ void ScriptTextEditor::_update_connected_methods() { } Vector<Node *> nodes = _find_all_node_for_script(base, base, script); - RBSet<StringName> methods_found; + HashSet<StringName> methods_found; for (int i = 0; i < nodes.size(); i++) { List<Connection> connections; nodes[i]->get_signals_connected_to_this(&connections); diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index ff13b38832..fc87c84a2c 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; - RBSet<int> safe_lines; + HashSet<int> safe_lines; List<Connection> missing_connections; diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index cb8d59dfe4..8a40ffbe38 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -125,8 +125,8 @@ void SpriteFramesEditor::_sheet_preview_draw() { Color accent = get_theme_color("accent_color", "Editor"); - for (RBSet<int>::Element *E = frames_selected.front(); E; E = E->next()) { - const int idx = E->get(); + for (const int &E : frames_selected) { + const int idx = E; const int x = idx % frame_count.x; const int y = idx / frame_count.x; const Point2 pos = draw_offset + Point2(x, y) * (draw_frame_size + draw_sep); @@ -248,8 +248,8 @@ void SpriteFramesEditor::_sheet_add_frames() { int fc = frames->get_frame_count(edited_anim); - for (RBSet<int>::Element *E = frames_selected.front(); E; E = E->next()) { - int idx = E->get(); + for (const int &E : frames_selected) { + int idx = E; const Point2 frame_coords(idx % frame_count.x, idx / frame_count.x); Ref<AtlasTexture> at; diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h index 6f16ff2bd1..3c8c5ef19d 100644 --- a/editor/plugins/sprite_frames_editor_plugin.h +++ b/editor/plugins/sprite_frames_editor_plugin.h @@ -50,7 +50,7 @@ class SpriteFramesEditor : public HSplitContainer { enum { PARAM_USE_CURRENT, // Used in callbacks to indicate `dominant_param` should be not updated. - PARAM_FRAME_COUNT, // Keep "Horizontal" & "Vertial" values. + PARAM_FRAME_COUNT, // Keep "Horizontal" & "Vertical" values. PARAM_SIZE, // Keep "Size" values. }; int dominant_param = PARAM_FRAME_COUNT; @@ -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; - RBSet<int> frames_selected; - RBSet<int> frames_toggled_by_mouse_hover; + HashSet<int> frames_selected; + HashSet<int> frames_toggled_by_mouse_hover; int last_frame_selected = 0; float scale_ratio; diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp index 252a19a7db..a6e34cf5e0 100644 --- a/editor/plugins/theme_editor_preview.cpp +++ b/editor/plugins/theme_editor_preview.cpp @@ -269,6 +269,15 @@ ThemeEditorPreview::ThemeEditorPreview() { picker_overlay->connect("mouse_exited", callable_mp(this, &ThemeEditorPreview::_reset_picker_overlay)); } +void DefaultThemeEditorPreview::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + test_color_picker_button->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); + } break; + } +} + DefaultThemeEditorPreview::DefaultThemeEditorPreview() { Panel *main_panel = memnew(Panel); preview_content->add_child(main_panel); @@ -343,7 +352,8 @@ DefaultThemeEditorPreview::DefaultThemeEditorPreview() { test_option_button->add_item(TTR("Many")); test_option_button->add_item(TTR("Options")); first_vb->add_child(test_option_button); - first_vb->add_child(memnew(ColorPickerButton)); + test_color_picker_button = memnew(ColorPickerButton); + first_vb->add_child(test_color_picker_button); VBoxContainer *second_vb = memnew(VBoxContainer); second_vb->set_h_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/plugins/theme_editor_preview.h b/editor/plugins/theme_editor_preview.h index d05916afae..4d209ac788 100644 --- a/editor/plugins/theme_editor_preview.h +++ b/editor/plugins/theme_editor_preview.h @@ -38,6 +38,8 @@ #include "scene/gui/scroll_container.h" #include "scene/resources/theme.h" +class ColorPickerButton; + class ThemeEditorPreview : public VBoxContainer { GDCLASS(ThemeEditorPreview, VBoxContainer); @@ -87,6 +89,11 @@ public: class DefaultThemeEditorPreview : public ThemeEditorPreview { GDCLASS(DefaultThemeEditorPreview, ThemeEditorPreview); + ColorPickerButton *test_color_picker_button = nullptr; + +protected: + void _notification(int p_what); + public: DefaultThemeEditorPreview(); }; diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index eda05b1005..244c718ebe 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -897,8 +897,8 @@ void TileDataDefaultEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas_ } } - for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { - Vector2i coords = E->get().get_atlas_coords(); + for (const TileMapCell &E : edited) { + Vector2i coords = E.get_atlas_coords(); p_canvas_item->draw_rect(p_tile_set_atlas_source->get_tile_texture_region(coords), selection_color, false); } p_canvas_item->draw_set_transform_matrix(Transform2D()); @@ -1755,8 +1755,8 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas } } - for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { - Vector2i coords = E->get().get_atlas_coords(); + for (const TileMapCell &E : edited) { + Vector2i coords = E.get_atlas_coords(); p_canvas_item->draw_rect(p_tile_set_atlas_source->get_tile_texture_region(coords), selection_color, false); } p_canvas_item->draw_set_transform_matrix(Transform2D()); @@ -1800,8 +1800,8 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas p_canvas_item->draw_set_transform_matrix(p_transform); - for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { - Vector2i coords = E->get().get_atlas_coords(); + for (const TileMapCell &E : edited) { + Vector2i coords = E.get_atlas_coords(); Rect2i texture_region = p_tile_set_atlas_source->get_tile_texture_region(coords); Vector2i position = texture_region.get_center() + p_tile_set_atlas_source->get_tile_effective_texture_offset(coords, 0); @@ -2133,15 +2133,15 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_t } } undo_redo->create_action(TTR("Painting Terrain Set")); - for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { - Vector2i coords = E->get().get_atlas_coords(); + for (const TileMapCell &E : edited) { + Vector2i coords = E.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()); - undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->get().alternative_tile), drag_painted_value); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E.alternative_tile), tile_data->get_terrain_set()); + undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E.alternative_tile), drag_painted_value); for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) { TileSet::CellNeighbor bit = TileSet::CellNeighbor(i); if (tile_data->is_valid_peering_bit_terrain(bit)) { - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->get().alternative_tile), tile_data->get_peering_bit_terrain(bit)); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.alternative_tile), tile_data->get_peering_bit_terrain(bit)); } } } @@ -2220,8 +2220,8 @@ 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 (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) { - Vector2i coords = E->get().get_atlas_coords(); + for (const TileMapCell &E : edited) { + Vector2i coords = E.get_atlas_coords(); TileData *tile_data = p_tile_set_atlas_source->get_tile_data(coords, 0); for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) { @@ -2236,8 +2236,8 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_t } if (!Geometry2D::intersect_polygons(polygon, mouse_pos_rect_polygon).is_empty()) { // Draw bit. - undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->get().alternative_tile), terrain); - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->get().alternative_tile), tile_data->get_peering_bit_terrain(bit)); + undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.alternative_tile), terrain); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.alternative_tile), tile_data->get_peering_bit_terrain(bit)); } } } diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index 12e1f10750..6c39244f80 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -501,8 +501,8 @@ 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 (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { - coords_array.push_back(E->get()); + for (const Vector2i &E : tile_map_selection) { + coords_array.push_back(E); } tile_map_clipboard = tile_map->get_pattern(tile_map_layer, coords_array); } @@ -511,9 +511,9 @@ 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 (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())); + for (const Vector2i &E : tile_map_selection) { + undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E, TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E, tile_map->get_cell_source_id(tile_map_layer, E), tile_map->get_cell_atlas_coords(tile_map_layer, E), tile_map->get_cell_alternative_tile(tile_map_layer, E)); } undo_redo->add_undo_method(this, "_set_tile_map_selection", _get_tile_map_selection()); tile_map_selection.clear(); @@ -542,9 +542,9 @@ 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 (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())); + for (const Vector2i &E : tile_map_selection) { + undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E, TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E, tile_map->get_cell_source_id(tile_map_layer, E), tile_map->get_cell_atlas_coords(tile_map_layer, E), tile_map->get_cell_alternative_tile(tile_map_layer, E)); } undo_redo->add_undo_method(this, "_set_tile_map_selection", _get_tile_map_selection()); tile_map_selection.clear(); @@ -628,8 +628,8 @@ 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 (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { - Vector2i coords = E->get(); + for (const Vector2i &E : tile_map_selection) { + Vector2i coords = E; 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); } @@ -785,8 +785,8 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over if (!tile_map_selection.is_empty()) { top_left = tile_map_selection.front()->get(); } - for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { - top_left = top_left.min(E->get()); + for (const Vector2i &E : tile_map_selection) { + top_left = top_left.min(E); } Vector2i offset = drag_start_mouse_pos - tile_map->map_to_world(top_left); offset = tile_map->world_to_map(drag_last_mouse_pos - offset) - tile_map->world_to_map(drag_start_mouse_pos - offset); @@ -1278,8 +1278,8 @@ void TileMapEditorTilesPlugin::_stop_dragging() { if (!tile_map_selection.is_empty()) { top_left = tile_map_selection.front()->get(); } - for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { - top_left = top_left.min(E->get()); + for (const Vector2i &E : tile_map_selection) { + top_left = top_left.min(E); } // Get the offset from the mouse. @@ -1534,8 +1534,8 @@ void TileMapEditorTilesPlugin::_update_selection_pattern_from_tilemap_selection( selection_pattern.instantiate(); TypedArray<Vector2i> coords_array; - for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { - coords_array.push_back(E->get()); + for (const Vector2i &E : tile_map_selection) { + coords_array.push_back(E); } selection_pattern = tile_map->get_pattern(tile_map_layer, coords_array); } @@ -1559,8 +1559,8 @@ void TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_sele // Group per source. 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())); + for (const TileMapCell &E : tile_set_selection) { + per_source[E.source_id].push_back(&(E)); } int vertical_offset = 0; @@ -1680,14 +1680,14 @@ 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 (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++) { + for (const TileMapCell &E : tile_set_selection) { + if (E.source_id == source_id && E.alternative_tile == 0) { + for (int frame = 0; frame < atlas->get_tile_animation_frames_count(E.get_atlas_coords()); frame++) { Color color = selection_color; if (frame > 0) { color.a *= 0.3; } - tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E->get().get_atlas_coords(), frame), color, false); + tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E.get_atlas_coords(), frame), color, false); } } } @@ -1721,8 +1721,8 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() { } } Color selection_rect_color = selection_color.lightened(0.2); - 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); + for (const Vector2i &E : to_draw) { + tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E), selection_rect_color, false); } } } @@ -1868,9 +1868,9 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_draw() { } // Draw the selection. - 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); + for (const TileMapCell &E : tile_set_selection) { + if (E.source_id == source_id && E.get_atlas_coords() != TileSetSource::INVALID_ATLAS_COORDS && E.alternative_tile > 0) { + Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E.get_atlas_coords(), E.alternative_tile); if (rect != Rect2i()) { alternative_tiles_control->draw_rect(rect, Color(0.2, 0.2, 1.0), false); } @@ -1972,8 +1972,8 @@ void TileMapEditorTilesPlugin::_set_tile_map_selection(const TypedArray<Vector2i TypedArray<Vector2i> TileMapEditorTilesPlugin::_get_tile_map_selection() const { TypedArray<Vector2i> output; - for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { - output.push_back(E->get()); + for (const Vector2i &E : tile_map_selection) { + output.push_back(E); } return output; } @@ -2341,8 +2341,8 @@ HashMap<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const TileSet::TerrainsPattern terrains_pattern = E_to_paint.value; 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()); + for (const TileMap::TerrainConstraint &E : cell_constraints) { + added_tiles_constraints_set.insert(E); } } @@ -2377,18 +2377,18 @@ HashMap<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const // Filter the sources to make sure they are in the potential_to_replace. 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 TileMap::TerrainConstraint &E : removed_cells_constraints_set) { + HashMap<Vector2i, TileSet::CellNeighbor> sources_of_constraint = E.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); + per_constraint_tiles[E].insert(E_source_tile_of_constraint.key); } } } to_replace_modified = false; - for (RBSet<TileMap::TerrainConstraint>::Element *E = added_tiles_constraints_set.front(); E; E = E->next()) { - TileMap::TerrainConstraint c = E->get(); + for (const TileMap::TerrainConstraint &E : added_tiles_constraints_set) { + TileMap::TerrainConstraint c = E; // 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()) { // If we do, we search for a neighbor to remove. @@ -2409,8 +2409,8 @@ HashMap<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const // Combine all constraints together. 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()); + for (const TileMap::TerrainConstraint &E : added_tiles_constraints_set) { + constraints.insert(E); } // Remove the central tiles from the ones to replace. @@ -3194,22 +3194,22 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() { // Sort the items in a map by the number of corresponding terrains. RBMap<int, RBSet<TileSet::TerrainsPattern>> sorted; - for (RBSet<TileSet::TerrainsPattern>::Element *E = per_terrain_terrains_patterns[selected_terrain_set][selected_terrain_id].front(); E; E = E->next()) { + for (const TileSet::TerrainsPattern &E : per_terrain_terrains_patterns[selected_terrain_set][selected_terrain_id]) { // Count the number of matching sides/terrains. int count = 0; for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) { TileSet::CellNeighbor bit = TileSet::CellNeighbor(i); - if (tile_set->is_valid_peering_bit_terrain(selected_terrain_set, bit) && E->get().get_terrain(bit) == selected_terrain_id) { + if (tile_set->is_valid_peering_bit_terrain(selected_terrain_set, bit) && E.get_terrain(bit) == selected_terrain_id) { count++; } } - sorted[count].insert(E->get()); + sorted[count].insert(E); } 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(); + for (const TileSet::TerrainsPattern &E : E_set->get()) { + TileSet::TerrainsPattern terrains_pattern = E; // Get the icon. Ref<Texture2D> icon; diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index dc3fa87565..b87aedcf60 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -270,9 +270,9 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_na // Other properties. bool any_valid = false; - for (RBSet<TileSelection>::Element *E = tiles.front(); E; E = E->next()) { - const Vector2i &coords = E->get().tile; - const int &alternative = E->get().alternative; + for (const TileSelection &E : tiles) { + const Vector2i &coords = E.tile; + const int &alternative = E.alternative; bool valid = false; TileData *tile_data = tile_set_atlas_source->get_tile_data(coords, alternative); @@ -354,11 +354,11 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_get(const StringName &p_na } } - for (RBSet<TileSelection>::Element *E = tiles.front(); E; E = E->next()) { + for (const TileSelection &E : tiles) { // 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; - const int &alternative = E->get().alternative; + const Vector2i &coords = E.tile; + const int &alternative = E.alternative; TileData *tile_data = tile_set_atlas_source->get_tile_data(coords, alternative); ERR_FAIL_COND_V(!tile_data, false); @@ -429,9 +429,9 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro RBMap<PropertyId, PLData> usage; List<PLData *> data_list; - for (RBSet<TileSelection>::Element *E = tiles.front(); E; E = E->next()) { - const Vector2i &coords = E->get().tile; - const int &alternative = E->get().alternative; + for (const TileSelection &E : tiles) { + const Vector2i &coords = E.tile; + const int &alternative = E.alternative; TileData *tile_data = tile_set_atlas_source->get_tile_data(coords, alternative); ERR_FAIL_COND(!tile_data); @@ -476,15 +476,15 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro 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 (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); + for (const TileSelection &E : p_tiles) { + ERR_FAIL_COND(E.tile == TileSetSource::INVALID_ATLAS_COORDS); + ERR_FAIL_COND(E.alternative < 0); } // Disconnect to changes. - for (RBSet<TileSelection>::Element *E = tiles.front(); E; E = E->next()) { - const Vector2i &coords = E->get().tile; - const int &alternative = E->get().alternative; + for (const TileSelection &E : tiles) { + const Vector2i &coords = E.tile; + const int &alternative = E.alternative; if (tile_set_atlas_source && tile_set_atlas_source->has_tile(coords) && tile_set_atlas_source->has_alternative_tile(coords, alternative)) { TileData *tile_data = tile_set_atlas_source->get_tile_data(coords, alternative); @@ -498,9 +498,9 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::edit(TileSetAtlasSource *p_ tiles = RBSet<TileSelection>(p_tiles); // Connect to changes. - for (RBSet<TileSelection>::Element *E = p_tiles.front(); E; E = E->next()) { - const Vector2i &coords = E->get().tile; - const int &alternative = E->get().alternative; + for (const TileSelection &E : p_tiles) { + const Vector2i &coords = E.tile; + const int &alternative = E.alternative; if (tile_set_atlas_source->has_tile(coords) && tile_set_atlas_source->has_alternative_tile(coords, alternative)) { TileData *tile_data = tile_set_atlas_source->get_tile_data(coords, alternative); @@ -1313,9 +1313,9 @@ void TileSetAtlasSourceEditor::_end_dragging() { switch (drag_type) { case DRAG_TYPE_CREATE_TILES: undo_redo->create_action(TTR("Create tiles")); - 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()); + for (const Vector2i &E : drag_modified_tiles) { + undo_redo->add_do_method(tile_set_atlas_source, "create_tile", E); + undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", E); } undo_redo->commit_action(false); break; @@ -1330,8 +1330,8 @@ void TileSetAtlasSourceEditor::_end_dragging() { tile_set_atlas_source->get_property_list(&list); HashMap<Vector2i, List<const PropertyInfo *>> per_tile = _group_properties_per_tiles(list, tile_set_atlas_source); undo_redo->create_action(TTR("Remove tiles")); - for (RBSet<Vector2i>::Element *E = drag_modified_tiles.front(); E; E = E->next()) { - Vector2i coords = E->get(); + for (const Vector2i &E : drag_modified_tiles) { + Vector2i coords = E; undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", coords); undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", coords); if (per_tile.has(coords)) { @@ -1384,8 +1384,8 @@ void TileSetAtlasSourceEditor::_end_dragging() { undo_redo->create_action(TTR("Remove tiles")); undo_redo->add_do_method(this, "_set_selection_from_array", Array()); - for (RBSet<Vector2i>::Element *E = to_delete.front(); E; E = E->next()) { - Vector2i coords = E->get(); + for (const Vector2i &E : to_delete) { + Vector2i coords = E; undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", coords); undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", coords); if (per_tile.has(coords)) { @@ -1549,8 +1549,8 @@ void TileSetAtlasSourceEditor::_menu_option(int p_option) { // Remove tiles RBSet<Vector2i> removed; - for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { - TileSelection selected = E->get(); + for (const TileSelection &E : selection) { + TileSelection selected = E; if (selected.alternative == 0) { // Remove a tile. undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", selected.tile); @@ -1569,8 +1569,8 @@ void TileSetAtlasSourceEditor::_menu_option(int p_option) { } // Remove alternatives - for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { - TileSelection selected = E->get(); + for (const TileSelection &E : selection) { + TileSelection selected = E; if (selected.alternative > 0 && !removed.has(selected.tile)) { // Remove an alternative tile. undo_redo->add_do_method(tile_set_atlas_source, "remove_alternative_tile", selected.tile, selected.alternative); @@ -1608,13 +1608,13 @@ void TileSetAtlasSourceEditor::_menu_option(int p_option) { case TILE_CREATE_ALTERNATIVE: { undo_redo->create_action(TTR("Create tile alternatives")); Array array; - 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); - array.push_back(E->get().tile); + for (const TileSelection &E : selection) { + if (E.alternative == 0) { + int next_id = tile_set_atlas_source->get_next_alternative_tile_id(E.tile); + undo_redo->add_do_method(tile_set_atlas_source, "create_alternative_tile", E.tile, next_id); + array.push_back(E.tile); array.push_back(next_id); - undo_redo->add_undo_method(tile_set_atlas_source, "remove_alternative_tile", E->get().tile, next_id); + undo_redo->add_undo_method(tile_set_atlas_source, "remove_alternative_tile", E.tile, next_id); } } undo_redo->add_do_method(this, "_set_selection_from_array", array); @@ -1658,9 +1658,9 @@ void TileSetAtlasSourceEditor::_set_selection_from_array(Array p_selection) { Array TileSetAtlasSourceEditor::_get_selection_as_array() { Array output; - for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { - output.push_back(E->get().tile); - output.push_back(E->get().alternative); + for (const TileSelection &E : selection) { + output.push_back(E.tile); + output.push_back(E.alternative); } return output; } @@ -1672,8 +1672,8 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { // Draw the selected tile. if (tools_button_group->get_pressed_button() == tool_select_button) { - for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { - TileSelection selected = E->get(); + for (const TileSelection &E : selection) { + TileSelection selected = E; if (selected.alternative == 0) { // Draw the rect. for (int frame = 0; frame < tile_set_atlas_source->get_tile_animation_frames_count(selected.tile); frame++) { @@ -1722,9 +1722,9 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { if (drag_type == DRAG_TYPE_REMOVE_TILES) { // Draw the tiles to be removed. - 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); + for (const Vector2i &E : drag_modified_tiles) { + for (int frame = 0; frame < tile_set_atlas_source->get_tile_animation_frames_count(E); frame++) { + tile_atlas_control->draw_rect(tile_set_atlas_source->get_tile_texture_region(E, frame), Color(0.0, 0.0, 0.0), false); } } } else if (drag_type == DRAG_TYPE_RECT_SELECT || drag_type == DRAG_TYPE_REMOVE_TILES_USING_RECT) { @@ -1749,8 +1749,8 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { } } - for (RBSet<Vector2i>::Element *E = to_paint.front(); E; E = E->next()) { - Vector2i coords = E->get(); + for (const Vector2i &E : to_paint) { + Vector2i coords = E; tile_atlas_control->draw_rect(tile_set_atlas_source->get_tile_texture_region(coords), color, false); } } else if (drag_type == DRAG_TYPE_CREATE_TILES_USING_RECT) { @@ -1837,19 +1837,19 @@ 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 (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { - if (E->get().alternative != 0) { + for (const TileSelection &E : selection) { + if (E.alternative != 0) { continue; } - Rect2i texture_region = tile_set_atlas_source->get_tile_texture_region(E->get().tile); - Vector2i position = texture_region.get_center() + tile_set_atlas_source->get_tile_effective_texture_offset(E->get().tile, 0); + Rect2i texture_region = tile_set_atlas_source->get_tile_texture_region(E.tile); + Vector2i position = texture_region.get_center() + tile_set_atlas_source->get_tile_effective_texture_offset(E.tile, 0); Transform2D xform = tile_atlas_control->get_parent_control()->get_transform(); xform.translate(position); TileMapCell cell; cell.source_id = tile_set_atlas_source_id; - cell.set_atlas_coords(E->get().tile); + cell.set_atlas_coords(E.tile); cell.alternative_tile = 0; current_tile_data_editor->draw_over_tile(tile_atlas_control_unscaled, xform, cell, true); } @@ -1962,8 +1962,8 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() { } // Draw selected tile. - for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { - TileSelection selected = E->get(); + for (const TileSelection &E : selection) { + TileSelection selected = E; if (selected.alternative >= 1) { Rect2i rect = tile_atlas_view->get_alternative_tile_rect(selected.tile, selected.alternative); if (rect != Rect2i()) { @@ -2005,11 +2005,11 @@ 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 (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { - if (E->get().alternative == 0) { + for (const TileSelection &E : selection) { + if (E.alternative == 0) { continue; } - Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E->get().tile, E->get().alternative); + Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E.tile, E.alternative); Vector2 position = rect.get_center(); Transform2D xform = alternative_tiles_control->get_parent_control()->get_transform(); @@ -2017,8 +2017,8 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw() { TileMapCell cell; cell.source_id = tile_set_atlas_source_id; - cell.set_atlas_coords(E->get().tile); - cell.alternative_tile = E->get().alternative; + cell.set_atlas_coords(E.tile); + cell.alternative_tile = E.alternative; current_tile_data_editor->draw_over_tile(alternative_tiles_control_unscaled, xform, cell, true); } } diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index c5669f3eda..f8797ded66 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1670,7 +1670,7 @@ void VisualShaderEditor::_update_uniforms(bool p_update_refs) { } } -void VisualShaderEditor::_update_uniform_refs(RBSet<String> &p_deleted_names) { +void VisualShaderEditor::_update_uniform_refs(HashSet<String> &p_deleted_names) { for (int i = 0; i < VisualShader::TYPE_MAX; i++) { VisualShader::Type type = VisualShader::Type(i); @@ -2288,7 +2288,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); - RBSet<String> changed_names; + HashSet<String> changed_names; changed_names.insert(node->get_uniform_name()); _update_uniform_refs(changed_names); @@ -3108,7 +3108,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { } } - RBSet<String> uniform_names; + HashSet<String> uniform_names; for (const int &F : p_nodes) { Ref<VisualShaderNode> node = visual_shader->get_node(type, F); @@ -3212,11 +3212,11 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) { undo_redo->create_action(TTR("Convert Uniform Node(s) To Constant(s)")); } - const RBSet<int> ¤t_set = p_vice_versa ? selected_uniforms : selected_constants; - RBSet<String> deleted_names; + const HashSet<int> ¤t_set = p_vice_versa ? selected_uniforms : selected_constants; + HashSet<String> deleted_names; - for (RBSet<int>::Element *E = current_set.front(); E; E = E->next()) { - int node_id = E->get(); + for (const int &E : current_set) { + int node_id = E; Ref<VisualShaderNode> node = visual_shader->get_node(type_id, node_id); bool caught = false; Variant var; @@ -3789,7 +3789,7 @@ void VisualShaderEditor::_dup_copy_nodes(int p_type, List<CopyItem> &r_items, Li selection_center.x = 0.0f; selection_center.y = 0.0f; - RBSet<int> nodes; + HashSet<int> nodes; for (int i = 0; i < graph->get_child_count(); i++) { GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i)); @@ -3869,8 +3869,8 @@ 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; HashMap<int, int> connection_remap; - RBSet<int> unsupported_set; - RBSet<int> added_set; + HashSet<int> unsupported_set; + HashSet<int> added_set; for (CopyItem &item : r_items) { if (item.disabled) { diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index 003c8b15a8..1b56892ebf 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -358,8 +358,8 @@ class VisualShaderEditor : public VBoxContainer { int from_node = -1; int from_slot = -1; - RBSet<int> selected_constants; - RBSet<int> selected_uniforms; + HashSet<int> selected_constants; + HashSet<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(RBSet<String> &p_names); + void _update_uniform_refs(HashSet<String> &p_names); void _update_varyings(); void _visibility_changed(); diff --git a/editor/pot_generator.cpp b/editor/pot_generator.cpp index c46a4f5a86..a00df0ef40 100644 --- a/editor/pot_generator.cpp +++ b/editor/pot_generator.cpp @@ -46,8 +46,8 @@ void POTGenerator::_print_all_translation_strings() { print_line("msgid: " + E.key()); print_line("context: " + v_md[i].ctx); print_line("msgid_plural: " + v_md[i].plural); - for (RBSet<String>::Element *F = v_md[i].locations.front(); F; F = F->next()) { - print_line("location: " + F->get()); + for (const String &F : v_md[i].locations) { + print_line("location: " + F); } } } @@ -127,14 +127,14 @@ void POTGenerator::_write_to_pot(const String &p_file) { 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 RBSet<String> &locations = v_msgid_data[i].locations; + const HashSet<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 (RBSet<String>::Element *E = locations.front(); E; E = E->next()) { - file->store_line("#: " + E->get().trim_prefix("res://")); + for (const String &E : locations) { + file->store_line("#: " + E.trim_prefix("res://")); } // Write context. diff --git a/editor/pot_generator.h b/editor/pot_generator.h index b24eadfd95..7b14eb027e 100644 --- a/editor/pot_generator.h +++ b/editor/pot_generator.h @@ -33,7 +33,7 @@ #include "core/io/file_access.h" #include "core/templates/hash_map.h" -#include "core/templates/rb_set.h" +#include "core/templates/hash_set.h" //#define DEBUG_POT @@ -43,7 +43,7 @@ class POTGenerator { struct MsgidData { String ctx; String plural; - RBSet<String> locations; + HashSet<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. HashMap<String, Vector<MsgidData>> all_translation_strings; diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 839378dad2..503eb5000b 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -366,10 +366,13 @@ void ProjectExportDialog::_update_feature_list() { } custom_feature_display->clear(); - for (RBSet<String>::Element *E = fset.front(); E; E = E->next()) { - String f = E->get(); - if (E->next()) { + bool first = true; + for (const String &E : fset) { + String f = E; + if (!first) { f += ", "; + } else { + first = false; } custom_feature_display->add_text(f); } diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index d74cfe4ec0..379c3bbb01 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1064,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 RBSet<String> &get_selected_project_keys() const; + const HashSet<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; @@ -1090,7 +1090,7 @@ private: String _search_term; FilterOption _order_option; - RBSet<String> _selected_project_keys; + HashSet<String> _selected_project_keys; String _last_clicked; // Project key VBoxContainer *_scroll_children; int _icon_load_index; @@ -1258,7 +1258,7 @@ void ProjectList::load_projects() { List<PropertyInfo> properties; EditorSettings::get_singleton()->get_property_list(&properties); - RBSet<String> favorites; + HashSet<String> favorites; // Find favourites... for (const PropertyInfo &E : properties) { String property_key = E.name; @@ -1504,7 +1504,7 @@ void ProjectList::sort_projects() { update_dock_menu(); } -const RBSet<String> &ProjectList::get_selected_project_keys() const { +const HashSet<String> &ProjectList::get_selected_project_keys() const { // Faster if that's all you need return _selected_project_keys; } @@ -1539,7 +1539,7 @@ int ProjectList::get_single_selected_index() const { String key; if (_selected_project_keys.size() == 1) { // Only one selected - key = _selected_project_keys.front()->get(); + key = *_selected_project_keys.begin(); } else { // Multiple selected, consider the last clicked one as "main" key = _last_clicked; @@ -1884,6 +1884,16 @@ void ProjectManager::_notification(int p_what) { if (open_templates->is_visible()) { open_templates->popup_centered(); } + real_t size = get_size().x / EDSCALE; + asset_library->set_columns(size < 1000 ? 1 : 2); + // Adjust names of tabs to fit the new size. + if (size < 650) { + local_projects_hb->set_name(TTR("Local")); + asset_library->set_name(TTR("Asset Library")); + } else { + local_projects_hb->set_name(TTR("Local Projects")); + asset_library->set_name(TTR("Asset Library Projects")); + } } break; case NOTIFICATION_READY: { @@ -2095,12 +2105,12 @@ void ProjectManager::_confirm_update_settings() { void ProjectManager::_open_selected_projects() { // Show loading text to tell the user that the project manager is busy loading. // This is especially important for the HTML5 project manager. - loading_label->set_modulate(Color(1, 1, 1)); + loading_label->show(); - const RBSet<String> &selected_list = _project_list->get_selected_project_keys(); + const HashSet<String> &selected_list = _project_list->get_selected_project_keys(); - for (const RBSet<String>::Element *E = selected_list.front(); E; E = E->next()) { - const String &selected = E->get(); + for (const String &E : selected_list) { + const String &selected = E; String path = EditorSettings::get_singleton()->get("projects/" + selected); String conf = path.plus_file("project.godot"); @@ -2146,7 +2156,7 @@ void ProjectManager::_open_selected_projects() { } void ProjectManager::_open_selected_projects_ask() { - const RBSet<String> &selected_list = _project_list->get_selected_project_keys(); + const HashSet<String> &selected_list = _project_list->get_selected_project_keys(); if (selected_list.size() < 1) { return; @@ -2261,7 +2271,7 @@ void ProjectManager::_run_project_confirm() { } void ProjectManager::_run_project() { - const RBSet<String> &selected_list = _project_list->get_selected_project_keys(); + const HashSet<String> &selected_list = _project_list->get_selected_project_keys(); if (selected_list.size() < 1) { return; @@ -2321,14 +2331,14 @@ void ProjectManager::_import_project() { } void ProjectManager::_rename_project() { - const RBSet<String> &selected_list = _project_list->get_selected_project_keys(); + const HashSet<String> &selected_list = _project_list->get_selected_project_keys(); if (selected_list.size() == 0) { return; } - for (RBSet<String>::Element *E = selected_list.front(); E; E = E->next()) { - const String &selected = E->get(); + for (const String &E : selected_list) { + const String &selected = E; String path = EditorSettings::get_singleton()->get("projects/" + selected); npdialog->set_project_path(path); npdialog->set_mode(ProjectDialog::MODE_RENAME); @@ -2347,7 +2357,7 @@ void ProjectManager::_erase_missing_projects_confirm() { } void ProjectManager::_erase_project() { - const RBSet<String> &selected_list = _project_list->get_selected_project_keys(); + const HashSet<String> &selected_list = _project_list->get_selected_project_keys(); if (selected_list.size() == 0) { return; @@ -2404,7 +2414,7 @@ void ProjectManager::_files_dropped(PackedStringArray p_files) { _install_project(p_files[0], file.substr(0, file.length() - 4).capitalize()); return; } - RBSet<String> folders_set; + HashSet<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]; @@ -2412,8 +2422,8 @@ void ProjectManager::_files_dropped(PackedStringArray p_files) { } if (folders_set.size() > 0) { PackedStringArray folders; - for (RBSet<String>::Element *E = folders_set.front(); E; E = E->next()) { - folders.push_back(E->get()); + for (const String &E : folders_set) { + folders.push_back(E); } bool confirm = true; @@ -2567,14 +2577,14 @@ ProjectManager::ProjectManager() { tabs->set_anchors_and_offsets_preset(Control::PRESET_WIDE); tabs->connect("tab_changed", callable_mp(this, &ProjectManager::_on_tab_changed)); - HBoxContainer *projects_hb = memnew(HBoxContainer); - projects_hb->set_name(TTR("Local Projects")); - tabs->add_child(projects_hb); + local_projects_hb = memnew(HBoxContainer); + local_projects_hb->set_name(TTR("Local Projects")); + tabs->add_child(local_projects_hb); { // Projects + search bar VBoxContainer *search_tree_vb = memnew(VBoxContainer); - projects_hb->add_child(search_tree_vb); + local_projects_hb->add_child(search_tree_vb); search_tree_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); HBoxContainer *hb = memnew(HBoxContainer); @@ -2592,8 +2602,8 @@ ProjectManager::ProjectManager() { loading_label->add_theme_font_override("font", get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); loading_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); hb->add_child(loading_label); - // Hide the label but make it still take up space. This prevents reflows when showing the label. - loading_label->set_modulate(Color(0, 0, 0, 0)); + // The loading label is shown later. + loading_label->hide(); Label *sort_label = memnew(Label); sort_label->set_text(TTR("Sort:")); @@ -2601,7 +2611,7 @@ ProjectManager::ProjectManager() { filter_option = memnew(OptionButton); filter_option->set_clip_text(true); - filter_option->set_custom_minimum_size(Size2(150 * EDSCALE, 10 * EDSCALE)); + filter_option->set_h_size_flags(Control::SIZE_EXPAND_FILL); filter_option->connect("item_selected", callable_mp(this, &ProjectManager::_on_order_option_changed)); hb->add_child(filter_option); @@ -2630,7 +2640,7 @@ ProjectManager::ProjectManager() { // Project tab side bar VBoxContainer *tree_vb = memnew(VBoxContainer); tree_vb->set_custom_minimum_size(Size2(120, 120)); - projects_hb->add_child(tree_vb); + local_projects_hb->add_child(tree_vb); Button *create = memnew(Button); create->set_text(TTR("New Project")); @@ -2727,6 +2737,12 @@ ProjectManager::ProjectManager() { language_btn->set_icon(get_theme_icon(SNAME("Environment"), SNAME("EditorIcons"))); language_btn->set_focus_mode(Control::FOCUS_NONE); language_btn->connect("item_selected", callable_mp(this, &ProjectManager::_language_selected)); +#ifdef ANDROID_ENABLED + // The language selection dropdown doesn't work on Android (as the setting isn't saved), see GH-60353. + // Also, the dropdown it spawns is very tall and can't be scrolled without a hardware mouse. + // Hiding the language selection dropdown also leaves more space for the version label to display. + language_btn->hide(); +#endif Vector<String> editor_languages; List<PropertyInfo> editor_settings_properties; @@ -2869,8 +2885,8 @@ ProjectManager::ProjectManager() { SceneTree::get_singleton()->get_root()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped)); - // Define a minimum window size to prevent UI elements from overlapping or being cut off - DisplayServer::get_singleton()->window_set_min_size(Size2(750, 420) * EDSCALE); + // Define a minimum window size to prevent UI elements from overlapping or being cut off. + DisplayServer::get_singleton()->window_set_min_size(Size2(520, 350) * EDSCALE); // Resize the bootsplash window based on Editor display scale EDSCALE. float scale_factor = MAX(1, EDSCALE); diff --git a/editor/project_manager.h b/editor/project_manager.h index 93a6e1c405..2ffe293f3b 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -70,6 +70,7 @@ class ProjectManager : public Control { Button *erase_missing_btn = nullptr; Button *about_btn = nullptr; + HBoxContainer *local_projects_hb = nullptr; EditorAssetLibrary *asset_library = nullptr; EditorFileDialog *scan_dir = nullptr; diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index bd0affbcc3..14a0427e18 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() { - RBSet<String> presets; + HashSet<String> presets; presets.insert("bptc"); presets.insert("s3tc"); @@ -292,8 +292,8 @@ 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 (RBSet<String>::Element *E = presets.front(); E; E = E->next()) { - feature_box->add_item(E->get(), id++); + for (const String &E : presets) { + feature_box->add_item(E, id++); } } diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 71cdcc2580..da67ed79ba 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -137,14 +137,14 @@ void CustomPropertyEditor::_menu_option(int p_which) { ResourceLoader::get_recognized_extensions_for_type(type.get_slice(",", i), &extensions); } - RBSet<String> valid_extensions; + HashSet<String> valid_extensions; for (const String &E : extensions) { valid_extensions.insert(E); } file->clear_filters(); - for (RBSet<String>::Element *E = valid_extensions.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); + for (const String &E : valid_extensions) { + file->add_filter("*." + E + " ; " + E.to_upper()); } file->popup_file_dialog(); @@ -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); - RBSet<String> valid_inheritors; + HashSet<String> valid_inheritors; valid_inheritors.insert(base); List<StringName> inheritors; ClassDB::get_inheriters_from_class(base.strip_edges(), &inheritors); @@ -890,8 +890,8 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: E = E->next(); } - for (RBSet<String>::Element *j = valid_inheritors.front(); j; j = j->next()) { - const String &t = j->get(); + for (const String &j : valid_inheritors) { + const String &t = j; bool is_custom_resource = false; Ref<Texture2D> icon; diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp index 38d909038f..5a8fe24518 100644 --- a/editor/reparent_dialog.cpp +++ b/editor/reparent_dialog.cpp @@ -57,7 +57,7 @@ void ReparentDialog::_reparent() { } } -void ReparentDialog::set_current(const RBSet<Node *> &p_selection) { +void ReparentDialog::set_current(const HashSet<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 a5a9818e7f..49b00661a0 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 RBSet<Node *> &p_selection); + void set_current(const HashSet<Node *> &p_selection); ReparentDialog(); ~ReparentDialog(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 99a1cffa30..c1cc144ff5 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -715,7 +715,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } List<Node *> nodes = editor_selection->get_selected_node_list(); - RBSet<Node *> nodeset; + HashSet<Node *> nodeset; for (Node *E : nodes) { nodeset.insert(E); } @@ -1527,8 +1527,8 @@ bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_var return false; } -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; +void SceneTreeDock::perform_node_renames(Node *p_base, HashMap<Node *, NodePath> *p_renames, HashMap<Ref<Animation>, HashSet<int>> *r_rem_anims) { + HashMap<Ref<Animation>, HashSet<int>> rem_anims; if (!r_rem_anims) { r_rem_anims = &rem_anims; } @@ -1580,14 +1580,14 @@ void SceneTreeDock::perform_node_renames(Node *p_base, HashMap<Node *, NodePath> for (const StringName &E : anims) { Ref<Animation> anim = ap->get_animation(E); if (!r_rem_anims->has(anim)) { - r_rem_anims->insert(anim, RBSet<int>()); - RBSet<int> &ran = r_rem_anims->find(anim)->value; + r_rem_anims->insert(anim, HashSet<int>()); + HashSet<int> &ran = r_rem_anims->find(anim)->value; for (int i = 0; i < anim->get_track_count(); i++) { ran.insert(i); } } - RBSet<int> &ran = r_rem_anims->find(anim)->value; + HashSet<int> &ran = r_rem_anims->find(anim)->value; if (anim.is_null()) { continue; @@ -1610,11 +1610,11 @@ void SceneTreeDock::perform_node_renames(Node *p_base, HashMap<Node *, NodePath> //will be erased int idx = 0; - RBSet<int>::Element *EI = ran.front(); + HashSet<int>::Iterator EI = ran.begin(); ERR_FAIL_COND(!EI); //bug - while (EI->get() != i) { + while (*EI != i) { idx++; - EI = EI->next(); + ++EI; ERR_FAIL_COND(!EI); //another bug } diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index eff34b518c..54e6108d84 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -294,7 +294,7 @@ public: 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, 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); + void perform_node_renames(Node *p_base, HashMap<Node *, NodePath> *p_renames, HashMap<Ref<Animation>, HashSet<int>> *r_rem_anims = nullptr); SceneTreeEditor *get_tree_editor() { return scene_tree; } EditorData *get_editor_data() { return editor_data; } diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index afb42efa76..fbcf9739ca 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -874,7 +874,7 @@ Node *SceneTreeEditor::get_selected() { return selected; } -void SceneTreeEditor::set_marked(const RBSet<Node *> &p_marked, bool p_selectable, bool p_children_selectable) { +void SceneTreeEditor::set_marked(const HashSet<Node *> &p_marked, bool p_selectable, bool p_children_selectable) { if (tree_dirty) { _update_tree(); } @@ -885,7 +885,7 @@ void SceneTreeEditor::set_marked(const RBSet<Node *> &p_marked, bool p_selectabl } void SceneTreeEditor::set_marked(Node *p_marked, bool p_selectable, bool p_children_selectable) { - RBSet<Node *> s; + HashSet<Node *> s; if (p_marked) { s.insert(p_marked); } diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h index 604d77cf76..1f79b48449 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; - RBSet<Node *> marked; + HashSet<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 RBSet<Node *> &p_marked, bool p_selectable = false, bool p_children_selectable = true); + void set_marked(const HashSet<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 046e8fcdfc..9c322320b8 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(); - RBSet<String> extensions; + HashSet<String> extensions; for (int i = 0; i < SHADER_TYPE_MAX; i++) { for (const String &ext : language_data[i].extensions) { diff --git a/editor/translations/extract.py b/editor/translations/extract.py index bd32fc01c7..7f3da400e7 100755 --- a/editor/translations/extract.py +++ b/editor/translations/extract.py @@ -100,6 +100,7 @@ class ExtractType(enum.IntEnum): TEXT = 1 PROPERTY_PATH = 2 GROUP = 3 + SUBGROUP = 4 # Regex "(?P<name>([^"\\]|\\.)*)" creates a group named `name` that matches a string. @@ -115,19 +116,23 @@ message_patterns = { ): ExtractType.TEXT, re.compile(r'_initial_set\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH, re.compile(r'GLOBAL_DEF(_RST)?(_NOVAL)?(_BASIC)?\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH, - re.compile(r'GLOBAL_DEF_BASIC\(vformat\("(?P<message>layer_names/\w+)/layer_%d"'): ExtractType.PROPERTY_PATH, re.compile(r'EDITOR_DEF(_RST)?\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH, re.compile( r'EDITOR_SETTING(_USAGE)?\(Variant::[_A-Z0-9]+, [_A-Z0-9]+, "(?P<message>[^"]+?)",' ): ExtractType.PROPERTY_PATH, re.compile( - r'(ADD_PROPERTYI?|ImportOption|ExportOption)\(PropertyInfo\(Variant::[_A-Z0-9]+, "(?P<message>[^"]+?)"[,)]' + r"(ADD_PROPERTYI?|ImportOption|ExportOption)\(PropertyInfo\(" + + r"Variant::[_A-Z0-9]+" # Name + + r', "(?P<message>[^"]+)"' # Type + + r'(, [_A-Z0-9]+(, "([^"\\]|\\.)*"(, (?P<usage>[_A-Z0-9]+))?)?|\))' # [, hint[, hint string[, usage]]]. ): ExtractType.PROPERTY_PATH, - re.compile( - r"(?!#define )LIMPL_PROPERTY(_RANGE)?\(Variant::[_A-Z0-9]+, (?P<message>[^,]+?)," - ): ExtractType.PROPERTY_PATH, - re.compile(r'ADD_GROUP\("(?P<message>[^"]+?)", "(?P<prefix>[^"]*?)"\)'): ExtractType.GROUP, - re.compile(r'#define WRTC_\w+ "(?P<message>[^"]+?)"'): ExtractType.PROPERTY_PATH, + re.compile(r'ADD_ARRAY\("(?P<message>[^"]+)", '): ExtractType.PROPERTY_PATH, + re.compile(r'ADD_ARRAY_COUNT(_WITH_USAGE_FLAGS)?\("(?P<message>[^"]+)", '): ExtractType.TEXT, + re.compile(r'(ADD_GROUP|GNAME)\("(?P<message>[^"]+)", "(?P<prefix>[^"]*)"\)'): ExtractType.GROUP, + re.compile(r'ADD_GROUP_INDENT\("(?P<message>[^"]+)", "(?P<prefix>[^"]*)", '): ExtractType.GROUP, + re.compile(r'ADD_SUBGROUP\("(?P<message>[^"]+)", "(?P<prefix>[^"]*)"\)'): ExtractType.SUBGROUP, + re.compile(r'ADD_SUBGROUP_INDENT\("(?P<message>[^"]+)", "(?P<prefix>[^"]*)", '): ExtractType.GROUP, + re.compile(r'PNAME\("(?P<message>[^"]+)"\)'): ExtractType.PROPERTY_PATH, } theme_property_patterns = { re.compile(r'set_(constant|font|font_size|stylebox|color|icon)\("(?P<message>[^"]+)", '): ExtractType.PROPERTY_PATH, @@ -203,6 +208,7 @@ def process_file(f, fname): is_block_translator_comment = False translator_comment = "" current_group = "" + current_subgroup = "" patterns = message_patterns if os.path.basename(fname) == "default_theme.cpp": @@ -239,11 +245,25 @@ def process_file(f, fname): if extract_type == ExtractType.TEXT: _add_message(msg, msg_plural, msgctx, location, translator_comment) elif extract_type == ExtractType.PROPERTY_PATH: - if current_group: + if captures.get("usage") == "PROPERTY_USAGE_NO_EDITOR": + continue + + if current_subgroup: + if msg.startswith(current_subgroup): + msg = msg[len(current_subgroup) :] + elif current_subgroup.startswith(msg): + pass # Keep this as-is. See EditorInspector::update_tree(). + else: + current_subgroup = "" + elif current_group: if msg.startswith(current_group): msg = msg[len(current_group) :] + elif current_group.startswith(msg): + pass # Keep this as-is. See EditorInspector::update_tree(). else: current_group = "" + current_subgroup = "" + if "." in msg: # Strip feature tag. msg = msg.split(".", 1)[0] for part in msg.split("/"): @@ -251,6 +271,10 @@ def process_file(f, fname): elif extract_type == ExtractType.GROUP: _add_message(msg, msg_plural, msgctx, location, translator_comment) current_group = captures["prefix"] + current_subgroup = "" + elif extract_type == ExtractType.SUBGROUP: + _add_message(msg, msg_plural, msgctx, location, translator_comment) + current_subgroup = captures["prefix"] translator_comment = "" l = f.readline() |