Skin preview previews gui colors
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1123 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
fb3404e2ba
commit
e7f34fefe4
42
buttons.c
42
buttons.c
@ -1031,8 +1031,13 @@ void Button_Skins(void)
|
||||
char * cursors[] = { "Solid", "Transparent", "Thin" };
|
||||
T_Gui_skin * gfx = NULL;
|
||||
|
||||
|
||||
#define FILESEL_Y 34
|
||||
|
||||
// Show preferred colors
|
||||
Set_color(MC_Dark, Config.Fav_menu_colors[1].R, Config.Fav_menu_colors[1].G, Config.Fav_menu_colors[1].B);
|
||||
Set_color(MC_Light, Config.Fav_menu_colors[2].R, Config.Fav_menu_colors[2].G, Config.Fav_menu_colors[2].B);
|
||||
|
||||
// --- Read the contents of skins/ directory ------------------
|
||||
|
||||
// Here we use the same data container as the fileselectors.
|
||||
@ -1138,8 +1143,8 @@ void Button_Skins(void)
|
||||
else
|
||||
{
|
||||
// Update preview
|
||||
// The new palette is not in place but the skin is loaded using the
|
||||
// new color indexes, so we have to reverse-remap it...
|
||||
|
||||
// Display the bitmap according to its own color indices
|
||||
for (y = 14, offs_y = 0; offs_y < 16; offs_y++, y++)
|
||||
for (x = 6, x_pos = 0; x_pos<173; x_pos++, x++)
|
||||
{
|
||||
@ -1152,6 +1157,17 @@ void Button_Skins(void)
|
||||
else if (gfx->Preview[offs_y][x_pos] == gfx->Color_light)
|
||||
Pixel_in_window(x, y, MC_Light);
|
||||
}
|
||||
// Actualize current screen according to preferred GUI colors
|
||||
Set_color(
|
||||
MC_Dark,
|
||||
gfx->Default_palette[gfx->Color_dark].R,
|
||||
gfx->Default_palette[gfx->Color_dark].G,
|
||||
gfx->Default_palette[gfx->Color_dark].B);
|
||||
Set_color(
|
||||
MC_Light,
|
||||
gfx->Default_palette[gfx->Color_light].R,
|
||||
gfx->Default_palette[gfx->Color_light].G,
|
||||
gfx->Default_palette[gfx->Color_light].B);
|
||||
}
|
||||
Update_window_area(4, 14, 174, 16);
|
||||
|
||||
@ -1185,22 +1201,7 @@ void Button_Skins(void)
|
||||
|
||||
if (gfx != NULL)
|
||||
{
|
||||
free(Gfx);
|
||||
Gfx = gfx;
|
||||
|
||||
free(Config.Skin_file);
|
||||
Config.Skin_file = strdup(skinsdir);
|
||||
|
||||
Config.Fav_menu_colors[0] = gfx->Default_palette[gfx->Color_black];
|
||||
Config.Fav_menu_colors[1] = gfx->Default_palette[gfx->Color_dark];
|
||||
Config.Fav_menu_colors[2] = gfx->Default_palette[gfx->Color_light];
|
||||
Config.Fav_menu_colors[3] = gfx->Default_palette[gfx->Color_white];
|
||||
|
||||
MC_Black = gfx->Color_black;
|
||||
MC_Dark = gfx->Color_dark;
|
||||
MC_Light = gfx->Color_light;
|
||||
MC_White = gfx->Color_white;
|
||||
MC_Trans = gfx->Color_trans;
|
||||
Set_current_skin(skinsdir, gfx);
|
||||
}
|
||||
// (Re-)load the selected font
|
||||
new_font = Load_font(Get_item_by_index(&Font_files_list,selected_font)->Full_name);
|
||||
@ -1224,9 +1225,14 @@ void Button_Skins(void)
|
||||
Compute_optimal_menu_colors(Main_palette);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Set_palette(Main_palette);
|
||||
}
|
||||
|
||||
Close_window();
|
||||
Unselect_button(BUTTON_SETTINGS);
|
||||
|
||||
// Raffichage du menu pour que les inscriptions qui y figurent soient retracées avec la nouvelle fonte
|
||||
Display_menu();
|
||||
Display_cursor();
|
||||
|
||||
3
global.h
3
global.h
@ -71,9 +71,6 @@ GFX2_GLOBAL byte MC_Light; ///< Index of color to use as "light grey" in the GUI
|
||||
GFX2_GLOBAL byte MC_White; ///< Index of color to use as "white" in the GUI menus.
|
||||
GFX2_GLOBAL byte MC_Trans; ///< Index of color to use as "transparent" while loading the GUI file.
|
||||
|
||||
/// Favorite menu colors (RGB values).
|
||||
GFX2_GLOBAL T_Components Fav_menu_colors[4];
|
||||
|
||||
// Input state
|
||||
GFX2_GLOBAL word Mouse_X; ///< Current mouse cursor position.
|
||||
GFX2_GLOBAL word Mouse_Y; ///< Current mouse cursor position.
|
||||
|
||||
25
init.c
25
init.c
@ -2472,3 +2472,28 @@ void Init_brush_container(void)
|
||||
Brush_container[i].Brush = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Set_current_skin(const char *skinfile, T_Gui_skin *gfx)
|
||||
{
|
||||
// Free previous one
|
||||
free(Gfx);
|
||||
|
||||
// Assign main skin pointer
|
||||
Gfx = gfx;
|
||||
|
||||
// Change config
|
||||
free(Config.Skin_file);
|
||||
Config.Skin_file = strdup(skinfile);
|
||||
|
||||
Config.Fav_menu_colors[0] = gfx->Default_palette[gfx->Color_black];
|
||||
Config.Fav_menu_colors[1] = gfx->Default_palette[gfx->Color_dark];
|
||||
Config.Fav_menu_colors[2] = gfx->Default_palette[gfx->Color_light];
|
||||
Config.Fav_menu_colors[3] = gfx->Default_palette[gfx->Color_white];
|
||||
|
||||
// Reassign GUI color indices
|
||||
MC_Black = gfx->Color_black;
|
||||
MC_Dark = gfx->Color_dark;
|
||||
MC_Light = gfx->Color_light;
|
||||
MC_White = gfx->Color_white;
|
||||
MC_Trans = gfx->Color_trans;
|
||||
}
|
||||
|
||||
1
init.h
1
init.h
@ -23,6 +23,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
T_Gui_skin *Load_graphics(const char * skin_file);
|
||||
void Set_current_skin(const char *skinfile, T_Gui_skin *gfx);
|
||||
void Init_buttons(void);
|
||||
void Init_operations(void);
|
||||
void Init_brush_container(void);
|
||||
|
||||
77
main.c
77
main.c
@ -75,9 +75,6 @@
|
||||
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
|
||||
#endif
|
||||
|
||||
// filename for the current GUI skin file.
|
||||
static char Gui_skin_file[MAX_PATH_CHARACTERS];
|
||||
|
||||
//--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles ---
|
||||
void Display_syntax(void)
|
||||
{
|
||||
@ -278,7 +275,7 @@ void Analyze_command_line(int argc, char * argv[])
|
||||
index++;
|
||||
if (index<argc)
|
||||
{
|
||||
strcpy(Gui_skin_file, argv[index]);
|
||||
strcpy(Config.Skin_file,argv[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -290,31 +287,24 @@ void Analyze_command_line(int argc, char * argv[])
|
||||
else
|
||||
{
|
||||
// Si ce n'est pas un paramètre, c'est le nom du fichier à ouvrir
|
||||
if (File_in_command_line > 1)
|
||||
if (File_in_command_line)
|
||||
{
|
||||
// Il y a déjà 2 noms de fichiers et on vient d'en trouver un 3ème
|
||||
// plusieurs noms de fichier en argument
|
||||
Error(ERROR_COMMAND_LINE);
|
||||
Display_syntax();
|
||||
exit(0);
|
||||
}
|
||||
else if (File_exists(argv[index]))
|
||||
{
|
||||
File_in_command_line ++;
|
||||
buffer = Realpath(argv[index], NULL);
|
||||
File_in_command_line=1;
|
||||
|
||||
if (File_in_command_line == 1)
|
||||
{
|
||||
// Separate path from filename
|
||||
// On récupère le chemin complet du paramètre
|
||||
// Et on découpe ce chemin en répertoire(path) + fichier(.ext)
|
||||
buffer=Realpath(argv[index],NULL);
|
||||
Extract_path(Main_file_directory, buffer);
|
||||
Extract_filename(Main_filename, buffer);
|
||||
DEBUG(Main_filename, 0);
|
||||
free(buffer);
|
||||
} else {
|
||||
Extract_path(Spare_file_directory, buffer);
|
||||
Extract_filename(Spare_filename, buffer);
|
||||
DEBUG(Spare_filename, 1);
|
||||
free(buffer);
|
||||
}
|
||||
chdir(Main_file_directory);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -333,6 +323,7 @@ int Init_program(int argc,char * argv[])
|
||||
int temp;
|
||||
int starting_videomode;
|
||||
char program_directory[MAX_PATH_CHARACTERS];
|
||||
T_Gui_skin *gfx;
|
||||
|
||||
// On crée dès maintenant les descripteurs des listes de pages pour la page
|
||||
// principale et la page de brouillon afin que leurs champs ne soient pas
|
||||
@ -561,42 +552,29 @@ int Init_program(int argc,char * argv[])
|
||||
Help_position=0;
|
||||
|
||||
// Load sprites, palette etc.
|
||||
strcpy(Gui_skin_file,Config.Skin_file);
|
||||
Gfx = Load_graphics(Gui_skin_file);
|
||||
if (Gfx == NULL)
|
||||
gfx = Load_graphics(Config.Skin_file);
|
||||
if (gfx == NULL)
|
||||
{
|
||||
Gfx = Load_graphics("skin_modern.png");
|
||||
if (Gfx == NULL)
|
||||
gfx = Load_graphics("skin_modern.png");
|
||||
if (gfx == NULL)
|
||||
{
|
||||
printf("%s", Gui_loading_error_message);
|
||||
Error(ERROR_GUI_MISSING);
|
||||
}
|
||||
}
|
||||
Config.Fav_menu_colors[0] = Gfx->Default_palette[Gfx->Color_black];
|
||||
Config.Fav_menu_colors[1] = Gfx->Default_palette[Gfx->Color_dark];
|
||||
Config.Fav_menu_colors[2] = Gfx->Default_palette[Gfx->Color_light];
|
||||
Config.Fav_menu_colors[3] = Gfx->Default_palette[Gfx->Color_white];
|
||||
|
||||
MC_Black = Gfx->Color_black;
|
||||
MC_Dark = Gfx->Color_dark;
|
||||
MC_Light = Gfx->Color_light;
|
||||
MC_White = Gfx->Color_white;
|
||||
MC_Trans = Gfx->Color_trans;
|
||||
|
||||
// Infos sur les trames (Sieve)
|
||||
Sieve_mode=0;
|
||||
Copy_preset_sieve(0);
|
||||
|
||||
// Transfert des valeurs du .INI qui ne changent pas dans des variables
|
||||
// plus accessibles:
|
||||
// Let's load the colors from the skin instead !
|
||||
Set_current_skin(Config.Skin_file, gfx);
|
||||
Fore_color=MC_White;
|
||||
Back_color=MC_Black;
|
||||
// Override colors
|
||||
// Gfx->Default_palette[MC_Black]=Fav_menu_colors[0]=Config.Fav_menu_colors[0];
|
||||
// Gfx->Default_palette[MC_Dark] =Fav_menu_colors[1]=Config.Fav_menu_colors[1];
|
||||
// Gfx->Default_palette[MC_Light]=Fav_menu_colors[2]=Config.Fav_menu_colors[2];
|
||||
// Gfx->Default_palette[MC_White]=Fav_menu_colors[3]=Config.Fav_menu_colors[3];
|
||||
Compute_optimal_menu_colors(Gfx->Default_palette);
|
||||
Fore_color=MC_White;
|
||||
Back_color=MC_Black;
|
||||
|
||||
// Infos sur les trames (Sieve)
|
||||
Sieve_mode=0;
|
||||
Copy_preset_sieve(0);
|
||||
|
||||
// Font
|
||||
if (!(Menu_font=Load_font(Config.Font_file)))
|
||||
@ -657,7 +635,7 @@ int Init_program(int argc,char * argv[])
|
||||
// Brouillon_* et pas les infos contenues dans la page de brouillon
|
||||
// elle-même ne m'inspire pas confiance mais ça a l'air de marcher sans
|
||||
// poser de problèmes, alors...
|
||||
if (File_in_command_line == 1)
|
||||
if (File_in_command_line)
|
||||
{
|
||||
strcpy(Spare_file_directory,Spare_current_directory);
|
||||
strcpy(Spare_filename,"NO_NAME.GIF");
|
||||
@ -815,19 +793,10 @@ int main(int argc,char * argv[])
|
||||
if (Config.Opening_message && (!File_in_command_line))
|
||||
Button_Message_initial();
|
||||
|
||||
switch (File_in_command_line)
|
||||
if (File_in_command_line)
|
||||
{
|
||||
case 2:
|
||||
Button_Reload();
|
||||
DEBUG(Main_filename, 0);
|
||||
DEBUG(Spare_filename, 0);
|
||||
Button_Page();
|
||||
// no break ! proceed with the other file now
|
||||
case 1:
|
||||
Button_Reload();
|
||||
Resolution_in_command_line=0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
Main_handler();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user