diff --git a/src/miscfileformats.c b/src/miscfileformats.c index 6c546285..2ddf774e 100644 --- a/src/miscfileformats.c +++ b/src/miscfileformats.c @@ -2831,9 +2831,8 @@ int Save_C64_hires(T_IO_Context *context, char *filename, byte saveWhat, byte lo numcolors=Count_used_colors_area(cusage,cx*8,cy*8,8,8); if (numcolors>2) { - Warning_message("More than 2 colors in 8x8 pixels"); + Warning_with_format("More than 2 colors\nin 8x8 pixel cell: (%d, %d)\nRect: (%d, %d, %d, %d)", cx, cy, cx * 8, cy * 8, cx * 8 + 7, cy * 8 + 7); // TODO here we should hilite the offending block - printf("\nerror at %dx%d (%d colors)\n",cx*8,cy*8,numcolors); return 1; } c1 = 0; c2 = 0; @@ -3006,7 +3005,7 @@ int Save_C64_multi(T_IO_Context *context, char *filename, byte saveWhat, byte lo numcolors=Count_used_colors_area(cusage,cx*4,cy*8,4,8); if(numcolors>4) { - Warning_message("More than 4 colors in 4x8"); + Warning_with_format("More than 4 colors\nin 4x8 pixel cell: (%d, %d)\nRect: (%d, %d, %d, %d)", cx, cy, cx * 4, cy * 8, cx * 4 + 3, cy * 8 + 7); // TODO hilite offending block return 1; } diff --git a/src/windows.c b/src/windows.c index 63ded010..c1cce9f9 100644 --- a/src/windows.c +++ b/src/windows.c @@ -25,6 +25,7 @@ */ #include +#include // va_args ... #include // atoi() #include // strncpy() strlen() @@ -1183,6 +1184,26 @@ void Warning_message(char * message) Display_cursor(); } +/// Window that shows a warning message and waits for a click on the OK button +/// This has the added advantage of supporting the printf interface. +void Warning_with_format(const char *template, ...) { + va_list arg_ptr; + char *message; + + message = malloc(sizeof(char) * 1024); // a maximum of 1 KiB of complete message. + if (message) { + va_start(arg_ptr, template); + vsprintf(message, template, arg_ptr); + //Warning_message(message); + Verbose_message("Warning", message); + va_end(arg_ptr); + free(message); + } else { + //Warning_message(template); + Verbose_message("Warning", template); + } +} + /// Window that shows a big message (up to 35x13), and waits for a click on OK. /// On call: Cursor must be displayed /// On exit: Cursor is displayed diff --git a/src/windows.h b/src/windows.h index 9fd18883..0b2ea718 100644 --- a/src/windows.h +++ b/src/windows.h @@ -76,6 +76,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 Warning_with_format(const char * message, ...); void Verbose_message(const char * caption, const char * message); int Requester_window(char* message, int initial_value);