Skip to content

Commit

Permalink
Cleaned up navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Polprzewodnikowy committed Dec 21, 2023
1 parent 621e50c commit 3846547
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 19 deletions.
6 changes: 0 additions & 6 deletions src/menu/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ static void actions_clear (menu_t *menu) {
menu->actions.enter = false;
menu->actions.back = false;
menu->actions.options = false;
menu->actions.system_info = false;
menu->actions.settings = false;
menu->actions.credits = false;
}

static void actions_update_direction (menu_t *menu) {
Expand Down Expand Up @@ -91,11 +89,7 @@ static void actions_update_buttons (menu_t *menu) {
menu->actions.back = true;
} else if (pressed.r) {
menu->actions.options = true;
} else if (pressed.z) {
menu->actions.system_info = true;
} else if (pressed.start) {
menu->actions.credits = true;
} else if (pressed.l) {
menu->actions.settings = true;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/menu/menu_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ typedef struct {
bool enter;
bool back;
bool options;
bool system_info;
bool settings;
bool credits;
} actions;

struct {
Expand Down
42 changes: 33 additions & 9 deletions src/menu/views/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,36 @@ static component_context_menu_t entry_context_menu = {
}
};

static void edit_settings (menu_t *menu) {
menu->next_mode = MENU_MODE_SETTINGS_EDITOR;
}

static void show_system_info (menu_t *menu) {
menu->next_mode = MENU_MODE_SYSTEM_INFO;
}

static void show_credits (menu_t *menu) {
menu->next_mode = MENU_MODE_CREDITS;
}

static component_context_menu_t settings_context_menu = {
.list = {
{ .text = "Edit settings", .action = edit_settings },
{ .text = "Show system info", .action = show_system_info },
{ .text = "Show credits", .action = show_credits },
COMPONENT_CONTEXT_MENU_LIST_END,
}
};

static void process (menu_t *menu) {
if (component_context_menu_process(menu, &entry_context_menu)) {
return;
}

if (component_context_menu_process(menu, &settings_context_menu)) {
return;
}

int scroll_speed = menu->actions.go_fast ? 10 : 1;

if (menu->browser.entries > 1) {
Expand Down Expand Up @@ -284,12 +309,8 @@ static void process (menu_t *menu) {
}
} else if (menu->actions.options && menu->browser.entry) {
component_context_menu_show(&entry_context_menu);
} else if (menu->actions.system_info) {
menu->next_mode = MENU_MODE_SYSTEM_INFO;
} else if (menu->actions.credits) {
menu->next_mode = MENU_MODE_CREDITS;
} else if (menu->actions.settings) {
menu->next_mode = MENU_MODE_SETTINGS_EDITOR;
component_context_menu_show(&settings_context_menu);
}
}

Expand Down Expand Up @@ -326,29 +347,32 @@ static void draw (menu_t *menu, surface_t *d) {

component_actions_bar_text_draw(
ALIGN_RIGHT, VALIGN_TOP,
"%s\n"
"L: Settings",
menu->browser.entries == 0 ? "" : "R: Options"
"Start: Settings\n"
"^%02XR: Options^00",
menu->browser.entries == 0 ? STL_UNKNOWN : STL_DEFAULT
);

if (menu->current_time >= 0) {
component_actions_bar_text_draw(
ALIGN_CENTER, VALIGN_TOP,
"Z: System Info | Start: Credits\n"
"\n"
"%s",
ctime(&menu->current_time)
);
}

component_context_menu_draw(&entry_context_menu);

component_context_menu_draw(&settings_context_menu);

rdpq_detach_show();
}


void view_browser_init (menu_t *menu) {
if (!menu->browser.valid) {
component_context_menu_init(&entry_context_menu);
component_context_menu_init(&settings_context_menu);
if (load_directory(menu)) {
path_free(menu->browser.directory);
menu->browser.directory = path_init("sd:/", "");
Expand Down
4 changes: 2 additions & 2 deletions src/menu/views/load_rom.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ static component_context_menu_t set_tv_type_context_menu = { .list = {
}};

static component_context_menu_t options_context_menu = { .list = {
{ .text = "Set Save Type", .submenu = &set_save_type_context_menu },
{ .text = "Set TV Type", .submenu = &set_tv_type_context_menu },
{ .text = "Set save type", .submenu = &set_save_type_context_menu },
{ .text = "Set TV type", .submenu = &set_tv_type_context_menu },
COMPONENT_CONTEXT_MENU_LIST_END,
}};

Expand Down

0 comments on commit 3846547

Please sign in to comment.