aboutsummaryrefslogtreecommitdiff
path: root/src/engine/graphics/scene.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/graphics/scene.cpp')
-rw-r--r--src/engine/graphics/scene.cpp31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/engine/graphics/scene.cpp b/src/engine/graphics/scene.cpp
index a8e7b88..c4a398c 100644
--- a/src/engine/graphics/scene.cpp
+++ b/src/engine/graphics/scene.cpp
@@ -4,13 +4,19 @@
#include <fmt/core.h>
#include <iostream>
-
-Scene::Scene(IMatrixFactory<std::string_view> matrix_factory)
- : _is_shown(false), _matrix_factory(matrix_factory)
+#include <utility>
+
+Scene::Scene(IMatrixFactory<std::string_view> matrix_factory,
+ std::shared_ptr<ICursorController> cursor_controller,
+ std::shared_ptr<IWindow> window) noexcept
+ : _is_shown(false),
+ _matrix_factory(matrix_factory),
+ _cursor_controller(std::move(cursor_controller)),
+ _window(std::move(window))
{
}
-void Scene::enter()
+void Scene::enter() noexcept
{
if (_is_shown)
{
@@ -23,7 +29,7 @@ void Scene::enter()
_is_shown = true;
}
-void Scene::leave()
+void Scene::leave() noexcept
{
if (!_is_shown)
{
@@ -35,3 +41,18 @@ void Scene::leave()
_is_shown = false;
}
+
+void Scene::write_status(const std::string_view &str) noexcept
+{
+ const auto previous_position = _cursor_controller->where();
+
+ const auto window_size = _window->size();
+
+ _cursor_controller->move_to(
+ Vector2({.x = 1, .y = static_cast<Vector2::Value>(window_size.get_height())}));
+
+ fmt::print(ERASE_ENTIRE_LINE, fmt::arg("esc", ESC));
+ fmt::print(fmt::runtime(str.data()));
+
+ _cursor_controller->move_to(previous_position);
+}