Skip to content

Commit

Permalink
Add Godot scene format class
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Oct 5, 2024
1 parent 6b3b092 commit cb18c8d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source/godot_tscn_format/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ 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
"inc/tactile/godot_tscn_format/api.hpp"
"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"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -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<ir::Map, std::error_code> override;

[[nodiscard]]
auto save_map(const IMapView& map, const SaveFormatWriteOptions& options) const
-> std::expected<void, std::error_code> override;

private:
IRuntime* m_runtime;
};

} // namespace tactile::godot
27 changes: 27 additions & 0 deletions source/godot_tscn_format/lib/src/godot_scene_format.cpp
Original file line number Diff line number Diff line change
@@ -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 <system_error> // 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<ir::Map, std::error_code>
{
return std::unexpected {std::make_error_code(std::errc::not_supported)};
}

auto GodotSceneFormat::save_map(const IMapView& map,
const SaveFormatWriteOptions& options) const
-> std::expected<void, std::error_code>
{
return std::unexpected {std::make_error_code(std::errc::not_supported)};
}

} // namespace tactile::godot

0 comments on commit cb18c8d

Please sign in to comment.