diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-05-22 00:26:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-22 00:26:36 +0200 |
commit | 3b3a55ca04331e85cc24ac315b60e7ad4aeb17df (patch) | |
tree | 41f05ec760eaa59bdd94921bb84872b124ee5626 /editor | |
parent | 2687ac2720efd500a6bac88de6f3dcf5dfa4d657 (diff) | |
parent | 7d80480b72ee63950d12f7accec8b87e96f2163a (diff) |
Merge pull request #48918 from groud/fix_tilemap_y_sort
Fixes TileSet Y-sort not working and TileSet not saving correctly
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/tiles/tile_data_editors.cpp | 17 | ||||
-rw-r--r-- | editor/plugins/tiles/tile_data_editors.h | 7 | ||||
-rw-r--r-- | editor/plugins/tiles/tile_set_editor.cpp | 7 | ||||
-rw-r--r-- | editor/plugins/tiles/tile_set_editor.h | 2 |
4 files changed, 29 insertions, 4 deletions
diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index d2665a3a2b..61457e3e59 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -113,7 +113,22 @@ void TileDataPositionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform ERR_FAIL_COND(value.get_type() != Variant::VECTOR2I && value.get_type() != Variant::VECTOR2); Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon("EditorPosition", "EditorIcons"); - p_canvas_item->draw_texture(position_icon, p_transform.get_origin() + Vector2(value) - position_icon->get_size() / 2); + p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(value)) - position_icon->get_size() / 2); +} + +void TileDataYSortEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) { + TileData *tile_data = _get_tile_data(p_tile_set, p_atlas_source_id, p_atlas_coords, p_alternative_tile); + ERR_FAIL_COND(!tile_data); + + bool valid; + Variant value = tile_data->get(p_property, &valid); + if (!valid) { + return; + } + ERR_FAIL_COND(value.get_type() != Variant::INT); + + Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon("EditorPosition", "EditorIcons"); + p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(0, value)) - position_icon->get_size() / 2); } void TileDataOcclusionShapeEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) { diff --git a/editor/plugins/tiles/tile_data_editors.h b/editor/plugins/tiles/tile_data_editors.h index f4f9c25157..b82189e1ee 100644 --- a/editor/plugins/tiles/tile_data_editors.h +++ b/editor/plugins/tiles/tile_data_editors.h @@ -79,6 +79,13 @@ public: virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) override; }; +class TileDataYSortEditor : public TileDataEditor { + GDCLASS(TileDataYSortEditor, TileDataEditor); + +public: + virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) override; +}; + class TileDataOcclusionShapeEditor : public TileDataEditor { GDCLASS(TileDataOcclusionShapeEditor, TileDataEditor); diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 05ebe408a5..6078c986cb 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -298,6 +298,9 @@ void TileSetEditor::_notification(int p_what) { break; case NOTIFICATION_INTERNAL_PROCESS: if (tile_set_changed_needs_update) { + if (tile_set.is_valid()) { + tile_set->set_edited(true); + } _update_atlas_sources_list(); tile_set_changed_needs_update = false; } @@ -445,7 +448,7 @@ TileDataEditor *TileSetEditor::get_tile_data_editor(String p_property) { } else if (p_property == "probability") { return tile_data_float_editor; } else if (p_property == "y_sort_origin") { - return tile_data_position_editor; + return tile_data_y_sort_editor; } else if (p_property == "texture_offset") { return tile_data_texture_offset_editor; } else if (components.size() >= 1 && components[0].begins_with("occlusion_layer_")) { @@ -575,7 +578,7 @@ TileSetEditor::~TileSetEditor() { // Delete tile data editors. memdelete(tile_data_texture_offset_editor); - memdelete(tile_data_position_editor); + memdelete(tile_data_y_sort_editor); memdelete(tile_data_integer_editor); memdelete(tile_data_float_editor); memdelete(tile_data_occlusion_shape_editor); diff --git a/editor/plugins/tiles/tile_set_editor.h b/editor/plugins/tiles/tile_set_editor.h index d508c04319..f584c043cc 100644 --- a/editor/plugins/tiles/tile_set_editor.h +++ b/editor/plugins/tiles/tile_set_editor.h @@ -56,7 +56,7 @@ private: // List of tile data editors. TileDataTextureOffsetEditor *tile_data_texture_offset_editor = memnew(TileDataTextureOffsetEditor); - TileDataPositionEditor *tile_data_position_editor = memnew(TileDataPositionEditor); + TileDataYSortEditor *tile_data_y_sort_editor = memnew(TileDataYSortEditor); TileDataIntegerEditor *tile_data_integer_editor = memnew(TileDataIntegerEditor); TileDataFloatEditor *tile_data_float_editor = memnew(TileDataFloatEditor); TileDataOcclusionShapeEditor *tile_data_occlusion_shape_editor = memnew(TileDataOcclusionShapeEditor); |