Default gradients (or cycles) are now loaded from skins. Initialized all current skins so that range 0 is a white->black range, this way the grad shapes are immediately efficient. Still has a problem when loading an image in command-line.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1714 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
af857c09c9
commit
1e6c4d22bc
@ -1363,7 +1363,7 @@ void Button_Skins(void)
|
||||
strcpy(skinsdir, Get_item_by_index(&Skin_files_list,
|
||||
skin_list->List_start + skin_list->Cursor_position)->Full_name);
|
||||
|
||||
gfx = Load_graphics(skinsdir);
|
||||
gfx = Load_graphics(skinsdir, NULL);
|
||||
if (gfx == NULL) // Error
|
||||
{
|
||||
Display_cursor();
|
||||
@ -2668,7 +2668,7 @@ void Button_Gradients(void)
|
||||
Hide_cursor();
|
||||
// On inverse le sens (par un XOR de 1)
|
||||
Main_backups->Pages->Gradients->Range[Current_gradient].Inverse^=1;
|
||||
Print_in_window(12,25,(Main_backups->Pages->Gradients->Range[Current_gradient].Inverse)?"\033":"\032",MC_Black,MC_Light);
|
||||
Print_in_window(12,23,(Main_backups->Pages->Gradients->Range[Current_gradient].Inverse)?"\033":"\032",MC_Black,MC_Light);
|
||||
// On affiche la nouvelle preview
|
||||
Draw_gradient_preview(8,128,108,14,Current_gradient);
|
||||
Display_cursor();
|
||||
|
||||
28
src/init.c
28
src/init.c
@ -643,7 +643,7 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
T_Gui_skin * Load_graphics(const char * skin_file)
|
||||
T_Gui_skin * Load_graphics(const char * skin_file, T_Gradient_array *gradients)
|
||||
{
|
||||
T_Gui_skin * gfx;
|
||||
char filename[MAX_PATH_CHARACTERS];
|
||||
@ -661,7 +661,7 @@ T_Gui_skin * Load_graphics(const char * skin_file)
|
||||
strcat(filename,SKINS_SUBDIRECTORY PATH_SEPARATOR);
|
||||
strcat(filename,skin_file);
|
||||
|
||||
gui=Load_surface(filename);
|
||||
gui=Load_surface(filename, gradients);
|
||||
if (!gui)
|
||||
{
|
||||
sprintf(Gui_loading_error_message, "Unable to load the skin image (missing? not an image file?)\n");
|
||||
@ -739,7 +739,7 @@ byte * Load_font(const char * font_name)
|
||||
// Read the file containing the image
|
||||
sprintf(filename,"%s" SKINS_SUBDIRECTORY "%s%s", Data_directory, PATH_SEPARATOR, font_name);
|
||||
|
||||
image=Load_surface(filename);
|
||||
image=Load_surface(filename, NULL);
|
||||
if (!image)
|
||||
{
|
||||
sprintf(Gui_loading_error_message, "Unable to load the skin image (missing? not an image file?)\n");
|
||||
@ -2557,28 +2557,6 @@ void Set_config_defaults(void)
|
||||
// Stencil
|
||||
for (index=0; index<256; index++)
|
||||
Stencil[index]=1;
|
||||
|
||||
// Dégradés
|
||||
/* TODO
|
||||
Current_gradient=0;
|
||||
for(index=0;index<16;index++)
|
||||
{
|
||||
Gradient_array[index].Start=0;
|
||||
Gradient_array[index].End=0;
|
||||
Gradient_array[index].Inverse=0;
|
||||
Gradient_array[index].Mix=0;
|
||||
Gradient_array[index].Technique=0;
|
||||
}
|
||||
Load_gradient_data(Current_gradient);
|
||||
*/
|
||||
// Can't Load_gradient_data(), it depends on Backup system
|
||||
// and this function can be called before Backup system is ready.
|
||||
Gradient_function=Gradient_basic;
|
||||
Gradient_lower_bound=0;
|
||||
Gradient_upper_bound=0;
|
||||
Gradient_random_factor=1;
|
||||
Gradient_bounds_range=1;
|
||||
|
||||
|
||||
// Smooth
|
||||
Smooth_matrix[0][0]=1;
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
/// Initialization (and some de-initialization) functions.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
T_Gui_skin *Load_graphics(const char * skin_file);
|
||||
T_Gui_skin *Load_graphics(const char * skin_file, T_Gradient_array *gradients);
|
||||
void Set_current_skin(const char *skinfile, T_Gui_skin *gfx);
|
||||
void Init_buttons(void);
|
||||
void Init_operations(void);
|
||||
|
||||
@ -1013,8 +1013,10 @@ void Load_SDL_Image(T_IO_Context *context)
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
|
||||
///
|
||||
/// Load an arbitrary SDL_Surface.
|
||||
SDL_Surface * Load_surface(char *full_name)
|
||||
/// @param gradients Pass the address of a target T_Gradient_array if you want the gradients, NULL otherwise
|
||||
SDL_Surface * Load_surface(char *full_name, T_Gradient_array *gradients)
|
||||
{
|
||||
SDL_Surface * bmp=NULL;
|
||||
T_IO_Context context;
|
||||
@ -1023,8 +1025,23 @@ SDL_Surface * Load_surface(char *full_name)
|
||||
Load_image(&context);
|
||||
|
||||
if (context.Surface)
|
||||
{
|
||||
bmp=context.Surface;
|
||||
|
||||
// Caller wants the gradients:
|
||||
if (gradients != NULL)
|
||||
{
|
||||
int i;
|
||||
|
||||
memset(gradients, 0, sizeof(T_Gradient_array));
|
||||
for (i=0; i<context.Color_cycles; i++)
|
||||
{
|
||||
gradients->Range[i].Start=context.Cycle_range[i].Start;
|
||||
gradients->Range[i].End=context.Cycle_range[i].End;
|
||||
gradients->Range[i].Inverse=context.Cycle_range[i].Inverse;
|
||||
gradients->Range[i].Speed=context.Cycle_range[i].Speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
Destroy_context(&context);
|
||||
|
||||
return bmp;
|
||||
|
||||
@ -181,8 +181,10 @@ extern T_Format File_formats[];
|
||||
/// is too high.
|
||||
void Image_emergency_backup(void);
|
||||
|
||||
///
|
||||
/// Load an arbitrary SDL_Surface.
|
||||
SDL_Surface * Load_surface(char *full_name);
|
||||
/// @param gradients Pass the address of a target T_Gradient_array if you want the gradients, NULL otherwise
|
||||
SDL_Surface * Load_surface(char *full_name, T_Gradient_array *gradients);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
18
src/main.c
18
src/main.c
@ -426,6 +426,7 @@ int Init_program(int argc,char * argv[])
|
||||
static char program_directory[MAX_PATH_CHARACTERS];
|
||||
T_Gui_skin *gfx;
|
||||
int file_in_command_line;
|
||||
T_Gradient_array initial_gradients;
|
||||
static char main_filename [MAX_PATH_CHARACTERS];
|
||||
static char main_directory[MAX_PATH_CHARACTERS];
|
||||
static char spare_filename [MAX_PATH_CHARACTERS];
|
||||
@ -666,10 +667,10 @@ int Init_program(int argc,char * argv[])
|
||||
Help_position=0;
|
||||
|
||||
// Load sprites, palette etc.
|
||||
gfx = Load_graphics(Config.Skin_file);
|
||||
gfx = Load_graphics(Config.Skin_file, &initial_gradients);
|
||||
if (gfx == NULL)
|
||||
{
|
||||
gfx = Load_graphics(DEFAULT_SKIN_FILENAME);
|
||||
gfx = Load_graphics(DEFAULT_SKIN_FILENAME, &initial_gradients);
|
||||
if (gfx == NULL)
|
||||
{
|
||||
printf("%s", Gui_loading_error_message);
|
||||
@ -750,6 +751,19 @@ int Init_program(int argc,char * argv[])
|
||||
// Nettoyage de l'écran virtuel (les autres recevront celui-ci par copie)
|
||||
memset(Main_screen,0,Main_image_width*Main_image_height);
|
||||
|
||||
// Now that the backup system is there, we can store the gradients.
|
||||
memcpy(Main_backups->Pages->Gradients->Range, initial_gradients.Range, sizeof(initial_gradients.Range));
|
||||
memcpy(Spare_backups->Pages->Gradients->Range, initial_gradients.Range, sizeof(initial_gradients.Range));
|
||||
|
||||
Gradient_function=Gradient_basic;
|
||||
Gradient_lower_bound=0;
|
||||
Gradient_upper_bound=0;
|
||||
Gradient_random_factor=1;
|
||||
Gradient_bounds_range=1;
|
||||
|
||||
Current_gradient=0;
|
||||
Load_gradient_data(0);
|
||||
|
||||
// Initialisation de diverses variables par calcul:
|
||||
Compute_magnifier_data();
|
||||
Compute_limits();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user