From 0b58f1facf7abfa4514b3d0478277b903a4244d1 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 20 Oct 2019 20:47:27 +1000 Subject: [PATCH] Frontend: Hook up "Start Disc" --- src/duckstation/duckstation.vcxproj | 3 +++ src/duckstation/sdl_interface.cpp | 29 ++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/duckstation/duckstation.vcxproj b/src/duckstation/duckstation.vcxproj index 7fdb2d270..b729d0663 100644 --- a/src/duckstation/duckstation.vcxproj +++ b/src/duckstation/duckstation.vcxproj @@ -38,6 +38,9 @@ {bb08260f-6fbc-46af-8924-090ee71360c6} + + {ace32f47-2960-4fb3-9f77-2c375625bf61} + {b56ce698-7300-4fa5-9609-942f1d05c5a2} diff --git a/src/duckstation/sdl_interface.cpp b/src/duckstation/sdl_interface.cpp index e4a7102a2..47b5254fa 100644 --- a/src/duckstation/sdl_interface.cpp +++ b/src/duckstation/sdl_interface.cpp @@ -13,6 +13,7 @@ #include #include #include +#include Log_SetChannel(SDLInterface); SDLInterface::SDLInterface() = default; @@ -651,7 +652,8 @@ void SDLInterface::DrawPoweredOffWindow() ImGui::NewLine(); ImGui::SetCursorPosX(button_left); - ImGui::Button("Start Disc", button_size); + if (ImGui::Button("Start Disc", button_size)) + DoStartDisc(); ImGui::NewLine(); ImGui::SetCursorPosX(button_left); @@ -754,14 +756,35 @@ void SDLInterface::DoReset() void SDLInterface::DoResume() {} -void SDLInterface::DoStartDisc() {} +void SDLInterface::DoStartDisc() +{ + Assert(!m_system); + + nfdchar_t* path = nullptr; + if (!NFD_OpenDialog("bin,img,cue,exe,psexe", nullptr, &path) || !path || std::strlen(path) == 0) + return; + + AddOSDMessage(SmallString::FromFormat("Starting disc from '%s'...", path)); + if (!InitializeSystem(path, nullptr)) + { + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "System initialization failed.", m_window); + return; + } + + ConnectDevices(); +} void SDLInterface::DoStartBIOS() { Assert(!m_system); AddOSDMessage("Starting BIOS..."); - InitializeSystem(nullptr, nullptr); + if (!InitializeSystem(nullptr, nullptr)) + { + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "System initialization failed.", m_window); + return; + } + ConnectDevices(); }