aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-17 13:36:17 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-17 13:36:17 +0100
commit0c02511f6a64766174cb0db3beb4cc159d3efdf7 (patch)
tree1ae713cfaad559aaae623f6e38639c2c10b1a158
parent24578c9afb61ae65b300dd7fb645220e133089be (diff)
merging wouter
-rw-r--r--src/crepe/facade/Font.cpp9
-rw-r--r--src/crepe/facade/Font.h3
-rw-r--r--src/crepe/facade/SDLContext.cpp2
-rw-r--r--src/crepe/system/RenderSystem.cpp2
4 files changed, 1 insertions, 15 deletions
diff --git a/src/crepe/facade/Font.cpp b/src/crepe/facade/Font.cpp
index 51e9690..9c1a800 100644
--- a/src/crepe/facade/Font.cpp
+++ b/src/crepe/facade/Font.cpp
@@ -2,8 +2,6 @@
#include "../api/Asset.h"
#include "../api/Config.h"
-#include "util/Log.h"
-#include <iostream>
#include <string>
#include "Font.h"
@@ -16,10 +14,6 @@ Font::Font(const Asset & src, Mediator & mediator)
Config & config = Config::get_instance();
const std::string FONT_PATH = src.get_path();
- this->path = FONT_PATH;
-
- cout << this->path << endl;
- /*
TTF_Font * loaded_font = TTF_OpenFont(FONT_PATH.c_str(), config.font.size);
if (loaded_font == NULL) {
throw runtime_error(format("Font: {} (path: {})", TTF_GetError(), FONT_PATH));
@@ -29,6 +23,3 @@ Font::Font(const Asset & src, Mediator & mediator)
TTF_Font * Font::get_font() const { return this->font.get(); }
-const string & Font::get_path() const noexcept{
- return this->path;
-}
diff --git a/src/crepe/facade/Font.h b/src/crepe/facade/Font.h
index 3eff3c6..b08366d 100644
--- a/src/crepe/facade/Font.h
+++ b/src/crepe/facade/Font.h
@@ -3,7 +3,6 @@
#include <SDL2/SDL_ttf.h>
#include <functional>
#include <memory>
-#include <string>
#include "../Resource.h"
@@ -35,8 +34,6 @@ public:
*/
TTF_Font * get_font() const;
- const std::string & get_path() const noexcept;
-
private:
//! The SDL_ttf font object with custom deleter.
std::unique_ptr<TTF_Font, std::function<void(TTF_Font *)>> font = nullptr;
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index 7bd9dbc..c19f0aa 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -294,9 +294,7 @@ void SDLContext::draw_text(const Text & text, const Font & font){
.b = text.data.text_color.b,
.a = text.data.text_color.a,
};
- TTF_Font * ttf_font = TTF_OpenFont(font.get_path().c_str(), Config::get_instance().font.size);
SDL_Surface * font_surface = TTF_RenderText_Solid(font.get_font(), text.text.c_str(), color);
- TTF_CloseFont(ttf_font);
SDL_Texture * font_texture = SDL_CreateTextureFromSurface(this->game_renderer.get(), font_surface);
SDL_FreeSurface(font_surface);
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index 7d6a31b..578a4c0 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -87,7 +87,7 @@ void RenderSystem::render_text(){
for (const Text & text : texts) {
if (!text.active) continue;
- const Font & res = resource_manager.get<Font>(text.font);
+ const Font & res = resource_manager.get<Font>(text.font.value());
ctx.draw_text(text, res);
}