diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h index 2cabed3772..485eb647c9 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h @@ -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 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 on_close; std::function 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; + } }; diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index f90635250b..09a91e73c6 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -842,6 +842,7 @@ void GLGSRender::on_init_thread() type.progress_bar_count = 2; dlg = fxm::get()->create(); + dlg->progress_bar_set_taskbar_index(-1); dlg->show("Loading precompiled shaders from disk...", type, [](s32 status) { if (status != CELL_OK) diff --git a/rpcs3/Emu/RSX/Overlays/overlays.cpp b/rpcs3/Emu/RSX/Overlays/overlays.cpp index a68b5d1139..e46ce0660e 100644 --- a/rpcs3/Emu/RSX/Overlays/overlays.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlays.cpp @@ -14,7 +14,15 @@ namespace rsx //Force unload exit = true; if (auto manager = fxm::get()) + { + if (auto dlg = manager->get()) + { + if (dlg->progress_bar_count()) + Emu.GetCallbacks().handle_taskbar_progress(0, 0); + } + manager->remove(uid); + } if (on_close) on_close(return_code); diff --git a/rpcs3/Emu/RSX/Overlays/overlays.h b/rpcs3/Emu/RSX/Overlays/overlays.h index 30b6ae15c1..e1fcd46946 100644 --- a/rpcs3/Emu/RSX/Overlays/overlays.h +++ b/rpcs3/Emu/RSX/Overlays/overlays.h @@ -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; } }; diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 08ebc4b5fb..de44fef148 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -1564,6 +1564,7 @@ void VKGSRender::on_init_thread() type.progress_bar_count = 2; dlg = fxm::get()->create(); + dlg->progress_bar_set_taskbar_index(-1); dlg->show("Loading precompiled shaders from disk...", type, [](s32 status) { if (status != CELL_OK) diff --git a/rpcs3/Emu/RSX/rsx_cache.h b/rpcs3/Emu/RSX/rsx_cache.h index 6957006626..af4a31cc6b 100644 --- a/rpcs3/Emu/RSX/rsx_cache.h +++ b/rpcs3/Emu/RSX/rsx_cache.h @@ -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 dlg; atomic_t 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([]() diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 05c91479f3..70c06af533 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -167,6 +167,7 @@ struct EmuCallbacks std::function on_stop; std::function on_ready; std::function exit; + std::function handle_taskbar_progress; std::function()> get_kb_handler; std::function()> get_mouse_handler; std::function()> get_pad_handler; diff --git a/rpcs3/rpcs3_app.cpp b/rpcs3/rpcs3_app.cpp index 6d83d3a3b1..fe9e45d9a6 100644 --- a/rpcs3/rpcs3_app.cpp +++ b/rpcs3/rpcs3_app.cpp @@ -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)); }