diff options
author | HampusM <hampus@hampusmat.com> | 2022-02-27 17:12:49 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:53 +0200 |
commit | fe79577396231f2edb7927f1f61ce814f03851a7 (patch) | |
tree | d353a1caa449ec772dcf9a8681084fc2d6e64116 /src/engine/graphics/scene.cpp | |
parent | 6964d48c970e5f7b11897096c816271785af23ac (diff) |
add basic engine graphics
Diffstat (limited to 'src/engine/graphics/scene.cpp')
-rw-r--r-- | src/engine/graphics/scene.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
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 <fmt/core.h> +#include <iostream> + +Scene::Scene(IMatrixFactory<std::string_view> 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<void()> &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(); +} +*/ |