Add Team and Bag pages to the Start menu #13
No files matched your search
@@ -129,6 +129,7 @@ extern struct SaveMenuState save_menu;
|
||||
int save_menu_input(unsigned keys, int can_open, const struct Location *location);
|
||||
void draw_save_menu(void);
|
||||
void draw_menu_scene(int x, int y);
|
||||
int menu_redraw_is_panel(enum SaveMenuPhase before, enum SaveMenuPhase after);
|
||||
void draw_bag(void);
|
||||
int has_caught(enum Species kind);
|
||||
int near_npc(int x, int y);
|
||||
|
||||
+7
-5
@@ -86,17 +86,19 @@ int main(void)
|
||||
unsigned now = movement_time();
|
||||
music_update(now);
|
||||
if (pressed & R_BUTTON) music_toggle_mute();
|
||||
int menu_was_open = save_menu.phase != SAVE_MENU_CLOSED;
|
||||
enum SaveMenuPhase menu_before = save_menu.phase;
|
||||
const struct Location here = {current_room, x, y, player_facing};
|
||||
int menu_changed = save_menu_input(keys,
|
||||
battle.phase == BATTLE_OFF && dialogue_page < 0, &here);
|
||||
if (menu_was_open || save_menu.phase != SAVE_MENU_CLOSED) {
|
||||
if (menu_before != SAVE_MENU_CLOSED || save_menu.phase != SAVE_MENU_CLOSED) {
|
||||
pause_movement_at(now);
|
||||
if (menu_changed) {
|
||||
DISPLAY = 0x0080;
|
||||
draw_menu_scene(x, y);
|
||||
int panel_only = menu_redraw_is_panel(menu_before, save_menu.phase);
|
||||
if (!panel_only) DISPLAY = 0x0080;
|
||||
if (panel_only) draw_save_menu();
|
||||
else draw_menu_scene(x, y);
|
||||
present_frame();
|
||||
DISPLAY = 0x0403;
|
||||
if (!panel_only) DISPLAY = 0x0403;
|
||||
pause_movement_at(movement_time());
|
||||
} else present_frame();
|
||||
continue;
|
||||
|
||||
@@ -74,6 +74,12 @@ void draw_menu_scene(int x, int y)
|
||||
}
|
||||
}
|
||||
|
||||
int menu_redraw_is_panel(enum SaveMenuPhase before, enum SaveMenuPhase after)
|
||||
{
|
||||
return before >= SAVE_MENU_OPTIONS && before <= SAVE_MENU_FAILED &&
|
||||
after >= SAVE_MENU_OPTIONS && after <= SAVE_MENU_FAILED;
|
||||
}
|
||||
|
||||
void draw_save_menu(void)
|
||||
{
|
||||
u16 ink = RGB(5, 8, 11), cream = RGB(30, 30, 26);
|
||||
|
||||
@@ -86,6 +86,56 @@ static void check_submenus(void)
|
||||
save_menu = (struct SaveMenuState){SAVE_MENU_CLOSED, 0, 0};
|
||||
}
|
||||
|
||||
static void check_highlight_redraw(void)
|
||||
{
|
||||
static u16 before[WIDTH * HEIGHT], visible[WIDTH * HEIGHT];
|
||||
unsigned char saved[sizeof(test_save)];
|
||||
memcpy(saved, test_save, sizeof(saved));
|
||||
enum Room old_room = current_room;
|
||||
for (int from = SAVE_MENU_CLOSED; from <= SAVE_MENU_BAG; ++from)
|
||||
for (int to = SAVE_MENU_CLOSED; to <= SAVE_MENU_BAG; ++to)
|
||||
assert(menu_redraw_is_panel((enum SaveMenuPhase)from, (enum SaveMenuPhase)to) ==
|
||||
(from >= SAVE_MENU_OPTIONS && from <= SAVE_MENU_FAILED &&
|
||||
to >= SAVE_MENU_OPTIONS && to <= SAVE_MENU_FAILED));
|
||||
for (int room = OUTSIDE; room < ROOM_COUNT; ++room) {
|
||||
current_room = (enum Room)room;
|
||||
for (int up = 0; up < 2; ++up) {
|
||||
save_menu = (struct SaveMenuState){SAVE_MENU_OPTIONS, 0, 0};
|
||||
draw_menu_scene(108, 103);
|
||||
copy_pending_rows(visible);
|
||||
for (int step = 0; step < MENU_COUNT; ++step) {
|
||||
memcpy(before, SCREEN, sizeof(before));
|
||||
enum SaveMenuPhase previous = save_menu.phase;
|
||||
press(up ? UP : DOWN);
|
||||
assert(save_menu.selection == (up ? (MENU_COUNT - step - 1) % MENU_COUNT : (step + 1) % MENU_COUNT));
|
||||
assert(menu_redraw_is_panel(previous, save_menu.phase));
|
||||
assert(!menu_input(up ? UP : DOWN, 1));
|
||||
reset_dirty_rows();
|
||||
test_pixels[0] = test_pixels[WIDTH * HEIGHT + 1] = 0xbeef;
|
||||
draw_save_menu();
|
||||
assert(pending_pixels() == SAVE_MENU_W * SAVE_MENU_H);
|
||||
for (int y = 0; y < HEIGHT; ++y)
|
||||
for (int x = 0; x < WIDTH; ++x)
|
||||
if (x < SAVE_MENU_X || x >= SAVE_MENU_X + SAVE_MENU_W ||
|
||||
y < SAVE_MENU_Y || y >= SAVE_MENU_Y + SAVE_MENU_H)
|
||||
assert(SCREEN[y * WIDTH + x] == before[y * WIDTH + x]);
|
||||
assert(memcmp(before, SCREEN, sizeof(before)) != 0);
|
||||
assert(test_pixels[0] == 0xbeef && test_pixels[WIDTH * HEIGHT + 1] == 0xbeef);
|
||||
copy_pending_rows(visible);
|
||||
assert(memcmp(visible, SCREEN, sizeof(visible)) == 0);
|
||||
if (room == OUTSIDE && !up) {
|
||||
const char *paths[] = {"build/highlight-team-preview.ppm", "build/highlight-bag-preview.ppm",
|
||||
"build/highlight-save-preview.ppm", "build/highlight-close-preview.ppm"};
|
||||
write_preview(paths[save_menu.selection]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(memcmp(saved, test_save, sizeof(saved)) == 0);
|
||||
current_room = old_room;
|
||||
save_menu = (struct SaveMenuState){SAVE_MENU_CLOSED, 0, 0};
|
||||
}
|
||||
|
||||
void check_save_menu(void)
|
||||
{
|
||||
unsigned char saved[sizeof(test_save)];
|
||||
@@ -185,5 +235,6 @@ void check_save_menu(void)
|
||||
assert(random_state == rng && grass_steps == grass && door_open == door);
|
||||
current_room = old_room;
|
||||
save_menu = (struct SaveMenuState){SAVE_MENU_CLOSED, 0, 0};
|
||||
check_highlight_redraw();
|
||||
check_submenus();
|
||||
}
|
||||
Reference in new issue
Block a user