From fcc1abc7c3a31e5084a14131d4d4ec78c6cde8a8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 8 Feb 2023 19:02:37 -0800 Subject: [PATCH] Dialog: Update by button flag consistently. Always check for the flag to change in Update(). --- Core/Dialog/PSPDialog.cpp | 17 +++++++++++++++++ Core/Dialog/PSPDialog.h | 2 ++ Core/Dialog/PSPGamedataInstallDialog.cpp | 3 +++ Core/Dialog/PSPMsgDialog.cpp | 14 ++------------ Core/Dialog/PSPNetconfDialog.cpp | 13 ++----------- Core/Dialog/PSPNpSigninDialog.cpp | 13 ++----------- Core/Dialog/PSPPlaceholderDialog.cpp | 2 ++ Core/Dialog/PSPSaveDialog.cpp | 12 ++---------- Core/Dialog/PSPScreenshotDialog.cpp | 2 ++ 9 files changed, 34 insertions(+), 44 deletions(-) diff --git a/Core/Dialog/PSPDialog.cpp b/Core/Dialog/PSPDialog.cpp index 7fddd2c642..1ede717e24 100644 --- a/Core/Dialog/PSPDialog.cpp +++ b/Core/Dialog/PSPDialog.cpp @@ -39,6 +39,23 @@ PSPDialog::PSPDialog(UtilityDialogType type) : dialogType_(type) { PSPDialog::~PSPDialog() { } +void PSPDialog::InitCommon() { + UpdateCommon(); +} + +void PSPDialog::UpdateCommon() { + okButtonImg = ImageID("I_CIRCLE"); + cancelButtonImg = ImageID("I_CROSS"); + okButtonFlag = CTRL_CIRCLE; + cancelButtonFlag = CTRL_CROSS; + if (GetCommonParam() && GetCommonParam()->buttonSwap == 1) { + okButtonImg = ImageID("I_CROSS"); + cancelButtonImg = ImageID("I_CIRCLE"); + okButtonFlag = CTRL_CROSS; + cancelButtonFlag = CTRL_CIRCLE; + } +} + PSPDialog::DialogStatus PSPDialog::GetStatus() { if (pendingStatusTicks != 0 && CoreTiming::GetTicks() >= pendingStatusTicks) { bool changeAllowed = true; diff --git a/Core/Dialog/PSPDialog.h b/Core/Dialog/PSPDialog.h index 0489a0d2b8..641829c4d4 100644 --- a/Core/Dialog/PSPDialog.h +++ b/Core/Dialog/PSPDialog.h @@ -89,6 +89,8 @@ public: int FinishShutdown(); protected: + void InitCommon(); + void UpdateCommon(); PPGeStyle FadedStyle(PPGeAlign align, float scale); PPGeImageStyle FadedImageStyle(); void UpdateButtons(); diff --git a/Core/Dialog/PSPGamedataInstallDialog.cpp b/Core/Dialog/PSPGamedataInstallDialog.cpp index 22ef058313..0f43cfbc4d 100644 --- a/Core/Dialog/PSPGamedataInstallDialog.cpp +++ b/Core/Dialog/PSPGamedataInstallDialog.cpp @@ -97,6 +97,7 @@ int PSPGamedataInstallDialog::Init(u32 paramAddr) { memset(&request, 0, sizeof(request)); // Only copy the right size to support different request format Memory::Memcpy(&request, paramAddr, size, "sceGamedataInstallInitStart"); + InitCommon(); ChangeStatusInit(GAMEDATA_INIT_DELAY_US); return 0; @@ -114,6 +115,8 @@ int PSPGamedataInstallDialog::Update(int animSpeed) { return 0; } + UpdateCommon(); + // TODO: param->mode == 1 should show a prompt to confirm, then a progress bar. // Any other mode (i.e. 0 or negative) should proceed and show no UI. diff --git a/Core/Dialog/PSPMsgDialog.cpp b/Core/Dialog/PSPMsgDialog.cpp index b681319aab..cffce18219 100755 --- a/Core/Dialog/PSPMsgDialog.cpp +++ b/Core/Dialog/PSPMsgDialog.cpp @@ -140,6 +140,7 @@ int PSPMsgDialog::Init(unsigned int paramAddr) { ChangeStatusInit(MSG_INIT_DELAY_US); UpdateButtons(); + InitCommon(); StartFade(true); return 0; } @@ -282,20 +283,9 @@ int PSPMsgDialog::Update(int animSpeed) { ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0); } else { UpdateButtons(); + UpdateCommon(); UpdateFade(animSpeed); - okButtonImg = ImageID("I_CIRCLE"); - cancelButtonImg = ImageID("I_CROSS"); - okButtonFlag = CTRL_CIRCLE; - cancelButtonFlag = CTRL_CROSS; - if (messageDialog.common.buttonSwap == 1) - { - okButtonImg = ImageID("I_CROSS"); - cancelButtonImg = ImageID("I_CIRCLE"); - okButtonFlag = CTRL_CROSS; - cancelButtonFlag = CTRL_CIRCLE; - } - StartDraw(); // white -> RGB(168,173,189), black -> RGB(129,134,150) // (255 - a) + (x * a / 255) = 173, x * a / 255 = 134 diff --git a/Core/Dialog/PSPNetconfDialog.cpp b/Core/Dialog/PSPNetconfDialog.cpp index bb9340471c..72d7bf7667 100644 --- a/Core/Dialog/PSPNetconfDialog.cpp +++ b/Core/Dialog/PSPNetconfDialog.cpp @@ -73,18 +73,8 @@ int PSPNetconfDialog::Init(u32 paramAddr) { ChangeStatusInit(NET_INIT_DELAY_US); // Eat any keys pressed before the dialog inited. + InitCommon(); UpdateButtons(); - okButtonImg = ImageID("I_CIRCLE"); - cancelButtonImg = ImageID("I_CROSS"); - okButtonFlag = CTRL_CIRCLE; - cancelButtonFlag = CTRL_CROSS; - if (request.common.buttonSwap == 1) - { - okButtonImg = ImageID("I_CROSS"); - cancelButtonImg = ImageID("I_CIRCLE"); - okButtonFlag = CTRL_CROSS; - cancelButtonFlag = CTRL_CIRCLE; - } connResult = -1; scanInfosAddr = 0; @@ -247,6 +237,7 @@ int PSPNetconfDialog::Update(int animSpeed) { } UpdateButtons(); + UpdateCommon(); auto di = GetI18NCategory("Dialog"); auto err = GetI18NCategory("Error"); u64 now = (u64)(time_now_d() * 1000000.0); diff --git a/Core/Dialog/PSPNpSigninDialog.cpp b/Core/Dialog/PSPNpSigninDialog.cpp index 48245c2008..6667bf217f 100644 --- a/Core/Dialog/PSPNpSigninDialog.cpp +++ b/Core/Dialog/PSPNpSigninDialog.cpp @@ -67,17 +67,7 @@ int PSPNpSigninDialog::Init(u32 paramAddr) { // Eat any keys pressed before the dialog inited. UpdateButtons(); - okButtonImg = ImageID("I_CIRCLE"); - cancelButtonImg = ImageID("I_CROSS"); - okButtonFlag = CTRL_CIRCLE; - cancelButtonFlag = CTRL_CROSS; - if (request.common.buttonSwap == 1) - { - okButtonImg = ImageID("I_CROSS"); - cancelButtonImg = ImageID("I_CIRCLE"); - okButtonFlag = CTRL_CROSS; - cancelButtonFlag = CTRL_CIRCLE; - } + InitCommon(); //npSigninResult = -1; startTime = (u64)(time_now_d() * 1000000.0); @@ -244,6 +234,7 @@ int PSPNpSigninDialog::Update(int animSpeed) { } UpdateButtons(); + UpdateCommon(); auto di = GetI18NCategory("Dialog"); auto err = GetI18NCategory("Error"); u64 now = (u64)(time_now_d() * 1000000.0); diff --git a/Core/Dialog/PSPPlaceholderDialog.cpp b/Core/Dialog/PSPPlaceholderDialog.cpp index 2fc3fbe92f..e320449bd3 100644 --- a/Core/Dialog/PSPPlaceholderDialog.cpp +++ b/Core/Dialog/PSPPlaceholderDialog.cpp @@ -27,6 +27,7 @@ PSPPlaceholderDialog::~PSPPlaceholderDialog() { int PSPPlaceholderDialog::Init() { ChangeStatus(SCE_UTILITY_STATUS_INITIALIZE, 0); + InitCommon(); return 0; } @@ -38,6 +39,7 @@ int PSPPlaceholderDialog::Update(int animSpeed) { } else if (ReadStatus() == SCE_UTILITY_STATUS_FINISHED) { ChangeStatus(SCE_UTILITY_STATUS_SHUTDOWN, 0); } + UpdateCommon(); return 0; } diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 9b21f5d770..9b153339d5 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -270,6 +270,7 @@ int PSPSaveDialog::Init(int paramAddr) } param.ClearCaches(); + InitCommon(); UpdateButtons(); StartFade(true); @@ -654,16 +655,7 @@ int PSPSaveDialog::Update(int animSpeed) UpdateButtons(); UpdateFade(animSpeed); - okButtonImg = ImageID("I_CIRCLE"); - cancelButtonImg = ImageID("I_CROSS"); - okButtonFlag = CTRL_CIRCLE; - cancelButtonFlag = CTRL_CROSS; - if (param.GetPspParam()->common.buttonSwap == 1) { - okButtonImg = ImageID("I_CROSS"); - cancelButtonImg = ImageID("I_CIRCLE"); - okButtonFlag = CTRL_CROSS; - cancelButtonFlag = CTRL_CIRCLE; - } + UpdateCommon(); auto di = GetI18NCategory("Dialog"); diff --git a/Core/Dialog/PSPScreenshotDialog.cpp b/Core/Dialog/PSPScreenshotDialog.cpp index 92e4a17a91..6615e84252 100644 --- a/Core/Dialog/PSPScreenshotDialog.cpp +++ b/Core/Dialog/PSPScreenshotDialog.cpp @@ -84,11 +84,13 @@ int PSPScreenshotDialog::Init(u32 paramAddr) { mode = params_->mode; ChangeStatus(SCE_UTILITY_STATUS_INITIALIZE, 0); + InitCommon(); return 0; } int PSPScreenshotDialog::Update(int animSpeed) { + UpdateCommon(); if (UseAutoStatus()) { if (ReadStatus() == SCE_UTILITY_STATUS_INITIALIZE) { ChangeStatus(SCE_UTILITY_STATUS_RUNNING, 0);