Use range iterators for RBSet in most cases

This commit is contained in:
Aaron Record 2022-05-18 17:43:40 -06:00
parent 71c40ff4da
commit 900c676b02
84 changed files with 782 additions and 782 deletions

View file

@ -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) {

View file

@ -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.
}
}

View file

@ -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

View file

@ -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);
}
}

View file

@ -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));
@ -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);

View file

@ -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) {

View file

@ -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;
}
@ -879,8 +879,8 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
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")) {

View file

@ -166,15 +166,15 @@ 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;
@ -182,8 +182,8 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) {
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 (const StringName &F : E.value) {
dis_props.push_back(String(E.key) + ":" + String(F));
}
}

View file

@ -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);
}
}

View file

@ -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;
}
}
@ -270,8 +270,8 @@ 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);
}
}

View file

@ -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;
@ -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);
@ -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;
@ -3680,8 +3680,8 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
for (KeyValue<String, RBSet<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);
}

View file

@ -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();
@ -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;
@ -599,8 +599,8 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const {
}
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();
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;
}
@ -651,8 +651,8 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_
// 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.

View file

@ -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;
}

View file

@ -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);
}
}

View file

@ -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 (Collada::Vertex &F : vertex_set) {
vertex_array.write[F.idx] = F;
}
if (has_weights) {
@ -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;
}
}

View file

@ -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++) {

View file

@ -6710,8 +6710,8 @@ RBSet<RID> _get_physics_bodies_rid(Node *node) {
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());
for (const PhysicsBody3D *I : child_nodes) {
rids.insert(I->get_rid());
}
return rids;
@ -6755,8 +6755,8 @@ 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());
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;

View file

@ -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++) {

View file

@ -693,8 +693,8 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
_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;

View file

@ -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;

View file

@ -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));
}
}
}

View file

@ -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;

View file

@ -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);
}
}

View file

@ -3215,8 +3215,8 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) {
const RBSet<int> &current_set = p_vice_versa ? selected_uniforms : selected_constants;
RBSet<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;

View file

@ -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);
}
}
}
@ -133,8 +133,8 @@ void POTGenerator::_write_to_pot(const String &p_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.

View file

@ -2099,8 +2099,8 @@ void ProjectManager::_open_selected_projects() {
const RBSet<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");
@ -2327,8 +2327,8 @@ void ProjectManager::_rename_project() {
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);
@ -2412,8 +2412,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;

View file

@ -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++);
}
}

View file

@ -143,8 +143,8 @@ void CustomPropertyEditor::_menu_option(int p_which) {
}
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();
@ -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;