-
Notifications
You must be signed in to change notification settings - Fork 2
/
options.cpp
134 lines (109 loc) · 3.16 KB
/
options.cpp
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "options.h"
#include "prompt.h"
#include "save.h"
// The Strings used for the Options Menu
const char optionsMenuItems_0[] PROGMEM = "[ Options Menu ]";
const char optionsMenuItems_1[] PROGMEM = "Sound:";
const char optionsMenuItems_2[] PROGMEM = "Play";
const char optionsMenuItems_3[] PROGMEM = "Reset Game Data";
const char* const optionsMenuItems[] PROGMEM = {
optionsMenuItems_0,
optionsMenuItems_1,
optionsMenuItems_2,
optionsMenuItems_3
};
const char clearSaveConfirmItems_0[] PROGMEM = "[REALLY CLEAR SAVE??]";
const char clearSaveConfirmItems_1[] PROGMEM = "No, whoops!";
const char clearSaveConfirmItems_2[] PROGMEM = "Yes, I'm sure.";
const char optionsMenuItemsCount = 3;
const char* const clearSaveMenuItems[] PROGMEM = {
clearSaveConfirmItems_0,
clearSaveConfirmItems_1,
clearSaveConfirmItems_2
};
const char clearSaveMenuItemsCount = 2;
unsigned char displayOptionsMenu()
{
unsigned char choice;
bool unlockedRandom = getRoomClearPercentage() >= 100;
// Repeat while a choice has not been made
while(choice != 255) {
// Check if the audio is currently enabled
bool audioEnabled = arduboy.audio.enabled();
// Prompt the user for a choice
arduboy.clear();
// Draw whether sound is disabled
arduboy.setCursor(6*7 + 2, 8);
if (audioEnabled) {
arduboy.print(F("On"));
} else {
arduboy.print(F("Off"));
}
// Draw Game Mode selection
arduboy.setCursor(6*6 + 2, 16);
if(GameMode == GAME_MODE_RANDOM) {
arduboy.print(F("Glove"));
} else if(unlockedRandom) {
arduboy.print(F("Random"));
} else {
arduboy.print(F("??????"));
}
choice = prompt_start(optionsMenuItems, optionsMenuItemsCount);
// Choice: Toggle Sound
if(choice == 0) {
if(audioEnabled) {
arduboy.audio.off();
} else {
arduboy.audio.on();
}
arduboy.audio.saveOnOff();
return SETTING_CHANGED;
}
// Choice: Change Mode
else if(choice == 1) {
if(GameMode == GAME_MODE_RANDOM) {
GameSaveOffset = GAME_GLOVE_OFFSET;
GameMode = GAME_MODE_GLOVE;
return SETTING_REBOOT;
} else if(unlockedRandom) {
GameSaveOffset = GAME_RANDOM_OFFSET;
GameMode = GAME_MODE_RANDOM;
return SETTING_REBOOT;
}
continue;
}
// Choice: Clear Data
else if(choice == 2) {
// If it's time to reboot, reboot!
if(displayClearMenu() == SETTING_REBOOT)
return SETTING_REBOOT;
// Otherwise return to settings
continue;
}
// Back: Go to previous screen
return SETTING_FINISHED;
}
}
unsigned char displayClearMenu()
{
unsigned char choice;
// Prompt the user for a choice
arduboy.clear();
choice = prompt_start(clearSaveMenuItems, clearSaveMenuItemsCount);
// Repeat while a choice has not been made
while(choice != 255) {
// Choice One: Do nothing
if(choice == 0)
return SETTING_FINISHED;
// Choice Two: Delete the save file
if(choice == 1)
{
// Delete the save file
breakSave(GAME_SAVE_FILE);
// Reboot the game
return SETTING_REBOOT;
}
// Back: Go to the previous screen
return SETTING_FINISHED;
}
}