aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-11 18:42:38 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-11 18:42:38 +0100
commita2b67f879e2073c5b094c9a480bf637c98703001 (patch)
treec5b3f8f65923413aa342759a675d77971d1cfbf3 /src
parentca6c4f30df6612f60db0fdfe4c2d366d7e4da8ea (diff)
example working again
Diffstat (limited to 'src')
-rw-r--r--src/crepe/api/LoopManager.h5
-rw-r--r--src/crepe/manager/Mediator.h2
-rw-r--r--src/crepe/manager/ReplayManager.cpp17
-rw-r--r--src/example/replay.cpp22
4 files changed, 36 insertions, 10 deletions
diff --git a/src/crepe/api/LoopManager.h b/src/crepe/api/LoopManager.h
index 28aa423..f34a5a0 100644
--- a/src/crepe/api/LoopManager.h
+++ b/src/crepe/api/LoopManager.h
@@ -2,13 +2,14 @@
#include "../facade/SDLContext.h"
#include "../manager/ComponentManager.h"
+#include "../manager/ReplayManager.h"
+#include "../manager/ResourceManager.h"
#include "../manager/ResourceManager.h"
#include "../manager/SaveManager.h"
#include "../manager/SceneManager.h"
#include "../system/System.h"
#include "LoopTimer.h"
-#include "manager/ResourceManager.h"
namespace crepe {
@@ -76,6 +77,8 @@ private:
SDLContext sdl_context{mediator};
//! LoopTimer instance
LoopTimer loop_timer{mediator};
+ //! ReplayManager instance
+ ReplayManager replay_manager{mediator};
private:
/**
diff --git a/src/crepe/manager/Mediator.h b/src/crepe/manager/Mediator.h
index 628154a..eef4432 100644
--- a/src/crepe/manager/Mediator.h
+++ b/src/crepe/manager/Mediator.h
@@ -13,6 +13,7 @@ class SaveManager;
class ResourceManager;
class SDLContext;
class LoopTimer;
+class ReplayManager;
/**
* Struct to pass references to classes that would otherwise need to be singletons down to
@@ -34,6 +35,7 @@ struct Mediator {
OptionalRef<EventManager> event_manager = EventManager::get_instance();
OptionalRef<ResourceManager> resource_manager;
OptionalRef<LoopTimer> timer;
+ OptionalRef<ReplayManager> replay_manager;
};
} // namespace crepe
diff --git a/src/crepe/manager/ReplayManager.cpp b/src/crepe/manager/ReplayManager.cpp
index 3643a8e..40d34a4 100644
--- a/src/crepe/manager/ReplayManager.cpp
+++ b/src/crepe/manager/ReplayManager.cpp
@@ -4,5 +4,22 @@
using namespace crepe;
ReplayManager::ReplayManager(Mediator & mediator) : Manager(mediator) {
+ mediator.replay_manager = *this;
+}
+
+void ReplayManager::record_start() {
+
+}
+
+recording_t ReplayManager::record_end() {
+ return 0;
+}
+
+void ReplayManager::play(recording_t handle) {
+
+}
+
+void ReplayManager::release(recording_t handle) {
+
}
diff --git a/src/example/replay.cpp b/src/example/replay.cpp
index 0c4f9b3..67acbd8 100644
--- a/src/example/replay.cpp
+++ b/src/example/replay.cpp
@@ -33,26 +33,30 @@ class AnimationScript : public Script {
class Timeline : public Script {
unsigned i = 0;
- OptionalRef<ReplayManager> mgr;
+ ReplayManager & mgr;
recording_t recording;
+
+public:
+ Timeline(ReplayManager & mgr)
+ : mgr(mgr) {}
+
void update() {
- ReplayManager & mgr = this->mgr;
switch (i++) {
default: break;
case 10:
- // mgr.record_start();
+ mgr.record_start();
Log::logf("start");
break;
case 60:
- // this->recording = mgr.record_end();
+ this->recording = mgr.record_end();
Log::logf("stop");
break;
case 70:
- // mgr.play(this->recording);
+ mgr.play(this->recording);
Log::logf("play");
break;
case 71:
- // mgr.release(this->recording);
+ mgr.release(this->recording);
Log::logf("end");
break;
case 72:
@@ -68,8 +72,8 @@ public:
using Scene::Scene;
void load_scene() {
- Mediator & m = this->mediator;
- ComponentManager & mgr = m.component_manager;
+ Mediator & mediator = this->mediator;
+ ComponentManager & mgr = mediator.component_manager;
GameObject cam = mgr.new_object("cam");
cam.add_component<Camera>(ivec2{640,480},vec2{3,3}, Camera::Data{
@@ -86,7 +90,7 @@ public:
square.add_component<BehaviorScript>().set_script<AnimationScript>();
GameObject scapegoat = mgr.new_object("");
- scapegoat.add_component<BehaviorScript>().set_script<Timeline>();
+ scapegoat.add_component<BehaviorScript>().set_script<Timeline>(mediator.replay_manager);
}
string get_name() const { return "scene1"; }