forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
panels.h
102 lines (83 loc) · 2.55 KB
/
panels.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#pragma once
#ifndef CATA_SRC_PANELS_H
#define CATA_SRC_PANELS_H
#include <functional>
#include <map>
#include <string>
#include <vector>
#include "coordinates.h"
class JsonIn;
class JsonOut;
class avatar;
struct point;
struct tripoint;
namespace catacurses
{
class window;
} // namespace catacurses
enum face_type : int {
face_human = 0,
face_bird,
face_bear,
face_cat,
num_face_types
};
namespace overmap_ui
{
void draw_overmap_chunk( const catacurses::window &w_minimap, const avatar &you,
const tripoint_abs_omt &global_omt, point start, int width,
int height );
} // namespace overmap_ui
bool default_render();
class window_panel
{
public:
window_panel( std::function<void( avatar &, const catacurses::window & )> draw_func,
const std::string &nm, int ht, int wd, bool default_toggle_,
std::function<bool()> render_func = default_render, bool force_draw = false );
std::function<void( avatar &, const catacurses::window & )> draw;
std::function<bool()> render;
int get_height() const;
int get_width() const;
std::string get_name() const;
bool toggle;
bool always_draw;
private:
int height;
int width;
bool default_toggle;
std::string name;
};
class panel_manager
{
public:
panel_manager();
~panel_manager() = default;
panel_manager( panel_manager && ) = default;
panel_manager( const panel_manager & ) = default;
panel_manager &operator=( panel_manager && ) = default;
panel_manager &operator=( const panel_manager & ) = default;
static panel_manager &get_manager() {
static panel_manager single_instance;
return single_instance;
}
std::vector<window_panel> &get_current_layout();
std::string get_current_layout_id() const;
int get_width_right();
int get_width_left();
void show_adm();
void init();
private:
bool save();
bool load();
void serialize( JsonOut &json );
void deserialize( JsonIn &jsin );
// update the screen offsets so the game knows how to adjust the main window
void update_offsets( int x );
// The amount of screen space from each edge the sidebar takes up
int width_right = 0;
int width_left = 0;
std::string current_layout_id;
std::map<std::string, std::vector<window_panel>> layouts;
};
#endif // CATA_SRC_PANELS_H