mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
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.
This commit is contained in:
@ -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<int> s_obscured_pixels_top = 0;
|
||||
struct Message
|
||||
{
|
||||
Message() = default;
|
||||
Message(std::string text_, u32 duration_, u32 color_, std::unique_ptr<Icon> 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> icon;
|
||||
const VideoCommon::CustomTextureData::ArraySlice::Level* icon;
|
||||
std::unique_ptr<AbstractTexture> texture;
|
||||
};
|
||||
static std::multimap<MessageType, Message> 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> 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> 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)));
|
||||
|
Reference in New Issue
Block a user