diff --git a/tile_editor/atlas_merging_dialog.cpp b/tile_editor/atlas_merging_dialog.cpp index 43b09f3..feeffcc 100644 --- a/tile_editor/atlas_merging_dialog.cpp +++ b/tile_editor/atlas_merging_dialog.cpp @@ -39,7 +39,7 @@ void RAtlasMergingDialog::_property_changed(const StringName &p_property, const _set(p_property, p_value); } -void RAtlasMergingDialog::_generate_merged(Vector> p_atlas_sources, int p_max_columns) { +void RAtlasMergingDialog::_generate_merged(Vector> p_atlas_sources, int p_max_columns) { merged.instantiate(); merged_mapping.clear(); @@ -51,15 +51,15 @@ void RAtlasMergingDialog::_generate_merged(Vector> p_atl // Compute the new texture region size. Vector2i new_texture_region_size; for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) { - Ref atlas_source = p_atlas_sources[source_index]; + Ref atlas_source = p_atlas_sources[source_index]; new_texture_region_size = new_texture_region_size.max(atlas_source->get_texture_region_size()); } - // Generate the merged TileSetAtlasSource. + // Generate the merged RTileSetAtlasSource. Vector2i atlas_offset; int line_height = 0; for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) { - Ref atlas_source = p_atlas_sources[source_index]; + Ref atlas_source = p_atlas_sources[source_index]; merged_mapping.push_back(Map()); // Layout the tiles. @@ -127,7 +127,7 @@ void RAtlasMergingDialog::_generate_merged(Vector> p_atl void RAtlasMergingDialog::_update_texture() { Vector selected = atlas_merging_atlases_list->get_selected_items(); if (selected.size() >= 2) { - Vector> to_merge; + Vector> to_merge; for (int i = 0; i < selected.size(); i++) { int source_id = atlas_merging_atlases_list->get_item_metadata(selected[i]); to_merge.push_back(tile_set->get_source(source_id)); @@ -139,7 +139,7 @@ void RAtlasMergingDialog::_update_texture() { get_ok_button()->set_disabled(false); merge_button->set_disabled(false); } else { - _generate_merged(Vector>(), next_line_after_column); + _generate_merged(Vector>(), next_line_after_column); preview->set_texture(Ref()); preview->hide(); select_2_atlases_label->show(); @@ -157,7 +157,7 @@ void RAtlasMergingDialog::_merge_confirmed(String p_path) { Ref new_texture_resource = ResourceLoader::load(p_path, "Texture2D"); merged->set_texture(new_texture_resource); - undo_redo->create_action(TTR("Merge TileSetAtlasSource")); + undo_redo->create_action(TTR("Merge RTileSetAtlasSource")); int next_id = tile_set->get_next_source_id(); undo_redo->add_do_method(*tile_set, "add_source", merged, next_id); undo_redo->add_undo_method(*tile_set, "remove_source", next_id); @@ -167,7 +167,7 @@ void RAtlasMergingDialog::_merge_confirmed(String p_path) { Vector selected = atlas_merging_atlases_list->get_selected_items(); for (int i = 0; i < selected.size(); i++) { int source_id = atlas_merging_atlases_list->get_item_metadata(selected[i]); - Ref tas = tile_set->get_source(source_id); + Ref tas = tile_set->get_source(source_id); undo_redo->add_do_method(*tile_set, "remove_source", source_id); undo_redo->add_undo_method(*tile_set, "add_source", tas, source_id); @@ -226,14 +226,14 @@ bool RAtlasMergingDialog::_get(const StringName &p_name, Variant &r_ret) const { return false; } -void RAtlasMergingDialog::update_tile_set(Ref p_tile_set) { +void RAtlasMergingDialog::update_tile_set(Ref p_tile_set) { ERR_FAIL_COND(!p_tile_set.is_valid()); tile_set = p_tile_set; atlas_merging_atlases_list->clear(); for (int i = 0; i < p_tile_set->get_source_count(); i++) { int source_id = p_tile_set->get_source_id(i); - Ref atlas_source = p_tile_set->get_source(source_id); + Ref atlas_source = p_tile_set->get_source(source_id); if (atlas_source.is_valid()) { Ref texture = atlas_source->get_texture(); if (texture.is_valid()) { diff --git a/tile_editor/atlas_merging_dialog.h b/tile_editor/atlas_merging_dialog.h index 7140755..9a8994a 100644 --- a/tile_editor/atlas_merging_dialog.h +++ b/tile_editor/atlas_merging_dialog.h @@ -37,7 +37,7 @@ #include "scene/gui/dialogs.h" #include "scene/gui/item_list.h" #include "scene/gui/texture_rect.h" -#include "scene/resources/tile_set.h" +#include "../rtile_set.h" class RAtlasMergingDialog : public ConfirmationDialog { GDCLASS(RAtlasMergingDialog, ConfirmationDialog); @@ -45,9 +45,9 @@ class RAtlasMergingDialog : public ConfirmationDialog { private: int commited_actions_count = 0; bool delete_original_atlases = true; - Ref merged; + Ref merged; LocalVector> merged_mapping; - Ref tile_set; + Ref tile_set; UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); @@ -65,7 +65,7 @@ private: void _property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing); - void _generate_merged(Vector> p_atlas_sources, int p_max_columns); + void _generate_merged(Vector> p_atlas_sources, int p_max_columns); void _update_texture(); void _merge_confirmed(String p_path); @@ -78,7 +78,7 @@ protected: bool _get(const StringName &p_name, Variant &r_ret) const; public: - void update_tile_set(Ref p_tile_set); + void update_tile_set(Ref p_tile_set); RAtlasMergingDialog(); }; diff --git a/tile_editor/tile_atlas_view.cpp b/tile_editor/tile_atlas_view.cpp index 12371e0..1ad0e60 100644 --- a/tile_editor/tile_atlas_view.cpp +++ b/tile_editor/tile_atlas_view.cpp @@ -30,9 +30,9 @@ #include "tile_atlas_view.h" -#include "core/input/input.h" +#include "core/os/input.h" #include "core/os/keyboard.h" -#include "scene/2d/tile_map.h" +#include "../rtile_map.h" #include "scene/gui/box_container.h" #include "scene/gui/label.h" #include "scene/gui/panel.h" @@ -57,13 +57,13 @@ void RTileAtlasView::gui_input(const Ref &p_event) { panning.x += 32 * mb->get_factor() * scroll_vec.x; } - emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); + emit_signal(("transform_changed"), zoom_widget->get_zoom(), panning); _update_zoom_and_panning(true); accept_event(); } else if (!mb->is_shift_pressed()) { zoom_widget->set_zoom_by_increments(scroll_vec.y * 2); - emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); + emit_signal(("transform_changed"), zoom_widget->get_zoom(), panning); _update_zoom_and_panning(true); accept_event(); } @@ -84,7 +84,7 @@ void RTileAtlasView::gui_input(const Ref &p_event) { if (drag_type == DRAG_TYPE_PAN) { panning += mm->get_relative(); _update_zoom_and_panning(); - emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); + emit_signal(("transform_changed"), zoom_widget->get_zoom(), panning); accept_event(); } } @@ -93,7 +93,7 @@ void RTileAtlasView::gui_input(const Ref &p_event) { Size2i RTileAtlasView::_compute_base_tiles_control_size() { // Update the texture. Vector2i size; - Ref texture = tile_set_atlas_source->get_texture(); + Ref texture = tile_set_atlas_source->get_texture(); if (texture.is_valid()) { size = texture->get_size(); } @@ -131,7 +131,7 @@ void RTileAtlasView::_update_zoom_and_panning(bool p_zoom_on_mouse_pos) { alternative_tiles_root_control->set_custom_minimum_size(Vector2(alternative_tiles_control_size) * zoom); // Set the texture for the base tiles. - Ref texture = tile_set_atlas_source->get_texture(); + Ref texture = tile_set_atlas_source->get_texture(); // Set the scales. if (base_tiles_control_size.x > 0 && base_tiles_control_size.y > 0) { @@ -174,14 +174,14 @@ void RTileAtlasView::_update_zoom_and_panning(bool p_zoom_on_mouse_pos) { void RTileAtlasView::_zoom_widget_changed() { _update_zoom_and_panning(); - emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); + emit_signal(("transform_changed"), zoom_widget->get_zoom(), panning); } void RTileAtlasView::_center_view() { panning = Vector2(); button_center_view->set_disabled(true); _update_zoom_and_panning(); - emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); + emit_signal(("transform_changed"), zoom_widget->get_zoom(), panning); } void RTileAtlasView::_base_tiles_root_control_gui_input(const Ref &p_event) { @@ -191,9 +191,9 @@ void RTileAtlasView::_base_tiles_root_control_gui_input(const Ref &p if (mm.is_valid()) { Transform2D xform = base_tiles_drawing_root->get_transform().affine_inverse(); Vector2i coords = get_atlas_tile_coords_at_pos(xform.xform(mm->get_position())); - if (coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS) { coords = tile_set_atlas_source->get_tile_at_coords(coords); - if (coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS) { base_tiles_root_control->set_tooltip(vformat(TTR("Source: %d\nAtlas coordinates: %s\nAlternative: 0"), source_id, coords)); } } @@ -201,7 +201,7 @@ void RTileAtlasView::_base_tiles_root_control_gui_input(const Ref &p } void RTileAtlasView::_draw_base_tiles() { - Ref texture = tile_set_atlas_source->get_texture(); + Ref texture = tile_set_atlas_source->get_texture(); if (texture.is_valid()) { Vector2i margins = tile_set_atlas_source->get_margins(); Vector2i separation = tile_set_atlas_source->get_separation(); @@ -212,7 +212,7 @@ void RTileAtlasView::_draw_base_tiles() { for (int x = 0; x < grid_size.x; x++) { for (int y = 0; y < grid_size.y; y++) { Vector2i coords = Vector2i(x, y); - if (tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) { + if (tile_set_atlas_source->get_tile_at_coords(coords) == RTileSetSource::INVALID_ATLAS_COORDS) { Rect2i rect = Rect2i((texture_region_size + separation) * coords + margins, texture_region_size + separation); rect = rect.intersection(Rect2i(Vector2(), texture->get_size())); if (rect.size.x > 0 && rect.size.y > 0) { @@ -292,7 +292,7 @@ void RTileAtlasView::_draw_base_tiles() { } void RTileAtlasView::_draw_base_tiles_texture_grid() { - Ref texture = tile_set_atlas_source->get_texture(); + Ref texture = tile_set_atlas_source->get_texture(); if (texture.is_valid()) { Vector2i margins = tile_set_atlas_source->get_margins(); Vector2i separation = tile_set_atlas_source->get_separation(); @@ -305,7 +305,7 @@ void RTileAtlasView::_draw_base_tiles_texture_grid() { for (int y = 0; y < grid_size.y; y++) { Vector2i origin = margins + (Vector2i(x, y) * (texture_region_size + separation)); Vector2i base_tile_coords = tile_set_atlas_source->get_tile_at_coords(Vector2i(x, y)); - if (base_tile_coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (base_tile_coords != RTileSetSource::INVALID_ATLAS_COORDS) { if (base_tile_coords == Vector2i(x, y)) { // Draw existing tile. Vector2i size_in_atlas = tile_set_atlas_source->get_tile_size_in_atlas(base_tile_coords); @@ -352,7 +352,7 @@ void RTileAtlasView::_alternative_tiles_root_control_gui_input(const Refget_position())); Vector2i coords = Vector2i(coords3.x, coords3.y); int alternative_id = coords3.z; - if (coords != TileSetSource::INVALID_ATLAS_COORDS && alternative_id != TileSetSource::INVALID_TILE_ALTERNATIVE) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS && alternative_id != RTileSetSource::INVALID_TILE_ALTERNATIVE) { alternative_tiles_root_control->set_tooltip(vformat(TTR("Source: %d\nAtlas coordinates: %s\nAlternative: %d"), source_id, coords, alternative_id)); } } @@ -360,7 +360,7 @@ void RTileAtlasView::_alternative_tiles_root_control_gui_input(const Ref texture = tile_set_atlas_source->get_texture(); + Ref texture = tile_set_atlas_source->get_texture(); if (texture.is_valid()) { Vector2 current_pos; for (int i = 0; i < tile_set_atlas_source->get_tiles_count(); i++) { @@ -398,18 +398,18 @@ void RTileAtlasView::_draw_alternatives() { } void RTileAtlasView::_draw_background_left() { - Ref texture = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); + Ref texture = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); background_left->set_size(base_tiles_root_control->get_custom_minimum_size()); background_left->draw_texture_rect(texture, Rect2(Vector2(), background_left->get_size()), true); } void RTileAtlasView::_draw_background_right() { - Ref texture = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); + Ref texture = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); background_right->set_size(alternative_tiles_root_control->get_custom_minimum_size()); background_right->draw_texture_rect(texture, Rect2(Vector2(), background_right->get_size()), true); } -void RTileAtlasView::set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) { +void RTileAtlasView::set_atlas_source(RTileSet *p_tile_set, RTileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) { ERR_FAIL_COND(!p_tile_set); ERR_FAIL_COND(!p_tile_set_atlas_source); ERR_FAIL_COND(p_source_id < 0); @@ -472,7 +472,7 @@ void RTileAtlasView::set_padding(Side p_side, int p_padding) { } Vector2i RTileAtlasView::get_atlas_tile_coords_at_pos(const Vector2 p_pos) const { - Ref texture = tile_set_atlas_source->get_texture(); + Ref texture = tile_set_atlas_source->get_texture(); if (texture.is_valid()) { Vector2i margins = tile_set_atlas_source->get_margins(); Vector2i separation = tile_set_atlas_source->get_separation(); @@ -485,7 +485,7 @@ Vector2i RTileAtlasView::get_atlas_tile_coords_at_pos(const Vector2 p_pos) const return ret; } - return TileSetSource::INVALID_ATLAS_COORDS; + return RTileSetSource::INVALID_ATLAS_COORDS; } void RTileAtlasView::_update_alternative_tiles_rect_cache() { @@ -527,7 +527,7 @@ Vector3i RTileAtlasView::get_alternative_tile_at_pos(const Vector2 p_pos) const } } - return Vector3i(TileSetSource::INVALID_ATLAS_COORDS.x, TileSetSource::INVALID_ATLAS_COORDS.y, TileSetSource::INVALID_TILE_ALTERNATIVE); + return Vector3i(RTileSetSource::INVALID_ATLAS_COORDS.x, RTileSetSource::INVALID_ATLAS_COORDS.y, RTileSetSource::INVALID_TILE_ALTERNATIVE); } Rect2i RTileAtlasView::get_alternative_tile_rect(const Vector2i p_coords, int p_alternative_tile) { diff --git a/tile_editor/tile_atlas_view.h b/tile_editor/tile_atlas_view.h index f113b03..14f0e71 100644 --- a/tile_editor/tile_atlas_view.h +++ b/tile_editor/tile_atlas_view.h @@ -39,15 +39,15 @@ #include "scene/gui/margin_container.h" #include "scene/gui/scroll_container.h" #include "scene/gui/texture_rect.h" -#include "scene/resources/tile_set.h" +#include "../rtile_set.h" class RTileAtlasView : public Control { GDCLASS(RTileAtlasView, Control); private: - TileSet *tile_set; - TileSetAtlasSource *tile_set_atlas_source; - int source_id = TileSet::INVALID_SOURCE; + RTileSet *tile_set; + RTileSetAtlasSource *tile_set_atlas_source; + int source_id = RTileSet::INVALID_SOURCE; enum DragType { DRAG_TYPE_NONE, @@ -112,7 +112,7 @@ protected: public: // Global. - void set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id); + void set_atlas_source(RTileSet *p_tile_set, RTileSetAtlasSource *p_tile_set_atlas_source, int p_source_id); float get_zoom() const; void set_transform(float p_zoom, Vector2i p_panning); diff --git a/tile_editor/tile_data_editors.cpp b/tile_editor/tile_data_editors.cpp index e63ec6e..893ca19 100644 --- a/tile_editor/tile_data_editors.cpp +++ b/tile_editor/tile_data_editors.cpp @@ -32,7 +32,7 @@ #include "tile_set_editor.h" -#include "core/math/geometry_2d.h" +#include "../geometry_2d.h" #include "core/os/keyboard.h" #include "editor/editor_properties.h" diff --git a/tile_editor/tile_data_editors.h b/tile_editor/tile_data_editors.h index b09c3b8..b7a622f 100644 --- a/tile_editor/tile_data_editors.h +++ b/tile_editor/tile_data_editors.h @@ -36,7 +36,7 @@ #include "editor/editor_node.h" #include "editor/editor_properties.h" -#include "scene/2d/tile_map.h" +#include "../rtile_map.h" #include "scene/gui/box_container.h" #include "scene/gui/control.h" #include "scene/gui/label.h" @@ -50,21 +50,21 @@ private: void _tile_set_changed_deferred_update(); protected: - Ref tile_set; + Ref tile_set; TileData *_get_tile_data(TileMapCell p_cell); virtual void _tile_set_changed(){}; static void _bind_methods(); public: - void set_tile_set(Ref p_tile_set); + void set_tile_set(Ref p_tile_set); // Input to handle painting. virtual Control *get_toolbar() { return nullptr; }; - virtual void forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){}; - virtual void forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){}; - virtual void forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref &p_event){}; - virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref &p_event){}; + virtual void forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){}; + virtual void forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){}; + virtual void forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, const Ref &p_event){}; + virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, const Ref &p_event){}; // Used to draw the tile data property value over a tile. virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false){}; @@ -90,7 +90,7 @@ class GenericTilePolygonEditor : public VBoxContainer { GDCLASS(GenericTilePolygonEditor, VBoxContainer); private: - Ref tile_set; + Ref tile_set; LocalVector> polygons; bool multiple_polygon_mode = false; @@ -168,7 +168,7 @@ protected: public: void set_use_undo_redo(bool p_use_undo_redo); - void set_tile_set(Ref p_tile_set); + void set_tile_set(Ref p_tile_set); void set_background(Ref p_texture, Rect2 p_region = Rect2(), Vector2 p_offset = Vector2(), bool p_flip_h = false, bool p_flip_v = false, bool p_transpose = false, Color p_modulate = Color(1.0, 1.0, 1.0, 0.0)); int get_polygon_count(); @@ -223,17 +223,17 @@ protected: void _notification(int p_what); virtual Variant _get_painted_value(); - virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile); - virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value); - virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile); - virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value); + virtual void _set_painted_value(RTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile); + virtual void _set_value(RTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value); + virtual Variant _get_value(RTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile); + virtual void _setup_undo_redo_action(RTileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value); public: virtual Control *get_toolbar() override { return toolbar; }; - virtual void forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override; - virtual void forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override; - virtual void forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref &p_event) override; - virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref &p_event) override; + virtual void forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override; + virtual void forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override; + virtual void forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, const Ref &p_event) override; + virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, const Ref &p_event) override; virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override; void setup_property_editor(Variant::Type p_type, String p_property, String p_label = "", Variant p_default_value = Variant()); @@ -275,10 +275,10 @@ private: void _polygon_changed(PackedVector2Array p_polygon); virtual Variant _get_painted_value() override; - virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override; - virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) override; + virtual void _set_painted_value(RTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; + virtual void _set_value(RTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override; + virtual Variant _get_value(RTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; + virtual void _setup_undo_redo_action(RTileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) override; protected: UndoRedo *undo_redo = EditorNode::get_undo_redo(); @@ -309,10 +309,10 @@ class TileDataCollisionEditor : public TileDataDefaultEditor { void _polygons_changed(); virtual Variant _get_painted_value() override; - virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override; - virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) override; + virtual void _set_painted_value(RTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; + virtual void _set_value(RTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override; + virtual Variant _get_value(RTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; + virtual void _setup_undo_redo_action(RTileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) override; protected: UndoRedo *undo_redo = EditorNode::get_undo_redo(); @@ -371,10 +371,10 @@ protected: public: virtual Control *get_toolbar() override { return toolbar; }; - virtual void forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override; - virtual void forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override; - virtual void forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref &p_event) override; - virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref &p_event) override; + virtual void forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override; + virtual void forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override; + virtual void forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, const Ref &p_event) override; + virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, const Ref &p_event) override; virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override; TileDataTerrainsEditor(); @@ -394,10 +394,10 @@ private: void _polygon_changed(PackedVector2Array p_polygon); virtual Variant _get_painted_value() override; - virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override; - virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) override; + virtual void _set_painted_value(RTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; + virtual void _set_value(RTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override; + virtual Variant _get_value(RTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; + virtual void _setup_undo_redo_action(RTileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) override; protected: UndoRedo *undo_redo = EditorNode::get_undo_redo(); diff --git a/tile_editor/tile_map_editor.cpp b/tile_editor/tile_map_editor.cpp index fa8ac21..72091fd 100644 --- a/tile_editor/tile_map_editor.cpp +++ b/tile_editor/tile_map_editor.cpp @@ -41,7 +41,7 @@ #include "scene/gui/split_container.h" #include "core/input/input.h" -#include "core/math/geometry_2d.h" +#include "../geometry_2d.h" #include "core/os/keyboard.h" void RTileMapEditorTilesPlugin::tile_set_changed() { @@ -131,7 +131,7 @@ void RTileMapEditorTilesPlugin::_update_tile_set_sources_list() { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -139,7 +139,7 @@ void RTileMapEditorTilesPlugin::_update_tile_set_sources_list() { 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; @@ -150,7 +150,7 @@ void RTileMapEditorTilesPlugin::_update_tile_set_sources_list() { } // 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()) { @@ -163,7 +163,7 @@ void RTileMapEditorTilesPlugin::_update_tile_set_sources_list() { } // Scene collection source. - TileSetScenesCollectionSource *scene_collection_source = Object::cast_to(source); + RTileSetScenesCollectionSource *scene_collection_source = Object::cast_to(source); if (scene_collection_source) { texture = tiles_bottom_panel->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); if (item_text.is_empty()) { @@ -204,7 +204,7 @@ void RTileMapEditorTilesPlugin::_update_source_display() { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -215,9 +215,9 @@ void RTileMapEditorTilesPlugin::_update_source_display() { missing_source_label->hide(); int source_id = sources_list->get_item_metadata(source_index); - TileSetSource *source = *tile_set->get_source(source_id); - TileSetAtlasSource *atlas_source = Object::cast_to(source); - TileSetScenesCollectionSource *scenes_collection_source = Object::cast_to(source); + RTileSetSource *source = *tile_set->get_source(source_id); + RTileSetAtlasSource *atlas_source = Object::cast_to(source); + RTileSetScenesCollectionSource *scenes_collection_source = Object::cast_to(source); if (atlas_source) { tile_atlas_view->show(); @@ -250,7 +250,7 @@ void RTileMapEditorTilesPlugin::_patterns_item_list_gui_input(const Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -258,7 +258,7 @@ void RTileMapEditorTilesPlugin::_patterns_item_list_gui_input(const Refis_pressed() && !p_event->is_echo()) { select_last_pattern = true; int new_pattern_index = tile_set->get_patterns_count(); - undo_redo->create_action(TTR("Add TileSet pattern")); + undo_redo->create_action(TTR("Add RTileSet pattern")); undo_redo->add_do_method(*tile_set, "add_pattern", tile_map_clipboard, new_pattern_index); undo_redo->add_undo_method(*tile_set, "remove_pattern", new_pattern_index); undo_redo->commit_action(); @@ -267,7 +267,7 @@ void RTileMapEditorTilesPlugin::_patterns_item_list_gui_input(const Refis_pressed() && !p_event->is_echo()) { Vector selected = patterns_item_list->get_selected_items(); - undo_redo->create_action(TTR("Remove TileSet patterns")); + undo_redo->create_action(TTR("Remove RTileSet patterns")); for (int i = 0; i < selected.size(); i++) { int pattern_index = selected[i]; undo_redo->add_do_method(*tile_set, "remove_pattern", pattern_index); @@ -294,7 +294,7 @@ void RTileMapEditorTilesPlugin::_update_patterns_list() { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -325,14 +325,14 @@ void RTileMapEditorTilesPlugin::_update_atlas_view() { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } int source_id = sources_list->get_item_metadata(sources_list->get_current()); - TileSetSource *source = *tile_set->get_source(source_id); - TileSetAtlasSource *atlas_source = Object::cast_to(source); + RTileSetSource *source = *tile_set->get_source(source_id); + RTileSetAtlasSource *atlas_source = Object::cast_to(source); ERR_FAIL_COND(!atlas_source); tile_atlas_view->set_atlas_source(*tile_map->get_tileset(), atlas_source, source_id); @@ -346,14 +346,14 @@ void RTileMapEditorTilesPlugin::_update_scenes_collection_view() { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } int source_id = sources_list->get_item_metadata(sources_list->get_current()); - TileSetSource *source = *tile_set->get_source(source_id); - TileSetScenesCollectionSource *scenes_collection_source = Object::cast_to(source); + RTileSetSource *source = *tile_set->get_source(source_id); + RTileSetScenesCollectionSource *scenes_collection_source = Object::cast_to(source); ERR_FAIL_COND(!scenes_collection_source); // Clear the list. @@ -400,7 +400,7 @@ void RTileMapEditorTilesPlugin::_scenes_list_multi_selected(int p_index, bool p_ return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -408,8 +408,8 @@ void RTileMapEditorTilesPlugin::_scenes_list_multi_selected(int p_index, bool p_ // Add or remove the Tile form the selection. int scene_id = scene_tiles_list->get_item_metadata(p_index); int source_id = sources_list->get_item_metadata(sources_list->get_current()); - TileSetSource *source = *tile_set->get_source(source_id); - TileSetScenesCollectionSource *scenes_collection_source = Object::cast_to(source); + RTileSetSource *source = *tile_set->get_source(source_id); + RTileSetScenesCollectionSource *scenes_collection_source = Object::cast_to(source); ERR_FAIL_COND(!scenes_collection_source); TileMapCell selected = TileMapCell(source_id, Vector2i(), scene_id); @@ -448,7 +448,7 @@ void RTileMapEditorTilesPlugin::_update_theme() { picker_button->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); erase_button->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("Eraser"), SNAME("EditorIcons"))); - missing_atlas_texture_icon = tiles_bottom_panel->get_theme_icon(SNAME("TileSet"), SNAME("EditorIcons")); + missing_atlas_texture_icon = tiles_bottom_panel->get_theme_icon(SNAME("RTileSet"), SNAME("EditorIcons")); } bool RTileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref &p_event) { @@ -471,7 +471,7 @@ bool RTileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref & } ERR_FAIL_INDEX_V(tile_map_layer, tile_map->get_layers_count(), false); - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return false; } @@ -493,7 +493,7 @@ bool RTileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref & if (!tile_map_selection.is_empty()) { undo_redo->create_action(TTR("Delete tiles")); for (Set::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_do_method(tile_map, "set_cell", tile_map_layer, E->get(), RTileSet::INVALID_SOURCE, RTileSetSource::INVALID_ATLAS_COORDS, RTileSetSource::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())); } undo_redo->add_undo_method(this, "_set_tile_map_selection", _get_tile_map_selection()); @@ -524,7 +524,7 @@ bool RTileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref & if (!tile_map_selection.is_empty()) { undo_redo->create_action(TTR("Delete tiles")); for (Set::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_do_method(tile_map, "set_cell", tile_map_layer, E->get(), RTileSet::INVALID_SOURCE, RTileSetSource::INVALID_ATLAS_COORDS, RTileSetSource::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())); } undo_redo->add_undo_method(this, "_set_tile_map_selection", _get_tile_map_selection()); @@ -545,7 +545,7 @@ bool RTileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref & case DRAG_TYPE_PAINT: { Map to_draw = _draw_line(drag_start_mouse_pos, drag_last_mouse_pos, mpos, drag_erasing); for (const KeyValue &E : to_draw) { - if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { + if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } Vector2i coords = E.key; @@ -562,7 +562,7 @@ bool RTileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref & 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) { - if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { + if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } Vector2i coords = E.key; @@ -612,7 +612,7 @@ bool RTileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref & for (Set::Element *E = tile_map_selection.front(); E; E = E->next()) { Vector2i coords = E->get(); drag_modified.insert(coords, tile_map->get_cell(tile_map_layer, coords)); - tile_map->set_cell(tile_map_layer, coords, TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + tile_map->set_cell(tile_map_layer, coords, RTileSet::INVALID_SOURCE, RTileSetSource::INVALID_ATLAS_COORDS, RTileSetSource::INVALID_TILE_ALTERNATIVE); } } else { // Select tiles @@ -631,7 +631,7 @@ bool RTileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref & drag_modified.clear(); Map to_draw = _draw_line(drag_start_mouse_pos, mpos, mpos, drag_erasing); for (const KeyValue &E : to_draw) { - if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { + if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } Vector2i coords = E.key; @@ -658,7 +658,7 @@ bool RTileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref & 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) { - if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { + if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } Vector2i coords = E.key; @@ -701,7 +701,7 @@ void RTileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_ove } ERR_FAIL_INDEX(tile_map_layer, tile_map->get_layers_count()); - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -737,7 +737,7 @@ void RTileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_ove 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); - if (tile_map->get_cell_source_id(tile_map_layer, coords) != TileSet::INVALID_SOURCE) { + if (tile_map->get_cell_source_id(tile_map_layer, coords) != RTileSet::INVALID_SOURCE) { Transform2D tile_xform; tile_xform.set_origin(tile_map->map_to_world(coords)); tile_xform.set_scale(tile_shape_size); @@ -753,7 +753,7 @@ void RTileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_ove 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); - if (tile_map->get_cell_source_id(tile_map_layer, coords) != TileSet::INVALID_SOURCE) { + if (tile_map->get_cell_source_id(tile_map_layer, coords) != RTileSet::INVALID_SOURCE) { to_draw.insert(coords); } } @@ -860,8 +860,8 @@ void RTileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_ove tile_set->draw_tile_shape(p_overlay, xform * tile_xform, Color(1.0, 1.0, 1.0, 0.5), true); } else { if (tile_set->has_source(E.value.source_id)) { - TileSetSource *source = *tile_set->get_source(E.value.source_id); - TileSetAtlasSource *atlas_source = Object::cast_to(source); + RTileSetSource *source = *tile_set->get_source(E.value.source_id); + RTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { // Get tile data. TileData *tile_data = Object::cast_to(atlas_source->get_tile_data(E.value.get_atlas_coords(), E.value.alternative_tile)); @@ -921,7 +921,7 @@ TileMapCell RTileMapEditorTilesPlugin::_pick_random_tile(Ref p_p return TileMapCell(); } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return TileMapCell(); } @@ -933,8 +933,8 @@ TileMapCell RTileMapEditorTilesPlugin::_pick_random_tile(Ref p_p Vector2i atlas_coords = p_pattern->get_cell_atlas_coords(used_cells[i]); int alternative_tile = p_pattern->get_cell_alternative_tile(used_cells[i]); - TileSetSource *source = *tile_set->get_source(source_id); - TileSetAtlasSource *atlas_source = Object::cast_to(source); + 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()); @@ -952,8 +952,8 @@ TileMapCell RTileMapEditorTilesPlugin::_pick_random_tile(Ref p_p Vector2i atlas_coords = p_pattern->get_cell_atlas_coords(used_cells[i]); int alternative_tile = p_pattern->get_cell_alternative_tile(used_cells[i]); - TileSetSource *source = *tile_set->get_source(source_id); - TileSetAtlasSource *atlas_source = Object::cast_to(source); + 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(); } else { @@ -973,7 +973,7 @@ Map RTileMapEditorTilesPlugin::_draw_line(Vector2 p_start return Map(); } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return Map(); } @@ -981,7 +981,7 @@ Map RTileMapEditorTilesPlugin::_draw_line(Vector2 p_start // Get or create the pattern. Ref erase_pattern; erase_pattern.instantiate(); - erase_pattern->set_cell(Vector2i(0, 0), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + 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; Map output; @@ -1022,7 +1022,7 @@ Map RTileMapEditorTilesPlugin::_draw_rect(Vector2i p_star return Map(); } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return Map(); } @@ -1034,7 +1034,7 @@ Map RTileMapEditorTilesPlugin::_draw_rect(Vector2i p_star // Get or create the pattern. Ref erase_pattern; erase_pattern.instantiate(); - erase_pattern->set_cell(Vector2i(0, 0), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + 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; Map err_output; @@ -1087,7 +1087,7 @@ Map RTileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i Map output; ERR_FAIL_INDEX_V(tile_map_layer, tile_map->get_layers_count(), output); - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return Map(); } @@ -1095,7 +1095,7 @@ Map RTileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i // Get or create the pattern. Ref erase_pattern; erase_pattern.instantiate(); - erase_pattern->set_cell(Vector2i(0, 0), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + 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; if (!pattern->is_empty()) { @@ -1103,7 +1103,7 @@ Map RTileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i // If we are filling empty tiles, compute the tilemap boundaries. Rect2i boundaries; - if (source_cell.source_id == TileSet::INVALID_SOURCE) { + if (source_cell.source_id == RTileSet::INVALID_SOURCE) { boundaries = tile_map->get_used_rect(); } @@ -1119,7 +1119,7 @@ Map RTileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i if (source_cell.source_id == tile_map->get_cell_source_id(tile_map_layer, coords) && source_cell.get_atlas_coords() == tile_map->get_cell_atlas_coords(tile_map_layer, coords) && source_cell.alternative_tile == tile_map->get_cell_alternative_tile(tile_map_layer, coords) && - (source_cell.source_id != TileSet::INVALID_SOURCE || boundaries.has_point(coords))) { + (source_cell.source_id != RTileSet::INVALID_SOURCE || boundaries.has_point(coords))) { if (!p_erase && random_tile_checkbox->is_pressed()) { // Paint a random tile. output.insert(coords, _pick_random_tile(pattern)); @@ -1147,7 +1147,7 @@ Map RTileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i } else { // Replace all tiles like the source. TypedArray to_check; - if (source_cell.source_id == TileSet::INVALID_SOURCE) { + if (source_cell.source_id == RTileSet::INVALID_SOURCE) { Rect2i rect = tile_map->get_used_rect(); if (rect.has_no_area()) { rect = Rect2i(p_coords, Vector2i(1, 1)); @@ -1165,7 +1165,7 @@ Map RTileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i if (source_cell.source_id == tile_map->get_cell_source_id(tile_map_layer, coords) && source_cell.get_atlas_coords() == tile_map->get_cell_atlas_coords(tile_map_layer, coords) && source_cell.alternative_tile == tile_map->get_cell_alternative_tile(tile_map_layer, coords) && - (source_cell.source_id != TileSet::INVALID_SOURCE || boundaries.has_point(coords))) { + (source_cell.source_id != RTileSet::INVALID_SOURCE || boundaries.has_point(coords))) { if (!p_erase && random_tile_checkbox->is_pressed()) { // Paint a random tile. output.insert(coords, _pick_random_tile(pattern)); @@ -1202,7 +1202,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { } ERR_FAIL_INDEX(tile_map_layer, tile_map->get_layers_count()); - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -1227,7 +1227,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { tile_map_selection.erase(coords); } } else { - if (tile_map->get_cell_source_id(tile_map_layer, coords) != TileSet::INVALID_SOURCE) { + if (tile_map->get_cell_source_id(tile_map_layer, coords) != RTileSet::INVALID_SOURCE) { tile_map_selection.insert(coords); } } @@ -1249,7 +1249,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { // Creating a pattern in the pattern list. select_last_pattern = true; int new_pattern_index = tile_set->get_patterns_count(); - undo_redo->create_action(TTR("Add TileSet pattern")); + undo_redo->create_action(TTR("Add RTileSet pattern")); undo_redo->add_do_method(*tile_set, "add_pattern", selection_pattern, new_pattern_index); undo_redo->add_undo_method(*tile_set, "remove_pattern", new_pattern_index); undo_redo->commit_action(); @@ -1318,7 +1318,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { 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); - if (tile_map->get_cell_source_id(tile_map_layer, coords) != TileSet::INVALID_SOURCE) { + if (tile_map->get_cell_source_id(tile_map_layer, coords) != RTileSet::INVALID_SOURCE) { coords_array.push_back(coords); } } @@ -1342,7 +1342,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { 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) { - if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { + if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); @@ -1354,7 +1354,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { 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) { - if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { + if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); @@ -1390,9 +1390,9 @@ void RTileMapEditorTilesPlugin::_stop_dragging() { void RTileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { TileMap *tile_map = Object::cast_to(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - hovered_tile.source_id = TileSet::INVALID_SOURCE; - hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); - hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + hovered_tile.source_id = RTileSet::INVALID_SOURCE; + hovered_tile.set_atlas_coords(RTileSetSource::INVALID_ATLAS_COORDS); + hovered_tile.alternative_tile = RTileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_selection.clear(); patterns_item_list->deselect_all(); tile_map_selection.clear(); @@ -1400,11 +1400,11 @@ void RTileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - hovered_tile.source_id = TileSet::INVALID_SOURCE; - hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); - hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + hovered_tile.source_id = RTileSet::INVALID_SOURCE; + hovered_tile.set_atlas_coords(RTileSetSource::INVALID_ATLAS_COORDS); + hovered_tile.alternative_tile = RTileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_selection.clear(); patterns_item_list->deselect_all(); tile_map_selection.clear(); @@ -1414,9 +1414,9 @@ void RTileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { int source_index = sources_list->get_current(); if (source_index < 0 || source_index >= sources_list->get_item_count()) { - hovered_tile.source_id = TileSet::INVALID_SOURCE; - hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); - hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + hovered_tile.source_id = RTileSet::INVALID_SOURCE; + hovered_tile.set_atlas_coords(RTileSetSource::INVALID_ATLAS_COORDS); + hovered_tile.alternative_tile = RTileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_selection.clear(); patterns_item_list->deselect_all(); tile_map_selection.clear(); @@ -1431,9 +1431,9 @@ void RTileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { !tile_set->has_source(hovered_tile.source_id) || !tile_set->get_source(hovered_tile.source_id)->has_tile(hovered_tile.get_atlas_coords()) || !tile_set->get_source(hovered_tile.source_id)->has_alternative_tile(hovered_tile.get_atlas_coords(), hovered_tile.alternative_tile)) { - hovered_tile.source_id = TileSet::INVALID_SOURCE; - hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); - hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + hovered_tile.source_id = RTileSet::INVALID_SOURCE; + hovered_tile.set_atlas_coords(RTileSetSource::INVALID_ATLAS_COORDS); + hovered_tile.alternative_tile = RTileSetSource::INVALID_TILE_ALTERNATIVE; } // Selection if needed. @@ -1464,7 +1464,7 @@ void RTileMapEditorTilesPlugin::_fix_invalid_tiles_in_tile_map_selection() { Set to_remove; for (Vector2i selected : tile_map_selection) { TileMapCell cell = tile_map->get_cell(tile_map_layer, selected); - if (cell.source_id == TileSet::INVALID_SOURCE && cell.get_atlas_coords() == TileSetSource::INVALID_ATLAS_COORDS && cell.alternative_tile == TileSetAtlasSource::INVALID_TILE_ALTERNATIVE) { + 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); } } @@ -1480,7 +1480,7 @@ void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tilemap_selection return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -1502,7 +1502,7 @@ void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_sel return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -1526,8 +1526,8 @@ void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_sel Rect2i encompassing_rect_coords; Map organized_pattern; - TileSetSource *source = *tile_set->get_source(E_source.key); - TileSetAtlasSource *atlas_source = Object::cast_to(source); + 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) { @@ -1575,7 +1575,7 @@ void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_pattern_s return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -1598,7 +1598,7 @@ void RTileMapEditorTilesPlugin::_update_tileset_selection_from_selection_pattern TypedArray 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) != TileSet::INVALID_SOURCE) { + 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))); } } @@ -1613,7 +1613,7 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_draw() { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -1628,7 +1628,7 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_draw() { return; } - TileSetAtlasSource *atlas = Object::cast_to(*tile_set->get_source(source_id)); + RTileSetAtlasSource *atlas = Object::cast_to(*tile_set->get_source(source_id)); if (!atlas) { return; } @@ -1649,7 +1649,7 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_draw() { } // Draw the hovered tile. - if (hovered_tile.get_atlas_coords() != TileSetSource::INVALID_ATLAS_COORDS && hovered_tile.alternative_tile == 0 && !tile_set_dragging_selection) { + if (hovered_tile.get_atlas_coords() != RTileSetSource::INVALID_ATLAS_COORDS && hovered_tile.alternative_tile == 0 && !tile_set_dragging_selection) { for (int frame = 0; frame < atlas->get_tile_animation_frames_count(hovered_tile.get_atlas_coords()); frame++) { Color color = Color(1.0, 1.0, 1.0); if (frame > 0) { @@ -1671,7 +1671,7 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_draw() { for (int x = region.position.x; x < region.get_end().x; x++) { for (int y = region.position.y; y < region.get_end().y; y++) { Vector2i tile = atlas->get_tile_at_coords(Vector2i(x, y)); - if (tile != TileSetSource::INVALID_ATLAS_COORDS) { + if (tile != RTileSetSource::INVALID_ATLAS_COORDS) { to_draw.insert(tile); } } @@ -1684,9 +1684,9 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_draw() { } void RTileMapEditorTilesPlugin::_tile_atlas_control_mouse_exited() { - hovered_tile.source_id = TileSet::INVALID_SOURCE; - hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); - hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + hovered_tile.source_id = RTileSet::INVALID_SOURCE; + hovered_tile.set_atlas_coords(RTileSetSource::INVALID_ATLAS_COORDS); + hovered_tile.alternative_tile = RTileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_dragging_selection = false; tile_atlas_control->update(); } @@ -1697,7 +1697,7 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -1712,19 +1712,19 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref(*tile_set->get_source(source_id)); + RTileSetAtlasSource *atlas = Object::cast_to(*tile_set->get_source(source_id)); if (!atlas) { return; } // Update the hovered tile hovered_tile.source_id = source_id; - hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); - hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + hovered_tile.set_atlas_coords(RTileSetSource::INVALID_ATLAS_COORDS); + hovered_tile.alternative_tile = RTileSetSource::INVALID_TILE_ALTERNATIVE; Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(tile_atlas_control->get_local_mouse_position()); - if (coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS) { coords = atlas->get_tile_at_coords(coords); - if (coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS) { hovered_tile.set_atlas_coords(coords); hovered_tile.alternative_tile = 0; } @@ -1745,7 +1745,7 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Refis_shift_pressed() && tile_set_selection.has(TileMapCell(source_id, hovered_tile.get_atlas_coords(), 0))) { tile_set_selection.erase(TileMapCell(source_id, hovered_tile.get_atlas_coords(), 0)); } else { @@ -1761,18 +1761,18 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Refget_atlas_tile_coords_at_pos(tile_set_drag_start_mouse_pos); Vector2i end_tile = tile_atlas_view->get_atlas_tile_coords_at_pos(tile_atlas_control->get_local_mouse_position()); - if (start_tile != TileSetSource::INVALID_ATLAS_COORDS && end_tile != TileSetSource::INVALID_ATLAS_COORDS) { + if (start_tile != RTileSetSource::INVALID_ATLAS_COORDS && end_tile != RTileSetSource::INVALID_ATLAS_COORDS) { Rect2i region = Rect2i(start_tile, end_tile - start_tile).abs(); region.size += Vector2i(1, 1); // To update the selection, we copy the selected/not selected status of the tiles we drag from. Vector2i start_coords = atlas->get_tile_at_coords(start_tile); - if (mb->is_shift_pressed() && start_coords != TileSetSource::INVALID_ATLAS_COORDS && !tile_set_selection.has(TileMapCell(source_id, start_coords, 0))) { + if (mb->is_shift_pressed() && start_coords != RTileSetSource::INVALID_ATLAS_COORDS && !tile_set_selection.has(TileMapCell(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 != TileSetSource::INVALID_ATLAS_COORDS && tile_set_selection.has(TileMapCell(source_id, tile_coords, 0))) { + if (tile_coords != RTileSetSource::INVALID_ATLAS_COORDS && tile_set_selection.has(TileMapCell(source_id, tile_coords, 0))) { tile_set_selection.erase(TileMapCell(source_id, tile_coords, 0)); } } @@ -1782,7 +1782,7 @@ void RTileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Refget_tile_at_coords(Vector2i(x, y)); - if (tile_coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (tile_coords != RTileSetSource::INVALID_ATLAS_COORDS) { tile_set_selection.insert(TileMapCell(source_id, tile_coords, 0)); } } @@ -1803,7 +1803,7 @@ void RTileMapEditorTilesPlugin::_tile_alternatives_control_draw() { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -1818,14 +1818,14 @@ void RTileMapEditorTilesPlugin::_tile_alternatives_control_draw() { return; } - TileSetAtlasSource *atlas = Object::cast_to(*tile_set->get_source(source_id)); + RTileSetAtlasSource *atlas = Object::cast_to(*tile_set->get_source(source_id)); if (!atlas) { return; } // Draw the selection. for (Set::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) { + 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()) { alternative_tiles_control->draw_rect(rect, Color(0.2, 0.2, 1.0), false); @@ -1834,7 +1834,7 @@ void RTileMapEditorTilesPlugin::_tile_alternatives_control_draw() { } // Draw hovered tile. - if (hovered_tile.get_atlas_coords() != TileSetSource::INVALID_ATLAS_COORDS && hovered_tile.alternative_tile > 0) { + if (hovered_tile.get_atlas_coords() != RTileSetSource::INVALID_ATLAS_COORDS && hovered_tile.alternative_tile > 0) { Rect2i rect = tile_atlas_view->get_alternative_tile_rect(hovered_tile.get_atlas_coords(), hovered_tile.alternative_tile); if (rect != Rect2i()) { alternative_tiles_control->draw_rect(rect, Color(1.0, 1.0, 1.0), false); @@ -1843,9 +1843,9 @@ void RTileMapEditorTilesPlugin::_tile_alternatives_control_draw() { } void RTileMapEditorTilesPlugin::_tile_alternatives_control_mouse_exited() { - hovered_tile.source_id = TileSet::INVALID_SOURCE; - hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); - hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + hovered_tile.source_id = RTileSet::INVALID_SOURCE; + hovered_tile.set_atlas_coords(RTileSetSource::INVALID_ATLAS_COORDS); + hovered_tile.alternative_tile = RTileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_dragging_selection = false; alternative_tiles_control->update(); } @@ -1856,7 +1856,7 @@ void RTileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -1871,19 +1871,19 @@ void RTileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref(*tile_set->get_source(source_id)); + RTileSetAtlasSource *atlas = Object::cast_to(*tile_set->get_source(source_id)); if (!atlas) { return; } // Update the hovered tile hovered_tile.source_id = source_id; - hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); - hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + hovered_tile.set_atlas_coords(RTileSetSource::INVALID_ATLAS_COORDS); + hovered_tile.alternative_tile = RTileSetSource::INVALID_TILE_ALTERNATIVE; Vector3i alternative_coords = tile_atlas_view->get_alternative_tile_at_pos(alternative_tiles_control->get_local_mouse_position()); Vector2i coords = Vector2i(alternative_coords.x, alternative_coords.y); int alternative = alternative_coords.z; - if (coords != TileSetSource::INVALID_ATLAS_COORDS && alternative != TileSetSource::INVALID_TILE_ALTERNATIVE) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS && alternative != RTileSetSource::INVALID_TILE_ALTERNATIVE) { hovered_tile.set_atlas_coords(coords); hovered_tile.alternative_tile = alternative; } @@ -1902,7 +1902,7 @@ void RTileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Refis_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)); } else { @@ -2093,7 +2093,7 @@ RTileMapEditorTilesPlugin::RTileMapEditorTilesPlugin() { tiles_bottom_panel->set_name(TTR("Tiles")); missing_source_label = memnew(Label); - missing_source_label->set_text(TTR("This TileMap's TileSet has no source configured. Edit the TileSet resource to add one.")); + missing_source_label->set_text(TTR("This TileMap's RTileSet has no source configured. Edit the RTileSet resource to add one.")); missing_source_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); missing_source_label->set_v_size_flags(Control::SIZE_EXPAND_FILL); missing_source_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); @@ -2237,13 +2237,13 @@ Vector RTileMapEditorTerrainsPlugin::get_tabs() c return tabs; } -Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Map &p_to_paint, int p_terrain_set) const { +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)); if (!tile_map) { return Map(); } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return Map(); } @@ -2252,9 +2252,9 @@ Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Ma // Add the constraints from the added tiles. Set added_tiles_constraints_set; - for (const KeyValue &E_to_paint : p_to_paint) { + for (const KeyValue &E_to_paint : p_to_paint) { Vector2i coords = E_to_paint.key; - TileSet::TerrainsPattern terrains_pattern = E_to_paint.value; + 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()) { @@ -2264,11 +2264,11 @@ Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Ma // Build the list of potential tiles to replace. Set potential_to_replace; - for (const KeyValue &E_to_paint : p_to_paint) { + for (const KeyValue &E_to_paint : p_to_paint) { Vector2i coords = E_to_paint.key; - for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) { - if (tile_map->is_existing_neighbor(TileSet::CellNeighbor(i))) { - Vector2i neighbor = tile_map->get_neighbor_cell(coords, TileSet::CellNeighbor(i)); + for (int i = 0; i < RTileSet::CELL_NEIGHBOR_MAX; i++) { + if (tile_map->is_existing_neighbor(RTileSet::CellNeighbor(i))) { + Vector2i neighbor = tile_map->get_neighbor_cell(coords, RTileSet::CellNeighbor(i)); if (!p_to_paint.has(neighbor)) { potential_to_replace.insert(neighbor); } @@ -2280,7 +2280,7 @@ Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Ma Set to_replace; // Add the central tiles to the one to replace. - for (const KeyValue &E_to_paint : p_to_paint) { + for (const KeyValue &E_to_paint : p_to_paint) { to_replace.insert(E_to_paint.key); } @@ -2294,8 +2294,8 @@ Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Ma // 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 sources_of_constraint = E->get().get_overlapping_coords_and_peering_bits(); - for (const KeyValue &E_source_tile_of_constraint : sources_of_constraint) { + 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)) { per_constraint_tiles[E->get()].insert(E_source_tile_of_constraint.key); } @@ -2330,20 +2330,20 @@ Map RTileMapEditorTerrainsPlugin::_draw_terrains(const Ma } // Remove the central tiles from the ones to replace. - for (const KeyValue &E_to_paint : p_to_paint) { + for (const KeyValue &E_to_paint : p_to_paint) { to_replace.erase(E_to_paint.key); } // Run WFC to fill the holes with the constraints. - Map wfc_output = tile_map->terrain_wave_function_collapse(to_replace, p_terrain_set, constraints); + Map wfc_output = tile_map->terrain_wave_function_collapse(to_replace, p_terrain_set, constraints); // Actually paint the tiles. - for (const KeyValue &E_to_paint : p_to_paint) { + for (const KeyValue &E_to_paint : p_to_paint) { output[E_to_paint.key] = tile_set->get_random_tile_from_terrains_pattern(p_terrain_set, E_to_paint.value); } // Use the WFC run for the output. - for (const KeyValue &E : wfc_output) { + for (const KeyValue &E : wfc_output) { output[E.key] = tile_set->get_random_tile_from_terrains_pattern(p_terrain_set, E.value); } @@ -2356,20 +2356,20 @@ Map RTileMapEditorTerrainsPlugin::_draw_line(Vector2i p_s return Map(); } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return Map(); } - TileSet::TerrainsPattern terrains_pattern; + RTileSet::TerrainsPattern terrains_pattern; if (p_erase) { - terrains_pattern = TileSet::TerrainsPattern(*tile_set, selected_terrain_set); + terrains_pattern = RTileSet::TerrainsPattern(*tile_set, selected_terrain_set); } else { terrains_pattern = selected_terrains_pattern; } Vector line = RTileMapEditor::get_line(tile_map, p_start_cell, p_end_cell); - Map to_draw; + Map to_draw; for (int i = 0; i < line.size(); i++) { to_draw[line[i]] = terrains_pattern; } @@ -2382,14 +2382,14 @@ Map RTileMapEditorTerrainsPlugin::_draw_rect(Vector2i p_s return Map(); } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return Map(); } - TileSet::TerrainsPattern terrains_pattern; + RTileSet::TerrainsPattern terrains_pattern; if (p_erase) { - terrains_pattern = TileSet::TerrainsPattern(*tile_set, selected_terrain_set); + terrains_pattern = RTileSet::TerrainsPattern(*tile_set, selected_terrain_set); } else { terrains_pattern = selected_terrains_pattern; } @@ -2399,7 +2399,7 @@ Map RTileMapEditorTerrainsPlugin::_draw_rect(Vector2i p_s rect.set_end(p_end_cell); rect = rect.abs(); - Map to_draw; + Map to_draw; for (int x = rect.position.x; x <= rect.get_end().x; x++) { for (int y = rect.position.y; y <= rect.get_end().y; y++) { to_draw[Vector2i(x, y)] = terrains_pattern; @@ -2414,18 +2414,18 @@ Set RTileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i return Set(); } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return Set(); } TileMapCell source_cell = tile_map->get_cell(tile_map_layer, p_coords); - TileSet::TerrainsPattern source_pattern(*tile_set, selected_terrain_set); - if (source_cell.source_id != TileSet::INVALID_SOURCE) { + RTileSet::TerrainsPattern source_pattern(*tile_set, selected_terrain_set); + if (source_cell.source_id != RTileSet::INVALID_SOURCE) { TileData *tile_data = nullptr; - Ref source = tile_set->get_source(source_cell.source_id); - Ref atlas_source = source; + 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)); } @@ -2437,7 +2437,7 @@ Set RTileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i // If we are filling empty tiles, compute the tilemap boundaries. Rect2i boundaries; - if (source_cell.source_id == TileSet::INVALID_SOURCE) { + if (source_cell.source_id == RTileSet::INVALID_SOURCE) { boundaries = tile_map->get_used_rect(); } @@ -2452,11 +2452,11 @@ Set RTileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i to_check.pop_back(); if (!already_checked.has(coords)) { // Get the candidate cell pattern. - TileSet::TerrainsPattern candidate_pattern(*tile_set, selected_terrain_set); - if (tile_map->get_cell_source_id(tile_map_layer, coords) != TileSet::INVALID_SOURCE) { + RTileSet::TerrainsPattern candidate_pattern(*tile_set, selected_terrain_set); + if (tile_map->get_cell_source_id(tile_map_layer, coords) != RTileSet::INVALID_SOURCE) { TileData *tile_data = nullptr; - Ref source = tile_set->get_source(tile_map->get_cell_source_id(tile_map_layer, coords)); - Ref atlas_source = source; + 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))); } @@ -2481,7 +2481,7 @@ Set RTileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i } else { // Replace all tiles like the source. TypedArray to_check; - if (source_cell.source_id == TileSet::INVALID_SOURCE) { + if (source_cell.source_id == RTileSet::INVALID_SOURCE) { Rect2i rect = tile_map->get_used_rect(); if (rect.has_no_area()) { rect = Rect2i(p_coords, Vector2i(1, 1)); @@ -2497,11 +2497,11 @@ Set RTileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i for (int i = 0; i < to_check.size(); i++) { Vector2i coords = to_check[i]; // Get the candidate cell pattern. - TileSet::TerrainsPattern candidate_pattern; - if (tile_map->get_cell_source_id(tile_map_layer, coords) != TileSet::INVALID_SOURCE) { + RTileSet::TerrainsPattern candidate_pattern; + if (tile_map->get_cell_source_id(tile_map_layer, coords) != RTileSet::INVALID_SOURCE) { TileData *tile_data = nullptr; - Ref source = tile_set->get_source(tile_map->get_cell_source_id(tile_map_layer, coords)); - Ref atlas_source = source; + 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))); } @@ -2525,20 +2525,20 @@ Map RTileMapEditorTerrainsPlugin::_draw_bucket_fill(Vecto return Map(); } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return Map(); } - TileSet::TerrainsPattern terrains_pattern; + RTileSet::TerrainsPattern terrains_pattern; if (p_erase) { - terrains_pattern = TileSet::TerrainsPattern(*tile_set, selected_terrain_set); + terrains_pattern = RTileSet::TerrainsPattern(*tile_set, selected_terrain_set); } else { terrains_pattern = selected_terrains_pattern; } Set cells_to_draw = _get_cells_for_bucket_fill(p_coords, p_contiguous); - Map to_draw; + Map to_draw; for (const Vector2i &coords : cells_to_draw) { to_draw[coords] = terrains_pattern; } @@ -2552,7 +2552,7 @@ void RTileMapEditorTerrainsPlugin::_stop_dragging() { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -2566,14 +2566,14 @@ void RTileMapEditorTerrainsPlugin::_stop_dragging() { TileMapCell cell = tile_map->get_cell(tile_map_layer, coords); TileData *tile_data = nullptr; - Ref source = tile_set->get_source(cell.source_id); - Ref atlas_source = source; + 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)); } if (tile_data) { - TileSet::TerrainsPattern terrains_pattern = tile_data->get_terrains_pattern(); + RTileSet::TerrainsPattern terrains_pattern = tile_data->get_terrains_pattern(); // Find the tree item for the right terrain set. bool need_tree_item_switch = true; @@ -2612,7 +2612,7 @@ void RTileMapEditorTerrainsPlugin::_stop_dragging() { if (tree_item) { for (int i = 0; i < terrains_tile_list->get_item_count(); i++) { Dictionary metadata_dict = terrains_tile_list->get_item_metadata(i); - TileSet::TerrainsPattern in_meta_terrains_pattern(*tile_set, new_terrain_set); + RTileSet::TerrainsPattern in_meta_terrains_pattern(*tile_set, new_terrain_set); in_meta_terrains_pattern.set_terrains_from_array(metadata_dict["terrains_pattern"]); if (in_meta_terrains_pattern == terrains_pattern) { terrains_tile_list->select(i); @@ -2637,7 +2637,7 @@ void RTileMapEditorTerrainsPlugin::_stop_dragging() { 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) { - if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { + if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); @@ -2649,7 +2649,7 @@ void RTileMapEditorTerrainsPlugin::_stop_dragging() { 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) { - if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { + if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); @@ -2683,13 +2683,13 @@ void RTileMapEditorTerrainsPlugin::_update_selection() { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } // Get the selected terrain. - selected_terrains_pattern = TileSet::TerrainsPattern(); + selected_terrains_pattern = RTileSet::TerrainsPattern(); selected_terrain_set = -1; TreeItem *selected_tree_item = terrains_tree->get_selected(); @@ -2700,10 +2700,10 @@ void RTileMapEditorTerrainsPlugin::_update_selection() { // Selected tile if (erase_button->is_pressed()) { - selected_terrains_pattern = TileSet::TerrainsPattern(*tile_set, selected_terrain_set); + selected_terrains_pattern = RTileSet::TerrainsPattern(*tile_set, selected_terrain_set); } else if (terrains_tile_list->is_anything_selected()) { metadata_dict = terrains_tile_list->get_item_metadata(terrains_tile_list->get_selected_items()[0]); - selected_terrains_pattern = TileSet::TerrainsPattern(*tile_set, selected_terrain_set); + selected_terrains_pattern = RTileSet::TerrainsPattern(*tile_set, selected_terrain_set); selected_terrains_pattern.set_terrains_from_array(metadata_dict["terrains_pattern"]); } } @@ -2724,7 +2724,7 @@ bool RTileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return false; } @@ -2821,7 +2821,7 @@ bool RTileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref 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 == TileSet::INVALID_SOURCE) { + if (!drag_erasing && E.value.source_id == RTileSet::INVALID_SOURCE) { continue; } Vector2i coords = E.key; @@ -2861,7 +2861,7 @@ void RTileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_ } ERR_FAIL_INDEX(tile_map_layer, tile_map->get_layers_count()); - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -2881,7 +2881,7 @@ void RTileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_ if (drag_type == DRAG_TYPE_PICK) { // Draw the area being picked. Vector2i coords = tile_map->world_to_map(drag_last_mouse_pos); - if (tile_map->get_cell_source_id(tile_map_layer, coords) != TileSet::INVALID_SOURCE) { + if (tile_map->get_cell_source_id(tile_map_layer, coords) != RTileSet::INVALID_SOURCE) { Transform2D tile_xform; tile_xform.set_origin(tile_map->map_to_world(coords)); tile_xform.set_scale(tile_shape_size); @@ -2912,7 +2912,7 @@ void RTileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_ rect.set_end(tile_map->world_to_map(drag_last_mouse_pos)); rect = rect.abs(); - Map to_draw; + Map to_draw; for (int x = rect.position.x; x <= rect.get_end().x; x++) { for (int y = rect.position.y; y <= rect.get_end().y; y++) { preview.insert(Vector2i(x, y)); @@ -2985,7 +2985,7 @@ void RTileMapEditorTerrainsPlugin::_update_terrains_cache() { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -3001,9 +3001,9 @@ void RTileMapEditorTerrainsPlugin::_update_terrains_cache() { for (int source_index = 0; source_index < tile_set->get_source_count(); source_index++) { int source_id = tile_set->get_source_id(source_index); - Ref source = tile_set->get_source(source_id); + Ref source = tile_set->get_source(source_id); - Ref atlas_source = source; + Ref atlas_source = source; if (atlas_source.is_valid()) { for (int tile_index = 0; tile_index < source->get_tiles_count(); tile_index++) { Vector2i tile_id = source->get_tile_id(tile_index); @@ -3020,10 +3020,10 @@ void RTileMapEditorTerrainsPlugin::_update_terrains_cache() { cell.set_atlas_coords(tile_id); cell.alternative_tile = alternative_id; - TileSet::TerrainsPattern terrains_pattern = tile_data->get_terrains_pattern(); + RTileSet::TerrainsPattern terrains_pattern = tile_data->get_terrains_pattern(); // Terrain bits. - for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) { - TileSet::CellNeighbor bit = TileSet::CellNeighbor(i); + for (int i = 0; i < RTileSet::CELL_NEIGHBOR_MAX; i++) { + RTileSet::CellNeighbor bit = RTileSet::CellNeighbor(i); if (tile_set->is_valid_peering_bit_terrain(terrain_set, bit)) { int terrain = terrains_pattern.get_terrain(bit); if (terrain >= 0 && terrain < (int)per_terrain_terrains_patterns[terrain_set].size()) { @@ -3047,7 +3047,7 @@ void RTileMapEditorTerrainsPlugin::_update_terrains_tree() { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -3058,10 +3058,10 @@ void RTileMapEditorTerrainsPlugin::_update_terrains_tree() { // Add an item for the terrain set. TreeItem *terrain_set_tree_item = terrains_tree->create_item(); String matches; - if (tile_set->get_terrain_set_mode(terrain_set_index) == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) { + if (tile_set->get_terrain_set_mode(terrain_set_index) == RTileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) { terrain_set_tree_item->set_icon(0, main_vbox_container->get_theme_icon(SNAME("TerrainMatchCornersAndSides"), SNAME("EditorIcons"))); matches = String(TTR("Matches Corners and Sides")); - } else if (tile_set->get_terrain_set_mode(terrain_set_index) == TileSet::TERRAIN_MODE_MATCH_CORNERS) { + } else if (tile_set->get_terrain_set_mode(terrain_set_index) == RTileSet::TERRAIN_MODE_MATCH_CORNERS) { terrain_set_tree_item->set_icon(0, main_vbox_container->get_theme_icon(SNAME("TerrainMatchCorners"), SNAME("EditorIcons"))); matches = String(TTR("Matches Corners Only")); } else { @@ -3094,7 +3094,7 @@ void RTileMapEditorTerrainsPlugin::_update_tiles_list() { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -3108,14 +3108,14 @@ void RTileMapEditorTerrainsPlugin::_update_tiles_list() { ERR_FAIL_INDEX(selected_terrain_id, tile_set->get_terrains_count(selected_terrain_set)); // Sort the items in a map by the number of corresponding terrains. - Map> sorted; + Map> sorted; - for (Set::Element *E = per_terrain_terrains_patterns[selected_terrain_set][selected_terrain_id].front(); E; E = E->next()) { + for (Set::Element *E = per_terrain_terrains_patterns[selected_terrain_set][selected_terrain_id].front(); E; E = E->next()) { // Count the number of matching sides/terrains. int count = 0; - for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) { - TileSet::CellNeighbor bit = TileSet::CellNeighbor(i); + for (int i = 0; i < RTileSet::CELL_NEIGHBOR_MAX; i++) { + RTileSet::CellNeighbor bit = RTileSet::CellNeighbor(i); if (tile_set->is_valid_peering_bit_terrain(selected_terrain_set, bit) && E->get().get_terrain(bit) == selected_terrain_id) { count++; } @@ -3123,9 +3123,9 @@ void RTileMapEditorTerrainsPlugin::_update_tiles_list() { sorted[count].insert(E->get()); } - for (Map>::Element *E_set = sorted.back(); E_set; E_set = E_set->prev()) { - for (Set::Element *E = E_set->get().front(); E; E = E->next()) { - TileSet::TerrainsPattern terrains_pattern = E->get(); + for (Map>::Element *E_set = sorted.back(); E_set; E_set = E_set->prev()) { + for (Set::Element *E = E_set->get().front(); E; E = E->next()) { + RTileSet::TerrainsPattern terrains_pattern = E->get(); // Get the icon. Ref icon; @@ -3134,9 +3134,9 @@ void RTileMapEditorTerrainsPlugin::_update_tiles_list() { double max_probability = -1.0; for (const TileMapCell &cell : tile_set->get_tiles_for_terrains_pattern(selected_terrain_set, terrains_pattern)) { - Ref source = tile_set->get_source(cell.source_id); + Ref source = tile_set->get_source(cell.source_id); - Ref atlas_source = source; + 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)); if (tile_data->get_probability() > max_probability) { @@ -3408,7 +3408,7 @@ void RTileMapEditor::_advanced_menu_button_id_pressed(int p_id) { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -3440,7 +3440,7 @@ void RTileMapEditor::_update_bottom_panel() { if (!tile_map) { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); // Update the visibility of controls. missing_tileset_label->set_visible(!tile_set.is_valid()); @@ -3455,19 +3455,19 @@ void RTileMapEditor::_update_bottom_panel() { Vector RTileMapEditor::get_line(TileMap *p_tile_map, Vector2i p_from_cell, Vector2i p_to_cell) { ERR_FAIL_COND_V(!p_tile_map, Vector()); - Ref tile_set = p_tile_map->get_tileset(); + Ref tile_set = p_tile_map->get_tileset(); ERR_FAIL_COND_V(!tile_set.is_valid(), Vector()); - if (tile_set->get_tile_shape() == TileSet::TILE_SHAPE_SQUARE) { + if (tile_set->get_tile_shape() == RTileSet::TILE_SHAPE_SQUARE) { return Geometry2D::bresenham_line(p_from_cell, p_to_cell); } else { // Adapt the bresenham line algorithm to half-offset shapes. // See this blog post: http://zvold.blogspot.com/2010/01/bresenhams-line-drawing-algorithm-on_26.html Vector points; - bool transposed = tile_set->get_tile_offset_axis() == TileSet::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(), TileSet::TILE_LAYOUT_STACKED); - p_to_cell = TileMap::transform_coords_layout(p_to_cell, tile_set->get_tile_offset_axis(), tile_set->get_tile_layout(), TileSet::TILE_LAYOUT_STACKED); + 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); 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(), TileSet::TILE_LAYOUT_STACKED, tile_set->get_tile_layout())); + 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())); 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(), TileSet::TILE_LAYOUT_STACKED, tile_set->get_tile_layout())); + 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())); } } 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(), TileSet::TILE_LAYOUT_STACKED, tile_set->get_tile_layout())); + 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())); } } @@ -3654,7 +3654,7 @@ void RTileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p if (p_array_prefix == "layer_") { end = tile_map->get_layers_count(); } else { - ERR_FAIL_MSG("Invalid array prefix for TileSet."); + ERR_FAIL_MSG("Invalid array prefix for RTileSet."); } if (p_from_index < 0) { // Adding new. @@ -3731,7 +3731,7 @@ void RTileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { return; } - Ref tile_set = tile_map->get_tileset(); + Ref tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { return; } @@ -3755,7 +3755,7 @@ void RTileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Vector2i tile_atlas_coords = tile_map->get_cell_atlas_coords(tile_map_layer, coords); int tile_alternative_tile = tile_map->get_cell_alternative_tile(tile_map_layer, coords); - TileSetSource *source = nullptr; + RTileSetSource *source = nullptr; if (tile_set->has_source(tile_source_id)) { source = *tile_set->get_source(tile_source_id); } @@ -3981,7 +3981,7 @@ RTileMapEditor::RTileMapEditor() { tile_map_toolbar->add_child(advanced_menu_button); missing_tileset_label = memnew(Label); - missing_tileset_label->set_text(TTR("The edited TileMap node has no TileSet resource.")); + missing_tileset_label->set_text(TTR("The edited TileMap node has no RTileSet resource.")); missing_tileset_label->set_h_size_flags(SIZE_EXPAND_FILL); missing_tileset_label->set_v_size_flags(SIZE_EXPAND_FILL); missing_tileset_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); diff --git a/tile_editor/tile_map_editor.h b/tile_editor/tile_map_editor.h index 2e5ebb4..e88709a 100644 --- a/tile_editor/tile_map_editor.h +++ b/tile_editor/tile_map_editor.h @@ -36,7 +36,7 @@ #include "core/os/thread.h" #include "core/typedefs.h" #include "editor/editor_node.h" -#include "scene/2d/tile_map.h" +#include "../rtile_map.h" #include "scene/gui/box_container.h" #include "scene/gui/tab_bar.h" @@ -256,7 +256,7 @@ private: Map drag_modified; // Painting - Map _draw_terrains(const Map &p_to_paint, int p_terrain_set) const; + Map _draw_terrains(const Map &p_to_paint, int p_terrain_set) const; Map _draw_line(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase); Map _draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase); Set _get_cells_for_bucket_fill(Vector2i p_coords, bool p_contiguous); @@ -264,7 +264,7 @@ private: void _stop_dragging(); int selected_terrain_set = -1; - TileSet::TerrainsPattern selected_terrains_pattern; + RTileSet::TerrainsPattern selected_terrains_pattern; void _update_selection(); // Bottom panel. @@ -272,7 +272,7 @@ private: ItemList *terrains_tile_list; // Cache. - LocalVector>> per_terrain_terrains_patterns; + LocalVector>> per_terrain_terrains_patterns; // Update functions. void _update_terrains_cache(); @@ -344,7 +344,7 @@ private: protected: void _notification(int p_what); - void _draw_shape(Control *p_control, Rect2 p_region, TileSet::TileShape p_shape, TileSet::TileOffsetAxis p_offset_axis, Color p_color); + void _draw_shape(Control *p_control, Rect2 p_region, RTileSet::TileShape p_shape, RTileSet::TileOffsetAxis p_offset_axis, Color p_color); public: bool forward_canvas_gui_input(const Ref &p_event); diff --git a/tile_editor/tile_proxies_manager_dialog.cpp b/tile_editor/tile_proxies_manager_dialog.cpp index 35384bd..c1b73cf 100644 --- a/tile_editor/tile_proxies_manager_dialog.cpp +++ b/tile_editor/tile_proxies_manager_dialog.cpp @@ -110,18 +110,18 @@ void RTileProxiesManagerDialog::_update_lists() { } void RTileProxiesManagerDialog::_update_enabled_property_editors() { - if (from.source_id == TileSet::INVALID_SOURCE) { - from.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); - to.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); - from.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; - to.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + if (from.source_id == RTileSet::INVALID_SOURCE) { + from.set_atlas_coords(RTileSetSource::INVALID_ATLAS_COORDS); + to.set_atlas_coords(RTileSetSource::INVALID_ATLAS_COORDS); + from.alternative_tile = RTileSetSource::INVALID_TILE_ALTERNATIVE; + to.alternative_tile = RTileSetSource::INVALID_TILE_ALTERNATIVE; coords_from_property_editor->hide(); coords_to_property_editor->hide(); alternative_from_property_editor->hide(); alternative_to_property_editor->hide(); } else if (from.get_atlas_coords().x == -1 || from.get_atlas_coords().y == -1) { - from.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; - to.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + from.alternative_tile = RTileSetSource::INVALID_TILE_ALTERNATIVE; + to.alternative_tile = RTileSetSource::INVALID_TILE_ALTERNATIVE; coords_from_property_editor->show(); coords_to_property_editor->show(); alternative_from_property_editor->hide(); @@ -146,11 +146,11 @@ void RTileProxiesManagerDialog::_property_changed(const String &p_path, const Va } void RTileProxiesManagerDialog::_add_button_pressed() { - if (from.source_id != TileSet::INVALID_SOURCE && to.source_id != TileSet::INVALID_SOURCE) { + if (from.source_id != RTileSet::INVALID_SOURCE && to.source_id != RTileSet::INVALID_SOURCE) { Vector2i from_coords = from.get_atlas_coords(); Vector2i to_coords = to.get_atlas_coords(); if (from_coords.x >= 0 && from_coords.y >= 0 && to_coords.x >= 0 && to_coords.y >= 0) { - if (from.alternative_tile != TileSetSource::INVALID_TILE_ALTERNATIVE && to.alternative_tile != TileSetSource::INVALID_TILE_ALTERNATIVE) { + if (from.alternative_tile != RTileSetSource::INVALID_TILE_ALTERNATIVE && to.alternative_tile != RTileSetSource::INVALID_TILE_ALTERNATIVE) { undo_redo->create_action(TTR("Create Alternative-level Tile Proxy")); undo_redo->add_do_method(*tile_set, "set_alternative_level_tile_proxy", from.source_id, from.get_atlas_coords(), from.alternative_tile, to.source_id, to.get_atlas_coords(), to.alternative_tile); if (tile_set->has_alternative_level_tile_proxy(from.source_id, from.get_atlas_coords(), from.alternative_tile)) { @@ -304,7 +304,7 @@ void RTileProxiesManagerDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &RTileProxiesManagerDialog::_unhandled_key_input); } -void RTileProxiesManagerDialog::update_tile_set(Ref p_tile_set) { +void RTileProxiesManagerDialog::update_tile_set(Ref p_tile_set) { ERR_FAIL_COND(!p_tile_set.is_valid()); tile_set = p_tile_set; commited_actions_count = 0; diff --git a/tile_editor/tile_proxies_manager_dialog.h b/tile_editor/tile_proxies_manager_dialog.h index 5406bc1..591b4f4 100644 --- a/tile_editor/tile_proxies_manager_dialog.h +++ b/tile_editor/tile_proxies_manager_dialog.h @@ -34,7 +34,7 @@ #include "editor/editor_node.h" #include "editor/editor_properties.h" -#include "scene/2d/tile_map.h" +#include "../rtile_map.h" #include "scene/gui/dialogs.h" #include "scene/gui/item_list.h" @@ -43,7 +43,7 @@ class RTileProxiesManagerDialog : public ConfirmationDialog { private: int commited_actions_count = 0; - Ref tile_set; + Ref tile_set; UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); @@ -82,7 +82,7 @@ protected: static void _bind_methods(); public: - void update_tile_set(Ref p_tile_set); + void update_tile_set(Ref p_tile_set); RTileProxiesManagerDialog(); }; diff --git a/tile_editor/tile_set_atlas_source_editor.cpp b/tile_editor/tile_set_atlas_source_editor.cpp index 435b70f..411e804 100644 --- a/tile_editor/tile_set_atlas_source_editor.cpp +++ b/tile_editor/tile_set_atlas_source_editor.cpp @@ -45,15 +45,15 @@ #include "scene/gui/tab_container.h" #include "core/core_string_names.h" -#include "core/math/geometry_2d.h" +#include "../geometry_2d.h" #include "core/os/keyboard.h" -void RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::set_id(int p_id) { +void RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::set_id(int p_id) { ERR_FAIL_COND(p_id < 0); if (source_id == p_id) { return; } - ERR_FAIL_COND_MSG(tile_set->has_source(p_id), vformat("Cannot change TileSet Atlas Source ID. Another source exists with id %d.", p_id)); + ERR_FAIL_COND_MSG(tile_set->has_source(p_id), vformat("Cannot change RTileSet Atlas Source ID. Another source exists with id %d.", p_id)); int previous_source = source_id; source_id = p_id; // source_id must be updated before, because it's used by the source list update. @@ -61,11 +61,11 @@ void RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::set_id(int p_id) emit_signal(SNAME("changed"), "id"); } -int RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::get_id() { +int RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::get_id() { return source_id; } -bool RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_set(const StringName &p_name, const Variant &p_value) { +bool RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::_set(const StringName &p_name, const Variant &p_value) { String name = p_name; if (name == "name") { // Use the resource_name property to store the source's name. @@ -79,7 +79,7 @@ bool RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_set(const String return valid; } -bool RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get(const StringName &p_name, Variant &r_ret) const { +bool RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::_get(const StringName &p_name, Variant &r_ret) const { if (!tile_set_atlas_source) { return false; } @@ -93,7 +93,7 @@ bool RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get(const String return valid; } -void RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get_property_list(List *p_list) const { +void RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::_get_property_list(List *p_list) const { p_list->push_back(PropertyInfo(Variant::STRING, "name", PROPERTY_HINT_NONE, "")); p_list->push_back(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D")); p_list->push_back(PropertyInfo(Variant::VECTOR2I, "margins", PROPERTY_HINT_NONE, "")); @@ -102,17 +102,17 @@ void RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get_property_lis p_list->push_back(PropertyInfo(Variant::BOOL, "use_texture_padding", PROPERTY_HINT_NONE, "")); } -void RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_bind_methods() { +void RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::_bind_methods() { // -- Shape and layout -- - ClassDB::bind_method(D_METHOD("set_id", "id"), &RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::set_id); - ClassDB::bind_method(D_METHOD("get_id"), &RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::get_id); + ClassDB::bind_method(D_METHOD("set_id", "id"), &RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::set_id); + ClassDB::bind_method(D_METHOD("get_id"), &RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::get_id); ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); ADD_SIGNAL(MethodInfo("changed", PropertyInfo(Variant::STRING, "what"))); } -void RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::edit(Ref p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) { +void RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::edit(Ref p_tile_set, RTileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) { ERR_FAIL_COND(!p_tile_set.is_valid()); ERR_FAIL_COND(!p_tile_set_atlas_source); ERR_FAIL_COND(p_source_id < 0); @@ -174,7 +174,7 @@ bool RTileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_n Vector2i as_vector2i = Vector2i(p_value); bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(coords, as_vector2i, tile_set_atlas_source->get_tile_animation_columns(coords), tile_set_atlas_source->get_tile_animation_separation(coords), tile_set_atlas_source->get_tile_animation_frames_count(coords), coords); ERR_FAIL_COND_V_EDMSG(!has_room_for_tile, false, "Invalid size or not enough room in the atlas for the tile."); - tile_set_atlas_source->move_tile_in_atlas(coords, TileSetSource::INVALID_ATLAS_COORDS, as_vector2i); + tile_set_atlas_source->move_tile_in_atlas(coords, RTileSetSource::INVALID_ATLAS_COORDS, as_vector2i); emit_signal(SNAME("changed"), "size_in_atlas"); return true; } @@ -472,11 +472,11 @@ void RTileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List p_tiles) { +void RTileSetAtlasSourceEditor::AtlasTileProxyObject::edit(RTileSetAtlasSource *p_tile_set_atlas_source, Set p_tiles) { ERR_FAIL_COND(!p_tile_set_atlas_source); ERR_FAIL_COND(p_tiles.is_empty()); for (Set::Element *E = p_tiles.front(); E; E = E->next()) { - ERR_FAIL_COND(E->get().tile == TileSetSource::INVALID_ATLAS_COORDS); + ERR_FAIL_COND(E->get().tile == RTileSetSource::INVALID_ATLAS_COORDS); ERR_FAIL_COND(E->get().alternative < 0); } @@ -549,12 +549,12 @@ void RTileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() { // Fix hovered. if (!tile_set_atlas_source->has_tile(hovered_base_tile_coords)) { - hovered_base_tile_coords = TileSetSource::INVALID_ATLAS_COORDS; + hovered_base_tile_coords = RTileSetSource::INVALID_ATLAS_COORDS; } Vector2i coords = Vector2i(hovered_alternative_tile_coords.x, hovered_alternative_tile_coords.y); int alternative = hovered_alternative_tile_coords.z; if (!tile_set_atlas_source->has_tile(coords) || !tile_set_atlas_source->has_alternative_tile(coords, alternative)) { - hovered_alternative_tile_coords = Vector3i(TileSetSource::INVALID_ATLAS_COORDS.x, TileSetSource::INVALID_ATLAS_COORDS.y, TileSetSource::INVALID_TILE_ALTERNATIVE); + hovered_alternative_tile_coords = Vector3i(RTileSetSource::INVALID_ATLAS_COORDS.x, RTileSetSource::INVALID_ATLAS_COORDS.y, RTileSetSource::INVALID_TILE_ALTERNATIVE); } } @@ -912,7 +912,7 @@ void RTileSetAtlasSourceEditor::_update_atlas_view() { button->add_theme_style_override("hover", memnew(StyleBoxEmpty)); button->add_theme_style_override("focus", memnew(StyleBoxEmpty)); button->add_theme_style_override("pressed", memnew(StyleBoxEmpty)); - button->connect("pressed", callable_mp(tile_set_atlas_source, &TileSetAtlasSource::create_alternative_tile), varray(tile_id, TileSetSource::INVALID_TILE_ALTERNATIVE)); + button->connect("pressed", callable_mp(tile_set_atlas_source, &RTileSetAtlasSource::create_alternative_tile), varray(tile_id, RTileSetSource::INVALID_TILE_ALTERNATIVE)); button->set_rect(Rect2(Vector2(pos.x, pos.y + (y_increment - texture_region_base_size.y) / 2.0), Vector2(texture_region_base_size_min, texture_region_base_size_min))); button->set_expand_icon(true); @@ -959,7 +959,7 @@ void RTileSetAtlasSourceEditor::_update_toolbar() { } void RTileSetAtlasSourceEditor::_tile_atlas_control_mouse_exited() { - hovered_base_tile_coords = TileSetSource::INVALID_ATLAS_COORDS; + hovered_base_tile_coords = RTileSetSource::INVALID_ATLAS_COORDS; tile_atlas_control->update(); tile_atlas_control_unscaled->update(); tile_atlas_view->update(); @@ -1002,7 +1002,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Refget(); - if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selected.alternative == 0) { + if (selected.tile != RTileSetSource::INVALID_ATLAS_COORDS && selected.alternative == 0) { Vector2 mouse_local_pos = tile_atlas_control->get_local_mouse_position(); Vector2i size_in_atlas = tile_set_atlas_source->get_tile_size_in_atlas(selected.tile); Rect2 region = tile_set_atlas_source->get_tile_texture_region(selected.tile); @@ -1048,7 +1048,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref line = Geometry2D::bresenham_line(last_base_tiles_coords, new_base_tiles_coords); for (int i = 0; i < line.size(); i++) { - if (tile_set_atlas_source->get_tile_at_coords(line[i]) == TileSetSource::INVALID_ATLAS_COORDS) { + if (tile_set_atlas_source->get_tile_at_coords(line[i]) == RTileSetSource::INVALID_ATLAS_COORDS) { tile_set_atlas_source->create_tile(line[i]); drag_modified_tiles.insert(line[i]); } @@ -1064,7 +1064,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref line = Geometry2D::bresenham_line(last_base_tiles_coords, new_base_tiles_coords); for (int i = 0; i < line.size(); i++) { Vector2i base_tile_coords = tile_set_atlas_source->get_tile_at_coords(line[i]); - if (base_tile_coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (base_tile_coords != RTileSetSource::INVALID_ATLAS_COORDS) { drag_modified_tiles.insert(base_tile_coords); } } @@ -1165,10 +1165,10 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Refget_atlas_tile_coords_at_pos(drag_start_mouse_pos); - if (coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS) { coords = tile_set_atlas_source->get_tile_at_coords(coords); } - if (coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS) { drag_modified_tiles.insert(coords); } } @@ -1177,7 +1177,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Refis_shift_pressed()) { // Create a big tile. Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(mouse_local_pos); - if (coords != TileSetSource::INVALID_ATLAS_COORDS && tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS && tile_set_atlas_source->get_tile_at_coords(coords) == RTileSetSource::INVALID_ATLAS_COORDS) { // Setup the dragging info, only if we start on an empty tile. drag_type = DRAG_TYPE_CREATE_BIG_TILE; drag_start_mouse_pos = mouse_local_pos; @@ -1202,7 +1202,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Refget_atlas_tile_coords_at_pos(drag_start_mouse_pos); - if (coords != TileSetSource::INVALID_ATLAS_COORDS && tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS && tile_set_atlas_source->get_tile_at_coords(coords) == RTileSetSource::INVALID_ATLAS_COORDS) { tile_set_atlas_source->create_tile(coords); drag_modified_tiles.insert(coords); } @@ -1213,7 +1213,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Refget(); - if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selected.alternative == 0) { + if (selected.tile != RTileSetSource::INVALID_ATLAS_COORDS && selected.alternative == 0) { Vector2i size_in_atlas = tile_set_atlas_source->get_tile_size_in_atlas(selected.tile); Rect2 region = tile_set_atlas_source->get_tile_texture_region(selected.tile); Size2 zoomed_size = resize_handle->get_size() / tile_atlas_view->get_zoom(); @@ -1252,17 +1252,17 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Refget_atlas_tile_coords_at_pos(mouse_local_pos); - if (coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS) { coords = tile_set_atlas_source->get_tile_at_coords(coords); - if (coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS) { selected = { coords, 0 }; } } bool shift = mb->is_shift_pressed(); - if (!shift && selection.size() == 1 && selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selection.has(selected)) { + if (!shift && selection.size() == 1 && selected.tile != RTileSetSource::INVALID_ATLAS_COORDS && selection.has(selected)) { // Start move dragging. drag_type = DRAG_TYPE_MOVE_TILE; drag_start_mouse_pos = mouse_local_pos; @@ -1354,7 +1354,7 @@ void RTileSetAtlasSourceEditor::_end_dragging() { for (int x = area.get_position().x; x < area.get_end().x; x++) { for (int y = area.get_position().y; y < area.get_end().y; y++) { Vector2i coords = Vector2i(x, y); - if (tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) { + if (tile_set_atlas_source->get_tile_at_coords(coords) == RTileSetSource::INVALID_ATLAS_COORDS) { undo_redo->add_do_method(tile_set_atlas_source, "create_tile", coords); undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", coords); } @@ -1375,7 +1375,7 @@ void RTileSetAtlasSourceEditor::_end_dragging() { for (int x = area.get_position().x; x < area.get_end().x; x++) { for (int y = area.get_position().y; y < area.get_end().y; y++) { Vector2i coords = tile_set_atlas_source->get_tile_at_coords(Vector2i(x, y)); - if (coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS) { to_delete.insert(coords); } } @@ -1416,8 +1416,8 @@ void RTileSetAtlasSourceEditor::_end_dragging() { case DRAG_TYPE_RECT_SELECT: { Vector2i start_base_tiles_coords = tile_atlas_view->get_atlas_tile_coords_at_pos(drag_start_mouse_pos); Vector2i new_base_tiles_coords = tile_atlas_view->get_atlas_tile_coords_at_pos(tile_atlas_control->get_local_mouse_position()); - ERR_FAIL_COND(start_base_tiles_coords == TileSetSource::INVALID_ATLAS_COORDS); - ERR_FAIL_COND(new_base_tiles_coords == TileSetSource::INVALID_ATLAS_COORDS); + ERR_FAIL_COND(start_base_tiles_coords == RTileSetSource::INVALID_ATLAS_COORDS); + ERR_FAIL_COND(new_base_tiles_coords == RTileSetSource::INVALID_ATLAS_COORDS); Rect2i region = Rect2i(start_base_tiles_coords, new_base_tiles_coords - start_base_tiles_coords).abs(); region.size += Vector2i(1, 1); @@ -1429,7 +1429,7 @@ void RTileSetAtlasSourceEditor::_end_dragging() { bool add_to_selection = true; if (Input::get_singleton()->is_key_pressed(Key::SHIFT)) { Vector2i coords = tile_set_atlas_source->get_tile_at_coords(start_base_tiles_coords); - if (coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS) { if (selection.has({ coords, 0 })) { add_to_selection = false; } @@ -1443,7 +1443,7 @@ void RTileSetAtlasSourceEditor::_end_dragging() { for (int y = region.position.y; y < region.get_end().y; y++) { Vector2i coords = Vector2i(x, y); coords = tile_set_atlas_source->get_tile_at_coords(coords); - if (coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS) { if (add_to_selection && !selection.has({ coords, 0 })) { selection.insert({ coords, 0 }); } else if (!add_to_selection && selection.has({ coords, 0 })) { @@ -1461,13 +1461,13 @@ void RTileSetAtlasSourceEditor::_end_dragging() { case DRAG_TYPE_MAY_POPUP_MENU: { Vector2 mouse_local_pos = tile_atlas_control->get_local_mouse_position(); TileSelection selected = { tile_atlas_view->get_atlas_tile_coords_at_pos(mouse_local_pos), 0 }; - if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS) { + if (selected.tile != RTileSetSource::INVALID_ATLAS_COORDS) { selected.tile = tile_set_atlas_source->get_tile_at_coords(selected.tile); } // Set the selection if needed. if (selection.size() <= 1) { - if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS) { + if (selected.tile != RTileSetSource::INVALID_ATLAS_COORDS) { undo_redo->create_action(TTR("Select tiles")); undo_redo->add_undo_method(this, "_set_selection_from_array", _get_selection_as_array()); selection.clear(); @@ -1481,15 +1481,15 @@ void RTileSetAtlasSourceEditor::_end_dragging() { } // Pops up the correct menu, depending on whether we have a tile or not. - if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selection.has(selected)) { + if (selected.tile != RTileSetSource::INVALID_ATLAS_COORDS && selection.has(selected)) { // We have a tile. menu_option_coords = selected.tile; menu_option_alternative = 0; base_tile_popup_menu->popup(Rect2i(get_global_mouse_position(), Size2i())); - } else if (hovered_base_tile_coords != TileSetSource::INVALID_ATLAS_COORDS) { + } else if (hovered_base_tile_coords != RTileSetSource::INVALID_ATLAS_COORDS) { // We don't have a tile, but can create one. menu_option_coords = hovered_base_tile_coords; - menu_option_alternative = TileSetSource::INVALID_TILE_ALTERNATIVE; + menu_option_alternative = RTileSetSource::INVALID_TILE_ALTERNATIVE; empty_base_tile_popup_menu->popup(Rect2i(get_global_mouse_position(), Size2i())); } } break; @@ -1522,7 +1522,7 @@ void RTileSetAtlasSourceEditor::_end_dragging() { tile_atlas_control->set_default_cursor_shape(CURSOR_ARROW); } -Map> RTileSetAtlasSourceEditor::_group_properties_per_tiles(const List &r_list, const TileSetAtlasSource *p_atlas) { +Map> RTileSetAtlasSourceEditor::_group_properties_per_tiles(const List &r_list, const RTileSetAtlasSource *p_atlas) { // Group properties per tile. Map> per_tile; for (const List::Element *E_property = r_list.front(); E_property; E_property = E_property->next()) { @@ -1742,7 +1742,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_draw() { for (int x = area.get_position().x; x < area.get_end().x; x++) { for (int y = area.get_position().y; y < area.get_end().y; y++) { Vector2i coords = tile_set_atlas_source->get_tile_at_coords(Vector2i(x, y)); - if (coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS) { to_paint.insert(coords); } } @@ -1765,7 +1765,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_draw() { for (int x = area.get_position().x; x < area.get_end().x; x++) { for (int y = area.get_position().y; y < area.get_end().y; y++) { Vector2i coords = Vector2i(x, y); - if (tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) { + if (tile_set_atlas_source->get_tile_at_coords(coords) == RTileSetSource::INVALID_ATLAS_COORDS) { Vector2i origin = margins + (coords * (tile_size + separation)); tile_atlas_control->draw_rect(Rect2i(origin, tile_size), Color(1.0, 1.0, 1.0), false); } @@ -1789,7 +1789,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_draw() { Vector2i grid_size = tile_set_atlas_source->get_atlas_grid_size(); if (hovered_base_tile_coords.x >= 0 && hovered_base_tile_coords.y >= 0 && hovered_base_tile_coords.x < grid_size.x && hovered_base_tile_coords.y < grid_size.y) { Vector2i hovered_tile = tile_set_atlas_source->get_tile_at_coords(hovered_base_tile_coords); - if (hovered_tile != TileSetSource::INVALID_ATLAS_COORDS) { + if (hovered_tile != RTileSetSource::INVALID_ATLAS_COORDS) { // Draw existing hovered tile. for (int frame = 0; frame < tile_set_atlas_source->get_tile_animation_frames_count(hovered_tile); frame++) { Color color = Color(1.0, 1.0, 1.0); @@ -1900,7 +1900,7 @@ void RTileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const Refupdate(); tile_atlas_control_unscaled->update(); alternative_tiles_control->update(); @@ -1953,7 +1953,7 @@ void RTileSetAtlasSourceEditor::_tile_alternatives_control_draw() { if (tools_button_group->get_pressed_button() == tool_select_button) { // Draw hovered tile. Vector2i coords = Vector2(hovered_alternative_tile_coords.x, hovered_alternative_tile_coords.y); - if (coords != TileSetSource::INVALID_ATLAS_COORDS) { + if (coords != RTileSetSource::INVALID_ATLAS_COORDS) { Rect2i rect = tile_atlas_view->get_alternative_tile_rect(coords, hovered_alternative_tile_coords.z); if (rect != Rect2i()) { alternative_tiles_control->draw_rect(rect, Color(1.0, 1.0, 1.0), false); @@ -2070,18 +2070,18 @@ void RTileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_red } } else if (p_property == "terrain_set") { int current_terrain_set = tile_data_proxy->get("terrain_set"); - for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) { - TileSet::CellNeighbor bit = TileSet::CellNeighbor(i); + for (int i = 0; i < RTileSet::CELL_NEIGHBOR_MAX; i++) { + RTileSet::CellNeighbor bit = RTileSet::CellNeighbor(i); if (tile_set->is_valid_peering_bit_terrain(current_terrain_set, bit)) { - ADD_UNDO(tile_data_proxy, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i])); + ADD_UNDO(tile_data_proxy, "terrains_peering_bit/" + String(RTileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i])); } } } } - TileSetAtlasSourceProxyObject *atlas_source_proxy = Object::cast_to(p_edited); + RTileSetAtlasSourceProxyObject *atlas_source_proxy = Object::cast_to(p_edited); if (atlas_source_proxy) { - TileSetAtlasSource *atlas_source = atlas_source_proxy->get_edited(); + RTileSetAtlasSource *atlas_source = atlas_source_proxy->get_edited(); ERR_FAIL_COND(!atlas_source); PackedVector2Array arr; @@ -2116,7 +2116,7 @@ void RTileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_red #undef ADD_UNDO } -void RTileSetAtlasSourceEditor::edit(Ref p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) { +void RTileSetAtlasSourceEditor::edit(Ref p_tile_set, RTileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) { ERR_FAIL_COND(!p_tile_set.is_valid()); ERR_FAIL_COND(!p_tile_set_atlas_source); ERR_FAIL_COND(p_source_id < 0); @@ -2177,7 +2177,7 @@ void RTileSetAtlasSourceEditor::_auto_create_tiles() { for (int x = 0; x < grid_size.x; x++) { // Check if we have a tile at the coord Vector2i coords = Vector2i(x, y); - if (tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) { + if (tile_set_atlas_source->get_tile_at_coords(coords) == RTileSetSource::INVALID_ATLAS_COORDS) { // Check if the texture is empty at the given coords. Rect2i region = Rect2i(margins + (coords * (texture_region_size + separation)), texture_region_size); bool is_opaque = false; @@ -2380,7 +2380,7 @@ RTileSetAtlasSourceEditor::RTileSetAtlasSourceEditor() { atlas_source_inspector_label->set_text(TTR("Atlas Properties:")); middle_vbox_container->add_child(atlas_source_inspector_label); - atlas_source_proxy_object = memnew(TileSetAtlasSourceProxyObject()); + atlas_source_proxy_object = memnew(RTileSetAtlasSourceProxyObject()); atlas_source_proxy_object->connect("changed", callable_mp(this, &RTileSetAtlasSourceEditor::_atlas_source_proxy_object_changed)); atlas_source_inspector = memnew(EditorInspector); @@ -2603,8 +2603,8 @@ void REditorPropertyTilePolygon::update_property() { ERR_FAIL_COND(!atlas_tile_proxy_object); ERR_FAIL_COND(atlas_tile_proxy_object->get_edited_tiles().is_empty()); - TileSetAtlasSource *tile_set_atlas_source = atlas_tile_proxy_object->get_edited_tile_set_atlas_source(); - generic_tile_polygon_editor->set_tile_set(Ref(tile_set_atlas_source->get_tile_set())); + RTileSetAtlasSource *tile_set_atlas_source = atlas_tile_proxy_object->get_edited_tile_set_atlas_source(); + generic_tile_polygon_editor->set_tile_set(Ref(tile_set_atlas_source->get_tile_set())); // Set the background Vector2i coords = atlas_tile_proxy_object->get_edited_tiles().front()->get().tile; diff --git a/tile_editor/tile_set_atlas_source_editor.h b/tile_editor/tile_set_atlas_source_editor.h index 6f540fb..9dc029c 100644 --- a/tile_editor/tile_set_atlas_source_editor.h +++ b/tile_editor/tile_set_atlas_source_editor.h @@ -36,9 +36,9 @@ #include "editor/editor_node.h" #include "scene/gui/split_container.h" -#include "scene/resources/tile_set.h" +#include "../rtile_set.h" -class TileSet; +class RTileSet; class RTileSetAtlasSourceEditor : public HBoxContainer { GDCLASS(RTileSetAtlasSourceEditor, HBoxContainer); @@ -46,8 +46,8 @@ class RTileSetAtlasSourceEditor : public HBoxContainer { public: // A class to store which tiles are selected. struct TileSelection { - Vector2i tile = TileSetSource::INVALID_ATLAS_COORDS; - int alternative = TileSetSource::INVALID_TILE_ALTERNATIVE; + Vector2i tile = RTileSetSource::INVALID_ATLAS_COORDS; + int alternative = RTileSetSource::INVALID_TILE_ALTERNATIVE; bool operator<(const TileSelection &p_other) const { if (tile == p_other.tile) { @@ -59,13 +59,13 @@ public: }; // -- Proxy object for an atlas source, needed by the inspector -- - class TileSetAtlasSourceProxyObject : public Object { - GDCLASS(TileSetAtlasSourceProxyObject, Object); + class RTileSetAtlasSourceProxyObject : public Object { + GDCLASS(RTileSetAtlasSourceProxyObject, Object); private: - Ref tile_set; - TileSetAtlasSource *tile_set_atlas_source = nullptr; - int source_id = TileSet::INVALID_SOURCE; + Ref tile_set; + RTileSetAtlasSource *tile_set_atlas_source = nullptr; + int source_id = RTileSet::INVALID_SOURCE; protected: bool _set(const StringName &p_name, const Variant &p_value); @@ -77,8 +77,8 @@ public: void set_id(int p_id); int get_id(); - void edit(Ref p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id); - TileSetAtlasSource *get_edited() { return tile_set_atlas_source; }; + void edit(Ref p_tile_set, RTileSetAtlasSource *p_tile_set_atlas_source, int p_source_id); + RTileSetAtlasSource *get_edited() { return tile_set_atlas_source; }; }; // -- Proxy object for a tile, needed by the inspector -- @@ -88,7 +88,7 @@ public: private: RTileSetAtlasSourceEditor *tiles_set_atlas_source_editor; - TileSetAtlasSource *tile_set_atlas_source = nullptr; + RTileSetAtlasSource *tile_set_atlas_source = nullptr; Set tiles = Set(); protected: @@ -99,11 +99,11 @@ public: static void _bind_methods(); public: - TileSetAtlasSource *get_edited_tile_set_atlas_source() const { return tile_set_atlas_source; }; + RTileSetAtlasSource *get_edited_tile_set_atlas_source() const { return tile_set_atlas_source; }; Set get_edited_tiles() const { return tiles; }; // Update the proxyed object. - void edit(TileSetAtlasSource *p_tile_set_atlas_source, Set p_tiles = Set()); + void edit(RTileSetAtlasSource *p_tile_set_atlas_source, Set p_tiles = Set()); AtlasTileProxyObject(RTileSetAtlasSourceEditor *p_tiles_set_atlas_source_editor) { tiles_set_atlas_source_editor = p_tiles_set_atlas_source_editor; @@ -111,9 +111,9 @@ public: }; private: - Ref tile_set; - TileSetAtlasSource *tile_set_atlas_source = nullptr; - int tile_set_atlas_source_id = TileSet::INVALID_SOURCE; + Ref tile_set; + RTileSetAtlasSource *tile_set_atlas_source = nullptr; + int tile_set_atlas_source_id = RTileSet::INVALID_SOURCE; UndoRedo *undo_redo = EditorNode::get_undo_redo(); @@ -143,7 +143,7 @@ private: String selected_property; void _inspector_property_selected(String p_property); - TileSetAtlasSourceProxyObject *atlas_source_proxy_object; + RTileSetAtlasSourceProxyObject *atlas_source_proxy_object; Label *atlas_source_inspector_label; EditorInspector *atlas_source_inspector; @@ -186,7 +186,7 @@ private: Set drag_modified_tiles; void _end_dragging(); - Map> _group_properties_per_tiles(const List &r_list, const TileSetAtlasSource *p_atlas); + Map> _group_properties_per_tiles(const List &r_list, const RTileSetAtlasSource *p_atlas); // Popup functions. enum MenuOptions { @@ -198,7 +198,7 @@ private: ADVANCED_AUTO_REMOVE_TILES, }; Vector2i menu_option_coords; - int menu_option_alternative = TileSetSource::INVALID_TILE_ALTERNATIVE; + int menu_option_alternative = RTileSetSource::INVALID_TILE_ALTERNATIVE; void _menu_option(int p_option); // Tool buttons. @@ -222,7 +222,7 @@ private: Array _get_selection_as_array(); // A control on the tile atlas to draw and handle input events. - Vector2i hovered_base_tile_coords = TileSetSource::INVALID_ATLAS_COORDS; + Vector2i hovered_base_tile_coords = RTileSetSource::INVALID_ATLAS_COORDS; PopupMenu *base_tile_popup_menu; PopupMenu *empty_base_tile_popup_menu; @@ -237,7 +237,7 @@ private: void _tile_atlas_view_transform_changed(); // A control over the alternative tiles. - Vector3i hovered_alternative_tile_coords = Vector3i(TileSetSource::INVALID_ATLAS_COORDS.x, TileSetSource::INVALID_ATLAS_COORDS.y, TileSetSource::INVALID_TILE_ALTERNATIVE); + Vector3i hovered_alternative_tile_coords = Vector3i(RTileSetSource::INVALID_ATLAS_COORDS.x, RTileSetSource::INVALID_ATLAS_COORDS.y, RTileSetSource::INVALID_TILE_ALTERNATIVE); PopupMenu *alternative_tile_popup_menu; Control *alternative_tiles_control; @@ -278,7 +278,7 @@ protected: static void _bind_methods(); public: - void edit(Ref p_tile_set, TileSetAtlasSource *p_tile_set_source, int p_source_id); + void edit(Ref p_tile_set, RTileSetAtlasSource *p_tile_set_source, int p_source_id); void init_source(); RTileSetAtlasSourceEditor(); diff --git a/tile_editor/tile_set_editor.h b/tile_editor/tile_set_editor.h index df37705..d0d908b 100644 --- a/tile_editor/tile_set_editor.h +++ b/tile_editor/tile_set_editor.h @@ -33,7 +33,7 @@ #include "atlas_merging_dialog.h" #include "scene/gui/box_container.h" -#include "scene/resources/tile_set.h" +#include "../rtile_set.h" #include "tile_proxies_manager_dialog.h" #include "tile_set_atlas_source_editor.h" #include "tile_set_scenes_collection_source_editor.h" @@ -44,7 +44,7 @@ class RTileSetEditor : public VBoxContainer { static RTileSetEditor *singleton; private: - Ref tile_set; + Ref tile_set; bool tile_set_changed_needs_update = false; HSplitContainer *split_container; diff --git a/tile_editor/tile_set_scenes_collection_source_editor.cpp b/tile_editor/tile_set_scenes_collection_source_editor.cpp index e644bd5..4ebd9eb 100644 --- a/tile_editor/tile_set_scenes_collection_source_editor.cpp +++ b/tile_editor/tile_set_scenes_collection_source_editor.cpp @@ -38,12 +38,12 @@ #include "core/core_string_names.h" -void RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::set_id(int p_id) { +void RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionProxyObject::set_id(int p_id) { ERR_FAIL_COND(p_id < 0); if (source_id == p_id) { return; } - ERR_FAIL_COND_MSG(tile_set->has_source(p_id), vformat("Cannot change TileSet Scenes Collection source ID. Another TileSet source exists with id %d.", p_id)); + ERR_FAIL_COND_MSG(tile_set->has_source(p_id), vformat("Cannot change RTileSet Scenes Collection source ID. Another RTileSet source exists with id %d.", p_id)); int previous_source = source_id; source_id = p_id; // source_id must be updated before, because it's used by the source list update. @@ -51,11 +51,11 @@ void RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::s emit_signal(SNAME("changed"), "id"); } -int RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::get_id() { +int RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionProxyObject::get_id() { return source_id; } -bool RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_set(const StringName &p_name, const Variant &p_value) { +bool RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionProxyObject::_set(const StringName &p_name, const Variant &p_value) { String name = p_name; if (name == "name") { // Use the resource_name property to store the source's name. @@ -69,7 +69,7 @@ bool RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_ return valid; } -bool RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_get(const StringName &p_name, Variant &r_ret) const { +bool RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionProxyObject::_get(const StringName &p_name, Variant &r_ret) const { if (!tile_set_scenes_collection_source) { return false; } @@ -83,21 +83,21 @@ bool RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_ return valid; } -void RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_get_property_list(List *p_list) const { +void RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionProxyObject::_get_property_list(List *p_list) const { p_list->push_back(PropertyInfo(Variant::STRING, "name", PROPERTY_HINT_NONE, "")); } -void RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_bind_methods() { +void RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionProxyObject::_bind_methods() { // -- Shape and layout -- - ClassDB::bind_method(D_METHOD("set_id", "id"), &RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::set_id); - ClassDB::bind_method(D_METHOD("get_id"), &RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::get_id); + ClassDB::bind_method(D_METHOD("set_id", "id"), &RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionProxyObject::set_id); + ClassDB::bind_method(D_METHOD("get_id"), &RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionProxyObject::get_id); ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); ADD_SIGNAL(MethodInfo("changed", PropertyInfo(Variant::STRING, "what"))); } -void RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::edit(Ref p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) { +void RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionProxyObject::edit(Ref p_tile_set, RTileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) { ERR_FAIL_COND(!p_tile_set.is_valid()); ERR_FAIL_COND(!p_tile_set_scenes_collection_source); ERR_FAIL_COND(p_source_id < 0); @@ -188,7 +188,7 @@ void RTileSetScenesCollectionSourceEditor::SceneTileProxyObject::_get_property_l p_list->push_back(PropertyInfo(Variant::BOOL, "display_placeholder", PROPERTY_HINT_NONE, "")); } -void RTileSetScenesCollectionSourceEditor::SceneTileProxyObject::edit(TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_scene_id) { +void RTileSetScenesCollectionSourceEditor::SceneTileProxyObject::edit(RTileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_scene_id) { ERR_FAIL_COND(!p_tile_set_scenes_collection_source); ERR_FAIL_COND(!p_tile_set_scenes_collection_source->has_scene_tile_id(p_scene_id)); @@ -353,7 +353,7 @@ void RTileSetScenesCollectionSourceEditor::_notification(int p_what) { } } -void RTileSetScenesCollectionSourceEditor::edit(Ref p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) { +void RTileSetScenesCollectionSourceEditor::edit(Ref p_tile_set, RTileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) { ERR_FAIL_COND(!p_tile_set.is_valid()); ERR_FAIL_COND(!p_tile_set_scenes_collection_source); ERR_FAIL_COND(p_source_id < 0); @@ -472,7 +472,7 @@ RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionSourceEditor() { scenes_collection_source_inspector_label->set_text(TTR("Scenes collection properties:")); middle_vbox_container->add_child(scenes_collection_source_inspector_label); - scenes_collection_source_proxy_object = memnew(TileSetScenesCollectionProxyObject()); + scenes_collection_source_proxy_object = memnew(RTileSetScenesCollectionProxyObject()); scenes_collection_source_proxy_object->connect("changed", callable_mp(this, &RTileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed)); scenes_collection_source_inspector = memnew(EditorInspector); diff --git a/tile_editor/tile_set_scenes_collection_source_editor.h b/tile_editor/tile_set_scenes_collection_source_editor.h index 14a7a17..5b75019 100644 --- a/tile_editor/tile_set_scenes_collection_source_editor.h +++ b/tile_editor/tile_set_scenes_collection_source_editor.h @@ -33,7 +33,7 @@ #include "editor/editor_node.h" #include "scene/gui/box_container.h" -#include "scene/resources/tile_set.h" +#include "../rtile_set.h" class RTileSetScenesCollectionSourceEditor : public HBoxContainer { GDCLASS(RTileSetScenesCollectionSourceEditor, HBoxContainer); @@ -44,7 +44,7 @@ private: GDCLASS(TileSetScenesCollectionProxyObject, Object); private: - Ref tile_set; + Ref tile_set; TileSetScenesCollectionSource *tile_set_scenes_collection_source = nullptr; int source_id = -1; @@ -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, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id); }; // -- Proxy object for a tile, needed by the inspector -- @@ -89,7 +89,7 @@ private: }; private: - Ref tile_set; + Ref tile_set; TileSetScenesCollectionSource *tile_set_scenes_collection_source = nullptr; int tile_set_source_id = -1; @@ -133,7 +133,7 @@ protected: static void _bind_methods(); public: - void edit(Ref p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id); + void edit(Ref p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id); RTileSetScenesCollectionSourceEditor(); ~RTileSetScenesCollectionSourceEditor(); }; diff --git a/tile_editor/tiles_editor_plugin.cpp b/tile_editor/tiles_editor_plugin.cpp index bbcd5a7..167000d 100644 --- a/tile_editor/tiles_editor_plugin.cpp +++ b/tile_editor/tiles_editor_plugin.cpp @@ -36,12 +36,12 @@ #include "editor/editor_scale.h" #include "editor/plugins/canvas_item_editor_plugin.h" -#include "scene/2d/tile_map.h" +#include "../rtile_map.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" #include "scene/gui/control.h" #include "scene/gui/separator.h" -#include "scene/resources/tile_set.h" +#include "../rtile_set.h" #include "tile_set_editor.h" @@ -98,7 +98,7 @@ void RTilesEditorPlugin::_thread() { encompassing_rect.expand_to(world_pos); // Texture. - Ref atlas_source = tile_set->get_source(tile_map->get_cell_source_id(0, cell)); + Ref atlas_source = tile_set->get_source(tile_map->get_cell_source_id(0, cell)); if (atlas_source.is_valid()) { Vector2i coords = tile_map->get_cell_atlas_coords(0, cell); int alternative = tile_map->get_cell_alternative_tile(0, cell); @@ -193,7 +193,7 @@ void RTilesEditorPlugin::make_visible(bool p_visible) { } } -void RTilesEditorPlugin::queue_pattern_preview(Ref p_tile_set, Ref p_pattern, Callable p_callback) { +void RTilesEditorPlugin::queue_pattern_preview(Ref p_tile_set, Ref p_pattern, Callable p_callback) { ERR_FAIL_COND(!p_tile_set.is_valid()); ERR_FAIL_COND(!p_pattern.is_valid()); { @@ -243,15 +243,15 @@ void RTilesEditorPlugin::edit(Object *p_object) { } // Update edited objects. - tile_set = Ref(); + tile_set = Ref(); 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_set = tile_map->get_tileset(); editor_node->make_bottom_panel_item_visible(tilemap_editor); - } else if (p_object->is_class("TileSet")) { - tile_set = Ref(p_object); + } else if (p_object->is_class("RTileSet")) { + tile_set = Ref(p_object); if (tile_map) { if (tile_map->get_tileset() != tile_set || !tile_map->is_inside_tree()) { tile_map = nullptr; @@ -272,7 +272,7 @@ void RTilesEditorPlugin::edit(Object *p_object) { } bool RTilesEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("TileMap") || p_object->is_class("TileSet"); + return p_object->is_class("TileMap") || p_object->is_class("RTileSet"); } RTilesEditorPlugin::RTilesEditorPlugin(EditorNode *p_node) { @@ -301,7 +301,7 @@ RTilesEditorPlugin::RTilesEditorPlugin(EditorNode *p_node) { pattern_preview_thread.start(_thread_func, this); // Bottom buttons. - tileset_editor_button = p_node->add_bottom_panel_item(TTR("TileSet"), tileset_editor); + tileset_editor_button = p_node->add_bottom_panel_item(TTR("RTileSet"), tileset_editor); tileset_editor_button->hide(); tilemap_editor_button = p_node->add_bottom_panel_item(TTR("TileMap"), tilemap_editor); tilemap_editor_button->hide(); diff --git a/tile_editor/tiles_editor_plugin.h b/tile_editor/tiles_editor_plugin.h index 148e3da..d8444e9 100644 --- a/tile_editor/tiles_editor_plugin.h +++ b/tile_editor/tiles_editor_plugin.h @@ -48,13 +48,13 @@ private: bool tile_map_changed_needs_update = false; ObjectID tile_map_id; - Ref tile_set; + Ref tile_set; Button *tilemap_editor_button; RTileMapEditor *tilemap_editor; Button *tileset_editor_button; - RTileSetEditor *tileset_editor; + RRTileSetEditor *tileset_editor; void _update_editors(); @@ -67,7 +67,7 @@ private: // Patterns preview generation. struct QueueItem { - Ref tile_set; + Ref tile_set; Ref pattern; Callable callback; }; @@ -93,7 +93,7 @@ public: virtual void forward_canvas_draw_over_viewport(Control *p_overlay) override { tilemap_editor->forward_canvas_draw_over_viewport(p_overlay); } // Pattern preview API. - void queue_pattern_preview(Ref p_tile_set, Ref p_pattern, Callable p_callback); + void queue_pattern_preview(Ref p_tile_set, Ref p_pattern, Callable p_callback); // To synchronize the atlas sources lists. void set_sources_lists_current(int p_current);