From 207e487d99c866cfafdafd8bcba3bdd73ad6c196 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Tue, 23 Jan 2018 10:38:55 +0100 Subject: [PATCH] Show palette in preview (instead of image) when loading palette ! --- src/fileformats.c | 1 + src/filesel.c | 2 ++ src/loadsave.c | 14 +++++++++++--- src/loadsave.h | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/fileformats.c b/src/fileformats.c index e92e6ee3..b1f356ae 100644 --- a/src/fileformats.c +++ b/src/fileformats.c @@ -4666,6 +4666,7 @@ static void Load_PNG_Sub(T_IO_Context * context, FILE * file) break; case CONTEXT_PALETTE: + case CONTEXT_PREVIEW_PALETTE: // No pixels to draw in a palette! break; } diff --git a/src/filesel.c b/src/filesel.c index f6cae8d3..ad84b3fb 100644 --- a/src/filesel.c +++ b/src/filesel.c @@ -2171,6 +2171,8 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context Init_context_preview(&preview_context, Selector_filename, Selector->Directory); Hide_cursor(); + if (context->Type == CONTEXT_PALETTE) + preview_context.Type = CONTEXT_PREVIEW_PALETTE; Load_image(&preview_context); Destroy_context(&preview_context); diff --git a/src/loadsave.c b/src/loadsave.c index 654fbac9..ce838ad5 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -260,6 +260,7 @@ void Set_pixel(T_IO_Context *context, short x_pos, short y_pos, byte color) break; case CONTEXT_PALETTE: + case CONTEXT_PREVIEW_PALETTE: break; } @@ -286,6 +287,7 @@ void Fill_canvas(T_IO_Context *context, byte color) case CONTEXT_SURFACE: break; case CONTEXT_PALETTE: + case CONTEXT_PREVIEW_PALETTE: break; } } @@ -329,6 +331,7 @@ void Set_pixel_24b(T_IO_Context *context, short x_pos, short y_pos, byte r, byte } break; + case CONTEXT_PREVIEW_PALETTE: case CONTEXT_PALETTE: // In a palette, there are no pixels! break; @@ -526,6 +529,7 @@ void Pre_load(T_IO_Context *context, short width, short height, long file_size, break; case CONTEXT_PALETTE: + case CONTEXT_PREVIEW_PALETTE: // In a palette, there are no pixels! break; } @@ -562,6 +566,7 @@ void Pre_load(T_IO_Context *context, short width, short height, long file_size, break; case CONTEXT_PALETTE: + case CONTEXT_PREVIEW_PALETTE: // In a palette, there are no pixels! break; } @@ -715,6 +720,7 @@ void Load_image(T_IO_Context *context) case CONTEXT_PALETTE: + case CONTEXT_PREVIEW_PALETTE: // In a palette, there are no pixels! break; } @@ -897,7 +903,7 @@ void Load_image(T_IO_Context *context) SDL_SetColors(context->Surface, colors, 0, 256); } } - else if (context->Type == CONTEXT_PREVIEW + else if (context->Type == CONTEXT_PREVIEW || context->Type == CONTEXT_PREVIEW_PALETTE /*&& !context->Buffer_image_24b*/ /*&& !Get_fileformat(context->Format)->Palette_only*/) { @@ -934,11 +940,12 @@ void Load_image(T_IO_Context *context) Set_palette(context->Palette); // Display palette preview - if (Get_fileformat(context->Format)->Palette_only) // TODO : OU nous somme dans le load du menu palette ! + if (Get_fileformat(context->Format)->Palette_only + || context->Type == CONTEXT_PREVIEW_PALETTE) { short index; - if (context->Type == CONTEXT_PREVIEW) + if (context->Type == CONTEXT_PREVIEW || context->Type == CONTEXT_PREVIEW_PALETTE) for (index=0; index<256; index++) Window_rectangle(183+(index/16)*7,95+(index&15)*5,5,5,index); @@ -1061,6 +1068,7 @@ void Save_image(T_IO_Context *context) break; case CONTEXT_PREVIEW: + case CONTEXT_PREVIEW_PALETTE: break; case CONTEXT_SURFACE: diff --git a/src/loadsave.h b/src/loadsave.h index fa84ddbb..9af8a180 100644 --- a/src/loadsave.h +++ b/src/loadsave.h @@ -34,6 +34,7 @@ enum CONTEXT_TYPE { CONTEXT_MAIN_IMAGE, CONTEXT_BRUSH, CONTEXT_PREVIEW, + CONTEXT_PREVIEW_PALETTE, CONTEXT_SURFACE, CONTEXT_PALETTE };