From 34692ab826abc8f8faa61bdb2280b742424528f1 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sat, 7 Dec 2013 15:14:29 -0500 Subject: Remove unnecessary Src/ folders --- Source/Core/VideoCommon/OnScreenDisplay.cpp | 93 +++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Source/Core/VideoCommon/OnScreenDisplay.cpp (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp') diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp new file mode 100644 index 0000000000..90e5c008ef --- /dev/null +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -0,0 +1,93 @@ +// Copyright 2013 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include + +#include "Common.h" + +#include "ConfigManager.h" +#include "OnScreenDisplay.h" +#include "RenderBase.h" +#include "Timer.h" + +#include +#include + +namespace OSD +{ + +struct Message +{ + Message() {} + Message(const std::string& s, u32 ts) : str(s), timestamp(ts) {} + + std::string str; + u32 timestamp; +}; + +static std::multimap s_callbacks; +static std::list s_msgList; + +void AddMessage(const std::string& str, u32 ms) +{ + s_msgList.push_back(Message(str, Common::Timer::GetTimeMs() + ms)); +} + +void DrawMessages() +{ + if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bOnScreenDisplayMessages) + return; + + int left = 25, top = 15; + 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; + } + + alpha <<= 24; + + g_renderer->RenderText(it->str.c_str(), left + 1, top + 1, 0x000000 | alpha); + g_renderer->RenderText(it->str.c_str(), left, top, 0xffff30 | alpha); + top += 15; + + if (time_left <= 0) + it = s_msgList.erase(it); + else + ++it; + } +} + +void ClearMessages() +{ + s_msgList.clear(); +} + +// On-Screen Display Callbacks +void AddCallback(CallbackType type, Callback cb) +{ + s_callbacks.insert(std::pair(type, cb)); +} + +void DoCallbacks(CallbackType type) +{ + auto it_bounds = s_callbacks.equal_range(type); + for (auto it = it_bounds.first; it != it_bounds.second; ++it) + { + it->second(); + } + + // Wipe all callbacks on shutdown + if (type == OSD_SHUTDOWN) + s_callbacks.clear(); +} + +} // namespace -- cgit v1.2.3 From ebb48d019eec1c29a37a406e2db16d7565367faa Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 9 Feb 2014 18:29:13 -0500 Subject: Clean up some struct indentations Also cleaned up the indentations of some variable declarations. --- Source/Core/VideoCommon/OnScreenDisplay.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp') diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index 90e5c008ef..9f14a90526 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -19,8 +19,8 @@ namespace OSD struct Message { - Message() {} - Message(const std::string& s, u32 ts) : str(s), timestamp(ts) {} + Message() {} + Message(const std::string& s, u32 ts) : str(s), timestamp(ts) {} std::string str; u32 timestamp; -- cgit v1.2.3 From 2afe2152712981e21d6bda6f029292ed2b1cf91e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 17 Feb 2014 05:18:15 -0500 Subject: Convert all includes to relative paths. --- Source/Core/VideoCommon/OnScreenDisplay.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp') diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index 9f14a90526..7ea6d55daa 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -3,16 +3,17 @@ // Refer to the license.txt file included. #include +#include +#include -#include "Common.h" +#include "Common/Common.h" +#include "Common/Timer.h" -#include "ConfigManager.h" -#include "OnScreenDisplay.h" -#include "RenderBase.h" -#include "Timer.h" +#include "Core/ConfigManager.h" + +#include "VideoCommon/OnScreenDisplay.h" +#include "VideoCommon/RenderBase.h" -#include -#include namespace OSD { -- cgit v1.2.3 From 31cfc73a09a8685cbab20502b4bc132e98e2feb5 Mon Sep 17 00:00:00 2001 From: Matthew Parlane Date: Tue, 11 Mar 2014 00:30:55 +1300 Subject: Fixes spacing for "for", "while", "switch" and "if" Also moved && and || to ends of lines instead of start. Fixed misc vertical alignments and some { needed newlining. --- Source/Core/VideoCommon/OnScreenDisplay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp') diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index 7ea6d55daa..1e4a8b41ec 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -37,7 +37,7 @@ void AddMessage(const std::string& str, u32 ms) void DrawMessages() { - if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bOnScreenDisplayMessages) + if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bOnScreenDisplayMessages) return; int left = 25, top = 15; -- cgit v1.2.3 From a82675b7d581421fa80d5d5c53253cf1d5c1a26d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 12 Mar 2014 15:33:41 -0400 Subject: Kill off some usages of c_str. Also changes some function params, but this is ok. Some simplifications were also able to be made (ie. killing off strcmps with ==, etc). --- Source/Core/VideoCommon/OnScreenDisplay.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp') diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index 1e4a8b41ec..30f6725ed6 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -56,8 +56,8 @@ void DrawMessages() alpha <<= 24; - g_renderer->RenderText(it->str.c_str(), left + 1, top + 1, 0x000000 | alpha); - g_renderer->RenderText(it->str.c_str(), left, top, 0xffff30 | alpha); + g_renderer->RenderText(it->str, left + 1, top + 1, 0x000000 | alpha); + g_renderer->RenderText(it->str, left, top, 0xffff30 | alpha); top += 15; if (time_left <= 0) -- cgit v1.2.3 From fbc64984ca7de7db10b1a8a4f49002f260c93569 Mon Sep 17 00:00:00 2001 From: Rohit Nirmal Date: Sun, 7 Sep 2014 20:06:58 -0500 Subject: Include CommonTypes.h instead of Common.h. --- Source/Core/VideoCommon/OnScreenDisplay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp') diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index 30f6725ed6..0b553c12d2 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -6,7 +6,7 @@ #include #include -#include "Common/Common.h" +#include "Common/CommonTypes.h" #include "Common/Timer.h" #include "Core/ConfigManager.h" -- cgit v1.2.3 From 3f9b52e555b860247cccfd21814a6ad7e8df4df8 Mon Sep 17 00:00:00 2001 From: degasus Date: Sat, 20 Dec 2014 13:31:41 +0100 Subject: OGL: draw shadows within rasterfont itself --- Source/Core/VideoCommon/OnScreenDisplay.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp') diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index 0b553c12d2..b25f461336 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -56,7 +56,6 @@ void DrawMessages() alpha <<= 24; - g_renderer->RenderText(it->str, left + 1, top + 1, 0x000000 | alpha); g_renderer->RenderText(it->str, left, top, 0xffff30 | alpha); top += 15; -- cgit v1.2.3 From 9d5c6c55fe1148c6dc5418a824d2bc84e83d2a76 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 1 Jan 2015 13:23:34 -0500 Subject: OnScreenDisplay: Allow for different colored messages --- Source/Core/VideoCommon/OnScreenDisplay.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp') 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 #include #include #include @@ -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 s_callbacks; static std::list 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) -- cgit v1.2.3 From cefcb0ace9d363b3679b4e93bcc9ec05f1e5f4f8 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Mon, 18 May 2015 01:08:10 +0200 Subject: Update license headers to GPLv2+ --- Source/Core/VideoCommon/OnScreenDisplay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp') diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index 92b94194d6..c30a7c1473 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -1,5 +1,5 @@ // Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 +// Licensed under GPLv2+ // Refer to the license.txt file included. #include -- cgit v1.2.3 From 30ebb2459eb97ba544547183854775df8460b475 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sun, 24 May 2015 06:55:12 +0200 Subject: Set copyright year to when a file was created --- Source/Core/VideoCommon/OnScreenDisplay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp') diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index c30a7c1473..2f59cf50dd 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -1,4 +1,4 @@ -// Copyright 2013 Dolphin Emulator Project +// Copyright 2009 Dolphin Emulator Project // Licensed under GPLv2+ // Refer to the license.txt file included. -- cgit v1.2.3