mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-12 20:40:49 +00:00
Make MsgDialog not put text outside the screen.
This commit is contained in:
parent
6b64554e64
commit
59e52f4e5a
@ -50,7 +50,7 @@ void PSPDialog::EndDraw()
|
|||||||
|
|
||||||
void PSPDialog::DisplayMessage(std::string text)
|
void PSPDialog::DisplayMessage(std::string text)
|
||||||
{
|
{
|
||||||
PPGeDrawText(text.c_str(), 480/2, 100, PPGE_ALIGN_CENTER, 0.5f, 0xFFFFFFFF);
|
PPGeDrawText(text.c_str(), 40, 30, PPGE_ALIGN_LEFT, 0.5f, 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PSPDialog::Shutdown()
|
int PSPDialog::Shutdown()
|
||||||
|
@ -238,18 +238,20 @@ static void PPGeMeasureText(const char *text, float scale, float *w, float *h) {
|
|||||||
const AtlasFont &atlasfont = *ppge_atlas.fonts[0];
|
const AtlasFont &atlasfont = *ppge_atlas.fonts[0];
|
||||||
unsigned char cval;
|
unsigned char cval;
|
||||||
float wacc = 0;
|
float wacc = 0;
|
||||||
|
float maxw = 0;
|
||||||
int lines = 1;
|
int lines = 1;
|
||||||
while ((cval = *text++) != '\0') {
|
while ((cval = *text++) != '\0') {
|
||||||
if (cval < 32) continue;
|
if (cval < 32) continue;
|
||||||
if (cval > 127) continue;
|
if (cval > 127) continue;
|
||||||
if (cval == '\n') {
|
if (cval == '\n') {
|
||||||
|
if (wacc > maxw) maxw = wacc;
|
||||||
wacc = 0;
|
wacc = 0;
|
||||||
lines++;
|
lines++;
|
||||||
}
|
}
|
||||||
AtlasChar c = atlasfont.chars[cval - 32];
|
AtlasChar c = atlasfont.chars[cval - 32];
|
||||||
wacc += c.wx * scale;
|
wacc += c.wx * scale;
|
||||||
}
|
}
|
||||||
if (w) *w = wacc;
|
if (w) *w = maxw;
|
||||||
if (h) *h = atlasfont.height * scale * lines;
|
if (h) *h = atlasfont.height * scale * lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,6 +280,7 @@ void PPGeDrawText(const char *text, float x, float y, int align, float scale, u3
|
|||||||
float sx = x;
|
float sx = x;
|
||||||
while ((cval = *text++) != '\0') {
|
while ((cval = *text++) != '\0') {
|
||||||
if (cval == '\n') {
|
if (cval == '\n') {
|
||||||
|
// This is not correct when centering or right-justifying, need to set x depending on line width (tricky)
|
||||||
y += atlasfont.height * scale;
|
y += atlasfont.height * scale;
|
||||||
x = sx;
|
x = sx;
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user