From 68fab7c94d61bf48a9caba7ad616aab5675ad325 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Mon, 2 Dec 2024 22:30:41 -0600 Subject: [PATCH] Bit of const cleanup --- src/dawn/component/CMakeLists.txt | 1 - src/dawn/component/SimpleComponent.cpp | 27 ------------------ src/dawn/component/SimpleComponent.hpp | 28 ------------------- src/dawn/component/display/Camera.cpp | 2 +- src/dawn/component/display/Camera.hpp | 4 +-- .../material/SimpleTexturedMaterial.cpp | 4 ++- .../material/SimpleTexturedMaterial.hpp | 2 +- src/dawn/component/ui/UICanvas.cpp | 2 +- src/dawn/component/ui/UICanvas.hpp | 2 +- src/dawn/display/pass/RenderPassContext.hpp | 2 +- src/dawn/display/shader/ShaderManager.hpp | 3 ++ src/dawn/locale/LocaleManager.hpp | 2 +- src/dawn/save/SaveManager.cpp | 2 +- src/dawn/save/SaveManager.hpp | 2 +- src/dawn/scene/Scene.hpp | 5 ---- 15 files changed, 16 insertions(+), 72 deletions(-) delete mode 100644 src/dawn/component/SimpleComponent.cpp delete mode 100644 src/dawn/component/SimpleComponent.hpp diff --git a/src/dawn/component/CMakeLists.txt b/src/dawn/component/CMakeLists.txt index 4333a63a..390c1143 100644 --- a/src/dawn/component/CMakeLists.txt +++ b/src/dawn/component/CMakeLists.txt @@ -5,7 +5,6 @@ target_sources(${DAWN_TARGET_NAME} PRIVATE - SimpleComponent.cpp SceneComponentRegistry.cpp ) diff --git a/src/dawn/component/SimpleComponent.cpp b/src/dawn/component/SimpleComponent.cpp deleted file mode 100644 index 249cf722..00000000 --- a/src/dawn/component/SimpleComponent.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2023 Dominic Masters -// -// This software is released under the MIT License. -// https://opensource.org/licenses/MIT - -#include "SimpleComponent.hpp" - -using namespace Dawn; - -void SimpleComponent::onInit() { - this->initMethod(*this, this->events); -} - -void SimpleComponent::onDispose() { - for(auto &event : this->events) { - event(); - } -} - -std::shared_ptr Dawn::addSimpleComponent( - std::shared_ptr item, - std::function>&)> init -) { - auto cmp = item->addComponent(); - cmp->initMethod = init; - return cmp; -} \ No newline at end of file diff --git a/src/dawn/component/SimpleComponent.hpp b/src/dawn/component/SimpleComponent.hpp deleted file mode 100644 index f35fc786..00000000 --- a/src/dawn/component/SimpleComponent.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2023 Dominic Masters -// -// This software is released under the MIT License. -// https://opensource.org/licenses/MIT - -#pragma once -#include "scene/Scene.hpp" - -namespace Dawn { - class SimpleComponent final : public SceneComponent { - public: - std::function>& - )> initMethod; - - void onInit() override; - void onDispose() override; - }; - - std::shared_ptr addSimpleComponent( - std::shared_ptr item, - std::function>& - )> init - ); -} \ No newline at end of file diff --git a/src/dawn/component/display/Camera.cpp b/src/dawn/component/display/Camera.cpp index 788e6203..fbfab56d 100644 --- a/src/dawn/component/display/Camera.cpp +++ b/src/dawn/component/display/Camera.cpp @@ -132,7 +132,7 @@ float_t Camera::lookAtPixelPerfect( ); } -void Camera::setRenderTarget(std::shared_ptr renderTarget) { +void Camera::setRenderTarget(const std::shared_ptr renderTarget) { onResizeListener(); this->renderTarget = renderTarget; this->onResizeListener = this->getRenderTarget()->onResize.listen([&]( diff --git a/src/dawn/component/display/Camera.hpp b/src/dawn/component/display/Camera.hpp index a8ece0b1..d9beb1bd 100644 --- a/src/dawn/component/display/Camera.hpp +++ b/src/dawn/component/display/Camera.hpp @@ -8,7 +8,7 @@ #include "display/RenderTarget.hpp" namespace Dawn { - enum CameraType { + enum class CameraType { PERSPECTIVE, ORTHOGONAL }; @@ -77,6 +77,6 @@ namespace Dawn { * * @param renderTarget The render target to set. */ - void setRenderTarget(std::shared_ptr renderTarget); + void setRenderTarget(const std::shared_ptr renderTarget); }; } \ No newline at end of file diff --git a/src/dawn/component/display/material/SimpleTexturedMaterial.cpp b/src/dawn/component/display/material/SimpleTexturedMaterial.cpp index 75f84c48..4a803a4d 100644 --- a/src/dawn/component/display/material/SimpleTexturedMaterial.cpp +++ b/src/dawn/component/display/material/SimpleTexturedMaterial.cpp @@ -30,7 +30,9 @@ std::shared_ptr SimpleTexturedMaterial::getTexture() { return this->texture; } -void SimpleTexturedMaterial::setTexture(std::shared_ptr texture) { +void SimpleTexturedMaterial::setTexture( + const std::shared_ptr texture +) { this->texture = texture; } diff --git a/src/dawn/component/display/material/SimpleTexturedMaterial.hpp b/src/dawn/component/display/material/SimpleTexturedMaterial.hpp index 9869caa0..b6f94fef 100644 --- a/src/dawn/component/display/material/SimpleTexturedMaterial.hpp +++ b/src/dawn/component/display/material/SimpleTexturedMaterial.hpp @@ -34,7 +34,7 @@ namespace Dawn { * * @param texture The texture to set. */ - void setTexture(std::shared_ptr texture); + void setTexture(const std::shared_ptr texture); /** * Sets the color of this material. diff --git a/src/dawn/component/ui/UICanvas.cpp b/src/dawn/component/ui/UICanvas.cpp index 6fc28f32..f8e1c77e 100644 --- a/src/dawn/component/ui/UICanvas.cpp +++ b/src/dawn/component/ui/UICanvas.cpp @@ -139,6 +139,6 @@ void UICanvas::flushPass() { textureBindings.clear(); } -void UICanvas::addElement(std::shared_ptr element) { +void UICanvas::addElement(const std::shared_ptr element) { elements.push_back(element); } \ No newline at end of file diff --git a/src/dawn/component/ui/UICanvas.hpp b/src/dawn/component/ui/UICanvas.hpp index fb24afd5..51f3b926 100644 --- a/src/dawn/component/ui/UICanvas.hpp +++ b/src/dawn/component/ui/UICanvas.hpp @@ -68,6 +68,6 @@ namespace Dawn { * * @param component The component to add. */ - void addElement(std::shared_ptr component); + void addElement(const std::shared_ptr component); }; } \ No newline at end of file diff --git a/src/dawn/display/pass/RenderPassContext.hpp b/src/dawn/display/pass/RenderPassContext.hpp index 87e54640..389014d5 100644 --- a/src/dawn/display/pass/RenderPassContext.hpp +++ b/src/dawn/display/pass/RenderPassContext.hpp @@ -9,7 +9,7 @@ #include "component/display/Camera.hpp" namespace Dawn { - struct RenderPassContext { + struct RenderPassContext { std::shared_ptr game; std::shared_ptr scene; std::shared_ptr camera; diff --git a/src/dawn/display/shader/ShaderManager.hpp b/src/dawn/display/shader/ShaderManager.hpp index 94224f1a..60219f7a 100644 --- a/src/dawn/display/shader/ShaderManager.hpp +++ b/src/dawn/display/shader/ShaderManager.hpp @@ -40,6 +40,9 @@ namespace Dawn { return newShader; } + /** + * Disposes of all shaders. + */ ~ShaderManager() { shaders.clear(); } diff --git a/src/dawn/locale/LocaleManager.hpp b/src/dawn/locale/LocaleManager.hpp index 66ad0934..32c21043 100644 --- a/src/dawn/locale/LocaleManager.hpp +++ b/src/dawn/locale/LocaleManager.hpp @@ -37,7 +37,7 @@ namespace Dawn { std::string getString( const std::string &key, const std::unordered_map replacements = - std::unordered_map() + std::unordered_map() ); /** diff --git a/src/dawn/save/SaveManager.cpp b/src/dawn/save/SaveManager.cpp index 8e1fb021..a7df17cf 100644 --- a/src/dawn/save/SaveManager.cpp +++ b/src/dawn/save/SaveManager.cpp @@ -8,7 +8,7 @@ using namespace Dawn; -void SaveManager::init(std::shared_ptr game) { +void SaveManager::init(const std::shared_ptr game) { assertNotNull(game, "Game instance cannot be null!"); this->game = game; } \ No newline at end of file diff --git a/src/dawn/save/SaveManager.hpp b/src/dawn/save/SaveManager.hpp index a6f92424..24fd175b 100644 --- a/src/dawn/save/SaveManager.hpp +++ b/src/dawn/save/SaveManager.hpp @@ -31,7 +31,7 @@ namespace Dawn { * * @param game The game to initialize the save manager for. */ - void init(std::shared_ptr game); + void init(const std::shared_ptr game); /** * Immediately save the game to the given file. This will invoke the diff --git a/src/dawn/scene/Scene.hpp b/src/dawn/scene/Scene.hpp index f22016c5..29cd7978 100644 --- a/src/dawn/scene/Scene.hpp +++ b/src/dawn/scene/Scene.hpp @@ -12,11 +12,6 @@ #include "util/Flag.hpp" namespace Dawn { - // struct IntervalData { - // float_t frequency; - // float_t nextInvoke; - // }; - enum class SceneState : flag_t { INITIAL = FLAG(0), INITIALIZED = FLAG(1),