aboutsummaryrefslogtreecommitdiff
path: root/src/example/loadfont.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-17 15:54:17 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-17 15:54:17 +0100
commit8d53634e2f47a616ff90f114fe1afbc2ba4df094 (patch)
tree5a5e11e9c54c845a5dd570bb76aa73724acc5dd9 /src/example/loadfont.cpp
parent0524c68cc4eb9fbd36c17ed4f5d8152cac2f977b (diff)
parenta8ccf7fe8662086bb223aa4eafd0f85e717d16cf (diff)
Merge branch 'master' into niels/UI
Diffstat (limited to 'src/example/loadfont.cpp')
-rw-r--r--src/example/loadfont.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/example/loadfont.cpp b/src/example/loadfont.cpp
index ed67ffa..e459332 100644
--- a/src/example/loadfont.cpp
+++ b/src/example/loadfont.cpp
@@ -2,6 +2,7 @@
#include <crepe/api/Asset.h>
#include <crepe/api/Text.h>
#include <crepe/facade/Font.h>
+#include <crepe/facade/FontFacade.h>
#include <crepe/facade/SDLContext.h>
#include <crepe/manager/Mediator.h>
#include <crepe/manager/ResourceManager.h>
@@ -14,24 +15,26 @@ int main() {
// SDLFontContext font_facade;
Mediator mediator;
+ FontFacade font_facade{};
SDLContext sdl_context{mediator};
// ComponentManager component_manager{mediator};
ResourceManager resource_manager{mediator};
try {
// Correct way to create a unique pointer for Text
std::unique_ptr<Text> label = std::make_unique<Text>(
- 1, vec2(100, 100), vec2(0, 0), "OpenSymbol", Text::Data{}, "test text", Asset(""));
+ 1, vec2(100, 100), vec2(0, 0), "OpenSymbol", Text::Data{}, "test text");
// std::cout << "Path: " << label->font.get_path() << std::endl;
-
+ Asset asset1 = font_facade.get_font_asset("OpenSymbol");
+ std::cout << asset1.get_path() << std::endl;
std::unique_ptr<Text> label2 = std::make_unique<Text>(
1, vec2(100, 100), vec2(0, 0), "fsaafdafsdafsdafsdasfdds", Text::Data{});
Asset asset = Asset("test test");
- label->font = asset;
+ label->font.emplace(asset);
std::cout << label->font.value().get_path() << std::endl;
// label2->font = std::make_optional(asset);
// std::cout << "Path: " << label2->font.get_path() << std::endl;
- // ResourceManager & resource_mgr = mediator.resource_manager;
- // const Font & res = resource_manager.get<Font>(label->font);
+ ResourceManager & resource_mgr = mediator.resource_manager;
+ const Font & res = resource_manager.get<Font>(label->font.value());
// TTF_Font * test_font = res.get_font();
// if (test_font == NULL) {
// std::cout << "error with font" << std::endl;