[Change] Tweaked dialogue behaviour a bit.
This commit is contained in:
parent
a4b17c561c
commit
5fd278a859
@ -82,18 +82,35 @@ static void dialogue_alertClose(unsigned int wid, char* str) {
|
|||||||
* @param[out] w Get the width needed.
|
* @param[out] w Get the width needed.
|
||||||
* @param[out] h Get the height needed.
|
* @param[out] h Get the height needed.
|
||||||
*/
|
*/
|
||||||
static glFont* dialogue_getSize(char* msg, int* w, int* h) {
|
static glFont* dialogue_getSize(char* msg, int* width, int* height) {
|
||||||
glFont* font;
|
glFont* font;
|
||||||
|
double w, h, d;
|
||||||
|
int len;
|
||||||
|
|
||||||
font = &gl_smallFont; /* Try to use small font. */
|
w = 300; /* Default width to try. */
|
||||||
|
len = strlen(msg);
|
||||||
|
|
||||||
(*h) = gl_printHeight(font, (*w)-40, msg);
|
/* First we split by text length. */
|
||||||
if(strlen(msg) > 100) { /* Make font bigger for large texts. */
|
if(len < 50) {
|
||||||
font = &gl_defFont;
|
font = &gl_defFont;
|
||||||
(*h) = gl_printHeight(font, (*w)-40, msg);
|
h = gl_printHeight(font, w-40, msg);
|
||||||
if((*h) > 200) (*w) += MIN((*h)-200, 600); /* Too big, so we make it wider. */
|
} else {
|
||||||
(*h) = gl_printHeight(font, (*w)-40, msg);
|
/* Now we look at proportion. */
|
||||||
|
font = &gl_smallFont;
|
||||||
|
h = gl_printHeight(font, w-40, msg);
|
||||||
|
|
||||||
|
d = ((double)w/(double)h) * (2./4.); /* Deformation factor. */
|
||||||
|
if(fabs(d) > 0.3) {
|
||||||
|
if(h > w)
|
||||||
|
w = h;
|
||||||
|
h = gl_printHeight(font, w-40, msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set values. */
|
||||||
|
(*width) = w;
|
||||||
|
(*height) = h;
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +134,6 @@ void dialogue_msg(char* caption, const char* fmt, ...) {
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
w = 300; /* Default width. */
|
|
||||||
font = dialogue_getSize(msg, &w, &h);
|
font = dialogue_getSize(msg, &w, &h);
|
||||||
|
|
||||||
/* Create the window. */
|
/* Create the window. */
|
||||||
@ -154,7 +170,6 @@ int dialogue_YesNo(char* caption, const char* fmt, ...) {
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
w = 300;
|
|
||||||
font = dialogue_getSize(msg, &w, &h);
|
font = dialogue_getSize(msg, &w, &h);
|
||||||
|
|
||||||
/* Create the window. */
|
/* Create the window. */
|
||||||
|
Loading…
Reference in New Issue
Block a user