mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 12:12:50 +01:00
rsx: Implement overlay message queue stacking
This commit is contained in:
parent
2f2fe72808
commit
504bd93007
@ -1,6 +1,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "overlay_message.h"
|
#include "overlay_message.h"
|
||||||
#include "Emu/RSX/RSXThread.h"
|
#include "Emu/RSX/RSXThread.h"
|
||||||
|
#pragma optimize("", off)
|
||||||
|
|
||||||
namespace rsx
|
namespace rsx
|
||||||
{
|
{
|
||||||
@ -38,7 +39,7 @@ namespace rsx
|
|||||||
m_fade_out_animation.duration = 2.f;
|
m_fade_out_animation.duration = 2.f;
|
||||||
m_fade_out_animation.active = true;
|
m_fade_out_animation.active = true;
|
||||||
|
|
||||||
back_color.a = 0.15;
|
back_color = 0.25;
|
||||||
|
|
||||||
if (icon)
|
if (icon)
|
||||||
{
|
{
|
||||||
@ -61,6 +62,11 @@ namespace rsx
|
|||||||
return m_refs && *m_refs == 0 ? 0 : m_expiration_time;
|
return m_refs && *m_refs == 0 ? 0 : m_expiration_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool message_item::text_matches(const std::u32string& text) const
|
||||||
|
{
|
||||||
|
return m_text.text == text;
|
||||||
|
}
|
||||||
|
|
||||||
void message_item::set_pos(u16 _x, u16 _y)
|
void message_item::set_pos(u16 _x, u16 _y)
|
||||||
{
|
{
|
||||||
rounded_rect::set_pos(_x, _y);
|
rounded_rect::set_pos(_x, _y);
|
||||||
@ -199,5 +205,36 @@ namespace rsx
|
|||||||
return cr;
|
return cr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool message::message_exists(message_pin_location location, localized_string_id id)
|
||||||
|
{
|
||||||
|
return message_exists(location, get_localized_u32string(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool message::message_exists(message_pin_location location, const std::string& msg)
|
||||||
|
{
|
||||||
|
return message_exists(location, utf8_to_u32string(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool message::message_exists(message_pin_location location, const std::u32string& msg)
|
||||||
|
{
|
||||||
|
auto check_list = [&](const std::deque<message_item>& list)
|
||||||
|
{
|
||||||
|
return std::any_of(list.cbegin(), list.cend(), [&](const message_item& item)
|
||||||
|
{
|
||||||
|
return item.text_matches(msg);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (location)
|
||||||
|
{
|
||||||
|
case message_pin_location::top:
|
||||||
|
return check_list(m_ready_queue_top) || check_list(m_vis_items_top);
|
||||||
|
case message_pin_location::bottom:
|
||||||
|
return check_list(m_ready_queue_bottom) || check_list(m_vis_items_bottom);
|
||||||
|
default:
|
||||||
|
fmt::throw_exception("Unreachable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace overlays
|
} // namespace overlays
|
||||||
} // namespace rsx
|
} // namespace rsx
|
||||||
|
@ -24,6 +24,8 @@ namespace rsx
|
|||||||
u64 get_expiration() const;
|
u64 get_expiration() const;
|
||||||
compiled_resource& get_compiled() override;
|
compiled_resource& get_compiled() override;
|
||||||
|
|
||||||
|
bool text_matches(const std::u32string& text) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
label m_text{};
|
label m_text{};
|
||||||
std::unique_ptr<overlay_element> m_icon{};
|
std::unique_ptr<overlay_element> m_icon{};
|
||||||
@ -62,10 +64,13 @@ namespace rsx
|
|||||||
{
|
{
|
||||||
for (auto id : msg_id)
|
for (auto id : msg_id)
|
||||||
{
|
{
|
||||||
queue.emplace_back(id, expiration, refs, icon);
|
if (!message_exists(location, id))
|
||||||
|
{
|
||||||
|
queue.emplace_back(id, expiration, refs, icon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (!message_exists(location, msg_id))
|
||||||
{
|
{
|
||||||
queue.emplace_back(msg_id, expiration, std::move(refs), std::move(icon));
|
queue.emplace_back(msg_id, expiration, std::move(refs), std::move(icon));
|
||||||
}
|
}
|
||||||
@ -86,6 +91,11 @@ namespace rsx
|
|||||||
std::deque<message_item> m_vis_items_bottom;
|
std::deque<message_item> m_vis_items_bottom;
|
||||||
|
|
||||||
void update_queue(std::deque<message_item>& vis_set, std::deque<message_item>& ready_set, message_pin_location origin);
|
void update_queue(std::deque<message_item>& vis_set, std::deque<message_item>& ready_set, message_pin_location origin);
|
||||||
|
|
||||||
|
// Stacking. Extends the lifetime of a message instead of inserting a duplicate
|
||||||
|
bool message_exists(message_pin_location location, localized_string_id id);
|
||||||
|
bool message_exists(message_pin_location location, const std::string& msg);
|
||||||
|
bool message_exists(message_pin_location location, const std::u32string& msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
Loading…
Reference in New Issue
Block a user