Fix display in message boxes when very long messages happened (normally only with Lua messages)

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1338 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2010-02-13 18:23:13 +00:00
parent 87432470f3
commit f64117aeda
5 changed files with 19 additions and 15 deletions

View File

@ -1117,7 +1117,7 @@ void Button_Skins(void)
gfx = Load_graphics(skinsdir); gfx = Load_graphics(skinsdir);
if (gfx == NULL) // Error if (gfx == NULL) // Error
{ {
Verbose_error_message(Gui_loading_error_message); Verbose_message("Error!", Gui_loading_error_message);
// Update preview // Update preview
Window_rectangle(6, 14, 173, 16, MC_Light); Window_rectangle(6, 14, 173, 16, MC_Light);
} }

View File

@ -793,7 +793,7 @@ void Button_Brush_Factory(void)
if (Brush_backup == NULL) if (Brush_backup == NULL)
{ {
Verbose_error_message("Out of memory!"); Verbose_message("Error!", "Out of memory!");
} }
else else
{ {
@ -803,7 +803,7 @@ void Button_Brush_Factory(void)
{ {
message = lua_tostring(L, 1); message = lua_tostring(L, 1);
if(message) if(message)
Verbose_error_message(message); Verbose_message("Error!", message);
else else
Warning_message("Unknown error loading script!"); Warning_message("Unknown error loading script!");
} }
@ -812,7 +812,10 @@ void Button_Brush_Factory(void)
int stack_size; int stack_size;
stack_size= lua_gettop(L); stack_size= lua_gettop(L);
if (stack_size>0 && (message = lua_tostring(L, stack_size))!=NULL) if (stack_size>0 && (message = lua_tostring(L, stack_size))!=NULL)
Verbose_error_message(message); //Verbose_message("Error running script", message);
Verbose_message("Error!", "Your WM is forcing GrafX2 to resize to something "
"smallerthantheminimalresolution.\n"
"GrafX2 switched to a smaller\npixel scaler to avoid problems.");
else else
Warning_message("Unknown error running script!"); Warning_message("Unknown error running script!");
} }
@ -841,7 +844,7 @@ void Button_Brush_Factory(void)
#else // NOLUA #else // NOLUA
void Button_Brush_Factory(void) void Button_Brush_Factory(void)
{ {
Verbose_error_message("The brush factory is not available in this build of GrafX2."); Verbose_message("Error!", "The brush factory is not available in this build of GrafX2.");
} }
#endif #endif

View File

@ -257,7 +257,7 @@ try_again:
{ {
if(pix_ratio != PIXEL_SIMPLE) { if(pix_ratio != PIXEL_SIMPLE) {
pix_ratio = PIXEL_SIMPLE; pix_ratio = PIXEL_SIMPLE;
Verbose_error_message("Your WM is forcing GrafX2 to resize to something " Verbose_message("Error!", "Your WM is forcing GrafX2 to resize to something "
"smaller than the minimal resolution.\n" "smaller than the minimal resolution.\n"
"GrafX2 switched to a smaller\npixel scaler to avoid problems "); "GrafX2 switched to a smaller\npixel scaler to avoid problems ");
goto try_again; goto try_again;

View File

@ -1113,8 +1113,8 @@ void Warning_message(char * message)
Display_cursor(); Display_cursor();
} }
/// Window that shows a big message, and waits for a click on OK /// Window that shows a big message (up to 34x12), and waits for a click on OK
void Verbose_error_message(const char * message) void Verbose_message(const char *caption, const char * message )
{ {
short clicked_button; short clicked_button;
int line; int line;
@ -1122,7 +1122,7 @@ void Verbose_error_message(const char * message)
int nb_char; int nb_char;
char buffer[36]; char buffer[36];
Open_window(300,160,"Error!"); Open_window(300,160,caption);
// Word-wrap the message // Word-wrap the message
for (line=0; line < 12 && *message!='\0'; line++) for (line=0; line < 12 && *message!='\0'; line++)
@ -1142,16 +1142,18 @@ void Verbose_error_message(const char * message)
} }
} }
// Close line buffer // Close line buffer
if (last_space == -1) if (message[nb_char]=='\0' || last_space == -1)
last_space = 34; last_space = nb_char;
buffer[last_space]='\0'; buffer[last_space]='\0';
// Print // 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);
// Next line // Next line
message=message+last_space+1; message=message+last_space;
// Strip leading spaces // Strip at most one carriage return and any leading spaces
if (*message == '\n')
message++;
while (*message == ' ') while (*message == ' ')
message++; message++;
} }
@ -1169,7 +1171,6 @@ void Verbose_error_message(const char * message)
Display_cursor(); Display_cursor();
} }
// -- Redessiner le sprite d'un bouton dans le menu -- // -- Redessiner le sprite d'un bouton dans le menu --
void Display_sprite_in_menu(int btn_number,int sprite_number) void Display_sprite_in_menu(int btn_number,int sprite_number)

View File

@ -75,7 +75,7 @@ void Print_counter(short x,short y,const char * str,byte text_color,byte backgro
byte Confirmation_box(char * message); byte Confirmation_box(char * message);
void Warning_message(char * message); void Warning_message(char * message);
void Verbose_error_message(const char * message); void Verbose_message(const char * caption, const char * message);
int Requester_window(char* message, int initial_value); int Requester_window(char* message, int initial_value);
void Display_image_limits(void); void Display_image_limits(void);