diff options
-rw-r--r-- | src/crepe/facade/Font.cpp | 4 | ||||
-rw-r--r-- | src/crepe/facade/Font.h | 7 | ||||
-rw-r--r-- | src/crepe/facade/FontFacade.cpp | 6 | ||||
-rw-r--r-- | src/crepe/facade/FontFacade.h | 2 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.cpp | 10 |
5 files changed, 24 insertions, 5 deletions
diff --git a/src/crepe/facade/Font.cpp b/src/crepe/facade/Font.cpp index d419974..5af943d 100644 --- a/src/crepe/facade/Font.cpp +++ b/src/crepe/facade/Font.cpp @@ -1,3 +1,5 @@ +#include <SDL2/SDL_ttf.h> + #include "../api/Asset.h" #include "../api/Config.h" @@ -15,7 +17,7 @@ Font::Font(const Asset & src, Mediator & mediator) if (loaded_font == NULL) { throw runtime_error(format("Font: {} (path: {})", TTF_GetError(), FONT_PATH)); } - this->font = {loaded_font, [](TTF_Font * font) { TTF_CloseFont(font); }}; + this->font = {loaded_font, [](TTF_Font * close_font) { TTF_CloseFont(close_font); }}; } TTF_Font * Font::get_font() const { return this->font.get(); } diff --git a/src/crepe/facade/Font.h b/src/crepe/facade/Font.h index 3ff156f..16f8cb6 100644 --- a/src/crepe/facade/Font.h +++ b/src/crepe/facade/Font.h @@ -24,7 +24,14 @@ public: * \param mediator The Mediator object used for managing the SDL context or related systems. */ Font(const Asset & src, Mediator & mediator); + Font(const Font &) = delete; + Font &operator=(const Font &) = delete; + // Default move constructor and move assignment operator + Font(Font &&) noexcept = delete; + Font &operator=(Font &&) noexcept = delete; + + ~Font() = default; /** * \brief Gets the underlying TTF_Font resource. * diff --git a/src/crepe/facade/FontFacade.cpp b/src/crepe/facade/FontFacade.cpp index aa9d00c..d447b6d 100644 --- a/src/crepe/facade/FontFacade.cpp +++ b/src/crepe/facade/FontFacade.cpp @@ -6,7 +6,7 @@ using namespace crepe; using namespace std; -Asset FontFacade::get_font_asset(const string font_family) { +Asset FontFacade::get_font_asset(const string& font_family) { if (!FcInit()) { throw runtime_error("Failed to initialize Fontconfig."); } @@ -19,7 +19,7 @@ Asset FontFacade::get_font_asset(const string font_family) { // Default configuration FcConfig * config = FcConfigGetCurrent(); if (config == NULL) { - FcPatternDestroy(pattern); + // FcPatternDestroy(pattern); throw runtime_error("Failed to get current Fontconfig configuration."); } @@ -37,7 +37,7 @@ Asset FontFacade::get_font_asset(const string font_family) { FcChar8 * file_path = nullptr; if (FcPatternGetString(matched_pattern, FC_FILE, 0, &file_path) != FcResultMatch || file_path == NULL) { - FcPatternDestroy(matched_pattern); + // FcPatternDestroy(matched_pattern); throw runtime_error("Failed to get font file path."); } diff --git a/src/crepe/facade/FontFacade.h b/src/crepe/facade/FontFacade.h index 0e6b7da..fc200d6 100644 --- a/src/crepe/facade/FontFacade.h +++ b/src/crepe/facade/FontFacade.h @@ -22,7 +22,7 @@ public: * \param font_family Name of the font family name. * \return Asset with filepath to the font. */ - static Asset get_font_asset(const std::string font_family); + static Asset get_font_asset(const std::string& font_family); }; } // namespace crepe diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index afd9548..5aa00b5 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -8,6 +8,8 @@ #include "../api/Camera.h" #include "../api/ParticleEmitter.h" #include "../api/Sprite.h" +#include "../api/Text.h" +#include "../facade/Font.h" #include "../api/Transform.h" #include "../facade/SDLContext.h" #include "../facade/Texture.h" @@ -120,8 +122,13 @@ void RenderSystem::render() { this->update_camera(); RefVector<Sprite> sprites = mgr.get_components_by_type<Sprite>(); + ResourceManager & resource_manager = this->mediator.resource_manager; RefVector<Sprite> sorted_sprites = this->sort(sprites); + RefVector<Text> texts = mgr.get_components_by_type<Text>(); + for(const Text& text : texts){ + const Font & res = resource_manager.get<Font>(text.font); + } for (const Sprite & sprite : sorted_sprites) { if (!sprite.active) continue; const Transform & transform @@ -132,5 +139,8 @@ void RenderSystem::render() { if (rendered_particles) continue; this->render_normal(sprite, transform); + + + } } |