2014-10-11 22:45:42 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2014-10-11 22:45:42 +00: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/>.
|
|
|
|
*/
|
|
|
|
|
2014-10-21 22:23:06 +00:00
|
|
|
#include <file/file_path.h>
|
2015-01-10 03:53:37 +00:00
|
|
|
#include "menu.h"
|
2014-10-14 17:40:52 +00:00
|
|
|
#include "menu_entries_cbs.h"
|
2015-02-14 00:51:28 +00:00
|
|
|
#include "menu_setting.h"
|
2015-01-11 05:24:44 +00:00
|
|
|
#include "menu_input.h"
|
2014-10-11 23:23:41 +00:00
|
|
|
#include "menu_entries.h"
|
2015-02-11 21:15:13 +00:00
|
|
|
#include "menu_navigation.h"
|
2014-10-11 22:45:42 +00:00
|
|
|
|
2015-01-16 00:37:34 +00:00
|
|
|
#include "../file_extract.h"
|
2015-01-31 11:03:38 +00:00
|
|
|
#include "../file_ops.h"
|
2014-10-28 18:54:23 +00:00
|
|
|
#include "../config.def.h"
|
2015-01-09 16:40:47 +00:00
|
|
|
#include "../retroarch.h"
|
2015-03-15 01:47:23 +00:00
|
|
|
#include "../runloop.h"
|
2014-10-12 03:01:52 +00:00
|
|
|
|
2015-02-26 15:50:30 +00:00
|
|
|
void menu_entries_common_load_content(bool persist)
|
2014-10-12 02:41:33 +00:00
|
|
|
{
|
2015-02-13 18:44:08 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
2014-10-25 00:42:37 +00:00
|
|
|
rarch_main_command(persist ? RARCH_CMD_LOAD_CONTENT_PERSIST : RARCH_CMD_LOAD_CONTENT);
|
2015-02-11 22:30:29 +00:00
|
|
|
|
|
|
|
menu_list_flush_stack(menu->menu_list, MENU_SETTINGS);
|
|
|
|
menu->msg_force = true;
|
2014-10-12 02:41:33 +00:00
|
|
|
}
|
|
|
|
|
2015-01-26 09:18:13 +00:00
|
|
|
int menu_action_setting_set_current_string(
|
|
|
|
rarch_setting_t *setting, const char *str)
|
|
|
|
{
|
|
|
|
strlcpy(setting->value.string, str, setting->size);
|
2015-02-14 00:51:28 +00:00
|
|
|
return menu_setting_generic(setting);
|
2015-01-26 09:18:13 +00:00
|
|
|
}
|
|
|
|
|
2015-01-28 07:55:02 +00:00
|
|
|
#ifdef HAVE_NETWORKING
|
2015-01-23 21:00:11 +00:00
|
|
|
/* HACK - we have to find some way to pass state inbetween
|
|
|
|
* function pointer callback functions that don't necessarily
|
|
|
|
* call each other. */
|
|
|
|
|
2015-02-23 00:23:21 +00:00
|
|
|
static int zlib_extract_core_callback(const char *name, const char *valid_exts,
|
2015-01-31 11:03:38 +00:00
|
|
|
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
|
|
|
|
uint32_t crc32, void *userdata)
|
|
|
|
{
|
|
|
|
char path[PATH_MAX_LENGTH];
|
|
|
|
|
|
|
|
/* Make directory */
|
|
|
|
fill_pathname_join(path, (const char*)userdata, name, sizeof(path));
|
|
|
|
path_basedir(path);
|
|
|
|
|
|
|
|
if (!path_mkdir(path))
|
|
|
|
{
|
|
|
|
RARCH_ERR("Failed to create directory: %s.\n", path);
|
2015-02-23 00:23:21 +00:00
|
|
|
return 0;
|
2015-01-31 11:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Ignore directories. */
|
|
|
|
if (name[strlen(name) - 1] == '/' || name[strlen(name) - 1] == '\\')
|
2015-02-23 00:23:21 +00:00
|
|
|
return 1;
|
2015-01-31 11:03:38 +00:00
|
|
|
|
|
|
|
fill_pathname_join(path, (const char*)userdata, name, sizeof(path));
|
|
|
|
|
|
|
|
RARCH_LOG("path is: %s, CRC32: 0x%x\n", path, crc32);
|
|
|
|
|
|
|
|
switch (cmode)
|
|
|
|
{
|
|
|
|
case 0: /* Uncompressed */
|
|
|
|
write_file(path, cdata, size);
|
|
|
|
break;
|
|
|
|
case 8: /* Deflate */
|
|
|
|
zlib_inflate_data_to_file(path, valid_exts, cdata, csize, size, crc32);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-02-23 00:23:21 +00:00
|
|
|
return 1;
|
2015-01-31 11:03:38 +00:00
|
|
|
}
|
|
|
|
|
2015-02-16 04:44:43 +00:00
|
|
|
int cb_core_updater_download(void *data_, size_t len)
|
2015-01-23 21:00:11 +00:00
|
|
|
{
|
|
|
|
FILE *f;
|
2015-01-31 11:03:38 +00:00
|
|
|
const char* file_ext = NULL;
|
2015-01-24 02:20:54 +00:00
|
|
|
char output_path[PATH_MAX_LENGTH], msg[PATH_MAX_LENGTH];
|
2015-01-23 21:00:11 +00:00
|
|
|
char *data = (char*)data_;
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
fill_pathname_join(output_path, g_settings.libretro_directory,
|
2015-02-01 14:57:25 +00:00
|
|
|
core_updater_path, sizeof(output_path));
|
2015-01-23 21:00:11 +00:00
|
|
|
|
|
|
|
f = fopen(output_path, "wb");
|
|
|
|
|
|
|
|
if (!f)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
fwrite(data, 1, len, f);
|
|
|
|
fclose(f);
|
|
|
|
|
2015-01-24 02:20:54 +00:00
|
|
|
snprintf(msg, sizeof(msg), "Download complete: %s.",
|
2015-02-01 14:57:25 +00:00
|
|
|
core_updater_path);
|
2015-01-24 02:20:54 +00:00
|
|
|
|
2015-03-15 01:47:23 +00:00
|
|
|
rarch_main_msg_queue_push(msg, 1, 90, true);
|
2015-01-24 02:20:54 +00:00
|
|
|
|
2015-01-31 11:03:38 +00:00
|
|
|
#ifdef HAVE_ZLIB
|
|
|
|
file_ext = path_get_extension(output_path);
|
2015-01-31 11:45:20 +00:00
|
|
|
|
|
|
|
if (!g_settings.network.buildbot_auto_extract_archive)
|
|
|
|
return 0;
|
|
|
|
|
2015-01-31 11:03:38 +00:00
|
|
|
if (!strcasecmp(file_ext,"zip"))
|
|
|
|
{
|
|
|
|
if (!zlib_parse_file(output_path, NULL, zlib_extract_core_callback,
|
|
|
|
|
|
|
|
(void*)g_settings.libretro_directory))
|
|
|
|
RARCH_LOG("Could not process ZIP file.\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-01-23 21:00:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2015-01-24 00:31:17 +00:00
|
|
|
#endif
|
2015-01-23 21:00:11 +00:00
|
|
|
|
2015-02-26 16:33:00 +00:00
|
|
|
int menu_entries_common_is_settings_entry(const char *label)
|
2015-01-31 04:28:14 +00:00
|
|
|
{
|
|
|
|
return (
|
2015-02-12 18:52:57 +00:00
|
|
|
!strcmp(label, "Driver Settings") ||
|
|
|
|
!strcmp(label, "General Settings") ||
|
|
|
|
!strcmp(label, "Video Settings") ||
|
|
|
|
!strcmp(label, "Shader Settings") ||
|
|
|
|
!strcmp(label, "Font Settings") ||
|
|
|
|
!strcmp(label, "Audio Settings") ||
|
|
|
|
!strcmp(label, "Input Settings") ||
|
|
|
|
!strcmp(label, "Overlay Settings") ||
|
|
|
|
!strcmp(label, "Menu Settings") ||
|
|
|
|
!strcmp(label, "UI Settings") ||
|
|
|
|
!strcmp(label, "Patch Settings") ||
|
|
|
|
!strcmp(label, "Playlist Settings") ||
|
|
|
|
!strcmp(label, "Onscreen Keyboard Overlay Settings") ||
|
|
|
|
!strcmp(label, "Core Updater Settings") ||
|
|
|
|
!strcmp(label, "Network Settings") ||
|
|
|
|
!strcmp(label, "Archive Settings") ||
|
|
|
|
!strcmp(label, "User Settings") ||
|
|
|
|
!strcmp(label, "Path Settings") ||
|
|
|
|
!strcmp(label, "Privacy Settings"));
|
2015-01-31 04:28:14 +00:00
|
|
|
}
|
|
|
|
|
2014-10-11 23:39:13 +00:00
|
|
|
void menu_entries_cbs_init(void *data,
|
|
|
|
const char *path, const char *label,
|
2014-10-20 02:37:52 +00:00
|
|
|
unsigned type, size_t idx)
|
2014-10-11 23:39:13 +00:00
|
|
|
{
|
2015-02-01 12:28:41 +00:00
|
|
|
struct string_list *str_list = NULL;
|
|
|
|
char elem0[PATH_MAX_LENGTH], elem1[PATH_MAX_LENGTH];
|
|
|
|
const char *menu_label = NULL;
|
2014-10-11 23:39:13 +00:00
|
|
|
menu_file_list_cbs_t *cbs = NULL;
|
|
|
|
file_list_t *list = (file_list_t*)data;
|
2015-02-13 18:44:08 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
if (!menu)
|
|
|
|
return;
|
2014-10-11 23:39:13 +00:00
|
|
|
|
|
|
|
if (!list)
|
|
|
|
return;
|
|
|
|
|
2015-01-26 09:58:47 +00:00
|
|
|
if (!(cbs = (menu_file_list_cbs_t*)list->list[idx].actiondata))
|
|
|
|
return;
|
2014-10-11 23:39:13 +00:00
|
|
|
|
2015-02-13 18:44:08 +00:00
|
|
|
menu_list_get_last_stack(menu->menu_list,
|
2015-02-01 12:28:41 +00:00
|
|
|
NULL, &menu_label, NULL);
|
|
|
|
|
|
|
|
if (label)
|
|
|
|
str_list = string_split(label, "|");
|
|
|
|
|
|
|
|
if (str_list && str_list->size > 0)
|
|
|
|
strlcpy(elem0, str_list->elems[0].data, sizeof(elem0));
|
2015-02-12 17:21:13 +00:00
|
|
|
else elem0[0]='\0';
|
2015-02-01 12:28:41 +00:00
|
|
|
if (str_list && str_list->size > 1)
|
|
|
|
strlcpy(elem1, str_list->elems[1].data, sizeof(elem1));
|
2015-02-12 17:21:13 +00:00
|
|
|
else elem1[0]='\0';
|
2015-02-01 12:28:41 +00:00
|
|
|
|
|
|
|
if (str_list)
|
|
|
|
{
|
|
|
|
string_list_free(str_list);
|
|
|
|
str_list = NULL;
|
|
|
|
}
|
2015-01-30 04:58:57 +00:00
|
|
|
|
2015-02-01 12:28:41 +00:00
|
|
|
menu_entries_cbs_init_bind_ok(cbs, path, label, type, idx, elem0, elem1, menu_label);
|
|
|
|
menu_entries_cbs_init_bind_cancel(cbs, path, label, type, idx, elem0, elem1);
|
|
|
|
menu_entries_cbs_init_bind_start(cbs, path, label, type, idx, elem0, elem1);
|
|
|
|
menu_entries_cbs_init_bind_select(cbs, path, label, type, idx, elem0, elem1);
|
|
|
|
menu_entries_cbs_init_bind_content_list_switch(cbs, path, label, type, idx, elem0, elem1);
|
|
|
|
menu_entries_cbs_init_bind_up_or_down(cbs, path, label, type, idx, elem0, elem1);
|
|
|
|
menu_entries_cbs_init_bind_toggle(cbs, path, label, type, idx, elem0, elem1, menu_label);
|
|
|
|
menu_entries_cbs_init_bind_deferred_push(cbs, path, label, type, idx, elem0, elem1);
|
|
|
|
menu_entries_cbs_init_bind_refresh(cbs, path, label, type, idx, elem0, elem1);
|
|
|
|
menu_entries_cbs_init_bind_iterate(cbs, path, label, type, idx, elem0, elem1);
|
|
|
|
menu_entries_cbs_init_bind_get_string_representation(cbs, path, label, type, idx, elem0, elem1);
|
2014-10-11 22:45:42 +00:00
|
|
|
}
|