From cb18c8d7f080bb065fd632c73e35e77fdbaa9809 Mon Sep 17 00:00:00 2001 From: Albin Johansson Date: Sat, 5 Oct 2024 15:59:32 +0200 Subject: [PATCH] Add Godot scene format class --- source/godot_tscn_format/lib/CMakeLists.txt | 2 ++ .../godot_tscn_format/godot_scene_format.hpp | 35 +++++++++++++++++++ .../lib/src/godot_scene_format.cpp | 27 ++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 source/godot_tscn_format/lib/inc/tactile/godot_tscn_format/godot_scene_format.hpp create mode 100644 source/godot_tscn_format/lib/src/godot_scene_format.cpp diff --git a/source/godot_tscn_format/lib/CMakeLists.txt b/source/godot_tscn_format/lib/CMakeLists.txt index 173578913f..7970b44f7c 100644 --- a/source/godot_tscn_format/lib/CMakeLists.txt +++ b/source/godot_tscn_format/lib/CMakeLists.txt @@ -7,6 +7,7 @@ target_sources(tactile-godot-tscn-format PRIVATE "src/gd3_document_converter.cpp" "src/gd3_scene_writer.cpp" + "src/godot_scene_format.cpp" "src/godot_tscn_format_plugin.cpp" PUBLIC FILE_SET "HEADERS" BASE_DIRS "inc" FILES @@ -14,6 +15,7 @@ target_sources(tactile-godot-tscn-format "inc/tactile/godot_tscn_format/gd3_document_converter.hpp" "inc/tactile/godot_tscn_format/gd3_scene_writer.hpp" "inc/tactile/godot_tscn_format/gd3_types.hpp" + "inc/tactile/godot_tscn_format/godot_scene_format.hpp" "inc/tactile/godot_tscn_format/godot_tscn_format_plugin.hpp" ) diff --git a/source/godot_tscn_format/lib/inc/tactile/godot_tscn_format/godot_scene_format.hpp b/source/godot_tscn_format/lib/inc/tactile/godot_tscn_format/godot_scene_format.hpp new file mode 100644 index 0000000000..ceb1b956d5 --- /dev/null +++ b/source/godot_tscn_format/lib/inc/tactile/godot_tscn_format/godot_scene_format.hpp @@ -0,0 +1,35 @@ +// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0) + +#pragma once + +#include "tactile/base/io/save/save_format.hpp" +#include "tactile/base/runtime.hpp" +#include "tactile/godot_tscn_format/api.hpp" + +namespace tactile::godot { + +/** + * Provides support for the scene format used by the Godot game engine. + * + * \see https://docs.godotengine.org/en/stable/contributing/development/file_formats/tscn.html + * \see https://docs.godotengine.org/en/3.6/development/file_formats/tscn.html + */ +class TACTILE_GODOT_API GodotSceneFormat final : public ISaveFormat +{ + public: + explicit GodotSceneFormat(IRuntime* runtime); + + [[nodiscard]] + auto load_map(const std::filesystem::path& map_path, + const SaveFormatReadOptions& options) const + -> std::expected override; + + [[nodiscard]] + auto save_map(const IMapView& map, const SaveFormatWriteOptions& options) const + -> std::expected override; + + private: + IRuntime* m_runtime; +}; + +} // namespace tactile::godot diff --git a/source/godot_tscn_format/lib/src/godot_scene_format.cpp b/source/godot_tscn_format/lib/src/godot_scene_format.cpp new file mode 100644 index 0000000000..39c68e7312 --- /dev/null +++ b/source/godot_tscn_format/lib/src/godot_scene_format.cpp @@ -0,0 +1,27 @@ +// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0) + +#include "tactile/godot_tscn_format/godot_scene_format.hpp" + +#include // make_error_code, errc + +namespace tactile::godot { + +GodotSceneFormat::GodotSceneFormat(IRuntime* runtime) + : m_runtime {runtime} +{} + +auto GodotSceneFormat::load_map(const std::filesystem::path& map_path, + const SaveFormatReadOptions& options) const + -> std::expected +{ + return std::unexpected {std::make_error_code(std::errc::not_supported)}; +} + +auto GodotSceneFormat::save_map(const IMapView& map, + const SaveFormatWriteOptions& options) const + -> std::expected +{ + return std::unexpected {std::make_error_code(std::errc::not_supported)}; +} + +} // namespace tactile::godot