From 8805b1fe27344e8086cebabf869b7a02d2376f05 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 7 Jun 2022 19:45:17 +0200 Subject: refactor: decouple statusline from scene & cursor controller Might be slightly slower than previously though... --- src/bootstrap.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/bootstrap.cpp') diff --git a/src/bootstrap.cpp b/src/bootstrap.cpp index 1effa96..44ef211 100644 --- a/src/bootstrap.cpp +++ b/src/bootstrap.cpp @@ -2,6 +2,8 @@ // Interfaces #include "interfaces/cell_helper.hpp" +#include "interfaces/component.hpp" +#include "interfaces/component_renderer.hpp" #include "interfaces/cursor.hpp" #include "interfaces/engine.hpp" #include "interfaces/game.hpp" @@ -13,12 +15,13 @@ #include "interfaces/statusline.hpp" // Implementations +#include "engine/components/statusline.hpp" #include "engine/data/bounds.hpp" #include "engine/data/vector2.hpp" #include "engine/engine.hpp" +#include "engine/graphics/component_renderer.hpp" #include "engine/graphics/matrix.hpp" #include "engine/graphics/scene.hpp" -#include "engine/graphics/statusline.hpp" #include "engine/user/cursor.hpp" #include "engine/user/input.hpp" #include "game/cell_helper.hpp" @@ -29,7 +32,6 @@ #include #include -#include #include #include #include @@ -48,8 +50,8 @@ auto bootstrap() noexcept -> yacppdic::Container const std::shared_ptr &cursor_controller, const std::shared_ptr &user_input_observer) { - std::shared_ptr statusline = - container.get()(cursor_controller, scene); + std::shared_ptr statusline = container.get()( + Bounds({.width = scene->size().get_width(), .height = 1})); std::shared_ptr status_manager = container.get()(statusline); @@ -83,10 +85,12 @@ auto bootstrap() noexcept -> yacppdic::Container }); container.bind().to_factory( - [](const std::shared_ptr &cursor_controller, - const std::shared_ptr &scene) + [&container](const Bounds &size) { - return std::make_unique(cursor_controller, scene); + const auto matrix_factory = + container.get>(); + + return std::make_unique(matrix_factory(size)); }); container.bind().to_factory( @@ -107,5 +111,11 @@ auto bootstrap() noexcept -> yacppdic::Container return std::make_unique>(matrix); }); + container.bind().to_factory( + [](const std::shared_ptr &cursor_controller) + { + return std::make_unique(cursor_controller); + }); + return container; } -- cgit v1.2.3-18-g5258