blob: 5b520273bce4c0d011c3e55b72cf9c05750c6fbe (
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
|
#pragma once
#include <fmt/core.h>
#include <memory>
#include <string_view>
#include <termios.h>
#include <utility>
#include <vector>
#include <yacppdic/auto_wirable.hpp>
#include "engine/data/bounds.hpp"
#include "engine/data/vector2.hpp"
#include "interfaces/component.hpp"
#include "interfaces/matrix.hpp"
#include "interfaces/scene.hpp"
class IComponent;
struct termios;
constexpr fmt::string_view ENABLE_ALT_BUFFER = "{esc}[?1049h";
constexpr fmt::string_view DISABLE_ALT_BUFFER = "{esc}[?1049l";
class Scene
: public IScene,
public yacppdic::AutoWirable<IScene, Scene, IMatrixFactory<IScene::MatrixElement>>
{
public:
explicit Scene(const IMatrixFactory<MatrixElement> &matrix_factory) noexcept;
void enter() noexcept override;
void leave() noexcept override;
[[nodiscard]] auto size() const noexcept -> Bounds override;
[[nodiscard]] auto get_matrix() const noexcept
-> const std::shared_ptr<IMatrix<MatrixElement>> & override;
void register_component(
const std::shared_ptr<IComponent> &component,
const Vector2 &position) noexcept override;
[[nodiscard]] auto get_components() const noexcept
-> std::vector<std::pair<std::shared_ptr<IComponent>, Vector2>> override;
private:
std::shared_ptr<IMatrix<MatrixElement>> _matrix;
bool _is_shown;
std::shared_ptr<termios> _original_termios = nullptr;
std::vector<std::pair<std::shared_ptr<IComponent>, Vector2>> _components;
};
|