aboutsummaryrefslogtreecommitdiff
path: root/src/engine/graphics/scene.cpp
blob: 3f63807ed036763b45776ac45937be4e35948bb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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();
}
*/