mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-20 11:30:37 +00:00
Create menu_entries.c
This commit is contained in:
parent
b9bd2072e4
commit
2c1a1f83a2
@ -337,6 +337,7 @@ ifeq ($(HAVE_MENU_COMMON), 1)
|
||||
OBJ += menu/menu_input.o \
|
||||
menu/menu.o \
|
||||
menu/menu_entry.o \
|
||||
menu/menu_entries.o \
|
||||
menu/menu_navigation.o \
|
||||
menu/menu_setting.o \
|
||||
menu/menu_shader.o \
|
||||
|
@ -713,6 +713,7 @@ MENU
|
||||
#include "../menu/menu_input.c"
|
||||
#include "../menu/menu.c"
|
||||
#include "../menu/menu_entry.c"
|
||||
#include "../menu/menu_entries.c"
|
||||
#include "../menu/menu_setting.c"
|
||||
#include "../menu/menu_list.c"
|
||||
#include "../menu/menu_cbs.c"
|
||||
|
96
menu/menu_entries.c
Normal file
96
menu/menu_entries.c
Normal file
@ -0,0 +1,96 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2014-2015 - Jay McCarthy
|
||||
*
|
||||
* RetroArch 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 Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "menu.h"
|
||||
#include "menu_display.h"
|
||||
#include "menu_entry.h"
|
||||
#include "menu_navigation.h"
|
||||
#include "menu_setting.h"
|
||||
#include "menu_input.h"
|
||||
#include "../runloop_data.h"
|
||||
|
||||
/* Returns the starting index of the menu entry list. */
|
||||
size_t menu_entries_get_start(void)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
return 0;
|
||||
|
||||
return menu->begin;
|
||||
}
|
||||
|
||||
/* Returns the last index (+1) of the menu entry list. */
|
||||
size_t menu_entries_get_end(void)
|
||||
{
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
return menu_list_get_size(menu_list);
|
||||
}
|
||||
|
||||
|
||||
/* Sets title to what the name of the current menu should be. */
|
||||
int menu_entries_get_title(char *s, size_t len)
|
||||
{
|
||||
const char *path = NULL;
|
||||
const char *label = NULL;
|
||||
unsigned menu_type = 0;
|
||||
menu_file_list_cbs_t *cbs = NULL;
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
|
||||
if (!menu_list)
|
||||
return -1;
|
||||
|
||||
cbs = (menu_file_list_cbs_t*)menu_list_get_last_stack_actiondata(menu_list);
|
||||
|
||||
menu_list_get_last_stack(menu_list, &path, &label, &menu_type, NULL);
|
||||
|
||||
if (cbs && cbs->action_get_title)
|
||||
return cbs->action_get_title(path, label, menu_type, s, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Returns true if a Back button should be shown (i.e. we are at least
|
||||
* one level deep in the menu hierarchy). */
|
||||
bool menu_entries_show_back(void)
|
||||
{
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
|
||||
if (!menu_list)
|
||||
return false;
|
||||
|
||||
return (menu_list_get_stack_size(menu_list) > 1);
|
||||
}
|
||||
|
||||
/* Sets 's' to the name of the current core
|
||||
* (shown at the top of the UI). */
|
||||
void menu_entries_get_core_title(char *s, size_t len)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
const char *core_name = global->menu.info.library_name;
|
||||
const char *core_version = global->menu.info.library_version;
|
||||
|
||||
if (!core_name)
|
||||
core_name = global->system.info.library_name;
|
||||
if (!core_name)
|
||||
core_name = "No Core";
|
||||
|
||||
if (!core_version)
|
||||
core_version = global->system.info.library_version;
|
||||
if (!core_version)
|
||||
core_version = "";
|
||||
|
||||
snprintf(s, len, "%s - %s %s", PACKAGE_VERSION,
|
||||
core_name, core_version);
|
||||
}
|
@ -24,7 +24,7 @@
|
||||
/* This file provides an abstraction of the currently displayed
|
||||
* menu.
|
||||
*
|
||||
* It is organized into event-system where the UI companion
|
||||
* It is organized into an event-based system where the UI companion
|
||||
* calls this functions and RetroArch responds by changing the global
|
||||
* state (including arranging for these functions to return different
|
||||
* values).
|
||||
@ -33,82 +33,6 @@
|
||||
* notify_list_loaded on the UI companion.
|
||||
*/
|
||||
|
||||
/* Returns the starting index of the menu entry list. */
|
||||
size_t menu_entries_get_start(void)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
return 0;
|
||||
|
||||
return menu->begin;
|
||||
}
|
||||
|
||||
/* Returns the last index (+1) of the menu entry list. */
|
||||
size_t menu_entries_get_end(void)
|
||||
{
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
return menu_list_get_size(menu_list);
|
||||
}
|
||||
|
||||
|
||||
/* Sets title to what the name of the current menu should be. */
|
||||
int menu_entries_get_title(char *s, size_t len)
|
||||
{
|
||||
const char *path = NULL;
|
||||
const char *label = NULL;
|
||||
unsigned menu_type = 0;
|
||||
menu_file_list_cbs_t *cbs = NULL;
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
|
||||
if (!menu_list)
|
||||
return -1;
|
||||
|
||||
cbs = (menu_file_list_cbs_t*)menu_list_get_last_stack_actiondata(menu_list);
|
||||
|
||||
menu_list_get_last_stack(menu_list, &path, &label, &menu_type, NULL);
|
||||
|
||||
(void)cbs;
|
||||
|
||||
if (cbs && cbs->action_get_title)
|
||||
return cbs->action_get_title(path, label, menu_type, s, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Returns true if a Back button should be shown (i.e. we are at least
|
||||
* one level deep in the menu hierarchy). */
|
||||
bool menu_entries_show_back(void)
|
||||
{
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
|
||||
if (!menu_list)
|
||||
return false;
|
||||
|
||||
return (menu_list_get_stack_size(menu_list) > 1);
|
||||
}
|
||||
|
||||
/* Sets 's' to the name of the current core
|
||||
* (shown at the top of the UI). */
|
||||
void menu_entries_get_core_title(char *s, size_t len)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
const char *core_name = global->menu.info.library_name;
|
||||
const char *core_version = global->menu.info.library_version;
|
||||
|
||||
if (!core_name)
|
||||
core_name = global->system.info.library_name;
|
||||
if (!core_name)
|
||||
core_name = "No Core";
|
||||
|
||||
if (!core_version)
|
||||
core_version = global->system.info.library_version;
|
||||
if (!core_version)
|
||||
core_version = "";
|
||||
|
||||
snprintf(s, len, "%s - %s %s", PACKAGE_VERSION,
|
||||
core_name, core_version);
|
||||
}
|
||||
|
||||
/* Clicks the back button */
|
||||
int menu_entry_go_back(void)
|
||||
{
|
||||
|
@ -49,18 +49,9 @@ typedef struct menu_entry
|
||||
unsigned spacing;
|
||||
} menu_entry_t;
|
||||
|
||||
size_t menu_entries_get_start(void);
|
||||
|
||||
size_t menu_entries_get_end(void);
|
||||
|
||||
int menu_entries_get_title(char *title, size_t title_len);
|
||||
|
||||
bool menu_entries_show_back(void);
|
||||
|
||||
int menu_entry_go_back(void);
|
||||
|
||||
void menu_entries_get_core_title(char *title_msg, size_t title_msg_len);
|
||||
|
||||
enum menu_entry_type menu_entry_get_type(uint32_t i);
|
||||
|
||||
void menu_entry_get_path(uint32_t i, char *s, size_t len);
|
||||
@ -125,6 +116,16 @@ int menu_entry_select(uint32_t i);
|
||||
int menu_entry_action(menu_entry_t *entry,
|
||||
unsigned i, enum menu_action action);
|
||||
|
||||
size_t menu_entries_get_start(void);
|
||||
|
||||
size_t menu_entries_get_end(void);
|
||||
|
||||
int menu_entries_get_title(char *title, size_t title_len);
|
||||
|
||||
bool menu_entries_show_back(void);
|
||||
|
||||
void menu_entries_get_core_title(char *title_msg, size_t title_msg_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user