cdrom: add load disc callback

This commit is contained in:
Brad Parker 2019-07-09 11:17:10 -04:00
parent cfbeed0c29
commit 119245e88b
6 changed files with 75 additions and 7 deletions

View File

@ -1629,9 +1629,9 @@ MSG_HASH(
"コンテンツをロード"
)
MSG_HASH(MENU_ENUM_LABEL_VALUE_LOAD_DISC,
"Load Disc")
"ディスクをロード")
MSG_HASH(MENU_ENUM_LABEL_VALUE_DUMP_DISC,
"Dump Disc")
"ディスクをダンプ")
MSG_HASH(
MENU_ENUM_LABEL_VALUE_LOAD_STATE,
"ステートロード"
@ -9007,3 +9007,13 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIDEO_GPU_INDEX,
"GPUインデックス"
)
MSG_HASH(MSG_DUMPING_DISC,
"ディスクをダンプ中...")
MSG_HASH(MSG_DRIVE_NUMBER,
"ドライブ%d")
MSG_HASH(MSG_LOAD_CORE_FIRST,
"コアをロードしてください。")
MSG_HASH(MSG_DISC_DUMP_FAILED_TO_READ_FROM_DRIVE,
"ドライブからの読み込みに失敗しました。ダンプが中止されました。")
MSG_HASH(MSG_DISC_DUMP_FAILED_TO_WRITE_TO_DISK,
"ディスクに書き込みに失敗しました。ダンプが中止されました。")

View File

@ -8943,3 +8943,9 @@ MSG_HASH(MSG_DUMPING_DISC,
"Dumping disc...")
MSG_HASH(MSG_DRIVE_NUMBER,
"Drive %d")
MSG_HASH(MSG_LOAD_CORE_FIRST,
"Please load a core first.")
MSG_HASH(MSG_DISC_DUMP_FAILED_TO_READ_FROM_DRIVE,
"Failed to read from drive. Dump aborted.")
MSG_HASH(MSG_DISC_DUMP_FAILED_TO_WRITE_TO_DISK,
"Failed to write to disk. Dump aborted.")

View File

@ -2134,7 +2134,47 @@ static int action_ok_mixer_stream_action_stop(const char *path,
static int action_ok_load_cdrom(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
/* TODO/FIXME - implement */
#ifdef HAVE_CDROM
struct retro_system_info *system = runloop_get_libretro_system_info();
if (system && !string_is_empty(system->library_name))
{
char cdrom_path[256];
cdrom_path[0] = '\0';
cdrom_device_fillpath(cdrom_path, sizeof(cdrom_path), label[0], 0, true);
RARCH_LOG("[CDROM] Loading disc from path: %s\n", cdrom_path);
path_clear(RARCH_PATH_CONTENT);
path_set(RARCH_PATH_CONTENT, cdrom_path);
#if defined(HAVE_DYNAMIC)
{
content_ctx_info_t content_info;
content_info.argc = 0;
content_info.argv = NULL;
content_info.args = NULL;
content_info.environ_get = NULL;
task_push_load_content_with_core_from_menu(cdrom_path, &content_info, CORE_TYPE_PLAIN, NULL, NULL);
}
#else
frontend_driver_set_fork(FRONTEND_FORK_CORE_WITH_ARGS);
#endif
}
else
{
RARCH_LOG("[CDROM] Cannot load disc without a core.\n");
runloop_msg_queue_push(
msg_hash_to_str(MSG_LOAD_CORE_FIRST),
1, 100, true,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
#endif
return 0;
}

View File

@ -4947,9 +4947,18 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
for (i = 0; list && i < list->size; i++)
{
char drive_string[256] = {0};
char drive[2] = {0};
size_t pos = 0;
drive[0] = list->elems[i].attr.i;
pos += snprintf(drive_string + pos, sizeof(drive_string) - pos, msg_hash_to_str(MSG_DRIVE_NUMBER), i + 1);
pos += snprintf(drive_string + pos, sizeof(drive_string) - pos, ": %s", list->elems[i].data);
menu_entries_append_enum(info->list,
list->elems[i].data,
"",
drive_string,
drive,
0,
MENU_SET_LOAD_CDROM_LIST,
0, i);

View File

@ -2437,6 +2437,9 @@ enum msg_hash_enums
MSG_DUMPING_DISC,
MSG_DRIVE_NUMBER,
MSG_LOAD_CORE_FIRST,
MSG_DISC_DUMP_FAILED_TO_READ_FROM_DRIVE,
MSG_DISC_DUMP_FAILED_TO_WRITE_TO_DISK,
MSG_LAST
};

View File

@ -412,7 +412,7 @@ static void task_cdrom_dump_handler(retro_task_t *task)
{
task_set_progress(task, 100);
task_free_title(task);
task_set_title(task, strdup("Failed to read from drive. Dump aborted."));
task_set_title(task, strdup(msg_hash_to_str(MSG_DISC_DUMP_FAILED_TO_READ_FROM_DRIVE)));
return;
}
@ -428,7 +428,7 @@ static void task_cdrom_dump_handler(retro_task_t *task)
{
task_set_progress(task, 100);
task_free_title(task);
task_set_title(task, strdup("Failed to write to disk. Dump aborted."));
task_set_title(task, strdup(msg_hash_to_str(MSG_DISC_DUMP_FAILED_TO_WRITE_TO_DISK)));
return;
}