Skip to content

Commit

Permalink
Rename Godot scene format plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Oct 5, 2024
1 parent b8ff4a7 commit 5921f80
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 39 deletions.
4 changes: 2 additions & 2 deletions source/godot_tscn_format/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ target_sources(tactile-godot-tscn-format
"src/gd3_document_converter.cpp"
"src/gd3_scene_writer.cpp"
"src/godot_scene_format.cpp"
"src/godot_tscn_format_plugin.cpp"
"src/godot_scene_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"
"inc/tactile/godot_tscn_format/godot_scene_format_plugin.hpp"
)

tactile_prepare_target(tactile-godot-tscn-format)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@

#pragma once

#include <memory> // unique_ptr

#include "tactile/base/prelude.hpp"
#include "tactile/godot_tscn_format/api.hpp"
#include "tactile/godot_tscn_format/godot_scene_format.hpp"
#include "tactile/runtime/plugin.hpp"

namespace tactile {
namespace tactile::godot {

class TACTILE_GODOT_API GodotTscnFormatPlugin final : public IPlugin
class TACTILE_GODOT_API GodotSceneFormatPlugin final : public IPlugin
{
public:
void load(IRuntime* runtime) override;

void unload() override;

private:
IRuntime* mRuntime {};
IRuntime* m_runtime {};
std::unique_ptr<GodotSceneFormat> m_format {};
};

extern "C"
Expand All @@ -25,4 +29,4 @@ extern "C"
TACTILE_GODOT_API void tactile_free_plugin(IPlugin* plugin);
}

} // namespace tactile
} // namespace tactile::godot
41 changes: 41 additions & 0 deletions source/godot_tscn_format/lib/src/godot_scene_format_plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0)

#include "tactile/godot_tscn_format/godot_scene_format_plugin.hpp"

#include <new> // nothrow

#include "tactile/base/runtime.hpp"
#include "tactile/runtime/logging.hpp"

namespace tactile::godot {

void GodotSceneFormatPlugin::load(IRuntime* runtime)
{
log(LogLevel::kTrace, "Loading Godot TSCN format plugin");
m_runtime = runtime;

m_format = std::make_unique<GodotSceneFormat>(m_runtime);
m_runtime->set_save_format(SaveFormatId::kGodotTscn, m_format.get());
}

void GodotSceneFormatPlugin::unload()
{
log(LogLevel::kTrace, "Unloading Godot TSCN format plugin");

m_runtime->set_save_format(SaveFormatId::kGodotTscn, nullptr);
m_format.reset();

m_runtime = nullptr;
}

auto tactile_make_plugin() -> IPlugin*
{
return new (std::nothrow) GodotSceneFormatPlugin {};
}

void tactile_free_plugin(IPlugin* plugin)
{
delete plugin;
}

} // namespace tactile::godot
33 changes: 0 additions & 33 deletions source/godot_tscn_format/lib/src/godot_tscn_format_plugin.cpp

This file was deleted.

0 comments on commit 5921f80

Please sign in to comment.