diff options
| author | Tilka <tilkax@gmail.com> | 2025-08-31 00:27:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-31 00:27:23 +0100 |
| commit | 033a0540f7d76feb7d9eef6be99977da3142e415 (patch) | |
| tree | 4500bc0e0c7fc61563a702b13b6ae4ee9331f07b /Source | |
| parent | 76c114a02b1cf1ad19dafcc33ec2bc2501f7cbd8 (diff) | |
| parent | 64a20c74fc0824c43921840c46090c33264d4f67 (diff) | |
Merge pull request #13899 from SuperSamus/patch-cheats-osd
PatchEngine: OSD message showing number of enabled patches and cheats
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/ActionReplay.cpp | 9 | ||||
| -rw-r--r-- | Source/Core/Core/ActionReplay.h | 1 | ||||
| -rw-r--r-- | Source/Core/Core/GeckoCode.cpp | 9 | ||||
| -rw-r--r-- | Source/Core/Core/GeckoCode.h | 1 | ||||
| -rw-r--r-- | Source/Core/Core/PatchEngine.cpp | 13 |
5 files changed, 33 insertions, 0 deletions
diff --git a/Source/Core/Core/ActionReplay.cpp b/Source/Core/Core/ActionReplay.cpp index 8cef176415..f0a77d7451 100644 --- a/Source/Core/Core/ActionReplay.cpp +++ b/Source/Core/Core/ActionReplay.cpp @@ -174,6 +174,15 @@ void AddCode(ARCode code) } } +size_t CountEnabledCodes() +{ + if (!Config::AreCheatsEnabled()) + return 0; + + std::lock_guard guard(s_lock); + return s_active_codes.size(); +} + void LoadAndApplyCodes(const Common::IniFile& global_ini, const Common::IniFile& local_ini, const std::string& game_id, u16 revision) { diff --git a/Source/Core/Core/ActionReplay.h b/Source/Core/Core/ActionReplay.h index 104b3a6c6e..694493ecb7 100644 --- a/Source/Core/Core/ActionReplay.h +++ b/Source/Core/Core/ActionReplay.h @@ -50,6 +50,7 @@ void SetSyncedCodesAsActive(); void UpdateSyncedCodes(std::span<const ARCode> codes); std::vector<ARCode> ApplyAndReturnCodes(std::span<const ARCode> codes); void AddCode(ARCode new_code); +size_t CountEnabledCodes(); void LoadAndApplyCodes(const Common::IniFile& global_ini, const Common::IniFile& local_ini, const std::string& game_id, u16 revision); diff --git a/Source/Core/Core/GeckoCode.cpp b/Source/Core/Core/GeckoCode.cpp index 62d2dc5481..5f6ddc4cb0 100644 --- a/Source/Core/Core/GeckoCode.cpp +++ b/Source/Core/Core/GeckoCode.cpp @@ -50,6 +50,15 @@ static std::vector<GeckoCode> s_active_codes; static std::vector<GeckoCode> s_synced_codes; static std::mutex s_active_codes_lock; +size_t CountEnabledCodes() +{ + if (!Config::AreCheatsEnabled()) + return 0; + + std::lock_guard guard(s_active_codes_lock); + return s_active_codes.size(); +} + void SetActiveCodes(std::span<const GeckoCode> gcodes, const std::string& game_id, u16 revision) { std::lock_guard lk(s_active_codes_lock); diff --git a/Source/Core/Core/GeckoCode.h b/Source/Core/Core/GeckoCode.h index 0746db0d21..716bcf9f16 100644 --- a/Source/Core/Core/GeckoCode.h +++ b/Source/Core/Core/GeckoCode.h @@ -60,6 +60,7 @@ constexpr u32 HLE_TRAMPOLINE_ADDRESS = INSTALLER_END_ADDRESS - 4; // preserve the emulation performance. constexpr u32 MAGIC_GAMEID = 0xD01F1BAD; +size_t CountEnabledCodes(); void SetActiveCodes(std::span<const GeckoCode> gcodes, const std::string& game_id, u16 revision); void SetSyncedCodesAsActive(); void UpdateSyncedCodes(std::span<const GeckoCode> gcodes); diff --git a/Source/Core/Core/PatchEngine.cpp b/Source/Core/Core/PatchEngine.cpp index 44e5ecedc8..b7dc594858 100644 --- a/Source/Core/Core/PatchEngine.cpp +++ b/Source/Core/Core/PatchEngine.cpp @@ -35,6 +35,7 @@ #include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" #include "Core/System.h" +#include "VideoCommon/OnScreenDisplay.h" namespace PatchEngine { @@ -200,6 +201,18 @@ void LoadPatches() ActionReplay::LoadAndApplyCodes(globalIni, localIni, sconfig.GetGameID(), sconfig.GetRevision()); } + + const size_t enabled_patch_count = + std::ranges::count_if(s_on_frame, [](Patch patch) { return patch.enabled; }); + if (enabled_patch_count > 0) + { + OSD::AddMessage(fmt::format("{} game patch(es) enabled", enabled_patch_count), + OSD::Duration::NORMAL); + } + + const size_t enabled_cheat_count = ActionReplay::CountEnabledCodes() + Gecko::CountEnabledCodes(); + if (enabled_cheat_count > 0) + OSD::AddMessage(fmt::format("{} cheat(s) enabled", enabled_cheat_count), OSD::Duration::NORMAL); } static void ApplyPatches(const Core::CPUThreadGuard& guard, const std::vector<Patch>& patches) |
