More work.

This commit is contained in:
Relintai 2021-12-11 20:07:58 +01:00
parent e801ee260d
commit dea8f85cbc
17 changed files with 410 additions and 410 deletions

View File

@ -39,7 +39,7 @@ void RAtlasMergingDialog::_property_changed(const StringName &p_property, const
_set(p_property, p_value);
}
void RAtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atlas_sources, int p_max_columns) {
void RAtlasMergingDialog::_generate_merged(Vector<Ref<RTileSetAtlasSource>> p_atlas_sources, int p_max_columns) {
merged.instantiate();
merged_mapping.clear();
@ -51,15 +51,15 @@ void RAtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> 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<TileSetAtlasSource> atlas_source = p_atlas_sources[source_index];
Ref<RTileSetAtlasSource> 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<TileSetAtlasSource> atlas_source = p_atlas_sources[source_index];
Ref<RTileSetAtlasSource> atlas_source = p_atlas_sources[source_index];
merged_mapping.push_back(Map<Vector2i, Vector2i>());
// Layout the tiles.
@ -127,7 +127,7 @@ void RAtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atl
void RAtlasMergingDialog::_update_texture() {
Vector<int> selected = atlas_merging_atlases_list->get_selected_items();
if (selected.size() >= 2) {
Vector<Ref<TileSetAtlasSource>> to_merge;
Vector<Ref<RTileSetAtlasSource>> 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<Ref<TileSetAtlasSource>>(), next_line_after_column);
_generate_merged(Vector<Ref<RTileSetAtlasSource>>(), next_line_after_column);
preview->set_texture(Ref<Texture2D>());
preview->hide();
select_2_atlases_label->show();
@ -157,7 +157,7 @@ void RAtlasMergingDialog::_merge_confirmed(String p_path) {
Ref<Texture2D> 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<int> 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<TileSetAtlasSource> tas = tile_set->get_source(source_id);
Ref<RTileSetAtlasSource> 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<TileSet> p_tile_set) {
void RAtlasMergingDialog::update_tile_set(Ref<RTileSet> 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<TileSetAtlasSource> atlas_source = p_tile_set->get_source(source_id);
Ref<RTileSetAtlasSource> atlas_source = p_tile_set->get_source(source_id);
if (atlas_source.is_valid()) {
Ref<Texture2D> texture = atlas_source->get_texture();
if (texture.is_valid()) {

View File

@ -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<TileSetAtlasSource> merged;
Ref<RTileSetAtlasSource> merged;
LocalVector<Map<Vector2i, Vector2i>> merged_mapping;
Ref<TileSet> tile_set;
Ref<RTileSet> 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<Ref<TileSetAtlasSource>> p_atlas_sources, int p_max_columns);
void _generate_merged(Vector<Ref<RTileSetAtlasSource>> 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<TileSet> p_tile_set);
void update_tile_set(Ref<RTileSet> p_tile_set);
RAtlasMergingDialog();
};

View File

@ -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<InputEvent> &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<InputEvent> &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<InputEvent> &p_event) {
Size2i RTileAtlasView::_compute_base_tiles_control_size() {
// Update the texture.
Vector2i size;
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
Ref<Texture> 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<Texture2D> texture = tile_set_atlas_source->get_texture();
Ref<Texture> 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<InputEvent> &p_event) {
@ -191,9 +191,9 @@ void RTileAtlasView::_base_tiles_root_control_gui_input(const Ref<InputEvent> &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<InputEvent> &p
}
void RTileAtlasView::_draw_base_tiles() {
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
Ref<Texture> 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<Texture2D> texture = tile_set_atlas_source->get_texture();
Ref<Texture> 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 Ref<InputEv
Vector3i coords3 = get_alternative_tile_at_pos(xform.xform(mm->get_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<InputEv
void RTileAtlasView::_draw_alternatives() {
// Draw the alternative tiles.
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
Ref<Texture> 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<Texture2D> texture = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons"));
Ref<Texture> 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<Texture2D> texture = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons"));
Ref<Texture> 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<Texture2D> texture = tile_set_atlas_source->get_texture();
Ref<Texture> 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) {

View File

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

View File

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

View File

@ -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<TileSet> tile_set;
Ref<RTileSet> tile_set;
TileData *_get_tile_data(TileMapCell p_cell);
virtual void _tile_set_changed(){};
static void _bind_methods();
public:
void set_tile_set(Ref<TileSet> p_tile_set);
void set_tile_set(Ref<RTileSet> 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<InputEvent> &p_event){};
virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &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<InputEvent> &p_event){};
virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &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<TileSet> tile_set;
Ref<RTileSet> tile_set;
LocalVector<Vector<Point2>> 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<TileSet> p_tile_set);
void set_tile_set(Ref<RTileSet> p_tile_set);
void set_background(Ref<Texture2D> 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<TileMapCell, Variant> 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<TileMapCell, Variant> 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<InputEvent> &p_event) override;
virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &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<InputEvent> &p_event) override;
virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &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<TileMapCell, Variant> 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<TileMapCell, Variant> 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<TileMapCell, Variant> 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<TileMapCell, Variant> 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<InputEvent> &p_event) override;
virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &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<InputEvent> &p_event) override;
virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, RTileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &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<TileMapCell, Variant> 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<TileMapCell, Variant> p_previous_values, Variant p_new_value) override;
protected:
UndoRedo *undo_redo = EditorNode::get_undo_redo();

File diff suppressed because it is too large Load Diff

View File

@ -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<Vector2i, TileMapCell> drag_modified;
// Painting
Map<Vector2i, TileMapCell> _draw_terrains(const Map<Vector2i, TileSet::TerrainsPattern> &p_to_paint, int p_terrain_set) const;
Map<Vector2i, TileMapCell> _draw_terrains(const Map<Vector2i, RTileSet::TerrainsPattern> &p_to_paint, int p_terrain_set) const;
Map<Vector2i, TileMapCell> _draw_line(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase);
Map<Vector2i, TileMapCell> _draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase);
Set<Vector2i> _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<LocalVector<Set<TileSet::TerrainsPattern>>> per_terrain_terrains_patterns;
LocalVector<LocalVector<Set<RTileSet::TerrainsPattern>>> 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<InputEvent> &p_event);

View File

@ -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<TileSet> p_tile_set) {
void RTileProxiesManagerDialog::update_tile_set(Ref<RTileSet> p_tile_set) {
ERR_FAIL_COND(!p_tile_set.is_valid());
tile_set = p_tile_set;
commited_actions_count = 0;

View File

@ -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<TileSet> tile_set;
Ref<RTileSet> 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<TileSet> p_tile_set);
void update_tile_set(Ref<RTileSet> p_tile_set);
RTileProxiesManagerDialog();
};

View File

@ -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<PropertyInfo> *p_list) const {
void RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::_get_property_list(List<PropertyInfo> *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<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
void RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::edit(Ref<RTileSet> 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<Pr
}
}
void RTileSetAtlasSourceEditor::AtlasTileProxyObject::edit(TileSetAtlasSource *p_tile_set_atlas_source, Set<TileSelection> p_tiles) {
void RTileSetAtlasSourceEditor::AtlasTileProxyObject::edit(RTileSetAtlasSource *p_tile_set_atlas_source, Set<TileSelection> p_tiles) {
ERR_FAIL_COND(!p_tile_set_atlas_source);
ERR_FAIL_COND(p_tiles.is_empty());
for (Set<TileSelection>::Element *E = p_tiles.front(); E; E = E->next()) {
ERR_FAIL_COND(E->get().tile == TileSetSource::INVALID_ATLAS_COORDS);
ERR_FAIL_COND(E->get().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 Ref<InputEve
if (selection.size() == 1) {
// Change the cursor depending on the hovered thing.
TileSelection selected = selection.front()->get();
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<InputEve
Vector<Point2i> 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<InputEve
Vector<Point2i> 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 Ref<InputEve
// Remove a first tile.
Vector2i coords = tile_atlas_view->get_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 Ref<InputEve
if (mb->is_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 Ref<InputEve
// Create a first tile if needed.
Vector2i coords = tile_atlas_view->get_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 Ref<InputEve
drag_type = DRAG_TYPE_NONE;
if (selection.size() == 1) {
TileSelection selected = selection.front()->get();
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 Ref<InputEve
// Selecting then dragging a tile.
if (drag_type == DRAG_TYPE_NONE) {
TileSelection selected = { TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE };
TileSelection selected = { RTileSetSource::INVALID_ATLAS_COORDS, RTileSetSource::INVALID_TILE_ALTERNATIVE };
Vector2i coords = tile_atlas_view->get_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<Vector2i, List<const PropertyInfo *>> RTileSetAtlasSourceEditor::_group_properties_per_tiles(const List<PropertyInfo> &r_list, const TileSetAtlasSource *p_atlas) {
Map<Vector2i, List<const PropertyInfo *>> RTileSetAtlasSourceEditor::_group_properties_per_tiles(const List<PropertyInfo> &r_list, const RTileSetAtlasSource *p_atlas) {
// Group properties per tile.
Map<Vector2i, List<const PropertyInfo *>> per_tile;
for (const List<PropertyInfo>::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 Ref<I
selection.clear();
TileSelection selected = { Vector2i(tile.x, tile.y), int(tile.z) };
if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS) {
if (selected.tile != RTileSetSource::INVALID_ATLAS_COORDS) {
selection.insert(selected);
}
@ -1915,7 +1915,7 @@ void RTileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const Ref<I
selection.clear();
TileSelection selected = { Vector2i(tile.x, tile.y), int(tile.z) };
if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS) {
if (selected.tile != RTileSetSource::INVALID_ATLAS_COORDS) {
selection.insert(selected);
}
@ -1938,7 +1938,7 @@ void RTileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const Ref<I
}
void RTileSetAtlasSourceEditor::_tile_alternatives_control_mouse_exited() {
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);
tile_atlas_control->update();
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<TileSetAtlasSourceProxyObject>(p_edited);
RTileSetAtlasSourceProxyObject *atlas_source_proxy = Object::cast_to<RTileSetAtlasSourceProxyObject>(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<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
void RTileSetAtlasSourceEditor::edit(Ref<RTileSet> 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<TileSet>(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<RTileSet>(tile_set_atlas_source->get_tile_set()));
// Set the background
Vector2i coords = atlas_tile_proxy_object->get_edited_tiles().front()->get().tile;

View File

@ -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<TileSet> tile_set;
TileSetAtlasSource *tile_set_atlas_source = nullptr;
int source_id = TileSet::INVALID_SOURCE;
Ref<RTileSet> 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<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id);
TileSetAtlasSource *get_edited() { return tile_set_atlas_source; };
void edit(Ref<RTileSet> 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<TileSelection> tiles = Set<TileSelection>();
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<TileSelection> get_edited_tiles() const { return tiles; };
// Update the proxyed object.
void edit(TileSetAtlasSource *p_tile_set_atlas_source, Set<TileSelection> p_tiles = Set<TileSelection>());
void edit(RTileSetAtlasSource *p_tile_set_atlas_source, Set<TileSelection> p_tiles = Set<TileSelection>());
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<TileSet> tile_set;
TileSetAtlasSource *tile_set_atlas_source = nullptr;
int tile_set_atlas_source_id = TileSet::INVALID_SOURCE;
Ref<RTileSet> 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<Vector2i> drag_modified_tiles;
void _end_dragging();
Map<Vector2i, List<const PropertyInfo *>> _group_properties_per_tiles(const List<PropertyInfo> &r_list, const TileSetAtlasSource *p_atlas);
Map<Vector2i, List<const PropertyInfo *>> _group_properties_per_tiles(const List<PropertyInfo> &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<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_source, int p_source_id);
void edit(Ref<RTileSet> p_tile_set, RTileSetAtlasSource *p_tile_set_source, int p_source_id);
void init_source();
RTileSetAtlasSourceEditor();

View File

@ -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<TileSet> tile_set;
Ref<RTileSet> tile_set;
bool tile_set_changed_needs_update = false;
HSplitContainer *split_container;

View File

@ -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<PropertyInfo> *p_list) const {
void RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionProxyObject::_get_property_list(List<PropertyInfo> *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<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) {
void RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionProxyObject::edit(Ref<RTileSet> 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<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) {
void RTileSetScenesCollectionSourceEditor::edit(Ref<RTileSet> 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);

View File

@ -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<TileSet> tile_set;
Ref<RTileSet> 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<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id);
void edit(Ref<RTileSet> 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<TileSet> tile_set;
Ref<RTileSet> 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<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id);
void edit(Ref<RTileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id);
RTileSetScenesCollectionSourceEditor();
~RTileSetScenesCollectionSourceEditor();
};

View File

@ -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<TileSetAtlasSource> atlas_source = tile_set->get_source(tile_map->get_cell_source_id(0, cell));
Ref<RTileSetAtlasSource> 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<TileSet> p_tile_set, Ref<TileMapPattern> p_pattern, Callable p_callback) {
void RTilesEditorPlugin::queue_pattern_preview(Ref<RTileSet> p_tile_set, Ref<TileMapPattern> 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<TileSet>();
tile_set = Ref<RTileSet>();
if (p_object) {
if (p_object->is_class("TileMap")) {
tile_map_id = p_object->get_instance_id();
tile_map = Object::cast_to<TileMap>(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<TileSet>(p_object);
} else if (p_object->is_class("RTileSet")) {
tile_set = Ref<RTileSet>(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();

View File

@ -48,13 +48,13 @@ private:
bool tile_map_changed_needs_update = false;
ObjectID tile_map_id;
Ref<TileSet> tile_set;
Ref<RTileSet> 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<TileSet> tile_set;
Ref<RTileSet> tile_set;
Ref<TileMapPattern> 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<TileSet> p_tile_set, Ref<TileMapPattern> p_pattern, Callable p_callback);
void queue_pattern_preview(Ref<RTileSet> p_tile_set, Ref<TileMapPattern> p_pattern, Callable p_callback);
// To synchronize the atlas sources lists.
void set_sources_lists_current(int p_current);