| 2330 | } |
| 2331 | |
| 2332 | bool VMManager::ChangeDisc(CDVD_SourceType source, std::string path) |
| 2333 | { |
| 2334 | const CDVD_SourceType old_type = CDVDsys_GetSourceType(); |
| 2335 | const std::string old_path(CDVDsys_GetFile(old_type)); |
| 2336 | |
| 2337 | CDVDsys_ChangeSource(source); |
| 2338 | if (!path.empty()) |
| 2339 | CDVDsys_SetFile(source, path); |
| 2340 | |
| 2341 | Error error; |
| 2342 | const bool result = DoCDVDopen(&error); |
| 2343 | if (result) |
| 2344 | { |
| 2345 | if (source == CDVD_SourceType::NoDisc) |
| 2346 | { |
| 2347 | if (old_path.empty()) |
| 2348 | Host::AddIconOSDMessage("ChangeDisc", ICON_FA_COMPACT_DISC, TRANSLATE_SV("VMManager", "No disc to remove."), |
| 2349 | Host::OSD_INFO_DURATION); |
| 2350 | else |
| 2351 | { |
| 2352 | Host::AddIconOSDMessage("ChangeDisc", ICON_FA_COMPACT_DISC, TRANSLATE_SV("VMManager", "Disc removed."), |
| 2353 | Host::OSD_INFO_DURATION); |
| 2354 | Console.WriteLnFmt("Removed disc: '{}'", old_path); |
| 2355 | } |
| 2356 | } |
| 2357 | else |
| 2358 | { |
| 2359 | Host::AddIconOSDMessage("ChangeDisc", ICON_FA_COMPACT_DISC, |
| 2360 | fmt::format(TRANSLATE_FS("VMManager", "Disc changed to '{}'."), |
| 2361 | Path::GetFileName(CDVDsys_GetFile(CDVDsys_GetSourceType()))), |
| 2362 | Host::OSD_INFO_DURATION); |
| 2363 | } |
| 2364 | } |
| 2365 | else |
| 2366 | { |
| 2367 | Host::AddIconOSDMessage("ChangeDisc", ICON_FA_COMPACT_DISC, |
| 2368 | fmt::format( |
| 2369 | TRANSLATE_FS("VMManager", "Failed to open new disc image '{}'. Reverting to old image.\nError was: {}"), |
| 2370 | Path::GetFileName(path), error.GetDescription()), |
| 2371 | Host::OSD_ERROR_DURATION); |
| 2372 | CDVDsys_ChangeSource(old_type); |
| 2373 | if (!old_path.empty()) |
| 2374 | CDVDsys_SetFile(old_type, std::move(old_path)); |
| 2375 | if (!DoCDVDopen(&error)) |
| 2376 | { |
| 2377 | Host::AddIconOSDMessage("ChangeDisc", ICON_FA_COMPACT_DISC, |
| 2378 | fmt::format(TRANSLATE_FS("VMManager", "Failed to switch back to old disc image. Removing disc.\nError was: {}"), |
| 2379 | error.GetDescription()), |
| 2380 | Host::OSD_CRITICAL_ERROR_DURATION); |
| 2381 | CDVDsys_ChangeSource(CDVD_SourceType::NoDisc); |
| 2382 | DoCDVDopen(nullptr); |
| 2383 | } |
| 2384 | } |
| 2385 | cdvd.Tray.cdvdActionSeconds = 1; |
| 2386 | cdvd.Tray.trayState = CDVD_DISC_OPEN; |
| 2387 | UpdateDiscDetails(false); |
| 2388 | return result; |
| 2389 | } |
nothing calls this directly
no test coverage detected