summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/OnScreenDisplay.cpp
diff options
context:
space:
mode:
authorMarkus Wick <markus+github@selfnet.de>2015-02-14 10:47:47 +0100
committerMarkus Wick <markus+github@selfnet.de>2015-02-14 10:47:47 +0100
commit405444d4fec446fbcc8665fb8c1b6107220876ec (patch)
tree1aa69f0e9312d7ef7e01f7f486de81751c6b2315 /Source/Core/VideoCommon/OnScreenDisplay.cpp
parent61b19bda3e82b0ed0da4c7a1fabfcf939b0a2ecb (diff)
parent9d5c6c55fe1148c6dc5418a824d2bc84e83d2a76 (diff)
Merge pull request #1803 from lioncash/rgb
OnScreenDisplay: Allow for different colored messages
Diffstat (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp')
-rw-r--r--Source/Core/VideoCommon/OnScreenDisplay.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp
index b25f461336..92b94194d6 100644
--- a/Source/Core/VideoCommon/OnScreenDisplay.cpp
+++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp
@@ -2,6 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
+#include <algorithm>
#include <list>
#include <map>
#include <string>
@@ -21,18 +22,21 @@ namespace OSD
struct Message
{
Message() {}
- Message(const std::string& s, u32 ts) : str(s), timestamp(ts) {}
+ Message(const std::string& s, u32 ts, u32 rgba) : m_str(s), m_timestamp(ts), m_rgba(rgba)
+ {
+ }
- std::string str;
- u32 timestamp;
+ std::string m_str;
+ u32 m_timestamp;
+ u32 m_rgba;
};
static std::multimap<CallbackType, Callback> s_callbacks;
static std::list<Message> s_msgList;
-void AddMessage(const std::string& str, u32 ms)
+void AddMessage(const std::string& str, u32 ms, u32 rgba)
{
- s_msgList.push_back(Message(str, Common::Timer::GetTimeMs() + ms));
+ s_msgList.emplace_back(str, Common::Timer::GetTimeMs() + ms, rgba);
}
void DrawMessages()
@@ -44,19 +48,12 @@ void DrawMessages()
auto it = s_msgList.begin();
while (it != s_msgList.end())
{
- int time_left = (int)(it->timestamp - Common::Timer::GetTimeMs());
- u32 alpha = 255;
-
- if (time_left < 1024)
- {
- alpha = time_left >> 2;
- if (time_left < 0)
- alpha = 0;
- }
+ int time_left = (int)(it->m_timestamp - Common::Timer::GetTimeMs());
+ float alpha = std::max(1.0f, std::min(0.0f, time_left / 1024.0f));
+ u32 color = (it->m_rgba & 0xFFFFFF) | ((u32)((it->m_rgba >> 24) * alpha) << 24);
- alpha <<= 24;
+ g_renderer->RenderText(it->m_str, left, top, color);
- g_renderer->RenderText(it->str, left, top, 0xffff30 | alpha);
top += 15;
if (time_left <= 0)