Proper word-wrapping in Verbose_error_message() box.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1133 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
373e39abe8
commit
fffb90dfaf
36
windows.c
36
windows.c
@ -914,28 +914,42 @@ void Verbose_error_message(const char * message)
|
|||||||
{
|
{
|
||||||
short clicked_button;
|
short clicked_button;
|
||||||
int line;
|
int line;
|
||||||
int i;
|
int last_space;
|
||||||
char buffer[36]; // 35 characters + \0
|
int nb_char;
|
||||||
|
char buffer[36];
|
||||||
|
|
||||||
Open_window(300,160,"Error!");
|
Open_window(300,160,"Error!");
|
||||||
|
|
||||||
// Word-wrap the message
|
// Word-wrap the message
|
||||||
for (line=0; line < 10; line++)
|
for (line=0; line < 12 && *message!='\0'; line++)
|
||||||
{
|
{
|
||||||
for (i=0;i<35 && *message!='\0';i++)
|
last_space = -1;
|
||||||
|
for (nb_char=0; nb_char<35 && message[nb_char]!='\0'; nb_char++)
|
||||||
{
|
{
|
||||||
if (*message == '\n')
|
buffer[nb_char]=message[nb_char];
|
||||||
|
if (message[nb_char] == ' ')
|
||||||
{
|
{
|
||||||
message++;
|
last_space = nb_char;
|
||||||
|
}
|
||||||
|
else if (message[nb_char] == '\n')
|
||||||
|
{
|
||||||
|
last_space = nb_char;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buffer[i]=*message;
|
|
||||||
message++;
|
|
||||||
}
|
}
|
||||||
buffer[i]='\0';
|
// Close line buffer
|
||||||
|
if (last_space == -1)
|
||||||
|
last_space = 34;
|
||||||
|
buffer[last_space]='\0';
|
||||||
|
|
||||||
|
// Print
|
||||||
Print_in_window(10,20+line*8,buffer,MC_Black,MC_Light);
|
Print_in_window(10,20+line*8,buffer,MC_Black,MC_Light);
|
||||||
if (*message=='\0')
|
|
||||||
break;
|
// Next line
|
||||||
|
message=message+last_space+1;
|
||||||
|
// Strip leading spaces
|
||||||
|
while (*message == ' ')
|
||||||
|
message++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window_set_normal_button(300/2-20,160-23,40,14,"OK",1,1,SDLK_RETURN); // 1
|
Window_set_normal_button(300/2-20,160-23,40,14,"OK",1,1,SDLK_RETURN); // 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user