diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index 0ca005fb4a..a2683b27bf 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -2,7 +2,10 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "VideoCommon/OnScreenDisplay.h" + #include +#include #include #include #include @@ -12,12 +15,11 @@ #include "AudioCommon/AudioCommon.h" #include "Common/CommonTypes.h" -#include "Common/Timer.h" #include "Common/Config/Config.h" +#include "Common/Timer.h" #include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Slippi/SlippiPlayback.h" -#include "VideoCommon/OnScreenDisplay.h" #ifdef IS_PLAYBACK #ifndef IMGUI_DEFINE_MATH_OPERATORS @@ -39,6 +41,9 @@ constexpr float LEFT_MARGIN = 10.0f; // Pixels to the left of OSD messages. constexpr float TOP_MARGIN = 10.0f; // Pixels above the first OSD message. constexpr float WINDOW_PADDING = 4.0f; // Pixels between subsequent OSD messages. +static std::atomic s_obscured_pixels_left = 0; +static std::atomic s_obscured_pixels_top = 0; + struct Message { Message() = default; @@ -53,12 +58,12 @@ struct Message static std::multimap s_messages; static std::mutex s_messages_mutex; -static ImVec4 RGBAToImVec4(const u32 rgba) +static ImVec4 ARGBToImVec4(const u32 argb) { - return ImVec4(static_cast((rgba >> 16) & 0xFF) / 255.0f, - static_cast((rgba >> 8) & 0xFF) / 255.0f, - static_cast((rgba >> 0) & 0xFF) / 255.0f, - static_cast((rgba >> 24) & 0xFF) / 255.0f); + return ImVec4(static_cast((argb >> 16) & 0xFF) / 255.0f, + static_cast((argb >> 8) & 0xFF) / 255.0f, + static_cast((argb >> 0) & 0xFF) / 255.0f, + static_cast((argb >> 24) & 0xFF) / 255.0f); } static float DrawMessage(int index, const Message& msg, const ImVec2& position, int time_left) @@ -83,7 +88,7 @@ static float DrawMessage(int index, const Message& msg, const ImVec2& position, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing)) { // 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 = ImGui::GetWindowSize().y + (WINDOW_PADDING * ImGui::GetIO().DisplayFramebufferScale.y); } @@ -94,26 +99,27 @@ static float DrawMessage(int index, const Message& msg, const ImVec2& position, 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}; 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}; 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() { const bool draw_messages = Config::Get(Config::MAIN_OSD_MESSAGES); const u32 now = Common::Timer::GetTimeMs(); - const float current_x = LEFT_MARGIN * ImGui::GetIO().DisplayFramebufferScale.x; - float current_y = TOP_MARGIN * ImGui::GetIO().DisplayFramebufferScale.y; + const float current_x = + LEFT_MARGIN * ImGui::GetIO().DisplayFramebufferScale.x + s_obscured_pixels_left; + float current_y = TOP_MARGIN * ImGui::GetIO().DisplayFramebufferScale.y + s_obscured_pixels_top; int index = 0; std::lock_guard lock{s_messages_mutex}; @@ -144,6 +150,16 @@ void ClearMessages() s_messages.clear(); } +void SetObscuredPixelsLeft(int width) +{ + s_obscured_pixels_left = width; +} + +void SetObscuredPixelsTop(int height) +{ + s_obscured_pixels_top = height; +} + #ifdef IS_PLAYBACK static float height = 1080.0f; static float scaled_height = height;