From 486ca3846b46dc229e5807968578809766ec1991 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 23 Mar 2022 19:41:31 +0100 Subject: feat: implement generations & multithreading --- src/interfaces/game.hpp | 6 ++++-- src/interfaces/generation_tracker.hpp | 18 ++++++++++++++++++ src/interfaces/scene.hpp | 2 -- src/interfaces/status_updater.hpp | 19 +++++++++++++++++++ src/interfaces/statusline.hpp | 27 +++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 src/interfaces/generation_tracker.hpp create mode 100644 src/interfaces/status_updater.hpp create mode 100644 src/interfaces/statusline.hpp (limited to 'src/interfaces') 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 +#include + +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 (*)(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> & 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 + +class IStatusUpdater : public ISubscriber +{ +public: + void update(const Vector2 &context) noexcept override = 0; +}; + +using IStatusUpdaterFactory = std::shared_ptr (*)( + const std::shared_ptr &statusline, + const std::shared_ptr &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 + +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 (*)( + const std::shared_ptr &cursor_controller, + const std::shared_ptr &window); -- cgit v1.2.3-18-g5258