aboutsummaryrefslogtreecommitdiff
path: root/src/bootstrap.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-06-07 19:45:17 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:57:01 +0200
commit8805b1fe27344e8086cebabf869b7a02d2376f05 (patch)
treea90a2e2dda1bcb98fb4de5cd983138e5441c2222 /src/bootstrap.cpp
parentf778317bae709f397345a2d5e04e23864c6391b3 (diff)
refactor: decouple statusline from scene & cursor controller
Might be slightly slower than previously though...
Diffstat (limited to 'src/bootstrap.cpp')
-rw-r--r--src/bootstrap.cpp24
1 files changed, 17 insertions, 7 deletions
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 <fmt/core.h>
#include <memory>
-#include <random>
#include <string>
#include <string_view>
#include <vector>
@@ -48,8 +50,8 @@ auto bootstrap() noexcept -> yacppdic::Container
const std::shared_ptr<ICursorController> &cursor_controller,
const std::shared_ptr<IUserInputObserver> &user_input_observer)
{
- std::shared_ptr<IStatusLine> statusline =
- container.get<IStatusLineFactory>()(cursor_controller, scene);
+ std::shared_ptr<IStatusLine> statusline = container.get<IStatusLineFactory>()(
+ Bounds({.width = scene->size().get_width(), .height = 1}));
std::shared_ptr<IStatusManager> status_manager =
container.get<IStatusManagerFactory>()(statusline);
@@ -83,10 +85,12 @@ auto bootstrap() noexcept -> yacppdic::Container
});
container.bind<IStatusLineFactory>().to_factory(
- [](const std::shared_ptr<ICursorController> &cursor_controller,
- const std::shared_ptr<IScene> &scene)
+ [&container](const Bounds &size)
{
- return std::make_unique<StatusLine>(cursor_controller, scene);
+ const auto matrix_factory =
+ container.get<IMatrixFactory<IComponent::ComponentMatrix::Element>>();
+
+ return std::make_unique<StatusLine>(matrix_factory(size));
});
container.bind<IStatusManagerFactory>().to_factory(
@@ -107,5 +111,11 @@ auto bootstrap() noexcept -> yacppdic::Container
return std::make_unique<CellHelper<char>>(matrix);
});
+ container.bind<IComponentRendererFactory>().to_factory(
+ [](const std::shared_ptr<ICursorController> &cursor_controller)
+ {
+ return std::make_unique<ComponentRenderer>(cursor_controller);
+ });
+
return container;
}