From 469a2edbf8647d5abf3cafc3c7221a8f358f3981 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 11 Dec 2021 20:15:57 +0100 Subject: [PATCH] More work. --- tile_editor/atlas_merging_dialog.cpp | 6 +- tile_editor/tile_data_editors.cpp | 246 +++++++++--------- tile_editor/tile_data_editors.h | 110 ++++---- tile_editor/tile_map_editor.cpp | 14 +- tile_editor/tile_map_editor.h | 10 +- tile_editor/tile_proxies_manager_dialog.h | 4 +- tile_editor/tile_set_atlas_source_editor.cpp | 30 +-- tile_editor/tile_set_atlas_source_editor.h | 4 +- tile_editor/tile_set_editor.cpp | 10 +- tile_editor/tile_set_editor.h | 4 +- ...le_set_scenes_collection_source_editor.cpp | 4 +- ...tile_set_scenes_collection_source_editor.h | 2 +- 12 files changed, 222 insertions(+), 222 deletions(-) diff --git a/tile_editor/atlas_merging_dialog.cpp b/tile_editor/atlas_merging_dialog.cpp index feeffcc..ce684c9 100644 --- a/tile_editor/atlas_merging_dialog.cpp +++ b/tile_editor/atlas_merging_dialog.cpp @@ -140,7 +140,7 @@ void RAtlasMergingDialog::_update_texture() { merge_button->set_disabled(false); } else { _generate_merged(Vector>(), next_line_after_column); - preview->set_texture(Ref()); + preview->set_texture(Ref()); preview->hide(); select_2_atlases_label->show(); get_ok_button()->set_disabled(true); @@ -154,7 +154,7 @@ void RAtlasMergingDialog::_merge_confirmed(String p_path) { Ref output_image_texture = merged->get_texture(); output_image_texture->get_image()->save_png(p_path); - Ref new_texture_resource = ResourceLoader::load(p_path, "Texture2D"); + Ref new_texture_resource = ResourceLoader::load(p_path, "Texture"); merged->set_texture(new_texture_resource); undo_redo->create_action(TTR("Merge RTileSetAtlasSource")); @@ -235,7 +235,7 @@ void RAtlasMergingDialog::update_tile_set(Ref p_tile_set) { int source_id = p_tile_set->get_source_id(i); Ref atlas_source = p_tile_set->get_source(source_id); if (atlas_source.is_valid()) { - Ref texture = atlas_source->get_texture(); + Ref texture = atlas_source->get_texture(); if (texture.is_valid()) { String item_text = vformat("%s (id:%d)", texture->get_path().get_file(), source_id); atlas_merging_atlases_list->add_item(item_text, texture); diff --git a/tile_editor/tile_data_editors.cpp b/tile_editor/tile_data_editors.cpp index 893ca19..3085b9c 100644 --- a/tile_editor/tile_data_editors.cpp +++ b/tile_editor/tile_data_editors.cpp @@ -50,17 +50,17 @@ void RTileDataEditor::_tile_set_changed_deferred_update() { } } -TileData *RTileDataEditor::_get_tile_data(TileMapCell p_cell) { +RTileData *RTileDataEditor::_get_tile_data(RTileMapCell p_cell) { ERR_FAIL_COND_V(!tile_set.is_valid(), nullptr); ERR_FAIL_COND_V(!tile_set->has_source(p_cell.source_id), nullptr); - TileData *td = nullptr; - TileSetSource *source = *tile_set->get_source(p_cell.source_id); - TileSetAtlasSource *atlas_source = Object::cast_to(source); + RTileData *td = nullptr; + RTileSetSource *source = *tile_set->get_source(p_cell.source_id); + RTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { ERR_FAIL_COND_V(!atlas_source->has_tile(p_cell.get_atlas_coords()), nullptr); ERR_FAIL_COND_V(!atlas_source->has_alternative_tile(p_cell.get_atlas_coords(), p_cell.alternative_tile), nullptr); - td = Object::cast_to(atlas_source->get_tile_data(p_cell.get_atlas_coords(), p_cell.alternative_tile)); + td = Object::cast_to(atlas_source->get_tile_data(p_cell.get_atlas_coords(), p_cell.alternative_tile)); } return td; @@ -72,7 +72,7 @@ void RTileDataEditor::_bind_methods() { ADD_SIGNAL(MethodInfo("needs_redraw")); } -void RTileDataEditor::set_tile_set(Ref p_tile_set) { +void RTileDataEditor::set_tile_set(Ref p_tile_set) { if (tile_set.is_valid()) { tile_set->disconnect("changed", callable_mp(this, &RTileDataEditor::_tile_set_changed_plan_update)); } @@ -83,7 +83,7 @@ void RTileDataEditor::set_tile_set(Ref p_tile_set) { _tile_set_changed_plan_update(); } -bool DummyObject::_set(const StringName &p_name, const Variant &p_value) { +bool RDummyObject::_set(const StringName &p_name, const Variant &p_value) { if (properties.has(p_name)) { properties[p_name] = p_value; return true; @@ -91,7 +91,7 @@ bool DummyObject::_set(const StringName &p_name, const Variant &p_value) { return false; } -bool DummyObject::_get(const StringName &p_name, Variant &r_ret) const { +bool RDummyObject::_get(const StringName &p_name, Variant &r_ret) const { if (properties.has(p_name)) { r_ret = properties[p_name]; return true; @@ -99,32 +99,32 @@ bool DummyObject::_get(const StringName &p_name, Variant &r_ret) const { return false; } -bool DummyObject::has_dummy_property(StringName p_name) { +bool RDummyObject::has_dummy_property(StringName p_name) { return properties.has(p_name); } -void DummyObject::add_dummy_property(StringName p_name) { +void RDummyObject::add_dummy_property(StringName p_name) { ERR_FAIL_COND(properties.has(p_name)); properties[p_name] = Variant(); } -void DummyObject::remove_dummy_property(StringName p_name) { +void RDummyObject::remove_dummy_property(StringName p_name) { ERR_FAIL_COND(!properties.has(p_name)); properties.erase(p_name); } -void DummyObject::clear_dummy_properties() { +void RDummyObject::clear_dummy_properties() { properties.clear(); } -void GenericTilePolygonEditor::_base_control_draw() { +void RGenericTilePolygonEditor::_base_control_draw() { ERR_FAIL_COND(!tile_set.is_valid()); real_t grab_threshold = EDITOR_GET("editors/polygon_editor/point_grab_radius"); Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color"); - const Ref handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); - const Ref add_handle = get_theme_icon(SNAME("EditorHandleAdd"), SNAME("EditorIcons")); + const Ref handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); + const Ref add_handle = get_theme_icon(SNAME("EditorHandleAdd"), SNAME("EditorIcons")); const Ref focus_stylebox = get_theme_stylebox(SNAME("Focus"), SNAME("EditorStyles")); // Draw the focus rectangle. @@ -236,17 +236,17 @@ void GenericTilePolygonEditor::_base_control_draw() { base_control->draw_set_transform_matrix(Transform2D()); } -void GenericTilePolygonEditor::_center_view() { +void RGenericTilePolygonEditor::_center_view() { panning = Vector2(); base_control->update(); button_center_view->set_disabled(true); } -void GenericTilePolygonEditor::_zoom_changed() { +void RGenericTilePolygonEditor::_zoom_changed() { base_control->update(); } -void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) { +void RGenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) { UndoRedo *undo_redo = use_undo_redo ? editor_undo_redo : memnew(UndoRedo); switch (p_item_pressed) { case RESET_TO_DEFAULT_TILE: { @@ -326,7 +326,7 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) { } } -void GenericTilePolygonEditor::_grab_polygon_point(Vector2 p_pos, const Transform2D &p_polygon_xform, int &r_polygon_index, int &r_point_index) { +void RGenericTilePolygonEditor::_grab_polygon_point(Vector2 p_pos, const Transform2D &p_polygon_xform, int &r_polygon_index, int &r_point_index) { const real_t grab_threshold = EDITOR_GET("editors/polygon_editor/point_grab_radius"); r_polygon_index = -1; r_point_index = -1; @@ -344,7 +344,7 @@ void GenericTilePolygonEditor::_grab_polygon_point(Vector2 p_pos, const Transfor } } -void GenericTilePolygonEditor::_grab_polygon_segment_point(Vector2 p_pos, const Transform2D &p_polygon_xform, int &r_polygon_index, int &r_segment_index, Vector2 &r_point) { +void RGenericTilePolygonEditor::_grab_polygon_segment_point(Vector2 p_pos, const Transform2D &p_polygon_xform, int &r_polygon_index, int &r_segment_index, Vector2 &r_point) { const real_t grab_threshold = EDITOR_GET("editors/polygon_editor/point_grab_radius"); Point2 point = p_polygon_xform.affine_inverse().xform(p_pos); @@ -367,7 +367,7 @@ void GenericTilePolygonEditor::_grab_polygon_segment_point(Vector2 p_pos, const } } -void GenericTilePolygonEditor::_snap_to_tile_shape(Point2 &r_point, float &r_current_snapped_dist, float p_snap_dist) { +void RGenericTilePolygonEditor::_snap_to_tile_shape(Point2 &r_point, float &r_current_snapped_dist, float p_snap_dist) { ERR_FAIL_COND(!tile_set.is_valid()); Vector polygon = tile_set->get_tile_shape_polygon(); @@ -403,11 +403,11 @@ void GenericTilePolygonEditor::_snap_to_tile_shape(Point2 &r_point, float &r_cur r_point = snapped_point; } -void GenericTilePolygonEditor::_snap_to_half_pixel(Point2 &r_point) { +void RGenericTilePolygonEditor::_snap_to_half_pixel(Point2 &r_point) { r_point = (r_point * 2).round() / 2.0; } -void GenericTilePolygonEditor::_base_control_gui_input(Ref p_event) { +void RGenericTilePolygonEditor::_base_control_gui_input(Ref p_event) { UndoRedo *undo_redo = use_undo_redo ? editor_undo_redo : memnew(UndoRedo); real_t grab_threshold = EDITOR_GET("editors/polygon_editor/point_grab_radius"); @@ -605,11 +605,11 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref p_event) } } -void GenericTilePolygonEditor::set_use_undo_redo(bool p_use_undo_redo) { +void RGenericTilePolygonEditor::set_use_undo_redo(bool p_use_undo_redo) { use_undo_redo = p_use_undo_redo; } -void GenericTilePolygonEditor::set_tile_set(Ref p_tile_set) { +void RGenericTilePolygonEditor::set_tile_set(Ref p_tile_set) { ERR_FAIL_COND(!p_tile_set.is_valid()); if (tile_set == p_tile_set) { return; @@ -642,7 +642,7 @@ void GenericTilePolygonEditor::set_tile_set(Ref p_tile_set) { _zoom_changed(); } -void GenericTilePolygonEditor::set_background(Ref p_texture, Rect2 p_region, Vector2 p_offset, bool p_flip_h, bool p_flip_v, bool p_transpose, Color p_modulate) { +void RGenericTilePolygonEditor::set_background(Ref p_texture, Rect2 p_region, Vector2 p_offset, bool p_flip_h, bool p_flip_v, bool p_transpose, Color p_modulate) { background_texture = p_texture; background_region = p_region; background_offset = p_offset; @@ -653,11 +653,11 @@ void GenericTilePolygonEditor::set_background(Ref p_texture, Rect2 p_ base_control->update(); } -int GenericTilePolygonEditor::get_polygon_count() { +int RGenericTilePolygonEditor::get_polygon_count() { return polygons.size(); } -int GenericTilePolygonEditor::add_polygon(Vector p_polygon, int p_index) { +int RGenericTilePolygonEditor::add_polygon(Vector p_polygon, int p_index) { ERR_FAIL_COND_V(p_polygon.size() < 3, -1); ERR_FAIL_COND_V(!multiple_polygon_mode && polygons.size() >= 1, -1); @@ -674,7 +674,7 @@ int GenericTilePolygonEditor::add_polygon(Vector p_polygon, int p_index) } } -void GenericTilePolygonEditor::remove_polygon(int p_index) { +void RGenericTilePolygonEditor::remove_polygon(int p_index) { ERR_FAIL_INDEX(p_index, (int)polygons.size()); polygons.remove_at(p_index); @@ -684,12 +684,12 @@ void GenericTilePolygonEditor::remove_polygon(int p_index) { base_control->update(); } -void GenericTilePolygonEditor::clear_polygons() { +void RGenericTilePolygonEditor::clear_polygons() { polygons.clear(); base_control->update(); } -void GenericTilePolygonEditor::set_polygon(int p_polygon_index, Vector p_polygon) { +void RGenericTilePolygonEditor::set_polygon(int p_polygon_index, Vector p_polygon) { ERR_FAIL_INDEX(p_polygon_index, (int)polygons.size()); ERR_FAIL_COND(p_polygon.size() < 3); polygons[p_polygon_index] = p_polygon; @@ -697,21 +697,21 @@ void GenericTilePolygonEditor::set_polygon(int p_polygon_index, Vector p base_control->update(); } -Vector GenericTilePolygonEditor::get_polygon(int p_polygon_index) { +Vector RGenericTilePolygonEditor::get_polygon(int p_polygon_index) { ERR_FAIL_INDEX_V(p_polygon_index, (int)polygons.size(), Vector()); return polygons[p_polygon_index]; } -void GenericTilePolygonEditor::set_polygons_color(Color p_color) { +void RGenericTilePolygonEditor::set_polygons_color(Color p_color) { polygon_color = p_color; base_control->update(); } -void GenericTilePolygonEditor::set_multiple_polygon_mode(bool p_multiple_polygon_mode) { +void RGenericTilePolygonEditor::set_multiple_polygon_mode(bool p_multiple_polygon_mode) { multiple_polygon_mode = p_multiple_polygon_mode; } -void GenericTilePolygonEditor::_notification(int p_what) { +void RGenericTilePolygonEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); @@ -730,18 +730,18 @@ void GenericTilePolygonEditor::_notification(int p_what) { } } -void GenericTilePolygonEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_polygon_count"), &GenericTilePolygonEditor::get_polygon_count); - ClassDB::bind_method(D_METHOD("add_polygon", "polygon", "index"), &GenericTilePolygonEditor::add_polygon, DEFVAL(-1)); - ClassDB::bind_method(D_METHOD("remove_polygon", "index"), &GenericTilePolygonEditor::remove_polygon); - ClassDB::bind_method(D_METHOD("clear_polygons"), &GenericTilePolygonEditor::clear_polygons); - ClassDB::bind_method(D_METHOD("set_polygon", "index", "polygon"), &GenericTilePolygonEditor::set_polygon); - ClassDB::bind_method(D_METHOD("get_polygon", "index"), &GenericTilePolygonEditor::set_polygon); +void RGenericTilePolygonEditor::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_polygon_count"), &RGenericTilePolygonEditor::get_polygon_count); + ClassDB::bind_method(D_METHOD("add_polygon", "polygon", "index"), &RGenericTilePolygonEditor::add_polygon, DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("remove_polygon", "index"), &RGenericTilePolygonEditor::remove_polygon); + ClassDB::bind_method(D_METHOD("clear_polygons"), &RGenericTilePolygonEditor::clear_polygons); + ClassDB::bind_method(D_METHOD("set_polygon", "index", "polygon"), &RGenericTilePolygonEditor::set_polygon); + ClassDB::bind_method(D_METHOD("get_polygon", "index"), &RGenericTilePolygonEditor::set_polygon); ADD_SIGNAL(MethodInfo("polygons_changed")); } -GenericTilePolygonEditor::GenericTilePolygonEditor() { +RGenericTilePolygonEditor::RGenericTilePolygonEditor() { toolbar = memnew(HBoxContainer); add_child(toolbar); @@ -779,7 +779,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() { button_advanced_menu->get_popup()->add_icon_item(get_theme_icon(SNAME("RotateLeft"), SNAME("EditorIcons")), TTR("Rotate Left"), ROTATE_LEFT); button_advanced_menu->get_popup()->add_icon_item(get_theme_icon(SNAME("MirrorX"), SNAME("EditorIcons")), TTR("Flip Horizontally"), FLIP_HORIZONTALLY); button_advanced_menu->get_popup()->add_icon_item(get_theme_icon(SNAME("MirrorY"), SNAME("EditorIcons")), TTR("Flip Vertically"), FLIP_VERTICALLY); - button_advanced_menu->get_popup()->connect("id_pressed", callable_mp(this, &GenericTilePolygonEditor::_advanced_menu_item_pressed)); + button_advanced_menu->get_popup()->connect("id_pressed", callable_mp(this, &RGenericTilePolygonEditor::_advanced_menu_item_pressed)); button_advanced_menu->set_focus_mode(FOCUS_ALL); toolbar->add_child(button_advanced_menu); @@ -806,37 +806,37 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() { base_control = memnew(Control); base_control->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); base_control->set_anchors_and_offsets_preset(Control::PRESET_WIDE); - base_control->connect("draw", callable_mp(this, &GenericTilePolygonEditor::_base_control_draw)); - base_control->connect("gui_input", callable_mp(this, &GenericTilePolygonEditor::_base_control_gui_input)); + base_control->connect("draw", callable_mp(this, &RGenericTilePolygonEditor::_base_control_draw)); + base_control->connect("gui_input", callable_mp(this, &RGenericTilePolygonEditor::_base_control_gui_input)); base_control->set_clip_contents(true); base_control->set_focus_mode(Control::FOCUS_CLICK); root->add_child(base_control); editor_zoom_widget = memnew(EditorZoomWidget); editor_zoom_widget->set_position(Vector2(5, 5)); - editor_zoom_widget->connect("zoom_changed", callable_mp(this, &GenericTilePolygonEditor::_zoom_changed).unbind(1)); + editor_zoom_widget->connect("zoom_changed", callable_mp(this, &RGenericTilePolygonEditor::_zoom_changed).unbind(1)); root->add_child(editor_zoom_widget); button_center_view = memnew(Button); button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons"))); button_center_view->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5); - button_center_view->connect("pressed", callable_mp(this, &GenericTilePolygonEditor::_center_view)); + button_center_view->connect("pressed", callable_mp(this, &RGenericTilePolygonEditor::_center_view)); button_center_view->set_flat(true); button_center_view->set_disabled(true); root->add_child(button_center_view); } -void TileDataDefaultEditor::_property_value_changed(StringName p_property, Variant p_value, StringName p_field) { +void RTileDataDefaultEditor::_property_value_changed(StringName p_property, Variant p_value, StringName p_field) { ERR_FAIL_COND(!dummy_object); dummy_object->set(p_property, p_value); } -Variant TileDataDefaultEditor::_get_painted_value() { +Variant RTileDataDefaultEditor::_get_painted_value() { ERR_FAIL_COND_V(!dummy_object, Variant()); return dummy_object->get(property); } -void TileDataDefaultEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { +void RTileDataDefaultEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { TileData *tile_data = Object::cast_to(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile)); ERR_FAIL_COND(!tile_data); Variant value = tile_data->get(property); @@ -846,19 +846,19 @@ void TileDataDefaultEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_at } } -void TileDataDefaultEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { +void RTileDataDefaultEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { TileData *tile_data = Object::cast_to(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile)); ERR_FAIL_COND(!tile_data); tile_data->set(property, p_value); } -Variant TileDataDefaultEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { +Variant RTileDataDefaultEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { TileData *tile_data = Object::cast_to(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile)); ERR_FAIL_COND_V(!tile_data, Variant()); return tile_data->get(property); } -void TileDataDefaultEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) { +void RTileDataDefaultEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) { for (const KeyValue &E : p_previous_values) { Vector2i coords = E.key.get_atlas_coords(); undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/%s", coords.x, coords.y, E.key.alternative_tile, property), E.value); @@ -866,7 +866,7 @@ void TileDataDefaultEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_s } } -void TileDataDefaultEditor::forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) { +void RTileDataDefaultEditor::forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) { if (drag_type == DRAG_TYPE_PAINT_RECT) { Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color"); Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0); @@ -901,11 +901,11 @@ void TileDataDefaultEditor::forward_draw_over_atlas(RTileAtlasView *p_tile_atlas } }; -void TileDataDefaultEditor::forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){ +void RTileDataDefaultEditor::forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){ }; -void TileDataDefaultEditor::forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref &p_event) { +void RTileDataDefaultEditor::forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref &p_event) { Ref mm = p_event; if (mm.is_valid()) { if (drag_type == DRAG_TYPE_PAINT) { @@ -995,7 +995,7 @@ void TileDataDefaultEditor::forward_painting_atlas_gui_input(RTileAtlasView *p_t } } -void TileDataDefaultEditor::forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref &p_event) { +void RTileDataDefaultEditor::forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref &p_event) { Ref mm = p_event; if (mm.is_valid()) { if (drag_type == DRAG_TYPE_PAINT) { @@ -1059,7 +1059,7 @@ void TileDataDefaultEditor::forward_painting_alternatives_gui_input(RTileAtlasVi } } -void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { +void RTileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { TileData *tile_data = _get_tile_data(p_cell); ERR_FAIL_COND(!tile_data); @@ -1070,7 +1070,7 @@ void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2 } if (value.get_type() == Variant::BOOL) { - Ref texture = (bool)value ? tile_bool_checked : tile_bool_unchecked; + Ref texture = (bool)value ? tile_bool_checked : tile_bool_unchecked; int size = MIN(tile_set->get_tile_size().x, tile_set->get_tile_size().y) / 3; Rect2 rect = p_transform.xform(Rect2(Vector2(-size / 2, -size / 2), Vector2(size, size))); p_canvas_item->draw_texture_rect(texture, rect); @@ -1117,8 +1117,8 @@ void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2 } } -void TileDataDefaultEditor::setup_property_editor(Variant::Type p_type, String p_property, String p_label, Variant p_default_value) { - ERR_FAIL_COND_MSG(!property.is_empty(), "Cannot setup TileDataDefaultEditor twice"); +void RTileDataDefaultEditor::setup_property_editor(Variant::Type p_type, String p_property, String p_label, Variant p_default_value) { + ERR_FAIL_COND_MSG(!property.is_empty(), "Cannot setup RTileDataDefaultEditor twice"); property = p_property; // Update everything. @@ -1147,12 +1147,12 @@ void TileDataDefaultEditor::setup_property_editor(Variant::Type p_type, String p } else { property_editor->set_label(p_label); } - property_editor->connect("property_changed", callable_mp(this, &TileDataDefaultEditor::_property_value_changed).unbind(1)); + property_editor->connect("property_changed", callable_mp(this, &RTileDataDefaultEditor::_property_value_changed).unbind(1)); property_editor->update_property(); add_child(property_editor); } -void TileDataDefaultEditor::_notification(int p_what) { +void RTileDataDefaultEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: @@ -1165,7 +1165,7 @@ void TileDataDefaultEditor::_notification(int p_what) { } } -TileDataDefaultEditor::TileDataDefaultEditor() { +RTileDataDefaultEditor::RTileDataDefaultEditor() { label = memnew(Label); label->set_text(TTR("Painting:")); add_child(label); @@ -1179,12 +1179,12 @@ TileDataDefaultEditor::TileDataDefaultEditor() { toolbar->add_child(picker_button); } -TileDataDefaultEditor::~TileDataDefaultEditor() { +RTileDataDefaultEditor::~RTileDataDefaultEditor() { toolbar->queue_delete(); memdelete(dummy_object); } -void TileDataTextureOffsetEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { +void RTileDataTextureOffsetEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { TileData *tile_data = _get_tile_data(p_cell); ERR_FAIL_COND(!tile_data); @@ -1200,7 +1200,7 @@ void TileDataTextureOffsetEditor::draw_over_tile(CanvasItem *p_canvas_item, Tran tile_set->draw_tile_shape(p_canvas_item, p_transform * tile_xform, color); } -void TileDataPositionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { +void RRTileDataPositionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { TileData *tile_data = _get_tile_data(p_cell); ERR_FAIL_COND(!tile_data); @@ -1217,11 +1217,11 @@ void TileDataPositionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0); color = selection_color; } - Ref position_icon = RTileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); + Ref position_icon = RTileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(value)) - position_icon->get_size() / 2, color); } -void TileDataYSortEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { +void RTileDataYSortEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { TileData *tile_data = _get_tile_data(p_cell); ERR_FAIL_COND(!tile_data); @@ -1231,11 +1231,11 @@ void TileDataYSortEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0); color = selection_color; } - Ref position_icon = RTileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); + Ref position_icon = RTileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(0, tile_data->get_y_sort_origin())) - position_icon->get_size() / 2, color); } -void TileDataOcclusionShapeEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { +void RTileDataOcclusionShapeEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { TileData *tile_data = _get_tile_data(p_cell); ERR_FAIL_COND(!tile_data); @@ -1258,7 +1258,7 @@ void TileDataOcclusionShapeEditor::draw_over_tile(CanvasItem *p_canvas_item, Tra RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), Transform2D()); } -Variant TileDataOcclusionShapeEditor::_get_painted_value() { +Variant RTileDataOcclusionShapeEditor::_get_painted_value() { Ref occluder_polygon; occluder_polygon.instantiate(); if (polygon_editor->get_polygon_count() >= 1) { @@ -1267,7 +1267,7 @@ Variant TileDataOcclusionShapeEditor::_get_painted_value() { return occluder_polygon; } -void TileDataOcclusionShapeEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { +void RTileDataOcclusionShapeEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { TileData *tile_data = Object::cast_to(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile)); ERR_FAIL_COND(!tile_data); @@ -1279,7 +1279,7 @@ void TileDataOcclusionShapeEditor::_set_painted_value(TileSetAtlasSource *p_tile polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); } -void TileDataOcclusionShapeEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { +void RTileDataOcclusionShapeEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { TileData *tile_data = Object::cast_to(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile)); ERR_FAIL_COND(!tile_data); Ref occluder_polygon = p_value; @@ -1288,13 +1288,13 @@ void TileDataOcclusionShapeEditor::_set_value(TileSetAtlasSource *p_tile_set_atl polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); } -Variant TileDataOcclusionShapeEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { +Variant RTileDataOcclusionShapeEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { TileData *tile_data = Object::cast_to(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile)); ERR_FAIL_COND_V(!tile_data, Variant()); return tile_data->get_occluder(occlusion_layer); } -void TileDataOcclusionShapeEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) { +void RTileDataOcclusionShapeEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) { for (const KeyValue &E : p_previous_values) { Vector2i coords = E.key.get_atlas_coords(); undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/occlusion_layer_%d/polygon", coords.x, coords.y, E.key.alternative_tile, occlusion_layer), E.value); @@ -1302,11 +1302,11 @@ void TileDataOcclusionShapeEditor::_setup_undo_redo_action(TileSetAtlasSource *p } } -void TileDataOcclusionShapeEditor::_tile_set_changed() { +void RTileDataOcclusionShapeEditor::_tile_set_changed() { polygon_editor->set_tile_set(tile_set); } -void TileDataOcclusionShapeEditor::_notification(int p_what) { +void RTileDataOcclusionShapeEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: polygon_editor->set_polygons_color(get_tree()->get_debug_collisions_color()); @@ -1316,16 +1316,16 @@ void TileDataOcclusionShapeEditor::_notification(int p_what) { } } -TileDataOcclusionShapeEditor::TileDataOcclusionShapeEditor() { - polygon_editor = memnew(GenericTilePolygonEditor); +RTileDataOcclusionShapeEditor::RTileDataOcclusionShapeEditor() { + polygon_editor = memnew(RGenericTilePolygonEditor); add_child(polygon_editor); } -void TileDataCollisionEditor::_property_value_changed(StringName p_property, Variant p_value, StringName p_field) { +void RTileDataCollisionEditor::_property_value_changed(StringName p_property, Variant p_value, StringName p_field) { dummy_object->set(p_property, p_value); } -void TileDataCollisionEditor::_polygons_changed() { +void RTileDataCollisionEditor::_polygons_changed() { // Update the dummy object properties and their editors. for (int i = 0; i < polygon_editor->get_polygon_count(); i++) { StringName one_way_property = vformat("polygon_%d_one_way", i); @@ -1345,7 +1345,7 @@ void TileDataCollisionEditor::_polygons_changed() { EditorProperty *one_way_property_editor = EditorInspectorDefaultPlugin::get_editor_for_property(dummy_object, Variant::BOOL, one_way_property, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT); one_way_property_editor->set_object_and_property(dummy_object, one_way_property); one_way_property_editor->set_label(one_way_property); - one_way_property_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1)); + one_way_property_editor->connect("property_changed", callable_mp(this, &RTileDataCollisionEditor::_property_value_changed).unbind(1)); one_way_property_editor->update_property(); add_child(one_way_property_editor); property_editors[one_way_property] = one_way_property_editor; @@ -1355,7 +1355,7 @@ void TileDataCollisionEditor::_polygons_changed() { EditorProperty *one_way_margin_property_editor = EditorInspectorDefaultPlugin::get_editor_for_property(dummy_object, Variant::FLOAT, one_way_margin_property, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT); one_way_margin_property_editor->set_object_and_property(dummy_object, one_way_margin_property); one_way_margin_property_editor->set_label(one_way_margin_property); - one_way_margin_property_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1)); + one_way_margin_property_editor->connect("property_changed", callable_mp(this, &RTileDataCollisionEditor::_property_value_changed).unbind(1)); one_way_margin_property_editor->update_property(); add_child(one_way_margin_property_editor); property_editors[one_way_margin_property] = one_way_margin_property_editor; @@ -1379,7 +1379,7 @@ void TileDataCollisionEditor::_polygons_changed() { } } -Variant TileDataCollisionEditor::_get_painted_value() { +Variant RTileDataCollisionEditor::_get_painted_value() { Dictionary dict; dict["linear_velocity"] = dummy_object->get("linear_velocity"); dict["angular_velocity"] = dummy_object->get("angular_velocity"); @@ -1397,7 +1397,7 @@ Variant TileDataCollisionEditor::_get_painted_value() { return dict; } -void TileDataCollisionEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { +void RTileDataCollisionEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { TileData *tile_data = Object::cast_to(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile)); ERR_FAIL_COND(!tile_data); @@ -1423,7 +1423,7 @@ void TileDataCollisionEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_ polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); } -void TileDataCollisionEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { +void RTileDataCollisionEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { TileData *tile_data = Object::cast_to(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile)); ERR_FAIL_COND(!tile_data); @@ -1442,7 +1442,7 @@ void TileDataCollisionEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_so polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); } -Variant TileDataCollisionEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { +Variant RTileDataCollisionEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { TileData *tile_data = Object::cast_to(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile)); ERR_FAIL_COND_V(!tile_data, Variant()); @@ -1461,7 +1461,7 @@ Variant TileDataCollisionEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas return dict; } -void TileDataCollisionEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) { +void RTileDataCollisionEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) { Array new_array = p_new_value; for (KeyValue &E : p_previous_values) { Array old_array = E.value; @@ -1485,12 +1485,12 @@ void TileDataCollisionEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile } } -void TileDataCollisionEditor::_tile_set_changed() { +void RTileDataCollisionEditor::_tile_set_changed() { polygon_editor->set_tile_set(tile_set); _polygons_changed(); } -void TileDataCollisionEditor::_notification(int p_what) { +void RTileDataCollisionEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: polygon_editor->set_polygons_color(get_tree()->get_debug_collisions_color()); @@ -1500,10 +1500,10 @@ void TileDataCollisionEditor::_notification(int p_what) { } } -TileDataCollisionEditor::TileDataCollisionEditor() { - polygon_editor = memnew(GenericTilePolygonEditor); +RTileDataCollisionEditor::RTileDataCollisionEditor() { + polygon_editor = memnew(RGenericTilePolygonEditor); polygon_editor->set_multiple_polygon_mode(true); - polygon_editor->connect("polygons_changed", callable_mp(this, &TileDataCollisionEditor::_polygons_changed)); + polygon_editor->connect("polygons_changed", callable_mp(this, &RTileDataCollisionEditor::_polygons_changed)); add_child(polygon_editor); dummy_object->add_dummy_property("linear_velocity"); @@ -1514,7 +1514,7 @@ TileDataCollisionEditor::TileDataCollisionEditor() { EditorProperty *linear_velocity_editor = EditorInspectorDefaultPlugin::get_editor_for_property(dummy_object, Variant::VECTOR2, "linear_velocity", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT); linear_velocity_editor->set_object_and_property(dummy_object, "linear_velocity"); linear_velocity_editor->set_label("linear_velocity"); - linear_velocity_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1)); + linear_velocity_editor->connect("property_changed", callable_mp(this, &RTileDataCollisionEditor::_property_value_changed).unbind(1)); linear_velocity_editor->update_property(); add_child(linear_velocity_editor); property_editors["linear_velocity"] = linear_velocity_editor; @@ -1522,7 +1522,7 @@ TileDataCollisionEditor::TileDataCollisionEditor() { EditorProperty *angular_velocity_editor = EditorInspectorDefaultPlugin::get_editor_for_property(dummy_object, Variant::FLOAT, "angular_velocity", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT); angular_velocity_editor->set_object_and_property(dummy_object, "angular_velocity"); angular_velocity_editor->set_label("angular_velocity"); - angular_velocity_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1)); + angular_velocity_editor->connect("property_changed", callable_mp(this, &RTileDataCollisionEditor::_property_value_changed).unbind(1)); angular_velocity_editor->update_property(); add_child(angular_velocity_editor); property_editors["angular_velocity"] = angular_velocity_editor; @@ -1530,11 +1530,11 @@ TileDataCollisionEditor::TileDataCollisionEditor() { _polygons_changed(); } -TileDataCollisionEditor::~TileDataCollisionEditor() { +RTileDataCollisionEditor::~RTileDataCollisionEditor() { memdelete(dummy_object); } -void TileDataCollisionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { +void RTileDataCollisionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { TileData *tile_data = _get_tile_data(p_cell); ERR_FAIL_COND(!tile_data); @@ -1560,7 +1560,7 @@ void TileDataCollisionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transfor RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), Transform2D()); } -void TileDataTerrainsEditor::_update_terrain_selector() { +void RTileDataTerrainsEditor::_update_terrain_selector() { ERR_FAIL_COND(!tile_set.is_valid()); // Update the terrain set selector. @@ -1578,7 +1578,7 @@ void TileDataTerrainsEditor::_update_terrain_selector() { terrain_property_editor->hide(); } else { options.clear(); - Vector>> icons = tile_set->generate_terrains_icons(Size2(16, 16) * EDSCALE); + Vector>> icons = tile_set->generate_terrains_icons(Size2(16, 16) * EDSCALE); options.push_back(String(TTR("No terrain")) + String(":-1")); for (int i = 0; i < tile_set->get_terrains_count(terrain_set); i++) { String name = tile_set->get_terrain_name(terrain_set, i); @@ -1601,7 +1601,7 @@ void TileDataTerrainsEditor::_update_terrain_selector() { } } -void TileDataTerrainsEditor::_property_value_changed(StringName p_property, Variant p_value, StringName p_field) { +void RTileDataTerrainsEditor::_property_value_changed(StringName p_property, Variant p_value, StringName p_field) { Variant old_value = dummy_object->get(p_property); dummy_object->set(p_property, p_value); if (p_property == "terrain_set") { @@ -1613,7 +1613,7 @@ void TileDataTerrainsEditor::_property_value_changed(StringName p_property, Vari emit_signal(SNAME("needs_redraw")); } -void TileDataTerrainsEditor::_tile_set_changed() { +void RTileDataTerrainsEditor::_tile_set_changed() { ERR_FAIL_COND(!tile_set.is_valid()); // Fix if wrong values are selected. @@ -1631,7 +1631,7 @@ void TileDataTerrainsEditor::_tile_set_changed() { _update_terrain_selector(); } -void TileDataTerrainsEditor::forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) { +void RTileDataTerrainsEditor::forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) { ERR_FAIL_COND(!tile_set.is_valid()); // Draw the hovered terrain bit, or the whole tile if it has the wrong terrain set. @@ -1803,7 +1803,7 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(RTileAtlasView *p_tile_atla } } -void TileDataTerrainsEditor::forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) { +void RTileDataTerrainsEditor::forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) { ERR_FAIL_COND(!tile_set.is_valid()); // Draw the hovered terrain bit, or the whole tile if it has the wrong terrain set. @@ -1885,7 +1885,7 @@ void TileDataTerrainsEditor::forward_draw_over_alternatives(RTileAtlasView *p_ti p_canvas_item->draw_set_transform_matrix(Transform2D()); } -void TileDataTerrainsEditor::forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref &p_event) { +void RTileDataTerrainsEditor::forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref &p_event) { Ref mm = p_event; if (mm.is_valid()) { if (drag_type == DRAG_TYPE_PAINT_TERRAIN_SET) { @@ -2228,7 +2228,7 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(RTileAtlasView *p_ } } -void TileDataTerrainsEditor::forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref &p_event) { +void RTileDataTerrainsEditor::forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref &p_event) { Ref mm = p_event; if (mm.is_valid()) { if (drag_type == DRAG_TYPE_PAINT_TERRAIN_SET) { @@ -2449,14 +2449,14 @@ void TileDataTerrainsEditor::forward_painting_alternatives_gui_input(RTileAtlasV } } -void TileDataTerrainsEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { +void RTileDataTerrainsEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { TileData *tile_data = _get_tile_data(p_cell); ERR_FAIL_COND(!tile_data); tile_set->draw_terrains(p_canvas_item, p_transform, tile_data); } -void TileDataTerrainsEditor::_notification(int p_what) { +void RTileDataTerrainsEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: @@ -2467,7 +2467,7 @@ void TileDataTerrainsEditor::_notification(int p_what) { } } -TileDataTerrainsEditor::TileDataTerrainsEditor() { +RTileDataTerrainsEditor::RTileDataTerrainsEditor() { label = memnew(Label); label->set_text("Painting:"); add_child(label); @@ -2491,22 +2491,22 @@ TileDataTerrainsEditor::TileDataTerrainsEditor() { terrain_set_property_editor = memnew(EditorPropertyEnum); terrain_set_property_editor->set_object_and_property(dummy_object, "terrain_set"); terrain_set_property_editor->set_label("Terrain Set"); - terrain_set_property_editor->connect("property_changed", callable_mp(this, &TileDataTerrainsEditor::_property_value_changed).unbind(1)); + terrain_set_property_editor->connect("property_changed", callable_mp(this, &RTileDataTerrainsEditor::_property_value_changed).unbind(1)); add_child(terrain_set_property_editor); terrain_property_editor = memnew(EditorPropertyEnum); terrain_property_editor->set_object_and_property(dummy_object, "terrain"); terrain_property_editor->set_label("Terrain"); - terrain_property_editor->connect("property_changed", callable_mp(this, &TileDataTerrainsEditor::_property_value_changed).unbind(1)); + terrain_property_editor->connect("property_changed", callable_mp(this, &RTileDataTerrainsEditor::_property_value_changed).unbind(1)); add_child(terrain_property_editor); } -TileDataTerrainsEditor::~TileDataTerrainsEditor() { +RTileDataTerrainsEditor::~RTileDataTerrainsEditor() { toolbar->queue_delete(); memdelete(dummy_object); } -Variant TileDataNavigationEditor::_get_painted_value() { +Variant RTileDataNavigationEditor::_get_painted_value() { Ref navigation_polygon; navigation_polygon.instantiate(); @@ -2519,7 +2519,7 @@ Variant TileDataNavigationEditor::_get_painted_value() { return navigation_polygon; } -void TileDataNavigationEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { +void RTileDataNavigationEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { TileData *tile_data = Object::cast_to(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile)); ERR_FAIL_COND(!tile_data); @@ -2533,7 +2533,7 @@ void TileDataNavigationEditor::_set_painted_value(TileSetAtlasSource *p_tile_set polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); } -void TileDataNavigationEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { +void RTileDataNavigationEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { TileData *tile_data = Object::cast_to(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile)); ERR_FAIL_COND(!tile_data); Ref navigation_polygon = p_value; @@ -2542,13 +2542,13 @@ void TileDataNavigationEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_s polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); } -Variant TileDataNavigationEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { +Variant RTileDataNavigationEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { TileData *tile_data = Object::cast_to(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile)); ERR_FAIL_COND_V(!tile_data, Variant()); return tile_data->get_navigation_polygon(navigation_layer); } -void TileDataNavigationEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) { +void RTileDataNavigationEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) { for (const KeyValue &E : p_previous_values) { Vector2i coords = E.key.get_atlas_coords(); undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/navigation_layer_%d/polygon", coords.x, coords.y, E.key.alternative_tile, navigation_layer), E.value); @@ -2556,11 +2556,11 @@ void TileDataNavigationEditor::_setup_undo_redo_action(TileSetAtlasSource *p_til } } -void TileDataNavigationEditor::_tile_set_changed() { +void RTileDataNavigationEditor::_tile_set_changed() { polygon_editor->set_tile_set(tile_set); } -void TileDataNavigationEditor::_notification(int p_what) { +void RTileDataNavigationEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: polygon_editor->set_polygons_color(get_tree()->get_debug_navigation_color()); @@ -2570,13 +2570,13 @@ void TileDataNavigationEditor::_notification(int p_what) { } } -TileDataNavigationEditor::TileDataNavigationEditor() { - polygon_editor = memnew(GenericTilePolygonEditor); +RTileDataNavigationEditor::RTileDataNavigationEditor() { + polygon_editor = memnew(RGenericTilePolygonEditor); polygon_editor->set_multiple_polygon_mode(true); add_child(polygon_editor); } -void TileDataNavigationEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { +void RTileDataNavigationEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) { TileData *tile_data = _get_tile_data(p_cell); ERR_FAIL_COND(!tile_data); diff --git a/tile_editor/tile_data_editors.h b/tile_editor/tile_data_editors.h index b7a622f..d61fb01 100644 --- a/tile_editor/tile_data_editors.h +++ b/tile_editor/tile_data_editors.h @@ -51,7 +51,7 @@ private: protected: Ref tile_set; - TileData *_get_tile_data(TileMapCell p_cell); + RTileData *_get_tile_data(RTileMapCell p_cell); virtual void _tile_set_changed(){}; static void _bind_methods(); @@ -67,11 +67,11 @@ public: 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){}; + virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, RTileMapCell p_cell, bool p_selected = false){}; }; -class DummyObject : public Object { - GDCLASS(DummyObject, Object) +class RDummyObject : public Object { + GDCLASS(RDummyObject, Object) private: Map properties; @@ -86,8 +86,8 @@ public: void clear_dummy_properties(); }; -class GenericTilePolygonEditor : public VBoxContainer { - GDCLASS(GenericTilePolygonEditor, VBoxContainer); +class RGenericTilePolygonEditor : public VBoxContainer { + GDCLASS(RGenericTilePolygonEditor, VBoxContainer); private: Ref tile_set; @@ -131,7 +131,7 @@ private: Button *button_center_view; Vector2 panning; - Ref background_texture; + Ref background_texture; Rect2 background_region; Vector2 background_offset; bool background_h_flip; @@ -169,7 +169,7 @@ public: void set_use_undo_redo(bool p_use_undo_redo); 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)); + 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(); int add_polygon(Vector p_polygon, int p_index = -1); @@ -181,11 +181,11 @@ public: void set_polygons_color(Color p_color); void set_multiple_polygon_mode(bool p_multiple_polygon_mode); - GenericTilePolygonEditor(); + RGenericTilePolygonEditor(); }; -class TileDataDefaultEditor : public RTileDataEditor { - GDCLASS(TileDataDefaultEditor, RTileDataEditor); +class RTileDataDefaultEditor : public RTileDataEditor { + GDCLASS(RTileDataDefaultEditor, RTileDataEditor); private: // Toolbar @@ -193,8 +193,8 @@ private: Button *picker_button; // UI - Ref tile_bool_checked; - Ref tile_bool_unchecked; + Ref tile_bool_checked; + Ref tile_bool_unchecked; Label *label; EditorProperty *property_editor = nullptr; @@ -208,13 +208,13 @@ private: DragType drag_type = DRAG_TYPE_NONE; Vector2 drag_start_pos; Vector2 drag_last_pos; - Map drag_modified; + Map drag_modified; Variant drag_painted_value; void _property_value_changed(StringName p_property, Variant p_value, StringName p_field); protected: - DummyObject *dummy_object = memnew(DummyObject); + RDummyObject *dummy_object = memnew(RDummyObject); UndoRedo *undo_redo = EditorNode::get_undo_redo(); @@ -226,7 +226,7 @@ protected: 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); + 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; }; @@ -234,43 +234,43 @@ public: 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; + virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, RTileMapCell 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()); - TileDataDefaultEditor(); - ~TileDataDefaultEditor(); + RTileDataDefaultEditor(); + ~RTileDataDefaultEditor(); }; -class TileDataTextureOffsetEditor : public TileDataDefaultEditor { - GDCLASS(TileDataTextureOffsetEditor, TileDataDefaultEditor); +class RTileDataTextureOffsetEditor : public RTileDataDefaultEditor { + GDCLASS(RTileDataTextureOffsetEditor, RTileDataDefaultEditor); public: - virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override; + virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, RTileMapCell p_cell, bool p_selected = false) override; }; -class TileDataPositionEditor : public TileDataDefaultEditor { - GDCLASS(TileDataPositionEditor, TileDataDefaultEditor); +class RTileDataPositionEditor : public RTileDataDefaultEditor { + GDCLASS(RTileDataPositionEditor, RTileDataDefaultEditor); public: - virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override; + virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, RTileMapCell p_cell, bool p_selected = false) override; }; -class TileDataYSortEditor : public TileDataDefaultEditor { - GDCLASS(TileDataYSortEditor, TileDataDefaultEditor); +class RTileDataYSortEditor : public RTileDataDefaultEditor { + GDCLASS(RTileDataYSortEditor, RTileDataDefaultEditor); public: - virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override; + virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, RTileMapCell p_cell, bool p_selected = false) override; }; -class TileDataOcclusionShapeEditor : public TileDataDefaultEditor { - GDCLASS(TileDataOcclusionShapeEditor, TileDataDefaultEditor); +class RTileDataOcclusionShapeEditor : public RTileDataDefaultEditor { + GDCLASS(RTileDataOcclusionShapeEditor, RTileDataDefaultEditor); private: int occlusion_layer = -1; // UI - GenericTilePolygonEditor *polygon_editor; + RGenericTilePolygonEditor *polygon_editor; void _polygon_changed(PackedVector2Array p_polygon); @@ -278,7 +278,7 @@ private: 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; + 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(); @@ -288,21 +288,21 @@ protected: void _notification(int p_what); public: - virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override; + virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, RTileMapCell p_cell, bool p_selected = false) override; void set_occlusion_layer(int p_occlusion_layer) { occlusion_layer = p_occlusion_layer; } - TileDataOcclusionShapeEditor(); + RTileDataOcclusionShapeEditor(); }; -class TileDataCollisionEditor : public TileDataDefaultEditor { - GDCLASS(TileDataCollisionEditor, TileDataDefaultEditor); +class RTileDataCollisionEditor : public RTileDataDefaultEditor { + GDCLASS(RTileDataCollisionEditor, RTileDataDefaultEditor); int physics_layer = -1; // UI - GenericTilePolygonEditor *polygon_editor; - DummyObject *dummy_object = memnew(DummyObject); + RGenericTilePolygonEditor *polygon_editor; + RDummyObject *dummy_object = memnew(RDummyObject); Map property_editors; void _property_value_changed(StringName p_property, Variant p_value, StringName p_field); @@ -312,7 +312,7 @@ class TileDataCollisionEditor : public TileDataDefaultEditor { 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; + 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(); @@ -322,16 +322,16 @@ protected: void _notification(int p_what); public: - virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override; + virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, RTileMapCell p_cell, bool p_selected = false) override; void set_physics_layer(int p_physics_layer) { physics_layer = p_physics_layer; } - TileDataCollisionEditor(); - ~TileDataCollisionEditor(); + RTileDataCollisionEditor(); + ~RTileDataCollisionEditor(); }; -class TileDataTerrainsEditor : public RTileDataEditor { - GDCLASS(TileDataTerrainsEditor, RTileDataEditor); +class RTileDataTerrainsEditor : public RTileDataEditor { + GDCLASS(RTileDataTerrainsEditor, RTileDataEditor); private: // Toolbar @@ -349,12 +349,12 @@ private: DragType drag_type = DRAG_TYPE_NONE; Vector2 drag_start_pos; Vector2 drag_last_pos; - Map drag_modified; + Map drag_modified; Variant drag_painted_value; // UI Label *label; - DummyObject *dummy_object = memnew(DummyObject); + RDummyObject *dummy_object = memnew(RDummyObject); EditorPropertyEnum *terrain_set_property_editor = nullptr; EditorPropertyEnum *terrain_property_editor = nullptr; @@ -375,21 +375,21 @@ public: 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; + virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, RTileMapCell p_cell, bool p_selected = false) override; - TileDataTerrainsEditor(); - ~TileDataTerrainsEditor(); + RTileDataTerrainsEditor(); + ~RTileDataTerrainsEditor(); }; -class TileDataNavigationEditor : public TileDataDefaultEditor { - GDCLASS(TileDataNavigationEditor, TileDataDefaultEditor); +class RTileDataNavigationEditor : public RTileDataDefaultEditor { + GDCLASS(RTileDataNavigationEditor, RTileDataDefaultEditor); private: int navigation_layer = -1; PackedVector2Array navigation_polygon; // UI - GenericTilePolygonEditor *polygon_editor; + RGenericTilePolygonEditor *polygon_editor; void _polygon_changed(PackedVector2Array p_polygon); @@ -397,7 +397,7 @@ private: 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; + 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(); @@ -407,11 +407,11 @@ protected: void _notification(int p_what); public: - virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override; + virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, RTileMapCell p_cell, bool p_selected = false) override; void set_navigation_layer(int p_navigation_layer) { navigation_layer = p_navigation_layer; } - TileDataNavigationEditor(); + RTileDataNavigationEditor(); }; #endif // TILE_DATA_EDITORS_H diff --git a/tile_editor/tile_map_editor.cpp b/tile_editor/tile_map_editor.cpp index 72091fd..62b7e7b 100644 --- a/tile_editor/tile_map_editor.cpp +++ b/tile_editor/tile_map_editor.cpp @@ -141,7 +141,7 @@ void RTileMapEditorTilesPlugin::_update_tile_set_sources_list() { RTileSetSource *source = *tile_set->get_source(source_id); - Ref texture; + Ref texture; String item_text; // Common to all type of sources. @@ -278,7 +278,7 @@ void RTileMapEditorTilesPlugin::_patterns_item_list_gui_input(const Ref p_pattern, Ref p_texture) { +void RTileMapEditorTilesPlugin::_pattern_preview_done(Ref p_pattern, Ref p_texture) { // TODO optimize ? for (int i = 0; i < patterns_item_list->get_item_count(); i++) { if (patterns_item_list->get_item_metadata(i) == p_pattern) { @@ -386,7 +386,7 @@ void RTileMapEditorTilesPlugin::_update_scenes_collection_view() { scene_tiles_list->set_fixed_icon_size(Vector2(int_size, int_size)); } -void RTileMapEditorTilesPlugin::_scene_thumbnail_done(const String &p_path, const Ref &p_preview, const Ref &p_small_preview, Variant p_ud) { +void RTileMapEditorTilesPlugin::_scene_thumbnail_done(const String &p_path, const Ref &p_preview, const Ref &p_small_preview, Variant p_ud) { int index = p_ud; if (index >= 0 && index < scene_tiles_list->get_item_count()) { @@ -3053,7 +3053,7 @@ void RTileMapEditorTerrainsPlugin::_update_terrains_tree() { } // Fill in the terrain list. - Vector>> icons = tile_set->generate_terrains_icons(Size2(16, 16) * EDSCALE); + Vector>> icons = tile_set->generate_terrains_icons(Size2(16, 16) * EDSCALE); for (int terrain_set_index = 0; terrain_set_index < tile_set->get_terrain_sets_count(); terrain_set_index++) { // Add an item for the terrain set. TreeItem *terrain_set_tree_item = terrains_tree->create_item(); @@ -3128,7 +3128,7 @@ void RTileMapEditorTerrainsPlugin::_update_tiles_list() { RTileSet::TerrainsPattern terrains_pattern = E->get(); // Get the icon. - Ref icon; + Ref icon; Rect2 region; bool transpose = false; @@ -3347,7 +3347,7 @@ void RTileMapEditor::_layers_selection_button_draw() { } RID ci = layers_selection_button->get_canvas_item(); - Ref arrow = Control::get_theme_icon(SNAME("arrow"), SNAME("OptionButton")); + Ref arrow = Control::get_theme_icon(SNAME("arrow"), SNAME("OptionButton")); Color clr = Color(1, 1, 1); if (get_theme_constant(SNAME("modulate_arrow"))) { @@ -3630,7 +3630,7 @@ void RTileMapEditor::_update_layers_selection() { // Set button minimum width. Size2 min_button_size = Size2(layers_selection_popup->get_contents_minimum_size().x, 0); if (has_theme_icon(SNAME("arrow"), SNAME("OptionButton"))) { - Ref arrow = Control::get_theme_icon(SNAME("arrow"), SNAME("OptionButton")); + Ref arrow = Control::get_theme_icon(SNAME("arrow"), SNAME("OptionButton")); min_button_size.x += arrow->get_size().x; } layers_selection_button->set_custom_minimum_size(min_button_size); diff --git a/tile_editor/tile_map_editor.h b/tile_editor/tile_map_editor.h index e88709a..57e679b 100644 --- a/tile_editor/tile_map_editor.h +++ b/tile_editor/tile_map_editor.h @@ -146,7 +146,7 @@ private: ItemList *sources_list; - Ref missing_atlas_texture_icon; + Ref missing_atlas_texture_icon; void _update_tile_set_sources_list(); void _update_source_display(); @@ -175,7 +175,7 @@ private: ItemList *scene_tiles_list; void _update_scenes_collection_view(); - void _scene_thumbnail_done(const String &p_path, const Ref &p_preview, const Ref &p_small_preview, Variant p_ud); + void _scene_thumbnail_done(const String &p_path, const Ref &p_preview, const Ref &p_small_preview, Variant p_ud); void _scenes_list_multi_selected(int p_index, bool p_selected); void _scenes_list_nothing_selected(); @@ -184,7 +184,7 @@ private: ItemList *patterns_item_list; Label *patterns_help_label; void _patterns_item_list_gui_input(const Ref &p_event); - void _pattern_preview_done(Ref p_pattern, Ref p_texture); + void _pattern_preview_done(Ref p_pattern, Ref p_texture); bool select_last_pattern = false; void _update_patterns_list(); @@ -328,8 +328,8 @@ private: void _update_bottom_panel(); // TileMap. - Ref missing_tile_texture; - Ref warning_pattern_texture; + Ref missing_tile_texture; + Ref warning_pattern_texture; // CallBack. void _tile_map_changed(); diff --git a/tile_editor/tile_proxies_manager_dialog.h b/tile_editor/tile_proxies_manager_dialog.h index 591b4f4..06b07b9 100644 --- a/tile_editor/tile_proxies_manager_dialog.h +++ b/tile_editor/tile_proxies_manager_dialog.h @@ -47,8 +47,8 @@ private: UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); - TileMapCell from; - TileMapCell to; + RTileMapCell from; + RTileMapCell to; // GUI ItemList *source_level_list; diff --git a/tile_editor/tile_set_atlas_source_editor.cpp b/tile_editor/tile_set_atlas_source_editor.cpp index 411e804..37c9703 100644 --- a/tile_editor/tile_set_atlas_source_editor.cpp +++ b/tile_editor/tile_set_atlas_source_editor.cpp @@ -95,7 +95,7 @@ bool RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::_get(const Strin 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::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture")); p_list->push_back(PropertyInfo(Variant::VECTOR2I, "margins", PROPERTY_HINT_NONE, "")); p_list->push_back(PropertyInfo(Variant::VECTOR2I, "separation", PROPERTY_HINT_NONE, "")); p_list->push_back(PropertyInfo(Variant::VECTOR2I, "texture_region_size", PROPERTY_HINT_NONE, "")); @@ -620,7 +620,7 @@ void RTileSetAtlasSourceEditor::_update_tile_data_editors() { ADD_TILE_DATA_EDITOR(group, "Texture Offset", "texture_offset"); if (!tile_data_editors.has("texture_offset")) { - TileDataTextureOffsetEditor *tile_data_texture_offset_editor = memnew(TileDataTextureOffsetEditor); + RTileDataTextureOffsetEditor *tile_data_texture_offset_editor = memnew(RTileDataTextureOffsetEditor); tile_data_texture_offset_editor->hide(); tile_data_texture_offset_editor->setup_property_editor(Variant::VECTOR2, "texture_offset"); tile_data_texture_offset_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); @@ -630,7 +630,7 @@ void RTileSetAtlasSourceEditor::_update_tile_data_editors() { ADD_TILE_DATA_EDITOR(group, "Modulate", "modulate"); if (!tile_data_editors.has("modulate")) { - TileDataDefaultEditor *tile_data_modulate_editor = memnew(TileDataDefaultEditor()); + RTileDataDefaultEditor *tile_data_modulate_editor = memnew(RTileDataDefaultEditor()); tile_data_modulate_editor->hide(); tile_data_modulate_editor->setup_property_editor(Variant::COLOR, "modulate", "", Color(1.0, 1.0, 1.0, 1.0)); tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); @@ -640,7 +640,7 @@ void RTileSetAtlasSourceEditor::_update_tile_data_editors() { ADD_TILE_DATA_EDITOR(group, "Z Index", "z_index"); if (!tile_data_editors.has("z_index")) { - TileDataDefaultEditor *tile_data_z_index_editor = memnew(TileDataDefaultEditor()); + RTileDataDefaultEditor *tile_data_z_index_editor = memnew(RTileDataDefaultEditor()); tile_data_z_index_editor->hide(); tile_data_z_index_editor->setup_property_editor(Variant::INT, "z_index"); tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); @@ -650,7 +650,7 @@ void RTileSetAtlasSourceEditor::_update_tile_data_editors() { ADD_TILE_DATA_EDITOR(group, "Y Sort Origin", "y_sort_origin"); if (!tile_data_editors.has("y_sort_origin")) { - TileDataYSortEditor *tile_data_y_sort_editor = memnew(TileDataYSortEditor); + RTileDataYSortEditor *tile_data_y_sort_editor = memnew(RTileDataYSortEditor); tile_data_y_sort_editor->hide(); tile_data_y_sort_editor->setup_property_editor(Variant::INT, "y_sort_origin"); tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); @@ -661,7 +661,7 @@ void RTileSetAtlasSourceEditor::_update_tile_data_editors() { for (int i = 0; i < tile_set->get_occlusion_layers_count(); i++) { ADD_TILE_DATA_EDITOR(group, vformat("Occlusion Layer %d", i), vformat("occlusion_layer_%d", i)); if (!tile_data_editors.has(vformat("occlusion_layer_%d", i))) { - TileDataOcclusionShapeEditor *tile_data_occlusion_shape_editor = memnew(TileDataOcclusionShapeEditor()); + RTileDataOcclusionShapeEditor *tile_data_occlusion_shape_editor = memnew(RTileDataOcclusionShapeEditor()); tile_data_occlusion_shape_editor->hide(); tile_data_occlusion_shape_editor->set_occlusion_layer(i); tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); @@ -677,7 +677,7 @@ void RTileSetAtlasSourceEditor::_update_tile_data_editors() { // --- Rendering --- ADD_TILE_DATA_EDITOR(root, "Terrains", "terrain_set"); if (!tile_data_editors.has("terrain_set")) { - TileDataTerrainsEditor *tile_data_terrains_editor = memnew(TileDataTerrainsEditor); + RTileDataTerrainsEditor *tile_data_terrains_editor = memnew(RTileDataTerrainsEditor); tile_data_terrains_editor->hide(); tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); @@ -687,7 +687,7 @@ void RTileSetAtlasSourceEditor::_update_tile_data_editors() { // --- Miscellaneous --- ADD_TILE_DATA_EDITOR(root, "Probability", "probability"); if (!tile_data_editors.has("probability")) { - TileDataDefaultEditor *tile_data_probability_editor = memnew(TileDataDefaultEditor()); + RTileDataDefaultEditor *tile_data_probability_editor = memnew(RTileDataDefaultEditor()); tile_data_probability_editor->hide(); tile_data_probability_editor->setup_property_editor(Variant::FLOAT, "probability", "", 1.0); tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); @@ -700,7 +700,7 @@ void RTileSetAtlasSourceEditor::_update_tile_data_editors() { for (int i = 0; i < tile_set->get_physics_layers_count(); i++) { ADD_TILE_DATA_EDITOR(group, vformat("Physics Layer %d", i), vformat("physics_layer_%d", i)); if (!tile_data_editors.has(vformat("physics_layer_%d", i))) { - TileDataCollisionEditor *tile_data_collision_editor = memnew(TileDataCollisionEditor()); + RTileDataCollisionEditor *tile_data_collision_editor = memnew(RTileDataCollisionEditor()); tile_data_collision_editor->hide(); tile_data_collision_editor->set_physics_layer(i); tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); @@ -718,7 +718,7 @@ void RTileSetAtlasSourceEditor::_update_tile_data_editors() { for (int i = 0; i < tile_set->get_navigation_layers_count(); i++) { ADD_TILE_DATA_EDITOR(group, vformat("Navigation Layer %d", i), vformat("navigation_layer_%d", i)); if (!tile_data_editors.has(vformat("navigation_layer_%d", i))) { - TileDataNavigationEditor *tile_data_navigation_editor = memnew(TileDataNavigationEditor()); + RTileDataNavigationEditor *tile_data_navigation_editor = memnew(RTileDataNavigationEditor()); tile_data_navigation_editor->hide(); tile_data_navigation_editor->set_navigation_layer(i); tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); @@ -740,7 +740,7 @@ void RTileSetAtlasSourceEditor::_update_tile_data_editors() { ADD_TILE_DATA_EDITOR(group, tile_set->get_custom_data_name(i), vformat("custom_data_%d", i)); } if (!tile_data_editors.has(vformat("custom_data_%d", i))) { - TileDataDefaultEditor *tile_data_custom_data_editor = memnew(TileDataDefaultEditor()); + RTileDataDefaultEditor *tile_data_custom_data_editor = memnew(RTileDataDefaultEditor()); tile_data_custom_data_editor->hide(); tile_data_custom_data_editor->setup_property_editor(tile_set->get_custom_data_type(i), vformat("custom_data_%d", i), tile_set->get_custom_data_name(i)); tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); @@ -828,7 +828,7 @@ void RTileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw() { } RID ci = tile_data_editor_dropdown_button->get_canvas_item(); - Ref arrow = Control::get_theme_icon(SNAME("arrow"), SNAME("OptionButton")); + Ref arrow = Control::get_theme_icon(SNAME("arrow"), SNAME("OptionButton")); Color clr = Color(1, 1, 1); if (get_theme_constant(SNAME("modulate_arrow"))) { switch (tile_data_editor_dropdown_button->get_draw_mode()) { @@ -2166,7 +2166,7 @@ void RTileSetAtlasSourceEditor::_auto_create_tiles() { return; } - 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(); @@ -2210,7 +2210,7 @@ void RTileSetAtlasSourceEditor::_auto_remove_tiles() { return; } - 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(); @@ -2663,7 +2663,7 @@ void REditorPropertyTilePolygon::setup_multiple_mode(const StringName &p_propert REditorPropertyTilePolygon::REditorPropertyTilePolygon() { // Setup the polygon editor. - generic_tile_polygon_editor = memnew(GenericTilePolygonEditor); + generic_tile_polygon_editor = memnew(RGenericTilePolygonEditor); generic_tile_polygon_editor->set_use_undo_redo(false); generic_tile_polygon_editor->clear_polygons(); add_child(generic_tile_polygon_editor); diff --git a/tile_editor/tile_set_atlas_source_editor.h b/tile_editor/tile_set_atlas_source_editor.h index 9dc029c..b131f2b 100644 --- a/tile_editor/tile_set_atlas_source_editor.h +++ b/tile_editor/tile_set_atlas_source_editor.h @@ -226,8 +226,8 @@ private: PopupMenu *base_tile_popup_menu; PopupMenu *empty_base_tile_popup_menu; - Ref resize_handle; - Ref resize_handle_disabled; + Ref resize_handle; + Ref resize_handle_disabled; Control *tile_atlas_control; Control *tile_atlas_control_unscaled; void _tile_atlas_control_draw(); diff --git a/tile_editor/tile_set_editor.cpp b/tile_editor/tile_set_editor.cpp index 80cf875..bed0e8a 100644 --- a/tile_editor/tile_set_editor.cpp +++ b/tile_editor/tile_set_editor.cpp @@ -55,7 +55,7 @@ void RTileSetEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Dictionary d = p_data; Vector files = d["files"]; for (int i = 0; i < files.size(); i++) { - Ref resource = ResourceLoader::load(files[i]); + Ref resource = ResourceLoader::load(files[i]); if (resource.is_valid()) { // Retrieve the id for the next created source. source_id = tile_set->get_next_source_id(); @@ -91,7 +91,7 @@ bool RTileSetEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_d return false; } - // Check if we have a Texture2D. + // Check if we have a Texture. if (String(d["type"]) == "files") { Vector files = d["files"]; @@ -103,7 +103,7 @@ bool RTileSetEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_d String file = files[i]; String ftype = EditorFileSystem::get_singleton()->get_file_type(file); - if (!ClassDB::is_parent_class(ftype, "Texture2D")) { + if (!ClassDB::is_parent_class(ftype, "Texture")) { return false; } } @@ -142,7 +142,7 @@ void RTileSetEditor::_update_sources_list(int force_selected_id) { TileSetSource *source = *tile_set->get_source(source_id); - Ref texture; + Ref texture; String item_text; // Common to all type of sources. @@ -352,7 +352,7 @@ void RTileSetEditor::_patterns_item_list_gui_input(const Ref &p_even } } -void RTileSetEditor::_pattern_preview_done(Ref p_pattern, Ref p_texture) { +void RTileSetEditor::_pattern_preview_done(Ref p_pattern, Ref p_texture) { // TODO optimize ? for (int i = 0; i < patterns_item_list->get_item_count(); i++) { if (patterns_item_list->get_item_metadata(i) == p_pattern) { diff --git a/tile_editor/tile_set_editor.h b/tile_editor/tile_set_editor.h index d0d908b..6949c38 100644 --- a/tile_editor/tile_set_editor.h +++ b/tile_editor/tile_set_editor.h @@ -69,7 +69,7 @@ private: MenuButton *sources_add_button; MenuButton *sources_advanced_menu_button; ItemList *sources_list; - Ref missing_texture_texture; + Ref missing_texture_texture; void _source_selected(int p_source_index); void _source_delete_pressed(); void _source_add_id_pressed(int p_id_pressed); @@ -82,7 +82,7 @@ private: ItemList *patterns_item_list; Label *patterns_help_label; void _patterns_item_list_gui_input(const Ref &p_event); - void _pattern_preview_done(Ref p_pattern, Ref p_texture); + void _pattern_preview_done(Ref p_pattern, Ref p_texture); bool select_last_pattern = false; void _update_patterns_list(); diff --git a/tile_editor/tile_set_scenes_collection_source_editor.cpp b/tile_editor/tile_set_scenes_collection_source_editor.cpp index 4ebd9eb..0a04cd0 100644 --- a/tile_editor/tile_set_scenes_collection_source_editor.cpp +++ b/tile_editor/tile_set_scenes_collection_source_editor.cpp @@ -216,7 +216,7 @@ void RTileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_ch tile_set_scenes_collection_source_changed_needs_update = true; } -void RTileSetScenesCollectionSourceEditor::_scene_thumbnail_done(const String &p_path, const Ref &p_preview, const Ref &p_small_preview, Variant p_ud) { +void RTileSetScenesCollectionSourceEditor::_scene_thumbnail_done(const String &p_path, const Ref &p_preview, const Ref &p_small_preview, Variant p_ud) { int index = p_ud; if (index >= 0 && index < scene_tiles_list->get_item_count()) { @@ -420,7 +420,7 @@ bool RTileSetScenesCollectionSourceEditor::_can_drop_data_fw(const Point2 &p_poi return false; } - // Check if we have a Texture2D. + // Check if we have a Texture. if (String(d["type"]) == "files") { Vector files = d["files"]; diff --git a/tile_editor/tile_set_scenes_collection_source_editor.h b/tile_editor/tile_set_scenes_collection_source_editor.h index 5b75019..ce104ef 100644 --- a/tile_editor/tile_set_scenes_collection_source_editor.h +++ b/tile_editor/tile_set_scenes_collection_source_editor.h @@ -113,7 +113,7 @@ private: void _tile_set_scenes_collection_source_changed(); void _scenes_collection_source_proxy_object_changed(String p_what); - void _scene_thumbnail_done(const String &p_path, const Ref &p_preview, const Ref &p_small_preview, Variant p_ud); + void _scene_thumbnail_done(const String &p_path, const Ref &p_preview, const Ref &p_small_preview, Variant p_ud); void _scenes_list_item_activated(int p_index); void _source_add_pressed();