mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Reformat all the things. Have fun with merge conflicts.
This commit is contained in:
@ -15,20 +15,15 @@
|
||||
#include "VideoCommon/OnScreenDisplay.h"
|
||||
#include "VideoCommon/RenderBase.h"
|
||||
|
||||
|
||||
namespace OSD
|
||||
{
|
||||
|
||||
struct Message
|
||||
{
|
||||
Message() {}
|
||||
Message(const std::string& s, u32 ts, u32 rgba) : m_str(s), m_timestamp(ts), m_rgba(rgba)
|
||||
{
|
||||
}
|
||||
|
||||
std::string m_str;
|
||||
u32 m_timestamp;
|
||||
u32 m_rgba;
|
||||
Message() {}
|
||||
Message(const std::string& s, u32 ts, u32 rgba) : m_str(s), m_timestamp(ts), m_rgba(rgba) {}
|
||||
std::string m_str;
|
||||
u32 m_timestamp;
|
||||
u32 m_rgba;
|
||||
};
|
||||
|
||||
static std::multimap<CallbackType, Callback> s_callbacks;
|
||||
@ -36,55 +31,55 @@ static std::list<Message> s_msgList;
|
||||
|
||||
void AddMessage(const std::string& str, u32 ms, u32 rgba)
|
||||
{
|
||||
s_msgList.emplace_back(str, Common::Timer::GetTimeMs() + ms, rgba);
|
||||
s_msgList.emplace_back(str, Common::Timer::GetTimeMs() + ms, rgba);
|
||||
}
|
||||
|
||||
void DrawMessages()
|
||||
{
|
||||
if (!SConfig::GetInstance().bOnScreenDisplayMessages)
|
||||
return;
|
||||
if (!SConfig::GetInstance().bOnScreenDisplayMessages)
|
||||
return;
|
||||
|
||||
int left = 25, top = 15;
|
||||
auto it = s_msgList.begin();
|
||||
while (it != s_msgList.end())
|
||||
{
|
||||
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);
|
||||
int left = 25, top = 15;
|
||||
auto it = s_msgList.begin();
|
||||
while (it != s_msgList.end())
|
||||
{
|
||||
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);
|
||||
|
||||
g_renderer->RenderText(it->m_str, left, top, color);
|
||||
g_renderer->RenderText(it->m_str, left, top, color);
|
||||
|
||||
top += 15;
|
||||
top += 15;
|
||||
|
||||
if (time_left <= 0)
|
||||
it = s_msgList.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
if (time_left <= 0)
|
||||
it = s_msgList.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void ClearMessages()
|
||||
{
|
||||
s_msgList.clear();
|
||||
s_msgList.clear();
|
||||
}
|
||||
|
||||
// On-Screen Display Callbacks
|
||||
void AddCallback(CallbackType type, Callback cb)
|
||||
{
|
||||
s_callbacks.emplace(type, cb);
|
||||
s_callbacks.emplace(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();
|
||||
}
|
||||
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 == CallbackType::Shutdown)
|
||||
s_callbacks.clear();
|
||||
// Wipe all callbacks on shutdown
|
||||
if (type == CallbackType::Shutdown)
|
||||
s_callbacks.clear();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user