VideoCommon/OSD: Process OSD messages even when they are disabled.

This commit is contained in:
Jordan Woyak 2020-01-24 11:00:58 -06:00
parent 42c03c4dad
commit c08671c4ce
1 changed files with 20 additions and 18 deletions

View File

@ -94,29 +94,31 @@ void AddMessage(std::string message, u32 ms, u32 rgba)
void DrawMessages() void DrawMessages()
{ {
if (!SConfig::GetInstance().bOnScreenDisplayMessages) const bool draw_messages = SConfig::GetInstance().bOnScreenDisplayMessages;
return;
{
std::lock_guard lock{s_messages_mutex};
const u32 now = Common::Timer::GetTimeMs(); const u32 now = Common::Timer::GetTimeMs();
float current_x = LEFT_MARGIN * ImGui::GetIO().DisplayFramebufferScale.x; const float current_x = LEFT_MARGIN * ImGui::GetIO().DisplayFramebufferScale.x;
float current_y = TOP_MARGIN * ImGui::GetIO().DisplayFramebufferScale.y; float current_y = TOP_MARGIN * ImGui::GetIO().DisplayFramebufferScale.y;
int index = 0; int index = 0;
auto it = s_messages.begin(); std::lock_guard lock{s_messages_mutex};
while (it != s_messages.end())
for (auto it = s_messages.begin(); it != s_messages.end();)
{ {
const Message& msg = it->second; const Message& msg = it->second;
const int time_left = static_cast<int>(msg.timestamp - now); const int time_left = static_cast<int>(msg.timestamp - now);
current_y += DrawMessage(index++, msg, ImVec2(current_x, current_y), time_left);
if (time_left <= 0) if (time_left <= 0)
{
it = s_messages.erase(it); it = s_messages.erase(it);
continue;
}
else else
{
++it; ++it;
} }
if (draw_messages)
current_y += DrawMessage(index++, msg, ImVec2(current_x, current_y), time_left);
} }
} }