From f64117aeda8a3bc336ffb2fa61c2566b5f0f5b8c Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Sat, 13 Feb 2010 18:23:13 +0000 Subject: [PATCH] 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 --- buttons.c | 2 +- factory.c | 11 +++++++---- graph.c | 2 +- windows.c | 17 +++++++++-------- windows.h | 2 +- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/buttons.c b/buttons.c index 08bfb559..42462141 100644 --- a/buttons.c +++ b/buttons.c @@ -1117,7 +1117,7 @@ void Button_Skins(void) gfx = Load_graphics(skinsdir); if (gfx == NULL) // Error { - Verbose_error_message(Gui_loading_error_message); + Verbose_message("Error!", Gui_loading_error_message); // Update preview Window_rectangle(6, 14, 173, 16, MC_Light); } diff --git a/factory.c b/factory.c index ee6f9514..179c712d 100644 --- a/factory.c +++ b/factory.c @@ -793,7 +793,7 @@ void Button_Brush_Factory(void) if (Brush_backup == NULL) { - Verbose_error_message("Out of memory!"); + Verbose_message("Error!", "Out of memory!"); } else { @@ -803,7 +803,7 @@ void Button_Brush_Factory(void) { message = lua_tostring(L, 1); if(message) - Verbose_error_message(message); + Verbose_message("Error!", message); else Warning_message("Unknown error loading script!"); } @@ -812,7 +812,10 @@ void Button_Brush_Factory(void) int stack_size; stack_size= lua_gettop(L); 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 Warning_message("Unknown error running script!"); } @@ -841,7 +844,7 @@ void Button_Brush_Factory(void) #else // NOLUA 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 diff --git a/graph.c b/graph.c index da2eb065..fe5a880b 100644 --- a/graph.c +++ b/graph.c @@ -257,7 +257,7 @@ try_again: { if(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" "GrafX2 switched to a smaller\npixel scaler to avoid problems "); goto try_again; diff --git a/windows.c b/windows.c index 7e19cc3e..c240a83e 100644 --- a/windows.c +++ b/windows.c @@ -1113,8 +1113,8 @@ void Warning_message(char * message) Display_cursor(); } -/// Window that shows a big message, and waits for a click on OK -void Verbose_error_message(const char * message) +/// Window that shows a big message (up to 34x12), and waits for a click on OK +void Verbose_message(const char *caption, const char * message ) { short clicked_button; int line; @@ -1122,7 +1122,7 @@ void Verbose_error_message(const char * message) int nb_char; char buffer[36]; - Open_window(300,160,"Error!"); + Open_window(300,160,caption); // Word-wrap the message for (line=0; line < 12 && *message!='\0'; line++) @@ -1142,16 +1142,18 @@ void Verbose_error_message(const char * message) } } // Close line buffer - if (last_space == -1) - last_space = 34; + if (message[nb_char]=='\0' || last_space == -1) + last_space = nb_char; buffer[last_space]='\0'; // Print Print_in_window(10,20+line*8,buffer,MC_Black,MC_Light); // Next line - message=message+last_space+1; - // Strip leading spaces + message=message+last_space; + // Strip at most one carriage return and any leading spaces + if (*message == '\n') + message++; while (*message == ' ') message++; } @@ -1169,7 +1171,6 @@ void Verbose_error_message(const char * message) Display_cursor(); } - // -- Redessiner le sprite d'un bouton dans le menu -- void Display_sprite_in_menu(int btn_number,int sprite_number) diff --git a/windows.h b/windows.h index 860dc73a..0b00e8e1 100644 --- a/windows.h +++ b/windows.h @@ -75,7 +75,7 @@ void Print_counter(short x,short y,const char * str,byte text_color,byte backgro byte Confirmation_box(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); void Display_image_limits(void);