1 /*  RetroArch - A frontend for libretro.
2  *  Copyright (C) 2011-2017 - Daniel De Matteis
3  *
4  *  RetroArch is free software: you can redistribute it and/or modify it under the terms
5  *  of the GNU General Public License as published by the Free Software Found-
6  *  ation, either version 3 of the License, or (at your option) any later version.
7  *
8  *  RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9  *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10  *  PURPOSE.  See the GNU General Public License for more details.
11  *
12  *  You should have received a copy of the GNU General Public License along with RetroArch.
13  *  If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #ifndef _MENU_DISPLAYLIST_H
17 #define _MENU_DISPLAYLIST_H
18 
19 #include <stdint.h>
20 
21 #include <boolean.h>
22 #include <retro_miscellaneous.h>
23 #include <retro_common_api.h>
24 #include <lists/file_list.h>
25 
26 #include "../configuration.h"
27 #include "../msg_hash.h"
28 #include "../setting_list.h"
29 
30 RETRO_BEGIN_DECLS
31 
32 /* NOTE: Order matters - only add new entries at
33  * the bottom */
34 enum menu_displaylist_parse_type
35 {
36    PARSE_NONE = 0,
37    PARSE_GROUP,
38    PARSE_ACTION,
39    PARSE_ONLY_INT,
40    PARSE_ONLY_UINT,
41    PARSE_ONLY_BOOL,
42    PARSE_ONLY_FLOAT,
43    PARSE_ONLY_BIND,
44    PARSE_ONLY_GROUP,
45    PARSE_ONLY_STRING,
46    PARSE_ONLY_PATH,
47    PARSE_ONLY_STRING_OPTIONS,
48    PARSE_ONLY_HEX,
49    PARSE_ONLY_DIR,
50    PARSE_SUB_GROUP,
51    PARSE_ONLY_SIZE
52 };
53 
54 enum menu_displaylist_ctl_state
55 {
56    DISPLAYLIST_NONE = 0,
57    DISPLAYLIST_DROPDOWN_LIST,
58    DISPLAYLIST_DROPDOWN_LIST_SPECIAL,
59    DISPLAYLIST_DROPDOWN_LIST_RESOLUTION,
60    DISPLAYLIST_DROPDOWN_LIST_VIDEO_SHADER_PARAMETER,
61    DISPLAYLIST_DROPDOWN_LIST_VIDEO_SHADER_PRESET_PARAMETER,
62    DISPLAYLIST_DROPDOWN_LIST_VIDEO_SHADER_NUM_PASSES,
63    DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_DEFAULT_CORE,
64    DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_LABEL_DISPLAY_MODE,
65    DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_RIGHT_THUMBNAIL_MODE,
66    DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_LEFT_THUMBNAIL_MODE,
67    DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_SORT_MODE,
68    DISPLAYLIST_DROPDOWN_LIST_MANUAL_CONTENT_SCAN_SYSTEM_NAME,
69    DISPLAYLIST_DROPDOWN_LIST_MANUAL_CONTENT_SCAN_CORE_NAME,
70    DISPLAYLIST_DROPDOWN_LIST_DISK_INDEX,
71    DISPLAYLIST_DROPDOWN_LIST_INPUT_DEVICE_TYPE,
72    DISPLAYLIST_DROPDOWN_LIST_INPUT_DEVICE_INDEX,
73    DISPLAYLIST_DROPDOWN_LIST_INPUT_DESCRIPTION,
74    DISPLAYLIST_DROPDOWN_LIST_INPUT_DESCRIPTION_KBD,
75    DISPLAYLIST_CDROM_DETAIL_INFO,
76    DISPLAYLIST_INFO,
77    DISPLAYLIST_HELP,
78    DISPLAYLIST_HELP_SCREEN_LIST,
79    DISPLAYLIST_MAIN_MENU,
80    DISPLAYLIST_GENERIC,
81    DISPLAYLIST_SETTINGS_ALL,
82    DISPLAYLIST_HORIZONTAL,
83    DISPLAYLIST_HORIZONTAL_CONTENT_ACTIONS,
84    DISPLAYLIST_HISTORY,
85    DISPLAYLIST_EXPLORE,
86    DISPLAYLIST_FAVORITES,
87    DISPLAYLIST_PLAYLIST,
88    DISPLAYLIST_VIDEO_HISTORY,
89    DISPLAYLIST_MUSIC_HISTORY,
90    DISPLAYLIST_IMAGES_HISTORY,
91    DISPLAYLIST_MUSIC_LIST,
92    DISPLAYLIST_PLAYLIST_COLLECTION,
93    DISPLAYLIST_DEFAULT,
94    DISPLAYLIST_FILE_BROWSER_SELECT_DIR,
95    DISPLAYLIST_FILE_BROWSER_SCAN_DIR,
96    DISPLAYLIST_FILE_BROWSER_SELECT_FILE,
97    DISPLAYLIST_FILE_BROWSER_SELECT_CORE,
98    DISPLAYLIST_FILE_BROWSER_SELECT_SIDELOAD_CORE,
99    DISPLAYLIST_FILE_BROWSER_SELECT_COLLECTION,
100    DISPLAYLIST_CORES,
101    DISPLAYLIST_CORES_SUPPORTED,
102    DISPLAYLIST_CORES_COLLECTION_SUPPORTED,
103    DISPLAYLIST_CORES_UPDATER,
104    DISPLAYLIST_CORE_MANAGER_LIST,
105    DISPLAYLIST_THUMBNAILS_UPDATER,
106    DISPLAYLIST_PL_THUMBNAILS_UPDATER,
107    DISPLAYLIST_LAKKA,
108    DISPLAYLIST_CORES_DETECTED,
109    DISPLAYLIST_CORE_OPTIONS,
110    DISPLAYLIST_CORE_OPTION_OVERRIDE_LIST,
111    DISPLAYLIST_CORE_INFO,
112    DISPLAYLIST_DISC_INFO,
113    DISPLAYLIST_PERFCOUNTERS_CORE,
114    DISPLAYLIST_PERFCOUNTERS_FRONTEND,
115    DISPLAYLIST_SHADER_PASS,
116    DISPLAYLIST_SHADER_PRESET,
117    DISPLAYLIST_DATABASES,
118    DISPLAYLIST_DATABASE_CURSORS,
119    DISPLAYLIST_DATABASE_PLAYLISTS,
120    DISPLAYLIST_DATABASE_PLAYLISTS_HORIZONTAL,
121    DISPLAYLIST_DATABASE_QUERY,
122    DISPLAYLIST_DATABASE_ENTRY,
123    DISPLAYLIST_AUDIO_FILTERS,
124    DISPLAYLIST_VIDEO_FILTERS,
125    DISPLAYLIST_CHEAT_FILES,
126    DISPLAYLIST_REMAP_FILES,
127    DISPLAYLIST_RECORD_CONFIG_FILES,
128    DISPLAYLIST_STREAM_CONFIG_FILES,
129    DISPLAYLIST_RGUI_THEME_PRESETS,
130    DISPLAYLIST_CONFIG_FILES,
131    DISPLAYLIST_CONTENT_HISTORY,
132    DISPLAYLIST_IMAGES,
133    DISPLAYLIST_FONTS,
134    DISPLAYLIST_VIDEO_FONTS,
135    DISPLAYLIST_LOAD_DISC,
136    DISPLAYLIST_DUMP_DISC,
137    DISPLAYLIST_OVERLAYS,
138 #ifdef HAVE_VIDEO_LAYOUT
139    DISPLAYLIST_VIDEO_LAYOUT_PATH,
140 #endif
141    DISPLAYLIST_SHADER_PARAMETERS,
142    DISPLAYLIST_SHADER_PARAMETERS_PRESET,
143    DISPLAYLIST_SHADER_PRESET_SAVE,
144    DISPLAYLIST_SHADER_PRESET_REMOVE,
145    DISPLAYLIST_NETWORK_INFO,
146    DISPLAYLIST_SYSTEM_INFO,
147    DISPLAYLIST_ACHIEVEMENT_PAUSE_MENU,
148    DISPLAYLIST_ACHIEVEMENT_LIST,
149    DISPLAYLIST_USER_BINDS_LIST,
150    DISPLAYLIST_ACCOUNTS_LIST,
151    DISPLAYLIST_SUBSYSTEM_SETTINGS_LIST,
152    DISPLAYLIST_MIXER_STREAM_SETTINGS_LIST,
153    DISPLAYLIST_DRIVER_SETTINGS_LIST,
154    DISPLAYLIST_VIDEO_FULLSCREEN_MODE_SETTINGS_LIST,
155    DISPLAYLIST_VIDEO_WINDOWED_MODE_SETTINGS_LIST,
156    DISPLAYLIST_VIDEO_SYNCHRONIZATION_SETTINGS_LIST,
157    DISPLAYLIST_VIDEO_OUTPUT_SETTINGS_LIST,
158    DISPLAYLIST_VIDEO_SCALING_SETTINGS_LIST,
159    DISPLAYLIST_CRT_SWITCHRES_SETTINGS_LIST,
160    DISPLAYLIST_VIDEO_SETTINGS_LIST,
161    DISPLAYLIST_CONFIGURATION_SETTINGS_LIST,
162    DISPLAYLIST_SAVING_SETTINGS_LIST,
163    DISPLAYLIST_LOGGING_SETTINGS_LIST,
164    DISPLAYLIST_FRAME_THROTTLE_SETTINGS_LIST,
165    DISPLAYLIST_FRAME_TIME_COUNTER_SETTINGS_LIST,
166    DISPLAYLIST_REWIND_SETTINGS_LIST,
167    DISPLAYLIST_CHEAT_DETAILS_SETTINGS_LIST,
168    DISPLAYLIST_CHEAT_SEARCH_SETTINGS_LIST,
169    DISPLAYLIST_AUDIO_SETTINGS_LIST,
170    DISPLAYLIST_AUDIO_RESAMPLER_SETTINGS_LIST,
171    DISPLAYLIST_AUDIO_OUTPUT_SETTINGS_LIST,
172    DISPLAYLIST_AUDIO_SYNCHRONIZATION_SETTINGS_LIST,
173    DISPLAYLIST_AUDIO_MIXER_SETTINGS_LIST,
174    DISPLAYLIST_CORE_SETTINGS_LIST,
175    DISPLAYLIST_INPUT_SETTINGS_LIST,
176    DISPLAYLIST_INPUT_TURBO_FIRE_SETTINGS_LIST,
177    DISPLAYLIST_INPUT_HAPTIC_FEEDBACK_SETTINGS_LIST,
178    DISPLAYLIST_INPUT_MENU_SETTINGS_LIST,
179    DISPLAYLIST_LATENCY_SETTINGS_LIST,
180    DISPLAYLIST_INPUT_HOTKEY_BINDS_LIST,
181 #if defined(HAVE_OVERLAY)
182    DISPLAYLIST_ONSCREEN_OVERLAY_SETTINGS_LIST,
183 #endif
184    DISPLAYLIST_AI_SERVICE_SETTINGS_LIST,
185    DISPLAYLIST_ACCESSIBILITY_SETTINGS_LIST,
186 #ifdef HAVE_VIDEO_LAYOUT
187    DISPLAYLIST_ONSCREEN_VIDEO_LAYOUT_SETTINGS_LIST,
188 #endif
189    DISPLAYLIST_ONSCREEN_DISPLAY_SETTINGS_LIST,
190    DISPLAYLIST_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST,
191    DISPLAYLIST_ONSCREEN_NOTIFICATIONS_VIEWS_SETTINGS_LIST,
192    DISPLAYLIST_MENU_FILE_BROWSER_SETTINGS_LIST,
193    DISPLAYLIST_MENU_VIEWS_SETTINGS_LIST,
194    DISPLAYLIST_QUICK_MENU_VIEWS_SETTINGS_LIST,
195    DISPLAYLIST_SETTINGS_VIEWS_SETTINGS_LIST,
196    DISPLAYLIST_MENU_SETTINGS_LIST,
197    DISPLAYLIST_USER_INTERFACE_SETTINGS_LIST,
198    DISPLAYLIST_POWER_MANAGEMENT_SETTINGS_LIST,
199    DISPLAYLIST_MENU_SOUNDS_LIST,
200    DISPLAYLIST_RETRO_ACHIEVEMENTS_SETTINGS_LIST,
201    DISPLAYLIST_UPDATER_SETTINGS_LIST,
202    DISPLAYLIST_BLUETOOTH_SETTINGS_LIST,
203    DISPLAYLIST_WIFI_SETTINGS_LIST,
204    DISPLAYLIST_NETWORK_SETTINGS_LIST,
205    DISPLAYLIST_NETWORK_HOSTING_SETTINGS_LIST,
206    DISPLAYLIST_NETPLAY_LAN_SCAN_SETTINGS_LIST,
207    DISPLAYLIST_LAKKA_SERVICES_LIST,
208    DISPLAYLIST_USER_SETTINGS_LIST,
209    DISPLAYLIST_DIRECTORY_SETTINGS_LIST,
210    DISPLAYLIST_PRIVACY_SETTINGS_LIST,
211    DISPLAYLIST_MIDI_SETTINGS_LIST,
212    DISPLAYLIST_RECORDING_SETTINGS_LIST,
213    DISPLAYLIST_PLAYLIST_SETTINGS_LIST,
214    DISPLAYLIST_PLAYLIST_MANAGER_LIST,
215    DISPLAYLIST_PLAYLIST_MANAGER_SETTINGS,
216    DISPLAYLIST_ACCOUNTS_CHEEVOS_LIST,
217    DISPLAYLIST_ACCOUNTS_YOUTUBE_LIST,
218    DISPLAYLIST_ACCOUNTS_TWITCH_LIST,
219    DISPLAYLIST_ACCOUNTS_FACEBOOK_LIST,
220    DISPLAYLIST_BROWSE_URL_LIST,
221    DISPLAYLIST_BROWSE_URL_START,
222    DISPLAYLIST_LOAD_CONTENT_LIST,
223    DISPLAYLIST_LOAD_CONTENT_SPECIAL,
224    DISPLAYLIST_INFORMATION_LIST,
225    DISPLAYLIST_INFORMATION,
226    DISPLAYLIST_CONTENT_SETTINGS,
227    DISPLAYLIST_OPTIONS,
228    DISPLAYLIST_OPTIONS_CHEATS,
229    DISPLAYLIST_OPTIONS_REMAPPINGS,
230    DISPLAYLIST_OPTIONS_REMAPPINGS_PORT,
231    DISPLAYLIST_OPTIONS_MANAGEMENT,
232    DISPLAYLIST_OPTIONS_DISK,
233    DISPLAYLIST_OPTIONS_SHADERS,
234    DISPLAYLIST_OPTIONS_OVERRIDES,
235    DISPLAYLIST_NETPLAY,
236    DISPLAYLIST_ADD_CONTENT_LIST,
237    DISPLAYLIST_CONFIGURATIONS_LIST,
238    DISPLAYLIST_SCAN_DIRECTORY_LIST,
239    DISPLAYLIST_NETPLAY_ROOM_LIST,
240    DISPLAYLIST_ARCHIVE_ACTION,
241    DISPLAYLIST_ARCHIVE_ACTION_DETECT_CORE,
242    DISPLAYLIST_CORE_CONTENT,
243    DISPLAYLIST_CORE_CONTENT_DIRS,
244    DISPLAYLIST_CORE_CONTENT_DIRS_SUBDIR,
245 #ifdef HAVE_LAKKA_SWITCH
246    DISPLAYLIST_SWITCH_GPU_PROFILE,
247 #endif
248 #if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
249    DISPLAYLIST_SWITCH_CPU_PROFILE,
250 #endif
251    DISPLAYLIST_MANUAL_CONTENT_SCAN_LIST,
252    DISPLAYLIST_MANUAL_CONTENT_SCAN_DAT_FILES,
253    DISPLAYLIST_CORE_RESTORE_BACKUP_LIST,
254    DISPLAYLIST_CORE_DELETE_BACKUP_LIST,
255    DISPLAYLIST_WIFI_NETWORKS_LIST,
256 #if defined(HAVE_LAKKA)
257    DISPLAYLIST_CPU_PERFPOWER_LIST,
258    DISPLAYLIST_CPU_POLICY_LIST,
259 #endif
260    DISPLAYLIST_PENDING_CLEAR
261 };
262 
263 enum filebrowser_enums
264 {
265    FILEBROWSER_NONE              = 0,
266    FILEBROWSER_SELECT_DIR,
267    FILEBROWSER_SCAN_DIR,
268    FILEBROWSER_SCAN_FILE,
269    FILEBROWSER_MANUAL_SCAN_DIR,
270    FILEBROWSER_SELECT_FILE,
271    FILEBROWSER_SELECT_FILE_SUBSYSTEM,
272    FILEBROWSER_SELECT_IMAGE,
273    FILEBROWSER_SELECT_VIDEO_FONT,
274    FILEBROWSER_SELECT_COLLECTION
275 };
276 
277 typedef struct menu_displaylist_info
278 {
279    char *path;
280    char *path_b;
281    char *path_c;
282    char *exts;
283    char *label;
284    file_list_t *list;
285    file_list_t *menu_list;
286    rarch_setting_t *setting;
287 
288    size_t directory_ptr;
289 
290    unsigned count;
291 
292    unsigned type;
293    unsigned type_default;
294    unsigned flags;
295 
296    enum msg_hash_enums enum_idx;
297    /* should the displaylist be sorted by alphabet? */
298    bool need_sort;
299    bool need_refresh;
300    bool need_entries_refresh;
301    bool need_push;
302    bool need_push_no_playlist_entries;
303    /* should we clear the displaylist before we push
304     * entries onto it? */
305    bool need_clear;
306    bool push_builtin_cores;
307    /* Should a 'download core' entry be pushed onto the list?
308     * This will be set to true in case there are no currently
309     * installed cores. */
310    bool download_core;
311    /* does the navigation index need to be cleared to 0 (first entry) ? */
312    bool need_navigation_clear;
313 } menu_displaylist_info_t;
314 
315 #define MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list, label, parse_type, add_empty_entry) menu_displaylist_parse_settings_enum(list, parse_type, add_empty_entry, menu_setting_find_enum(label), label, true)
316 
317 #define MENU_DISPLAYLIST_PARSE_SETTINGS(list, label, parse_type, add_empty_entry, entry_type) menu_displaylist_parse_settings_enum(list, parse_type, add_empty_entry, menu_setting_find(label), entry_type, false)
318 
319 bool menu_displaylist_process(menu_displaylist_info_t *info);
320 
321 void menu_displaylist_info_free(menu_displaylist_info_t *info);
322 
323 unsigned menu_displaylist_build_list(
324       file_list_t *list,
325       settings_t *settings,
326       enum menu_displaylist_ctl_state type,
327       bool include_everything);
328 
329 void menu_displaylist_info_init(menu_displaylist_info_t *info);
330 
331 bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist_info_t *info, settings_t *settings);
332 
333 #ifdef HAVE_NETWORKING
334 unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list);
335 #endif
336 
337 bool menu_displaylist_has_subsystems(void);
338 
339 #if defined(HAVE_LIBRETRODB)
340 unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings);
341 #endif
342 
343 enum filebrowser_enums filebrowser_get_type(void);
344 
345 void filebrowser_clear_type(void);
346 
347 void filebrowser_set_type(enum filebrowser_enums type);
348 
349 int menu_displaylist_parse_settings_enum(
350       file_list_t *info_list,
351       enum menu_displaylist_parse_type parse_type,
352       bool add_empty_entry,
353       rarch_setting_t *setting,
354       unsigned entry_type,
355       bool is_enum
356       );
357 
358 RETRO_END_DECLS
359 
360 #endif
361