From 7501e89b7a852c16dd7409d9b88026a5d5332000 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 21 Feb 2021 16:53:14 +1000 Subject: [PATCH] System: Add path/image to game change notification --- android/app/src/cpp/android_host_interface.cpp | 5 +++-- android/app/src/cpp/android_host_interface.h | 3 ++- src/core/host_interface.cpp | 6 ++++-- src/core/host_interface.h | 3 ++- src/core/system.cpp | 4 +++- src/duckstation-nogui/nogui_host_interface.cpp | 5 +++-- src/duckstation-nogui/nogui_host_interface.h | 3 ++- src/duckstation-qt/qthostinterface.cpp | 5 +++-- src/duckstation-qt/qthostinterface.h | 5 +++-- src/frontend-common/common_host_interface.cpp | 5 +++-- src/frontend-common/common_host_interface.h | 3 ++- 11 files changed, 30 insertions(+), 17 deletions(-) diff --git a/android/app/src/cpp/android_host_interface.cpp b/android/app/src/cpp/android_host_interface.cpp index 83b60033b..05c768167 100644 --- a/android/app/src/cpp/android_host_interface.cpp +++ b/android/app/src/cpp/android_host_interface.cpp @@ -597,9 +597,10 @@ void AndroidHostInterface::OnSystemDestroyed() SetVibration(false); } -void AndroidHostInterface::OnRunningGameChanged() +void AndroidHostInterface::OnRunningGameChanged(const std::string& path, CDImage* image, const std::string& game_code, + const std::string& game_title) { - CommonHostInterface::OnRunningGameChanged(); + CommonHostInterface::OnRunningGameChanged(path, image, game_code, game_title); ApplySettings(true); if (m_emulation_activity_object) diff --git a/android/app/src/cpp/android_host_interface.h b/android/app/src/cpp/android_host_interface.h index 4bb520772..9c32e0f36 100644 --- a/android/app/src/cpp/android_host_interface.h +++ b/android/app/src/cpp/android_host_interface.h @@ -85,7 +85,8 @@ protected: void OnSystemPaused(bool paused) override; void OnSystemDestroyed() override; - void OnRunningGameChanged() override; + void OnRunningGameChanged(const std::string& path, CDImage* image, const std::string& game_code, + const std::string& game_title) override; private: void EmulationThreadLoop(JNIEnv* env); diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index d4e9ef0bc..a00af9c23 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -172,7 +172,6 @@ void HostInterface::DestroySystem() UpdateSoftwareCursor(); ReleaseHostDisplay(); OnSystemDestroyed(); - OnRunningGameChanged(); } void HostInterface::ReportError(const char* message) @@ -471,7 +470,10 @@ void HostInterface::OnSystemPerformanceCountersUpdated() {} void HostInterface::OnSystemStateSaved(bool global, s32 slot) {} -void HostInterface::OnRunningGameChanged() {} +void HostInterface::OnRunningGameChanged(const std::string& path, CDImage* image, const std::string& game_code, + const std::string& game_title) +{ +} void HostInterface::OnControllerTypeChanged(u32 slot) {} diff --git a/src/core/host_interface.h b/src/core/host_interface.h index ed5b09704..5bcf37da4 100644 --- a/src/core/host_interface.h +++ b/src/core/host_interface.h @@ -143,7 +143,8 @@ public: /// This is the APK for Android builds, or the program directory for standalone builds. virtual std::unique_ptr OpenPackageFile(const char* path, u32 flags) = 0; - virtual void OnRunningGameChanged(); + virtual void OnRunningGameChanged(const std::string& path, CDImage* image, const std::string& game_code, + const std::string& game_title); virtual void OnSystemPerformanceCountersUpdated(); protected: diff --git a/src/core/system.cpp b/src/core/system.cpp index cc314839a..eb3f2ea56 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -913,6 +913,8 @@ void Shutdown() s_media_playlist_filename.clear(); s_cheat_list.reset(); s_state = State::Shutdown; + + g_host_interface->OnRunningGameChanged(s_running_game_path, nullptr, s_running_game_code, s_running_game_title); } bool CreateGPU(GPURenderer renderer) @@ -1882,7 +1884,7 @@ void UpdateRunningGame(const char* path, CDImage* image) g_texture_replacements.SetGameID(s_running_game_code); - g_host_interface->OnRunningGameChanged(); + g_host_interface->OnRunningGameChanged(s_running_game_path, image, s_running_game_code, s_running_game_title); } bool CheckForSBIFile(CDImage* image) diff --git a/src/duckstation-nogui/nogui_host_interface.cpp b/src/duckstation-nogui/nogui_host_interface.cpp index d30efaf60..944b4c22b 100644 --- a/src/duckstation-nogui/nogui_host_interface.cpp +++ b/src/duckstation-nogui/nogui_host_interface.cpp @@ -314,9 +314,10 @@ void NoGUIHostInterface::OnSystemDestroyed() FullscreenUI::SystemDestroyed(); } -void NoGUIHostInterface::OnRunningGameChanged() +void NoGUIHostInterface::OnRunningGameChanged(const std::string& path, CDImage* image, const std::string& game_code, + const std::string& game_title) { - CommonHostInterface::OnRunningGameChanged(); + CommonHostInterface::OnRunningGameChanged(path, image, game_code, game_title); // TODO: Move to common if (g_settings.apply_game_settings) diff --git a/src/duckstation-nogui/nogui_host_interface.h b/src/duckstation-nogui/nogui_host_interface.h index 373f0dbbd..63185ac7b 100644 --- a/src/duckstation-nogui/nogui_host_interface.h +++ b/src/duckstation-nogui/nogui_host_interface.h @@ -54,7 +54,8 @@ protected: void OnSystemCreated() override; void OnSystemPaused(bool paused) override; void OnSystemDestroyed() override; - void OnRunningGameChanged() override; + void OnRunningGameChanged(const std::string& path, CDImage* image, const std::string& game_code, + const std::string& game_title) override; void RequestExit() override; virtual void PollAndUpdate() override; diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index 836fac668..e6363adc8 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -701,9 +701,10 @@ void QtHostInterface::OnSystemPerformanceCountersUpdated() System::GetAverageFrameTime(), System::GetWorstFrameTime()); } -void QtHostInterface::OnRunningGameChanged() +void QtHostInterface::OnRunningGameChanged(const std::string& path, CDImage* image, const std::string& game_code, + const std::string& game_title) { - CommonHostInterface::OnRunningGameChanged(); + CommonHostInterface::OnRunningGameChanged(path, image, game_code, game_title); applySettings(true); if (!System::IsShutdown()) diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index 87f101dcd..b3c5f7a81 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -2,8 +2,8 @@ #include "common/event.h" #include "core/host_interface.h" #include "core/system.h" -#include "qtutils.h" #include "frontend-common/common_host_interface.h" +#include "qtutils.h" #include #include #include @@ -202,7 +202,8 @@ protected: void OnSystemPaused(bool paused) override; void OnSystemDestroyed() override; void OnSystemPerformanceCountersUpdated() override; - void OnRunningGameChanged() override; + void OnRunningGameChanged(const std::string& path, CDImage* image, const std::string& game_code, + const std::string& game_title) override; void OnSystemStateSaved(bool global, s32 slot) override; void LoadSettings() override; diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index cb2bdcdbf..fb99133b7 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -812,9 +812,10 @@ void CommonHostInterface::OnSystemDestroyed() StopControllerRumble(); } -void CommonHostInterface::OnRunningGameChanged() +void CommonHostInterface::OnRunningGameChanged(const std::string& path, CDImage* image, const std::string& game_code, + const std::string& game_title) { - HostInterface::OnRunningGameChanged(); + HostInterface::OnRunningGameChanged(path, image, game_code, game_title); if (!System::IsShutdown()) { diff --git a/src/frontend-common/common_host_interface.h b/src/frontend-common/common_host_interface.h index a8e28a3db..5dc9512aa 100644 --- a/src/frontend-common/common_host_interface.h +++ b/src/frontend-common/common_host_interface.h @@ -309,7 +309,8 @@ protected: virtual void OnSystemCreated() override; virtual void OnSystemPaused(bool paused) override; virtual void OnSystemDestroyed() override; - virtual void OnRunningGameChanged() override; + virtual void OnRunningGameChanged(const std::string& path, CDImage* image, const std::string& game_code, + const std::string& game_title) override; virtual void OnControllerTypeChanged(u32 slot) override; virtual std::optional GetHostKeyCode(const std::string_view key_code) const;