mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 06:21:26 +12:00
overlays: add internal lock for progress bar texts
This commit is contained in:
parent
be49a80bc7
commit
ebf72eb126
2 changed files with 48 additions and 6 deletions
|
@ -71,6 +71,23 @@ namespace rsx
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (const auto [dirty, text] = text_guard.get_text(); dirty)
|
||||||
|
{
|
||||||
|
u16 text_w, text_h;
|
||||||
|
text_display.set_pos(90, 364);
|
||||||
|
text_display.set_text(text);
|
||||||
|
text_display.measure_text(text_w, text_h);
|
||||||
|
text_display.translate(0, -(text_h - 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (u32 i = 0; i < progress_bars.size(); i++)
|
||||||
|
{
|
||||||
|
if (const auto [dirty, text] = ::at32(bar_text_guard, i).get_text(); dirty)
|
||||||
|
{
|
||||||
|
::at32(progress_bars, i).set_text(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
compiled_resource result;
|
compiled_resource result;
|
||||||
|
|
||||||
update_custom_background();
|
update_custom_background();
|
||||||
|
@ -339,11 +356,7 @@ namespace rsx
|
||||||
|
|
||||||
void message_dialog::set_text(const std::string& text)
|
void message_dialog::set_text(const std::string& text)
|
||||||
{
|
{
|
||||||
u16 text_w, text_h;
|
text_guard.set_text(text);
|
||||||
text_display.set_pos(90, 364);
|
|
||||||
text_display.set_text(text);
|
|
||||||
text_display.measure_text(text_w, text_h);
|
|
||||||
text_display.translate(0, -(text_h - 16));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void message_dialog::update_custom_background()
|
void message_dialog::update_custom_background()
|
||||||
|
@ -415,7 +428,7 @@ namespace rsx
|
||||||
if (index >= num_progress_bars)
|
if (index >= num_progress_bars)
|
||||||
return CELL_MSGDIALOG_ERROR_PARAM;
|
return CELL_MSGDIALOG_ERROR_PARAM;
|
||||||
|
|
||||||
::at32(progress_bars, index).set_text(msg);
|
::at32(bar_text_guard, index).set_text(msg);
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,35 @@ namespace rsx
|
||||||
|
|
||||||
animation_color_interpolate fade_animation;
|
animation_color_interpolate fade_animation;
|
||||||
|
|
||||||
|
struct text_guard_t
|
||||||
|
{
|
||||||
|
std::mutex mutex;
|
||||||
|
std::string text;
|
||||||
|
bool dirty{false};
|
||||||
|
|
||||||
|
void set_text(std::string t)
|
||||||
|
{
|
||||||
|
std::lock_guard lock(mutex);
|
||||||
|
text = std::move(t);
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<bool, std::string> get_text()
|
||||||
|
{
|
||||||
|
if (dirty)
|
||||||
|
{
|
||||||
|
std::lock_guard lock(mutex);
|
||||||
|
dirty = false;
|
||||||
|
return { true, std::move(text) };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { false, {} };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
text_guard_t text_guard{};
|
||||||
|
std::array<text_guard_t, 2> bar_text_guard{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
message_dialog(bool allow_custom_background = false);
|
message_dialog(bool allow_custom_background = false);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue