summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/OnScreenDisplay.cpp
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2013-12-07 15:14:29 -0500
committerJasper St. Pierre <jstpierre@mecheye.net>2013-12-31 14:03:19 -0500
commit34692ab826abc8f8faa61bdb2280b742424528f1 (patch)
treeb0eedc645badbea316ff59c125eaf808b28777ec /Source/Core/VideoCommon/OnScreenDisplay.cpp
parent43e618682e8093602fc83dfa902ee7ae3fd3a4f6 (diff)
Remove unnecessary Src/ folders
Diffstat (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp')
-rw-r--r--Source/Core/VideoCommon/OnScreenDisplay.cpp93
1 files changed, 93 insertions, 0 deletions
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 <list>
+
+#include "Common.h"
+
+#include "ConfigManager.h"
+#include "OnScreenDisplay.h"
+#include "RenderBase.h"
+#include "Timer.h"
+
+#include <map>
+#include <string>
+
+namespace OSD
+{
+
+struct Message
+{
+ Message() {}
+ Message(const std::string& s, u32 ts) : str(s), timestamp(ts) {}
+
+ std::string str;
+ u32 timestamp;
+};
+
+static std::multimap<CallbackType, Callback> s_callbacks;
+static std::list<Message> 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<CallbackType, Callback>(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