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/bootstrap.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'src/bootstrap.cpp') diff --git a/src/bootstrap.cpp b/src/bootstrap.cpp index 713991d..8dec609 100644 --- a/src/bootstrap.cpp +++ b/src/bootstrap.cpp @@ -5,10 +5,13 @@ #include "interfaces/cursor.hpp" #include "interfaces/engine.hpp" #include "interfaces/game.hpp" +#include "interfaces/generation_tracker.hpp" #include "interfaces/input.hpp" #include "interfaces/matrix.hpp" #include "interfaces/randomization.hpp" #include "interfaces/scene.hpp" +#include "interfaces/status_updater.hpp" +#include "interfaces/statusline.hpp" #include "interfaces/window.hpp" // Implementations @@ -22,6 +25,9 @@ #include "engine/user/cursor.hpp" #include "engine/user/input.hpp" #include "game/game.hpp" +#include "game/generation_tracker.hpp" +#include "game/status_updater.hpp" +#include "game/statusline.hpp" #include "randomization/generator.hpp" #include "randomization/seed_generator.hpp" @@ -42,11 +48,21 @@ Container bootstrap() noexcept container.bind().to(); container.bind().to_factory(normalize_lambda( - [](const std::shared_ptr &window, const std::shared_ptr &scene, - const std::shared_ptr &cursor_controller) + [&container](const std::shared_ptr &window, + const std::shared_ptr &scene, + const std::shared_ptr &cursor_controller) { + auto statusline = + container.get()(cursor_controller, window); + + auto generation_tracker = container.get()(true); + + auto status_updater = + container.get()(statusline, generation_tracker); + return std::dynamic_pointer_cast( - std::make_shared(window, scene, cursor_controller)); + std::make_shared(window, scene, cursor_controller, statusline, + generation_tracker, status_updater)); })); container.bind().to_factory( @@ -79,5 +95,28 @@ Container bootstrap() noexcept cursor_controller, window)); })); + container.bind().to_factory( + [](const std::shared_ptr &cursor_controller, + const std::shared_ptr &window) + { + return std::dynamic_pointer_cast( + std::make_shared(cursor_controller, window)); + }); + + container.bind().to_factory( + [](const std::shared_ptr &status_line, + const std::shared_ptr &generation_tracker) + { + return std::dynamic_pointer_cast( + std::make_shared(status_line, generation_tracker)); + }); + + container.bind().to_factory( + [](bool is_paused) + { + return std::dynamic_pointer_cast( + std::make_shared(is_paused)); + }); + return container; } -- cgit v1.2.3-18-g5258