-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlobby_view_layout.h
105 lines (88 loc) · 2.84 KB
/
lobby_view_layout.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
103
104
105
#ifndef LOBBY_VIEW_LAYOUT_H
#define LOBBY_VIEW_LAYOUT_H
#include "side.h"
#include "lobby_view_item.h"
#include "screen_rect.h"
#include "layout.h"
#include <vector>
/// The layout of the lobby view
/// x x x x
/// 1 2 3 4
///
/// +---------------------------+
/// | |
/// | +-----------------------+ | y1
/// | | | |
/// | | | |
/// | | | |
/// | | image | |
/// | | | |
/// | | | |
/// | | | |
/// | +-----------------------+ | y2
/// | |
/// | +----------+ +----------+ | y3
/// | | | | | |
/// | | color | | color | |
/// | | | | | |
/// | +----------+ +----------+ | y4
/// | |
/// | +----------+ +----------+ | y5
/// | | | | | |
/// | | racee | | race | |
/// | | | | | |
/// | +----------+ +----------+ | y6
/// | |
/// | +----------+ +----------+ | y7 <-+
/// | | | | | | |
/// | | ready | | read | | +- panel_height
/// | | | | | | |
/// | +----------+ +----------+ | y8 <-+
/// | |
/// +---------------------------+
///
/// ^ ^
/// | |
/// +----------+
/// panel_width
///
class lobby_view_layout
{
public:
explicit lobby_view_layout(
const screen_coordinat& window_size = get_default_screen_size(),
const int margin_width = get_default_margin_width()
);
const auto& get_image() const noexcept { return m_image; }
const screen_rect& get_color(const side player_side) const noexcept;
const screen_rect& get_race(const side player_side) const noexcept;
const screen_rect& get_start(const side player_side) const noexcept;
/// Get the size of the font that would fit nicely
int get_font_size() const noexcept { return m_font_size; }
screen_coordinat get_window_size() const noexcept { return m_window_size; }
private:
screen_rect m_image;
screen_rect m_lhs_color;
screen_rect m_lhs_race;
screen_rect m_lhs_start;
screen_rect m_rhs_color;
screen_rect m_rhs_race;
screen_rect m_rhs_start;
lobby_view_item m_lhs_cursor;
lobby_view_item m_rhs_cursor;
/// The size of the font that would fit nicely
int m_font_size;
/// The size of the window
screen_coordinat m_window_size;
};
/// Get the rectangangle of the item
const screen_rect& get_cursor_rect(
const lobby_view_layout& layout,
const lobby_view_item item,
const side player_side
) noexcept;
/// Get the panels in the layout
std::vector<screen_rect> get_panels(const lobby_view_layout& layout);
/// Test the lobby_view_layout class
void test_lobby_view_layout();
#endif // LOBBY_VIEW_LAYOUT_H