diff --git a/rpcs3/Emu/Cell/Modules/cellCrossController.cpp b/rpcs3/Emu/Cell/Modules/cellCrossController.cpp index 270b706ebe..1f28328c78 100644 --- a/rpcs3/Emu/Cell/Modules/cellCrossController.cpp +++ b/rpcs3/Emu/Cell/Modules/cellCrossController.cpp @@ -72,7 +72,7 @@ struct cross_controller msg_dialog_callback.set(g_fxo->get().func_addr(FIND_FUNC(finish_callback))); // TODO: Show icons from comboplay_plugin.rco in dialog. Maybe use a new dialog or add an optional icon to this one. - error_code res = open_msg_dialog(false, CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_OFF, vm::make_str(msg), msg_dialog_callback, userdata); + error_code res = open_msg_dialog(false, CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_OFF, vm::make_str(msg), msg_dialog_source::_cellCrossController, msg_dialog_callback, userdata); sysutil_register_cb([this, res](ppu_thread& ppu) -> s32 { diff --git a/rpcs3/Emu/Cell/Modules/cellGame.cpp b/rpcs3/Emu/Cell/Modules/cellGame.cpp index 6ae7ed6ea1..4ddc29d639 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGame.cpp @@ -579,7 +579,7 @@ error_code cellHddGameCheck(ppu_thread& ppu, u32 version, vm::cptr dirName lv2_obj::sleep(ppu); // Get user confirmation by opening a blocking dialog - error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON, vm::make_str(error_msg)); + error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON, vm::make_str(error_msg), msg_dialog_source::_cellGame); // Reschedule after a blocking dialog returns if (ppu.check_state()) @@ -664,7 +664,7 @@ error_code cellHddGameSetSystemVer(vm::cptr systemVersion) error_code cellHddGameExitBroken() { cellGame.warning("cellHddGameExitBroken()"); - return open_exit_dialog(get_localized_string(localized_string_id::CELL_HDD_GAME_EXIT_BROKEN), true); + return open_exit_dialog(get_localized_string(localized_string_id::CELL_HDD_GAME_EXIT_BROKEN), true, msg_dialog_source::_cellGame); } error_code cellGameDataGetSizeKB(ppu_thread& ppu, vm::ptr size) @@ -723,7 +723,7 @@ error_code cellGameDataSetSystemVer(vm::cptr systemVersion) error_code cellGameDataExitBroken() { cellGame.warning("cellGameDataExitBroken()"); - return open_exit_dialog(get_localized_string(localized_string_id::CELL_GAME_DATA_EXIT_BROKEN), true); + return open_exit_dialog(get_localized_string(localized_string_id::CELL_GAME_DATA_EXIT_BROKEN), true, msg_dialog_source::_cellGame); } error_code cellGameBootCheck(vm::ptr type, vm::ptr attributes, vm::ptr size, vm::ptr dirName) @@ -1198,7 +1198,7 @@ error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr lv2_obj::sleep(ppu); // Get user confirmation by opening a blocking dialog - error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON, vm::make_str(error_msg)); + error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON, vm::make_str(error_msg), msg_dialog_source::_cellGame); // Reschedule after a blocking dialog returns if (ppu.check_state()) @@ -1714,7 +1714,7 @@ error_code cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, vm::cptr CELL_GAME_ERRDIALOG_NOSPACE); + return open_exit_dialog(error_msg, type > CELL_GAME_ERRDIALOG_NOSPACE, msg_dialog_source::_cellGame); } error_code cellGameThemeInstall(vm::cptr usrdirPath, vm::cptr fileName, u32 option) diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp b/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp index 1204ff1773..2b433e999c 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp @@ -33,6 +33,27 @@ void fmt_class_string::format(std::string& out, u64 arg) }); } +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto src) + { + switch (src) + { + case msg_dialog_source::_cellMsgDialog: return "cellMsgDialog"; + case msg_dialog_source::_cellSaveData: return "cellSaveData"; + case msg_dialog_source::_cellGame: return "cellGame"; + case msg_dialog_source::_cellCrossController: return "cellCrossController"; + case msg_dialog_source::_sceNp: return "sceNp"; + case msg_dialog_source::_sceNpTrophy: return "sceNpTrophy"; + case msg_dialog_source::sys_progress: return "sys_progress"; + case msg_dialog_source::shader_loading: return "shader_loading"; + } + + return unknown; + }); +} + MsgDialogBase::~MsgDialogBase() { } @@ -141,9 +162,9 @@ using msg_dlg_thread = named_thread; error_code cellMsgDialogOpen2(u32 type, vm::cptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam); // wrapper to call for other hle dialogs -error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam, s32* return_code) +error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr msgString, msg_dialog_source source, vm::ptr callback, vm::ptr userData, vm::ptr extParam, s32* return_code) { - cellSysutil.notice("open_msg_dialog(is_blocking=%d, type=0x%x, msgString=%s, callback=*0x%x, userData=*0x%x, extParam=*0x%x, return_code=*0x%x)", is_blocking, type, msgString, callback, userData, extParam, return_code); + cellSysutil.notice("open_msg_dialog(is_blocking=%d, type=0x%x, msgString=%s, source=%s, callback=*0x%x, userData=*0x%x, extParam=*0x%x, return_code=*0x%x)", is_blocking, type, msgString, source, callback, userData, extParam, return_code); const MsgDialogType _type{ type }; @@ -166,7 +187,7 @@ error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr msgString, const auto notify = std::make_shared>(0); - const auto res = manager->create()->show(is_blocking, msgString.get_ptr(), _type, [callback, userData, &return_code, is_blocking, notify](s32 status) + const auto res = manager->create()->show(is_blocking, msgString.get_ptr(), _type, source, [callback, userData, &return_code, is_blocking, notify](s32 status) { if (is_blocking && return_code) { @@ -213,6 +234,7 @@ error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr msgString, } dlg->type = _type; + dlg->source = source; dlg->on_close = [callback, userData, is_blocking, &return_code, wptr = std::weak_ptr(dlg)](s32 status) { @@ -318,9 +340,9 @@ void exit_game(s32/* buttonType*/, vm::ptr/* userData*/) sysutil_send_system_cmd(CELL_SYSUTIL_REQUEST_EXITGAME, 0); } -error_code open_exit_dialog(const std::string& message, bool is_exit_requested) +error_code open_exit_dialog(const std::string& message, bool is_exit_requested, msg_dialog_source source) { - cellSysutil.notice("open_exit_dialog(message=%s, is_exit_requested=%d)", message, is_exit_requested); + cellSysutil.notice("open_exit_dialog(message=%s, is_exit_requested=%d, source=%s)", message, is_exit_requested, source); vm::bptr callback = vm::null; @@ -334,6 +356,7 @@ error_code open_exit_dialog(const std::string& message, bool is_exit_requested) true, CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON, vm::make_str(message), + source, callback ); @@ -401,7 +424,7 @@ error_code cellMsgDialogOpen2(u32 type, vm::cptr msgString, vm::ptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam) @@ -496,7 +519,8 @@ error_code cellMsgDialogClose(f32 delay) if (auto manager = g_fxo->try_get()) { - if (auto dlg = manager->get()) + if (auto dlg = manager->get(); + dlg && dlg->source() == msg_dialog_source::_cellMsgDialog) { auto& thr = g_fxo->get(); thr.wait_until = wait_until; @@ -509,7 +533,7 @@ error_code cellMsgDialogClose(f32 delay) const auto dlg = g_fxo->get().get(); - if (!dlg) + if (!dlg || dlg->source != msg_dialog_source::_cellMsgDialog) { return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED; } @@ -526,7 +550,8 @@ error_code cellMsgDialogAbort() if (auto manager = g_fxo->try_get()) { - if (auto dlg = manager->get()) + if (auto dlg = manager->get(); + dlg && dlg->source() == msg_dialog_source::_cellMsgDialog) { g_fxo->get().wait_until = 0; dlg->close(false, true); // this doesn't call on_close @@ -539,7 +564,7 @@ error_code cellMsgDialogAbort() const auto dlg = g_fxo->get().get(); - if (!dlg) + if (!dlg || dlg->source != msg_dialog_source::_cellMsgDialog) { return CELL_OK; // Not CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED, tested on HW. } diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h index 727d0f0cdd..0292c1c620 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h @@ -89,9 +89,21 @@ enum class MsgDialogState Close, }; +enum class msg_dialog_source +{ + _cellMsgDialog, + _cellSaveData, + _cellGame, + _cellCrossController, + _sceNp, + _sceNpTrophy, + sys_progress, + shader_loading, +}; + void close_msg_dialog(); -error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr msgString, vm::ptr callback = vm::null, vm::ptr userData = vm::null, vm::ptr extParam = vm::null, s32* return_code = nullptr); -error_code open_exit_dialog(const std::string& message, bool is_exit_requested); +error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr msgString, msg_dialog_source source, vm::ptr callback = vm::null, vm::ptr userData = vm::null, vm::ptr extParam = vm::null, s32* return_code = nullptr); +error_code open_exit_dialog(const std::string& message, bool is_exit_requested, msg_dialog_source source); class MsgDialogBase { @@ -103,6 +115,7 @@ public: atomic_t state{ MsgDialogState::Close }; MsgDialogType type{}; + msg_dialog_source source = msg_dialog_source::_cellMsgDialog; std::function on_close = nullptr; diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index dee57ac893..fe062bede0 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -333,7 +333,7 @@ static error_code select_and_delete(ppu_thread& ppu) // Get user confirmation by opening a blocking dialog s32 return_code = CELL_MSGDIALOG_BUTTON_NONE; - error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO, vm::make_str(msg), vm::null, vm::null, vm::null, &return_code); + error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO, vm::make_str(msg), msg_dialog_source::_cellSaveData, vm::null, vm::null, vm::null, &return_code); // Reschedule after a blocking dialog returns if (ppu.check_state()) @@ -370,7 +370,7 @@ static error_code select_and_delete(ppu_thread& ppu) lv2_obj::sleep(ppu); // Display success message by opening a blocking dialog (return value should be irrelevant here) - res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK, vm::make_str(msg)); + res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK, vm::make_str(msg), msg_dialog_source::_cellSaveData); // Reschedule after blocking dialog returns if (ppu.check_state()) @@ -423,7 +423,7 @@ static error_code display_callback_result_error_message(ppu_thread& ppu, const C lv2_obj::sleep(ppu); // Get user confirmation by opening a blocking dialog (return value should be irrelevant here) - [[maybe_unused]] error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK, use_invalid_message ? result.invalidMsg : vm::make_str(msg)); + [[maybe_unused]] error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK, use_invalid_message ? result.invalidMsg : vm::make_str(msg), msg_dialog_source::_cellSaveData); // Reschedule after a blocking dialog returns if (ppu.check_state()) @@ -1219,7 +1219,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v // Get user confirmation by opening a blocking dialog s32 return_code = CELL_MSGDIALOG_BUTTON_NONE; - error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO, vm::make_str(message), vm::null, vm::null, vm::null, &return_code); + error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO, vm::make_str(message), msg_dialog_source::_cellSaveData, vm::null, vm::null, vm::null, &return_code); // Reschedule after a blocking dialog returns if (ppu.check_state()) @@ -1350,7 +1350,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v // Get user confirmation by opening a blocking dialog s32 return_code = CELL_MSGDIALOG_BUTTON_NONE; - error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO, vm::make_str(message), vm::null, vm::null, vm::null, &return_code); + error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO, vm::make_str(message), msg_dialog_source::_cellSaveData, vm::null, vm::null, vm::null, &return_code); // Reschedule after a blocking dialog returns if (ppu.check_state()) diff --git a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp index a04ef5bd9c..b3c38bb383 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp @@ -572,7 +572,7 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle, { if (!!(options & SCE_NP_TROPHY_OPTIONS_REGISTER_CONTEXT_SHOW_ERROR_EXIT)) { - static_cast(open_exit_dialog("Error during trophy registration! The game will now be terminated.", true)); + static_cast(open_exit_dialog("Error during trophy registration! The game will now be terminated.", true, msg_dialog_source::_sceNpTrophy)); } }; diff --git a/rpcs3/Emu/RSX/Overlays/Network/overlay_sendmessage_dialog.cpp b/rpcs3/Emu/RSX/Overlays/Network/overlay_sendmessage_dialog.cpp index b93095870a..737b8cf3bc 100644 --- a/rpcs3/Emu/RSX/Overlays/Network/overlay_sendmessage_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/Network/overlay_sendmessage_dialog.cpp @@ -247,7 +247,7 @@ namespace rsx // Hide list visible = false; - error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO, vm::make_str(confirmation_msg), vm::null, vm::null, vm::null, &confirmation_code); + error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO, vm::make_str(confirmation_msg), msg_dialog_source::_sceNp, vm::null, vm::null, vm::null, &confirmation_code); if (res != CELL_OK) { rsx_log.fatal("sendmessage dialog failed to open confirmation dialog (error=%d)", +res); diff --git a/rpcs3/Emu/RSX/Overlays/Shaders/shader_loading_dialog_native.cpp b/rpcs3/Emu/RSX/Overlays/Shaders/shader_loading_dialog_native.cpp index c0d0f4ff93..3546592cfc 100644 --- a/rpcs3/Emu/RSX/Overlays/Shaders/shader_loading_dialog_native.cpp +++ b/rpcs3/Emu/RSX/Overlays/Shaders/shader_loading_dialog_native.cpp @@ -21,7 +21,7 @@ namespace rsx dlg = g_fxo->get().create(true); dlg->progress_bar_set_taskbar_index(-1); - dlg->show(false, msg, type, [](s32 status) + dlg->show(false, msg, type, msg_dialog_source::shader_loading, [](s32 status) { if (status != CELL_OK) { diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp index c6f60d1733..b5318f4c86 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp @@ -201,9 +201,10 @@ namespace rsx fade_animation.update(timestamp_us); } - error_code message_dialog::show(bool is_blocking, const std::string& text, const MsgDialogType& type, std::function on_close) + error_code message_dialog::show(bool is_blocking, const std::string& text, const MsgDialogType& type, msg_dialog_source source, std::function on_close) { visible = false; + m_source = source; num_progress_bars = type.progress_bar_count; if (num_progress_bars) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.h b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.h index 9bfb96d0a7..933510e5c6 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.h @@ -10,6 +10,8 @@ namespace rsx { class message_dialog : public user_interface { + msg_dialog_source m_source = msg_dialog_source::_cellMsgDialog; + label text_display; image_button btn_ok; image_button btn_cancel; @@ -44,7 +46,7 @@ namespace rsx void on_button_pressed(pad_button button_press, bool is_auto_repeat) override; void close(bool use_callback, bool stop_pad_interception) override; - error_code show(bool is_blocking, const std::string& text, const MsgDialogType& type, std::function on_close); + error_code show(bool is_blocking, const std::string& text, const MsgDialogType& type, msg_dialog_source source, std::function on_close); void set_text(std::string text); void update_custom_background(); @@ -56,6 +58,8 @@ namespace rsx error_code progress_bar_set_value(u32 index, f32 value); error_code progress_bar_reset(u32 index); error_code progress_bar_set_limit(u32 index, u32 limit); + + msg_dialog_source source() const { return m_source; } }; } } diff --git a/rpcs3/Emu/system_progress.cpp b/rpcs3/Emu/system_progress.cpp index 33c80a8d4d..3d6f1bb4b1 100644 --- a/rpcs3/Emu/system_progress.cpp +++ b/rpcs3/Emu/system_progress.cpp @@ -130,7 +130,7 @@ void progress_dialog_server::operator()() type.progress_bar_count = 1; native_dlg = manager->create(true); - native_dlg->show(false, text0, type, nullptr); + native_dlg->show(false, text0, type, msg_dialog_source::sys_progress, nullptr); native_dlg->progress_bar_set_message(0, "Please wait"); } }