mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 03:25:16 +00:00
RSX: add taskbar progress to native ui progress dialogs
This commit is contained in:
parent
17250bc2d4
commit
4003aacc6a
8 changed files with 71 additions and 6 deletions
|
@ -73,14 +73,15 @@ enum class MsgDialogState
|
|||
|
||||
class MsgDialogBase
|
||||
{
|
||||
protected:
|
||||
// the progressbar that will be represented in the taskbar. Use -1 to combine the progress.
|
||||
s32 taskbar_index = 0;
|
||||
|
||||
public:
|
||||
atomic_t<MsgDialogState> state{ MsgDialogState::Open };
|
||||
|
||||
MsgDialogType type{};
|
||||
|
||||
// the progressbar that will be represented in the taskbar. Use -1 to combine the progress.
|
||||
s32 taskbar_index = 0;
|
||||
|
||||
std::function<void(s32 status)> on_close;
|
||||
std::function<void()> on_osk_input_entered;
|
||||
|
||||
|
@ -92,4 +93,9 @@ public:
|
|||
virtual void ProgressBarReset(u32 progressBarIndex) = 0;
|
||||
virtual void ProgressBarInc(u32 progressBarIndex, u32 delta) = 0;
|
||||
virtual void ProgressBarSetLimit(u32 index, u32 limit) = 0;
|
||||
|
||||
void ProgressBarSetTaskbarIndex(s32 index)
|
||||
{
|
||||
taskbar_index = index;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -842,6 +842,7 @@ void GLGSRender::on_init_thread()
|
|||
type.progress_bar_count = 2;
|
||||
|
||||
dlg = fxm::get<rsx::overlays::display_manager>()->create<rsx::overlays::message_dialog>();
|
||||
dlg->progress_bar_set_taskbar_index(-1);
|
||||
dlg->show("Loading precompiled shaders from disk...", type, [](s32 status)
|
||||
{
|
||||
if (status != CELL_OK)
|
||||
|
|
|
@ -14,7 +14,15 @@ namespace rsx
|
|||
//Force unload
|
||||
exit = true;
|
||||
if (auto manager = fxm::get<display_manager>())
|
||||
{
|
||||
if (auto dlg = manager->get<rsx::overlays::message_dialog>())
|
||||
{
|
||||
if (dlg->progress_bar_count())
|
||||
Emu.GetCallbacks().handle_taskbar_progress(0, 0);
|
||||
}
|
||||
|
||||
manager->remove(uid);
|
||||
}
|
||||
|
||||
if (on_close)
|
||||
on_close(return_code);
|
||||
|
|
|
@ -722,6 +722,8 @@ namespace rsx
|
|||
overlay_element bottom_bar, background;
|
||||
progress_bar progress_1, progress_2;
|
||||
u8 num_progress_bars = 0;
|
||||
s32 taskbar_index = 0;
|
||||
s32 taskbar_limit = 0;
|
||||
|
||||
bool interactive = false;
|
||||
bool ok_only = false;
|
||||
|
@ -900,6 +902,16 @@ namespace rsx
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
u32 progress_bar_count()
|
||||
{
|
||||
return num_progress_bars;
|
||||
}
|
||||
|
||||
void progress_bar_set_taskbar_index(s32 index)
|
||||
{
|
||||
taskbar_index = index;
|
||||
}
|
||||
|
||||
s32 progress_bar_set_message(u32 index, const std::string& msg)
|
||||
{
|
||||
if (index >= num_progress_bars)
|
||||
|
@ -923,6 +935,9 @@ namespace rsx
|
|||
else
|
||||
progress_2.inc(value);
|
||||
|
||||
if (index == taskbar_index || taskbar_index == -1)
|
||||
Emu.GetCallbacks().handle_taskbar_progress(1, value);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -936,6 +951,8 @@ namespace rsx
|
|||
else
|
||||
progress_2.set_value(0.f);
|
||||
|
||||
Emu.GetCallbacks().handle_taskbar_progress(0, 0);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -949,6 +966,17 @@ namespace rsx
|
|||
else
|
||||
progress_2.set_limit((float)limit);
|
||||
|
||||
if (index == taskbar_index)
|
||||
{
|
||||
taskbar_limit = limit;
|
||||
Emu.GetCallbacks().handle_taskbar_progress(2, taskbar_limit);
|
||||
}
|
||||
else if (taskbar_index == -1)
|
||||
{
|
||||
taskbar_limit += limit;
|
||||
Emu.GetCallbacks().handle_taskbar_progress(2, taskbar_limit);
|
||||
}
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1564,6 +1564,7 @@ void VKGSRender::on_init_thread()
|
|||
type.progress_bar_count = 2;
|
||||
|
||||
dlg = fxm::get<rsx::overlays::display_manager>()->create<rsx::overlays::message_dialog>();
|
||||
dlg->progress_bar_set_taskbar_index(-1);
|
||||
dlg->show("Loading precompiled shaders from disk...", type, [](s32 status)
|
||||
{
|
||||
if (status != CELL_OK)
|
||||
|
|
|
@ -404,8 +404,6 @@ namespace rsx
|
|||
|
||||
struct progress_dialog_helper
|
||||
{
|
||||
s32 taskbar_index = -1; // -1 to combine all progressbars in the taskbar progress
|
||||
|
||||
std::shared_ptr<MsgDialogBase> dlg;
|
||||
atomic_t<bool> initialized{ false };
|
||||
|
||||
|
@ -415,7 +413,7 @@ namespace rsx
|
|||
dlg->type.se_normal = true;
|
||||
dlg->type.bg_invisible = true;
|
||||
dlg->type.progress_bar_count = 2;
|
||||
dlg->taskbar_index = taskbar_index;
|
||||
dlg->ProgressBarSetTaskbarIndex(-1); // -1 to combine all progressbars in the taskbar progress
|
||||
dlg->on_close = [](s32 status)
|
||||
{
|
||||
Emu.CallAfter([]()
|
||||
|
|
|
@ -167,6 +167,7 @@ struct EmuCallbacks
|
|||
std::function<void()> on_stop;
|
||||
std::function<void()> on_ready;
|
||||
std::function<void()> exit;
|
||||
std::function<void(s32, s32)> handle_taskbar_progress;
|
||||
std::function<std::shared_ptr<class KeyboardHandlerBase>()> get_kb_handler;
|
||||
std::function<std::shared_ptr<class MouseHandlerBase>()> get_mouse_handler;
|
||||
std::function<std::shared_ptr<class pad_thread>()> get_pad_handler;
|
||||
|
|
|
@ -275,6 +275,28 @@ void rpcs3_app::InitializeCallbacks()
|
|||
callbacks.on_stop = [=]() { OnEmulatorStop(); };
|
||||
callbacks.on_ready = [=]() { OnEmulatorReady(); };
|
||||
|
||||
callbacks.handle_taskbar_progress = [=](s32 type, s32 value)
|
||||
{
|
||||
if (gameWindow)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
((gs_frame*)gameWindow)->progress_reset();
|
||||
break;
|
||||
case 1:
|
||||
((gs_frame*)gameWindow)->progress_increment(value);
|
||||
break;
|
||||
case 2:
|
||||
((gs_frame*)gameWindow)->progress_set_limit(value);
|
||||
break;
|
||||
default:
|
||||
LOG_FATAL(GENERAL, "Unknown type in handle_taskbar_progress(type=%d, value=%d)", type, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Emu.SetCallbacks(std::move(callbacks));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue