From dc8f3f6eaea51d054be6007713959426763b611d Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Mon, 13 May 2024 00:15:21 -0400 Subject: Refactored Achievement Badges into Texture Layers Achievement badges/icons are refactored into the type CustomTextureData::ArraySlice::Level as that is the data type images loaded from the filesystem will be. This includes everything that uses the badges in the Qt UI and OnScreenDisplay, and similarly removes the OSD::Icon type because Level already contains that information. --- Source/Core/VideoCommon/OnScreenDisplay.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp') diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index bfa8bc5321..c24fee6538 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -20,6 +20,7 @@ #include "VideoCommon/AbstractGfx.h" #include "VideoCommon/AbstractTexture.h" +#include "VideoCommon/Assets/CustomTextureData.h" #include "VideoCommon/TextureConfig.h" namespace OSD @@ -36,8 +37,9 @@ static std::atomic s_obscured_pixels_top = 0; struct Message { Message() = default; - Message(std::string text_, u32 duration_, u32 color_, std::unique_ptr icon_ = nullptr) - : text(std::move(text_)), duration(duration_), color(color_), icon(std::move(icon_)) + Message(std::string text_, u32 duration_, u32 color_, + const VideoCommon::CustomTextureData::ArraySlice::Level* icon_ = nullptr) + : text(std::move(text_)), duration(duration_), color(color_), icon(icon_) { timer.Start(); } @@ -48,7 +50,7 @@ struct Message bool ever_drawn = false; bool should_discard = false; u32 color = 0; - std::unique_ptr icon; + const VideoCommon::CustomTextureData::ArraySlice::Level* icon; std::unique_ptr texture; }; static std::multimap s_messages; @@ -95,13 +97,13 @@ static float DrawMessage(int index, Message& msg, const ImVec2& position, int ti msg.texture = g_gfx->CreateTexture(tex_config); if (msg.texture) { - msg.texture->Load(0, width, height, width, msg.icon->rgba_data.data(), + msg.texture->Load(0, width, height, width, msg.icon->data.data(), sizeof(u32) * width * height); } else { // don't try again next time - msg.icon.reset(); + msg.icon = nullptr; } } @@ -127,7 +129,7 @@ static float DrawMessage(int index, Message& msg, const ImVec2& position, int ti } void AddTypedMessage(MessageType type, std::string message, u32 ms, u32 argb, - std::unique_ptr icon) + const VideoCommon::CustomTextureData::ArraySlice::Level* icon) { std::lock_guard lock{s_messages_mutex}; @@ -141,7 +143,8 @@ void AddTypedMessage(MessageType type, std::string message, u32 ms, u32 argb, s_messages.emplace(type, Message(std::move(message), ms, argb, std::move(icon))); } -void AddMessage(std::string message, u32 ms, u32 argb, std::unique_ptr icon) +void AddMessage(std::string message, u32 ms, u32 argb, + const VideoCommon::CustomTextureData::ArraySlice::Level* icon) { std::lock_guard lock{s_messages_mutex}; s_messages.emplace(MessageType::Typeless, Message(std::move(message), ms, argb, std::move(icon))); -- cgit v1.2.3