From 1bfd582b7b7f762011f5f4b7f84e180cf20e9046 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Thu, 12 Dec 2024 19:35:19 +0100 Subject: shielded mediator --- src/crepe/api/Scene.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/crepe/api/Scene.hpp (limited to 'src/crepe/api/Scene.hpp') diff --git a/src/crepe/api/Scene.hpp b/src/crepe/api/Scene.hpp new file mode 100644 index 0000000..d0ada65 --- /dev/null +++ b/src/crepe/api/Scene.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "Scene.h" +#include "../util/Log.h" + +namespace crepe { + +template +void Scene::logf(Args &&... args) { + Log::logf(std::forward(args)...); +} + +} -- cgit v1.2.3 From c9a093dfb670e29fb92cfd75938aa8f293a0767a Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Thu, 12 Dec 2024 19:37:10 +0100 Subject: format --- src/crepe/api/Scene.h | 15 +++++---------- src/crepe/api/Scene.hpp | 4 ++-- 2 files changed, 7 insertions(+), 12 deletions(-) (limited to 'src/crepe/api/Scene.hpp') diff --git a/src/crepe/api/Scene.h b/src/crepe/api/Scene.h index a1e5cfe..6ee1f68 100644 --- a/src/crepe/api/Scene.h +++ b/src/crepe/api/Scene.h @@ -2,9 +2,9 @@ #include +#include "../manager/ComponentManager.h" #include "../manager/Mediator.h" #include "../manager/ResourceManager.h" -#include "../manager/ComponentManager.h" #include "../util/OptionalRef.h" #include "GameObject.h" @@ -59,15 +59,12 @@ private: OptionalRef mediator; protected: - /** * \brief Retrieve the reference to the SaveManager instance * * \returns A reference to the SaveManager instance held by the Mediator. */ - SaveManager& get_save_manager() const{ - return mediator->save_manager; - } + SaveManager & get_save_manager() const { return mediator->save_manager; } /** * \brief Create a new game object using the component manager @@ -83,8 +80,8 @@ protected: * \note This method automatically assigns a new entity ID */ GameObject new_object(const std::string & name, const std::string & tag = "", - const vec2 & position = {0, 0}, double rotation = 0, - double scale = 1) { + const vec2 & position = {0, 0}, double rotation = 0, + double scale = 1) { // Forward the call to ComponentManager's new_object method return mediator->component_manager->new_object(name, tag, position, rotation, scale); } @@ -95,7 +92,7 @@ protected: * \param asset Asset the concrete resource is instantiated from * \param persistent Whether this resource is persistent (true=keep, false=destroy) */ - void set_persistent(const Asset & asset, bool persistent){ + void set_persistent(const Asset & asset, bool persistent) { mediator->resource_manager->set_persistent(asset, persistent); } @@ -107,10 +104,8 @@ protected: */ template void logf(Args &&... args); - }; } // namespace crepe - #include "Scene.hpp" diff --git a/src/crepe/api/Scene.hpp b/src/crepe/api/Scene.hpp index d0ada65..58aacb6 100644 --- a/src/crepe/api/Scene.hpp +++ b/src/crepe/api/Scene.hpp @@ -1,7 +1,7 @@ #pragma once -#include "Scene.h" #include "../util/Log.h" +#include "Scene.h" namespace crepe { @@ -10,4 +10,4 @@ void Scene::logf(Args &&... args) { Log::logf(std::forward(args)...); } -} +} // namespace crepe -- cgit v1.2.3 From 5f09a71b433e01a9dc17f93c5d9f79117cef618e Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Thu, 12 Dec 2024 19:38:17 +0100 Subject: fixed includes --- src/crepe/api/Scene.h | 1 + src/crepe/api/Scene.hpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/crepe/api/Scene.hpp') diff --git a/src/crepe/api/Scene.h b/src/crepe/api/Scene.h index a1e5cfe..cb8147f 100644 --- a/src/crepe/api/Scene.h +++ b/src/crepe/api/Scene.h @@ -6,6 +6,7 @@ #include "../manager/ResourceManager.h" #include "../manager/ComponentManager.h" #include "../util/OptionalRef.h" + #include "GameObject.h" namespace crepe { diff --git a/src/crepe/api/Scene.hpp b/src/crepe/api/Scene.hpp index d0ada65..b0ef392 100644 --- a/src/crepe/api/Scene.hpp +++ b/src/crepe/api/Scene.hpp @@ -1,8 +1,9 @@ #pragma once -#include "Scene.h" #include "../util/Log.h" +#include "Scene.h" + namespace crepe { template -- cgit v1.2.3 From 1cce3f1456f9df143d700d3ac37fcfd318577a36 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Thu, 12 Dec 2024 19:39:01 +0100 Subject: removed merge include --- src/crepe/api/Scene.hpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/crepe/api/Scene.hpp') diff --git a/src/crepe/api/Scene.hpp b/src/crepe/api/Scene.hpp index ee89981..ecb21ed 100644 --- a/src/crepe/api/Scene.hpp +++ b/src/crepe/api/Scene.hpp @@ -1,7 +1,6 @@ #pragma once #include "../util/Log.h" -#include "Scene.h" #include "Scene.h" -- cgit v1.2.3 From 128e7975eb6417438fcf6f51224b6067554a2004 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Fri, 13 Dec 2024 18:43:12 +0100 Subject: added feedback --- src/crepe/api/Scene.cpp | 5 +++++ src/crepe/api/Scene.h | 38 +++++++++++++++----------------------- src/crepe/api/Scene.hpp | 11 ++++++++--- 3 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 src/crepe/api/Scene.cpp (limited to 'src/crepe/api/Scene.hpp') diff --git a/src/crepe/api/Scene.cpp b/src/crepe/api/Scene.cpp new file mode 100644 index 0000000..5117766 --- /dev/null +++ b/src/crepe/api/Scene.cpp @@ -0,0 +1,5 @@ +#include "Scene.h" + +using namespace crepe; + +SaveManager & Scene::get_save_manager() const { return mediator->save_manager; } diff --git a/src/crepe/api/Scene.h b/src/crepe/api/Scene.h index 1203612..cba4e10 100644 --- a/src/crepe/api/Scene.h +++ b/src/crepe/api/Scene.h @@ -6,6 +6,7 @@ #include "../manager/Mediator.h" #include "../manager/ResourceManager.h" #include "../util/OptionalRef.h" +#include "../util/Log.h" #include "GameObject.h" @@ -65,20 +66,10 @@ protected: * * \returns A reference to the SaveManager instance held by the Mediator. */ - SaveManager & get_save_manager() const { return mediator->save_manager; } + SaveManager & get_save_manager() const; /** - * \brief Create a new game object using the component manager - * - * \param name Metadata::name (required) - * \param tag Metadata::tag (optional, empty by default) - * \param position Transform::position (optional, origin by default) - * \param rotation Transform::rotation (optional, 0 by default) - * \param scale Transform::scale (optional, 1 by default) - * - * \returns GameObject interface - * - * \note This method automatically assigns a new entity ID + * \copydoc ComponentManager::new_object */ GameObject new_object(const std::string & name, const std::string & tag = "", const vec2 & position = {0, 0}, double rotation = 0, @@ -88,23 +79,24 @@ protected: } /** - * \brief Mark a resource as persistent (i.e. used across multiple scenes) - * - * \param asset Asset the concrete resource is instantiated from - * \param persistent Whether this resource is persistent (true=keep, false=destroy) + * \copydoc ResourceManager::set_persistent */ void set_persistent(const Asset & asset, bool persistent) { mediator->resource_manager->set_persistent(asset, persistent); } /** - * \brief Log a message using Log::logf - * - * \tparam Args Log::logf parameters - * \param args Log::logf parameters - */ - template - void logf(Args &&... args); + * \name Logging functions + * \see Log + * \{ + */ + //! \copydoc Log::logf + template + void logf(const Log::Level & level, std::format_string fmt, Args &&... args); + //! \copydoc Log::logf + template + void logf(std::format_string fmt, Args &&... args); + //! \} }; } // namespace crepe diff --git a/src/crepe/api/Scene.hpp b/src/crepe/api/Scene.hpp index ecb21ed..14635df 100644 --- a/src/crepe/api/Scene.hpp +++ b/src/crepe/api/Scene.hpp @@ -6,9 +6,14 @@ namespace crepe { -template -void Scene::logf(Args &&... args) { - Log::logf(std::forward(args)...); +template +void Scene::logf(const Log::Level & level, std::format_string fmt, Args &&... args) { + Log::logf(level, fmt, std::forward(args)...); +} + +template +void Scene::logf(std::format_string fmt, Args &&... args) { + Log::logf(fmt, std::forward(args)...); } } // namespace crepe -- cgit v1.2.3