mirror of
https://github.com/joel16/VitaShell.git
synced 2024-11-23 11:49:40 +00:00
Added maximum length for dialogs
This commit is contained in:
parent
c8ec848b15
commit
e3f52ccac7
1
main.h
1
main.h
@ -155,6 +155,7 @@
|
||||
#define MAX_NAME_WIDTH 500.0f
|
||||
|
||||
// Uncommon dialog
|
||||
#define UNCOMMON_DIALOG_MAX_WIDTH 800
|
||||
#define UNCOMMON_DIALOG_PROGRESS_BAR_BOX_WIDTH 420.0f
|
||||
#define UNCOMMON_DIALOG_PROGRESS_BAR_HEIGHT 8.0f
|
||||
#define MSG_DIALOG_MODE_QR_SCAN 10
|
||||
|
4
qr.c
4
qr.c
@ -264,8 +264,8 @@ NETWORK_FAILURE:
|
||||
sceKernelDelayThread(10 * 1000);
|
||||
}
|
||||
|
||||
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_OK, language_container[QR_SHOW_CONTENTS], data);
|
||||
setDialogStep(DIALOG_STEP_QR_SHOW_CONTENTS);
|
||||
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, language_container[QR_OPEN_WEBSITE], data);
|
||||
setDialogStep(DIALOG_STEP_QR_OPEN_WEBSITE);
|
||||
return sceKernelExitDeleteThread(0);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,9 @@ static UncommonDialog uncommon_dialog;
|
||||
static void calculateDialogBoxSize() {
|
||||
int len = strlen(uncommon_dialog.msg);
|
||||
char *string = uncommon_dialog.msg;
|
||||
|
||||
char *tempstr = "";
|
||||
float text_width = 0;
|
||||
|
||||
// Get width and height
|
||||
uncommon_dialog.width = 0.0f;
|
||||
uncommon_dialog.height = 0.0f;
|
||||
@ -58,22 +60,41 @@ static void calculateDialogBoxSize() {
|
||||
float width = vita2d_pgf_text_width(font, FONT_SIZE, string);
|
||||
if (width > uncommon_dialog.width)
|
||||
uncommon_dialog.width = width;
|
||||
|
||||
|
||||
uncommon_dialog.msg[i] = '\n';
|
||||
|
||||
string = uncommon_dialog.msg + i;
|
||||
uncommon_dialog.height += FONT_Y_SPACE;
|
||||
}
|
||||
|
||||
if (uncommon_dialog.msg[i] == '\0') {
|
||||
float width = vita2d_pgf_text_width(font, FONT_SIZE, string);
|
||||
if (width > uncommon_dialog.width)
|
||||
uncommon_dialog.width = width;
|
||||
}
|
||||
|
||||
uncommon_dialog.height += FONT_Y_SPACE;
|
||||
tempstr = strdup(uncommon_dialog.msg);
|
||||
tempstr[i+1] = '\0';
|
||||
text_width = vita2d_pgf_text_width(font, FONT_SIZE, tempstr);
|
||||
|
||||
if (text_width > UNCOMMON_DIALOG_MAX_WIDTH) {
|
||||
int lastSpace = i - 1;
|
||||
while (uncommon_dialog.msg[lastSpace] != ' ' && uncommon_dialog.msg[lastSpace] != '\n' && lastSpace > 0) lastSpace--;
|
||||
if (lastSpace == 0 || uncommon_dialog.msg[lastSpace] == '\n') {
|
||||
memmove(uncommon_dialog.msg+i+1, uncommon_dialog.msg+i, strlen(uncommon_dialog.msg)-(i + 1));
|
||||
uncommon_dialog.msg[i] = '\n';
|
||||
} else {
|
||||
uncommon_dialog.msg[lastSpace] = '\n';
|
||||
}
|
||||
|
||||
uncommon_dialog.width = text_width;
|
||||
string = uncommon_dialog.msg + i;
|
||||
}
|
||||
}
|
||||
|
||||
uncommon_dialog.height += FONT_Y_SPACE;
|
||||
for (i = 0; uncommon_dialog.msg[i]; i++)
|
||||
uncommon_dialog.height += FONT_Y_SPACE * (uncommon_dialog.msg[i] == '\n');
|
||||
|
||||
// Margin
|
||||
uncommon_dialog.width += 2.0f*SHELL_MARGIN_X;
|
||||
uncommon_dialog.height += 2.0f*SHELL_MARGIN_Y;
|
||||
|
Loading…
Reference in New Issue
Block a user