Add Team and Bag pages to the Start menu
This commit is contained in:
8 files changed
+194
-66
No files matched your search
+96
-2
@@ -2,6 +2,90 @@
|
||||
|
||||
static void release_keys(void) { assert(!menu_input(0, 1)); }
|
||||
|
||||
static void press(unsigned keys)
|
||||
{
|
||||
release_keys();
|
||||
assert(menu_input(keys, 1));
|
||||
}
|
||||
|
||||
static void check_submenus(void)
|
||||
{
|
||||
unsigned char saved[sizeof(test_save)];
|
||||
memcpy(saved, test_save, sizeof(saved));
|
||||
static u16 expected[WIDTH * HEIGHT], zero[WIDTH * HEIGHT];
|
||||
current_room = OUTSIDE;
|
||||
int x = 108, y = 103;
|
||||
player_facing = FACING_UP;
|
||||
partner_owned = caught_count = active_member = ball_count = rod_owned = 0;
|
||||
for (int owned = 0; owned < 2; ++owned) {
|
||||
partner_owned = owned;
|
||||
caught_count = owned ? 2 : 0;
|
||||
caught_species[0] = FERNFOX; caught_species[1] = TIDEFIN;
|
||||
for (int parent = 0; parent < 2; ++parent) {
|
||||
press(parent ? START : SELECT);
|
||||
if (parent) press(A);
|
||||
assert(save_menu.phase == SAVE_MENU_TEAM);
|
||||
assert(!menu_input(parent ? A : SELECT, 1));
|
||||
draw_menu_scene(x, y);
|
||||
write_preview(owned ? "build/menu-team-owned-preview.ppm" : "build/menu-team-empty-preview.ppm");
|
||||
if (owned) {
|
||||
press(LEFT); assert(!menu_input(LEFT, 1));
|
||||
press(RIGHT); press(LEFT);
|
||||
draw_menu_scene(x, y);
|
||||
write_preview("build/menu-team-caught-preview.ppm");
|
||||
press(A);
|
||||
assert(active_member == 2);
|
||||
} else {
|
||||
int fx = follower_x, fy = follower_y, head = trail_head;
|
||||
press(B);
|
||||
assert(follower_x == fx && follower_y == fy && trail_head == head);
|
||||
}
|
||||
assert(save_menu.phase == (parent ? SAVE_MENU_OPTIONS : SAVE_MENU_CLOSED));
|
||||
assert(!menu_input(owned ? A : B, 1));
|
||||
if (parent) {
|
||||
render_scene(x, y); draw_save_menu();
|
||||
memcpy(expected, SCREEN, sizeof(expected));
|
||||
draw_team(); draw_menu_scene(x, y);
|
||||
assert(memcmp(expected, SCREEN, sizeof(expected)) == 0);
|
||||
press(A); press(SELECT);
|
||||
assert(save_menu.phase == SAVE_MENU_OPTIONS);
|
||||
press(B);
|
||||
}
|
||||
render_scene(x, y); memcpy(expected, SCREEN, sizeof(expected));
|
||||
draw_bag(); draw_menu_scene(x, y);
|
||||
assert(memcmp(expected, SCREEN, sizeof(expected)) == 0);
|
||||
}
|
||||
}
|
||||
press(START);
|
||||
for (int i = 1; i <= MENU_COUNT; ++i) {
|
||||
press(DOWN); assert(save_menu.selection == i % MENU_COUNT);
|
||||
assert(!menu_input(DOWN, 1));
|
||||
}
|
||||
press(DOWN); press(A);
|
||||
assert(save_menu.phase == SAVE_MENU_BAG);
|
||||
assert(!menu_input(A, 1));
|
||||
for (int full = 0; full < 2; ++full) {
|
||||
ball_count = full ? 99 : 0; rod_owned = full;
|
||||
test_pixels[0] = test_pixels[WIDTH * HEIGHT + 1] = 0xbeef;
|
||||
reset_dirty_rows(); draw_menu_scene(x, y);
|
||||
assert(pending_pixels() == WIDTH * HEIGHT);
|
||||
assert(test_pixels[0] == 0xbeef && test_pixels[WIDTH * HEIGHT + 1] == 0xbeef);
|
||||
write_preview(full ? "build/bag-full-preview.ppm" : "build/bag-zero-preview.ppm");
|
||||
if (!full) memcpy(zero, SCREEN, sizeof(zero));
|
||||
else assert(memcmp(zero, SCREEN, sizeof(zero)) != 0);
|
||||
}
|
||||
press(B); assert(save_menu.phase == SAVE_MENU_OPTIONS);
|
||||
assert(!menu_input(B, 1));
|
||||
press(A); press(START);
|
||||
assert(save_menu.phase == SAVE_MENU_CLOSED && !menu_input(START, 1));
|
||||
press(SELECT); press(START);
|
||||
assert(save_menu.phase == SAVE_MENU_CLOSED);
|
||||
assert(x == 108 && y == 103 && player_facing == FACING_UP && current_room == OUTSIDE);
|
||||
assert(memcmp(saved, test_save, sizeof(saved)) == 0);
|
||||
load_progress();
|
||||
save_menu = (struct SaveMenuState){SAVE_MENU_CLOSED, 0, 0};
|
||||
}
|
||||
|
||||
void check_save_menu(void)
|
||||
{
|
||||
unsigned char saved[sizeof(test_save)];
|
||||
@@ -24,7 +108,7 @@ void check_save_menu(void)
|
||||
release_keys();
|
||||
assert(menu_input(UP, 1) && save_menu.selection == 0);
|
||||
release_keys();
|
||||
assert(menu_input(UP, 1) && save_menu.selection == 1);
|
||||
assert(menu_input(UP, 1) && save_menu.selection == MENU_CLOSE);
|
||||
release_keys();
|
||||
assert(menu_input(A, 1) && save_menu.phase == SAVE_MENU_CLOSED);
|
||||
const unsigned cancel[] = {B, START};
|
||||
@@ -38,6 +122,10 @@ void check_save_menu(void)
|
||||
assert(memcmp(saved, test_save, sizeof(saved)) == 0);
|
||||
release_keys();
|
||||
assert(menu_input(START, 1));
|
||||
for (int i = 0; i < MENU_SAVE; ++i) {
|
||||
release_keys();
|
||||
assert(menu_input(DOWN, 1));
|
||||
}
|
||||
release_keys();
|
||||
assert(menu_input(A, 1) && save_menu.phase == SAVE_MENU_SAVED);
|
||||
test_save[0] = 0;
|
||||
@@ -61,7 +149,7 @@ void check_save_menu(void)
|
||||
memcpy(expected, SCREEN, sizeof(expected));
|
||||
for (int phase = SAVE_MENU_OPTIONS; phase <= SAVE_MENU_FAILED; ++phase) {
|
||||
save_menu.phase = (enum SaveMenuPhase)phase;
|
||||
for (int choice = 0; choice < 2; ++choice) {
|
||||
for (int choice = 0; choice < MENU_COUNT; ++choice) {
|
||||
save_menu.selection = choice;
|
||||
test_pixels[0] = test_pixels[WIDTH * HEIGHT + 1] = 0xbeef;
|
||||
reset_dirty_rows();
|
||||
@@ -83,6 +171,11 @@ void check_save_menu(void)
|
||||
"build/game-saved-preview.ppm", "build/save-failed-preview.ppm"};
|
||||
write_preview(paths[phase - SAVE_MENU_OPTIONS]);
|
||||
}
|
||||
if (room == OUTSIDE && phase == SAVE_MENU_OPTIONS) {
|
||||
const char *paths[] = {"build/menu-team-preview.ppm", "build/menu-bag-preview.ppm",
|
||||
"build/menu-save-preview.ppm", "build/menu-close-preview.ppm"};
|
||||
write_preview(paths[choice]);
|
||||
}
|
||||
}
|
||||
render_scene(108, 103);
|
||||
assert(memcmp(expected, SCREEN, sizeof(expected)) == 0);
|
||||
@@ -92,4 +185,5 @@ 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_submenus();
|
||||
}
|
||||
@@ -56,6 +56,10 @@ void check_progress(void)
|
||||
memcpy(kinds, caught_species, sizeof(kinds));
|
||||
assert(!menu_input(0, 1));
|
||||
assert(menu_input(START, 1));
|
||||
for (int i = 0; i < MENU_SAVE; ++i) {
|
||||
assert(!menu_input(0, 1));
|
||||
assert(menu_input(DOWN, 1));
|
||||
}
|
||||
assert(!menu_input(0, 1));
|
||||
assert(menu_input(A, 1) && save_menu.phase == SAVE_MENU_FAILED);
|
||||
int after[] = {partner_owned, balls_given, rod_owned, ball_count, caught_count, active_member};
|
||||
|
||||
@@ -21,6 +21,10 @@ void save_at_menu(const struct Location *location, enum SaveMenuPhase expected)
|
||||
{
|
||||
assert(!save_menu_input(0, 1, location));
|
||||
assert(save_menu_input(START, 1, location) && save_menu.phase == SAVE_MENU_OPTIONS);
|
||||
for (int i = 0; i < MENU_SAVE; ++i) {
|
||||
assert(!save_menu_input(0, 1, location));
|
||||
assert(save_menu_input(DOWN, 1, location));
|
||||
}
|
||||
assert(!save_menu_input(0, 1, location));
|
||||
assert(save_menu_input(A, 1, location) && save_menu.phase == expected);
|
||||
assert(!save_menu_input(0, 1, location));
|
||||
|
||||
Reference in new issue
Block a user