Merge pull request #8997 from Felk/osd_rgba_to_argb

OnScreenDisplay: fix names rgba -> argb
This commit is contained in:
LC 2020-08-01 21:28:50 -04:00 committed by GitHub
commit dc8dd5a0ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 12 deletions

View File

@ -37,12 +37,12 @@ struct Message
static std::multimap<MessageType, Message> s_messages; static std::multimap<MessageType, Message> s_messages;
static std::mutex s_messages_mutex; static std::mutex s_messages_mutex;
static ImVec4 RGBAToImVec4(const u32 rgba) static ImVec4 ARGBToImVec4(const u32 argb)
{ {
return ImVec4(static_cast<float>((rgba >> 16) & 0xFF) / 255.0f, return ImVec4(static_cast<float>((argb >> 16) & 0xFF) / 255.0f,
static_cast<float>((rgba >> 8) & 0xFF) / 255.0f, static_cast<float>((argb >> 8) & 0xFF) / 255.0f,
static_cast<float>((rgba >> 0) & 0xFF) / 255.0f, static_cast<float>((argb >> 0) & 0xFF) / 255.0f,
static_cast<float>((rgba >> 24) & 0xFF) / 255.0f); static_cast<float>((argb >> 24) & 0xFF) / 255.0f);
} }
static float DrawMessage(int index, const Message& msg, const ImVec2& position, int time_left) static float DrawMessage(int index, const Message& msg, const ImVec2& position, int time_left)
@ -67,7 +67,7 @@ static float DrawMessage(int index, const Message& msg, const ImVec2& position,
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing)) ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing))
{ {
// Use %s in case message contains %. // Use %s in case message contains %.
ImGui::TextColored(RGBAToImVec4(msg.color), "%s", msg.text.c_str()); ImGui::TextColored(ARGBToImVec4(msg.color), "%s", msg.text.c_str());
window_height = window_height =
ImGui::GetWindowSize().y + (WINDOW_PADDING * ImGui::GetIO().DisplayFramebufferScale.y); ImGui::GetWindowSize().y + (WINDOW_PADDING * ImGui::GetIO().DisplayFramebufferScale.y);
} }
@ -78,18 +78,18 @@ static float DrawMessage(int index, const Message& msg, const ImVec2& position,
return window_height; return window_height;
} }
void AddTypedMessage(MessageType type, std::string message, u32 ms, u32 rgba) void AddTypedMessage(MessageType type, std::string message, u32 ms, u32 argb)
{ {
std::lock_guard lock{s_messages_mutex}; std::lock_guard lock{s_messages_mutex};
s_messages.erase(type); s_messages.erase(type);
s_messages.emplace(type, Message(std::move(message), Common::Timer::GetTimeMs() + ms, rgba)); s_messages.emplace(type, Message(std::move(message), Common::Timer::GetTimeMs() + ms, argb));
} }
void AddMessage(std::string message, u32 ms, u32 rgba) void AddMessage(std::string message, u32 ms, u32 argb)
{ {
std::lock_guard lock{s_messages_mutex}; std::lock_guard lock{s_messages_mutex};
s_messages.emplace(MessageType::Typeless, s_messages.emplace(MessageType::Typeless,
Message(std::move(message), Common::Timer::GetTimeMs() + ms, rgba)); Message(std::move(message), Common::Timer::GetTimeMs() + ms, argb));
} }
void DrawMessages() void DrawMessages()

View File

@ -37,9 +37,9 @@ constexpr u32 VERY_LONG = 10000;
}; // namespace Duration }; // namespace Duration
// On-screen message display (colored yellow by default) // On-screen message display (colored yellow by default)
void AddMessage(std::string message, u32 ms = Duration::SHORT, u32 rgba = Color::YELLOW); void AddMessage(std::string message, u32 ms = Duration::SHORT, u32 argb = Color::YELLOW);
void AddTypedMessage(MessageType type, std::string message, u32 ms = Duration::SHORT, void AddTypedMessage(MessageType type, std::string message, u32 ms = Duration::SHORT,
u32 rgba = Color::YELLOW); u32 argb = Color::YELLOW);
// Draw the current messages on the screen. Only call once per frame. // Draw the current messages on the screen. Only call once per frame.
void DrawMessages(); void DrawMessages();