Add manual cartridge saving and a right-side menu
This commit is contained in:
17 files changed
+449
-63
No files matched your search
@@ -0,0 +1,66 @@
|
||||
#include "game.h"
|
||||
|
||||
struct SaveMenuState save_menu;
|
||||
|
||||
int save_menu_input(unsigned keys, int can_open)
|
||||
{
|
||||
unsigned pressed = keys & ~save_menu.previous;
|
||||
save_menu.previous = keys;
|
||||
if (save_menu.phase == SAVE_MENU_CLOSED) {
|
||||
if (!can_open || !(pressed & START)) return 0;
|
||||
save_menu.phase = SAVE_MENU_OPTIONS;
|
||||
save_menu.selection = 0;
|
||||
return 1;
|
||||
}
|
||||
if (pressed & (B | START)) {
|
||||
save_menu.phase = SAVE_MENU_CLOSED;
|
||||
return 1;
|
||||
}
|
||||
if (save_menu.phase != SAVE_MENU_OPTIONS) {
|
||||
if (!(pressed & A)) return 0;
|
||||
save_menu.phase = SAVE_MENU_CLOSED;
|
||||
return 1;
|
||||
}
|
||||
if (pressed & A) {
|
||||
if (save_menu.selection) save_menu.phase = SAVE_MENU_CLOSED;
|
||||
else save_menu.phase = save_progress() ? SAVE_MENU_SAVED : SAVE_MENU_FAILED;
|
||||
return 1;
|
||||
}
|
||||
unsigned direction = pressed & (UP | DOWN);
|
||||
if (direction == UP || direction == DOWN) {
|
||||
save_menu.selection ^= 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void draw_save_menu(void)
|
||||
{
|
||||
u16 ink = RGB(5, 8, 11), cream = RGB(30, 30, 26);
|
||||
int x = SAVE_MENU_X, y = SAVE_MENU_Y;
|
||||
rectangle(x, y, SAVE_MENU_W, SAVE_MENU_H, ink);
|
||||
rectangle(x + 2, y + 2, SAVE_MENU_W - 4, SAVE_MENU_H - 4, cream);
|
||||
large_text(x + 16, y + 10, "MENU", ink);
|
||||
rectangle(x + 6, y + 23, SAVE_MENU_W - 12, 1, RGB(15, 24, 20));
|
||||
text(x + 8, y + 85, "TEAM AND", ink);
|
||||
text(x + 8, y + 95, "ITEMS ONLY", ink);
|
||||
text(x + 8, y + 105, "NO LOCATION", ink);
|
||||
if (save_menu.phase == SAVE_MENU_OPTIONS) {
|
||||
int selected_y = y + 32 + save_menu.selection * 20;
|
||||
rectangle(x + 6, selected_y, SAVE_MENU_W - 12, 16, RGB(23, 28, 21));
|
||||
rectangle(x + 10, selected_y + 5, 1, 5, ink);
|
||||
rectangle(x + 11, selected_y + 6, 1, 3, ink);
|
||||
rectangle(x + 12, selected_y + 7, 1, 1, ink);
|
||||
large_text(x + 20, y + 37, "SAVE", ink);
|
||||
large_text(x + 20, y + 57, "CLOSE", ink);
|
||||
text(x + 8, y + 124, "UP DOWN", ink);
|
||||
text(x + 8, y + 133, "A SELECT", ink);
|
||||
text(x + 8, y + 142, "B START CLOSE", ink);
|
||||
} else {
|
||||
int saved = save_menu.phase == SAVE_MENU_SAVED;
|
||||
large_text(x + 16, y + 37, saved ? "GAME" : "SAVE", ink);
|
||||
large_text(x + 16, y + 55, saved ? "SAVED" : "FAILED", ink);
|
||||
text(x + 8, y + 126, "A B START", ink);
|
||||
text(x + 8, y + 136, "TO CLOSE", ink);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user