diff --git a/.vscode/launch.json b/.vscode/launch.json index e7552247cc..d55f87de4e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,7 +13,7 @@ "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], - "externalConsole": false, + "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe", "setupCommands": [ diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 5d4bbcad1c..a31e28f937 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -675,7 +675,15 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_LIST, - "Sideload Core" + "Install or Restore a Core" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_ERROR, + "Core installation failed" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_SUCCESS, + "Core installation succesful" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_CORE_OPTIONS, @@ -4894,6 +4902,10 @@ MSG_HASH( MENU_ENUM_SUBLABEL_CORE_LIST, "Select which core to use." ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SIDELOAD_CORE_LIST, + "Install or restore a core from the downloads directory." + ) MSG_HASH( MENU_ENUM_SUBLABEL_LOAD_CONTENT_LIST, "Select which content to start." diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 9ddc6aaa8d..f20f3f06a0 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1240,6 +1240,54 @@ static int generic_action_ok_command(enum event_command cmd) return 0; } +/* TO-DO: Localization for errors */ +static bool file_copy(char* src_path, char* dst_path, char* msg, size_t size) +{ + + FILE *src, *dst; + char buffer[100]; + int numr, numw; + bool ret = true; + + src = fopen(src_path, "rb"); + + if (!src) + { + strlcpy(msg, "unable to open source file", size); + ret = false; + } + + dst = fopen(dst_path, "wb"); + if (!dst) + { + strlcpy(msg, "unable to open destination file", size); + ret = false; + } + + while (!feof(src)) + { + memset(buffer, 0, sizeof(buffer)); + numr = fread(buffer, 1, 100, src); + if (ferror(dst) != 0) + { + strlcpy(msg, "error reading file\n", size); + ret = false; + break; + } + + numw = fwrite(buffer, sizeof(char), numr, dst); + if (numw != numr) + { + strlcpy(msg, "error writing to file\n", size); + ret = false; + break; + } + } + fclose(src); + fclose(dst); + return ret; +} + static int generic_action_ok(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx, unsigned id, enum msg_hash_enums flush_id) @@ -1310,39 +1358,24 @@ static int generic_action_ok(const char *path, { settings_t *settings = config_get_ptr(); char destination_path[PATH_MAX_LENGTH]; - FILE *src, *dst; - char buffer[100]; - int numr, numw; + char message[PATH_MAX_LENGTH]; fill_pathname_join(destination_path, settings->paths.directory_libretro, path_basename(action_path), sizeof(destination_path)); - src = fopen(action_path, "rb"); - if (!src) - RARCH_LOG("Unable to open source file\n"); - - dst = fopen(destination_path, "wb"); - if (!dst) - RARCH_LOG("Unable to open destination file\n"); - - while (!feof(src)) + if(!file_copy(action_path, destination_path, message, sizeof(message))) { - memset(buffer, 0, sizeof(buffer)); - numr = fread(buffer, 1, 100, src); - if (ferror(dst) != 0) - { - RARCH_LOG("File read error\n"); - break; - } - - numw = fwrite(buffer, sizeof(char), numr, dst); - if (numw != numr) - { - RARCH_LOG("File write error\n"); - break; - } + runloop_msg_queue_push(msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_ERROR), 1, 100, true); + RARCH_LOG("[sideload] %s: %s\n", msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_ERROR), message); + RARCH_LOG(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_ERROR)); + } + else + { + runloop_msg_queue_push(msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_SUCCESS), 1, 100, true); + RARCH_LOG("[sideload] %s\n", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_SUCCESS)); } - fclose(src); - fclose(dst); } break; case ACTION_OK_LOAD_CONFIG_FILE: diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 56f2efa9bb..0f3a27756c 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -188,6 +188,7 @@ default_sublabel_macro(action_bind_sublabel_cheevos_username, MENU_ default_sublabel_macro(action_bind_sublabel_cheevos_password, MENU_ENUM_SUBLABEL_CHEEVOS_PASSWORD) default_sublabel_macro(action_bind_sublabel_video_post_filter_record, MENU_ENUM_SUBLABEL_VIDEO_POST_FILTER_RECORD) default_sublabel_macro(action_bind_sublabel_core_list, MENU_ENUM_SUBLABEL_CORE_LIST) +default_sublabel_macro(action_bind_sublabel_sideload_core_list, MENU_ENUM_SUBLABEL_SIDELOAD_CORE_LIST) default_sublabel_macro(action_bind_sublabel_content_list, MENU_ENUM_SUBLABEL_LOAD_CONTENT_LIST) default_sublabel_macro(action_bind_sublabel_content_special, MENU_ENUM_SUBLABEL_LOAD_CONTENT_SPECIAL) default_sublabel_macro(action_bind_sublabel_network_information, MENU_ENUM_SUBLABEL_NETWORK_INFORMATION) @@ -1673,6 +1674,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_CORE_LIST: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_core_list); break; + case MENU_ENUM_LABEL_SIDELOAD_CORE_LIST: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_sideload_core_list); + break; case MENU_ENUM_LABEL_VIDEO_POST_FILTER_RECORD: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_post_filter_record); break; diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 8b2f048b1f..676ad9b94f 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -589,9 +589,11 @@ static int ozone_list_push(void *data, void *userdata, { entry.enum_idx = MENU_ENUM_LABEL_CORE_LIST; menu_displaylist_setting(&entry); - - entry.enum_idx = MENU_ENUM_LABEL_SIDELOAD_CORE_LIST; - menu_displaylist_setting(&entry); + if (settings->bools.menu_show_advanced_settings) + { + entry.enum_idx = MENU_ENUM_LABEL_SIDELOAD_CORE_LIST; + menu_displaylist_setting(&entry); + } } } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 8e212f474b..9c5b37b24e 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -5541,6 +5541,11 @@ static int xmb_list_push(void *data, void *userdata, { entry.enum_idx = MENU_ENUM_LABEL_CORE_LIST; menu_displaylist_setting(&entry); + if (settings->bools.menu_show_advanced_settings) + { + entry.enum_idx = MENU_ENUM_LABEL_SIDELOAD_CORE_LIST; + menu_displaylist_setting(&entry); + } } } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 6d049e6bb5..c201c99b99 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3703,15 +3703,13 @@ static unsigned menu_displaylist_parse_cores( file_type = FILE_TYPE_DIRECTORY; enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_DIRECTORY; } - else if(string_is_equal(info->path, settings->paths.directory_core_assets)) - { - file_type = FILE_TYPE_CORE; - enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_SIDELOAD_CORE; - } else { file_type = FILE_TYPE_CORE; - enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_CORE; + if (string_is_equal(info->label, msg_hash_to_str(MENU_ENUM_LABEL_SIDELOAD_CORE_LIST))) + enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_SIDELOAD_CORE; + else + enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_CORE; } items_found++; diff --git a/msg_hash.h b/msg_hash.h index e986b508c4..5cb184c924 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1572,6 +1572,8 @@ enum msg_hash_enums MENU_LABEL(SUBSYSTEM_LOAD), MENU_LABEL(CORE_LIST), MENU_LABEL(SIDELOAD_CORE_LIST), + MENU_LABEL(SIDELOAD_CORE_ERROR), + MENU_LABEL(SIDELOAD_CORE_SUCCESS), MENU_LABEL(MANAGEMENT), MENU_LABEL(ONLINE), MENU_LABEL(ONLINE_UPDATER),