Fix an issue with files since the adding of xpm saving

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1706 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2011-01-30 19:35:29 +00:00
parent 7150a1ebcd
commit 5a8972d0f9
3 changed files with 16 additions and 13 deletions

View File

@ -1226,6 +1226,7 @@ byte Button_Load_or_Save(byte load, T_IO_Context *context)
T_Dropdown_button * formats_dropdown; T_Dropdown_button * formats_dropdown;
T_Dropdown_button * bookmark_dropdown[4]; T_Dropdown_button * bookmark_dropdown[4];
short temp; short temp;
unsigned int format;
int dummy=0; // Sert à appeler SDL_GetKeyState int dummy=0; // Sert à appeler SDL_GetKeyState
byte save_or_load_image=0; byte save_or_load_image=0;
byte has_clicked_ok=0;// Indique si on a clické sur Load ou Save ou sur byte has_clicked_ok=0;// Indique si on a clické sur Load ou Save ou sur
@ -1304,11 +1305,11 @@ byte Button_Load_or_Save(byte load, T_IO_Context *context)
Get_fileformat(Main_format)->Label, Get_fileformat(Main_format)->Label,
1,0,1,RIGHT_SIDE|LEFT_SIDE,0); // 6 1,0,1,RIGHT_SIDE|LEFT_SIDE,0); // 6
for (temp=0; temp < NB_KNOWN_FORMATS; temp++) for (format=0; format < Nb_known_formats(); format++)
{ {
if ((load && (File_formats[temp].Identifier <= FORMAT_ALL_FILES || File_formats[temp].Load)) || if ((load && (File_formats[format].Identifier <= FORMAT_ALL_FILES || File_formats[format].Load)) ||
(!load && File_formats[temp].Save)) (!load && File_formats[format].Save))
Window_dropdown_add_item(formats_dropdown,File_formats[temp].Identifier,File_formats[temp].Label); Window_dropdown_add_item(formats_dropdown,File_formats[format].Identifier,File_formats[format].Label);
} }
Print_in_window(70,18,"Format",MC_Dark,MC_Light); Print_in_window(70,18,"Format",MC_Dark,MC_Light);

View File

@ -139,7 +139,7 @@ void Save_PNG(T_IO_Context *);
void Load_SDL_Image(T_IO_Context *); void Load_SDL_Image(T_IO_Context *);
// ENUM Name TestFunc LoadFunc SaveFunc PalOnly Comment Layers Ext Exts // ENUM Name TestFunc LoadFunc SaveFunc PalOnly Comment Layers Ext Exts
T_Format File_formats[NB_KNOWN_FORMATS] = { T_Format File_formats[] = {
{FORMAT_ALL_IMAGES, "(all)", NULL, NULL, NULL, 0, 0, 0, "", "gif;png;bmp;pcx;pkm;lbm;ilbm;iff;img;sci;scq;scf;scn;sco;pi1;pc1;cel;neo;kcf;pal;c64;koa;tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico"}, {FORMAT_ALL_IMAGES, "(all)", NULL, NULL, NULL, 0, 0, 0, "", "gif;png;bmp;pcx;pkm;lbm;ilbm;iff;img;sci;scq;scf;scn;sco;pi1;pc1;cel;neo;kcf;pal;c64;koa;tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico"},
{FORMAT_ALL_FILES, "(*.*)", NULL, NULL, NULL, 0, 0, 0, "", "*"}, {FORMAT_ALL_FILES, "(*.*)", NULL, NULL, NULL, 0, 0, 0, "", "*"},
{FORMAT_GIF, " gif", Test_GIF, Load_GIF, Save_GIF, 0, 1, 1, "gif", "gif"}, {FORMAT_GIF, " gif", Test_GIF, Load_GIF, Save_GIF, 0, 1, 1, "gif", "gif"},
@ -164,6 +164,12 @@ T_Format File_formats[NB_KNOWN_FORMATS] = {
{FORMAT_MISC,"misc.",NULL, NULL, NULL, 0, 0, 0, "", "tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico"}, {FORMAT_MISC,"misc.",NULL, NULL, NULL, 0, 0, 0, "", "tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico"},
}; };
/// Total number of known file formats
unsigned int Nb_known_formats(void)
{
return sizeof(File_formats)/sizeof(File_formats[0]);
}
/// Set the color of a pixel (on load) /// Set the color of a pixel (on load)
void Set_pixel(T_IO_Context *context, short x_pos, short y_pos, byte color) void Set_pixel(T_IO_Context *context, short x_pos, short y_pos, byte color)
{ {
@ -567,7 +573,7 @@ void Load_image(T_IO_Context *context)
{ {
// Sinon, on va devoir scanner les différents formats qu'on connait pour // Sinon, on va devoir scanner les différents formats qu'on connait pour
// savoir à quel format est le fichier: // savoir à quel format est le fichier:
for (index=0; index < NB_KNOWN_FORMATS; index++) for (index=0; index < Nb_known_formats(); index++)
{ {
format = Get_fileformat(index); format = Get_fileformat(index);
// Loadable format // Loadable format
@ -1089,7 +1095,7 @@ T_Format * Get_fileformat(byte format)
unsigned int i; unsigned int i;
T_Format * safe_default = File_formats; T_Format * safe_default = File_formats;
for (i=0; i < NB_KNOWN_FORMATS; i++) for (i=0; i < Nb_known_formats(); i++)
{ {
if (File_formats[i].Identifier == format) if (File_formats[i].Identifier == format)
return &(File_formats[i]); return &(File_formats[i]);

View File

@ -194,12 +194,8 @@ T_Format * Get_fileformat(byte format);
// -- File formats // -- File formats
#ifndef __no_pnglib__ /// Total number of known file formats
#define NB_KNOWN_FORMATS 19 ///< Total number of known file formats. unsigned int Nb_known_formats(void);
#else
// Without pnglib
#define NB_KNOWN_FORMATS 18 ///< Total number of known file formats.
#endif
// Internal use // Internal use