diff options
| author | Shawn Hoffman <godisgovernment@gmail.com> | 2016-10-03 19:37:18 -0700 |
|---|---|---|
| committer | Shawn Hoffman <godisgovernment@gmail.com> | 2016-10-03 19:37:18 -0700 |
| commit | fa5fa8e09473fb8750af2a21fa24dff76970a681 (patch) | |
| tree | b3b111c395d06aa0cbfb2c1175140aa64a5f4394 /Source/Core/VideoCommon/OnScreenDisplay.cpp | |
| parent | 4573cc89fa65a867f991c1e592ad47382f1ee0a5 (diff) | |
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 <thib.gilles@gmail.com>
Date: Sun Aug 7 16:08:41 2016 +0200
Diffstat (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/OnScreenDisplay.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
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<CallbackType, Callback> s_callbacks; static std::multimap<MessageType, Message> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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()) |
