From 9bda6c5ef7f6ea8263f89af9dc01a35dba13f58b Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 28 Oct 2019 17:34:59 +1000 Subject: [PATCH] Frontend: Hook up change disc menu item --- src/duckstation/sdl_interface.cpp | 17 ++++++++++++++++- src/duckstation/sdl_interface.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/duckstation/sdl_interface.cpp b/src/duckstation/sdl_interface.cpp index c5e7a7f93..931c8aa91 100644 --- a/src/duckstation/sdl_interface.cpp +++ b/src/duckstation/sdl_interface.cpp @@ -752,7 +752,8 @@ void SDLInterface::DrawMainMenuBar() ImGui::Separator(); - ImGui::MenuItem("Change Disc", nullptr, false, system_enabled); + if (ImGui::MenuItem("Change Disc", nullptr, false, system_enabled)) + DoChangeDisc(); if (ImGui::MenuItem("Frame Step", nullptr, false, system_enabled)) DoFrameStep(); @@ -1166,6 +1167,20 @@ void SDLInterface::DoStartBIOS() ClearImGuiFocus(); } +void SDLInterface::DoChangeDisc() +{ + Assert(m_system); + + nfdchar_t* path = nullptr; + if (!NFD_OpenDialog("bin,img,cue,exe,psexe", nullptr, &path) || !path || std::strlen(path) == 0) + return; + + if (m_system->InsertMedia(path)) + AddOSDMessage(SmallString::FromFormat("Switched CD to '%s'", path)); + else + AddOSDMessage("Failed to switch CD. The log may contain further information."); +} + void SDLInterface::DoLoadState(u32 index) { if (!HasSystem() && !InitializeSystem(nullptr, nullptr)) diff --git a/src/duckstation/sdl_interface.h b/src/duckstation/sdl_interface.h index a45674892..7183c973c 100644 --- a/src/duckstation/sdl_interface.h +++ b/src/duckstation/sdl_interface.h @@ -70,6 +70,7 @@ private: void DoResume(); void DoStartDisc(); void DoStartBIOS(); + void DoChangeDisc(); void DoLoadState(u32 index); void DoSaveState(u32 index); void DoTogglePause();