From fa5fa8e09473fb8750af2a21fa24dff76970a681 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Mon, 3 Oct 2016 19:37:18 -0700 Subject: Clean OSD messages code Some OSD messages were displayed in RenderBase.cpp using global variables and some code duplicated in OnScreeDisplay.cpp. Now all messages are displayed using functions in the OSD namepace. * OSDChoice and OSDTime global variables are gone * All OSD logic is kept at the same place * All messages are properly aligned * Clean characters for all OSD messages Original commit: commit f0ec61c05707c9657baaad096e21cf60abd267f9 Author: Aestek Date: Sun Aug 7 16:08:41 2016 +0200 --- Source/Core/VideoCommon/OnScreenDisplay.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp') diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index 62997cd150..d0f6f24825 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -21,18 +21,24 @@ static std::multimap s_callbacks; static std::multimap s_messages; static std::mutex s_messages_mutex; +static std::string CleanMessage(std::string message) +{ + std::replace_if(message.begin(), message.end(), [](char c) { return !std::isprint(c); }, '?'); + return message; +} + void AddTypedMessage(MessageType type, const std::string& message, u32 ms, u32 rgba) { std::lock_guard lock(s_messages_mutex); s_messages.erase(type); - s_messages.emplace(type, Message(message, Common::Timer::GetTimeMs() + ms, rgba)); + s_messages.emplace(type, Message(CleanMessage(message), Common::Timer::GetTimeMs() + ms, rgba)); } void AddMessage(const std::string& message, u32 ms, u32 rgba) { std::lock_guard lock(s_messages_mutex); s_messages.emplace(MessageType::Typeless, - Message(message, Common::Timer::GetTimeMs() + ms, rgba)); + Message(CleanMessage(message), Common::Timer::GetTimeMs() + ms, rgba)); } void DrawMessage(const Message& msg, int top, int left, int time_left) @@ -52,7 +58,7 @@ void DrawMessages() std::lock_guard lock(s_messages_mutex); u32 now = Common::Timer::GetTimeMs(); - int left = 20, top = 35; + int left = 20, top = 20; auto it = s_messages.begin(); while (it != s_messages.end()) -- cgit v1.2.3