Implement "save palette" button
* Actually a shortcut to "save picture" with preset PAL format and different window title. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@2110 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
d9f2cd2d40
commit
fa80a10093
@ -3433,32 +3433,52 @@ void Backup_existing_file(void)
|
||||
}
|
||||
|
||||
|
||||
void Save_picture(byte image)
|
||||
// image=1 => On charge/sauve une image
|
||||
// image=0 => On charge/sauve une brosse
|
||||
void Save_picture(enum CONTEXT_TYPE type)
|
||||
{
|
||||
byte confirm;
|
||||
byte old_cursor_shape;
|
||||
T_IO_Context save_context;
|
||||
static char filename [MAX_PATH_CHARACTERS];
|
||||
static char directory[MAX_PATH_CHARACTERS];
|
||||
|
||||
if (image)
|
||||
|
||||
if (type == CONTEXT_MAIN_IMAGE)
|
||||
{
|
||||
strcpy(filename, Main_backups->Pages->Filename);
|
||||
strcpy(directory, Main_backups->Pages->File_directory);
|
||||
Init_context_layered_image(&save_context, filename, directory);
|
||||
save_context.Format = Main_fileformat;
|
||||
}
|
||||
else
|
||||
else if (type == CONTEXT_BRUSH)
|
||||
{
|
||||
strcpy(filename, Brush_filename);
|
||||
strcpy(directory, Brush_file_directory);
|
||||
Init_context_brush(&save_context, filename, directory);
|
||||
save_context.Format = Brush_fileformat;
|
||||
}
|
||||
else if (type == CONTEXT_PALETTE)
|
||||
{
|
||||
char* dotpos;
|
||||
strcpy(filename, Main_backups->Pages->Filename);
|
||||
|
||||
confirm=Button_Load_or_Save(image?&Main_selector:&Brush_selector,0, &save_context);
|
||||
// Replace extension with PAL
|
||||
dotpos = strrchr(filename, '.');
|
||||
if (dotpos == NULL)
|
||||
dotpos = filename + strlen(filename);
|
||||
strcpy(dotpos, ".pal");
|
||||
|
||||
printf("FILEN %s\n", filename);
|
||||
|
||||
strcpy(directory, Main_backups->Pages->File_directory);
|
||||
Init_context_layered_image(&save_context, filename, directory);
|
||||
save_context.Type = CONTEXT_PALETTE;
|
||||
|
||||
// Set format to PAL
|
||||
save_context.Format = FORMAT_PAL;
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
confirm=Button_Load_or_Save((type==CONTEXT_MAIN_IMAGE)?&Main_selector:&Brush_selector,0, &save_context);
|
||||
|
||||
if (confirm && File_exists(save_context.File_name))
|
||||
{
|
||||
@ -3486,14 +3506,14 @@ void Save_picture(byte image)
|
||||
Save_image(&save_context);
|
||||
|
||||
format=Get_fileformat(save_context.Format);
|
||||
if (!File_error && image && !format->Palette_only && (Main_backups->Pages->Nb_layers==1 || format->Supports_layers))
|
||||
if (!File_error && type == CONTEXT_MAIN_IMAGE && !format->Palette_only && (Main_backups->Pages->Nb_layers==1 || format->Supports_layers))
|
||||
{
|
||||
Main_image_is_modified=0;
|
||||
Main_fileformat=save_context.Format;
|
||||
strcpy(Main_backups->Pages->Filename, save_context.File_name);
|
||||
strcpy(Main_backups->Pages->File_directory, save_context.File_directory);
|
||||
}
|
||||
if (!image)
|
||||
if (type == CONTEXT_BRUSH)
|
||||
{
|
||||
Brush_fileformat=save_context.Format;
|
||||
strcpy(Brush_filename, save_context.File_name);
|
||||
@ -3512,7 +3532,7 @@ void Save_picture(byte image)
|
||||
|
||||
void Button_Save(void)
|
||||
{
|
||||
Save_picture(1);
|
||||
Save_picture(CONTEXT_MAIN_IMAGE);
|
||||
}
|
||||
|
||||
/// Save main image over existing file (no fileselector)
|
||||
@ -4037,7 +4057,7 @@ void Button_Brush_FX(void)
|
||||
break;
|
||||
case 19 : // Save
|
||||
Display_cursor();
|
||||
Save_picture(0);
|
||||
Save_picture(CONTEXT_BRUSH);
|
||||
Hide_cursor();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#define __BOUTONS_H_
|
||||
|
||||
#include "struct.h"
|
||||
#include "loadsave.h"
|
||||
|
||||
void Stencil_update_color(byte color);
|
||||
void Stencil_tag_color(byte color, byte tag_color);
|
||||
@ -654,7 +655,7 @@ void Load_picture(byte image);
|
||||
/*!
|
||||
Save picture to file.
|
||||
*/
|
||||
void Save_picture(byte image);
|
||||
void Save_picture(enum CONTEXT_TYPE type);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
@ -1027,7 +1027,7 @@ void Main_handler(void)
|
||||
action++;
|
||||
break;
|
||||
case SPECIAL_SAVE_BRUSH :
|
||||
Save_picture(0);
|
||||
Save_picture(CONTEXT_BRUSH);
|
||||
action++;
|
||||
break;
|
||||
case SPECIAL_ZOOM_IN : // Zoom in
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
@ -1397,12 +1398,16 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context
|
||||
{
|
||||
if (context->Type == CONTEXT_MAIN_IMAGE)
|
||||
Open_window(310,200,"Save picture");
|
||||
else
|
||||
else if (context->Type == CONTEXT_BRUSH)
|
||||
Open_window(310,200,"Save brush");
|
||||
else if (context->Type == CONTEXT_PALETTE)
|
||||
Open_window(310,200,"Save palette");
|
||||
else
|
||||
assert(false);
|
||||
Window_set_normal_button(198,180,51,14,"Save",0,1,SDLK_RETURN); // 1
|
||||
if (Selector->Format_filter<=FORMAT_ALL_FILES) // Correction du *.*
|
||||
{
|
||||
Selector->Format_filter=Main_fileformat;
|
||||
Selector->Format_filter=context->Format;
|
||||
Selector->Position=0;
|
||||
Selector->Offset=0;
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ enum CONTEXT_TYPE {
|
||||
CONTEXT_BRUSH,
|
||||
CONTEXT_PREVIEW,
|
||||
CONTEXT_SURFACE,
|
||||
CONTEXT_PALETTE
|
||||
};
|
||||
|
||||
/// Data for a cycling color series. Heavily cloned from T_Gradient_array.
|
||||
|
||||
@ -2576,6 +2576,13 @@ void Button_Palette(void)
|
||||
Wait_end_of_click();
|
||||
break;
|
||||
}
|
||||
|
||||
case 26: // Load palette (TODO)
|
||||
break;
|
||||
|
||||
case 27: // Save palette
|
||||
Save_picture(CONTEXT_PALETTE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user