-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.h
73 lines (49 loc) · 1.03 KB
/
menu.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
//
// Created by Avihoo on 23/06/2020.
//
#ifndef TETRIS_MENU_H
#define TETRIS_MENU_H
#include "sound.h"
#include "tetris.h"
#include "logic.h"
#define MENU_COUNT 2
#define MAIN_MENU 0
#define SETTINGS_MENU 1
typedef enum
{
MENU_PRESS_LEFT,
MENU_PRESS_RIGHT,
MENU_PRESS_RETURN
} menuAction;
typedef const char *(*menuItemGetText)();
typedef void (*menuItemDoAction)(menuAction action);
typedef struct menuItem
{
menuItemGetText getText;
menuItemDoAction doAction;
} menuItem;
typedef struct menu
{
unsigned int selectedItem;
unsigned int menuItemCount;
menuItem *menuItems;
} menu;
struct
{
unsigned int isActive;
unsigned int selectedMenu;
unsigned int wantsToQuit;
unsigned int menuCount;
menu *menus;
} menuState;
menuItem createMenuItem(menuItemGetText getText, menuItemDoAction doAction);
menuItem createBackMenuItem();
void initMenu();
void destroyMenu();
void activateMenu();
void menuActionUp();
void menuActionDown();
void menuActionReturn();
void menuActionLeft();
void menuActionRight();
#endif //TETRIS_MENU_H