-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchoose_n_players_menu_sfml.h
78 lines (57 loc) · 1.94 KB
/
choose_n_players_menu_sfml.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
#ifndef CHOOSE_N_PLAYERS_MENU_SFML_H
#define CHOOSE_N_PLAYERS_MENU_SFML_H
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include "choose_n_players_menu.h"
#include "program_state.h"
/// SFML visualization of the choose_n_players_menu
class choose_n_players_menu_sfml
{
public:
///Starts the music
///@param n_players the initial number of players suggested
choose_n_players_menu_sfml(
sf::RenderWindow& window,
const bool do_play_music = true,
const int n_players = 2
);
///Stops the music
~choose_n_players_menu_sfml();
///Will the music be player
bool do_play_music() const noexcept { return m_do_play_music; }
///Runs this menu, which is handling input and displayal.
///Closes when the user wants to quit
///or continue to the next menu screen
///This can be obtained with the do_quit member function
void execute();
///Get the current number of players chosen
int get_n_players() const noexcept { return m_menu.get_n_player(); }
///Obtain the current or state after execute
program_state get_state() const noexcept { return m_state; }
///Handle input and show this screen once, to be used in testing only
void tick();
private:
///Will music be played?
bool m_do_play_music;
///The font for all texts
sf::Font m_font;
///The lower text
sf::Text m_lower_text;
///The logic behind this menu
choose_n_players_menu m_menu;
///Music played, starts at constructor, ends at destructor
sf::Music m_music;
///In which state is the program while and directly after this menu?
program_state m_state;
///The upper text
sf::Text m_top_text;
///Window used for displayal
sf::RenderWindow& m_window;
///Show this menu on the screen
void display();
///Process a single event
void process_event(const sf::Event& event);
};
///Get the display color of the text showing the number of players
sf::Color n_players_to_color(const int player_amount);
#endif // CHOOSE_N_PLAYERS_MENU_SFML_H