aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/crepe/api/Script.h3
-rw-r--r--src/crepe/facade/FontFacade.cpp4
-rw-r--r--src/example/CMakeLists.txt1
-rw-r--r--src/example/FontExample.cpp51
-rw-r--r--src/example/loadfont.cpp2
5 files changed, 57 insertions, 4 deletions
diff --git a/src/crepe/api/Script.h b/src/crepe/api/Script.h
index 668e5d1..ee45b8d 100644
--- a/src/crepe/api/Script.h
+++ b/src/crepe/api/Script.h
@@ -156,6 +156,7 @@ private:
void subscribe_internal(const EventHandler<EventType> & callback, event_channel_t channel);
protected:
+ OptionalRef<Mediator> mediator;
// NOTE: This must be the only constructor on Script, see "Late references" below
Script() = default;
//! Only \c BehaviorScript instantiates Script
@@ -190,7 +191,7 @@ private:
//! Reference to parent component
OptionalRef<bool> active;
//! Mediator reference
- OptionalRef<Mediator> mediator;
+
//! \}
private:
diff --git a/src/crepe/facade/FontFacade.cpp b/src/crepe/facade/FontFacade.cpp
index 708b2ff..a63b022 100644
--- a/src/crepe/facade/FontFacade.cpp
+++ b/src/crepe/facade/FontFacade.cpp
@@ -16,7 +16,7 @@ Asset FontFacade::get_font_asset(const string font_family) {
if (pattern == NULL) {
throw runtime_error("Failed to create font pattern.");
}
-
+
// Default configuration
FcConfig * config = FcConfigGetCurrent();
if (config == NULL) {
@@ -43,7 +43,7 @@ Asset FontFacade::get_font_asset(const string font_family) {
}
// Convert the file path to a string
- string font_file_path(reinterpret_cast<const char *>(file_path));
+ string font_file_path = reinterpret_cast<const char *>(file_path);
FcPatternDestroy(matched_pattern);
FcFini();
return Asset(font_file_path);
diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt
index 0e2d5e2..f62414e 100644
--- a/src/example/CMakeLists.txt
+++ b/src/example/CMakeLists.txt
@@ -20,4 +20,5 @@ add_example(rendering_particle)
add_example(game)
add_example(button)
add_example(loadfont)
+add_example(FontExample)
add_example(AITest)
diff --git a/src/example/FontExample.cpp b/src/example/FontExample.cpp
new file mode 100644
index 0000000..620cf8e
--- /dev/null
+++ b/src/example/FontExample.cpp
@@ -0,0 +1,51 @@
+#include <crepe/api/Text.h>
+#include <SDL2/SDL_ttf.h>
+#include <crepe/facade/Font.h>
+#include <crepe/facade/SDLContext.h>
+#include <crepe/manager/Mediator.h>
+#include <crepe/manager/ResourceManager.h>
+#include <crepe/manager/EventManager.h>
+#include <crepe/api/Scene.h>
+#include <crepe/api/Script.h>
+#include <crepe/api/GameObject.h>
+#include <exception>
+#include <iostream>
+#include <memory>
+#include <chrono>
+using namespace crepe;
+using namespace std;
+using namespace std::chrono;
+class TestScript : public Script{
+ public:
+ steady_clock::time_point start_time;
+ virtual void init() override{
+ start_time = steady_clock::now();
+ }
+ virtual void update() override{
+ auto now = steady_clock::now();
+ auto elapsed = duration_cast<seconds>(now - start_time).count();
+
+ if (elapsed >= 1) {
+ Mediator& med = mediator;
+ EventManager& event_mgr = med.event_manager;
+ event_mgr.trigger_event<ShutDownEvent>();
+ }
+ }
+};
+class TestScene : public Scene{
+ public:
+ void load_scene() override{
+ GameObject text_object = this->new_object("test","test",vec2{0,0},0,1);
+ text_object.add_component<Text>(vec2(100, 100), vec2(0, 0), "test test",
+ "OpenSymbol", Text::Data{});
+ text_object.add_component<BehaviorScript>();
+
+ }
+ std::string get_name(){ return "hey";}
+};
+int main() {
+
+
+
+ return 0;
+}
diff --git a/src/example/loadfont.cpp b/src/example/loadfont.cpp
index a77e457..f863053 100644
--- a/src/example/loadfont.cpp
+++ b/src/example/loadfont.cpp
@@ -13,7 +13,7 @@ int main() {
// SDLFontContext font_facade;
Mediator mediator;
SDLContext sdl_context{mediator};
- ComponentManager component_manager{mediator};
+ // ComponentManager component_manager{mediator};
ResourceManager resource_manager{mediator};
try {
// Correct way to create a unique pointer for Text