summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Src/OnScreenDisplay.cpp
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2013-04-13 00:48:53 -0500
committerRyan Houdek <Sonicadvance1@gmail.com>2013-04-13 00:48:53 -0500
commit39a7096711fa991e78fe297960137941b52120eb (patch)
treed007afb5e0c44cc4e7b37e009cd17cb85e81f81d /Source/Core/VideoCommon/Src/OnScreenDisplay.cpp
parentccf1cee2032fa0b419541e795c5b414e91ff00b1 (diff)
Extend our OSD class to support callbacks on init, onframe, and shutdown.
Diffstat (limited to 'Source/Core/VideoCommon/Src/OnScreenDisplay.cpp')
-rw-r--r--Source/Core/VideoCommon/Src/OnScreenDisplay.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/Src/OnScreenDisplay.cpp b/Source/Core/VideoCommon/Src/OnScreenDisplay.cpp
index 10cf5b84af..ffe0766e44 100644
--- a/Source/Core/VideoCommon/Src/OnScreenDisplay.cpp
+++ b/Source/Core/VideoCommon/Src/OnScreenDisplay.cpp
@@ -24,6 +24,8 @@
#include "RenderBase.h"
#include "Timer.h"
+#include <vector>
+
namespace OSD
{
@@ -39,6 +41,26 @@ struct MESSAGE
u32 dwTimeStamp;
};
+class CALLBACK
+{
+private:
+ CallbackPtr m_functionptr;
+ CallbackType m_type;
+ u32 m_data;
+public:
+ CALLBACK(CallbackType OnType, CallbackPtr FuncPtr, u32 UserData)
+ {
+ m_type = OnType;
+ m_functionptr = FuncPtr;
+ m_data = UserData;
+ }
+ void Call()
+ {
+ m_functionptr(m_data);
+ }
+ CallbackType Type() { return m_type; }
+};
+std::vector<CALLBACK> m_callbacks;
static std::list<MESSAGE> s_listMsgs;
void AddMessage(const char* pstr, u32 ms)
@@ -86,4 +108,17 @@ void ClearMessages()
it = s_listMsgs.erase(it);
}
+// On-Screen Display Callbacks
+void AddCallback(CallbackType OnType, CallbackPtr FuncPtr, u32 UserData)
+{
+ m_callbacks.push_back(CALLBACK(OnType, FuncPtr, UserData));
+}
+
+void DoCallbacks(CallbackType OnType)
+{
+ for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
+ if (it->Type() == OnType)
+ it->Call();
+}
+
} // namespace