-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontrols_view.h
100 lines (69 loc) · 2.46 KB
/
controls_view.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
#ifndef CONTROLS_VIEW_H
#define CONTROLS_VIEW_H
#ifndef LOGIC_ONLY
#include <SFML/Graphics.hpp>
#include "physical_controller.h"
#include "game_resources.h"
#include "controls_view_layout.h"
#include "controls_view_item.h"
class controls_view
{
public:
controls_view(const physical_controller& c);
/// Run the menu, until the user quits
void exec();
/// Get the controller, as changed by this view
const auto& get_controller() const noexcept { return m_controller; }
const auto& get_layout() const noexcept { return m_layout; }
auto& get_resources() noexcept { return m_resources; }
const auto& get_selected() const noexcept { return m_selected; }
auto& get_window() noexcept { return m_window; }
/// Set a uniform text style
void set_text_style(sf::Text& text);
private:
/// The layout of this window
controls_view_layout m_layout;
/// The window to draw to
sf::RenderWindow m_window;
/// The controller
physical_controller m_controller;
/// Resources
game_resources m_resources;
/// The selected item
controls_view_item m_selected;
/// Change the selected item, from spacebar or LMB click
void change_selected();
/// Process all events
/// @return if the user wants to quit
bool process_events();
/// Show the menu on-screen
void show();
};
/// @param is_active if the panel is active:
/// if true, draw with the real color,
/// else use a greyed out color
void draw_panel(
controls_view& v,
const screen_rect& panel_position,
const std::string panel_text,
const chess_color color,
const bool is_active
);
std::string get_key_str_for_action_1(const controls_view& v);
std::string get_key_str_for_action_2(const controls_view& v);
std::string get_key_str_for_action_3(const controls_view& v);
std::string get_key_str_for_action_4(const controls_view& v);
std::string get_key_str_for_do(const controls_view& v);
std::string get_key_str_for_move_down(const controls_view& v);
std::string get_key_str_for_move_left(const controls_view& v);
std::string get_key_str_for_move_right(const controls_view& v);
std::string get_key_str_for_move_up(const controls_view& v);
std::string get_key_str_for_next(const controls_view& v);
void show_keyboard_panel(controls_view& v);
void show_mouse_panel(controls_view& v);
/// Show where the panels will be drawn
void show_layout_panels(controls_view& v);
void show_selected_panel(controls_view& v);
void show_type_panel(controls_view& v);
#endif // LOGIC_ONLY
#endif // CONTROLS_VIEW_H