From fe79577396231f2edb7927f1f61ce814f03851a7 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 27 Feb 2022 17:12:49 +0100 Subject: add basic engine graphics --- src/engine/graphics/scene.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/engine/graphics/scene.cpp (limited to 'src/engine/graphics/scene.cpp') diff --git a/src/engine/graphics/scene.cpp b/src/engine/graphics/scene.cpp new file mode 100644 index 0000000..3f63807 --- /dev/null +++ b/src/engine/graphics/scene.cpp @@ -0,0 +1,57 @@ +#include "scene.hpp" + +#include +#include + +Scene::Scene(IMatrixFactory matrix_factory) + : _is_shown(false), _matrix_factory(std::move(matrix_factory)) +{ +} + +void Scene::enter() +{ + if (_is_shown) + { + return; + } + + fmt::print(ENABLE_ALT_BUFFER, fmt::arg("esc", ESC)); + std::cout.flush(); + + _is_shown = true; +} + +void Scene::leave() +{ + if (!_is_shown) + { + return; + } + + fmt::print(DISABLE_ALT_BUFFER, fmt::arg("esc", ESC)); + std::cout.flush(); + + _is_shown = false; +} + +/* +void do_in_statusbar(const std::function &routine) +{ + const auto prev_pos = Cursor::where(); + + const auto window_size = Window::size(); + + Cursor::hide(); + + Cursor::move_to(Vector2({1, window_size.height()})); + + std::cout << fmt::format(EscapeSequences::ERASE_LINE, fmt::arg("esc", ESC)); + std::cout.flush(); + + routine(); + + Cursor::move_to(prev_pos); + + Cursor::show(); +} +*/ -- cgit v1.2.3-18-g5258