From 97a48f45742aa2e89a2b714bbe061134351d7d9a Mon Sep 17 00:00:00 2001 From: Albin Johansson Date: Mon, 7 Oct 2024 22:09:57 +0200 Subject: [PATCH] Fix tileset generation --- .../tactile/godot_tscn_format/gd3_types.hpp | 1 - .../lib/src/gd3_document_converter.cpp | 1 - .../lib/src/gd3_exporter.cpp | 20 +++++++++---------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/source/godot_tscn_format/lib/inc/tactile/godot_tscn_format/gd3_types.hpp b/source/godot_tscn_format/lib/inc/tactile/godot_tscn_format/gd3_types.hpp index 6d305ebc5d..a18674a2b8 100644 --- a/source/godot_tscn_format/lib/inc/tactile/godot_tscn_format/gd3_types.hpp +++ b/source/godot_tscn_format/lib/inc/tactile/godot_tscn_format/gd3_types.hpp @@ -170,7 +170,6 @@ struct Gd3Map final { Gd3Metadata meta; Gd3Resources resources; - ExtResourceId tileset_id; Int2 tile_size; Gd3Tileset tileset; std::vector layers; diff --git a/source/godot_tscn_format/lib/src/gd3_document_converter.cpp b/source/godot_tscn_format/lib/src/gd3_document_converter.cpp index e90fe42c8d..d91ce547f0 100644 --- a/source/godot_tscn_format/lib/src/gd3_document_converter.cpp +++ b/source/godot_tscn_format/lib/src/gd3_document_converter.cpp @@ -267,7 +267,6 @@ auto Gd3DocumentConverter::visit(const IMapView& map) -> std::expected(layer.value); writer.newline() .node_header(layer.name, "TileMap", layer.parent) - .ext_resource_variable("tile_set", tileset_id) + .sub_resource_variable("tile_set", tileset_id) .variable("visible", layer.visible) .vector2_variable("cell_size", tile_layer.cell_size) .color_variable("modulate", FColor {1, 1, 1, layer.opacity}) @@ -367,12 +367,12 @@ void _emit_object_layer(Gd3SceneWriter& writer, const Gd3Layer& layer) void _emit_layer(Gd3SceneWriter& writer, const Gd3Layer& layer, - ExtResourceId tileset_id, + SubResourceId tileset_id, SubResourceId sprite_frames_id); void _emit_group_layer(Gd3SceneWriter& writer, const Gd3Layer& layer, - const ExtResourceId tileset_id, + const SubResourceId tileset_id, const SubResourceId sprite_frames_id) { const auto& group_layer = std::get(layer.value); @@ -391,7 +391,7 @@ void _emit_group_layer(Gd3SceneWriter& writer, void _emit_layer(Gd3SceneWriter& writer, const Gd3Layer& layer, - const ExtResourceId tileset_id, + const SubResourceId tileset_id, const SubResourceId sprite_frames_id) { switch (layer.value.index()) { @@ -467,15 +467,15 @@ auto _emit_map_file(const Gd3Map& map, const SaveFormatWriteOptions& options) -> _emit_metadata(writer, map.meta); for (const auto& layer : map.layers) { - _emit_layer(writer, layer, map.tileset_id, map.sprite_frames.id); + _emit_layer(writer, layer, map.tileset.id, map.sprite_frames.id); } return kOK; } [[nodiscard]] -auto _save_tileset_images(const Gd3Tileset& tileset, - const SaveFormatWriteOptions& options) -> Result +auto _save_tileset_images(const Gd3Tileset& tileset, const SaveFormatWriteOptions& options) + -> Result { for (const auto& tile_atlas : tileset.atlases) { const auto dest = options.base_dir / tile_atlas.image_path.filename(); // FIXME @@ -501,8 +501,8 @@ auto _save_tileset_images(const Gd3Tileset& tileset, } // namespace -auto save_godot3_scene(const Gd3Map& map, - const SaveFormatWriteOptions& options) -> Result +auto save_godot3_scene(const Gd3Map& map, const SaveFormatWriteOptions& options) + -> Result { return _save_tileset_images(map.tileset, options).and_then([&] { return _emit_map_file(map, options);