cellGame: improve exit functions

This commit is contained in:
Megamouse 2019-01-20 22:57:51 +01:00 committed by Ivan
parent 17a5e0bc98
commit fe79e541dd
3 changed files with 73 additions and 32 deletions

View File

@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
@ -253,17 +253,7 @@ error_code cellHddGameSetSystemVer(vm::cptr<char> systemVersion)
error_code cellHddGameExitBroken()
{
cellGame.warning("cellHddGameExitBroken()");
s32 res = open_msg_dialog(CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON,
vm::make_str("There has been an error!\n\nPlease reinstall the HDD boot game."));
if (res != CELL_OK)
{
return CELL_HDDGAME_ERROR_INTERNAL;
}
sysutil_send_system_cmd(CELL_SYSUTIL_REQUEST_EXITGAME, 0);
return CELL_OK;
return open_exit_dialog("There has been an error!\n\nPlease reinstall the HDD boot game.", true);
}
error_code cellGameDataGetSizeKB(vm::ptr<u32> size)
@ -302,17 +292,7 @@ error_code cellGameDataSetSystemVer(vm::cptr<char> systemVersion)
error_code cellGameDataExitBroken()
{
cellGame.warning("cellGameDataExitBroken()");
s32 res = open_msg_dialog(CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON,
vm::make_str("There has been an error!\n\nPlease delete the game's game data."));
if (res != CELL_OK)
{
return CELL_GAMEDATA_ERROR_INTERNAL;
}
sysutil_send_system_cmd(CELL_SYSUTIL_REQUEST_EXITGAME, 0);
return CELL_OK;
return open_exit_dialog("There has been an error!\n\nPlease delete the game's game data.", true);
}
error_code cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr<CellGameContentSize> size, vm::ptr<char[CELL_GAME_DIRNAME_SIZE]> dirName)
@ -904,12 +884,12 @@ error_code cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, vm::cptr<char
std::string errorName;
switch (type)
{
case CELL_GAME_ERRDIALOG_BROKEN_GAMEDATA: errorName = "Game data is corrupted (can be continued)."; break;
case CELL_GAME_ERRDIALOG_BROKEN_HDDGAME: errorName = "HDD boot game is corrupted (can be continued)."; break;
case CELL_GAME_ERRDIALOG_NOSPACE: errorName = "Not enough available space (can be continued)."; break;
case CELL_GAME_ERRDIALOG_BROKEN_EXIT_GAMEDATA: errorName = "Game data is corrupted (terminate application)."; break;
case CELL_GAME_ERRDIALOG_BROKEN_EXIT_HDDGAME: errorName = "HDD boot game is corrupted (terminate application)."; break;
case CELL_GAME_ERRDIALOG_NOSPACE_EXIT: errorName = "Not enough available space (terminate application)."; break;
case CELL_GAME_ERRDIALOG_BROKEN_GAMEDATA: errorName = "Game data is corrupted. The application will continue."; break;
case CELL_GAME_ERRDIALOG_BROKEN_HDDGAME: errorName = "HDD boot game is corrupted. The application will continue."; break;
case CELL_GAME_ERRDIALOG_NOSPACE: errorName = "Not enough available space. The application will continue."; break;
case CELL_GAME_ERRDIALOG_BROKEN_EXIT_GAMEDATA: errorName = "Game data is corrupted. The application will be terminated."; break;
case CELL_GAME_ERRDIALOG_BROKEN_EXIT_HDDGAME: errorName = "HDD boot game is corrupted. The application will be terminated."; break;
case CELL_GAME_ERRDIALOG_NOSPACE_EXIT: errorName = "Not enough available space. The application will be terminated."; break;
default: return CELL_GAME_ERROR_PARAM;
}
@ -925,12 +905,15 @@ error_code cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, vm::cptr<char
if (dirName)
{
if (!memchr(dirName.get_ptr(), '\0', CELL_GAME_DIRNAME_SIZE))
{
return CELL_GAME_ERROR_PARAM;
}
errorMsg += fmt::format("\nDirectory name: %s", dirName);
}
verify(HERE), CELL_OK == open_msg_dialog(CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON, vm::make_str(errorMsg));
return CELL_OK;
return open_exit_dialog(errorMsg, type > CELL_GAME_ERRDIALOG_NOSPACE);
}
s32 cellGameThemeInstall(vm::cptr<char> usrdirPath, vm::cptr<char> fileName, u32 option)

View File

@ -40,6 +40,60 @@ error_code open_msg_dialog(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDi
return cellMsgDialogOpen2(type, msgString, callback, userData, extParam);
}
void exit_game(s32/* buttonType*/, vm::ptr<void>/* userData*/)
{
sysutil_send_system_cmd(CELL_SYSUTIL_REQUEST_EXITGAME, 0);
}
error_code open_exit_dialog(const std::string& message, bool is_exit_requested)
{
cellSysutil.warning("open_exit_dialog(message=%s, is_exit_requested=%d)", message, is_exit_requested);
vm::bptr<CellMsgDialogCallback> callback = vm::null;
if (is_exit_requested)
{
callback.set(ppu_function_manager::addr + 8 * FIND_FUNC(exit_game));
}
const error_code res = cellMsgDialogOpen2
(
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
);
if (res != CELL_OK)
{
// Something went wrong, exit anyway
if (is_exit_requested)
{
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;
}
error_code cellMsgDialogOpen2(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialogCallback> callback, vm::ptr<void> userData, vm::ptr<void> extParam)
{
cellSysutil.warning("cellMsgDialogOpen2(type=0x%x, msgString=%s, callback=*0x%x, userData=*0x%x, extParam=*0x%x)", type, msgString, callback, userData, extParam);
@ -462,4 +516,7 @@ void cellSysutil_MsgDialog_init()
REG_FUNC(cellSysutil, cellMsgDialogProgressBarInc);
REG_FUNC(cellSysutil, cellMsgDialogClose);
REG_FUNC(cellSysutil, cellMsgDialogAbort);
// Helper Function
REG_FUNC(cellSysutil, exit_game);
}

View File

@ -83,6 +83,7 @@ enum class MsgDialogState
};
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_exit_dialog(const std::string& message, bool is_exit_requested);
class MsgDialogBase
{