mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
(menu_common_backend.c) Cut down on some code duplication
This commit is contained in:
parent
bbb28c06e6
commit
fae308d1f9
@ -55,17 +55,15 @@ static int menu_message_toggle(unsigned action)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int menu_setting_ok_pressed(unsigned type,
|
||||
const char *path, const char *label,
|
||||
static int menu_setting_ok_pressed(
|
||||
menu_file_list_cbs_t *cbs,
|
||||
unsigned type,
|
||||
const char *path,
|
||||
const char *label,
|
||||
unsigned action)
|
||||
{
|
||||
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
|
||||
file_list_get_actiondata_at_offset(driver.menu->selection_buf,
|
||||
driver.menu->selection_ptr);
|
||||
|
||||
if (cbs && cbs->action_ok)
|
||||
return cbs->action_ok(path, label, type, driver.menu->selection_ptr);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -214,29 +212,25 @@ static int menu_start_screen_iterate(unsigned action)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int menu_setting_start_pressed(unsigned type,
|
||||
const char *label, unsigned action)
|
||||
static int menu_setting_start_pressed(
|
||||
menu_file_list_cbs_t *cbs,
|
||||
unsigned type,
|
||||
const char *label,
|
||||
unsigned action)
|
||||
{
|
||||
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
|
||||
file_list_get_actiondata_at_offset(driver.menu->selection_buf,
|
||||
driver.menu->selection_ptr);
|
||||
|
||||
if (cbs && cbs->action_start)
|
||||
return cbs->action_start(type, label, action);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int menu_setting_toggle_pressed(unsigned type,
|
||||
const char *label, unsigned action)
|
||||
static int menu_setting_toggle_pressed(
|
||||
menu_file_list_cbs_t *cbs,
|
||||
unsigned type,
|
||||
const char *label,
|
||||
unsigned action)
|
||||
{
|
||||
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
|
||||
file_list_get_actiondata_at_offset(driver.menu->selection_buf,
|
||||
driver.menu->selection_ptr);
|
||||
|
||||
if (cbs && cbs->action_toggle)
|
||||
return cbs->action_toggle(type, label, action);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -246,12 +240,17 @@ static int menu_settings_iterate(unsigned action)
|
||||
const char *label = NULL;
|
||||
unsigned type = 0;
|
||||
unsigned menu_type = 0;
|
||||
|
||||
menu_file_list_cbs_t *cbs = NULL;
|
||||
|
||||
driver.menu->frame_buf_pitch = driver.menu->width * 2;
|
||||
|
||||
file_list_get_at_offset(driver.menu->selection_buf,
|
||||
driver.menu->selection_ptr, &path, &label, &type);
|
||||
|
||||
cbs = (menu_file_list_cbs_t*)
|
||||
file_list_get_actiondata_at_offset(driver.menu->selection_buf,
|
||||
driver.menu->selection_ptr);
|
||||
|
||||
if (driver.menu->need_refresh && action != MENU_ACTION_MESSAGE)
|
||||
action = MENU_ACTION_REFRESH;
|
||||
|
||||
@ -281,17 +280,17 @@ static int menu_settings_iterate(unsigned action)
|
||||
0, driver.menu->selection_ptr);
|
||||
break;
|
||||
case MENU_ACTION_OK:
|
||||
if (menu_setting_ok_pressed(type, path, label, action) == 0)
|
||||
if (menu_setting_ok_pressed(cbs, type, path, label, action) == 0)
|
||||
return 0;
|
||||
/* fall-through */
|
||||
case MENU_ACTION_START:
|
||||
if (menu_setting_start_pressed(type, label, action) == 0)
|
||||
if (menu_setting_start_pressed(cbs, type, label, action) == 0)
|
||||
return 0;
|
||||
/* fall-through */
|
||||
case MENU_ACTION_LEFT:
|
||||
case MENU_ACTION_RIGHT:
|
||||
{
|
||||
int ret = menu_setting_toggle_pressed(type, label, action);
|
||||
int ret = menu_setting_toggle_pressed(cbs, type, label, action);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user