mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-08 18:16:12 +00:00
Merge pull request #5188 from unknownbrackets/msgdialog
Clean up some more minor things in message dialogs
This commit is contained in:
commit
d69f02dea0
@ -148,8 +148,15 @@ bool PSPDialog::IsButtonHeld(int checkButton, int &framesHeld, int framesHeldThr
|
||||
return false;
|
||||
}
|
||||
|
||||
void PSPDialog::DisplayButtons(int flags)
|
||||
void PSPDialog::DisplayButtons(int flags, const char *caption)
|
||||
{
|
||||
bool useCaption = false;
|
||||
char safeCaption[65] = {0};
|
||||
if (caption != NULL && *caption != '\0') {
|
||||
useCaption = true;
|
||||
strncpy(safeCaption, caption, 64);
|
||||
}
|
||||
|
||||
I18NCategory *d = GetI18NCategory("Dialog");
|
||||
float x1 = 183.5f, x2 = 261.5f;
|
||||
if (GetCommonParam()->buttonSwap == 1) {
|
||||
@ -157,14 +164,16 @@ void PSPDialog::DisplayButtons(int flags)
|
||||
x2 = 183.5f;
|
||||
}
|
||||
if (flags & DS_BUTTON_OK) {
|
||||
const char *text = useCaption ? safeCaption : d->T("Enter");
|
||||
PPGeDrawImage(okButtonImg, x2, 258, 11.5f, 11.5f, 0, CalcFadedColor(0x80000000));
|
||||
PPGeDrawImage(okButtonImg, x2, 256, 11.5f, 11.5f, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(d->T("Enter"), x2 + 15.5f, 254, PPGE_ALIGN_LEFT, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(d->T("Enter"), x2 + 14.5f, 252, PPGE_ALIGN_LEFT, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(text, x2 + 15.5f, 254, PPGE_ALIGN_LEFT, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(text, x2 + 14.5f, 252, PPGE_ALIGN_LEFT, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
if (flags & DS_BUTTON_CANCEL) {
|
||||
PPGeDrawText(d->T("Back"), x1 + 15.5f, 254, PPGE_ALIGN_LEFT, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(d->T("Back"), x1 + 14.5f, 252, PPGE_ALIGN_LEFT, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
const char *text = useCaption ? safeCaption : d->T("Back");
|
||||
PPGeDrawText(text, x1 + 15.5f, 254, PPGE_ALIGN_LEFT, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(text, x1 + 14.5f, 252, PPGE_ALIGN_LEFT, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawImage(cancelButtonImg, x1, 258, 11.5f, 11.5f, 0, CalcFadedColor(0x80000000));
|
||||
PPGeDrawImage(cancelButtonImg, x1, 256, 11.5f, 11.5f, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
|
@ -80,7 +80,8 @@ public:
|
||||
protected:
|
||||
bool IsButtonPressed(int checkButton);
|
||||
bool IsButtonHeld(int checkButton, int &framesHeld, int framesHeldThreshold = 30, int framesHeldRepeatRate = 10);
|
||||
void DisplayButtons(int flags);
|
||||
// The caption override is assumed to have a size of 64 bytes.
|
||||
void DisplayButtons(int flags, const char *caption = NULL);
|
||||
|
||||
void StartFade(bool fadeIn_);
|
||||
void UpdateFade(int animSpeed);
|
||||
|
@ -54,7 +54,7 @@ int PSPMsgDialog::Init(unsigned int paramAddr)
|
||||
Memory::Memcpy(&messageDialog,paramAddr,size);
|
||||
|
||||
// debug info
|
||||
int optionsNotCoded = ((messageDialog.options | SCE_UTILITY_MSGDIALOG_DEBUG_OPTION_CODED) ^ SCE_UTILITY_MSGDIALOG_DEBUG_OPTION_CODED);
|
||||
int optionsNotCoded = messageDialog.options & ~SCE_UTILITY_MSGDIALOG_OPTION_SUPPORTED;
|
||||
if(optionsNotCoded)
|
||||
{
|
||||
ERROR_LOG_REPORT(SCEUTILITY, "PSPMsgDialog options not coded : 0x%08x", optionsNotCoded);
|
||||
@ -70,7 +70,7 @@ int PSPMsgDialog::Init(unsigned int paramAddr)
|
||||
}
|
||||
else if(size == SCE_UTILITY_MSGDIALOG_SIZE_V2 && messageDialog.type == 1)
|
||||
{
|
||||
unsigned int validOp = SCE_UTILITY_MSGDIALOG_OPTION_TEXT |
|
||||
unsigned int validOp = SCE_UTILITY_MSGDIALOG_OPTION_TEXTSOUND |
|
||||
SCE_UTILITY_MSGDIALOG_OPTION_YESNO |
|
||||
SCE_UTILITY_MSGDIALOG_OPTION_DEFAULT_NO;
|
||||
if (((messageDialog.options | validOp) ^ validOp) != 0)
|
||||
@ -87,6 +87,11 @@ int PSPMsgDialog::Init(unsigned int paramAddr)
|
||||
flag |= DS_ERROR;
|
||||
messageDialog.result = SCE_UTILITY_MSGDIALOG_ERROR_BADOPTION;
|
||||
}
|
||||
if (messageDialog.options & ~SCE_UTILITY_MSGDIALOG_OPTION_SUPPORTED)
|
||||
{
|
||||
flag |= DS_ERROR;
|
||||
messageDialog.result = SCE_UTILITY_MSGDIALOG_ERROR_BADOPTION;
|
||||
}
|
||||
}
|
||||
|
||||
if(flag == 0)
|
||||
@ -245,10 +250,10 @@ int PSPMsgDialog::Update(int animSpeed)
|
||||
DisplayMessage(msgText, (flag & DS_YESNO) != 0, (flag & DS_OK) != 0);
|
||||
|
||||
if (flag & (DS_OK | DS_VALIDBUTTON))
|
||||
DisplayButtons(DS_BUTTON_OK);
|
||||
DisplayButtons(DS_BUTTON_OK, messageDialog.common.size == SCE_UTILITY_MSGDIALOG_SIZE_V3 ? messageDialog.okayButton : NULL);
|
||||
|
||||
if (flag & DS_CANCELBUTTON)
|
||||
DisplayButtons(DS_BUTTON_CANCEL);
|
||||
DisplayButtons(DS_BUTTON_CANCEL, messageDialog.common.size == SCE_UTILITY_MSGDIALOG_SIZE_V3 ? messageDialog.cancelButton : NULL);
|
||||
|
||||
if (IsButtonPressed(cancelButtonFlag) && (flag & DS_CANCELBUTTON))
|
||||
{
|
||||
@ -276,9 +281,9 @@ int PSPMsgDialog::Update(int animSpeed)
|
||||
EndDraw();
|
||||
|
||||
lastButtons = buttons;
|
||||
messageDialog.result = 0;
|
||||
}
|
||||
|
||||
messageDialog.result = 0;
|
||||
Memory::Memcpy(messageDialogAddr, &messageDialog ,messageDialog.common.size);
|
||||
return 0;
|
||||
}
|
||||
|
@ -19,22 +19,22 @@
|
||||
|
||||
#include "PSPDialog.h"
|
||||
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_ERROR 0x00000000
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_TEXT 0x00000001
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_NOSOUND 0x00000002
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_YESNO 0x00000010
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_OK 0x00000020
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_NOCANCEL 0x00000080
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_DEFAULT_NO 0x00000100
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_ERRORSOUND 0x00000000
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_TEXTSOUND 0x00000001
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_NOSOUND 0x00000002
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_YESNO 0x00000010
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_OK 0x00000020
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_NOCANCEL 0x00000080
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_DEFAULT_NO 0x00000100
|
||||
|
||||
#define SCE_UTILITY_MSGDIALOG_SIZE_V1 572
|
||||
#define SCE_UTILITY_MSGDIALOG_SIZE_V2 580
|
||||
#define SCE_UTILITY_MSGDIALOG_SIZE_V3 708
|
||||
#define SCE_UTILITY_MSGDIALOG_SIZE_V1 572
|
||||
#define SCE_UTILITY_MSGDIALOG_SIZE_V2 580
|
||||
#define SCE_UTILITY_MSGDIALOG_SIZE_V3 708
|
||||
|
||||
#define SCE_UTILITY_MSGDIALOG_DEBUG_OPTION_CODED 0x000001B3 // OR of all options coded to display warning
|
||||
#define SCE_UTILITY_MSGDIALOG_OPTION_SUPPORTED 0x000001B3 // OR of all options coded to display warning
|
||||
|
||||
#define SCE_UTILITY_MSGDIALOG_ERROR_BADOPTION 0x80110501
|
||||
#define SCE_UTILITY_MSGDIALOG_ERROR_ERRORCODEINVALID 0x80110502
|
||||
#define SCE_UTILITY_MSGDIALOG_ERROR_BADOPTION 0x80110501
|
||||
#define SCE_UTILITY_MSGDIALOG_ERROR_ERRORCODEINVALID 0x80110502
|
||||
|
||||
struct pspMessageDialog
|
||||
{
|
||||
@ -47,7 +47,8 @@ struct pspMessageDialog
|
||||
u32_le options;
|
||||
u32_le buttonPressed;
|
||||
// End of request V2 (Size 580)
|
||||
s32_le unknown[32];
|
||||
char okayButton[64];
|
||||
char cancelButton[64];
|
||||
// End of request V3 (Size 708)
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user