2015-02-27 02:05:19 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
|
|
*
|
|
|
|
* 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 <file/file_path.h>
|
2015-03-15 03:52:46 +00:00
|
|
|
#include <retro_inline.h>
|
2015-02-27 02:05:19 +00:00
|
|
|
#include "menu.h"
|
2015-05-18 21:02:04 +00:00
|
|
|
#include "menu_display.h"
|
2015-05-10 09:23:00 +00:00
|
|
|
#include "menu_entry.h"
|
2015-02-27 02:05:19 +00:00
|
|
|
#include "menu_entries_cbs.h"
|
|
|
|
#include "menu_setting.h"
|
|
|
|
#include "menu_input.h"
|
|
|
|
#include "menu_shader.h"
|
|
|
|
#include "menu_navigation.h"
|
|
|
|
|
|
|
|
#include "../retroarch.h"
|
2015-05-12 11:14:04 +00:00
|
|
|
#include "../settings.h"
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
#include "../input/input_autodetect.h"
|
|
|
|
|
|
|
|
static int archive_open(void)
|
|
|
|
{
|
|
|
|
char cat_path[PATH_MAX_LENGTH];
|
2015-05-17 13:00:03 +00:00
|
|
|
menu_displaylist_info_t info = {0};
|
2015-02-27 02:05:19 +00:00
|
|
|
const char *menu_path = NULL;
|
|
|
|
const char *menu_label = NULL;
|
|
|
|
const char* path = NULL;
|
2015-03-23 02:09:30 +00:00
|
|
|
unsigned int type = 0;
|
2015-05-07 03:11:37 +00:00
|
|
|
menu_navigation_t *nav = menu_navigation_get_ptr();
|
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
2015-02-27 02:05:19 +00:00
|
|
|
|
2015-05-07 03:11:37 +00:00
|
|
|
if (!menu_list || !nav)
|
2015-02-27 02:05:19 +00:00
|
|
|
return -1;
|
|
|
|
|
2015-05-07 03:11:37 +00:00
|
|
|
menu_list_pop_stack(menu_list);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
2015-05-07 03:11:37 +00:00
|
|
|
menu_list_get_last_stack(menu_list,
|
2015-02-27 02:05:19 +00:00
|
|
|
&menu_path, &menu_label, NULL);
|
|
|
|
|
2015-05-07 03:11:37 +00:00
|
|
|
if (menu_list_get_size(menu_list) == 0)
|
2015-02-27 02:05:19 +00:00
|
|
|
return 0;
|
|
|
|
|
2015-05-07 03:11:37 +00:00
|
|
|
menu_list_get_at_offset(menu_list->selection_buf,
|
|
|
|
nav->selection_ptr, &path, NULL, &type);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
fill_pathname_join(cat_path, menu_path, path, sizeof(cat_path));
|
2015-05-17 13:00:03 +00:00
|
|
|
|
|
|
|
info.list = menu_list->menu_stack;
|
|
|
|
info.type = type;
|
|
|
|
info.directory_ptr = nav->selection_ptr;
|
|
|
|
strlcpy(info.path, cat_path, sizeof(info.path));
|
|
|
|
strlcpy(info.label, menu_label, sizeof(info.label));
|
|
|
|
|
|
|
|
return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC);
|
2015-02-27 02:05:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int archive_load(void)
|
|
|
|
{
|
2015-05-17 13:00:03 +00:00
|
|
|
int ret = 0;
|
|
|
|
menu_displaylist_info_t info = {0};
|
2015-02-27 02:05:19 +00:00
|
|
|
const char *menu_path = NULL;
|
|
|
|
const char *menu_label = NULL;
|
|
|
|
const char* path = NULL;
|
2015-03-20 20:22:38 +00:00
|
|
|
unsigned int type = 0;
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-03-20 20:22:38 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-03-21 04:42:49 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2015-05-07 08:48:57 +00:00
|
|
|
size_t selected = menu_navigation_get_current_selection();
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
menu_list_pop_stack(menu->menu_list);
|
|
|
|
|
|
|
|
menu_list_get_last_stack(menu->menu_list,
|
|
|
|
&menu_path, &menu_label, NULL);
|
|
|
|
|
|
|
|
if (menu_list_get_size(menu->menu_list) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
menu_list_get_at_offset(menu->menu_list->selection_buf,
|
2015-05-07 08:48:57 +00:00
|
|
|
selected, &path, NULL, &type);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
2015-03-21 04:42:49 +00:00
|
|
|
ret = rarch_defer_core(global->core_info, menu_path, path, menu_label,
|
2015-02-27 02:05:19 +00:00
|
|
|
menu->deferred_path, sizeof(menu->deferred_path));
|
|
|
|
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case -1:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_LOAD_CORE);
|
2015-02-27 02:05:19 +00:00
|
|
|
menu_entries_common_load_content(false);
|
|
|
|
break;
|
|
|
|
case 0:
|
2015-05-17 13:00:03 +00:00
|
|
|
info.list = menu->menu_list->menu_stack;
|
|
|
|
info.type = 0;
|
|
|
|
info.directory_ptr = selected;
|
|
|
|
strlcpy(info.path, settings->libretro_directory, sizeof(info.path));
|
|
|
|
strlcpy(info.label, "deferred_core_list", sizeof(info.label));
|
|
|
|
|
|
|
|
ret = menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC);
|
2015-02-27 02:05:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-05-17 13:00:03 +00:00
|
|
|
return ret;
|
2015-02-27 02:05:19 +00:00
|
|
|
}
|
|
|
|
|
2015-05-18 20:26:00 +00:00
|
|
|
static int load_or_open_zip_iterate(char *s, size_t len, unsigned action)
|
2015-02-27 02:05:19 +00:00
|
|
|
{
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return -1;
|
|
|
|
|
2015-05-18 20:26:00 +00:00
|
|
|
snprintf(s, len, "Opening compressed file\n"
|
2015-02-27 02:05:19 +00:00
|
|
|
" \n"
|
|
|
|
|
|
|
|
" - OK to open as Folder\n"
|
|
|
|
" - Cancel/Back to Load \n");
|
|
|
|
|
2015-05-18 20:26:00 +00:00
|
|
|
menu_driver_render_messagebox(s);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case MENU_ACTION_OK:
|
|
|
|
archive_open();
|
|
|
|
break;
|
|
|
|
case MENU_ACTION_CANCEL:
|
|
|
|
archive_load();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-18 20:26:00 +00:00
|
|
|
static int action_iterate_help(char *s, size_t len, const char *label)
|
2015-02-27 02:05:19 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
static const unsigned binds[] = {
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_UP,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_A,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_B,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
|
|
|
RARCH_MENU_TOGGLE,
|
|
|
|
RARCH_QUIT_KEY,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_X,
|
2015-05-25 23:10:27 +00:00
|
|
|
RETRO_DEVICE_ID_JOYPAD_Y,
|
2015-02-27 02:05:19 +00:00
|
|
|
};
|
|
|
|
char desc[ARRAY_SIZE(binds)][64];
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-03-20 20:22:38 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-03-18 18:40:00 +00:00
|
|
|
|
2015-02-27 02:05:19 +00:00
|
|
|
if (!menu)
|
|
|
|
return 0;
|
|
|
|
|
2015-03-22 05:03:55 +00:00
|
|
|
menu_driver_render();
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(binds); i++)
|
|
|
|
{
|
|
|
|
const struct retro_keybind *keybind = (const struct retro_keybind*)
|
2015-03-20 20:22:38 +00:00
|
|
|
&settings->input.binds[0][binds[i]];
|
2015-02-27 02:05:19 +00:00
|
|
|
const struct retro_keybind *auto_bind = (const struct retro_keybind*)
|
|
|
|
input_get_auto_bind(0, binds[i]);
|
|
|
|
|
|
|
|
input_get_bind_string(desc[i], keybind, auto_bind, sizeof(desc[i]));
|
|
|
|
}
|
|
|
|
|
2015-05-18 20:26:00 +00:00
|
|
|
snprintf(s, len,
|
2015-02-27 02:05:19 +00:00
|
|
|
"-- Welcome to RetroArch --\n"
|
|
|
|
" \n" // strtok_r doesn't split empty strings.
|
|
|
|
|
|
|
|
"Basic Menu controls:\n"
|
|
|
|
" Scroll (Up): %-20s\n"
|
|
|
|
" Scroll (Down): %-20s\n"
|
|
|
|
" Accept/OK: %-20s\n"
|
|
|
|
" Back: %-20s\n"
|
|
|
|
" Info: %-20s\n"
|
|
|
|
"Enter/Exit Menu: %-20s\n"
|
|
|
|
" Exit RetroArch: %-20s\n"
|
|
|
|
"Toggle Keyboard: %-20s\n"
|
2015-05-25 23:10:27 +00:00
|
|
|
" Scan: %-20s\n"
|
2015-02-27 02:05:19 +00:00
|
|
|
" \n"
|
|
|
|
|
|
|
|
"To run content:\n"
|
|
|
|
"Load a libretro core (Core).\n"
|
|
|
|
"Load a content file (Load Content). \n"
|
|
|
|
" \n"
|
2015-04-13 15:29:21 +00:00
|
|
|
"See Path Settings to set directories \n"
|
|
|
|
"for faster access to files.\n"
|
2015-02-27 02:05:19 +00:00
|
|
|
" \n"
|
|
|
|
|
|
|
|
"Press Accept/OK to continue.",
|
2015-05-25 23:10:27 +00:00
|
|
|
desc[0], desc[1], desc[2], desc[3], desc[4], desc[5], desc[6], desc[7], desc[8]);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
2015-05-19 18:30:58 +00:00
|
|
|
return 0;
|
2015-02-27 02:05:19 +00:00
|
|
|
}
|
|
|
|
|
2015-05-18 20:26:00 +00:00
|
|
|
static int action_iterate_info(char *s, size_t len, const char *label)
|
2015-02-27 02:05:19 +00:00
|
|
|
{
|
2015-05-11 21:03:49 +00:00
|
|
|
int ret = 0;
|
2015-02-27 02:05:19 +00:00
|
|
|
char needle[PATH_MAX_LENGTH];
|
2015-03-23 02:09:30 +00:00
|
|
|
unsigned info_type = 0;
|
2015-02-27 02:05:19 +00:00
|
|
|
rarch_setting_t *current_setting = NULL;
|
2015-03-23 02:09:30 +00:00
|
|
|
file_list_t *list = NULL;
|
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-05-07 08:55:57 +00:00
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
2015-05-07 08:48:57 +00:00
|
|
|
size_t selection = menu_navigation_get_current_selection();
|
2015-02-27 02:05:19 +00:00
|
|
|
if (!menu)
|
|
|
|
return 0;
|
|
|
|
|
2015-05-07 08:55:57 +00:00
|
|
|
list = (file_list_t*)menu_list->selection_buf;
|
2015-02-27 02:05:19 +00:00
|
|
|
|
2015-03-22 05:03:55 +00:00
|
|
|
menu_driver_render();
|
2015-02-27 02:05:19 +00:00
|
|
|
|
2015-05-08 15:19:43 +00:00
|
|
|
current_setting = menu_setting_find(list->list[selection].label);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
if (current_setting)
|
|
|
|
strlcpy(needle, current_setting->name, sizeof(needle));
|
2015-05-08 15:19:43 +00:00
|
|
|
else if ((current_setting = menu_setting_find(list->list[selection].label)))
|
2015-02-27 02:05:19 +00:00
|
|
|
{
|
|
|
|
if (current_setting)
|
|
|
|
strlcpy(needle, current_setting->name, sizeof(needle));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const char *lbl = NULL;
|
2015-05-07 08:48:57 +00:00
|
|
|
menu_list_get_at_offset(list, selection, NULL, &lbl, &info_type);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
if (lbl)
|
|
|
|
strlcpy(needle, lbl, sizeof(needle));
|
|
|
|
}
|
|
|
|
|
2015-05-18 20:26:00 +00:00
|
|
|
setting_get_description(needle, s, len);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
2015-05-11 21:03:49 +00:00
|
|
|
return ret;
|
2015-02-27 02:05:19 +00:00
|
|
|
}
|
|
|
|
|
2015-05-18 20:26:00 +00:00
|
|
|
static int action_iterate_load_open_zip(const char *label, char *s, size_t len, unsigned action)
|
2015-02-27 02:05:19 +00:00
|
|
|
{
|
2015-03-20 20:22:38 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
switch (settings->archive.mode)
|
2015-02-27 02:05:19 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2015-05-18 20:26:00 +00:00
|
|
|
return load_or_open_zip_iterate(s, len, action);
|
2015-02-27 02:05:19 +00:00
|
|
|
case 1:
|
|
|
|
return archive_load();
|
|
|
|
case 2:
|
|
|
|
return archive_open();
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-18 20:26:00 +00:00
|
|
|
static int action_iterate_menu_viewport(char *s, size_t len, const char *label, unsigned action)
|
2015-02-27 02:05:19 +00:00
|
|
|
{
|
|
|
|
int stride_x = 1, stride_y = 1;
|
2015-05-18 18:57:56 +00:00
|
|
|
menu_displaylist_info_t info = {0};
|
2015-02-27 02:05:19 +00:00
|
|
|
struct retro_game_geometry *geom = NULL;
|
2015-03-23 02:09:30 +00:00
|
|
|
const char *base_msg = NULL;
|
|
|
|
unsigned type = 0;
|
2015-05-20 16:57:17 +00:00
|
|
|
video_viewport_t *custom = video_viewport_get_custom();
|
2015-03-23 02:09:30 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-05-07 08:55:57 +00:00
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
2015-03-23 02:09:30 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-05-20 16:57:17 +00:00
|
|
|
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
2015-03-20 20:22:38 +00:00
|
|
|
|
2015-02-27 02:05:19 +00:00
|
|
|
if (!menu)
|
|
|
|
return -1;
|
|
|
|
|
2015-05-07 08:55:57 +00:00
|
|
|
menu_list_get_last_stack(menu_list, NULL, NULL, &type);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
2015-05-20 16:57:17 +00:00
|
|
|
geom = (struct retro_game_geometry*)&av_info->geometry;
|
2015-02-27 02:05:19 +00:00
|
|
|
|
2015-03-20 20:22:38 +00:00
|
|
|
if (settings->video.scale_integer)
|
2015-02-27 02:05:19 +00:00
|
|
|
{
|
|
|
|
stride_x = geom->base_width;
|
|
|
|
stride_y = geom->base_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case MENU_ACTION_UP:
|
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
|
|
|
|
{
|
2015-03-23 02:09:30 +00:00
|
|
|
custom->y -= stride_y;
|
2015-02-27 02:05:19 +00:00
|
|
|
custom->height += stride_y;
|
|
|
|
}
|
|
|
|
else if (custom->height >= (unsigned)stride_y)
|
|
|
|
custom->height -= stride_y;
|
|
|
|
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_VIDEO_APPLY_STATE_CHANGES);
|
2015-02-27 02:05:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_DOWN:
|
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
|
|
|
|
{
|
|
|
|
custom->y += stride_y;
|
|
|
|
if (custom->height >= (unsigned)stride_y)
|
|
|
|
custom->height -= stride_y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
custom->height += stride_y;
|
|
|
|
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_VIDEO_APPLY_STATE_CHANGES);
|
2015-02-27 02:05:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_LEFT:
|
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
|
|
|
|
{
|
2015-03-23 02:09:30 +00:00
|
|
|
custom->x -= stride_x;
|
2015-02-27 02:05:19 +00:00
|
|
|
custom->width += stride_x;
|
|
|
|
}
|
|
|
|
else if (custom->width >= (unsigned)stride_x)
|
|
|
|
custom->width -= stride_x;
|
|
|
|
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_VIDEO_APPLY_STATE_CHANGES);
|
2015-02-27 02:05:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_RIGHT:
|
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
|
|
|
|
{
|
|
|
|
custom->x += stride_x;
|
|
|
|
if (custom->width >= (unsigned)stride_x)
|
|
|
|
custom->width -= stride_x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
custom->width += stride_x;
|
|
|
|
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_VIDEO_APPLY_STATE_CHANGES);
|
2015-02-27 02:05:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_CANCEL:
|
2015-05-07 08:55:57 +00:00
|
|
|
menu_list_pop_stack(menu_list);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
if (!strcmp(label, "custom_viewport_2"))
|
|
|
|
{
|
2015-05-18 18:57:56 +00:00
|
|
|
info.list = menu_list->menu_stack;
|
|
|
|
info.type = MENU_SETTINGS_CUSTOM_VIEWPORT;
|
|
|
|
info.directory_ptr = menu->navigation.selection_ptr;
|
|
|
|
|
|
|
|
menu_displaylist_push_list(&info, DISPLAYLIST_SELECT);
|
2015-02-27 02:05:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_OK:
|
2015-05-07 08:55:57 +00:00
|
|
|
menu_list_pop_stack(menu_list);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT
|
2015-03-20 20:22:38 +00:00
|
|
|
&& !settings->video.scale_integer)
|
2015-05-18 18:57:56 +00:00
|
|
|
{
|
|
|
|
info.list = menu_list->menu_stack;
|
|
|
|
strlcpy(info.label, "custom_viewport_2", sizeof(info.label));
|
|
|
|
info.type = 0;
|
|
|
|
info.directory_ptr = menu->navigation.selection_ptr;
|
|
|
|
|
|
|
|
menu_displaylist_push_list(&info, DISPLAYLIST_SELECT);
|
|
|
|
}
|
2015-02-27 02:05:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_START:
|
2015-03-20 20:22:38 +00:00
|
|
|
if (!settings->video.scale_integer)
|
2015-02-27 02:05:19 +00:00
|
|
|
{
|
|
|
|
video_viewport_t vp;
|
2015-03-22 20:28:50 +00:00
|
|
|
video_driver_viewport_info(&vp);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
|
|
|
|
{
|
2015-03-23 02:09:30 +00:00
|
|
|
custom->width += custom->x;
|
2015-02-27 02:05:19 +00:00
|
|
|
custom->height += custom->y;
|
2015-03-23 02:09:30 +00:00
|
|
|
custom->x = 0;
|
|
|
|
custom->y = 0;
|
2015-02-27 02:05:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-03-23 02:09:30 +00:00
|
|
|
custom->width = vp.full_width - custom->x;
|
|
|
|
custom->height = vp.full_height - custom->y;
|
2015-02-27 02:05:19 +00:00
|
|
|
}
|
|
|
|
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_VIDEO_APPLY_STATE_CHANGES);
|
2015-02-27 02:05:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_MESSAGE:
|
|
|
|
menu->msg_force = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-05-07 08:55:57 +00:00
|
|
|
menu_list_get_last_stack(menu_list, NULL, &label, &type);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
2015-03-22 05:03:55 +00:00
|
|
|
menu_driver_render();
|
2015-02-27 02:05:19 +00:00
|
|
|
|
2015-03-20 20:22:38 +00:00
|
|
|
if (settings->video.scale_integer)
|
2015-02-27 02:05:19 +00:00
|
|
|
{
|
2015-03-23 02:09:30 +00:00
|
|
|
custom->x = 0;
|
|
|
|
custom->y = 0;
|
2015-02-27 02:05:19 +00:00
|
|
|
custom->width = ((custom->width + geom->base_width - 1) /
|
|
|
|
geom->base_width) * geom->base_width;
|
|
|
|
custom->height = ((custom->height + geom->base_height - 1) /
|
|
|
|
geom->base_height) * geom->base_height;
|
2015-03-23 02:09:30 +00:00
|
|
|
base_msg = "Set scale";
|
|
|
|
|
2015-05-18 20:26:00 +00:00
|
|
|
snprintf(s, len, "%s (%4ux%4u, %u x %u scale)",
|
2015-02-27 02:05:19 +00:00
|
|
|
base_msg,
|
|
|
|
custom->width, custom->height,
|
|
|
|
custom->width / geom->base_width,
|
|
|
|
custom->height / geom->base_height);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
|
|
|
|
base_msg = "Set Upper-Left Corner";
|
|
|
|
else if (!strcmp(label, "custom_viewport_2"))
|
|
|
|
base_msg = "Set Bottom-Right Corner";
|
|
|
|
|
2015-05-18 20:26:00 +00:00
|
|
|
snprintf(s, len, "%s (%d, %d : %4ux%4u)",
|
2015-02-27 02:05:19 +00:00
|
|
|
base_msg, custom->x, custom->y, custom->width, custom->height);
|
|
|
|
}
|
|
|
|
|
2015-05-18 20:26:00 +00:00
|
|
|
menu_driver_render_messagebox(s);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
if (!custom->width)
|
|
|
|
custom->width = stride_x;
|
|
|
|
if (!custom->height)
|
|
|
|
custom->height = stride_y;
|
|
|
|
|
|
|
|
aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
|
|
|
|
(float)custom->width / custom->height;
|
|
|
|
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_VIDEO_APPLY_STATE_CHANGES);
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-18 19:42:09 +00:00
|
|
|
enum action_iterate_type
|
|
|
|
{
|
|
|
|
ITERATE_TYPE_DEFAULT = 0,
|
|
|
|
ITERATE_TYPE_HELP,
|
|
|
|
ITERATE_TYPE_INFO,
|
|
|
|
ITERATE_TYPE_ZIP,
|
|
|
|
ITERATE_TYPE_MESSAGE,
|
|
|
|
ITERATE_TYPE_VIEWPORT,
|
|
|
|
ITERATE_TYPE_BIND,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum action_iterate_type action_iterate_type(const char *label)
|
2015-05-08 09:16:31 +00:00
|
|
|
{
|
2015-05-08 09:11:18 +00:00
|
|
|
if (!strcmp(label, "help"))
|
2015-05-18 19:42:09 +00:00
|
|
|
return ITERATE_TYPE_HELP;
|
2015-05-08 09:11:18 +00:00
|
|
|
else if (!strcmp(label, "info_screen"))
|
2015-05-18 19:42:09 +00:00
|
|
|
return ITERATE_TYPE_INFO;
|
2015-05-08 09:11:18 +00:00
|
|
|
else if (!strcmp(label, "load_open_zip"))
|
2015-05-18 19:42:09 +00:00
|
|
|
return ITERATE_TYPE_ZIP;
|
2015-05-08 09:11:18 +00:00
|
|
|
else if (!strcmp(label, "message"))
|
2015-05-18 19:42:09 +00:00
|
|
|
return ITERATE_TYPE_MESSAGE;
|
2015-05-08 09:11:18 +00:00
|
|
|
else if (
|
|
|
|
!strcmp(label, "custom_viewport_1") ||
|
|
|
|
!strcmp(label, "custom_viewport_2")
|
|
|
|
)
|
2015-05-18 19:42:09 +00:00
|
|
|
return ITERATE_TYPE_VIEWPORT;
|
2015-05-08 09:11:18 +00:00
|
|
|
else if (
|
|
|
|
!strcmp(label, "custom_bind") ||
|
|
|
|
!strcmp(label, "custom_bind_all") ||
|
|
|
|
!strcmp(label, "custom_bind_defaults")
|
|
|
|
)
|
2015-05-18 19:42:09 +00:00
|
|
|
return ITERATE_TYPE_BIND;
|
|
|
|
return ITERATE_TYPE_DEFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int action_iterate_main(const char *label, unsigned action)
|
|
|
|
{
|
2015-05-18 21:56:23 +00:00
|
|
|
static bool did_messagebox = false;
|
2015-05-18 20:26:00 +00:00
|
|
|
char msg[PATH_MAX_LENGTH];
|
2015-05-18 19:42:09 +00:00
|
|
|
enum action_iterate_type iterate_type;
|
|
|
|
menu_entry_t entry;
|
2015-05-18 19:58:17 +00:00
|
|
|
size_t selected, *pop_selected = false;
|
2015-05-18 20:28:34 +00:00
|
|
|
bool do_messagebox = false;
|
2015-05-18 19:55:20 +00:00
|
|
|
bool do_pop_stack = false;
|
2015-05-18 19:52:14 +00:00
|
|
|
bool do_post_iterate = false;
|
|
|
|
bool do_render = false;
|
2015-05-18 19:42:09 +00:00
|
|
|
int ret = 0;
|
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
|
|
|
if (!menu || !menu_list)
|
2015-05-18 01:37:07 +00:00
|
|
|
return 0;
|
2015-05-18 19:42:09 +00:00
|
|
|
|
|
|
|
iterate_type = action_iterate_type(label);
|
2015-05-08 09:11:18 +00:00
|
|
|
|
2015-05-18 19:42:09 +00:00
|
|
|
switch (iterate_type)
|
|
|
|
{
|
|
|
|
case ITERATE_TYPE_HELP:
|
2015-05-18 20:26:00 +00:00
|
|
|
ret = action_iterate_help(msg, sizeof(msg), label);
|
2015-05-18 19:58:17 +00:00
|
|
|
pop_selected = NULL;
|
2015-05-18 20:28:34 +00:00
|
|
|
do_messagebox = true;
|
2015-05-18 19:58:17 +00:00
|
|
|
do_pop_stack = true;
|
2015-05-18 19:52:14 +00:00
|
|
|
do_post_iterate = true;
|
2015-05-18 19:42:09 +00:00
|
|
|
break;
|
|
|
|
case ITERATE_TYPE_BIND:
|
|
|
|
if (menu_input_bind_iterate())
|
|
|
|
menu_list_pop_stack(menu_list);
|
|
|
|
break;
|
|
|
|
case ITERATE_TYPE_VIEWPORT:
|
2015-05-18 20:26:00 +00:00
|
|
|
ret = action_iterate_menu_viewport(msg, sizeof(msg), label, action);
|
2015-05-18 19:42:09 +00:00
|
|
|
break;
|
|
|
|
case ITERATE_TYPE_INFO:
|
2015-05-18 20:26:00 +00:00
|
|
|
ret = action_iterate_info(msg, sizeof(msg), label);
|
2015-05-18 19:58:17 +00:00
|
|
|
pop_selected = &menu->navigation.selection_ptr;
|
2015-05-18 20:28:34 +00:00
|
|
|
do_messagebox = true;
|
2015-05-18 19:55:20 +00:00
|
|
|
do_pop_stack = true;
|
2015-05-18 19:52:14 +00:00
|
|
|
do_post_iterate = true;
|
2015-05-18 19:42:09 +00:00
|
|
|
break;
|
|
|
|
case ITERATE_TYPE_ZIP:
|
2015-05-18 20:26:00 +00:00
|
|
|
ret = action_iterate_load_open_zip(label, msg, sizeof(msg), action);
|
2015-05-18 19:42:09 +00:00
|
|
|
break;
|
|
|
|
case ITERATE_TYPE_MESSAGE:
|
2015-05-18 20:32:31 +00:00
|
|
|
strlcpy(msg, menu->message_contents, sizeof(msg));
|
2015-05-18 19:58:17 +00:00
|
|
|
pop_selected = &menu->navigation.selection_ptr;
|
2015-05-18 20:32:31 +00:00
|
|
|
do_messagebox = true;
|
2015-05-18 19:55:20 +00:00
|
|
|
do_pop_stack = true;
|
2015-05-18 19:42:09 +00:00
|
|
|
break;
|
|
|
|
case ITERATE_TYPE_DEFAULT:
|
|
|
|
selected = menu_navigation_get_current_selection();
|
|
|
|
menu_entry_get(&entry, selected, NULL, false);
|
2015-05-20 00:50:27 +00:00
|
|
|
ret = menu_entry_action(&entry, selected, (enum menu_action)action);
|
2015-05-08 09:11:18 +00:00
|
|
|
|
2015-05-18 19:42:09 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2015-02-27 02:05:19 +00:00
|
|
|
|
2015-05-18 19:52:14 +00:00
|
|
|
do_post_iterate = true;
|
|
|
|
do_render = true;
|
2015-02-27 02:05:19 +00:00
|
|
|
|
2015-05-18 19:42:09 +00:00
|
|
|
/* Have to defer it so we let settings refresh. */
|
|
|
|
if (menu->push_start_screen)
|
|
|
|
{
|
|
|
|
menu_displaylist_info_t info = {0};
|
2015-05-08 09:16:31 +00:00
|
|
|
|
2015-05-18 19:42:09 +00:00
|
|
|
info.list = menu_list->menu_stack;
|
|
|
|
strlcpy(info.label, "help", sizeof(info.label));
|
2015-05-18 01:25:45 +00:00
|
|
|
|
2015-05-18 19:42:09 +00:00
|
|
|
menu_displaylist_push_list(&info, DISPLAYLIST_HELP);
|
|
|
|
}
|
|
|
|
break;
|
2015-02-27 02:05:19 +00:00
|
|
|
}
|
2015-05-18 19:55:20 +00:00
|
|
|
|
2015-05-18 21:56:23 +00:00
|
|
|
did_messagebox = did_messagebox != do_messagebox;
|
|
|
|
|
|
|
|
if (did_messagebox)
|
2015-05-18 22:05:17 +00:00
|
|
|
menu_display_fb_set_dirty();
|
2015-05-18 21:56:23 +00:00
|
|
|
|
2015-05-18 20:28:34 +00:00
|
|
|
if (do_messagebox)
|
|
|
|
menu_driver_render_messagebox(msg);
|
|
|
|
|
2015-05-18 19:55:20 +00:00
|
|
|
if (do_pop_stack && action == MENU_ACTION_OK)
|
2015-05-18 19:58:17 +00:00
|
|
|
menu_list_pop(menu_list->menu_stack, pop_selected);
|
2015-05-18 19:52:14 +00:00
|
|
|
|
|
|
|
if (do_post_iterate)
|
|
|
|
menu_input_post_iterate(&ret, action);
|
|
|
|
|
|
|
|
if (do_render)
|
|
|
|
menu_driver_render();
|
2015-02-27 02:05:19 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void menu_entries_cbs_init_bind_iterate(menu_file_list_cbs_t *cbs,
|
|
|
|
const char *path, const char *label, unsigned type, size_t idx,
|
|
|
|
const char *elem0, const char *elem1)
|
|
|
|
{
|
|
|
|
if (cbs)
|
|
|
|
cbs->action_iterate = action_iterate_main;
|
|
|
|
}
|