2002-05-17 12:22:24 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Robert E. Hak
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-05-17 12:22:24 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2005-10-30 22:34:51 +00:00
|
|
|
/*
|
|
|
|
2005 Kevin Ferrare :
|
|
|
|
- Multi screen support
|
|
|
|
- Rewrote/removed a lot of code now useless with the new gui API
|
|
|
|
*/
|
2002-05-26 17:03:17 +00:00
|
|
|
#include <stdbool.h>
|
2004-03-12 10:20:33 +00:00
|
|
|
#include <stdlib.h>
|
2007-03-01 11:14:46 +00:00
|
|
|
#include "config.h"
|
2007-11-16 08:18:08 +00:00
|
|
|
#include "system.h"
|
2002-08-31 04:58:35 +00:00
|
|
|
|
2010-02-26 03:45:41 +00:00
|
|
|
#include "appevents.h"
|
2002-05-17 12:22:24 +00:00
|
|
|
#include "lcd.h"
|
2002-09-12 13:33:59 +00:00
|
|
|
#include "font.h"
|
2009-08-19 22:15:45 +00:00
|
|
|
#include "file.h"
|
2002-05-17 12:22:24 +00:00
|
|
|
#include "menu.h"
|
2002-05-21 14:25:45 +00:00
|
|
|
#include "button.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "debug.h"
|
2002-08-23 02:17:00 +00:00
|
|
|
#include "usb.h"
|
2002-08-11 09:17:47 +00:00
|
|
|
#include "panic.h"
|
2002-08-20 19:37:00 +00:00
|
|
|
#include "settings.h"
|
2007-02-08 04:33:41 +00:00
|
|
|
#include "settings_list.h"
|
2007-07-11 05:41:23 +00:00
|
|
|
#include "option_select.h"
|
2002-09-24 18:04:15 +00:00
|
|
|
#include "screens.h"
|
2004-03-14 21:33:53 +00:00
|
|
|
#include "talk.h"
|
2004-07-23 23:01:20 +00:00
|
|
|
#include "lang.h"
|
2004-07-26 16:06:59 +00:00
|
|
|
#include "misc.h"
|
2006-08-15 12:27:07 +00:00
|
|
|
#include "action.h"
|
2007-02-08 04:33:41 +00:00
|
|
|
#include "menus/exported_menus.h"
|
2007-02-08 10:28:42 +00:00
|
|
|
#include "string.h"
|
2007-03-01 11:14:46 +00:00
|
|
|
#include "root_menu.h"
|
|
|
|
#include "audio.h"
|
2008-03-26 03:35:24 +00:00
|
|
|
#include "viewport.h"
|
2008-05-03 12:30:40 +00:00
|
|
|
#include "quickscreen.h"
|
2011-11-15 13:22:02 +00:00
|
|
|
#include "shortcuts.h"
|
2002-08-30 13:49:32 +00:00
|
|
|
|
2002-06-14 08:47:44 +00:00
|
|
|
#include "icons.h"
|
2002-08-30 13:49:32 +00:00
|
|
|
|
2005-10-30 22:34:51 +00:00
|
|
|
/* gui api */
|
|
|
|
#include "list.h"
|
2007-02-08 04:33:41 +00:00
|
|
|
|
2007-05-08 11:55:43 +00:00
|
|
|
#define MAX_MENUS 8
|
2007-02-08 04:33:41 +00:00
|
|
|
/* used to allow for dynamic menus */
|
|
|
|
#define MAX_MENU_SUBITEMS 64
|
2007-03-17 14:10:51 +00:00
|
|
|
static struct menu_item_ex *current_submenus_menu;
|
2007-02-08 04:33:41 +00:00
|
|
|
static int current_subitems[MAX_MENU_SUBITEMS];
|
|
|
|
static int current_subitems_count = 0;
|
2007-10-21 00:23:23 +00:00
|
|
|
static int talk_menu_item(int selected_item, void *data);
|
2007-02-08 04:33:41 +00:00
|
|
|
|
2021-10-27 05:28:46 +00:00
|
|
|
struct menu_data_t
|
|
|
|
{
|
|
|
|
const struct menu_item_ex *menu;
|
|
|
|
int selected;
|
|
|
|
};
|
|
|
|
|
2007-05-19 19:54:11 +00:00
|
|
|
static void get_menu_callback(const struct menu_item_ex *m,
|
2021-10-21 20:42:01 +00:00
|
|
|
menu_callback_type *menu_callback)
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
2007-02-19 02:14:51 +00:00
|
|
|
if (m->flags&(MENU_HAS_DESC|MENU_DYNAMIC_DESC))
|
2007-02-08 10:28:42 +00:00
|
|
|
*menu_callback= m->callback_and_desc->menu_callback;
|
2010-02-11 10:41:06 +00:00
|
|
|
else
|
2007-02-08 10:28:42 +00:00
|
|
|
*menu_callback = m->menu_callback;
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
|
|
|
|
2021-10-27 05:28:46 +00:00
|
|
|
static bool query_audio_status(int *old_audio_status)
|
|
|
|
{
|
|
|
|
bool redraw_list = false;
|
|
|
|
/* query audio status to see if it changed */
|
|
|
|
int new_audio_status = audio_status();
|
|
|
|
if (*old_audio_status != new_audio_status)
|
|
|
|
{ /* force a redraw if anything changed the audio status from outside */
|
|
|
|
*old_audio_status = new_audio_status;
|
|
|
|
redraw_list = true;
|
|
|
|
}
|
|
|
|
return redraw_list;
|
|
|
|
}
|
|
|
|
|
2007-02-08 04:33:41 +00:00
|
|
|
static int get_menu_selection(int selected_item, const struct menu_item_ex *menu)
|
|
|
|
{
|
|
|
|
int type = (menu->flags&MENU_TYPE_MASK);
|
2009-06-26 17:59:33 +00:00
|
|
|
if ((type == MT_MENU || type == MT_RETURN_ID)
|
|
|
|
&& (selected_item<current_subitems_count))
|
2007-02-08 04:33:41 +00:00
|
|
|
return current_subitems[selected_item];
|
|
|
|
return selected_item;
|
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
static int find_menu_selection(int selected)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i=0; i< current_subitems_count; i++)
|
|
|
|
if (current_subitems[i] == selected)
|
|
|
|
return i;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-08-20 16:47:44 +00:00
|
|
|
static const char* get_menu_item_name(int selected_item,
|
|
|
|
void * data,
|
|
|
|
char *buffer,
|
|
|
|
size_t buffer_len)
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
2020-07-27 03:48:25 +00:00
|
|
|
const char *name;
|
2007-02-08 04:33:41 +00:00
|
|
|
const struct menu_item_ex *menu = (const struct menu_item_ex *)data;
|
|
|
|
int type = (menu->flags&MENU_TYPE_MASK);
|
|
|
|
selected_item = get_menu_selection(selected_item, menu);
|
2010-02-11 10:41:06 +00:00
|
|
|
|
2007-02-08 04:33:41 +00:00
|
|
|
/* only MT_MENU or MT_RETURN_ID is allowed in here */
|
|
|
|
if (type == MT_RETURN_ID)
|
|
|
|
{
|
2007-02-27 09:06:30 +00:00
|
|
|
if (menu->flags&MENU_DYNAMIC_DESC)
|
2020-07-27 03:48:25 +00:00
|
|
|
{
|
|
|
|
name = menu->menu_get_name_and_icon->list_get_name(selected_item,
|
2019-09-20 08:07:29 +00:00
|
|
|
menu->menu_get_name_and_icon->list_get_name_data, buffer, buffer_len);
|
2020-07-27 03:48:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
name = menu->strings[selected_item];
|
|
|
|
|
|
|
|
if (P2ID((unsigned char *)name) > VOICEONLY_DELIMITER)
|
|
|
|
name = "";
|
|
|
|
|
|
|
|
return name;
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
2019-09-21 00:23:18 +00:00
|
|
|
if (type == MT_MENU)
|
|
|
|
menu = menu->submenus[selected_item];
|
2010-02-11 10:41:06 +00:00
|
|
|
|
2007-03-03 14:23:03 +00:00
|
|
|
if ((menu->flags&MENU_DYNAMIC_DESC) && (type != MT_SETTING_W_TEXT))
|
2007-02-26 08:17:07 +00:00
|
|
|
return menu->menu_get_name_and_icon->list_get_name(selected_item,
|
2019-09-20 08:07:29 +00:00
|
|
|
menu->menu_get_name_and_icon->list_get_name_data, buffer, buffer_len);
|
2010-02-11 10:41:06 +00:00
|
|
|
|
2007-02-08 04:33:41 +00:00
|
|
|
type = (menu->flags&MENU_TYPE_MASK);
|
2007-03-03 14:23:03 +00:00
|
|
|
if ((type == MT_SETTING) || (type == MT_SETTING_W_TEXT))
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
2021-10-27 05:28:46 +00:00
|
|
|
const struct settings_list *v = find_setting(menu->variable, NULL);
|
2007-02-08 04:33:41 +00:00
|
|
|
if (v)
|
|
|
|
return str(v->lang_id);
|
|
|
|
else return "Not Done yet!";
|
|
|
|
}
|
|
|
|
return P2STR(menu->callback_and_desc->desc);
|
|
|
|
}
|
2020-07-17 14:31:31 +00:00
|
|
|
|
2009-07-11 00:22:26 +00:00
|
|
|
static enum themable_icons menu_get_icon(int selected_item, void * data)
|
2007-02-14 06:58:30 +00:00
|
|
|
{
|
|
|
|
const struct menu_item_ex *menu = (const struct menu_item_ex *)data;
|
2007-03-03 14:23:03 +00:00
|
|
|
int menu_icon = Icon_NOICON;
|
2019-09-21 00:23:18 +00:00
|
|
|
int type = (menu->flags&MENU_TYPE_MASK);
|
2007-02-14 06:58:30 +00:00
|
|
|
selected_item = get_menu_selection(selected_item, menu);
|
2010-02-11 10:41:06 +00:00
|
|
|
|
2019-09-21 00:23:18 +00:00
|
|
|
if (type == MT_RETURN_ID)
|
2007-03-25 14:31:56 +00:00
|
|
|
{
|
2007-04-16 09:14:36 +00:00
|
|
|
return Icon_Menu_functioncall;
|
2007-03-25 14:31:56 +00:00
|
|
|
}
|
2019-09-21 00:23:18 +00:00
|
|
|
if (type == MT_MENU)
|
|
|
|
menu = menu->submenus[selected_item];
|
|
|
|
|
2007-02-26 08:17:07 +00:00
|
|
|
if (menu->flags&MENU_HAS_DESC)
|
2007-03-03 13:52:14 +00:00
|
|
|
menu_icon = menu->callback_and_desc->icon_id;
|
2007-02-26 08:17:07 +00:00
|
|
|
else if (menu->flags&MENU_DYNAMIC_DESC)
|
2007-03-03 13:52:14 +00:00
|
|
|
menu_icon = menu->menu_get_name_and_icon->icon_id;
|
2010-02-11 10:41:06 +00:00
|
|
|
|
2007-04-16 09:14:36 +00:00
|
|
|
if (menu_icon == Icon_NOICON)
|
2007-02-14 06:58:30 +00:00
|
|
|
{
|
2021-10-27 05:28:46 +00:00
|
|
|
unsigned int flags = (menu->flags&MENU_TYPE_MASK);
|
|
|
|
if(flags == MT_MENU)
|
|
|
|
menu_icon = Icon_Submenu;
|
|
|
|
else if (flags == MT_SETTING || flags == MT_SETTING_W_TEXT)
|
|
|
|
menu_icon = Icon_Menu_setting;
|
|
|
|
else if (flags == MT_FUNCTION_CALL || flags == MT_RETURN_VALUE)
|
|
|
|
menu_icon = Icon_Menu_functioncall;
|
2007-02-14 06:58:30 +00:00
|
|
|
}
|
2007-04-16 09:14:36 +00:00
|
|
|
return menu_icon;
|
2007-02-14 06:58:30 +00:00
|
|
|
}
|
2007-02-08 04:33:41 +00:00
|
|
|
|
2021-10-23 02:17:36 +00:00
|
|
|
static int init_menu_lists(const struct menu_item_ex *menu,
|
2008-03-26 03:35:24 +00:00
|
|
|
struct gui_synclist *lists, int selected, bool callback,
|
|
|
|
struct viewport parent[NB_SCREENS])
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
2021-08-03 11:21:29 +00:00
|
|
|
if (!menu || !lists)
|
|
|
|
{
|
|
|
|
panicf("init_menu_lists, NULL pointer");
|
2021-10-23 02:17:36 +00:00
|
|
|
return 0;
|
2021-08-03 11:21:29 +00:00
|
|
|
}
|
|
|
|
|
2021-04-07 16:15:20 +00:00
|
|
|
int i;
|
2021-10-23 02:17:36 +00:00
|
|
|
int start_action = ACTION_ENTER_MENUITEM;
|
2021-04-07 16:15:20 +00:00
|
|
|
int count = MIN(MENU_GET_COUNT(menu->flags), MAX_MENU_SUBITEMS);
|
2007-03-25 14:31:56 +00:00
|
|
|
int type = (menu->flags&MENU_TYPE_MASK);
|
2007-02-08 04:33:41 +00:00
|
|
|
menu_callback_type menu_callback = NULL;
|
2007-04-16 09:14:36 +00:00
|
|
|
int icon;
|
2019-09-20 08:07:29 +00:00
|
|
|
char * title;
|
2007-02-08 04:33:41 +00:00
|
|
|
current_subitems_count = 0;
|
2007-03-07 13:00:46 +00:00
|
|
|
|
2007-03-25 14:31:56 +00:00
|
|
|
if (type == MT_RETURN_ID)
|
|
|
|
get_menu_callback(menu, &menu_callback);
|
|
|
|
|
2007-02-08 04:33:41 +00:00
|
|
|
for (i=0; i<count; i++)
|
|
|
|
{
|
2007-03-25 14:31:56 +00:00
|
|
|
if (type != MT_RETURN_ID)
|
|
|
|
get_menu_callback(menu->submenus[i],&menu_callback);
|
2007-02-08 04:33:41 +00:00
|
|
|
if (menu_callback)
|
|
|
|
{
|
2007-03-25 14:31:56 +00:00
|
|
|
if (menu_callback(ACTION_REQUEST_MENUITEM,
|
2020-07-19 17:42:04 +00:00
|
|
|
type==MT_RETURN_ID ? (void*)(intptr_t)i: menu->submenus[i], lists)
|
2007-02-08 04:33:41 +00:00
|
|
|
!= ACTION_EXIT_MENUITEM)
|
|
|
|
{
|
|
|
|
current_subitems[current_subitems_count] = i;
|
|
|
|
current_subitems_count++;
|
|
|
|
}
|
|
|
|
}
|
2010-02-11 10:41:06 +00:00
|
|
|
else
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
|
|
|
current_subitems[current_subitems_count] = i;
|
|
|
|
current_subitems_count++;
|
|
|
|
}
|
|
|
|
}
|
2021-04-07 16:15:20 +00:00
|
|
|
|
2007-03-17 14:16:11 +00:00
|
|
|
current_submenus_menu = (struct menu_item_ex *)menu;
|
2007-03-17 14:10:51 +00:00
|
|
|
|
2008-03-26 03:35:24 +00:00
|
|
|
gui_synclist_init(lists,get_menu_item_name,(void*)menu,false,1, parent);
|
2019-09-20 08:07:29 +00:00
|
|
|
|
|
|
|
if (menu->flags&MENU_HAS_DESC)
|
|
|
|
{
|
2007-04-16 09:14:36 +00:00
|
|
|
icon = menu->callback_and_desc->icon_id;
|
2019-09-20 08:07:29 +00:00
|
|
|
title = P2STR(menu->callback_and_desc->desc);
|
|
|
|
}
|
|
|
|
else if (menu->flags&MENU_DYNAMIC_DESC)
|
|
|
|
{
|
|
|
|
char buffer[80];
|
|
|
|
icon = menu->menu_get_name_and_icon->icon_id;
|
|
|
|
title = menu->menu_get_name_and_icon->
|
|
|
|
list_get_name(-1, menu->menu_get_name_and_icon->
|
|
|
|
list_get_name_data, buffer, sizeof(buffer));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
icon = Icon_NOICON;
|
|
|
|
title = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (icon == Icon_NOICON)
|
|
|
|
icon = Icon_Submenu_Entered;
|
|
|
|
gui_synclist_set_title(lists, title, icon);
|
2009-12-16 08:36:46 +00:00
|
|
|
gui_synclist_set_icon_callback(lists, global_settings.show_icons?menu_get_icon:NULL);
|
2007-10-21 00:23:23 +00:00
|
|
|
if(global_settings.talk_menu)
|
|
|
|
gui_synclist_set_voice_callback(lists, talk_menu_item);
|
2007-02-08 04:33:41 +00:00
|
|
|
gui_synclist_set_nb_items(lists,current_subitems_count);
|
2007-03-01 11:14:46 +00:00
|
|
|
gui_synclist_select_item(lists, find_menu_selection(selected));
|
2010-02-11 10:41:06 +00:00
|
|
|
|
2007-02-08 10:28:42 +00:00
|
|
|
get_menu_callback(menu,&menu_callback);
|
2007-02-08 04:33:41 +00:00
|
|
|
if (callback && menu_callback)
|
2021-10-23 02:17:36 +00:00
|
|
|
start_action = menu_callback(start_action, menu, lists);
|
|
|
|
|
|
|
|
return start_action;
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
|
|
|
|
2007-10-21 00:23:23 +00:00
|
|
|
static int talk_menu_item(int selected_item, void *data)
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
2007-10-21 00:23:23 +00:00
|
|
|
const struct menu_item_ex *menu = (const struct menu_item_ex *)data;
|
2007-02-08 04:33:41 +00:00
|
|
|
int id = -1;
|
2007-03-03 14:23:03 +00:00
|
|
|
int type;
|
2007-03-05 00:32:33 +00:00
|
|
|
unsigned char *str;
|
2007-10-21 00:23:23 +00:00
|
|
|
int sel = get_menu_selection(selected_item, menu);
|
2010-02-11 10:41:06 +00:00
|
|
|
|
2007-02-08 04:33:41 +00:00
|
|
|
if ((menu->flags&MENU_TYPE_MASK) == MT_MENU)
|
|
|
|
{
|
2007-03-03 14:23:03 +00:00
|
|
|
type = menu->submenus[sel]->flags&MENU_TYPE_MASK;
|
|
|
|
if ((type == MT_SETTING) || (type == MT_SETTING_W_TEXT))
|
2007-03-01 11:14:46 +00:00
|
|
|
talk_setting(menu->submenus[sel]->variable);
|
2010-02-11 10:41:06 +00:00
|
|
|
else
|
2007-03-01 11:14:46 +00:00
|
|
|
{
|
2007-03-05 00:32:33 +00:00
|
|
|
if (menu->submenus[sel]->flags&(MENU_DYNAMIC_DESC))
|
|
|
|
{
|
2007-10-09 03:48:56 +00:00
|
|
|
int (*list_speak_item)(int selected_item, void * data)
|
|
|
|
= menu->submenus[sel]->menu_get_name_and_icon->
|
|
|
|
list_speak_item;
|
|
|
|
if(list_speak_item)
|
|
|
|
list_speak_item(sel, menu->submenus[sel]->
|
|
|
|
menu_get_name_and_icon->
|
|
|
|
list_get_name_data);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char buffer[80];
|
|
|
|
str = menu->submenus[sel]->menu_get_name_and_icon->
|
|
|
|
list_get_name(sel, menu->submenus[sel]->
|
2019-09-20 08:07:29 +00:00
|
|
|
menu_get_name_and_icon->
|
|
|
|
list_get_name_data, buffer, sizeof(buffer));
|
2007-10-09 03:48:56 +00:00
|
|
|
id = P2ID(str);
|
|
|
|
}
|
2007-03-05 00:32:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
id = P2ID(menu->submenus[sel]->callback_and_desc->desc);
|
2007-03-01 11:14:46 +00:00
|
|
|
if (id != -1)
|
2010-02-11 10:41:06 +00:00
|
|
|
talk_id(id,false);
|
2007-03-01 11:14:46 +00:00
|
|
|
}
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
2007-08-20 09:11:05 +00:00
|
|
|
else if(((menu->flags&MENU_TYPE_MASK) == MT_RETURN_ID))
|
|
|
|
{
|
|
|
|
if ((menu->flags&MENU_DYNAMIC_DESC) == 0)
|
|
|
|
{
|
|
|
|
unsigned char *s = (unsigned char *)menu->strings[sel];
|
|
|
|
/* string list, try to talk it if ID2P was used */
|
|
|
|
id = P2ID(s);
|
|
|
|
if (id != -1)
|
|
|
|
talk_id(id,false);
|
|
|
|
}
|
|
|
|
}
|
2007-10-21 00:23:23 +00:00
|
|
|
return 0;
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
2008-03-25 15:24:03 +00:00
|
|
|
|
2011-11-15 13:22:02 +00:00
|
|
|
void do_setting_screen(const struct settings_list *setting, const char * title,
|
|
|
|
struct viewport parent[NB_SCREENS])
|
2007-02-19 02:14:51 +00:00
|
|
|
{
|
2007-11-05 13:15:35 +00:00
|
|
|
char padded_title[MAX_PATH];
|
2007-11-16 08:18:08 +00:00
|
|
|
/* Pad the title string by repeating it. This is needed
|
|
|
|
so the scroll settings title can actually be used to
|
|
|
|
test the setting */
|
2007-11-05 13:15:35 +00:00
|
|
|
if (setting->flags&F_PADTITLE)
|
|
|
|
{
|
|
|
|
int i = 0, len;
|
|
|
|
if (setting->lang_id == -1)
|
|
|
|
title = (char*)setting->cfg_vals;
|
|
|
|
else
|
|
|
|
title = P2STR((unsigned char*)title);
|
|
|
|
len = strlen(title);
|
2007-11-16 08:18:08 +00:00
|
|
|
while (i < MAX_PATH-1)
|
2007-11-05 13:15:35 +00:00
|
|
|
{
|
2007-11-16 08:18:08 +00:00
|
|
|
int padlen = MIN(len, MAX_PATH-1-i);
|
2009-07-29 13:35:00 +00:00
|
|
|
memcpy(&padded_title[i], title, padlen);
|
2007-11-16 08:18:08 +00:00
|
|
|
i += padlen;
|
2007-11-05 13:15:35 +00:00
|
|
|
if (i<MAX_PATH-1)
|
|
|
|
padded_title[i++] = ' ';
|
|
|
|
}
|
|
|
|
padded_title[i] = '\0';
|
|
|
|
title = padded_title;
|
|
|
|
}
|
2010-02-11 10:41:06 +00:00
|
|
|
|
2008-04-23 11:07:40 +00:00
|
|
|
option_screen((struct settings_list *)setting, parent,
|
2011-11-15 13:22:02 +00:00
|
|
|
setting->flags&F_TEMPVAR, (char*)title);
|
|
|
|
}
|
2021-10-21 20:42:01 +00:00
|
|
|
|
2011-11-15 13:22:02 +00:00
|
|
|
|
|
|
|
void do_setting_from_menu(const struct menu_item_ex *temp,
|
|
|
|
struct viewport parent[NB_SCREENS])
|
|
|
|
{
|
|
|
|
char *title;
|
|
|
|
int setting_id;
|
2021-08-03 11:21:29 +00:00
|
|
|
if (!temp)
|
|
|
|
{
|
|
|
|
panicf("do_setting_from_menu, NULL pointer");
|
|
|
|
return;
|
|
|
|
}
|
2011-11-15 13:22:02 +00:00
|
|
|
const struct settings_list *setting =
|
|
|
|
find_setting(temp->variable, &setting_id);
|
2021-08-03 11:21:29 +00:00
|
|
|
|
|
|
|
if ((temp->flags&MENU_TYPE_MASK) == MT_SETTING_W_TEXT)
|
2011-11-15 13:22:02 +00:00
|
|
|
title = temp->callback_and_desc->desc;
|
|
|
|
else
|
|
|
|
title = ID2P(setting->lang_id);
|
2021-08-03 11:21:29 +00:00
|
|
|
|
2011-11-15 13:22:02 +00:00
|
|
|
do_setting_screen(setting, title, parent);
|
2007-02-19 02:14:51 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 12:10:41 +00:00
|
|
|
/* display a menu */
|
2008-03-26 03:35:24 +00:00
|
|
|
int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
|
2010-01-26 20:14:42 +00:00
|
|
|
struct viewport parent[NB_SCREENS], bool hide_theme)
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
2007-03-01 11:14:46 +00:00
|
|
|
int selected = start_selected? *start_selected : 0;
|
2021-10-27 05:28:46 +00:00
|
|
|
int ret = 0;
|
2007-02-08 04:33:41 +00:00
|
|
|
int action;
|
2021-10-23 02:17:36 +00:00
|
|
|
int start_action;
|
2007-02-08 04:33:41 +00:00
|
|
|
struct gui_synclist lists;
|
2019-09-21 00:23:18 +00:00
|
|
|
const struct menu_item_ex *temp = NULL;
|
|
|
|
const struct menu_item_ex *menu = start_menu;
|
2021-10-27 05:28:46 +00:00
|
|
|
|
|
|
|
bool in_stringlist, done = false;
|
2007-07-11 02:22:03 +00:00
|
|
|
bool redraw_lists;
|
2021-10-27 05:28:46 +00:00
|
|
|
|
2010-08-07 21:30:22 +00:00
|
|
|
int old_audio_status = audio_status();
|
2012-01-26 22:48:54 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
/* plugins possibly have grid mode active. force global settings in lists */
|
|
|
|
enum touchscreen_mode tsm = touchscreen_get_mode();
|
2021-08-10 21:08:37 +00:00
|
|
|
enum touchscreen_mode old_global_mode = global_settings.touch_mode;
|
2012-01-26 22:48:54 +00:00
|
|
|
touchscreen_set_mode(global_settings.touch_mode);
|
|
|
|
#endif
|
|
|
|
|
2009-12-17 07:47:08 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2010-01-26 20:14:42 +00:00
|
|
|
viewportmanager_theme_enable(i, !hide_theme, NULL);
|
2010-02-11 10:41:06 +00:00
|
|
|
|
2021-10-27 05:28:46 +00:00
|
|
|
struct menu_data_t mstack[MAX_MENUS]; /* menu, selected */
|
2007-02-08 04:33:41 +00:00
|
|
|
int stack_top = 0;
|
2021-10-27 05:28:46 +00:00
|
|
|
|
2008-12-31 05:59:26 +00:00
|
|
|
struct viewport *vps = NULL;
|
2008-03-26 03:35:24 +00:00
|
|
|
menu_callback_type menu_callback = NULL;
|
2008-12-31 05:59:26 +00:00
|
|
|
|
2010-01-26 20:14:42 +00:00
|
|
|
/* if hide_theme is true, assume parent has been fixed before passed into
|
2021-10-23 02:17:36 +00:00
|
|
|
* this function, e.g. with viewport_set_defaults(parent, screen)
|
|
|
|
* start_action allows an action to be processed
|
|
|
|
* by menu logic by bypassing get_action on the initial run */
|
|
|
|
start_action = init_menu_lists(menu, &lists, selected, true, parent);
|
2008-12-31 05:59:26 +00:00
|
|
|
vps = *(lists.parent);
|
2007-02-08 04:33:41 +00:00
|
|
|
in_stringlist = ((menu->flags&MENU_TYPE_MASK) == MT_RETURN_ID);
|
2007-02-21 12:22:07 +00:00
|
|
|
/* load the callback, and only reload it if menu changes */
|
|
|
|
get_menu_callback(menu, &menu_callback);
|
2008-03-26 03:35:24 +00:00
|
|
|
|
2010-07-11 14:04:34 +00:00
|
|
|
gui_synclist_draw(&lists);
|
|
|
|
gui_synclist_speak_item(&lists);
|
2021-10-27 05:28:46 +00:00
|
|
|
|
2007-03-07 10:13:07 +00:00
|
|
|
while (!done)
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
2012-01-12 11:28:36 +00:00
|
|
|
keyclick_set_callback(gui_synclist_keyclick_callback, &lists);
|
2021-10-27 05:28:46 +00:00
|
|
|
|
2021-10-23 02:17:36 +00:00
|
|
|
if (UNLIKELY(start_action != ACTION_ENTER_MENUITEM))
|
|
|
|
{
|
|
|
|
action = start_action;
|
|
|
|
start_action = ACTION_ENTER_MENUITEM;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
action = get_action(CONTEXT_MAINMENU|ALLOW_SOFTLOCK,
|
2021-10-27 05:28:46 +00:00
|
|
|
list_do_action_timeout(&lists, HZ));
|
|
|
|
/* HZ so the status bar redraws corectly */
|
2010-08-07 21:30:22 +00:00
|
|
|
|
|
|
|
/* query audio status to see if it changed */
|
2021-10-27 05:28:46 +00:00
|
|
|
redraw_lists = query_audio_status(&old_audio_status);
|
2010-02-11 10:41:06 +00:00
|
|
|
|
2008-10-30 07:07:45 +00:00
|
|
|
if (menu_callback)
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
2021-10-27 05:28:46 +00:00
|
|
|
int new_action = menu_callback(action, menu, &lists);
|
|
|
|
if (new_action == ACTION_EXIT_AFTER_THIS_MENUITEM)
|
|
|
|
ret = MENU_SELECTED_EXIT; /* exit after return from selection */
|
|
|
|
else if (new_action == ACTION_REDRAW)
|
2007-07-11 02:22:03 +00:00
|
|
|
redraw_lists = true;
|
2021-10-27 05:28:46 +00:00
|
|
|
else
|
|
|
|
action = new_action;
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
|
|
|
|
2022-09-19 11:48:15 +00:00
|
|
|
if (LIKELY(gui_synclist_do_button(&lists, &action)))
|
2007-07-11 01:23:57 +00:00
|
|
|
continue;
|
2008-04-23 10:33:46 +00:00
|
|
|
#ifdef HAVE_QUICKSCREEN
|
|
|
|
else if (action == ACTION_STD_QUICKSCREEN)
|
|
|
|
{
|
2021-03-07 15:07:49 +00:00
|
|
|
if (global_settings.shortcuts_replaces_qs)
|
|
|
|
{
|
|
|
|
global_status.last_screen = GO_TO_SHORTCUTMENU;
|
|
|
|
ret = quick_screen_quick(action);
|
2021-03-09 02:59:04 +00:00
|
|
|
done = true;
|
2021-03-07 15:07:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
quick_screen_quick(action);
|
2008-04-23 10:33:46 +00:00
|
|
|
redraw_lists = true;
|
|
|
|
}
|
|
|
|
#endif
|
2007-08-02 12:13:20 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
2008-04-23 10:33:46 +00:00
|
|
|
else if (action == ACTION_STD_REC)
|
2007-08-02 12:13:20 +00:00
|
|
|
{
|
|
|
|
ret = GO_TO_RECSCREEN;
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
#endif
|
2008-04-23 10:33:46 +00:00
|
|
|
else if (action == ACTION_TREE_WPS)
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
2007-03-01 11:14:46 +00:00
|
|
|
ret = GO_TO_PREVIOUS_MUSIC;
|
2007-03-07 10:13:07 +00:00
|
|
|
done = true;
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
2007-04-08 01:33:01 +00:00
|
|
|
else if (action == ACTION_TREE_STOP)
|
2007-03-01 11:14:46 +00:00
|
|
|
{
|
2007-08-05 15:21:47 +00:00
|
|
|
redraw_lists = list_stop_handler();
|
2007-03-01 11:14:46 +00:00
|
|
|
}
|
2008-11-05 09:30:20 +00:00
|
|
|
else if (action == ACTION_STD_CONTEXT)
|
2007-04-12 15:28:51 +00:00
|
|
|
{
|
2008-11-05 09:30:20 +00:00
|
|
|
if (menu == &root_menu_)
|
|
|
|
{
|
|
|
|
ret = GO_TO_ROOTITEM_CONTEXT;
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else if (!in_stringlist)
|
|
|
|
{
|
2019-09-21 00:23:18 +00:00
|
|
|
int type = (menu->flags&MENU_TYPE_MASK);
|
2008-12-31 05:59:26 +00:00
|
|
|
selected = get_menu_selection(gui_synclist_get_sel_pos(&lists),menu);
|
2019-09-21 00:23:18 +00:00
|
|
|
if (type == MT_MENU)
|
|
|
|
{
|
|
|
|
temp = menu->submenus[selected];
|
|
|
|
type = (temp->flags&MENU_TYPE_MASK);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
type = -1;
|
|
|
|
|
2012-05-07 03:10:19 +00:00
|
|
|
if (type == MT_SETTING_W_TEXT || type == MT_SETTING)
|
2008-11-05 09:30:20 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_QUICKSCREEN
|
|
|
|
MENUITEM_STRINGLIST(quickscreen_able_option,
|
|
|
|
ID2P(LANG_ONPLAY_MENU_TITLE), NULL,
|
|
|
|
ID2P(LANG_RESET_SETTING),
|
2009-08-29 14:42:03 +00:00
|
|
|
ID2P(LANG_TOP_QS_ITEM),
|
2008-11-05 09:30:20 +00:00
|
|
|
ID2P(LANG_LEFT_QS_ITEM),
|
|
|
|
ID2P(LANG_BOTTOM_QS_ITEM),
|
2011-11-15 13:22:02 +00:00
|
|
|
ID2P(LANG_RIGHT_QS_ITEM),
|
|
|
|
ID2P(LANG_ADD_TO_FAVES));
|
2008-11-05 09:30:20 +00:00
|
|
|
#endif
|
2021-10-21 20:42:01 +00:00
|
|
|
MENUITEM_STRINGLIST(notquickscreen_able_option,
|
2008-11-05 09:30:20 +00:00
|
|
|
ID2P(LANG_ONPLAY_MENU_TITLE), NULL,
|
|
|
|
ID2P(LANG_RESET_SETTING));
|
|
|
|
const struct menu_item_ex *menu;
|
2021-10-21 20:42:01 +00:00
|
|
|
const struct settings_list *setting =
|
2008-11-05 09:30:20 +00:00
|
|
|
find_setting(temp->variable, NULL);
|
|
|
|
#ifdef HAVE_QUICKSCREEN
|
|
|
|
if (is_setting_quickscreenable(setting))
|
|
|
|
menu = &quickscreen_able_option;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
menu = ¬quickscreen_able_option;
|
2021-10-27 05:28:46 +00:00
|
|
|
|
|
|
|
int msel = do_menu(menu, NULL, NULL, false);
|
|
|
|
|
|
|
|
switch (msel)
|
2008-11-05 09:30:20 +00:00
|
|
|
{
|
|
|
|
case GO_TO_PREVIOUS:
|
|
|
|
break;
|
2010-02-11 10:41:06 +00:00
|
|
|
case 0: /* reset setting */
|
|
|
|
reset_setting(setting, setting->setting);
|
2017-02-28 20:46:39 +00:00
|
|
|
settings_save();
|
|
|
|
settings_apply(false);
|
2008-11-05 09:30:20 +00:00
|
|
|
break;
|
2010-02-11 10:41:06 +00:00
|
|
|
#ifdef HAVE_QUICKSCREEN
|
2009-08-29 14:42:03 +00:00
|
|
|
case 1: /* set as top QS item */
|
|
|
|
set_as_qs_item(setting, QUICKSCREEN_TOP);
|
|
|
|
break;
|
|
|
|
case 2: /* set as left QS item */
|
2008-11-05 09:30:20 +00:00
|
|
|
set_as_qs_item(setting, QUICKSCREEN_LEFT);
|
|
|
|
break;
|
2009-08-29 14:42:03 +00:00
|
|
|
case 3: /* set as bottom QS item */
|
2008-11-05 09:30:20 +00:00
|
|
|
set_as_qs_item(setting, QUICKSCREEN_BOTTOM);
|
|
|
|
break;
|
2009-08-29 14:42:03 +00:00
|
|
|
case 4: /* set as right QS item */
|
2008-11-05 09:30:20 +00:00
|
|
|
set_as_qs_item(setting, QUICKSCREEN_RIGHT);
|
|
|
|
break;
|
2011-11-15 13:22:02 +00:00
|
|
|
case 5: /* Add to faves. Same limitation on which can be
|
|
|
|
added to the shortcuts menu as the quickscreen */
|
|
|
|
shortcuts_add(SHORTCUT_SETTING, (void*)setting);
|
|
|
|
break;
|
2008-11-05 09:30:20 +00:00
|
|
|
#endif
|
|
|
|
} /* swicth(do_menu()) */
|
|
|
|
redraw_lists = true;
|
|
|
|
}
|
|
|
|
} /* else if (!in_stringlist) */
|
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
else if (action == ACTION_STD_MENU)
|
|
|
|
{
|
|
|
|
if (menu != &root_menu_)
|
|
|
|
ret = GO_TO_ROOT;
|
2007-03-06 13:35:15 +00:00
|
|
|
else
|
|
|
|
ret = GO_TO_PREVIOUS;
|
2007-03-07 10:13:07 +00:00
|
|
|
done = true;
|
2007-03-01 11:14:46 +00:00
|
|
|
}
|
|
|
|
else if (action == ACTION_STD_CANCEL)
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
2008-10-13 22:08:01 +00:00
|
|
|
/* might be leaving list, so stop scrolling */
|
2010-02-11 10:41:06 +00:00
|
|
|
gui_synclist_scroll_stop(&lists);
|
2021-10-27 05:28:46 +00:00
|
|
|
|
|
|
|
bool exiting_menu = false;
|
|
|
|
in_stringlist = false;
|
|
|
|
|
2007-02-21 12:22:07 +00:00
|
|
|
if (menu_callback)
|
2020-07-19 17:42:04 +00:00
|
|
|
menu_callback(ACTION_EXIT_MENUITEM, menu, &lists);
|
2008-10-13 22:08:01 +00:00
|
|
|
|
2007-04-30 13:41:33 +00:00
|
|
|
if (menu->flags&MENU_EXITAFTERTHISMENU)
|
|
|
|
done = true;
|
2007-11-07 10:06:21 +00:00
|
|
|
else if ((menu->flags&MENU_TYPE_MASK) == MT_MENU)
|
|
|
|
exiting_menu = true;
|
2021-10-27 05:28:46 +00:00
|
|
|
|
2007-02-08 04:33:41 +00:00
|
|
|
if (stack_top > 0)
|
|
|
|
{
|
|
|
|
stack_top--;
|
2021-10-27 05:28:46 +00:00
|
|
|
menu = mstack[stack_top].menu;
|
|
|
|
int msel = mstack[stack_top].selected;
|
2007-11-07 10:06:21 +00:00
|
|
|
if (!exiting_menu && (menu->flags&MENU_EXITAFTERTHISMENU))
|
2007-04-30 13:41:33 +00:00
|
|
|
done = true;
|
2007-08-04 09:47:17 +00:00
|
|
|
else
|
2021-10-27 05:28:46 +00:00
|
|
|
init_menu_lists(menu, &lists, msel, false, vps);
|
2010-07-11 14:04:34 +00:00
|
|
|
redraw_lists = true;
|
2007-02-21 12:22:07 +00:00
|
|
|
/* new menu, so reload the callback */
|
2007-02-16 00:55:52 +00:00
|
|
|
get_menu_callback(menu, &menu_callback);
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
else if (menu != &root_menu_)
|
|
|
|
{
|
|
|
|
ret = GO_TO_PREVIOUS;
|
2007-03-07 10:13:07 +00:00
|
|
|
done = true;
|
2007-03-01 11:14:46 +00:00
|
|
|
}
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
|
|
|
else if (action == ACTION_STD_OK)
|
|
|
|
{
|
2008-10-13 22:08:01 +00:00
|
|
|
/* entering an item that may not be a list, so stop scrolling */
|
2010-02-11 10:41:06 +00:00
|
|
|
gui_synclist_scroll_stop(&lists);
|
2021-10-27 05:28:46 +00:00
|
|
|
redraw_lists = true;
|
|
|
|
|
|
|
|
int type = (menu->flags&MENU_TYPE_MASK);
|
2007-02-08 04:33:41 +00:00
|
|
|
selected = get_menu_selection(gui_synclist_get_sel_pos(&lists), menu);
|
2019-09-21 00:23:18 +00:00
|
|
|
if (type == MT_MENU)
|
|
|
|
temp = menu->submenus[selected];
|
2021-10-27 05:28:46 +00:00
|
|
|
else if (!in_stringlist)
|
2019-09-21 00:23:18 +00:00
|
|
|
type = -1;
|
|
|
|
|
2021-10-27 05:28:46 +00:00
|
|
|
if (!in_stringlist && temp)
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
2007-03-25 14:31:56 +00:00
|
|
|
type = (temp->flags&MENU_TYPE_MASK);
|
|
|
|
get_menu_callback(temp, &menu_callback);
|
|
|
|
if (menu_callback)
|
|
|
|
{
|
2020-07-19 17:42:04 +00:00
|
|
|
action = menu_callback(ACTION_ENTER_MENUITEM, temp, &lists);
|
2007-03-25 14:31:56 +00:00
|
|
|
if (action == ACTION_EXIT_MENUITEM)
|
|
|
|
break;
|
|
|
|
}
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case MT_MENU:
|
|
|
|
if (stack_top < MAX_MENUS)
|
|
|
|
{
|
2021-10-27 05:28:46 +00:00
|
|
|
mstack[stack_top].menu = menu;
|
|
|
|
mstack[stack_top].selected = selected;
|
2007-02-08 04:33:41 +00:00
|
|
|
stack_top++;
|
|
|
|
menu = temp;
|
2010-07-11 14:04:34 +00:00
|
|
|
init_menu_lists(menu, &lists, 0, true, vps);
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MT_FUNCTION_CALL:
|
2007-03-17 12:33:34 +00:00
|
|
|
{
|
|
|
|
int return_value;
|
|
|
|
if (temp->flags&MENU_FUNC_USEPARAM)
|
|
|
|
return_value = temp->function->function_w_param(
|
|
|
|
temp->function->param);
|
2010-02-11 10:41:06 +00:00
|
|
|
else
|
2007-03-17 12:33:34 +00:00
|
|
|
return_value = temp->function->function();
|
2010-10-30 09:38:26 +00:00
|
|
|
if (!(menu->flags&MENU_EXITAFTERTHISMENU) ||
|
|
|
|
(temp->flags&MENU_EXITAFTERTHISMENU))
|
|
|
|
{
|
2021-10-23 02:17:36 +00:00
|
|
|
/* Reload menu but don't run the calback again FS#8117 */
|
|
|
|
init_menu_lists(menu, &lists, selected, false, vps);
|
2010-10-30 09:38:26 +00:00
|
|
|
}
|
2007-03-17 12:33:34 +00:00
|
|
|
if (temp->flags&MENU_FUNC_CHECK_RETVAL)
|
|
|
|
{
|
2008-10-30 07:07:45 +00:00
|
|
|
if (return_value != 0)
|
2007-03-18 06:31:33 +00:00
|
|
|
{
|
|
|
|
done = true;
|
|
|
|
ret = return_value;
|
|
|
|
}
|
2007-03-17 12:33:34 +00:00
|
|
|
}
|
2007-02-08 04:33:41 +00:00
|
|
|
break;
|
2007-03-17 12:33:34 +00:00
|
|
|
}
|
2007-02-08 04:33:41 +00:00
|
|
|
case MT_SETTING:
|
2007-03-03 14:23:03 +00:00
|
|
|
case MT_SETTING_W_TEXT:
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
2009-03-10 07:27:13 +00:00
|
|
|
do_setting_from_menu(temp, vps);
|
2010-02-26 03:45:41 +00:00
|
|
|
send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */
|
2007-02-08 04:33:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MT_RETURN_ID:
|
|
|
|
if (in_stringlist)
|
|
|
|
{
|
2007-03-18 06:31:33 +00:00
|
|
|
done = true;
|
|
|
|
ret = selected;
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
|
|
|
else if (stack_top < MAX_MENUS)
|
|
|
|
{
|
2021-10-27 05:28:46 +00:00
|
|
|
mstack[stack_top].menu = menu;
|
|
|
|
mstack[stack_top].selected = selected;
|
2007-02-08 04:33:41 +00:00
|
|
|
stack_top++;
|
|
|
|
menu = temp;
|
2008-03-26 03:35:24 +00:00
|
|
|
init_menu_lists(menu,&lists,0,false, vps);
|
2007-02-08 04:33:41 +00:00
|
|
|
in_stringlist = true;
|
|
|
|
}
|
|
|
|
break;
|
2007-03-01 11:14:46 +00:00
|
|
|
case MT_RETURN_VALUE:
|
2007-03-07 10:13:07 +00:00
|
|
|
ret = temp->value;
|
|
|
|
done = true;
|
|
|
|
break;
|
2019-09-21 00:23:18 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
ret = GO_TO_PREVIOUS;
|
|
|
|
done = true;
|
|
|
|
break;
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
2007-04-30 13:41:33 +00:00
|
|
|
if (type != MT_MENU)
|
|
|
|
{
|
|
|
|
if (menu_callback)
|
2020-07-19 17:42:04 +00:00
|
|
|
menu_callback(ACTION_EXIT_MENUITEM, temp, &lists);
|
2007-04-30 13:41:33 +00:00
|
|
|
}
|
2007-03-17 14:10:51 +00:00
|
|
|
if (current_submenus_menu != menu)
|
2008-03-26 03:35:24 +00:00
|
|
|
init_menu_lists(menu,&lists,selected,true,vps);
|
2007-02-21 12:22:07 +00:00
|
|
|
/* callback was changed, so reload the menu's callback */
|
|
|
|
get_menu_callback(menu, &menu_callback);
|
2021-10-21 20:42:01 +00:00
|
|
|
if ((menu->flags&MENU_EXITAFTERTHISMENU) &&
|
2007-04-30 13:41:33 +00:00
|
|
|
!(temp->flags&MENU_EXITAFTERTHISMENU))
|
|
|
|
{
|
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
}
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
2010-10-31 15:32:57 +00:00
|
|
|
else
|
2007-03-30 21:54:48 +00:00
|
|
|
{
|
2014-01-15 23:25:40 +00:00
|
|
|
if (action == SYS_USB_CONNECTED)
|
|
|
|
gui_synclist_scroll_stop(&lists);
|
|
|
|
|
2010-10-31 15:32:57 +00:00
|
|
|
switch(default_event_handler(action))
|
|
|
|
{
|
|
|
|
case SYS_USB_CONNECTED:
|
|
|
|
ret = MENU_ATTACHED_USB;
|
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
case SYS_CALL_HUNG_UP:
|
|
|
|
case BUTTON_MULTIMEDIA_PLAYPAUSE:
|
|
|
|
/* remove splash from playlist_resume() */
|
|
|
|
redraw_lists = true;
|
|
|
|
break;
|
|
|
|
}
|
2007-03-30 21:54:48 +00:00
|
|
|
}
|
2010-02-11 10:41:06 +00:00
|
|
|
|
2007-10-21 00:23:23 +00:00
|
|
|
if (redraw_lists && !done)
|
|
|
|
{
|
2008-10-30 07:07:45 +00:00
|
|
|
if (menu_callback)
|
2020-07-20 04:40:03 +00:00
|
|
|
if (menu_callback(ACTION_REDRAW, menu, &lists) != ACTION_REDRAW)
|
|
|
|
continue;
|
|
|
|
|
2021-12-20 19:12:03 +00:00
|
|
|
|
|
|
|
gui_synclist_set_title(&lists, lists.title, lists.title_icon);
|
2020-07-20 04:40:03 +00:00
|
|
|
gui_synclist_draw(&lists);
|
|
|
|
gui_synclist_speak_item(&lists);
|
2007-10-21 00:23:23 +00:00
|
|
|
}
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
2014-01-15 23:25:40 +00:00
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
if (start_selected)
|
2007-05-20 14:24:02 +00:00
|
|
|
{
|
|
|
|
/* make sure the start_selected variable is set to
|
|
|
|
the selected item from the menu do_menu() was called from */
|
|
|
|
if (stack_top > 0)
|
|
|
|
{
|
2021-10-27 05:28:46 +00:00
|
|
|
menu = mstack[0].menu;
|
|
|
|
init_menu_lists(menu,&lists,mstack[0].selected,true, vps);
|
2007-05-20 14:24:02 +00:00
|
|
|
}
|
2007-03-07 10:13:07 +00:00
|
|
|
*start_selected = get_menu_selection(
|
|
|
|
gui_synclist_get_sel_pos(&lists), menu);
|
2007-05-20 14:24:02 +00:00
|
|
|
}
|
2012-01-26 22:48:54 +00:00
|
|
|
|
2010-02-11 10:41:06 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
viewportmanager_theme_undo(i, false);
|
2012-01-26 22:48:54 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2021-08-10 21:08:37 +00:00
|
|
|
/* This is needed because this function runs the settings menu and we do
|
|
|
|
* not want to switch back to the old mode if the user intentionally went
|
|
|
|
* to a different one. This is a very hacky way to do this... */
|
|
|
|
if(!(global_settings.touch_mode != (int)old_global_mode &&
|
|
|
|
tsm == old_global_mode))
|
|
|
|
touchscreen_set_mode(tsm);
|
2012-01-26 22:48:54 +00:00
|
|
|
#endif
|
2007-02-08 04:33:41 +00:00
|
|
|
return ret;
|
|
|
|
}
|