-
Notifications
You must be signed in to change notification settings - Fork 1
/
menuscreen.hpp
47 lines (35 loc) · 1.09 KB
/
menuscreen.hpp
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
#pragma once
#include "screen.hpp"
#include <vector>
class MenuScreen : public Screen
{
public:
enum MenuOptionId {
TRY_AGAIN,
START_NEW_GAME,
ENTER_LEVEL_CODE,
CREDITS,
QUIT
};
private:
sf::Sprite &background_sp;
struct MenuOption {
MenuOptionId id;
std::string text;
bool active = true;
};
std::vector<MenuOption> menuOptions;
size_t currentMenuOptionId;
std::string levelCodeInput;
public:
MenuScreen(const sf::Font &font, sf::Sprite &background_sp, const sf::Color &fillColor, const sf::Color &outlineColor);
void enableTryAgain(bool enable);
void setActiveOption(MenuOptionId menuOptionId);
void clearLevelCode();
virtual void processEvent(const sf::Event &event);
private:
void changeSelection(int indexDiff);
void addMenuOption(MenuOption menuOption, bool setAsCurrent = false);
void drawMenuOption(const size_t &menuOptionId, sf::RenderTarget &target, sf::RenderStates states) const;
virtual void draw(sf::RenderTarget &target, sf::RenderStates states) const;
};