From 4a1499e0bef16dd6a228d2c0a48f658a6d77febf Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 20 Jan 2019 23:46:48 +0100 Subject: [PATCH] cellMsgDialog: optionally make dialogs blocking and fix exit condition and apply review fixes --- rpcs3/Emu/Cell/Modules/cellGame.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp | 63 ++++++++++++++---------- rpcs3/Emu/Cell/Modules/cellMsgDialog.h | 2 +- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellGame.cpp b/rpcs3/Emu/Cell/Modules/cellGame.cpp index 800e82c7cf..774dccdd45 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGame.cpp @@ -292,7 +292,7 @@ error_code cellGameDataSetSystemVer(vm::cptr systemVersion) error_code cellGameDataExitBroken() { cellGame.warning("cellGameDataExitBroken()"); - return open_exit_dialog("There has been an error!\n\nPlease delete the game's game data.", true); + return open_exit_dialog("There has been an error!\n\nPlease remove the game data for this title.", true); } error_code cellGameBootCheck(vm::ptr type, vm::ptr attributes, vm::ptr size, vm::ptr dirName) diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp b/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp index c7977354c2..55b27f3a62 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp @@ -34,10 +34,39 @@ MsgDialogBase::~MsgDialogBase() 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(u32 type, vm::cptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam) +error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam) { - cellSysutil.warning("open_msg_dialog called. This will call cellMsgDialogOpen2"); - return cellMsgDialogOpen2(type, msgString, callback, userData, extParam); + cellSysutil.warning("open_msg_dialog(is_blocking=%d, type=0x%x, msgString=%s, callback=*0x%x, userData=*0x%x, extParam=*0x%x)", is_blocking, type, msgString, callback, userData, extParam); + + const error_code res = cellMsgDialogOpen2(type, msgString, callback, userData, extParam); + + if (res == CELL_OK && is_blocking) + { + if (auto manager = fxm::get()) + { + while (auto dlg = manager->get()) + { + if (Emu.IsStopped()) + { + break; + } + dlg->refresh(); + } + } + else + { + while (auto dlg = fxm::get()) + { + if (Emu.IsStopped() || dlg->state != MsgDialogState::Open) + { + break; + } + std::this_thread::yield(); + } + } + } + + return res; } void exit_game(s32/* buttonType*/, vm::ptr/* userData*/) @@ -56,10 +85,12 @@ error_code open_exit_dialog(const std::string& message, bool is_exit_requested) callback.set(ppu_function_manager::addr + 8 * FIND_FUNC(exit_game)); } - const error_code res = cellMsgDialogOpen2 + const 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(message), callback, vm::null, vm::null + vm::make_str(message), + callback ); if (res != CELL_OK) @@ -69,26 +100,6 @@ error_code open_exit_dialog(const std::string& message, bool is_exit_requested) { sysutil_send_system_cmd(CELL_SYSUTIL_REQUEST_EXITGAME, 0); } - return CELL_OK; - } - - if (auto manager = fxm::get()) - { - while (auto dlg = manager->get()) - { - dlg->refresh(); - } - } - else - { - while (auto dlg = fxm::get()) - { - if (dlg->state != MsgDialogState::Open) - { - break; - } - std::this_thread::yield(); - } } return CELL_OK; @@ -518,5 +529,5 @@ void cellSysutil_MsgDialog_init() REG_FUNC(cellSysutil, cellMsgDialogAbort); // Helper Function - REG_FUNC(cellSysutil, exit_game); + REG_FUNC(cellSysutil, exit_game).flag(MFF_HIDDEN); } diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h index 97e48bdbfc..75131192f7 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h @@ -82,7 +82,7 @@ enum class MsgDialogState Close, }; -error_code open_msg_dialog(u32 type, vm::cptr msgString, vm::ptr callback = vm::null, vm::ptr userData = vm::null, vm::ptr extParam = vm::null); +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); error_code open_exit_dialog(const std::string& message, bool is_exit_requested); class MsgDialogBase