2012-05-06 04:04:33 +02:00
/* RetroArch - A frontend for libretro.
2013-01-01 01:37:37 +01:00
* Copyright ( C ) 2010 - 2013 - Hans - Kristian Arntzen
2013-03-11 07:13:11 +01:00
* Copyright ( C ) 2011 - 2013 - Daniel De Matteis
* Copyright ( C ) 2012 - 2013 - Michael Lelli
2012-05-06 04:04:33 +02:00
*
* 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 <stdlib.h>
# include <stddef.h>
# include <stdio.h>
# include <string.h>
# include <limits.h>
2013-01-09 17:49:43 +01:00
# include "rgui.h"
2013-09-19 14:49:07 +02:00
# include "menu_context.h"
2013-01-09 17:49:43 +01:00
# include "utils/file_list.h"
2013-03-09 15:33:44 +01:00
# include "../../general.h"
2013-07-15 14:54:40 +02:00
# include "../../file_ext.h"
2013-03-09 03:20:33 +01:00
# include "../../gfx/gfx_common.h"
2013-03-16 09:55:08 +01:00
# include "../../config.def.h"
# include "../../file.h"
2013-03-17 21:18:56 +01:00
# include "../../dynamic.h"
2013-04-04 20:21:51 +02:00
# include "../../compat/posix_string.h"
2013-04-07 16:45:05 +02:00
# include "../../gfx/shader_parse.h"
2013-07-06 20:39:19 +02:00
# include "../../performance.h"
2013-09-29 20:40:04 +02:00
# include "../../input/input_common.h"
2013-03-09 15:33:44 +01:00
# ifdef HAVE_OPENGL
# include "../../gfx/gl_common.h"
# endif
2013-01-09 17:49:43 +01:00
# include "../../screenshot.h"
2013-04-09 19:43:24 +02:00
# if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL)
# define HAVE_SHADER_MANAGER
# endif
2012-09-11 23:33:44 -04:00
unsigned RGUI_WIDTH = 320 ;
2012-09-11 21:19:22 -04:00
unsigned RGUI_HEIGHT = 240 ;
2013-03-09 15:33:44 +01:00
uint16_t menu_framebuf [ 400 * 240 ] ;
2013-04-07 16:45:05 +02:00
2013-05-08 19:12:18 -04:00
# ifdef HAVE_SHADER_MANAGER
2013-04-14 22:59:36 +02:00
static int shader_manager_toggle_setting ( rgui_handle_t * rgui , unsigned setting , rgui_action_t action ) ;
2013-05-08 19:12:18 -04:00
# endif
2013-04-14 22:59:36 +02:00
2013-05-17 23:57:06 +02:00
static void rgui_flush_menu_stack_type ( rgui_handle_t * rgui , unsigned final_type )
2013-05-04 16:56:02 +02:00
{
rgui - > need_refresh = true ;
unsigned type = 0 ;
rgui_list_get_last ( rgui - > menu_stack , NULL , & type ) ;
2013-05-17 23:57:06 +02:00
while ( type ! = final_type )
2013-05-04 16:56:02 +02:00
{
rgui_list_pop ( rgui - > menu_stack , & rgui - > selection_ptr ) ;
rgui_list_get_last ( rgui - > menu_stack , NULL , & type ) ;
}
}
2013-04-07 15:46:36 +02:00
static bool menu_type_is_settings ( unsigned type )
{
return type = = RGUI_SETTINGS | |
type = = RGUI_SETTINGS_CORE_OPTIONS | |
2013-04-28 00:32:25 +02:00
type = = RGUI_SETTINGS_VIDEO_OPTIONS | |
2013-05-06 00:53:53 +02:00
# ifdef HAVE_SHADER_MANAGER
2013-05-04 23:35:39 +02:00
type = = RGUI_SETTINGS_SHADER_OPTIONS | |
2013-05-06 00:53:53 +02:00
# endif
2013-05-04 19:00:57 +02:00
type = = RGUI_SETTINGS_AUDIO_OPTIONS | |
2013-05-04 19:26:34 +02:00
type = = RGUI_SETTINGS_DISK_OPTIONS | |
2013-05-04 21:17:47 +02:00
type = = RGUI_SETTINGS_PATH_OPTIONS | |
2013-05-05 22:02:30 +02:00
type = = RGUI_SETTINGS_OPTIONS | |
2013-05-04 19:00:57 +02:00
( type = = RGUI_SETTINGS_INPUT_OPTIONS ) ;
2013-04-07 15:46:36 +02:00
}
2013-04-28 01:04:34 +02:00
# ifdef HAVE_SHADER_MANAGER
2013-04-09 21:01:12 +02:00
static bool menu_type_is_shader_browser ( unsigned type )
{
2013-04-14 01:27:13 +02:00
return ( type > = RGUI_SETTINGS_SHADER_0 & &
2013-04-09 21:01:12 +02:00
type < = RGUI_SETTINGS_SHADER_LAST & &
2013-04-14 01:27:13 +02:00
( ( type - RGUI_SETTINGS_SHADER_0 ) % 3 ) = = 0 ) | |
type = = RGUI_SETTINGS_SHADER_PRESET ;
2013-04-09 21:01:12 +02:00
}
2013-04-28 01:04:34 +02:00
# endif
2013-04-09 21:01:12 +02:00
2013-05-20 22:17:26 -04:00
static bool menu_type_is_directory_browser ( unsigned type )
{
return type = = RGUI_BROWSER_DIR_PATH | |
# ifdef HAVE_SHADER_MANAGER
type = = RGUI_SHADER_DIR_PATH | |
# endif
type = = RGUI_SAVESTATE_DIR_PATH | |
2013-09-15 17:09:23 -04:00
# ifdef HAVE_DYNAMIC
2013-09-12 22:00:59 +02:00
type = = RGUI_LIBRETRO_DIR_PATH | |
2013-09-15 17:09:23 -04:00
# endif
2013-09-15 16:15:38 +02:00
type = = RGUI_CONFIG_DIR_PATH | |
2013-05-20 22:17:26 -04:00
type = = RGUI_SAVEFILE_DIR_PATH | |
2013-05-22 22:31:16 +02:00
# ifdef HAVE_OVERLAY
type = = RGUI_OVERLAY_DIR_PATH | |
2013-09-16 23:30:42 +02:00
# endif
# ifdef HAVE_SCREENSHOTS
type = = RGUI_SCREENSHOT_DIR_PATH | |
2013-05-22 22:31:16 +02:00
# endif
2013-05-20 22:17:26 -04:00
type = = RGUI_SYSTEM_DIR_PATH ;
}
2013-04-18 23:00:27 +02:00
static void rgui_settings_populate_entries ( rgui_handle_t * rgui ) ;
2013-09-28 04:45:44 +02:00
# include "rguidisp_bitmap.c"
2013-09-19 15:01:17 +02:00
static void * rgui_init ( void )
2012-05-06 04:04:33 +02:00
{
2013-04-18 14:57:28 +02:00
uint16_t * framebuf = menu_framebuf ;
size_t framebuf_pitch = RGUI_WIDTH * sizeof ( uint16_t ) ;
2012-05-06 04:04:33 +02:00
rgui_handle_t * rgui = ( rgui_handle_t * ) calloc ( 1 , sizeof ( * rgui ) ) ;
2012-08-26 20:33:22 -04:00
rgui - > frame_buf = framebuf ;
rgui - > frame_buf_pitch = framebuf_pitch ;
2012-05-06 04:04:33 +02:00
2013-09-28 04:45:44 +02:00
bool ret = rguidisp_init_font ( rgui ) ;
if ( ! ret )
2012-08-26 20:33:22 -04:00
{
2013-09-28 04:45:44 +02:00
RARCH_ERR ( " No font bitmap or binary, abort " ) ;
2013-04-18 18:33:03 +02:00
/* TODO - should be refactored - perhaps don't do rarch_fail but instead
* exit program */
2013-05-05 15:20:45 +02:00
g_extern . lifecycle_mode_state & = ~ ( ( 1ULL < < MODE_MENU ) | ( 1ULL < < MODE_GAME ) ) ;
2013-04-18 22:22:25 +02:00
return NULL ;
2012-08-26 20:33:22 -04:00
}
2012-05-06 04:04:33 +02:00
2013-04-18 22:22:25 +02:00
strlcpy ( rgui - > base_path , g_settings . rgui_browser_directory , sizeof ( rgui - > base_path ) ) ;
rgui - > menu_stack = ( rgui_list_t * ) calloc ( 1 , sizeof ( rgui_list_t ) ) ;
rgui - > selection_buf = ( rgui_list_t * ) calloc ( 1 , sizeof ( rgui_list_t ) ) ;
rgui_list_push ( rgui - > menu_stack , " " , RGUI_SETTINGS , 0 ) ;
2013-04-18 23:00:27 +02:00
rgui - > selection_ptr = 0 ;
rgui_settings_populate_entries ( rgui ) ;
2013-04-18 22:22:25 +02:00
2013-04-20 10:56:04 +02:00
// Make sure that custom viewport is something sane incase we use it
// before it's configured.
rarch_viewport_t * custom = & g_extern . console . screen . viewports . custom_vp ;
if ( driver . video_data & & ( ! custom - > width | | ! custom - > height ) )
2013-04-20 12:48:33 +02:00
{
2013-04-20 10:56:04 +02:00
driver . video - > viewport_info ( driver . video_data , custom ) ;
2013-04-20 12:48:33 +02:00
aspectratio_lut [ ASPECT_RATIO_CUSTOM ] . value =
( float ) custom - > width / custom - > height ;
}
2013-08-19 22:59:54 +02:00
else if ( DEFAULT_ASPECT_RATIO > 0.0f )
aspectratio_lut [ ASPECT_RATIO_CUSTOM ] . value = DEFAULT_ASPECT_RATIO ;
else
aspectratio_lut [ ASPECT_RATIO_CUSTOM ] . value = 4.0f / 3.0f ; // Something arbitrary
2013-04-20 10:56:04 +02:00
2012-05-06 04:04:33 +02:00
return rgui ;
}
2013-09-19 15:01:17 +02:00
static void rgui_free ( void * data )
2012-05-06 04:04:33 +02:00
{
2013-09-19 14:49:07 +02:00
rgui_handle_t * rgui = ( rgui_handle_t * ) data ;
2012-08-27 14:48:00 -04:00
if ( rgui - > alloc_font )
2013-04-28 00:35:20 +02:00
free ( ( uint8_t * ) rgui - > font ) ;
2013-03-17 21:18:56 +01:00
# ifdef HAVE_DYNAMIC
libretro_free_system_info ( & rgui - > info ) ;
# endif
2013-04-18 22:22:25 +02:00
rgui_list_free ( rgui - > menu_stack ) ;
rgui_list_free ( rgui - > selection_buf ) ;
2012-05-06 04:04:33 +02:00
}
2013-04-04 22:08:23 +02:00
static int rgui_core_setting_toggle ( unsigned setting , rgui_action_t action )
{
unsigned index = setting - RGUI_SETTINGS_CORE_OPTION_START ;
switch ( action )
{
case RGUI_ACTION_LEFT :
core_option_prev ( g_extern . system . core_options , index ) ;
break ;
case RGUI_ACTION_RIGHT :
case RGUI_ACTION_OK :
core_option_next ( g_extern . system . core_options , index ) ;
break ;
case RGUI_ACTION_START :
core_option_set_default ( g_extern . system . core_options , index ) ;
break ;
default :
break ;
}
return 0 ;
}
2013-04-07 16:45:05 +02:00
static int rgui_settings_toggle_setting ( rgui_handle_t * rgui , unsigned setting , rgui_action_t action , unsigned menu_type )
2012-07-16 17:57:43 -04:00
{
2013-05-08 18:17:30 +02:00
# ifdef HAVE_SHADER_MANAGER
2013-09-29 15:47:45 +02:00
if ( setting > = RGUI_SETTINGS_SHADER_FILTER & & setting < = RGUI_SETTINGS_SHADER_LAST )
2013-04-07 16:45:05 +02:00
return shader_manager_toggle_setting ( rgui , setting , action ) ;
2013-05-08 18:17:30 +02:00
# endif
2013-04-04 22:08:23 +02:00
if ( setting > = RGUI_SETTINGS_CORE_OPTION_START )
return rgui_core_setting_toggle ( setting , action ) ;
2013-09-29 15:47:45 +02:00
return menu_set_settings ( setting , action ) ;
2012-07-16 17:57:43 -04:00
}
2013-05-04 19:00:57 +02:00
static void rgui_settings_audio_options_populate_entries ( rgui_handle_t * rgui )
{
rgui_list_clear ( rgui - > selection_buf ) ;
rgui_list_push ( rgui - > selection_buf , " Mute Audio " , RGUI_SETTINGS_AUDIO_MUTE , 0 ) ;
2013-05-04 22:47:14 +02:00
rgui_list_push ( rgui - > selection_buf , " Rate Control Delta " , RGUI_SETTINGS_AUDIO_CONTROL_RATE_DELTA , 0 ) ;
2013-05-04 19:00:57 +02:00
}
2013-05-04 19:26:34 +02:00
static void rgui_settings_disc_options_populate_entries ( rgui_handle_t * rgui )
{
rgui_list_clear ( rgui - > selection_buf ) ;
rgui_list_push ( rgui - > selection_buf , " Disk Index " , RGUI_SETTINGS_DISK_INDEX , 0 ) ;
rgui_list_push ( rgui - > selection_buf , " Disk Image Append " , RGUI_SETTINGS_DISK_APPEND , 0 ) ;
}
2013-05-05 22:02:30 +02:00
static void rgui_settings_options_populate_entries ( rgui_handle_t * rgui )
{
rgui_list_clear ( rgui - > selection_buf ) ;
2013-05-17 22:22:15 +02:00
rgui_list_push ( rgui - > selection_buf , " Rewind " , RGUI_SETTINGS_REWIND_ENABLE , 0 ) ;
rgui_list_push ( rgui - > selection_buf , " Rewind Granularity " , RGUI_SETTINGS_REWIND_GRANULARITY , 0 ) ;
2013-09-16 23:10:15 +02:00
# ifdef HAVE_SCREENSHOTS
rgui_list_push ( rgui - > selection_buf , " GPU Screenshots " , RGUI_SETTINGS_GPU_SCREENSHOT , 0 ) ;
# endif
2013-05-22 15:35:28 +02:00
rgui_list_push ( rgui - > selection_buf , " Config Save On Exit " , RGUI_SETTINGS_CONFIG_SAVE_ON_EXIT , 0 ) ;
2013-05-17 22:22:15 +02:00
# if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE)
rgui_list_push ( rgui - > selection_buf , " SRAM Autosave " , RGUI_SETTINGS_SRAM_AUTOSAVE , 0 ) ;
# endif
2013-05-05 22:02:30 +02:00
rgui_list_push ( rgui - > selection_buf , " Debug Info Messages " , RGUI_SETTINGS_DEBUG_TEXT , 0 ) ;
}
2012-07-16 17:57:43 -04:00
static void rgui_settings_populate_entries ( rgui_handle_t * rgui )
{
2013-03-11 03:56:06 +01:00
rgui_list_clear ( rgui - > selection_buf ) ;
2012-07-27 20:39:49 -04:00
2013-04-08 01:51:18 +02:00
# if defined(HAVE_DYNAMIC) || defined(HAVE_LIBRETRO_MANAGEMENT)
2013-03-17 21:23:28 +01:00
rgui_list_push ( rgui - > selection_buf , " Core " , RGUI_SETTINGS_CORE , 0 ) ;
# endif
2013-04-29 14:12:39 +02:00
if ( rgui - > history )
rgui_list_push ( rgui - > selection_buf , " Load Game (History) " , RGUI_SETTINGS_OPEN_HISTORY , 0 ) ;
2013-04-20 18:06:08 +02:00
rgui_list_push ( rgui - > selection_buf , " Load Game " , RGUI_SETTINGS_OPEN_FILEBROWSER , 0 ) ;
2013-05-04 16:48:53 +02:00
rgui_list_push ( rgui - > selection_buf , " Core Options " , RGUI_SETTINGS_CORE_OPTIONS , 0 ) ;
2013-04-28 00:32:25 +02:00
rgui_list_push ( rgui - > selection_buf , " Video Options " , RGUI_SETTINGS_VIDEO_OPTIONS , 0 ) ;
2013-05-04 19:00:57 +02:00
rgui_list_push ( rgui - > selection_buf , " Audio Options " , RGUI_SETTINGS_AUDIO_OPTIONS , 0 ) ;
rgui_list_push ( rgui - > selection_buf , " Input Options " , RGUI_SETTINGS_INPUT_OPTIONS , 0 ) ;
2013-05-04 21:17:47 +02:00
rgui_list_push ( rgui - > selection_buf , " Path Options " , RGUI_SETTINGS_PATH_OPTIONS , 0 ) ;
2013-05-05 22:02:30 +02:00
rgui_list_push ( rgui - > selection_buf , " Settings " , RGUI_SETTINGS_OPTIONS , 0 ) ;
2013-04-20 18:06:08 +02:00
if ( g_extern . main_is_init & & ! g_extern . libretro_dummy )
2012-08-12 03:38:23 -04:00
{
2013-05-04 19:26:34 +02:00
if ( g_extern . system . disk_control . get_num_images )
rgui_list_push ( rgui - > selection_buf , " Disk Options " , RGUI_SETTINGS_DISK_OPTIONS , 0 ) ;
2013-03-11 03:56:06 +01:00
rgui_list_push ( rgui - > selection_buf , " Save State " , RGUI_SETTINGS_SAVESTATE_SAVE , 0 ) ;
rgui_list_push ( rgui - > selection_buf , " Load State " , RGUI_SETTINGS_SAVESTATE_LOAD , 0 ) ;
2013-03-10 17:54:46 -04:00
# ifdef HAVE_SCREENSHOTS
2013-03-11 03:56:06 +01:00
rgui_list_push ( rgui - > selection_buf , " Take Screenshot " , RGUI_SETTINGS_SCREENSHOT , 0 ) ;
2013-03-10 17:54:46 -04:00
# endif
2013-04-04 04:56:04 +02:00
rgui_list_push ( rgui - > selection_buf , " Resume Game " , RGUI_SETTINGS_RESUME_GAME , 0 ) ;
2013-03-11 03:56:06 +01:00
rgui_list_push ( rgui - > selection_buf , " Restart Game " , RGUI_SETTINGS_RESTART_GAME , 0 ) ;
2013-04-27 13:29:01 +02:00
2012-08-12 03:38:23 -04:00
}
2013-03-09 21:30:40 +01:00
# ifndef HAVE_DYNAMIC
2013-03-11 03:56:06 +01:00
rgui_list_push ( rgui - > selection_buf , " Restart RetroArch " , RGUI_SETTINGS_RESTART_EMULATOR , 0 ) ;
2013-03-09 21:30:40 +01:00
# endif
2013-09-15 15:36:45 +02:00
rgui_list_push ( rgui - > selection_buf , " RetroArch Config " , RGUI_SETTINGS_CONFIG , 0 ) ;
2013-09-22 12:48:33 +02:00
rgui_list_push ( rgui - > selection_buf , " Save New Config " , RGUI_SETTINGS_SAVE_CONFIG , 0 ) ;
2013-03-24 06:32:22 +01:00
rgui_list_push ( rgui - > selection_buf , " Quit RetroArch " , RGUI_SETTINGS_QUIT_RARCH , 0 ) ;
2012-07-16 17:57:43 -04:00
}
2013-04-04 21:47:37 +02:00
static void rgui_settings_core_options_populate_entries ( rgui_handle_t * rgui )
{
rgui_list_clear ( rgui - > selection_buf ) ;
2013-04-04 22:08:23 +02:00
if ( g_extern . system . core_options )
{
size_t opts = core_option_size ( g_extern . system . core_options ) ;
for ( size_t i = 0 ; i < opts ; i + + )
rgui_list_push ( rgui - > selection_buf ,
core_option_get_desc ( g_extern . system . core_options , i ) , RGUI_SETTINGS_CORE_OPTION_START + i , 0 ) ;
}
else
rgui_list_push ( rgui - > selection_buf , " No options available. " , RGUI_SETTINGS_CORE_OPTION_NONE , 0 ) ;
2013-04-04 21:47:37 +02:00
}
2013-05-04 23:35:39 +02:00
static void rgui_settings_video_options_populate_entries ( rgui_handle_t * rgui )
2013-04-07 15:46:36 +02:00
{
rgui_list_clear ( rgui - > selection_buf ) ;
2013-05-04 23:35:39 +02:00
# ifdef HAVE_SHADER_MANAGER
rgui_list_push ( rgui - > selection_buf , " Shader Options " , RGUI_SETTINGS_SHADER_OPTIONS , 0 ) ;
# endif
2013-04-28 01:41:38 +02:00
# ifdef GEKKO
rgui_list_push ( rgui - > selection_buf , " Screen Resolution " , RGUI_SETTINGS_VIDEO_RESOLUTION , 0 ) ;
# endif
2013-04-28 01:52:58 +02:00
# ifndef HAVE_SHADER_MANAGER
rgui_list_push ( rgui - > selection_buf , " Default Filter " , RGUI_SETTINGS_VIDEO_FILTER , 0 ) ;
2013-04-28 01:41:38 +02:00
# endif
# ifdef HW_RVL
rgui_list_push ( rgui - > selection_buf , " VI Trap filtering " , RGUI_SETTINGS_VIDEO_SOFT_FILTER , 0 ) ;
rgui_list_push ( rgui - > selection_buf , " Gamma " , RGUI_SETTINGS_VIDEO_GAMMA , 0 ) ;
# endif
rgui_list_push ( rgui - > selection_buf , " Integer Scale " , RGUI_SETTINGS_VIDEO_INTEGER_SCALE , 0 ) ;
rgui_list_push ( rgui - > selection_buf , " Aspect Ratio " , RGUI_SETTINGS_VIDEO_ASPECT_RATIO , 0 ) ;
rgui_list_push ( rgui - > selection_buf , " Custom Ratio " , RGUI_SETTINGS_CUSTOM_VIEWPORT , 0 ) ;
2013-09-01 13:46:35 +02:00
# if !defined(RARCH_CONSOLE) && !defined(RARCH_MOBILE)
2013-04-28 01:41:38 +02:00
rgui_list_push ( rgui - > selection_buf , " Toggle Fullscreen " , RGUI_SETTINGS_TOGGLE_FULLSCREEN , 0 ) ;
2013-09-01 13:46:35 +02:00
# endif
2013-04-28 01:04:34 +02:00
rgui_list_push ( rgui - > selection_buf , " Rotation " , RGUI_SETTINGS_VIDEO_ROTATION , 0 ) ;
2013-05-04 22:48:24 +02:00
rgui_list_push ( rgui - > selection_buf , " VSync " , RGUI_SETTINGS_VIDEO_VSYNC , 0 ) ;
2013-05-05 09:54:54 +02:00
rgui_list_push ( rgui - > selection_buf , " Hard GPU Sync " , RGUI_SETTINGS_VIDEO_HARD_SYNC , 0 ) ;
2013-05-26 13:43:24 +02:00
rgui_list_push ( rgui - > selection_buf , " Hard GPU Sync Frames " , RGUI_SETTINGS_VIDEO_HARD_SYNC_FRAMES , 0 ) ;
2013-08-30 09:35:13 +02:00
rgui_list_push ( rgui - > selection_buf , " Black Frame Insertion " , RGUI_SETTINGS_VIDEO_BLACK_FRAME_INSERTION , 0 ) ;
2013-09-01 13:20:10 +02:00
rgui_list_push ( rgui - > selection_buf , " VSync Swap Interval " , RGUI_SETTINGS_VIDEO_SWAP_INTERVAL , 0 ) ;
2013-09-01 13:46:35 +02:00
# if !defined(RARCH_CONSOLE) && !defined(RARCH_MOBILE)
rgui_list_push ( rgui - > selection_buf , " Windowed Scale (X) " , RGUI_SETTINGS_VIDEO_WINDOW_SCALE_X , 0 ) ;
rgui_list_push ( rgui - > selection_buf , " Windowed Scale (Y) " , RGUI_SETTINGS_VIDEO_WINDOW_SCALE_Y , 0 ) ;
# endif
rgui_list_push ( rgui - > selection_buf , " Crop Overscan (reload) " , RGUI_SETTINGS_VIDEO_CROP_OVERSCAN , 0 ) ;
2013-06-07 14:10:42 +02:00
rgui_list_push ( rgui - > selection_buf , " Estimated Monitor FPS " , RGUI_SETTINGS_VIDEO_REFRESH_RATE_AUTO , 0 ) ;
2013-05-04 23:35:39 +02:00
}
2013-04-28 00:32:25 +02:00
# ifdef HAVE_SHADER_MANAGER
2013-05-04 23:35:39 +02:00
static void rgui_settings_shader_manager_populate_entries ( rgui_handle_t * rgui )
{
rgui_list_clear ( rgui - > selection_buf ) ;
2013-04-28 01:52:58 +02:00
rgui_list_push ( rgui - > selection_buf , " Apply Shader Changes " ,
2013-04-07 16:45:05 +02:00
RGUI_SETTINGS_SHADER_APPLY , 0 ) ;
2013-04-28 01:52:58 +02:00
rgui_list_push ( rgui - > selection_buf , " Default Filter " , RGUI_SETTINGS_SHADER_FILTER , 0 ) ;
rgui_list_push ( rgui - > selection_buf , " Load Shader Preset " ,
2013-04-14 01:27:13 +02:00
RGUI_SETTINGS_SHADER_PRESET , 0 ) ;
2013-04-29 22:02:20 +02:00
rgui_list_push ( rgui - > selection_buf , " Shader Passes " ,
2013-04-07 16:45:05 +02:00
RGUI_SETTINGS_SHADER_PASSES , 0 ) ;
for ( unsigned i = 0 ; i < rgui - > shader . passes ; i + + )
{
char buf [ 64 ] ;
snprintf ( buf , sizeof ( buf ) , " Shader #%u " , i ) ;
rgui_list_push ( rgui - > selection_buf , buf ,
RGUI_SETTINGS_SHADER_0 + 3 * i , 0 ) ;
2013-04-28 01:52:58 +02:00
snprintf ( buf , sizeof ( buf ) , " Shader #%u Filter " , i ) ;
2013-04-07 16:45:05 +02:00
rgui_list_push ( rgui - > selection_buf , buf ,
RGUI_SETTINGS_SHADER_0_FILTER + 3 * i , 0 ) ;
2013-04-28 01:52:58 +02:00
snprintf ( buf , sizeof ( buf ) , " Shader #%u Scale " , i ) ;
2013-04-07 16:45:05 +02:00
rgui_list_push ( rgui - > selection_buf , buf ,
RGUI_SETTINGS_SHADER_0_SCALE + 3 * i , 0 ) ;
}
}
static int shader_manager_toggle_setting ( rgui_handle_t * rgui , unsigned setting , rgui_action_t action )
{
2013-04-09 19:43:24 +02:00
unsigned dist_shader = setting - RGUI_SETTINGS_SHADER_0 ;
unsigned dist_filter = setting - RGUI_SETTINGS_SHADER_0_FILTER ;
unsigned dist_scale = setting - RGUI_SETTINGS_SHADER_0_SCALE ;
2013-05-04 22:29:22 +02:00
2013-05-08 18:17:30 +02:00
if ( setting = = RGUI_SETTINGS_SHADER_FILTER )
2013-04-14 01:45:33 +02:00
{
switch ( action )
{
case RGUI_ACTION_START :
g_settings . video . smooth = true ;
break ;
case RGUI_ACTION_LEFT :
case RGUI_ACTION_RIGHT :
case RGUI_ACTION_OK :
g_settings . video . smooth = ! g_settings . video . smooth ;
break ;
default :
break ;
}
}
2013-09-30 02:17:15 +02:00
else if ( setting = = RGUI_SETTINGS_SHADER_APPLY | | setting = = RGUI_SETTINGS_SHADER_PASSES )
return menu_set_settings ( setting , action ) ;
2013-04-14 01:27:13 +02:00
else if ( ( dist_shader % 3 ) = = 0 | | setting = = RGUI_SETTINGS_SHADER_PRESET )
2013-04-09 19:43:24 +02:00
{
dist_shader / = 3 ;
2013-04-14 01:27:13 +02:00
struct gfx_shader_pass * pass = setting = = RGUI_SETTINGS_SHADER_PRESET ?
& rgui - > shader . pass [ dist_shader ] : NULL ;
2013-04-09 21:01:12 +02:00
switch ( action )
{
case RGUI_ACTION_OK :
rgui_list_push ( rgui - > menu_stack , g_settings . video . shader_dir , setting , rgui - > selection_ptr ) ;
rgui - > selection_ptr = 0 ;
rgui - > need_refresh = true ;
break ;
case RGUI_ACTION_START :
2013-04-14 01:27:13 +02:00
if ( pass )
* pass - > source . cg = ' \0 ' ;
2013-04-09 21:01:12 +02:00
break ;
default :
break ;
}
2013-04-09 19:43:24 +02:00
}
else if ( ( dist_filter % 3 ) = = 0 )
{
dist_filter / = 3 ;
struct gfx_shader_pass * pass = & rgui - > shader . pass [ dist_filter ] ;
switch ( action )
{
case RGUI_ACTION_START :
rgui - > shader . pass [ dist_filter ] . filter = RARCH_FILTER_UNSPEC ;
break ;
case RGUI_ACTION_LEFT :
case RGUI_ACTION_RIGHT :
case RGUI_ACTION_OK :
{
unsigned delta = action = = RGUI_ACTION_LEFT ? 2 : 1 ;
pass - > filter = ( enum gfx_filter_type ) ( ( pass - > filter + delta ) % 3 ) ;
break ;
}
default :
2013-04-07 16:45:05 +02:00
break ;
2013-04-09 19:43:24 +02:00
}
}
else if ( ( dist_scale % 3 ) = = 0 )
{
dist_scale / = 3 ;
struct gfx_shader_pass * pass = & rgui - > shader . pass [ dist_scale ] ;
switch ( action )
{
case RGUI_ACTION_START :
pass - > fbo . scale_x = pass - > fbo . scale_y = 0 ;
pass - > fbo . valid = false ;
break ;
2013-04-07 16:45:05 +02:00
2013-04-09 19:43:24 +02:00
case RGUI_ACTION_LEFT :
case RGUI_ACTION_RIGHT :
case RGUI_ACTION_OK :
{
unsigned current_scale = pass - > fbo . scale_x ;
unsigned delta = action = = RGUI_ACTION_LEFT ? 5 : 1 ;
current_scale = ( current_scale + delta ) % 6 ;
pass - > fbo . valid = current_scale ;
pass - > fbo . scale_x = pass - > fbo . scale_y = current_scale ;
break ;
}
default :
2013-04-07 16:45:05 +02:00
break ;
2013-04-09 19:43:24 +02:00
}
2013-04-07 16:45:05 +02:00
}
2013-05-08 18:17:30 +02:00
return 0 ;
}
# endif
2013-05-04 21:17:47 +02:00
static void rgui_settings_path_populate_entries ( rgui_handle_t * rgui )
{
rgui_list_clear ( rgui - > selection_buf ) ;
2013-05-05 11:17:27 +02:00
rgui_list_push ( rgui - > selection_buf , " Browser Directory " , RGUI_BROWSER_DIR_PATH , 0 ) ;
2013-09-15 16:15:38 +02:00
rgui_list_push ( rgui - > selection_buf , " Config Directory " , RGUI_CONFIG_DIR_PATH , 0 ) ;
2013-09-12 22:00:59 +02:00
# ifdef HAVE_DYNAMIC
rgui_list_push ( rgui - > selection_buf , " Core Directory " , RGUI_LIBRETRO_DIR_PATH , 0 ) ;
# endif
2013-05-04 22:29:22 +02:00
# ifdef HAVE_SHADER_MANAGER
2013-05-05 11:17:27 +02:00
rgui_list_push ( rgui - > selection_buf , " Shader Directory " , RGUI_SHADER_DIR_PATH , 0 ) ;
2013-05-04 22:29:22 +02:00
# endif
2013-05-05 11:17:27 +02:00
rgui_list_push ( rgui - > selection_buf , " Savestate Directory " , RGUI_SAVESTATE_DIR_PATH , 0 ) ;
rgui_list_push ( rgui - > selection_buf , " Savefile Directory " , RGUI_SAVEFILE_DIR_PATH , 0 ) ;
2013-05-22 22:31:16 +02:00
# ifdef HAVE_OVERLAY
rgui_list_push ( rgui - > selection_buf , " Overlay Directory " , RGUI_OVERLAY_DIR_PATH , 0 ) ;
# endif
2013-05-05 11:17:27 +02:00
rgui_list_push ( rgui - > selection_buf , " System Directory " , RGUI_SYSTEM_DIR_PATH , 0 ) ;
2013-09-16 23:30:42 +02:00
# ifdef HAVE_SCREENSHOTS
rgui_list_push ( rgui - > selection_buf , " Screenshot Directory " , RGUI_SCREENSHOT_DIR_PATH , 0 ) ;
# endif
2013-05-04 21:17:47 +02:00
}
2013-04-07 15:46:36 +02:00
2012-07-27 23:15:52 -04:00
static void rgui_settings_controller_populate_entries ( rgui_handle_t * rgui )
2012-07-16 17:57:43 -04:00
{
2013-03-11 03:56:06 +01:00
rgui_list_clear ( rgui - > selection_buf ) ;
2013-05-17 23:13:09 +02:00
# ifdef HAVE_OVERLAY
rgui_list_push ( rgui - > selection_buf , " Overlay Preset " , RGUI_SETTINGS_OVERLAY_PRESET , 0 ) ;
2013-05-17 23:26:11 +02:00
rgui_list_push ( rgui - > selection_buf , " Overlay Opacity " , RGUI_SETTINGS_OVERLAY_OPACITY , 0 ) ;
2013-05-17 23:37:48 +02:00
rgui_list_push ( rgui - > selection_buf , " Overlay Scale " , RGUI_SETTINGS_OVERLAY_SCALE , 0 ) ;
2013-05-17 23:13:09 +02:00
# endif
2013-05-04 17:01:10 +02:00
rgui_list_push ( rgui - > selection_buf , " Player " , RGUI_SETTINGS_BIND_PLAYER , 0 ) ;
2013-03-11 03:56:06 +01:00
rgui_list_push ( rgui - > selection_buf , " Device " , RGUI_SETTINGS_BIND_DEVICE , 0 ) ;
2013-04-27 12:32:03 +02:00
rgui_list_push ( rgui - > selection_buf , " Device Type " , RGUI_SETTINGS_BIND_DEVICE_TYPE , 0 ) ;
2013-04-27 00:37:20 +02:00
if ( driver . input & & driver . input - > set_keybinds )
rgui_list_push ( rgui - > selection_buf , " DPad Emulation " , RGUI_SETTINGS_BIND_DPAD_EMULATION , 0 ) ;
2013-09-29 19:37:48 +02:00
else
2013-09-29 20:40:04 +02:00
{
rgui_list_push ( rgui - > selection_buf , " Configure All (RetroPad) " , RGUI_SETTINGS_CUSTOM_BIND_ALL , 0 ) ; // This doesn't make sense on anything else than PC.
rgui_list_push ( rgui - > selection_buf , " Default All (RetroPad) " , RGUI_SETTINGS_CUSTOM_BIND_DEFAULT_ALL , 0 ) ; // This doesn't make sense on anything else than PC.
}
2013-09-29 20:44:44 +02:00
if ( rgui - > current_pad = = 0 )
rgui_list_push ( rgui - > selection_buf , " RGUI Menu Toggle " , RGUI_SETTINGS_BIND_MENU_TOGGLE , 0 ) ;
2013-09-29 20:40:04 +02:00
unsigned last = ( driver . input & & driver . input - > set_keybinds ) ? RGUI_SETTINGS_BIND_R3 : RGUI_SETTINGS_BIND_LAST ;
for ( unsigned i = RGUI_SETTINGS_BIND_BEGIN ; i < = last ; i + + )
2013-09-30 18:08:47 +02:00
rgui_list_push ( rgui - > selection_buf , input_config_bind_map [ i - RGUI_SETTINGS_BIND_BEGIN ] . desc , i , 0 ) ;
2013-09-29 17:58:46 +02:00
}
// This only makes sense for PC so far.
// Consoles use set_keybind callbacks instead.
static int rgui_custom_bind_iterate ( rgui_handle_t * rgui , rgui_action_t action )
{
( void ) action ; // Have to ignore action here. Only bind that should work here is Quit RetroArch or something like that.
render_text ( rgui ) ;
2013-09-29 19:37:48 +02:00
char msg [ 256 ] ;
2013-09-30 18:42:44 +02:00
snprintf ( msg , sizeof ( msg ) , " [%s] \n press joypad \n (RETURN to skip) " , input_config_bind_map [ rgui - > binds . begin - RGUI_SETTINGS_BIND_BEGIN ] . desc ) ;
2013-09-29 19:37:48 +02:00
render_messagebox ( rgui , msg ) ;
2013-09-29 17:58:46 +02:00
struct rgui_bind_state binds = rgui - > binds ;
menu_poll_bind_state ( & binds ) ;
if ( ( binds . skip & & ! rgui - > binds . skip ) | | menu_poll_find_trigger ( & rgui - > binds , & binds ) )
2013-09-29 19:37:48 +02:00
{
binds . begin + + ;
if ( binds . begin < = binds . last )
binds . target + + ;
else
rgui_list_pop ( rgui - > menu_stack , & rgui - > selection_ptr ) ;
2013-09-30 17:39:44 +02:00
// Avoid new binds triggering things right away.
rgui - > trigger_state = 0 ;
rgui - > old_input_state = - 1ULL ;
2013-09-29 19:37:48 +02:00
}
2013-09-29 17:58:46 +02:00
rgui - > binds = binds ;
return 0 ;
2012-07-27 23:15:52 -04:00
}
2013-02-27 20:20:29 -05:00
static int rgui_viewport_iterate ( rgui_handle_t * rgui , rgui_action_t action )
2012-08-20 21:56:07 -04:00
{
2013-04-20 10:56:04 +02:00
rarch_viewport_t * custom = & g_extern . console . screen . viewports . custom_vp ;
2013-03-10 16:40:36 +01:00
unsigned menu_type = 0 ;
2013-04-16 01:50:05 +02:00
rgui_list_get_last ( rgui - > menu_stack , NULL , & menu_type ) ;
2012-08-20 21:56:07 -04:00
2013-04-20 12:48:33 +02:00
struct retro_game_geometry * geom = & g_extern . system . av_info . geometry ;
int stride_x = g_settings . video . scale_integer ?
geom - > base_width : 1 ;
int stride_y = g_settings . video . scale_integer ?
geom - > base_height : 1 ;
2012-08-20 21:56:07 -04:00
switch ( action )
{
case RGUI_ACTION_UP :
if ( menu_type = = RGUI_SETTINGS_CUSTOM_VIEWPORT )
{
2013-04-20 12:48:33 +02:00
custom - > y - = stride_y ;
custom - > height + = stride_y ;
2012-08-20 21:56:07 -04:00
}
2013-04-20 12:48:33 +02:00
else if ( custom - > height > = ( unsigned ) stride_y )
custom - > height - = stride_y ;
2013-03-10 19:58:22 +01:00
if ( driver . video_poke - > apply_state_changes )
driver . video_poke - > apply_state_changes ( driver . video_data ) ;
2012-08-20 21:56:07 -04:00
break ;
2012-08-28 23:00:35 -04:00
2012-08-20 21:56:07 -04:00
case RGUI_ACTION_DOWN :
if ( menu_type = = RGUI_SETTINGS_CUSTOM_VIEWPORT )
{
2013-04-20 12:48:33 +02:00
custom - > y + = stride_y ;
2013-04-21 10:05:12 +02:00
if ( custom - > height > = ( unsigned ) stride_y )
2013-04-20 12:48:33 +02:00
custom - > height - = stride_y ;
2012-08-20 21:56:07 -04:00
}
else
2013-04-20 12:48:33 +02:00
custom - > height + = stride_y ;
2013-03-10 19:58:22 +01:00
if ( driver . video_poke - > apply_state_changes )
driver . video_poke - > apply_state_changes ( driver . video_data ) ;
2012-08-20 21:56:07 -04:00
break ;
2012-08-28 23:00:35 -04:00
2012-08-20 21:56:07 -04:00
case RGUI_ACTION_LEFT :
if ( menu_type = = RGUI_SETTINGS_CUSTOM_VIEWPORT )
{
2013-04-20 12:48:33 +02:00
custom - > x - = stride_x ;
custom - > width + = stride_x ;
2012-08-20 21:56:07 -04:00
}
2013-04-20 12:48:33 +02:00
else if ( custom - > width > = ( unsigned ) stride_x )
custom - > width - = stride_x ;
2013-03-10 19:58:22 +01:00
if ( driver . video_poke - > apply_state_changes )
driver . video_poke - > apply_state_changes ( driver . video_data ) ;
2012-08-20 21:56:07 -04:00
break ;
2012-08-28 23:00:35 -04:00
2012-08-20 21:56:07 -04:00
case RGUI_ACTION_RIGHT :
if ( menu_type = = RGUI_SETTINGS_CUSTOM_VIEWPORT )
{
2013-04-20 12:48:33 +02:00
custom - > x + = stride_x ;
if ( custom - > width > = ( unsigned ) stride_x )
custom - > width - = stride_x ;
2012-08-20 21:56:07 -04:00
}
else
2013-04-20 12:48:33 +02:00
custom - > width + = stride_x ;
2013-03-10 19:58:22 +01:00
if ( driver . video_poke - > apply_state_changes )
driver . video_poke - > apply_state_changes ( driver . video_data ) ;
2012-08-20 21:56:07 -04:00
break ;
2012-08-28 23:00:35 -04:00
2012-08-20 21:56:07 -04:00
case RGUI_ACTION_CANCEL :
2013-04-16 01:50:05 +02:00
rgui_list_pop ( rgui - > menu_stack , & rgui - > selection_ptr ) ;
2012-08-20 21:56:07 -04:00
if ( menu_type = = RGUI_SETTINGS_CUSTOM_VIEWPORT_2 )
2013-04-20 12:48:33 +02:00
{
rgui_list_push ( rgui - > menu_stack , " " ,
RGUI_SETTINGS_CUSTOM_VIEWPORT ,
2013-04-20 10:56:04 +02:00
rgui - > selection_ptr ) ;
2013-04-20 12:48:33 +02:00
}
2012-08-20 21:56:07 -04:00
break ;
2012-08-28 23:00:35 -04:00
2012-08-20 21:56:07 -04:00
case RGUI_ACTION_OK :
2013-04-16 01:50:05 +02:00
rgui_list_pop ( rgui - > menu_stack , & rgui - > selection_ptr ) ;
2013-04-20 12:48:33 +02:00
if ( menu_type = = RGUI_SETTINGS_CUSTOM_VIEWPORT
& & ! g_settings . video . scale_integer )
{
rgui_list_push ( rgui - > menu_stack , " " ,
RGUI_SETTINGS_CUSTOM_VIEWPORT_2 ,
2013-04-20 10:56:04 +02:00
rgui - > selection_ptr ) ;
2013-04-20 12:48:33 +02:00
}
2012-08-20 21:56:07 -04:00
break ;
2012-08-28 23:00:35 -04:00
2012-08-20 22:50:15 -04:00
case RGUI_ACTION_START :
2013-04-20 12:48:33 +02:00
if ( ! g_settings . video . scale_integer )
2012-08-20 22:50:15 -04:00
{
2013-04-20 12:48:33 +02:00
rarch_viewport_t vp ;
driver . video - > viewport_info ( driver . video_data , & vp ) ;
if ( menu_type = = RGUI_SETTINGS_CUSTOM_VIEWPORT )
{
custom - > width + = custom - > x ;
custom - > height + = custom - > y ;
custom - > x = 0 ;
custom - > y = 0 ;
}
else
{
custom - > width = vp . full_width - custom - > x ;
custom - > height = vp . full_height - custom - > y ;
}
if ( driver . video_poke - > apply_state_changes )
driver . video_poke - > apply_state_changes ( driver . video_data ) ;
2012-08-20 22:50:15 -04:00
}
break ;
2012-08-28 23:00:35 -04:00
2013-01-14 03:55:01 +01:00
case RGUI_ACTION_MESSAGE :
rgui - > msg_force = true ;
break ;
2012-08-20 21:56:07 -04:00
default :
break ;
}
2013-04-16 01:50:05 +02:00
rgui_list_get_last ( rgui - > menu_stack , NULL , & menu_type ) ;
2012-08-20 21:56:07 -04:00
render_text ( rgui ) ;
2013-04-20 10:56:04 +02:00
const char * base_msg = NULL ;
char msg [ 64 ] ;
2013-04-20 12:48:33 +02:00
if ( g_settings . video . scale_integer )
{
custom - > x = 0 ;
custom - > y = 0 ;
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 ;
base_msg = " Set scale " ;
snprintf ( msg , sizeof ( msg ) , " %s (%4ux%4u, %u x %u scale) " ,
base_msg ,
custom - > width , custom - > height ,
custom - > width / geom - > base_width ,
custom - > height / geom - > base_height ) ;
}
else
{
if ( menu_type = = RGUI_SETTINGS_CUSTOM_VIEWPORT )
base_msg = " Set Upper-Left Corner " ;
else if ( menu_type = = RGUI_SETTINGS_CUSTOM_VIEWPORT_2 )
base_msg = " Set Bottom-Right Corner " ;
snprintf ( msg , sizeof ( msg ) , " %s (%d, %d : %4ux%4u) " ,
base_msg , custom - > x , custom - > y , custom - > width , custom - > height ) ;
}
2013-04-20 10:56:04 +02:00
render_messagebox ( rgui , msg ) ;
2013-01-11 04:36:40 +01:00
2013-04-20 12:48:33 +02: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 ;
if ( driver . video_poke - > apply_state_changes )
driver . video_poke - > apply_state_changes ( driver . video_data ) ;
2013-01-11 04:36:40 +01:00
return 0 ;
2012-08-20 21:56:07 -04:00
}
2013-02-27 20:20:29 -05:00
static int rgui_settings_iterate ( rgui_handle_t * rgui , rgui_action_t action )
2012-07-27 23:15:52 -04:00
{
2012-09-11 23:33:44 -04:00
rgui - > frame_buf_pitch = RGUI_WIDTH * 2 ;
2013-03-10 16:40:36 +01:00
unsigned type = 0 ;
2013-03-17 21:18:56 +01:00
const char * label = NULL ;
2013-02-27 20:20:29 -05:00
if ( action ! = RGUI_ACTION_REFRESH )
2013-04-16 01:50:05 +02:00
rgui_list_get_at_offset ( rgui - > selection_buf , rgui - > selection_ptr , & label , & type ) ;
2013-03-17 21:18:56 +01:00
if ( type = = RGUI_SETTINGS_CORE )
2013-04-27 15:14:59 +02:00
{
# if defined(HAVE_DYNAMIC)
2013-03-17 21:18:56 +01:00
label = rgui - > libretro_dir ;
# elif defined(HAVE_LIBRETRO_MANAGEMENT)
2012-08-21 00:28:38 -04:00
label = default_paths . core_dir ;
2013-04-27 15:14:59 +02:00
# else
label = " " ; // Shouldn't happen ...
2013-02-14 21:24:54 +01:00
# endif
2013-04-27 15:14:59 +02:00
}
2013-09-15 15:36:45 +02:00
else if ( type = = RGUI_SETTINGS_CONFIG )
2013-09-15 16:03:43 +02:00
label = g_settings . rgui_config_directory ;
2013-04-27 15:14:59 +02:00
else if ( type = = RGUI_SETTINGS_DISK_APPEND )
label = rgui - > base_path ;
2013-03-17 21:18:56 +01:00
const char * dir = NULL ;
2013-03-10 16:40:36 +01:00
unsigned menu_type = 0 ;
2013-04-16 01:50:05 +02:00
rgui_list_get_last ( rgui - > menu_stack , & dir , & menu_type ) ;
2012-07-31 21:19:46 -04:00
if ( rgui - > need_refresh )
action = RGUI_ACTION_NOOP ;
2012-07-16 17:57:43 -04:00
switch ( action )
{
case RGUI_ACTION_UP :
2013-03-11 03:53:28 +01:00
if ( rgui - > selection_ptr > 0 )
rgui - > selection_ptr - - ;
2012-07-16 17:57:43 -04:00
else
2013-03-11 03:56:06 +01:00
rgui - > selection_ptr = rgui - > selection_buf - > size - 1 ;
2012-07-16 17:57:43 -04:00
break ;
case RGUI_ACTION_DOWN :
2013-03-11 03:56:06 +01:00
if ( rgui - > selection_ptr + 1 < rgui - > selection_buf - > size )
2013-03-11 03:53:28 +01:00
rgui - > selection_ptr + + ;
2012-07-16 17:57:43 -04:00
else
2013-03-11 03:53:28 +01:00
rgui - > selection_ptr = 0 ;
2012-07-16 17:57:43 -04:00
break ;
2013-04-21 01:25:56 +02:00
case RGUI_ACTION_CANCEL :
if ( rgui - > menu_stack - > size > 1 )
{
rgui_list_pop ( rgui - > menu_stack , & rgui - > selection_ptr ) ;
rgui - > need_refresh = true ;
}
break ;
2012-07-18 20:38:09 -04:00
case RGUI_ACTION_LEFT :
2012-07-16 17:57:43 -04:00
case RGUI_ACTION_RIGHT :
case RGUI_ACTION_OK :
2012-07-18 20:38:09 -04:00
case RGUI_ACTION_START :
2013-04-07 23:39:52 +02:00
if ( type = = RGUI_SETTINGS_OPEN_FILEBROWSER & & action = = RGUI_ACTION_OK )
{
rgui_list_push ( rgui - > menu_stack , rgui - > base_path , RGUI_FILE_DIRECTORY , rgui - > selection_ptr ) ;
2013-04-14 16:28:40 +02:00
rgui - > selection_ptr = 0 ;
2013-04-07 23:39:52 +02:00
rgui - > need_refresh = true ;
}
2013-05-20 22:17:26 -04:00
else if ( ( type = = RGUI_SETTINGS_OPEN_HISTORY | | menu_type_is_directory_browser ( type ) ) & & action = = RGUI_ACTION_OK )
2013-04-28 01:35:31 +02:00
{
2013-05-20 22:17:26 -04:00
rgui_list_push ( rgui - > menu_stack , " " , type , rgui - > selection_ptr ) ;
2013-04-28 01:35:31 +02:00
rgui - > selection_ptr = 0 ;
rgui - > need_refresh = true ;
}
2013-09-15 15:36:45 +02:00
else if ( ( menu_type_is_settings ( type ) | | type = = RGUI_SETTINGS_CORE | | type = = RGUI_SETTINGS_CONFIG | | type = = RGUI_SETTINGS_DISK_APPEND ) & & action = = RGUI_ACTION_OK )
2012-07-27 23:15:52 -04:00
{
2013-03-11 03:56:06 +01:00
rgui_list_push ( rgui - > menu_stack , label , type , rgui - > selection_ptr ) ;
2013-03-11 03:53:28 +01:00
rgui - > selection_ptr = 0 ;
2012-07-27 23:15:52 -04:00
rgui - > need_refresh = true ;
}
2012-08-20 21:56:07 -04:00
else if ( type = = RGUI_SETTINGS_CUSTOM_VIEWPORT & & action = = RGUI_ACTION_OK )
{
2013-03-11 03:56:06 +01:00
rgui_list_push ( rgui - > menu_stack , " " , type , rgui - > selection_ptr ) ;
2013-03-10 02:42:16 +01:00
2013-04-20 10:56:04 +02:00
// Start with something sane.
rarch_viewport_t * custom = & g_extern . console . screen . viewports . custom_vp ;
driver . video - > viewport_info ( driver . video_data , custom ) ;
2013-04-20 12:48:33 +02:00
aspectratio_lut [ ASPECT_RATIO_CUSTOM ] . value =
( float ) custom - > width / custom - > height ;
2013-04-20 10:56:04 +02:00
g_settings . video . aspect_ratio_idx = ASPECT_RATIO_CUSTOM ;
2013-03-10 02:42:16 +01:00
if ( driver . video_poke - > set_aspect_ratio )
2013-04-20 10:56:04 +02:00
driver . video_poke - > set_aspect_ratio ( driver . video_data ,
g_settings . video . aspect_ratio_idx ) ;
2012-08-20 21:56:07 -04:00
}
2012-07-27 23:15:52 -04:00
else
2013-01-11 04:36:40 +01:00
{
2013-04-07 16:45:05 +02:00
int ret = rgui_settings_toggle_setting ( rgui , type , action , menu_type ) ;
2013-04-20 10:56:04 +02:00
if ( ret )
2013-01-11 04:36:40 +01:00
return ret ;
}
2012-07-16 17:57:43 -04:00
break ;
case RGUI_ACTION_REFRESH :
2013-03-11 03:53:28 +01:00
rgui - > selection_ptr = 0 ;
2012-07-27 23:15:52 -04:00
rgui - > need_refresh = true ;
2012-07-16 17:57:43 -04:00
break ;
2013-01-14 03:55:01 +01:00
case RGUI_ACTION_MESSAGE :
rgui - > msg_force = true ;
break ;
2012-07-16 17:57:43 -04:00
default :
break ;
}
2013-04-16 01:50:05 +02:00
rgui_list_get_last ( rgui - > menu_stack , & dir , & menu_type ) ;
2012-07-31 21:19:46 -04:00
2013-04-28 01:04:34 +02:00
if ( rgui - > need_refresh & & ! ( menu_type = = RGUI_FILE_DIRECTORY | |
# ifdef HAVE_SHADER_MANAGER
menu_type_is_shader_browser ( menu_type ) | |
2013-05-17 23:13:09 +02:00
# endif
2013-05-20 22:17:26 -04:00
menu_type_is_directory_browser ( menu_type ) | |
2013-05-17 23:13:09 +02:00
# ifdef HAVE_OVERLAY
menu_type = = RGUI_SETTINGS_OVERLAY_PRESET | |
2013-04-28 01:04:34 +02:00
# endif
2013-09-15 15:36:45 +02:00
menu_type = = RGUI_SETTINGS_CORE | |
menu_type = = RGUI_SETTINGS_CONFIG | |
menu_type = = RGUI_SETTINGS_DISK_APPEND | |
2013-04-28 01:35:31 +02:00
menu_type = = RGUI_SETTINGS_OPEN_HISTORY ) )
2012-07-27 23:15:52 -04:00
{
2012-07-31 21:19:46 -04:00
rgui - > need_refresh = false ;
2013-07-02 15:23:20 +02:00
if ( menu_type = = RGUI_SETTINGS_INPUT_OPTIONS )
2012-07-27 23:15:52 -04:00
rgui_settings_controller_populate_entries ( rgui ) ;
2013-07-02 15:23:20 +02:00
else if ( menu_type = = RGUI_SETTINGS_PATH_OPTIONS )
2013-05-04 21:17:47 +02:00
rgui_settings_path_populate_entries ( rgui ) ;
2013-07-02 15:23:20 +02:00
else if ( menu_type = = RGUI_SETTINGS_OPTIONS )
2013-05-05 22:02:30 +02:00
rgui_settings_options_populate_entries ( rgui ) ;
2013-04-04 21:47:37 +02:00
else if ( menu_type = = RGUI_SETTINGS_CORE_OPTIONS )
rgui_settings_core_options_populate_entries ( rgui ) ;
2013-05-04 19:00:57 +02:00
else if ( menu_type = = RGUI_SETTINGS_AUDIO_OPTIONS )
rgui_settings_audio_options_populate_entries ( rgui ) ;
2013-05-04 19:26:34 +02:00
else if ( menu_type = = RGUI_SETTINGS_DISK_OPTIONS )
rgui_settings_disc_options_populate_entries ( rgui ) ;
2013-04-28 00:32:25 +02:00
else if ( menu_type = = RGUI_SETTINGS_VIDEO_OPTIONS )
2013-05-04 23:35:39 +02:00
rgui_settings_video_options_populate_entries ( rgui ) ;
# ifdef HAVE_SHADER_MANAGER
else if ( menu_type = = RGUI_SETTINGS_SHADER_OPTIONS )
2013-04-07 15:46:36 +02:00
rgui_settings_shader_manager_populate_entries ( rgui ) ;
2013-05-04 23:35:39 +02:00
# endif
2012-07-27 23:15:52 -04:00
else
rgui_settings_populate_entries ( rgui ) ;
}
2013-04-20 18:06:08 +02:00
render_text ( rgui ) ;
2012-07-16 17:57:43 -04:00
2013-01-11 04:36:40 +01:00
return 0 ;
2012-07-16 17:57:43 -04:00
}
2013-04-28 01:35:31 +02:00
static void history_parse ( rgui_handle_t * rgui )
{
size_t history_size = rom_history_size ( rgui - > history ) ;
for ( size_t i = 0 ; i < history_size ; i + + )
{
const char * path = NULL ;
const char * core_path = NULL ;
const char * core_name = NULL ;
rom_history_get_index ( rgui - > history , i ,
& path , & core_path , & core_name ) ;
char fill_buf [ PATH_MAX ] ;
2013-05-02 14:42:58 +02:00
if ( path )
{
char path_short [ PATH_MAX ] ;
fill_pathname ( path_short , path_basename ( path ) , " " , sizeof ( path_short ) ) ;
snprintf ( fill_buf , sizeof ( fill_buf ) , " %s (%s) " ,
path_short , core_name ) ;
}
else
strlcpy ( fill_buf , core_name , sizeof ( fill_buf ) ) ;
2013-04-28 01:35:31 +02:00
rgui_list_push ( rgui - > selection_buf , fill_buf , RGUI_FILE_PLAIN , 0 ) ;
}
}
2013-09-27 21:05:51 +02:00
static bool rgui_directory_parse ( rgui_handle_t * rgui , const char * directory , unsigned menu_type , void * ctx )
2013-03-11 04:21:40 +01:00
{
if ( ! * directory )
{
# if defined(GEKKO)
# ifdef HW_RVL
2013-04-21 16:30:26 +02:00
rgui_list_push ( ctx , " sd:/ " , menu_type , 0 ) ;
rgui_list_push ( ctx , " usb:/ " , menu_type , 0 ) ;
2013-03-11 04:21:40 +01:00
# endif
2013-04-28 18:37:55 +02:00
# if !(defined(HAVE_MINIOGC) && defined(HW_RVL))
2013-04-21 16:30:26 +02:00
rgui_list_push ( ctx , " carda:/ " , menu_type , 0 ) ;
rgui_list_push ( ctx , " cardb:/ " , menu_type , 0 ) ;
2013-04-28 18:37:55 +02:00
# endif
2013-03-11 04:21:40 +01:00
# elif defined(_XBOX1)
2013-04-21 16:30:26 +02:00
rgui_list_push ( ctx , " C: \\ " , menu_type , 0 ) ;
rgui_list_push ( ctx , " D: \\ " , menu_type , 0 ) ;
rgui_list_push ( ctx , " E: \\ " , menu_type , 0 ) ;
rgui_list_push ( ctx , " F: \\ " , menu_type , 0 ) ;
rgui_list_push ( ctx , " G: \\ " , menu_type , 0 ) ;
2013-04-04 20:21:51 +02:00
# elif defined(_WIN32)
unsigned drives = GetLogicalDrives ( ) ;
char drive [ ] = " : \\ " ;
for ( unsigned i = 0 ; i < 32 ; i + + )
{
drive [ 0 ] = ' A ' + i ;
if ( drives & ( 1 < < i ) )
2013-04-21 16:30:26 +02:00
rgui_list_push ( ctx , drive , menu_type , 0 ) ;
2013-04-04 20:21:51 +02:00
}
2013-03-11 04:21:40 +01:00
# elif defined(__CELLOS_LV2__)
2013-04-21 16:30:26 +02:00
rgui_list_push ( ctx , " app_home:/ " , menu_type , 0 ) ;
rgui_list_push ( ctx , " dev_hdd0:/ " , menu_type , 0 ) ;
rgui_list_push ( ctx , " dev_hdd1:/ " , menu_type , 0 ) ;
rgui_list_push ( ctx , " host_root:/ " , menu_type , 0 ) ;
# else
rgui_list_push ( ctx , " / " , menu_type , 0 ) ;
2013-03-11 04:21:40 +01:00
# endif
2013-04-21 16:30:26 +02:00
return true ;
2013-03-11 04:21:40 +01:00
}
# if defined(GEKKO) && defined(HW_RVL)
LWP_MutexLock ( gx_device_mutex ) ;
int dev = gx_get_device_from_path ( directory ) ;
if ( dev ! = - 1 & & ! gx_devices [ dev ] . mounted & & gx_devices [ dev ] . interface - > isInserted ( ) )
fatMountSimple ( gx_devices [ dev ] . name , gx_devices [ dev ] . interface ) ;
LWP_MutexUnlock ( gx_device_mutex ) ;
# endif
2013-03-17 21:18:56 +01:00
const char * exts ;
2013-04-30 23:36:29 +02:00
char ext_buf [ 1024 ] ;
2013-04-21 16:30:26 +02:00
if ( menu_type = = RGUI_SETTINGS_CORE )
2013-03-17 21:18:56 +01:00
exts = EXT_EXECUTABLES ;
2013-09-15 15:36:45 +02:00
else if ( menu_type = = RGUI_SETTINGS_CONFIG )
exts = " cfg " ;
2013-04-28 01:04:34 +02:00
# ifdef HAVE_SHADER_MANAGER
2013-04-14 01:27:13 +02:00
else if ( menu_type = = RGUI_SETTINGS_SHADER_PRESET )
exts = " cgp|glslp " ;
2013-04-09 21:01:12 +02:00
else if ( menu_type_is_shader_browser ( menu_type ) )
2013-04-11 16:01:42 +02:00
exts = " cg|glsl " ;
2013-05-17 23:13:09 +02:00
# endif
# ifdef HAVE_OVERLAY
else if ( menu_type = = RGUI_SETTINGS_OVERLAY_PRESET )
exts = " cfg " ;
2013-04-28 01:04:34 +02:00
# endif
2013-05-20 22:17:26 -04:00
else if ( menu_type_is_directory_browser ( menu_type ) )
exts = " " ; // we ignore files anyway
2013-03-17 21:18:56 +01:00
else if ( rgui - > info . valid_extensions )
2013-04-30 23:36:29 +02:00
{
exts = ext_buf ;
if ( * rgui - > info . valid_extensions )
2013-04-30 23:58:32 +02:00
snprintf ( ext_buf , sizeof ( ext_buf ) , " %s|zip " , rgui - > info . valid_extensions ) ;
2013-04-30 23:36:29 +02:00
else
* ext_buf = ' \0 ' ;
}
2013-03-17 21:18:56 +01:00
else
exts = g_extern . system . valid_extensions ;
2013-04-21 16:30:26 +02:00
struct string_list * list = dir_list_new ( directory , exts , true ) ;
2013-03-11 04:21:40 +01:00
if ( ! list )
return false ;
2013-03-11 05:22:05 +01:00
dir_list_sort ( list , true ) ;
2013-05-20 22:17:26 -04:00
if ( menu_type_is_directory_browser ( menu_type ) )
rgui_list_push ( ctx , " <Use this directory> " , RGUI_FILE_USE_DIRECTORY , 0 ) ;
2013-03-11 04:21:40 +01:00
for ( size_t i = 0 ; i < list - > size ; i + + )
{
bool is_dir = list - > elems [ i ] . attr . b ;
2013-04-21 16:30:26 +02:00
2013-05-20 22:17:26 -04:00
if ( menu_type_is_directory_browser ( menu_type ) & & ! is_dir )
continue ;
2013-03-11 04:21:40 +01:00
# ifdef HAVE_LIBRETRO_MANAGEMENT
2013-04-21 16:30:26 +02:00
if ( menu_type = = RGUI_SETTINGS_CORE & & ( is_dir | | strcasecmp ( list - > elems [ i ] . data , SALAMANDER_FILE ) = = 0 ) )
2013-03-11 04:57:17 +01:00
continue ;
2013-04-21 16:30:26 +02:00
# endif
2013-03-11 04:21:40 +01:00
2013-03-16 11:16:55 +01:00
// Need to preserve slash first time.
const char * path = list - > elems [ i ] . data ;
if ( * directory )
path = path_basename ( path ) ;
2013-04-12 09:08:07 +02:00
// Push menu_type further down in the chain.
// Needed for shader manager currently.
2013-03-16 11:16:55 +01:00
rgui_list_push ( ctx , path ,
2013-04-12 09:08:07 +02:00
is_dir ? menu_type : RGUI_FILE_PLAIN , 0 ) ;
2013-03-11 04:21:40 +01:00
}
string_list_free ( list ) ;
return true ;
}
2013-09-26 22:34:06 +02:00
static int rgui_iterate ( void * data , unsigned action )
2012-05-06 04:04:33 +02:00
{
2013-09-19 14:49:07 +02:00
rgui_handle_t * rgui = ( rgui_handle_t * ) data ;
2013-04-18 23:00:27 +02:00
2012-07-31 21:19:46 -04:00
const char * dir = 0 ;
2013-03-10 16:40:36 +01:00
unsigned menu_type = 0 ;
2013-04-16 01:50:05 +02:00
rgui_list_get_last ( rgui - > menu_stack , & dir , & menu_type ) ;
2013-01-13 15:26:12 -05:00
int ret = 0 ;
2012-07-27 23:15:52 -04:00
2013-04-18 23:00:27 +02:00
if ( driver . video_poke & & driver . video_poke - > set_texture_enable )
driver . video_poke - > set_texture_frame ( driver . video_data , menu_framebuf ,
false , RGUI_WIDTH , RGUI_HEIGHT , 1.0f ) ;
2013-04-07 15:46:36 +02:00
if ( menu_type_is_settings ( menu_type ) )
2012-07-27 23:15:52 -04:00
return rgui_settings_iterate ( rgui , action ) ;
2013-03-18 02:01:14 +01:00
else if ( menu_type = = RGUI_SETTINGS_CUSTOM_VIEWPORT | | menu_type = = RGUI_SETTINGS_CUSTOM_VIEWPORT_2 )
2012-08-20 21:56:07 -04:00
return rgui_viewport_iterate ( rgui , action ) ;
2013-09-29 17:58:46 +02:00
else if ( menu_type = = RGUI_SETTINGS_CUSTOM_BIND )
return rgui_custom_bind_iterate ( rgui , action ) ;
2013-09-27 20:32:29 +02:00
2012-08-28 23:00:35 -04:00
if ( rgui - > need_refresh & & action ! = RGUI_ACTION_MESSAGE )
2012-07-31 21:19:46 -04:00
action = RGUI_ACTION_NOOP ;
2012-05-06 04:04:33 +02:00
switch ( action )
{
case RGUI_ACTION_UP :
2013-03-11 03:53:28 +01:00
if ( rgui - > selection_ptr > 0 )
rgui - > selection_ptr - - ;
2012-06-27 00:43:25 -04:00
else
2013-03-11 03:56:06 +01:00
rgui - > selection_ptr = rgui - > selection_buf - > size - 1 ;
2012-05-06 04:04:33 +02:00
break ;
case RGUI_ACTION_DOWN :
2013-03-11 03:56:06 +01:00
if ( rgui - > selection_ptr + 1 < rgui - > selection_buf - > size )
2013-03-11 03:53:28 +01:00
rgui - > selection_ptr + + ;
2012-06-27 00:43:25 -04:00
else
2013-03-11 03:53:28 +01:00
rgui - > selection_ptr = 0 ;
2012-05-06 04:04:33 +02:00
break ;
case RGUI_ACTION_LEFT :
2013-04-04 22:27:16 +02:00
if ( rgui - > selection_ptr > 8 )
2013-03-11 03:53:28 +01:00
rgui - > selection_ptr - = 8 ;
2012-07-18 20:38:09 -04:00
else
2013-03-11 03:53:28 +01:00
rgui - > selection_ptr = 0 ;
2012-07-18 20:38:09 -04:00
break ;
case RGUI_ACTION_RIGHT :
2013-03-11 03:56:06 +01:00
if ( rgui - > selection_ptr + 8 < rgui - > selection_buf - > size )
2013-03-11 03:53:28 +01:00
rgui - > selection_ptr + = 8 ;
2012-07-18 20:38:09 -04:00
else
2013-03-11 03:56:06 +01:00
rgui - > selection_ptr = rgui - > selection_buf - > size - 1 ;
2012-07-18 20:38:09 -04:00
break ;
2013-09-26 15:49:17 +02:00
case RGUI_ACTION_SCROLL_UP :
if ( rgui - > selection_ptr > 16 )
rgui - > selection_ptr - = 16 ;
else
rgui - > selection_ptr = 0 ;
break ;
case RGUI_ACTION_SCROLL_DOWN :
if ( rgui - > selection_ptr + 16 < rgui - > selection_buf - > size )
rgui - > selection_ptr + = 16 ;
else
rgui - > selection_ptr = rgui - > selection_buf - > size - 1 ;
break ;
2012-07-18 20:38:09 -04:00
2012-05-06 04:04:33 +02:00
case RGUI_ACTION_CANCEL :
2013-03-11 03:56:06 +01:00
if ( rgui - > menu_stack - > size > 1 )
2012-05-06 04:04:33 +02:00
{
rgui - > need_refresh = true ;
2013-04-16 01:50:05 +02:00
rgui_list_pop ( rgui - > menu_stack , & rgui - > selection_ptr ) ;
2012-05-06 04:04:33 +02:00
}
break ;
case RGUI_ACTION_OK :
{
2013-03-11 03:56:06 +01:00
if ( rgui - > selection_buf - > size = = 0 )
2013-01-11 04:36:40 +01:00
return 0 ;
2012-05-06 04:04:33 +02:00
2012-07-28 15:36:03 -04:00
const char * path = 0 ;
2013-03-10 16:40:36 +01:00
unsigned type = 0 ;
2013-04-16 01:50:05 +02:00
rgui_list_get_at_offset ( rgui - > selection_buf , rgui - > selection_ptr , & path , & type ) ;
2012-05-06 04:04:33 +02:00
2013-04-28 01:04:34 +02:00
if (
# ifdef HAVE_SHADER_MANAGER
menu_type_is_shader_browser ( type ) | |
2013-05-17 23:13:09 +02:00
# endif
2013-05-20 22:17:26 -04:00
menu_type_is_directory_browser ( type ) | |
2013-05-17 23:13:09 +02:00
# ifdef HAVE_OVERLAY
type = = RGUI_SETTINGS_OVERLAY_PRESET | |
2013-04-28 01:04:34 +02:00
# endif
2013-04-21 16:30:26 +02:00
type = = RGUI_SETTINGS_CORE | |
2013-09-15 15:36:45 +02:00
type = = RGUI_SETTINGS_CONFIG | |
2013-04-27 15:14:59 +02:00
type = = RGUI_SETTINGS_DISK_APPEND | |
2013-04-21 16:30:26 +02:00
type = = RGUI_FILE_DIRECTORY )
2012-05-06 04:04:33 +02:00
{
char cat_path [ PATH_MAX ] ;
2013-03-11 06:23:14 +01:00
fill_pathname_join ( cat_path , dir , path , sizeof ( cat_path ) ) ;
2012-05-06 04:04:33 +02:00
2013-04-09 21:01:12 +02:00
rgui_list_push ( rgui - > menu_stack , cat_path , type , rgui - > selection_ptr ) ;
2013-03-11 06:05:01 +01:00
rgui - > selection_ptr = 0 ;
2012-06-30 03:08:05 -04:00
rgui - > need_refresh = true ;
}
2012-05-06 04:04:33 +02:00
else
{
2013-04-09 21:01:12 +02:00
# ifdef HAVE_SHADER_MANAGER
if ( menu_type_is_shader_browser ( menu_type ) )
{
2013-04-14 01:27:13 +02:00
if ( menu_type = = RGUI_SETTINGS_SHADER_PRESET )
{
char shader_path [ PATH_MAX ] ;
fill_pathname_join ( shader_path , dir , path , sizeof ( shader_path ) ) ;
2013-05-06 16:41:31 +02:00
shader_manager_set_preset ( & rgui - > shader , gfx_shader_parse_type ( shader_path , RARCH_SHADER_NONE ) ,
2013-04-14 01:27:13 +02:00
shader_path ) ;
}
else
{
unsigned pass = ( menu_type - RGUI_SETTINGS_SHADER_0 ) / 3 ;
fill_pathname_join ( rgui - > shader . pass [ pass ] . source . cg ,
dir , path , sizeof ( rgui - > shader . pass [ pass ] . source . cg ) ) ;
}
2013-04-09 21:23:34 +02:00
// Pop stack until we hit shader manager again.
2013-05-17 23:57:06 +02:00
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS_SHADER_OPTIONS ) ;
2013-04-09 21:01:12 +02:00
}
else
# endif
2012-07-31 21:19:46 -04:00
if ( menu_type = = RGUI_SETTINGS_CORE )
{
2013-03-11 05:34:25 +01:00
# if defined(HAVE_DYNAMIC)
2013-04-21 16:30:26 +02:00
fill_pathname_join ( g_settings . libretro , dir , path , sizeof ( g_settings . libretro ) ) ;
2013-03-17 21:18:56 +01:00
libretro_free_system_info ( & rgui - > info ) ;
2013-05-02 14:42:58 +02:00
libretro_get_system_info ( g_settings . libretro , & rgui - > info ,
& rgui - > load_no_rom ) ;
// No ROM needed for this core, load game immediately.
if ( rgui - > load_no_rom )
{
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_LOAD_GAME ) ;
* g_extern . fullpath = ' \0 ' ;
rgui - > msg_force = true ;
ret = - 1 ;
}
2013-03-17 21:18:56 +01:00
// Core selection on non-console just updates directory listing.
// Will take affect on new ROM load.
2013-05-22 00:29:48 +02:00
# elif defined(GEKKO) && defined(HW_RVL)
2013-08-25 11:07:06 +02:00
rarch_environment_cb ( RETRO_ENVIRONMENT_SET_LIBRETRO_PATH , ( void * ) path ) ;
2013-08-24 22:35:54 +02:00
2013-03-17 21:18:56 +01:00
fill_pathname_join ( g_extern . fullpath , default_paths . core_dir ,
SALAMANDER_FILE , sizeof ( g_extern . fullpath ) ) ;
2013-02-02 07:01:55 +01:00
g_extern . lifecycle_mode_state & = ~ ( 1ULL < < MODE_GAME ) ;
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_EXITSPAWN ) ;
2013-03-17 21:18:56 +01:00
ret = - 1 ;
2013-03-11 05:34:25 +01:00
# endif
2013-04-21 16:30:26 +02:00
2013-09-28 18:34:37 +02:00
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS ) ;
2012-07-31 21:19:46 -04:00
}
2013-09-15 15:36:45 +02:00
else if ( menu_type = = RGUI_SETTINGS_CONFIG )
{
char config [ PATH_MAX ] ;
fill_pathname_join ( config , dir , path , sizeof ( config ) ) ;
2013-09-28 18:34:37 +02:00
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS ) ;
2013-09-15 15:36:45 +02:00
rgui - > msg_force = true ;
if ( menu_replace_config ( config ) )
2013-09-17 21:11:30 +02:00
{
rgui - > selection_ptr = 0 ; // Menu can shrink.
2013-09-15 15:36:45 +02:00
ret = - 1 ;
2013-09-17 21:11:30 +02:00
}
2013-09-15 15:36:45 +02:00
}
2013-05-17 23:13:09 +02:00
# ifdef HAVE_OVERLAY
else if ( menu_type = = RGUI_SETTINGS_OVERLAY_PRESET )
{
fill_pathname_join ( g_settings . input . overlay , dir , path , sizeof ( g_settings . input . overlay ) ) ;
2013-05-17 23:57:06 +02:00
if ( driver . overlay )
input_overlay_free ( driver . overlay ) ;
2013-05-17 23:13:09 +02:00
driver . overlay = input_overlay_new ( g_settings . input . overlay ) ;
if ( ! driver . overlay )
RARCH_ERR ( " Failed to load overlay. \n " ) ;
2013-05-17 23:57:06 +02:00
2013-05-22 22:31:16 +02:00
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS_INPUT_OPTIONS ) ;
2013-05-17 23:13:09 +02:00
}
# endif
2013-04-27 15:14:59 +02:00
else if ( menu_type = = RGUI_SETTINGS_DISK_APPEND )
{
char image [ PATH_MAX ] ;
fill_pathname_join ( image , dir , path , sizeof ( image ) ) ;
rarch_disk_control_append_image ( image ) ;
g_extern . lifecycle_mode_state | = 1ULL < < MODE_GAME ;
2013-04-27 16:48:00 +02:00
2013-09-28 18:34:37 +02:00
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS ) ;
2013-04-27 15:14:59 +02:00
ret = - 1 ;
}
2013-04-28 01:35:31 +02:00
else if ( menu_type = = RGUI_SETTINGS_OPEN_HISTORY )
{
2013-04-29 03:10:26 +02:00
load_menu_game_history ( rgui - > selection_ptr ) ;
2013-09-28 18:34:37 +02:00
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS ) ;
2013-04-28 01:35:31 +02:00
ret = - 1 ;
}
2013-05-20 22:17:26 -04:00
else if ( menu_type = = RGUI_BROWSER_DIR_PATH )
{
strlcpy ( g_settings . rgui_browser_directory , dir , sizeof ( g_settings . rgui_browser_directory ) ) ;
strlcpy ( rgui - > base_path , dir , sizeof ( rgui - > base_path ) ) ;
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS_PATH_OPTIONS ) ;
}
2013-09-16 23:30:42 +02:00
# ifdef HAVE_SCREENSHOTS
else if ( menu_type = = RGUI_SCREENSHOT_DIR_PATH )
{
strlcpy ( g_settings . screenshot_directory , dir , sizeof ( g_settings . screenshot_directory ) ) ;
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS_PATH_OPTIONS ) ;
}
# endif
2013-05-20 22:17:26 -04:00
else if ( menu_type = = RGUI_SAVEFILE_DIR_PATH )
{
strlcpy ( g_extern . savefile_dir , dir , sizeof ( g_extern . savefile_dir ) ) ;
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS_PATH_OPTIONS ) ;
}
2013-05-22 22:31:16 +02:00
# ifdef HAVE_OVERLAY
else if ( menu_type = = RGUI_OVERLAY_DIR_PATH )
{
strlcpy ( g_extern . overlay_dir , dir , sizeof ( g_extern . overlay_dir ) ) ;
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS_PATH_OPTIONS ) ;
}
# endif
2013-05-20 22:17:26 -04:00
else if ( menu_type = = RGUI_SAVESTATE_DIR_PATH )
{
strlcpy ( g_extern . savestate_dir , dir , sizeof ( g_extern . savestate_dir ) ) ;
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS_PATH_OPTIONS ) ;
}
2013-09-15 17:09:23 -04:00
# ifdef HAVE_DYNAMIC
2013-09-12 22:00:59 +02:00
else if ( menu_type = = RGUI_LIBRETRO_DIR_PATH )
{
2013-09-15 16:15:38 +02:00
strlcpy ( rgui - > libretro_dir , dir , sizeof ( rgui - > libretro_dir ) ) ;
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS_PATH_OPTIONS ) ;
}
else if ( menu_type = = RGUI_CONFIG_DIR_PATH )
{
strlcpy ( g_settings . rgui_config_directory , dir , sizeof ( g_settings . rgui_config_directory ) ) ;
2013-09-12 22:00:59 +02:00
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS_PATH_OPTIONS ) ;
}
2013-09-15 17:09:23 -04:00
# endif
2013-05-20 22:17:26 -04:00
else if ( menu_type = = RGUI_SHADER_DIR_PATH )
{
strlcpy ( g_settings . video . shader_dir , dir , sizeof ( g_settings . video . shader_dir ) ) ;
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS_PATH_OPTIONS ) ;
}
else if ( menu_type = = RGUI_SYSTEM_DIR_PATH )
{
strlcpy ( g_settings . system_directory , dir , sizeof ( g_settings . system_directory ) ) ;
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS_PATH_OPTIONS ) ;
}
2012-07-31 21:19:46 -04:00
else
{
2013-03-11 06:23:14 +01:00
fill_pathname_join ( g_extern . fullpath , dir , path , sizeof ( g_extern . fullpath ) ) ;
2013-01-22 01:12:02 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_LOAD_GAME ) ;
2013-09-28 18:34:37 +02:00
rgui_flush_menu_stack_type ( rgui , RGUI_SETTINGS ) ;
2013-01-14 03:55:01 +01:00
rgui - > msg_force = true ;
2013-03-17 21:18:56 +01:00
ret = - 1 ;
2012-07-31 21:19:46 -04:00
}
2012-05-06 04:04:33 +02:00
}
break ;
}
case RGUI_ACTION_REFRESH :
2013-03-11 03:53:28 +01:00
rgui - > selection_ptr = 0 ;
2012-05-06 04:04:33 +02:00
rgui - > need_refresh = true ;
break ;
2013-01-14 03:55:01 +01:00
case RGUI_ACTION_MESSAGE :
rgui - > msg_force = true ;
break ;
2012-05-06 04:04:33 +02:00
default :
2012-06-29 21:53:00 -04:00
break ;
2012-05-06 04:04:33 +02:00
}
2012-07-31 21:19:46 -04:00
// refresh values in case the stack changed
2013-04-16 01:50:05 +02:00
rgui_list_get_last ( rgui - > menu_stack , & dir , & menu_type ) ;
2012-07-31 21:19:46 -04:00
2013-04-28 01:04:34 +02:00
if ( rgui - > need_refresh & & ( menu_type = = RGUI_FILE_DIRECTORY | |
# ifdef HAVE_SHADER_MANAGER
menu_type_is_shader_browser ( menu_type ) | |
2013-05-17 23:13:09 +02:00
# endif
2013-05-20 22:17:26 -04:00
menu_type_is_directory_browser ( menu_type ) | |
2013-05-17 23:13:09 +02:00
# ifdef HAVE_OVERLAY
menu_type = = RGUI_SETTINGS_OVERLAY_PRESET | |
2013-04-28 01:04:34 +02:00
# endif
2013-04-28 01:35:31 +02:00
menu_type = = RGUI_SETTINGS_CORE | |
2013-09-15 15:36:45 +02:00
menu_type = = RGUI_SETTINGS_CONFIG | |
2013-04-28 01:35:31 +02:00
menu_type = = RGUI_SETTINGS_OPEN_HISTORY | |
menu_type = = RGUI_SETTINGS_DISK_APPEND ) )
2012-05-06 04:04:33 +02:00
{
2012-06-30 04:03:48 -04:00
rgui - > need_refresh = false ;
2013-03-11 03:56:06 +01:00
rgui_list_clear ( rgui - > selection_buf ) ;
2013-04-28 01:35:31 +02:00
if ( menu_type = = RGUI_SETTINGS_OPEN_HISTORY )
history_parse ( rgui ) ;
else
2013-09-27 21:05:51 +02:00
rgui_directory_parse ( rgui , dir , menu_type , rgui - > selection_buf ) ;
2013-04-16 12:32:03 +02:00
// Before a refresh, we could have deleted a file on disk, causing
// selection_ptr to suddendly be out of range. Ensure it doesn't overflow.
if ( rgui - > selection_ptr > = rgui - > selection_buf - > size & & rgui - > selection_buf - > size )
rgui - > selection_ptr = rgui - > selection_buf - > size - 1 ;
else if ( ! rgui - > selection_buf - > size )
rgui - > selection_ptr = 0 ;
2012-05-06 04:04:33 +02:00
}
2012-07-31 21:19:46 -04:00
render_text ( rgui ) ;
2013-01-11 04:36:40 +01:00
2013-01-13 15:26:12 -05:00
return ret ;
2012-05-06 04:04:33 +02:00
}
2013-03-09 15:33:44 +01:00
2013-04-19 17:34:46 +02:00
int rgui_input_postprocess ( void * data , uint64_t old_state )
2013-03-09 15:33:44 +01:00
{
2013-04-17 23:31:49 +02:00
( void ) data ;
2013-04-18 23:00:27 +02:00
2013-04-17 21:11:13 +02:00
int ret = 0 ;
2013-09-27 14:31:16 +02:00
if ( ( rgui - > trigger_state & ( 1ULL < < RARCH_MENU_TOGGLE ) ) & &
2013-04-26 23:52:29 +02:00
g_extern . main_is_init & &
! g_extern . libretro_dummy )
2013-03-09 15:33:44 +01:00
{
2013-04-26 23:52:29 +02:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_GAME ) ;
ret = - 1 ;
2013-03-09 15:33:44 +01:00
}
2013-04-28 00:23:58 +02:00
if ( ret < 0 )
{
unsigned type = 0 ;
rgui_list_get_last ( rgui - > menu_stack , NULL , & type ) ;
while ( type ! = RGUI_SETTINGS )
{
rgui_list_pop ( rgui - > menu_stack , & rgui - > selection_ptr ) ;
rgui_list_get_last ( rgui - > menu_stack , NULL , & type ) ;
}
}
2013-04-17 21:11:13 +02:00
return ret ;
2013-03-09 15:33:44 +01:00
}
2013-09-19 14:49:07 +02:00
const menu_ctx_driver_t menu_ctx_rgui = {
rgui_iterate ,
rgui_init ,
rgui_free ,
" rgui " ,
} ;