@@ -19,6 +19,15 @@ namespace rsx
1919 template <typename T>
2020 message_item::message_item (const T& msg_id, u64 expiration, std::shared_ptr<atomic_t <u32 >> refs, std::shared_ptr<overlay_element> icon)
2121 {
22+ if constexpr (std::is_same_v<T, localized_string_id>)
23+ {
24+ m_loc_id = msg_id;
25+ }
26+ else if constexpr (std::is_same_v<T, localized_string>)
27+ {
28+ m_loc_id = msg_id.id ;
29+ }
30+
2231 m_visible_duration = expiration;
2332 m_refs = std::move (refs);
2433
@@ -54,6 +63,7 @@ namespace rsx
5463 }
5564 template message_item::message_item(const std::string& msg_id, u64 , std::shared_ptr<atomic_t <u32 >>, std::shared_ptr<overlay_element>);
5665 template message_item::message_item(const localized_string_id& msg_id, u64 , std::shared_ptr<atomic_t <u32 >>, std::shared_ptr<overlay_element>);
66+ template message_item::message_item(const localized_string& msg_id, u64 , std::shared_ptr<atomic_t <u32 >>, std::shared_ptr<overlay_element>);
5767
5868 void message_item::reset_expiration ()
5969 {
@@ -75,11 +85,22 @@ namespace rsx
7585 }
7686 }
7787
88+ bool message_item::id_matches (localized_string_id id) const
89+ {
90+ return m_loc_id == id;
91+ }
92+
7893 bool message_item::text_matches (const std::u32string& text) const
7994 {
8095 return m_text.text == text;
8196 }
8297
98+ void message_item::set_label_text (const std::string& text)
99+ {
100+ m_text.set_text (text);
101+ m_is_compiled = false ;
102+ }
103+
83104 void message_item::set_pos (s16 _x, s16 _y)
84105 {
85106 rounded_rect::set_pos (_x, _y);
@@ -277,19 +298,54 @@ namespace rsx
277298 return cr;
278299 }
279300
280- bool message::message_exists (message_pin_location location, localized_string_id id, bool allow_refresh )
301+ bool message::check_lists (message_pin_location location, std::function< bool (std::deque<message_item>& list)> check_list )
281302 {
282- return message_exists (location, get_localized_u32string (id), allow_refresh);
303+ if (!check_list) return false ;
304+
305+ switch (location)
306+ {
307+ case message_pin_location::bottom_right:
308+ return check_list (m_ready_queue_bottom_right) || check_list (m_visible_items_bottom_right);
309+ case message_pin_location::bottom_left:
310+ return check_list (m_ready_queue_bottom_left) || check_list (m_visible_items_bottom_left);
311+ case message_pin_location::top_right:
312+ return check_list (m_ready_queue_top_right) || check_list (m_visible_items_top_right);
313+ case message_pin_location::top_left:
314+ return check_list (m_ready_queue_top_left) || check_list (m_visible_items_top_left);
315+ }
316+
317+ return false ;
283318 }
284319
285- bool message::message_exists (message_pin_location location, const std::string& msg , bool allow_refresh)
320+ bool message::message_exists (message_pin_location location, localized_string_id id , bool allow_refresh, bool /* compare_id */ )
286321 {
287- return message_exists (location, utf8_to_u32string (msg), allow_refresh);
322+ const auto check_list = [&](std::deque<message_item>& list)
323+ {
324+ return std::any_of (list.begin (), list.end (), [&](message_item& item)
325+ {
326+ if (item.id_matches (id))
327+ {
328+ if (allow_refresh)
329+ {
330+ item.reset_expiration ();
331+ }
332+ return true ;
333+ }
334+ return false ;
335+ });
336+ };
337+
338+ return check_lists (location, check_list);
339+ }
340+
341+ bool message::message_exists (message_pin_location location, const std::string& msg, bool allow_refresh, bool compare_id)
342+ {
343+ return message_exists (location, utf8_to_u32string (msg), allow_refresh, compare_id);
288344 }
289345
290- bool message::message_exists (message_pin_location location, const std::u32string& msg, bool allow_refresh)
346+ bool message::message_exists (message_pin_location location, const std::u32string& msg, bool allow_refresh, bool /* compare_id */ )
291347 {
292- auto check_list = [&](std::deque<message_item>& list)
348+ const auto check_list = [&](std::deque<message_item>& list)
293349 {
294350 return std::any_of (list.begin (), list.end (), [&](message_item& item)
295351 {
@@ -305,19 +361,34 @@ namespace rsx
305361 });
306362 };
307363
308- switch (location)
364+ return check_lists (location, check_list);
365+ }
366+
367+ bool message::message_exists (message_pin_location location, const localized_string& container, bool allow_refresh, bool compare_id)
368+ {
369+ if (compare_id)
309370 {
310- case message_pin_location::bottom_right:
311- return check_list (m_ready_queue_bottom_right) || check_list (m_visible_items_bottom_right);
312- case message_pin_location::bottom_left:
313- return check_list (m_ready_queue_bottom_left) || check_list (m_visible_items_bottom_left);
314- case message_pin_location::top_right:
315- return check_list (m_ready_queue_top_right) || check_list (m_visible_items_top_right);
316- case message_pin_location::top_left:
317- return check_list (m_ready_queue_top_left) || check_list (m_visible_items_top_left);
371+ const auto check_list = [&](std::deque<message_item>& list)
372+ {
373+ return std::any_of (list.begin (), list.end (), [&](message_item& item)
374+ {
375+ if (item.id_matches (container.id ))
376+ {
377+ if (allow_refresh)
378+ {
379+ item.set_label_text (container.str );
380+ item.reset_expiration ();
381+ }
382+ return true ;
383+ }
384+ return false ;
385+ });
386+ };
387+
388+ return check_lists (location, check_list);
318389 }
319390
320- return false ;
391+ return message_exists (location, utf8_to_u32string (container. str ), allow_refresh, compare_id) ;
321392 }
322393
323394 void refresh_message_queue ()
0 commit comments