-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuState.h
More file actions
44 lines (34 loc) · 971 Bytes
/
MenuState.h
File metadata and controls
44 lines (34 loc) · 971 Bytes
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
#pragma once
#include "GameState.h"
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <string>
#include <array>
class MenuState : public GameState
{
public:
MenuState();
virtual void onEnter() override;
virtual void onClose() override;
virtual void pause() override;
virtual void resume() override;
virtual void draw() const override;
virtual GameState* handleEvents(InputQueue::Event& e) override;
virtual GameState* update(unsigned int delay) override;
virtual ~MenuState();
private:
struct Rect{int x,y,w,h;};
void resetRects();
int _currentItem = 0;
static constexpr int _numItems = 5;
std::array<std::string, _numItems> _menuItems;
std::array<Rect, _numItems> _itemRects;
std::array<std::function<GameState*()>, _numItems> _itemCallbacks;
int _menuItemMaxLength;
void *_font = GLUT_BITMAP_9_BY_15;
int _fontWidth = 9;
int _fontHeight = 15;
};