cellMsgDialog: optionally make dialogs blocking and fix exit condition

and apply review fixes
This commit is contained in:
Megamouse 2019-01-20 23:46:48 +01:00 committed by Ivan
parent fe79e541dd
commit 4a1499e0be
3 changed files with 39 additions and 28 deletions

View File

@ -292,7 +292,7 @@ error_code cellGameDataSetSystemVer(vm::cptr<char> systemVersion)
error_code cellGameDataExitBroken() error_code cellGameDataExitBroken()
{ {
cellGame.warning("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<u32> type, vm::ptr<u32> attributes, vm::ptr<CellGameContentSize> size, vm::ptr<char[CELL_GAME_DIRNAME_SIZE]> dirName) error_code cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr<CellGameContentSize> size, vm::ptr<char[CELL_GAME_DIRNAME_SIZE]> dirName)

View File

@ -34,10 +34,39 @@ MsgDialogBase::~MsgDialogBase()
error_code cellMsgDialogOpen2(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialogCallback> callback, vm::ptr<void> userData, vm::ptr<void> extParam); error_code cellMsgDialogOpen2(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialogCallback> callback, vm::ptr<void> userData, vm::ptr<void> extParam);
// wrapper to call for other hle dialogs // wrapper to call for other hle dialogs
error_code open_msg_dialog(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialogCallback> callback, vm::ptr<void> userData, vm::ptr<void> extParam) error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialogCallback> callback, vm::ptr<void> userData, vm::ptr<void> extParam)
{ {
cellSysutil.warning("open_msg_dialog called. This will call cellMsgDialogOpen2"); 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);
return cellMsgDialogOpen2(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<rsx::overlays::display_manager>())
{
while (auto dlg = manager->get<rsx::overlays::message_dialog>())
{
if (Emu.IsStopped())
{
break;
}
dlg->refresh();
}
}
else
{
while (auto dlg = fxm::get<MsgDialogBase>())
{
if (Emu.IsStopped() || dlg->state != MsgDialogState::Open)
{
break;
}
std::this_thread::yield();
}
}
}
return res;
} }
void exit_game(s32/* buttonType*/, vm::ptr<void>/* userData*/) void exit_game(s32/* buttonType*/, vm::ptr<void>/* 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)); 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, 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) 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); sysutil_send_system_cmd(CELL_SYSUTIL_REQUEST_EXITGAME, 0);
} }
return CELL_OK;
}
if (auto manager = fxm::get<rsx::overlays::display_manager>())
{
while (auto dlg = manager->get<rsx::overlays::message_dialog>())
{
dlg->refresh();
}
}
else
{
while (auto dlg = fxm::get<MsgDialogBase>())
{
if (dlg->state != MsgDialogState::Open)
{
break;
}
std::this_thread::yield();
}
} }
return CELL_OK; return CELL_OK;
@ -518,5 +529,5 @@ void cellSysutil_MsgDialog_init()
REG_FUNC(cellSysutil, cellMsgDialogAbort); REG_FUNC(cellSysutil, cellMsgDialogAbort);
// Helper Function // Helper Function
REG_FUNC(cellSysutil, exit_game); REG_FUNC(cellSysutil, exit_game).flag(MFF_HIDDEN);
} }

View File

@ -82,7 +82,7 @@ enum class MsgDialogState
Close, Close,
}; };
error_code open_msg_dialog(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialogCallback> callback = vm::null, vm::ptr<void> userData = vm::null, vm::ptr<void> extParam = vm::null); error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialogCallback> callback = vm::null, vm::ptr<void> userData = vm::null, vm::ptr<void> extParam = vm::null);
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);
class MsgDialogBase class MsgDialogBase