From 10a95cb4679f3ad38b26080f5d390e6b14aacca6 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 11 Dec 2021 23:13:05 +0100 Subject: [PATCH] More fixes. --- tile_editor/tile_map_editor.cpp | 370 +++++++++--------- tile_editor/tile_map_editor.h | 14 +- tile_editor/tile_set_atlas_source_editor.h | 4 +- tile_editor/tile_set_editor.cpp | 72 ++-- tile_editor/tile_set_editor.h | 4 +- ...tile_set_scenes_collection_source_editor.h | 2 +- tile_editor/tiles_editor_plugin.cpp | 12 +- 7 files changed, 239 insertions(+), 239 deletions(-) diff --git a/tile_editor/tile_map_editor.cpp b/tile_editor/tile_map_editor.cpp index 8c45a90..2391c4a 100644 --- a/tile_editor/tile_map_editor.cpp +++ b/tile_editor/tile_map_editor.cpp @@ -915,18 +915,18 @@ void RTileMapEditorTilesPlugin::_mouse_exited_viewport() { CanvasItemEditor::get_singleton()->update_viewport(); } -TileMapCell RTileMapEditorTilesPlugin::_pick_random_tile(Ref p_pattern) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); +RTileMapCell RTileMapEditorTilesPlugin::_pick_random_tile(Ref p_pattern) { + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return TileMapCell(); + return RTileMapCell(); } Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return TileMapCell(); + return RTileMapCell(); } - TypedArray used_cells = p_pattern->get_used_cells(); + PoolVector2Array used_cells = p_pattern->get_used_cells(); double sum = 0.0; for (int i = 0; i < used_cells.size(); i++) { int source_id = p_pattern->get_cell_source_id(used_cells[i]); @@ -936,8 +936,8 @@ TileMapCell RTileMapEditorTilesPlugin::_pick_random_tile(Ref p_p RTileSetSource *source = *tile_set->get_source(source_id); RTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { - TileData *tile_data = Object::cast_to(atlas_source->get_tile_data(atlas_coords, alternative_tile)); - ERR_FAIL_COND_V(!tile_data, TileMapCell()); + RTileData *tile_data = Object::cast_to(atlas_source->get_tile_data(atlas_coords, alternative_tile)); + ERR_FAIL_COND_V(!tile_data, RTileMapCell()); sum += tile_data->get_probability(); } else { sum += 1.0; @@ -955,36 +955,36 @@ TileMapCell RTileMapEditorTilesPlugin::_pick_random_tile(Ref p_p RTileSetSource *source = *tile_set->get_source(source_id); RTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { - current += Object::cast_to(atlas_source->get_tile_data(atlas_coords, alternative_tile))->get_probability(); + current += Object::cast_to(atlas_source->get_tile_data(atlas_coords, alternative_tile))->get_probability(); } else { current += 1.0; } if (current >= rand) { - return TileMapCell(source_id, atlas_coords, alternative_tile); + return RTileMapCell(source_id, atlas_coords, alternative_tile); } } - return TileMapCell(); + return RTileMapCell(); } -Map RTileMapEditorTilesPlugin::_draw_line(Vector2 p_start_drag_mouse_pos, Vector2 p_from_mouse_pos, Vector2 p_to_mouse_pos, bool p_erase) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); +Map RTileMapEditorTilesPlugin::_draw_line(Vector2 p_start_drag_mouse_pos, Vector2 p_from_mouse_pos, Vector2 p_to_mouse_pos, bool p_erase) { + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map(); + return Map(); } Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Map(); + return Map(); } // Get or create the pattern. - Ref erase_pattern; + Ref erase_pattern; erase_pattern.instance(); erase_pattern->set_cell(Vector2i(0, 0), RTileSet::INVALID_SOURCE, RTileSetSource::INVALID_ATLAS_COORDS, RTileSetSource::INVALID_TILE_ALTERNATIVE); - Ref pattern = p_erase ? erase_pattern : selection_pattern; + Ref pattern = p_erase ? erase_pattern : selection_pattern; - Map output; + Map output; if (!pattern->is_empty()) { // Paint the tiles on the tile map. if (!p_erase && random_tile_checkbox->is_pressed()) { @@ -1001,14 +1001,14 @@ Map RTileMapEditorTilesPlugin::_draw_line(Vector2 p_start Vector2i new_hovered_cell = tile_map->world_to_map(p_to_mouse_pos - mouse_offset); Vector2i drag_start_cell = tile_map->world_to_map(p_start_drag_mouse_pos - mouse_offset); - TypedArray used_cells = pattern->get_used_cells(); + PoolVector2Array used_cells = pattern->get_used_cells(); Vector2i offset = Vector2i(Math::posmod(drag_start_cell.x, pattern->get_size().x), Math::posmod(drag_start_cell.y, pattern->get_size().y)); // Note: no posmodv for Vector2i for now. Meh.s Vector line = RTileMapEditor::get_line(tile_map, (last_hovered_cell - offset) / pattern->get_size(), (new_hovered_cell - offset) / pattern->get_size()); for (int i = 0; i < line.size(); i++) { Vector2i top_left = line[i] * pattern->get_size() + offset; for (int j = 0; j < used_cells.size(); j++) { Vector2i coords = tile_map->map_pattern(top_left, used_cells[j], pattern); - output.insert(coords, TileMapCell(pattern->get_cell_source_id(used_cells[j]), pattern->get_cell_atlas_coords(used_cells[j]), pattern->get_cell_alternative_tile(used_cells[j]))); + output.insert(coords, RTileMapCell(pattern->get_cell_source_id(used_cells[j]), pattern->get_cell_atlas_coords(used_cells[j]), pattern->get_cell_alternative_tile(used_cells[j]))); } } } @@ -1016,15 +1016,15 @@ Map RTileMapEditorTilesPlugin::_draw_line(Vector2 p_start return output; } -Map RTileMapEditorTilesPlugin::_draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); +Map RTileMapEditorTilesPlugin::_draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) { + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map(); + return Map(); } Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Map(); + return Map(); } // Create the rect to draw. @@ -1032,12 +1032,12 @@ Map RTileMapEditorTilesPlugin::_draw_rect(Vector2i p_star rect.size += Vector2i(1, 1); // Get or create the pattern. - Ref erase_pattern; + Ref erase_pattern; erase_pattern.instance(); erase_pattern->set_cell(Vector2i(0, 0), RTileSet::INVALID_SOURCE, RTileSetSource::INVALID_ATLAS_COORDS, RTileSetSource::INVALID_TILE_ALTERNATIVE); - Ref pattern = p_erase ? erase_pattern : selection_pattern; + Ref pattern = p_erase ? erase_pattern : selection_pattern; - Map err_output; + Map err_output; ERR_FAIL_COND_V(pattern->is_empty(), err_output); // Compute the offset to align things to the bottom or right. @@ -1045,7 +1045,7 @@ Map RTileMapEditorTilesPlugin::_draw_rect(Vector2i p_star bool valigned_bottom = p_end_cell.y < p_start_cell.y; Vector2i offset = Vector2i(aligned_right ? -(pattern->get_size().x - (rect.get_size().x % pattern->get_size().x)) : 0, valigned_bottom ? -(pattern->get_size().y - (rect.get_size().y % pattern->get_size().y)) : 0); - Map output; + Map output; if (!pattern->is_empty()) { if (!p_erase && random_tile_checkbox->is_pressed()) { // Paint a random tile. @@ -1057,14 +1057,14 @@ Map RTileMapEditorTilesPlugin::_draw_rect(Vector2i p_star } } else { // Paint the pattern. - TypedArray used_cells = pattern->get_used_cells(); + PoolVector2Array used_cells = pattern->get_used_cells(); for (int x = 0; x <= rect.size.x / pattern->get_size().x; x++) { for (int y = 0; y <= rect.size.y / pattern->get_size().y; y++) { Vector2i pattern_coords = rect.position + Vector2i(x, y) * pattern->get_size() + offset; for (int j = 0; j < used_cells.size(); j++) { Vector2i coords = pattern_coords + used_cells[j]; if (rect.has_point(coords)) { - output.insert(coords, TileMapCell(pattern->get_cell_source_id(used_cells[j]), pattern->get_cell_atlas_coords(used_cells[j]), pattern->get_cell_alternative_tile(used_cells[j]))); + output.insert(coords, RTileMapCell(pattern->get_cell_source_id(used_cells[j]), pattern->get_cell_atlas_coords(used_cells[j]), pattern->get_cell_alternative_tile(used_cells[j]))); } } } @@ -1075,31 +1075,31 @@ Map RTileMapEditorTilesPlugin::_draw_rect(Vector2i p_star return output; } -Map RTileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); +Map RTileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase) { + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map(); + return Map(); } if (tile_map_layer < 0) { - return Map(); + return Map(); } - Map output; + Map output; ERR_FAIL_INDEX_V(tile_map_layer, tile_map->get_layers_count(), output); Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Map(); + return Map(); } // Get or create the pattern. - Ref erase_pattern; + Ref erase_pattern; erase_pattern.instance(); erase_pattern->set_cell(Vector2i(0, 0), RTileSet::INVALID_SOURCE, RTileSetSource::INVALID_ATLAS_COORDS, RTileSetSource::INVALID_TILE_ALTERNATIVE); - Ref pattern = p_erase ? erase_pattern : selection_pattern; + Ref pattern = p_erase ? erase_pattern : selection_pattern; if (!pattern->is_empty()) { - TileMapCell source_cell = tile_map->get_cell(tile_map_layer, p_coords); + RTileMapCell source_cell = tile_map->get_cell(tile_map_layer, p_coords); // If we are filling empty tiles, compute the tilemap boundaries. Rect2i boundaries; @@ -1112,7 +1112,7 @@ Map RTileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i Set already_checked; List to_check; to_check.push_back(p_coords); - while (!to_check.is_empty()) { + while (!to_check.empty()) { Vector2i coords = to_check.back()->get(); to_check.pop_back(); if (!already_checked.has(coords)) { @@ -1129,14 +1129,14 @@ Map RTileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i pattern_coords.x = pattern_coords.x < 0 ? pattern_coords.x + pattern->get_size().x : pattern_coords.x; pattern_coords.y = pattern_coords.y < 0 ? pattern_coords.y + pattern->get_size().y : pattern_coords.y; if (pattern->has_cell(pattern_coords)) { - output.insert(coords, TileMapCell(pattern->get_cell_source_id(pattern_coords), pattern->get_cell_atlas_coords(pattern_coords), pattern->get_cell_alternative_tile(pattern_coords))); + output.insert(coords, RTileMapCell(pattern->get_cell_source_id(pattern_coords), pattern->get_cell_atlas_coords(pattern_coords), pattern->get_cell_alternative_tile(pattern_coords))); } else { - output.insert(coords, TileMapCell()); + output.insert(coords, RTileMapCell()); } } // Get surrounding tiles (handles different tile shapes). - TypedArray around = tile_map->get_surrounding_tiles(coords); + PoolVector2Array around = tile_map->get_surrounding_tiles(coords); for (int i = 0; i < around.size(); i++) { to_check.push_back(around[i]); } @@ -1146,7 +1146,7 @@ Map RTileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i } } else { // Replace all tiles like the source. - TypedArray to_check; + PoolVector2Array to_check; if (source_cell.source_id == RTileSet::INVALID_SOURCE) { Rect2i rect = tile_map->get_used_rect(); if (rect.has_no_area()) { @@ -1175,9 +1175,9 @@ Map RTileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i pattern_coords.x = pattern_coords.x < 0 ? pattern_coords.x + pattern->get_size().x : pattern_coords.x; pattern_coords.y = pattern_coords.y < 0 ? pattern_coords.y + pattern->get_size().y : pattern_coords.y; if (pattern->has_cell(pattern_coords)) { - output.insert(coords, TileMapCell(pattern->get_cell_source_id(pattern_coords), pattern->get_cell_atlas_coords(pattern_coords), pattern->get_cell_alternative_tile(pattern_coords))); + output.insert(coords, RTileMapCell(pattern->get_cell_source_id(pattern_coords), pattern->get_cell_atlas_coords(pattern_coords), pattern->get_cell_alternative_tile(pattern_coords))); } else { - output.insert(coords, TileMapCell()); + output.insert(coords, RTileMapCell()); } } } @@ -1192,7 +1192,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { return; } - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -1234,7 +1234,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { } } undo_redo->add_do_method(this, "_set_tile_map_selection", _get_tile_map_selection()); - undo_redo->commit_action(false); + undo_redo->commit_action(); _update_selection_pattern_from_tilemap_selection(); _update_tileset_selection_from_selection_pattern(); @@ -1242,7 +1242,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { case DRAG_TYPE_MOVE: { if (patterns_item_list->is_visible_in_tree() && patterns_item_list->has_point(patterns_item_list->get_local_mouse_position())) { // Restore the cells. - for (KeyValue kv : drag_modified) { + for (KeyValue kv : drag_modified) { tile_map->set_cell(tile_map_layer, kv.key, kv.value.source_id, kv.value.get_atlas_coords(), kv.value.alternative_tile); } @@ -1256,7 +1256,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { } else { // Get the top-left cell. Vector2i top_left; - if (!tile_map_selection.is_empty()) { + if (!tile_map_selection.empty()) { top_left = tile_map_selection.front()->get(); } for (Set::Element *E = tile_map_selection.front(); E; E = E->next()) { @@ -1267,35 +1267,35 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { Vector2i offset = drag_start_mouse_pos - tile_map->map_to_world(top_left); offset = tile_map->world_to_map(mpos - offset) - tile_map->world_to_map(drag_start_mouse_pos - offset); - TypedArray selection_used_cells = selection_pattern->get_used_cells(); + PoolVector2Array selection_used_cells = selection_pattern->get_used_cells(); // Build the list of cells to undo. Vector2i coords; - Map cells_undo; + Map cells_undo; for (int i = 0; i < selection_used_cells.size(); i++) { coords = tile_map->map_pattern(top_left, selection_used_cells[i], selection_pattern); - cells_undo[coords] = TileMapCell(drag_modified[coords].source_id, drag_modified[coords].get_atlas_coords(), drag_modified[coords].alternative_tile); + cells_undo[coords] = RTileMapCell(drag_modified[coords].source_id, drag_modified[coords].get_atlas_coords(), drag_modified[coords].alternative_tile); coords = tile_map->map_pattern(top_left + offset, selection_used_cells[i], selection_pattern); cells_undo[coords] = TileMapCell(tile_map->get_cell_source_id(tile_map_layer, coords), tile_map->get_cell_atlas_coords(tile_map_layer, coords), tile_map->get_cell_alternative_tile(tile_map_layer, coords)); } // Build the list of cells to do. - Map cells_do; + Map cells_do; for (int i = 0; i < selection_used_cells.size(); i++) { coords = tile_map->map_pattern(top_left, selection_used_cells[i], selection_pattern); - cells_do[coords] = TileMapCell(); + cells_do[coords] = RTileMapCell(); } for (int i = 0; i < selection_used_cells.size(); i++) { coords = tile_map->map_pattern(top_left + offset, selection_used_cells[i], selection_pattern); - cells_do[coords] = TileMapCell(selection_pattern->get_cell_source_id(selection_used_cells[i]), selection_pattern->get_cell_atlas_coords(selection_used_cells[i]), selection_pattern->get_cell_alternative_tile(selection_used_cells[i])); + cells_do[coords] = RTileMapCell(selection_pattern->get_cell_source_id(selection_used_cells[i]), selection_pattern->get_cell_atlas_coords(selection_used_cells[i]), selection_pattern->get_cell_alternative_tile(selection_used_cells[i])); } // Move the tiles. undo_redo->create_action(TTR("Move tiles")); - for (Map::Element *E = cells_do.front(); E; E = E->next()) { + for (Map::Element *E = cells_do.front(); E; E = E->next()) { undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); } - for (Map::Element *E = cells_undo.front(); E; E = E->next()) { + for (Map::Element *E = cells_undo.front(); E; E = E->next()) { undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); } @@ -1314,7 +1314,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { Rect2i rect = Rect2i(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos) - tile_map->world_to_map(drag_start_mouse_pos)).abs(); rect.size += Vector2i(1, 1); - TypedArray coords_array; + PoolVector2Array coords_array; for (int x = rect.position.x; x < rect.get_end().x; x++) { for (int y = rect.position.y; y < rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); @@ -1323,7 +1323,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { } } } - Ref new_selection_pattern = tile_map->get_pattern(tile_map_layer, coords_array); + Ref new_selection_pattern = tile_map->get_pattern(tile_map_layer, coords_array); if (!new_selection_pattern->is_empty()) { selection_pattern = new_selection_pattern; _update_tileset_selection_from_selection_pattern(); @@ -1332,16 +1332,16 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { } break; case DRAG_TYPE_PAINT: { undo_redo->create_action(TTR("Paint tiles")); - for (const KeyValue &E : drag_modified) { + for (const KeyValue &E : drag_modified) { undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, tile_map->get_cell_source_id(tile_map_layer, E.key), tile_map->get_cell_atlas_coords(tile_map_layer, E.key), tile_map->get_cell_alternative_tile(tile_map_layer, E.key)); undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } undo_redo->commit_action(false); } break; case DRAG_TYPE_LINE: { - Map to_draw = _draw_line(drag_start_mouse_pos, drag_start_mouse_pos, mpos, drag_erasing); + Map to_draw = _draw_line(drag_start_mouse_pos, drag_start_mouse_pos, mpos, drag_erasing); undo_redo->create_action(TTR("Paint tiles")); - for (const KeyValue &E : to_draw) { + for (const KeyValue &E : to_draw) { if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } @@ -1351,9 +1351,9 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { undo_redo->commit_action(); } break; case DRAG_TYPE_RECT: { - Map to_draw = _draw_rect(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); + Map to_draw = _draw_rect(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); undo_redo->create_action(TTR("Paint tiles")); - for (const KeyValue &E : to_draw) { + for (const KeyValue &E : to_draw) { if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } @@ -1364,7 +1364,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { } break; case DRAG_TYPE_BUCKET: { undo_redo->create_action(TTR("Paint tiles")); - for (const KeyValue &E : drag_modified) { + for (const KeyValue &E : drag_modified) { undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, tile_map->get_cell_source_id(tile_map_layer, E.key), tile_map->get_cell_atlas_coords(tile_map_layer, E.key), tile_map->get_cell_alternative_tile(tile_map_layer, E.key)); undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } @@ -1373,7 +1373,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { case DRAG_TYPE_CLIPBOARD_PASTE: { Vector2 mouse_offset = (Vector2(tile_map_clipboard->get_size()) / 2.0 - Vector2(0.5, 0.5)) * tile_set->get_tile_size(); undo_redo->create_action(TTR("Paste tiles")); - TypedArray used_cells = tile_map_clipboard->get_used_cells(); + PoolVector2Array used_cells = tile_map_clipboard->get_used_cells(); for (int i = 0; i < used_cells.size(); i++) { Vector2i coords = tile_map->map_pattern(tile_map->world_to_map(mpos - mouse_offset), used_cells[i], tile_map_clipboard); undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, coords, tile_map_clipboard->get_cell_source_id(used_cells[i]), tile_map_clipboard->get_cell_atlas_coords(used_cells[i]), tile_map_clipboard->get_cell_alternative_tile(used_cells[i])); @@ -1388,7 +1388,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { } void RTileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { hovered_tile.source_id = RTileSet::INVALID_SOURCE; hovered_tile.set_atlas_coords(RTileSetSource::INVALID_ATLAS_COORDS); @@ -1437,8 +1437,8 @@ void RTileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { } // Selection if needed. - for (Set::Element *E = tile_set_selection.front(); E; E = E->next()) { - const TileMapCell *selected = &(E->get()); + for (Set::Element *E = tile_set_selection.front(); E; E = E->next()) { + const RTileMapCell *selected = &(E->get()); if (!tile_set->has_source(selected->source_id) || !tile_set->get_source(selected->source_id)->has_tile(selected->get_atlas_coords()) || !tile_set->get_source(selected->source_id)->has_alternative_tile(selected->get_atlas_coords(), selected->alternative_tile)) { @@ -1446,7 +1446,7 @@ void RTileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { } } - if (!tile_map_selection.is_empty()) { + if (!tile_map_selection.empty()) { _update_selection_pattern_from_tilemap_selection(); } else if (tiles_bottom_panel->is_visible_in_tree()) { _update_selection_pattern_from_tileset_tiles_selection(); @@ -1456,14 +1456,14 @@ void RTileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { } void RTileMapEditorTilesPlugin::_fix_invalid_tiles_in_tile_map_selection() { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } Set to_remove; for (Vector2i selected : tile_map_selection) { - TileMapCell cell = tile_map->get_cell(tile_map_layer, selected); + RTileMapCell cell = tile_map->get_cell(tile_map_layer, selected); if (cell.source_id == RTileSet::INVALID_SOURCE && cell.get_atlas_coords() == RTileSetSource::INVALID_ATLAS_COORDS && cell.alternative_tile == RTileSetAtlasSource::INVALID_TILE_ALTERNATIVE) { to_remove.insert(selected); } @@ -1475,7 +1475,7 @@ void RTileMapEditorTilesPlugin::_fix_invalid_tiles_in_tile_map_selection() { } void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tilemap_selection() { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -1489,7 +1489,7 @@ void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tilemap_selection selection_pattern.instance(); - TypedArray coords_array; + PoolVector2Array coords_array; for (Set::Element *E = tile_map_selection.front(); E; E = E->next()) { coords_array.push_back(E->get()); } @@ -1497,7 +1497,7 @@ void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tilemap_selection } void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_selection() { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -1514,23 +1514,23 @@ void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_sel selection_pattern.instance(); // Group per source. - Map> per_source; - for (Set::Element *E = tile_set_selection.front(); E; E = E->next()) { + Map> per_source; + for (Set::Element *E = tile_set_selection.front(); E; E = E->next()) { per_source[E->get().source_id].push_back(&(E->get())); } int vertical_offset = 0; - for (const KeyValue> &E_source : per_source) { + for (const KeyValue> &E_source : per_source) { // Per source. - List unorganized; + List unorganized; Rect2i encompassing_rect_coords; - Map organized_pattern; + Map organized_pattern; RTileSetSource *source = *tile_set->get_source(E_source.key); RTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { // Organize using coordinates. - for (const TileMapCell *current : E_source.value) { + for (const RTileMapCell *current : E_source.value) { if (current->alternative_tile == 0) { organized_pattern[current->get_atlas_coords()] = current; } else { @@ -1539,7 +1539,7 @@ void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_sel } // Compute the encompassing rect for the organized pattern. - Map::Element *E_cell = organized_pattern.front(); + Map::Element *E_cell = organized_pattern.front(); if (E_cell) { encompassing_rect_coords = Rect2i(E_cell->key(), Vector2i(1, 1)); for (; E_cell; E_cell = E_cell->next()) { @@ -1549,18 +1549,18 @@ void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_sel } } else { // Add everything unorganized. - for (const TileMapCell *cell : E_source.value) { + for (const RTileMapCell *cell : E_source.value) { unorganized.push_back(cell); } } // Now add everything to the output pattern. - for (const KeyValue &E_cell : organized_pattern) { + for (const KeyValue &E_cell : organized_pattern) { selection_pattern->set_cell(E_cell.key - encompassing_rect_coords.position + Vector2i(0, vertical_offset), E_cell.value->source_id, E_cell.value->get_atlas_coords(), E_cell.value->alternative_tile); } Vector2i organized_size = selection_pattern->get_size(); int unorganized_index = 0; - for (const TileMapCell *cell : unorganized) { + for (const RTileMapCell *cell : unorganized) { selection_pattern->set_cell(Vector2(organized_size.x + unorganized_index, vertical_offset), cell->source_id, cell->get_atlas_coords(), cell->alternative_tile); unorganized_index++; } @@ -1570,7 +1570,7 @@ void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_sel } void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_pattern_selection() { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -1595,11 +1595,11 @@ void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_pattern_s void RTileMapEditorTilesPlugin::_update_tileset_selection_from_selection_pattern() { tile_set_selection.clear(); - TypedArray used_cells = selection_pattern->get_used_cells(); + PoolVector2Array used_cells = selection_pattern->get_used_cells(); for (int i = 0; i < used_cells.size(); i++) { Vector2i coords = used_cells[i]; if (selection_pattern->get_cell_source_id(coords) != RTileSet::INVALID_SOURCE) { - tile_set_selection.insert(TileMapCell(selection_pattern->get_cell_source_id(coords), selection_pattern->get_cell_atlas_coords(coords), selection_pattern->get_cell_alternative_tile(coords))); + tile_set_selection.insert(RTileMapCell(selection_pattern->get_cell_source_id(coords), selection_pattern->get_cell_atlas_coords(coords), selection_pattern->get_cell_alternative_tile(coords))); } } _update_source_display(); @@ -1608,7 +1608,7 @@ void RTileMapEditorTilesPlugin::_update_tileset_selection_from_selection_pattern } void RTileMapEditorTilesPlugin::_tile_atlas_control_draw() { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -1636,7 +1636,7 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_draw() { // Draw the selection. Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color"); Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0); - for (Set::Element *E = tile_set_selection.front(); E; E = E->next()) { + for (Set::Element *E = tile_set_selection.front(); E; E = E->next()) { if (E->get().source_id == source_id && E->get().alternative_tile == 0) { for (int frame = 0; frame < atlas->get_tile_animation_frames_count(E->get().get_atlas_coords()); frame++) { Color color = selection_color; @@ -1692,7 +1692,7 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_mouse_exited() { } void RTileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref &p_event) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -1737,16 +1737,16 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref mb = p_event; - if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) { + if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) { if (mb->is_pressed()) { // Pressed tile_set_dragging_selection = true; tile_set_drag_start_mouse_pos = tile_atlas_control->get_local_mouse_position(); - if (!mb->is_shift_pressed()) { + if (!mb->get_shift()) { tile_set_selection.clear(); } if (hovered_tile.get_atlas_coords() != RTileSetSource::INVALID_ATLAS_COORDS && hovered_tile.alternative_tile == 0) { - if (mb->is_shift_pressed() && tile_set_selection.has(TileMapCell(source_id, hovered_tile.get_atlas_coords(), 0))) { + if (mb->get_shift() && tile_set_selection.has(RTileMapCell(source_id, hovered_tile.get_atlas_coords(), 0))) { tile_set_selection.erase(TileMapCell(source_id, hovered_tile.get_atlas_coords(), 0)); } else { tile_set_selection.insert(TileMapCell(source_id, hovered_tile.get_atlas_coords(), 0)); @@ -1755,7 +1755,7 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Refis_shift_pressed()) { + if (!mb->get_shift()) { tile_set_selection.clear(); } // Compute the covered area. @@ -1767,12 +1767,12 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Refget_tile_at_coords(start_tile); - if (mb->is_shift_pressed() && start_coords != RTileSetSource::INVALID_ATLAS_COORDS && !tile_set_selection.has(TileMapCell(source_id, start_coords, 0))) { + if (mb->get_shift() && start_coords != RTileSetSource::INVALID_ATLAS_COORDS && !tile_set_selection.has(RTileMapCell(source_id, start_coords, 0))) { // Remove from the selection. for (int x = region.position.x; x < region.get_end().x; x++) { for (int y = region.position.y; y < region.get_end().y; y++) { Vector2i tile_coords = atlas->get_tile_at_coords(Vector2i(x, y)); - if (tile_coords != RTileSetSource::INVALID_ATLAS_COORDS && tile_set_selection.has(TileMapCell(source_id, tile_coords, 0))) { + if (tile_coords != RTileSetSource::INVALID_ATLAS_COORDS && tile_set_selection.has(RTileMapCell(source_id, tile_coords, 0))) { tile_set_selection.erase(TileMapCell(source_id, tile_coords, 0)); } } @@ -1783,7 +1783,7 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Refget_tile_at_coords(Vector2i(x, y)); if (tile_coords != RTileSetSource::INVALID_ATLAS_COORDS) { - tile_set_selection.insert(TileMapCell(source_id, tile_coords, 0)); + tile_set_selection.insert(RTileMapCell(source_id, tile_coords, 0)); } } } @@ -1798,7 +1798,7 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -1824,7 +1824,7 @@ void RTileMapEditorTilesPlugin::_tile_alternatives_control_draw() { } // Draw the selection. - for (Set::Element *E = tile_set_selection.front(); E; E = E->next()) { + for (Set::Element *E = tile_set_selection.front(); E; E = E->next()) { if (E->get().source_id == source_id && E->get().get_atlas_coords() != RTileSetSource::INVALID_ATLAS_COORDS && E->get().alternative_tile > 0) { Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E->get().get_atlas_coords(), E->get().alternative_tile); if (rect != Rect2i()) { @@ -1851,7 +1851,7 @@ void RTileMapEditorTilesPlugin::_tile_alternatives_control_mouse_exited() { } void RTileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref &p_event) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -1895,18 +1895,18 @@ void RTileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref mb = p_event; - if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) { + if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) { if (mb->is_pressed()) { // Pressed // Left click pressed. - if (!mb->is_shift_pressed()) { + if (!mb->get_shift()) { tile_set_selection.clear(); } if (coords != RTileSetSource::INVALID_ATLAS_COORDS && alternative != RTileSetAtlasSource::INVALID_TILE_ALTERNATIVE) { - if (mb->is_shift_pressed() && tile_set_selection.has(TileMapCell(source_id, hovered_tile.get_atlas_coords(), hovered_tile.alternative_tile))) { - tile_set_selection.erase(TileMapCell(source_id, hovered_tile.get_atlas_coords(), hovered_tile.alternative_tile)); + if (mb->get_shift() && tile_set_selection.has(RTileMapCell(source_id, hovered_tile.get_atlas_coords(), hovered_tile.alternative_tile))) { + tile_set_selection.erase(RTileMapCell(source_id, hovered_tile.get_atlas_coords(), hovered_tile.alternative_tile)); } else { - tile_set_selection.insert(TileMapCell(source_id, hovered_tile.get_atlas_coords(), hovered_tile.alternative_tile)); + tile_set_selection.insert(RTileMapCell(source_id, hovered_tile.get_atlas_coords(), hovered_tile.alternative_tile)); } } _update_selection_pattern_from_tileset_tiles_selection(); @@ -1916,7 +1916,7 @@ void RTileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref &p_selection) { +void RTileMapEditorTilesPlugin::_set_tile_map_selection(const Vector &p_selection) { tile_map_selection.clear(); for (int i = 0; i < p_selection.size(); i++) { tile_map_selection.insert(p_selection[i]); @@ -1926,8 +1926,8 @@ void RTileMapEditorTilesPlugin::_set_tile_map_selection(const TypedArrayupdate_viewport(); } -TypedArray RTileMapEditorTilesPlugin::_get_tile_map_selection() const { - TypedArray output; +Vector RTileMapEditorTilesPlugin::_get_tile_map_selection() const { + Vector output; for (Set::Element *E = tile_map_selection.front(); E; E = E->next()) { output.push_back(E->get()); } @@ -2111,7 +2111,7 @@ RTileMapEditorTilesPlugin::RTileMapEditorTilesPlugin() { sources_list->set_h_size_flags(Control::SIZE_EXPAND_FILL); sources_list->set_stretch_ratio(0.25); sources_list->set_custom_minimum_size(Size2i(70, 0) * EDSCALE); - sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); + //sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); sources_list->connect("item_selected", callable_mp(this, &RTileMapEditorTilesPlugin::_update_fix_selected_and_hovered).unbind(1)); sources_list->connect("item_selected", callable_mp(this, &RTileMapEditorTilesPlugin::_update_source_display).unbind(1)); sources_list->connect("item_selected", callable_mp(RTilesEditorPlugin::get_singleton(), &RTilesEditorPlugin::set_sources_lists_current)); @@ -2147,7 +2147,7 @@ RTileMapEditorTilesPlugin::RTileMapEditorTilesPlugin() { scene_tiles_list->set_select_mode(ItemList::SELECT_MULTI); scene_tiles_list->connect("multi_selected", callable_mp(this, &RTileMapEditorTilesPlugin::_scenes_list_multi_selected)); scene_tiles_list->connect("nothing_selected", callable_mp(this, &RTileMapEditorTilesPlugin::_scenes_list_nothing_selected)); - scene_tiles_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); + //scene_tiles_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); atlas_sources_split_container->add_child(scene_tiles_list); // Invalid source label. @@ -2237,10 +2237,10 @@ Vector RTileMapEditorTerrainsPlugin::get_tabs() c return tabs; } -Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Map &p_to_paint, int p_terrain_set) const { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); +Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Map &p_to_paint, int p_terrain_set) const { + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map(); + return Map(); } Ref tile_set = tile_map->get_tileset(); @@ -2248,16 +2248,16 @@ Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Ma return Map(); } - Map output; + Map output; // Add the constraints from the added tiles. - Set added_tiles_constraints_set; + Set added_tiles_constraints_set; for (const KeyValue &E_to_paint : p_to_paint) { Vector2i coords = E_to_paint.key; RTileSet::TerrainsPattern terrains_pattern = E_to_paint.value; - Set cell_constraints = tile_map->get_terrain_constraints_from_added_tile(coords, p_terrain_set, terrains_pattern); - for (Set::Element *E = cell_constraints.front(); E; E = E->next()) { + Set cell_constraints = tile_map->get_terrain_constraints_from_added_tile(coords, p_terrain_set, terrains_pattern); + for (Set::Element *E = cell_constraints.front(); E; E = E->next()) { added_tiles_constraints_set.insert(E->get()); } } @@ -2285,15 +2285,15 @@ Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Ma } // Add the constraints from the surroundings of the modified areas. - Set removed_cells_constraints_set; + Set removed_cells_constraints_set; bool to_replace_modified = true; while (to_replace_modified) { // Get the constraints from the removed cells. removed_cells_constraints_set = tile_map->get_terrain_constraints_from_removed_cells_list(tile_map_layer, to_replace, p_terrain_set); // Filter the sources to make sure they are in the potential_to_replace. - Map> per_constraint_tiles; - for (Set::Element *E = removed_cells_constraints_set.front(); E; E = E->next()) { + Map> per_constraint_tiles; + for (Set::Element *E = removed_cells_constraints_set.front(); E; E = E->next()) { Map sources_of_constraint = E->get().get_overlapping_coords_and_peering_bits(); for (const KeyValue &E_source_tile_of_constraint : sources_of_constraint) { if (potential_to_replace.has(E_source_tile_of_constraint.key)) { @@ -2303,8 +2303,8 @@ Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Ma } to_replace_modified = false; - for (Set::Element *E = added_tiles_constraints_set.front(); E; E = E->next()) { - TileMap::TerrainConstraint c = E->get(); + for (Set::Element *E = added_tiles_constraints_set.front(); E; E = E->next()) { + RTileMap::TerrainConstraint c = E->get(); // Check if we have a conflict in constraints. if (removed_cells_constraints_set.has(c) && removed_cells_constraints_set.find(c)->get().get_terrain() != c.get_terrain()) { // If we do, we search for a neighbor to remove. @@ -2314,7 +2314,7 @@ Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Ma potential_to_replace.erase(to_add_to_remove); to_replace.insert(to_add_to_remove); to_replace_modified = true; - for (KeyValue> &E_source_tiles_of_constraint : per_constraint_tiles) { + for (KeyValue> &E_source_tiles_of_constraint : per_constraint_tiles) { E_source_tiles_of_constraint.value.erase(to_add_to_remove); } break; @@ -2324,8 +2324,8 @@ Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Ma } // Combine all constraints together. - Set constraints = removed_cells_constraints_set; - for (Set::Element *E = added_tiles_constraints_set.front(); E; E = E->next()) { + Set constraints = removed_cells_constraints_set; + for (Set::Element *E = added_tiles_constraints_set.front(); E; E = E->next()) { constraints.insert(E->get()); } @@ -2351,14 +2351,14 @@ Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Ma } Map RTileMapEditorTerrainsPlugin::_draw_line(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map(); + return Map(); } Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Map(); + return Map(); } RTileSet::TerrainsPattern terrains_pattern; @@ -2376,15 +2376,15 @@ Map RTileMapEditorTerrainsPlugin::_draw_line(Vector2i p_s return _draw_terrains(to_draw, selected_terrain_set); } -Map RTileMapEditorTerrainsPlugin::_draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); +Map RTileMapEditorTerrainsPlugin::_draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) { + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map(); + return Map(); } Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Map(); + return Map(); } RTileSet::TerrainsPattern terrains_pattern; @@ -2409,7 +2409,7 @@ Map RTileMapEditorTerrainsPlugin::_draw_rect(Vector2i p_s } Set RTileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i p_coords, bool p_contiguous) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return Set(); } @@ -2419,15 +2419,15 @@ Set RTileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i return Set(); } - TileMapCell source_cell = tile_map->get_cell(tile_map_layer, p_coords); + RTileMapCell source_cell = tile_map->get_cell(tile_map_layer, p_coords); RTileSet::TerrainsPattern source_pattern(*tile_set, selected_terrain_set); if (source_cell.source_id != RTileSet::INVALID_SOURCE) { - TileData *tile_data = nullptr; + RTileData *tile_data = nullptr; Ref source = tile_set->get_source(source_cell.source_id); Ref atlas_source = source; if (atlas_source.is_valid()) { - tile_data = Object::cast_to(atlas_source->get_tile_data(source_cell.get_atlas_coords(), source_cell.alternative_tile)); + tile_data = Object::cast_to(atlas_source->get_tile_data(source_cell.get_atlas_coords(), source_cell.alternative_tile)); } if (!tile_data) { return Set(); @@ -2458,7 +2458,7 @@ Set RTileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i Ref source = tile_set->get_source(tile_map->get_cell_source_id(tile_map_layer, coords)); Ref atlas_source = source; if (atlas_source.is_valid()) { - tile_data = Object::cast_to(atlas_source->get_tile_data(tile_map->get_cell_atlas_coords(tile_map_layer, coords), tile_map->get_cell_alternative_tile(tile_map_layer, coords))); + tile_data = Object::cast_to(atlas_source->get_tile_data(tile_map->get_cell_atlas_coords(tile_map_layer, coords), tile_map->get_cell_alternative_tile(tile_map_layer, coords))); } if (tile_data) { candidate_pattern = tile_data->get_terrains_pattern(); @@ -2499,11 +2499,11 @@ Set RTileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i // Get the candidate cell pattern. RTileSet::TerrainsPattern candidate_pattern; if (tile_map->get_cell_source_id(tile_map_layer, coords) != RTileSet::INVALID_SOURCE) { - TileData *tile_data = nullptr; + RTileData *tile_data = nullptr; Ref source = tile_set->get_source(tile_map->get_cell_source_id(tile_map_layer, coords)); Ref atlas_source = source; if (atlas_source.is_valid()) { - tile_data = Object::cast_to(atlas_source->get_tile_data(tile_map->get_cell_atlas_coords(tile_map_layer, coords), tile_map->get_cell_alternative_tile(tile_map_layer, coords))); + tile_data = Object::cast_to(atlas_source->get_tile_data(tile_map->get_cell_atlas_coords(tile_map_layer, coords), tile_map->get_cell_alternative_tile(tile_map_layer, coords))); } if (tile_data) { candidate_pattern = tile_data->get_terrains_pattern(); @@ -2519,15 +2519,15 @@ Set RTileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i return output; } -Map RTileMapEditorTerrainsPlugin::_draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); +Map RTileMapEditorTerrainsPlugin::_draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase) { + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - return Map(); + return Map(); } Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - return Map(); + return Map(); } RTileSet::TerrainsPattern terrains_pattern; @@ -2547,7 +2547,7 @@ Map RTileMapEditorTerrainsPlugin::_draw_bucket_fill(Vecto } void RTileMapEditorTerrainsPlugin::_stop_dragging() { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -2569,7 +2569,7 @@ void RTileMapEditorTerrainsPlugin::_stop_dragging() { Ref source = tile_set->get_source(cell.source_id); Ref atlas_source = source; if (atlas_source.is_valid()) { - tile_data = Object::cast_to(atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile)); + tile_data = Object::cast_to(atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile)); } if (tile_data) { @@ -2627,7 +2627,7 @@ void RTileMapEditorTerrainsPlugin::_stop_dragging() { } break; case DRAG_TYPE_PAINT: { undo_redo->create_action(TTR("Paint terrain")); - for (const KeyValue &E : drag_modified) { + for (const KeyValue &E : drag_modified) { undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, tile_map->get_cell_source_id(tile_map_layer, E.key), tile_map->get_cell_atlas_coords(tile_map_layer, E.key), tile_map->get_cell_alternative_tile(tile_map_layer, E.key)); undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } @@ -2636,7 +2636,7 @@ void RTileMapEditorTerrainsPlugin::_stop_dragging() { case DRAG_TYPE_LINE: { Map to_draw = _draw_line(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); undo_redo->create_action(TTR("Paint terrain")); - for (const KeyValue &E : to_draw) { + for (const KeyValue &E : to_draw) { if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } @@ -2648,7 +2648,7 @@ void RTileMapEditorTerrainsPlugin::_stop_dragging() { case DRAG_TYPE_RECT: { Map to_draw = _draw_rect(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); undo_redo->create_action(TTR("Paint terrain")); - for (const KeyValue &E : to_draw) { + for (const KeyValue &E : to_draw) { if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } @@ -2659,7 +2659,7 @@ void RTileMapEditorTerrainsPlugin::_stop_dragging() { } break; case DRAG_TYPE_BUCKET: { undo_redo->create_action(TTR("Paint terrain")); - for (const KeyValue &E : drag_modified) { + for (const KeyValue &E : drag_modified) { undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, tile_map->get_cell_source_id(tile_map_layer, E.key), tile_map->get_cell_atlas_coords(tile_map_layer, E.key), tile_map->get_cell_alternative_tile(tile_map_layer, E.key)); undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } @@ -2678,7 +2678,7 @@ void RTileMapEditorTerrainsPlugin::_mouse_exited_viewport() { } void RTileMapEditorTerrainsPlugin::_update_selection() { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -2719,7 +2719,7 @@ bool RTileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return false; } @@ -2745,8 +2745,8 @@ bool RTileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref= 0) { - Map to_draw = _draw_line(tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); - for (const KeyValue &E : to_draw) { + Map to_draw = _draw_line(tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); + for (const KeyValue &E : to_draw) { if (!drag_modified.has(E.key)) { drag_modified[E.key] = tile_map->get_cell(tile_map_layer, E.key); } @@ -2769,10 +2769,10 @@ bool RTileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Refget_canvas_transform() * tile_map->get_global_transform(); Vector2 mpos = xform.affine_inverse().xform(mb->get_position()); - if (mb->get_button_index() == MouseButton::LEFT || mb->get_button_index() == MouseButton::RIGHT) { + if (mb->get_button_index() == BUTTON_LEFT || mb->get_button_index() == BUTTON_RIGHT) { if (mb->is_pressed()) { // Pressed - if (erase_button->is_pressed() || mb->get_button_index() == MouseButton::RIGHT) { + if (erase_button->is_pressed() || mb->get_button_index() == BUTTON_RIGHT) { drag_erasing = true; } @@ -2790,8 +2790,8 @@ bool RTileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Refworld_to_map(mpos); - Map to_draw = _draw_line(cell, cell, drag_erasing); - for (const KeyValue &E : to_draw) { + Map to_draw = _draw_line(cell, cell, drag_erasing); + for (const KeyValue &E : to_draw) { drag_modified[E.key] = tile_map->get_cell(tile_map_layer, E.key); tile_map->set_cell(tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } @@ -2819,8 +2819,8 @@ bool RTileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref line = RTileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos)); for (int i = 0; i < line.size(); i++) { if (!drag_modified.has(line[i])) { - Map to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing); - for (const KeyValue &E : to_draw) { + Map to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing); + for (const KeyValue &E : to_draw) { if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } @@ -2851,7 +2851,7 @@ bool RTileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -2980,7 +2980,7 @@ void RTileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_ } void RTileMapEditorTerrainsPlugin::_update_terrains_cache() { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -3010,7 +3010,7 @@ void RTileMapEditorTerrainsPlugin::_update_terrains_cache() { for (int alternative_index = 0; alternative_index < source->get_alternative_tiles_count(tile_id); alternative_index++) { int alternative_id = source->get_alternative_tile_id(tile_id, alternative_index); - TileData *tile_data = Object::cast_to(atlas_source->get_tile_data(tile_id, alternative_id)); + RTileData *tile_data = Object::cast_to(atlas_source->get_tile_data(tile_id, alternative_id)); int terrain_set = tile_data->get_terrain_set(); if (terrain_set >= 0) { ERR_FAIL_INDEX(terrain_set, (int)per_terrain_terrains_patterns.size()); @@ -3042,7 +3042,7 @@ void RTileMapEditorTerrainsPlugin::_update_terrains_tree() { terrains_tree->clear(); terrains_tree->create_item(); - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -3089,7 +3089,7 @@ void RTileMapEditorTerrainsPlugin::_update_terrains_tree() { void RTileMapEditorTerrainsPlugin::_update_tiles_list() { terrains_tile_list->clear(); - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -3133,12 +3133,12 @@ void RTileMapEditorTerrainsPlugin::_update_tiles_list() { bool transpose = false; double max_probability = -1.0; - for (const TileMapCell &cell : tile_set->get_tiles_for_terrains_pattern(selected_terrain_set, terrains_pattern)) { + for (const RTileMapCell &cell : tile_set->get_tiles_for_terrains_pattern(selected_terrain_set, terrains_pattern)) { Ref source = tile_set->get_source(cell.source_id); Ref atlas_source = source; if (atlas_source.is_valid()) { - TileData *tile_data = Object::cast_to(atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile)); + RTileData *tile_data = Object::cast_to(atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile)); if (tile_data->get_probability() > max_probability) { icon = atlas_source->get_texture(); region = atlas_source->get_tile_texture_region(cell.get_atlas_coords()); @@ -3325,7 +3325,7 @@ void RTileMapEditor::_notification(int p_what) { toggle_grid_button->set_pressed(EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid")); break; case NOTIFICATION_VISIBILITY_CHANGED: - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (tile_map) { if (is_visible_in_tree()) { tile_map->set_selected_layer(tile_map_layer); @@ -3403,7 +3403,7 @@ void RTileMapEditor::_layers_selection_id_pressed(int p_id) { } void RTileMapEditor::_advanced_menu_button_id_pressed(int p_id) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -3419,9 +3419,9 @@ void RTileMapEditor::_advanced_menu_button_id_pressed(int p_id) { TypedArray used_cells = tile_map->get_used_cells(layer_index); for (int i = 0; i < used_cells.size(); i++) { Vector2i cell_coords = used_cells[i]; - TileMapCell from = tile_map->get_cell(layer_index, cell_coords); + RTileMapCell from = tile_map->get_cell(layer_index, cell_coords); Array to_array = tile_set->map_tile_proxy(from.source_id, from.get_atlas_coords(), from.alternative_tile); - TileMapCell to; + RTileMapCell to; to.source_id = to_array[0]; to.set_atlas_coords(to_array[1]); to.alternative_tile = to_array[2]; @@ -3436,7 +3436,7 @@ void RTileMapEditor::_advanced_menu_button_id_pressed(int p_id) { } void RTileMapEditor::_update_bottom_panel() { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -3466,8 +3466,8 @@ Vector RTileMapEditor::get_line(TileMap *p_tile_map, Vector2i p_from_c Vector points; bool transposed = tile_set->get_tile_offset_axis() == RTileSet::TILE_OFFSET_AXIS_VERTICAL; - p_from_cell = TileMap::transform_coords_layout(p_from_cell, tile_set->get_tile_offset_axis(), tile_set->get_tile_layout(), RTileSet::TILE_LAYOUT_STACKED); - p_to_cell = TileMap::transform_coords_layout(p_to_cell, tile_set->get_tile_offset_axis(), tile_set->get_tile_layout(), RTileSet::TILE_LAYOUT_STACKED); + p_from_cell = RTileMap::transform_coords_layout(p_from_cell, tile_set->get_tile_offset_axis(), tile_set->get_tile_layout(), RTileSet::TILE_LAYOUT_STACKED); + p_to_cell = RTileMap::transform_coords_layout(p_to_cell, tile_set->get_tile_offset_axis(), tile_set->get_tile_layout(), RTileSet::TILE_LAYOUT_STACKED); if (transposed) { SWAP(p_from_cell.x, p_from_cell.y); SWAP(p_to_cell.x, p_to_cell.y); @@ -3478,7 +3478,7 @@ Vector RTileMapEditor::get_line(TileMap *p_tile_map, Vector2i p_from_c Vector2i sign = delta.sign(); Vector2i current = p_from_cell; - points.push_back(TileMap::transform_coords_layout(transposed ? Vector2i(current.y, current.x) : current, tile_set->get_tile_offset_axis(), RTileSet::TILE_LAYOUT_STACKED, tile_set->get_tile_layout())); + points.push_back(RTileMap::transform_coords_layout(transposed ? Vector2i(current.y, current.x) : current, tile_set->get_tile_offset_axis(), RTileSet::TILE_LAYOUT_STACKED, tile_set->get_tile_layout())); int err = 0; if (ABS(delta.y) < ABS(delta.x)) { @@ -3496,7 +3496,7 @@ Vector RTileMapEditor::get_line(TileMap *p_tile_map, Vector2i p_from_c current += Vector2i(sign.x, 0); err += err_step.y; } - points.push_back(TileMap::transform_coords_layout(transposed ? Vector2i(current.y, current.x) : current, tile_set->get_tile_offset_axis(), RTileSet::TILE_LAYOUT_STACKED, tile_set->get_tile_layout())); + points.push_back(RTileMap::transform_coords_layout(transposed ? Vector2i(current.y, current.x) : current, tile_set->get_tile_offset_axis(), RTileSet::TILE_LAYOUT_STACKED, tile_set->get_tile_layout())); } } else { Vector2i err_step = delta.abs(); @@ -3517,7 +3517,7 @@ Vector RTileMapEditor::get_line(TileMap *p_tile_map, Vector2i p_from_c } err += err_step.y; } - points.push_back(TileMap::transform_coords_layout(transposed ? Vector2i(current.y, current.x) : current, tile_set->get_tile_offset_axis(), RTileSet::TILE_LAYOUT_STACKED, tile_set->get_tile_layout())); + points.push_back(RTileMap::transform_coords_layout(transposed ? Vector2i(current.y, current.x) : current, tile_set->get_tile_offset_axis(), RTileSet::TILE_LAYOUT_STACKED, tile_set->get_tile_layout())); } } @@ -3540,7 +3540,7 @@ void RTileMapEditor::_tab_changed(int p_tab_id) { tabs_data[p_tab_id].toolbar->show(); // Update visible panel. - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); for (unsigned int tab_index = 0; tab_index < tabs_data.size(); tab_index++) { tabs_data[tab_index].panel->hide(); } @@ -3554,7 +3554,7 @@ void RTileMapEditor::_tab_changed(int p_tab_id) { } void RTileMapEditor::_layers_select_next_or_previous(bool p_next) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -3583,7 +3583,7 @@ void RTileMapEditor::_layers_select_next_or_previous(bool p_next) { void RTileMapEditor::_update_layers_selection() { layers_selection_popup->clear(); - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -3643,7 +3643,7 @@ void RTileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p UndoRedo *undo_redo = Object::cast_to(p_undo_redo); ERR_FAIL_COND(!undo_redo); - TileMap *tile_map = Object::cast_to(p_edited); + RTileMap *tile_map = Object::cast_to(p_edited); if (!tile_map) { return; } @@ -3726,7 +3726,7 @@ bool RTileMapEditor::forward_canvas_gui_input(const Ref &p_event) { } void RTileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { return; } @@ -3860,12 +3860,12 @@ void RTileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { tabs_plugins[tabs_bar->get_current_tab()]->forward_canvas_draw_over_viewport(p_overlay); } -void RTileMapEditor::edit(TileMap *p_tile_map) { +void RTileMapEditor::edit(RTileMap *p_tile_map) { if (p_tile_map && p_tile_map->get_instance_id() == tile_map_id) { return; } - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (tile_map) { // Unselect layer if we are changing tile_map. if (tile_map != p_tile_map) { @@ -3879,7 +3879,7 @@ void RTileMapEditor::edit(TileMap *p_tile_map) { if (p_tile_map) { // Change the edited object. tile_map_id = p_tile_map->get_instance_id(); - tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); // Connect to changes. if (!tile_map->is_connected("changed", callable_mp(this, &RTileMapEditor::_tile_map_changed))) { tile_map->connect("changed", callable_mp(this, &RTileMapEditor::_tile_map_changed)); diff --git a/tile_editor/tile_map_editor.h b/tile_editor/tile_map_editor.h index 1871237..b1e7280 100644 --- a/tile_editor/tile_map_editor.h +++ b/tile_editor/tile_map_editor.h @@ -38,7 +38,7 @@ #include "editor/editor_node.h" #include "../rtile_map.h" #include "scene/gui/box_container.h" -#include "scene/gui/tab_bar.h" +#include "scene/gui/tabs.h" class RTileMapEditorPlugin : public Object { public: @@ -122,10 +122,10 @@ private: ///// Selection system. ///// Set tile_map_selection; - Ref tile_map_clipboard; - Ref selection_pattern; - void _set_tile_map_selection(const TypedArray &p_selection); - TypedArray _get_tile_map_selection() const; + Ref tile_map_clipboard; + Ref selection_pattern; + void _set_tile_map_selection(const Vector &p_selection); + Vector _get_tile_map_selection() const; Set tile_set_selection; @@ -184,7 +184,7 @@ private: ItemList *patterns_item_list; Label *patterns_help_label; void _patterns_item_list_gui_input(const Ref &p_event); - void _pattern_preview_done(Ref p_pattern, Ref p_texture); + void _pattern_preview_done(Ref p_pattern, Ref p_texture); bool select_last_pattern = false; void _update_patterns_list(); @@ -322,7 +322,7 @@ private: // Bottom panel. Label *missing_tileset_label; - TabBar *tabs_bar; + Tabs *tabs_bar; LocalVector tabs_data; LocalVector tabs_plugins; void _update_bottom_panel(); diff --git a/tile_editor/tile_set_atlas_source_editor.h b/tile_editor/tile_set_atlas_source_editor.h index b131f2b..50ebf64 100644 --- a/tile_editor/tile_set_atlas_source_editor.h +++ b/tile_editor/tile_set_atlas_source_editor.h @@ -294,7 +294,7 @@ class REditorPropertyTilePolygon : public EditorProperty { void _add_focusable_children(Node *p_node); - GenericTilePolygonEditor *generic_tile_polygon_editor; + RGenericTilePolygonEditor *generic_tile_polygon_editor; void _polygons_changed(); public: @@ -312,7 +312,7 @@ class REditorInspectorPluginTileData : public EditorInspectorPlugin { public: virtual bool can_handle(Object *p_object) override; - virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false) override; + virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false); }; #endif // TILE_SET_ATLAS_SOURCE_EDITOR_H diff --git a/tile_editor/tile_set_editor.cpp b/tile_editor/tile_set_editor.cpp index cc4301e..84b17d0 100644 --- a/tile_editor/tile_set_editor.cpp +++ b/tile_editor/tile_set_editor.cpp @@ -50,7 +50,7 @@ void RTileSetEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, if (p_from == sources_list) { // Handle dropping a texture in the list of atlas resources. - int source_id = TileSet::INVALID_SOURCE; + int source_id = RTileSet::INVALID_SOURCE; int added = 0; Dictionary d = p_data; Vector files = d["files"]; @@ -61,7 +61,7 @@ void RTileSetEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, source_id = tile_set->get_next_source_id(); // Actually create the new source. - Ref atlas_source = memnew(TileSetAtlasSource); + Ref atlas_source = memnew(RTileSetAtlasSource); atlas_source->set_texture(resource); undo_redo->create_action(TTR("Add a new atlas source")); undo_redo->add_do_method(*tile_set, "add_source", atlas_source, source_id); @@ -118,7 +118,7 @@ void RTileSetEditor::_update_sources_list(int force_selected_id) { ERR_FAIL_COND(!tile_set.is_valid()); // Get the previously selected id. - int old_selected = TileSet::INVALID_SOURCE; + int old_selected = RTileSet::INVALID_SOURCE; if (sources_list->get_current() >= 0) { int source_id = sources_list->get_item_metadata(sources_list->get_current()); if (tile_set->has_source(source_id)) { @@ -126,7 +126,7 @@ void RTileSetEditor::_update_sources_list(int force_selected_id) { } } - int to_select = TileSet::INVALID_SOURCE; + int to_select = RTileSet::INVALID_SOURCE; if (force_selected_id >= 0) { to_select = force_selected_id; } else if (old_selected >= 0) { @@ -140,7 +140,7 @@ void RTileSetEditor::_update_sources_list(int force_selected_id) { for (int i = 0; i < tile_set->get_source_count(); i++) { int source_id = tile_set->get_source_id(i); - TileSetSource *source = *tile_set->get_source(source_id); + RTileSetSource *source = *tile_set->get_source(source_id); Ref texture; String item_text; @@ -151,7 +151,7 @@ void RTileSetEditor::_update_sources_list(int force_selected_id) { } // Atlas source. - TileSetAtlasSource *atlas_source = Object::cast_to(source); + RTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { texture = atlas_source->get_texture(); if (item_text.is_empty()) { @@ -164,16 +164,16 @@ void RTileSetEditor::_update_sources_list(int force_selected_id) { } // Scene collection source. - TileSetScenesCollectionSource *scene_collection_source = Object::cast_to(source); + RTileSetScenesCollectionSource *scene_collection_source = Object::cast_to(source); if (scene_collection_source) { - texture = get_theme_icon(("PackedScene"), ("EditorIcons")); - if (item_text.is_empty()) { + texture = get_icon(("PackedScene"), ("EditorIcons")); + if (item_text.empty()) { item_text = vformat(TTR("Scene Collection Source (ID:%d)"), source_id); } } // Use default if not valid. - if (item_text.is_empty()) { + if (item_text.empty()) { item_text = vformat(TTR("Unknown Type Source (ID:%d)"), source_id); } if (!texture.is_valid()) { @@ -220,8 +220,8 @@ void RTileSetEditor::_source_selected(int p_source_index) { if (p_source_index >= 0) { int source_id = sources_list->get_item_metadata(p_source_index); - TileSetAtlasSource *atlas_source = Object::cast_to(*tile_set->get_source(source_id)); - TileSetScenesCollectionSource *scenes_collection_source = Object::cast_to(*tile_set->get_source(source_id)); + RTileSetAtlasSource *atlas_source = Object::cast_to(*tile_set->get_source(source_id)); + RTileSetScenesCollectionSource *scenes_collection_source = Object::cast_to(*tile_set->get_source(source_id)); if (atlas_source) { no_source_selected_label->hide(); tile_set_atlas_source_editor->edit(*tile_set, atlas_source, source_id); @@ -250,7 +250,7 @@ void RTileSetEditor::_source_delete_pressed() { // Update the selected source. int to_delete = sources_list->get_item_metadata(sources_list->get_current()); - Ref source = tile_set->get_source(to_delete); + Ref source = tile_set->get_source(to_delete); // Remove the source. undo_redo->create_action(TTR("Remove source")); @@ -268,7 +268,7 @@ void RTileSetEditor::_source_add_id_pressed(int p_id_pressed) { case 0: { int source_id = tile_set->get_next_source_id(); - Ref atlas_source = memnew(TileSetAtlasSource); + Ref atlas_source = memnew(RTileSetAtlasSource); // Add a new source. undo_redo->create_action(TTR("Add atlas source")); @@ -282,7 +282,7 @@ void RTileSetEditor::_source_add_id_pressed(int p_id_pressed) { case 1: { int source_id = tile_set->get_next_source_id(); - Ref scene_collection_source = memnew(TileSetScenesCollectionSource); + Ref scene_collection_source = memnew(RTileSetScenesCollectionSource); // Add a new source. undo_redo->create_action(TTR("Add atlas source")); @@ -316,10 +316,10 @@ void RTileSetEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - sources_delete_button->set_icon(get_theme_icon(("Remove"), ("EditorIcons"))); - sources_add_button->set_icon(get_theme_icon(("Add"), ("EditorIcons"))); - sources_advanced_menu_button->set_icon(get_theme_icon(("GuiTabMenuHl"), ("EditorIcons"))); - missing_texture_texture = get_theme_icon(("TileSet"), ("EditorIcons")); + sources_delete_button->set_icon(get_icon(("Remove"), ("EditorIcons"))); + sources_add_button->set_icon(get_icon(("Add"), ("EditorIcons"))); + sources_advanced_menu_button->set_icon(get_icon(("GuiTabMenuHl"), ("EditorIcons"))); + missing_texture_texture = get_icon(("TileSet"), ("EditorIcons")); break; case NOTIFICATION_INTERNAL_PROCESS: if (tile_set_changed_needs_update) { @@ -352,7 +352,7 @@ void RTileSetEditor::_patterns_item_list_gui_input(const Ref &p_even } } -void RTileSetEditor::_pattern_preview_done(Ref p_pattern, Ref p_texture) { +void RTileSetEditor::_pattern_preview_done(Ref p_pattern, Ref p_texture) { // TODO optimize ? for (int i = 0; i < patterns_item_list->get_item_count(); i++) { if (patterns_item_list->get_item_metadata(i) == p_pattern) { @@ -390,7 +390,7 @@ void RTileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p UndoRedo *undo_redo = Object::cast_to(p_undo_redo); ERR_FAIL_COND(!undo_redo); - TileSet *tile_set = Object::cast_to(p_edited); + RTileSet *tile_set = Object::cast_to(p_edited); if (!tile_set) { return; } @@ -459,13 +459,13 @@ void RTileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p for (int i = 0; i < tile_set->get_source_count(); i++) { int source_id = tile_set->get_source_id(i); - Ref tas = tile_set->get_source(source_id); + Ref tas = tile_set->get_source(source_id); if (tas.is_valid()) { for (int j = 0; j < tas->get_tiles_count(); j++) { Vector2i tile_id = tas->get_tile_id(j); for (int k = 0; k < tas->get_alternative_tiles_count(tile_id); k++) { int alternative_id = tas->get_alternative_tile_id(tile_id, k); - TileData *tile_data = Object::cast_to(tas->get_tile_data(tile_id, alternative_id)); + RTileData *tile_data = Object::cast_to(tas->get_tile_data(tile_id, alternative_id)); ERR_FAIL_COND(!tile_data); // Actually saving stuff. @@ -485,16 +485,16 @@ void RTileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p } else if (p_array_prefix == "terrain_set_") { ADD_UNDO(tile_data, "terrain_set"); for (int terrain_set_index = begin; terrain_set_index < end; terrain_set_index++) { - for (int l = 0; l < TileSet::CELL_NEIGHBOR_MAX; l++) { - TileSet::CellNeighbor bit = TileSet::CellNeighbor(l); + for (int l = 0; l < RTileSet::CELL_NEIGHBOR_MAX; l++) { + RTileSet::CellNeighbor bit = RTileSet::CellNeighbor(l); if (tile_data->is_valid_peering_bit_terrain(bit)) { ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l])); } } } } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") { - for (int terrain_index = 0; terrain_index < TileSet::CELL_NEIGHBOR_MAX; terrain_index++) { - TileSet::CellNeighbor bit = TileSet::CellNeighbor(terrain_index); + for (int terrain_index = 0; terrain_index < RTileSet::CELL_NEIGHBOR_MAX; terrain_index++) { + RTileSet::CellNeighbor bit = RTileSet::CellNeighbor(terrain_index); if (tile_data->is_valid_peering_bit_terrain(bit)) { ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[terrain_index])); } @@ -572,31 +572,31 @@ void RTileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object * ERR_FAIL_COND(!undo_redo); #define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property)); - TileSet *tile_set = Object::cast_to(p_edited); + RTileSet *tile_set = Object::cast_to(p_edited); if (tile_set) { Vector components = p_property.split("/", true, 3); for (int i = 0; i < tile_set->get_source_count(); i++) { int source_id = tile_set->get_source_id(i); - Ref tas = tile_set->get_source(source_id); + Ref tas = tile_set->get_source(source_id); if (tas.is_valid()) { for (int j = 0; j < tas->get_tiles_count(); j++) { Vector2i tile_id = tas->get_tile_id(j); for (int k = 0; k < tas->get_alternative_tiles_count(tile_id); k++) { int alternative_id = tas->get_alternative_tile_id(tile_id, k); - TileData *tile_data = Object::cast_to(tas->get_tile_data(tile_id, alternative_id)); + RTileData *tile_data = Object::cast_to(tas->get_tile_data(tile_id, alternative_id)); ERR_FAIL_COND(!tile_data); if (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "mode") { ADD_UNDO(tile_data, "terrain_set"); - for (int l = 0; l < TileSet::CELL_NEIGHBOR_MAX; l++) { - TileSet::CellNeighbor bit = TileSet::CellNeighbor(l); + for (int l = 0; l < RTileSet::CELL_NEIGHBOR_MAX; l++) { + RTileSet::CellNeighbor bit = RTileSet::CellNeighbor(l); if (tile_data->is_valid_peering_bit_terrain(bit)) { - ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l])); + ADD_UNDO(tile_data, "terrains_peering_bit/" + String(RTileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l])); } } } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int() && components[1] == "type") { - int custom_data_layer = components[0].trim_prefix("custom_data_layer_").is_valid_int(); + int custom_data_layer = components[0].trim_prefix("custom_data_layer_").is_valid_integer(); ADD_UNDO(tile_data, vformat("custom_data_%d", custom_data_layer)); } } @@ -612,7 +612,7 @@ void RTileSetEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_drop_data_fw"), &RTileSetEditor::_drop_data_fw); } -void RTileSetEditor::edit(Ref p_tile_set) { +void RTileSetEditor::edit(Ref p_tile_set) { if (p_tile_set == tile_set) { return; } @@ -677,7 +677,7 @@ RTileSetEditor::RTileSetEditor() { sources_list->connect("item_selected", callable_mp(this, &RTileSetEditor::_source_selected)); sources_list->connect("item_selected", callable_mp(RTilesEditorPlugin::get_singleton(), &RTilesEditorPlugin::set_sources_lists_current)); sources_list->connect("visibility_changed", callable_mp(RTilesEditorPlugin::get_singleton(), &RTilesEditorPlugin::synchronize_sources_list), varray(sources_list)); - sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); + //sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); sources_list->set_drag_forwarding(this); split_container_left_side->add_child(sources_list); diff --git a/tile_editor/tile_set_editor.h b/tile_editor/tile_set_editor.h index 1a3ef8a..ed6141a 100644 --- a/tile_editor/tile_set_editor.h +++ b/tile_editor/tile_set_editor.h @@ -50,7 +50,7 @@ private: // TabBar. HBoxContainer *tile_set_toolbar; - TabBar *tabs_bar; + Tabs *tabs_bar; // Tiles. Label *no_source_selected_label; @@ -99,7 +99,7 @@ protected: public: _FORCE_INLINE_ static RTileSetEditor *get_singleton() { return singleton; } - void edit(Ref p_tile_set); + void edit(Ref p_tile_set); RTileSetEditor(); ~RTileSetEditor(); diff --git a/tile_editor/tile_set_scenes_collection_source_editor.h b/tile_editor/tile_set_scenes_collection_source_editor.h index 9a51305..3f4b3a2 100644 --- a/tile_editor/tile_set_scenes_collection_source_editor.h +++ b/tile_editor/tile_set_scenes_collection_source_editor.h @@ -58,7 +58,7 @@ private: void set_id(int p_id); int get_id(); - void edit(Ref p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id); + void edit(Ref p_tile_set, RTileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id); }; // -- Proxy object for a tile, needed by the inspector -- diff --git a/tile_editor/tiles_editor_plugin.cpp b/tile_editor/tiles_editor_plugin.cpp index 0f72b3d..3eaf0b3 100644 --- a/tile_editor/tiles_editor_plugin.cpp +++ b/tile_editor/tiles_editor_plugin.cpp @@ -48,7 +48,7 @@ RTilesEditorPlugin *RTilesEditorPlugin::singleton = nullptr; void RTilesEditorPlugin::_preview_frame_started() { - RS::get_singleton()->request_frame_drawn_callback(callable_mp(const_cast(this), &RTilesEditorPlugin::_pattern_preview_done)); + VS::get_singleton()->request_frame_drawn_callback(callable_mp(const_cast(this), &RTilesEditorPlugin::_pattern_preview_done)); } void RTilesEditorPlugin::_pattern_preview_done() { @@ -83,7 +83,7 @@ void RTilesEditorPlugin::_thread() { viewport->set_transparent_background(true); viewport->set_update_mode(SubViewport::UPDATE_ONCE); - TileMap *tile_map = memnew(TileMap); + RTileMap *tile_map = memnew(RTileMap); tile_map->set_tileset(item.tile_set); tile_map->set_pattern(0, Vector2(), item.pattern); viewport->add_child(tile_map); @@ -163,7 +163,7 @@ void RTilesEditorPlugin::_notification(int p_what) { switch (p_what) { case NOTIFICATION_INTERNAL_PROCESS: { if (tile_map_changed_needs_update) { - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (tile_map) { tile_set = tile_map->get_tileset(); } @@ -177,7 +177,7 @@ void RTilesEditorPlugin::_notification(int p_what) { void RTilesEditorPlugin::make_visible(bool p_visible) { if (p_visible) { // Disable and hide invalid editors. - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); tileset_editor_button->set_visible(tile_set.is_valid()); tilemap_editor_button->set_visible(tile_map); if (tile_map) { @@ -237,7 +237,7 @@ void RTilesEditorPlugin::synchronize_atlas_view(Object *p_current) { void RTilesEditorPlugin::edit(Object *p_object) { // Disconnect to changes. - TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + RTileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (tile_map) { tile_map->disconnect("changed", callable_mp(this, &RTilesEditorPlugin::_tile_map_changed)); } @@ -247,7 +247,7 @@ void RTilesEditorPlugin::edit(Object *p_object) { if (p_object) { if (p_object->is_class("TileMap")) { tile_map_id = p_object->get_instance_id(); - tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); + tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); tile_set = tile_map->get_tileset(); editor_node->make_bottom_panel_item_visible(tilemap_editor); } else if (p_object->is_class("RTileSet")) {