diff --git a/Common/System/OSD.cpp b/Common/System/OSD.cpp index d8d36ec11b0a..075c73b5c15b 100644 --- a/Common/System/OSD.cpp +++ b/Common/System/OSD.cpp @@ -48,7 +48,7 @@ void OnScreenDisplay::DismissEntry(size_t index, double now) { } } -void OnScreenDisplay::Show(OSDType type, const std::string &text, const std::string &text2, const std::string &icon, float duration_s, const char *id) { +void OnScreenDisplay::Show(OSDType type, std::string_view text, std::string_view text2, std::string_view icon, float duration_s, const char *id) { // Automatic duration based on type. if (duration_s <= 0.0f) { switch (type) { @@ -103,9 +103,12 @@ void OnScreenDisplay::Show(OSDType type, const std::string &text, const std::str entries_.insert(entries_.begin(), msg); } -void OnScreenDisplay::ShowOnOff(const std::string &message, bool on, float duration_s) { +void OnScreenDisplay::ShowOnOff(std::string_view message, bool on, float duration_s) { + std::string msg(message); + msg += ": "; + msg += on ? "on" : "off"; // TODO: translate "on" and "off"? Or just get rid of this whole thing? - Show(OSDType::MESSAGE_INFO, message + ": " + (on ? "on" : "off"), duration_s); + Show(OSDType::MESSAGE_INFO, msg, duration_s); } void OnScreenDisplay::ShowAchievementUnlocked(int achievementID) { diff --git a/Common/System/OSD.h b/Common/System/OSD.h index c1eded390797..5c58e69a3734 100644 --- a/Common/System/OSD.h +++ b/Common/System/OSD.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -33,15 +34,15 @@ enum class OSDType { class OnScreenDisplay { public: // If you specify 0.0f as duration, a duration will be chosen automatically depending on type. - void Show(OSDType type, const std::string &text, float duration_s = 0.0f, const char *id = nullptr) { + void Show(OSDType type, std::string_view text, float duration_s = 0.0f, const char *id = nullptr) { Show(type, text, "", duration_s, id); } - void Show(OSDType type, const std::string &text, const std::string &text2, float duration_s = 0.0f, const char *id = nullptr) { + void Show(OSDType type, std::string_view text, std::string_view text2, float duration_s = 0.0f, const char *id = nullptr) { Show(type, text, text2, "", duration_s, id); } - void Show(OSDType type, const std::string &text, const std::string &text2, const std::string &icon, float duration_s = 0.0f, const char *id = nullptr); + void Show(OSDType type, std::string_view text, std::string_view text2, std::string_view icon, float duration_s = 0.0f, const char *id = nullptr); - void ShowOnOff(const std::string &message, bool on, float duration_s = 0.0f); + void ShowOnOff(std::string_view message, bool on, float duration_s = 0.0f); bool IsEmpty() const { return entries_.empty(); } // Shortcut to skip rendering. diff --git a/Core/Core.cpp b/Core/Core.cpp index ac7347366398..8add9989c863 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -424,13 +424,13 @@ void Core_MemoryException(u32 address, u32 accessSize, u32 pc, MemoryExceptionTy } } -void Core_MemoryExceptionInfo(u32 address, u32 accessSize, u32 pc, MemoryExceptionType type, const std::string &additionalInfo, bool forceReport) { +void Core_MemoryExceptionInfo(u32 address, u32 accessSize, u32 pc, MemoryExceptionType type, std::string_view additionalInfo, bool forceReport) { const char *desc = MemoryExceptionTypeAsString(type); // In jit, we only flush PC when bIgnoreBadMemAccess is off. if ((g_Config.iCpuCore == (int)CPUCore::JIT || g_Config.iCpuCore == (int)CPUCore::JIT_IR) && g_Config.bIgnoreBadMemAccess) { - WARN_LOG(MEMMAP, "%s: Invalid access at %08x (size %08x). %s", desc, address, accessSize, additionalInfo.c_str()); + WARN_LOG(MEMMAP, "%s: Invalid access at %08x (size %08x). %.*s", desc, address, accessSize, (int)additionalInfo.length(), additionalInfo.data()); } else { - WARN_LOG(MEMMAP, "%s: Invalid access at %08x (size %08x) PC %08x LR %08x %s", desc, address, accessSize, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA], additionalInfo.c_str()); + WARN_LOG(MEMMAP, "%s: Invalid access at %08x (size %08x) PC %08x LR %08x %.*s", desc, address, accessSize, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA], (int)additionalInfo.length(), additionalInfo.data()); } if (!g_Config.bIgnoreBadMemAccess || forceReport) { diff --git a/Core/Core.h b/Core/Core.h index dfa7a41a426c..3d55c132f228 100644 --- a/Core/Core.h +++ b/Core/Core.h @@ -18,6 +18,7 @@ #pragma once #include +#include #include "Core/System.h" #include "Core/CoreParameter.h" @@ -107,7 +108,7 @@ enum class ExecExceptionType { // Separate one for without info, to avoid having to allocate a string void Core_MemoryException(u32 address, u32 accessSize, u32 pc, MemoryExceptionType type); -void Core_MemoryExceptionInfo(u32 address, u32 accessSize, u32 pc, MemoryExceptionType type, const std::string &additionalInfo, bool forceReport); +void Core_MemoryExceptionInfo(u32 address, u32 accessSize, u32 pc, MemoryExceptionType type, std::string_view additionalInfo, bool forceReport); void Core_ExecException(u32 address, u32 pc, ExecExceptionType type); void Core_Break(u32 pc); diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index 40fc161a01b4..292f8248320d 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -17,6 +17,8 @@ #include "Common/Serialize/SerializeFuncs.h" #include "Common/LogManager.h" +#include "Common/System/OSD.h" + #include "Core/Core.h" #include "Core/Config.h" #include "Core/CwCheat.h" @@ -314,6 +316,8 @@ void sceKernelExitGame() INFO_LOG(SCEKERNEL, "sceKernelExitGame"); __KernelSwitchOffThread("game exited"); Core_Stop(); + + g_OSD.Show(OSDType::MESSAGE_INFO, "sceKernelExitGame()"); } void sceKernelExitGameWithStatus() @@ -321,6 +325,8 @@ void sceKernelExitGameWithStatus() INFO_LOG(SCEKERNEL, "sceKernelExitGameWithStatus"); __KernelSwitchOffThread("game exited"); Core_Stop(); + + g_OSD.Show(OSDType::MESSAGE_INFO, "sceKernelExitGameWithStatus()"); } u32 sceKernelDevkitVersion()