aboutsummaryrefslogtreecommitdiff
path: root/src/engine/graphics/scene.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-05-22 17:05:00 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:59 +0200
commit7de921836587cdc359c2c4b84ed6446ada16c008 (patch)
treec4ec20b4769817c41ce7d939956da297bf787597 /src/engine/graphics/scene.cpp
parent723ea6535b4c4e5605e5592137a898d6ffa458c1 (diff)
refactor: remove window class
Diffstat (limited to 'src/engine/graphics/scene.cpp')
-rw-r--r--src/engine/graphics/scene.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/engine/graphics/scene.cpp b/src/engine/graphics/scene.cpp
index 73c1292..52613d8 100644
--- a/src/engine/graphics/scene.cpp
+++ b/src/engine/graphics/scene.cpp
@@ -5,17 +5,17 @@
#include <fmt/color.h>
#include <fmt/core.h>
+
#include <iostream>
+#include <sys/ioctl.h>
#include <utility>
Scene::Scene(
IMatrixFactory<std::string_view> matrix_factory,
- std::shared_ptr<ICursorController> cursor_controller,
- std::shared_ptr<IWindow> window) noexcept
+ std::shared_ptr<ICursorController> cursor_controller) noexcept
: _is_shown(false),
- _matrix(matrix_factory(window->size() - Bounds({.width = 0U, .height = 1U}))),
- _cursor_controller(std::move(cursor_controller)),
- _window(std::move(window))
+ _matrix(matrix_factory(size() - Bounds({.width = 0U, .height = 1U}))),
+ _cursor_controller(std::move(cursor_controller))
{
_matrix->fill(" ");
}
@@ -46,6 +46,16 @@ void Scene::leave() noexcept
_is_shown = false;
}
+auto Scene::size() const noexcept -> Bounds
+{
+ winsize window_size = {};
+
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
+ ioctl(0, TIOCGWINSZ, &window_size);
+
+ return Bounds({window_size.ws_col, window_size.ws_row});
+}
+
auto Scene::get_matrix() const noexcept
-> const std::shared_ptr<IMatrix<std::string_view>> &
{