aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-23 19:41:31 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:57 +0200
commit486ca3846b46dc229e5807968578809766ec1991 (patch)
tree65a4b7a746d6305666af06f8a1975c76244085a7 /src/interfaces
parentb8e86ce397dc07320c02f6a5f592c7c6a4421c86 (diff)
feat: implement generations & multithreading
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/game.hpp6
-rw-r--r--src/interfaces/generation_tracker.hpp18
-rw-r--r--src/interfaces/scene.hpp2
-rw-r--r--src/interfaces/status_updater.hpp19
-rw-r--r--src/interfaces/statusline.hpp27
5 files changed, 68 insertions, 4 deletions
diff --git a/src/interfaces/game.hpp b/src/interfaces/game.hpp
index c99c01f..6836dbd 100644
--- a/src/interfaces/game.hpp
+++ b/src/interfaces/game.hpp
@@ -11,9 +11,11 @@
class IGame
{
public:
- virtual ~IGame() = default;
+ virtual ~IGame() noexcept = default;
- virtual void on_start() = 0;
+ virtual void on_start() noexcept = 0;
+
+ virtual void on_update() noexcept = 0;
virtual void on_exit() const noexcept = 0;
diff --git a/src/interfaces/generation_tracker.hpp b/src/interfaces/generation_tracker.hpp
new file mode 100644
index 0000000..135af00
--- /dev/null
+++ b/src/interfaces/generation_tracker.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+#include <cstdint>
+#include <memory>
+
+class IGenerationTracker
+{
+public:
+ virtual ~IGenerationTracker() noexcept = default;
+
+ [[nodiscard]] virtual uint32_t get_current_generation() const noexcept = 0;
+
+ [[nodiscard]] virtual bool get_is_paused() const noexcept = 0;
+
+ virtual void set_is_paused(bool is_paused) noexcept = 0;
+};
+
+using IGenerationTrackerFactory = std::shared_ptr<IGenerationTracker> (*)(bool is_paused);
diff --git a/src/interfaces/scene.hpp b/src/interfaces/scene.hpp
index 0443d41..3b5e037 100644
--- a/src/interfaces/scene.hpp
+++ b/src/interfaces/scene.hpp
@@ -15,8 +15,6 @@ public:
virtual void leave() noexcept = 0;
- virtual void write_status(const std::string_view &str) noexcept = 0;
-
[[nodiscard]] virtual const std::shared_ptr<IMatrix<std::string_view>> &
get_matrix() const noexcept = 0;
};
diff --git a/src/interfaces/status_updater.hpp b/src/interfaces/status_updater.hpp
new file mode 100644
index 0000000..ccfb2db
--- /dev/null
+++ b/src/interfaces/status_updater.hpp
@@ -0,0 +1,19 @@
+#pragma once
+
+#include "interfaces/generation_tracker.hpp"
+#include "interfaces/statusline.hpp"
+#include "interfaces/subscriber.hpp"
+
+#include "engine/data/vector2.hpp"
+
+#include <memory>
+
+class IStatusUpdater : public ISubscriber<Vector2>
+{
+public:
+ void update(const Vector2 &context) noexcept override = 0;
+};
+
+using IStatusUpdaterFactory = std::shared_ptr<IStatusUpdater> (*)(
+ const std::shared_ptr<IStatusLine> &statusline,
+ const std::shared_ptr<IGenerationTracker> &generation_tracker);
diff --git a/src/interfaces/statusline.hpp b/src/interfaces/statusline.hpp
new file mode 100644
index 0000000..00da99b
--- /dev/null
+++ b/src/interfaces/statusline.hpp
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "interfaces/cursor.hpp"
+#include "interfaces/window.hpp"
+
+#include <string_view>
+
+enum StatusLineSection
+{
+ A,
+ B
+};
+
+class IStatusLine
+{
+public:
+ virtual ~IStatusLine() noexcept = default;
+
+ virtual void initialize_background() noexcept = 0;
+
+ virtual void set_status(StatusLineSection section,
+ const std::string_view &str) noexcept = 0;
+};
+
+using IStatusLineFactory = std::shared_ptr<IStatusLine> (*)(
+ const std::shared_ptr<ICursorController> &cursor_controller,
+ const std::shared_ptr<IWindow> &window);