From 2f3c55477e45567d50ae5699cc412452428484ac Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Sun, 5 Jul 2015 01:10:31 +0000 Subject: [PATCH] Fileselectors : handle palette and image formats separately git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@2125 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/const.h | 5 +++-- src/filesel.c | 4 ++-- src/loadsave.c | 11 ++++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/const.h b/src/const.h index e317565f..cf54ae27 100644 --- a/src/const.h +++ b/src/const.h @@ -113,8 +113,9 @@ /// List of file formats recognized by grafx2 enum FILE_FORMATS { - FORMAT_ALL_IMAGES=0, ///< This is not really a file format, it's reserverd for a compilation of all file extensions - FORMAT_ALL_FILES=1, ///< This is not really a file format, it's reserverd for the "*.*" filter option. + FORMAT_ALL_IMAGES=0, ///< This is not really a file format, it's reserverd for a compilation of all image file extensions + FORMAT_ALL_PALETTES=1, ///< This is not really a file format, it's reserverd for a compilation of all palette file extensions + FORMAT_ALL_FILES=2, ///< This is not really a file format, it's reserverd for the "*.*" filter option. FORMAT_PNG, FORMAT_GIF, FORMAT_BMP, diff --git a/src/filesel.c b/src/filesel.c index 422aa6ec..0d817be8 100644 --- a/src/filesel.c +++ b/src/filesel.c @@ -1447,8 +1447,8 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context for (format=0; format < Nb_known_formats(); format++) { - if ((load && (File_formats[format].Identifier <= FORMAT_ALL_FILES || File_formats[format].Load)) || - (!load && File_formats[format].Save)) + if (((context->Type == CONTEXT_PALETTE) == File_formats[format].Palette_only) && + ((load && (File_formats[format].Load || File_formats[format].Identifier <= FORMAT_ALL_FILES)) || (!load && File_formats[format].Save))) Window_dropdown_add_item(formats_dropdown,File_formats[format].Identifier,File_formats[format].Label); } Print_in_window(70,18,"Format",MC_Dark,MC_Light); diff --git a/src/loadsave.c b/src/loadsave.c index 922ba04e..d2738916 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -153,7 +153,8 @@ void Load_SDL_Image(T_IO_Context *); // ENUM Name TestFunc LoadFunc SaveFunc PalOnly Comment Layers Ext Exts T_Format File_formats[] = { - {FORMAT_ALL_IMAGES, "(all)", NULL, NULL, NULL, 0, 0, 0, "", "gif;png;bmp;pcx;pkm;iff;lbm;ilbm;img;sci;scq;scf;scn;sco;pi1;pc1;cel;neo;kcf;pal;gpl;c64;koa;koala;fli;bml;cdu;prg;tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico;cm5"}, + {FORMAT_ALL_IMAGES, "(all)", NULL, NULL, NULL, 0, 0, 0, "", "gif;png;bmp;pcx;pkm;iff;lbm;ilbm;img;sci;scq;scf;scn;sco;pi1;pc1;cel;neo;c64;koa;koala;fli;bml;cdu;prg;tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico;cm5"}, + {FORMAT_ALL_PALETTES, "(all)", NULL, NULL, NULL, 1, 0, 0, "", "kcf;pal;gpl"}, {FORMAT_ALL_FILES, "(*.*)", NULL, NULL, NULL, 0, 0, 0, "", "*"}, {FORMAT_GIF, " gif", Test_GIF, Load_GIF, Save_GIF, 0, 1, 1, "gif", "gif"}, #ifndef __no_pnglib__ @@ -244,7 +245,9 @@ void Set_pixel(T_IO_Context *context, short x_pos, short y_pos, byte color) if (x_pos>=0 && y_pos>=0 && x_posSurface->w && y_posSurface->h) *(((byte *)(context->Surface->pixels)) + context->Surface->pitch * y_pos + x_pos) = color; break; - + + case CONTEXT_PALETTE: + break; } } @@ -269,6 +272,8 @@ void Fill_canvas(T_IO_Context *context, byte color) break; case CONTEXT_SURFACE: break; + case CONTEXT_PALETTE: + break; } } @@ -566,7 +571,7 @@ void Set_file_error(int value) void Load_image(T_IO_Context *context) { unsigned int index; // index de balayage des formats - T_Format *format = &(File_formats[2]); // Format du fichier à charger + T_Format *format = &(File_formats[FORMAT_ALL_FILES+1]); // Format du fichier à charger int i; byte old_cursor_shape;