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
264
buttons.c
264
buttons.c
@ -309,10 +309,10 @@ void Button_Select_forecolor(void)
|
|||||||
// Check if it's a double-click
|
// Check if it's a double-click
|
||||||
if (time_click - time_previous < Config.Double_click_speed)
|
if (time_click - time_previous < Config.Double_click_speed)
|
||||||
{
|
{
|
||||||
// Open palette window
|
// Open palette window
|
||||||
Button_Palette();
|
Button_Palette();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (color!=-1)
|
else if (color!=-1)
|
||||||
{
|
{
|
||||||
Hide_cursor();
|
Hide_cursor();
|
||||||
@ -964,8 +964,8 @@ void Add_font_or_skin(const char *name)
|
|||||||
fname=name;
|
fname=name;
|
||||||
namelength = strlen(fname);
|
namelength = strlen(fname);
|
||||||
if (namelength>=10 && fname[0]!='_' && !strncasecmp(fname, "skin_", 5)
|
if (namelength>=10 && fname[0]!='_' && !strncasecmp(fname, "skin_", 5)
|
||||||
&& (!strcasecmp(fname+namelength-4,".png")
|
&& (!strcasecmp(fname+namelength-4,".png")
|
||||||
|| !strcasecmp(fname+namelength-4,".gif")))
|
|| !strcasecmp(fname+namelength-4,".gif")))
|
||||||
{
|
{
|
||||||
Add_element_to_list(&Skin_files_list, name, 0);
|
Add_element_to_list(&Skin_files_list, name, 0);
|
||||||
|
|
||||||
@ -976,8 +976,8 @@ void Add_font_or_skin(const char *name)
|
|||||||
strcpy(Skin_files_list.First->Full_name, fname);
|
strcpy(Skin_files_list.First->Full_name, fname);
|
||||||
// Reformat the short name differently
|
// Reformat the short name differently
|
||||||
strcpy(Skin_files_list.First->Short_name,
|
strcpy(Skin_files_list.First->Short_name,
|
||||||
Format_filename(Skin_files_list.First->Full_name, 0)
|
Format_filename(Skin_files_list.First->Full_name, 0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (namelength>=10 && !strncasecmp(fname, "font_", 5) && (!strcasecmp(fname+namelength-4,".png")))
|
else if (namelength>=10 && !strncasecmp(fname, "font_", 5) && (!strcasecmp(fname+namelength-4,".png")))
|
||||||
{
|
{
|
||||||
@ -1031,8 +1031,13 @@ void Button_Skins(void)
|
|||||||
char * cursors[] = { "Solid", "Transparent", "Thin" };
|
char * cursors[] = { "Solid", "Transparent", "Thin" };
|
||||||
T_Gui_skin * gfx = NULL;
|
T_Gui_skin * gfx = NULL;
|
||||||
|
|
||||||
|
|
||||||
#define FILESEL_Y 34
|
#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 ------------------
|
// --- Read the contents of skins/ directory ------------------
|
||||||
|
|
||||||
// Here we use the same data container as the fileselectors.
|
// Here we use the same data container as the fileselectors.
|
||||||
@ -1067,11 +1072,11 @@ void Button_Skins(void)
|
|||||||
|
|
||||||
// List of skins
|
// List of skins
|
||||||
skin_list = Window_set_list_button(
|
skin_list = Window_set_list_button(
|
||||||
// Fileselector
|
// Fileselector
|
||||||
Window_set_special_button(8, FILESEL_Y + 1, 144, 80), // 2
|
Window_set_special_button(8, FILESEL_Y + 1, 144, 80), // 2
|
||||||
// Scroller for the fileselector
|
// Scroller for the fileselector
|
||||||
(file_scroller = Window_set_scroller_button(155, FILESEL_Y - 1, 82,
|
(file_scroller = Window_set_scroller_button(155, FILESEL_Y - 1, 82,
|
||||||
Skin_files_list.Nb_elements, 10, 0)), // 3
|
Skin_files_list.Nb_elements, 10, 0)), // 3
|
||||||
Draw_one_skin_name); // 4
|
Draw_one_skin_name); // 4
|
||||||
|
|
||||||
skin_list->Cursor_position = Find_file_in_fileselector(&Skin_files_list, Config.Skin_file);
|
skin_list->Cursor_position = Find_file_in_fileselector(&Skin_files_list, Config.Skin_file);
|
||||||
@ -1086,17 +1091,17 @@ void Button_Skins(void)
|
|||||||
|
|
||||||
// Dropdown list to choose cursor type
|
// Dropdown list to choose cursor type
|
||||||
cursor_dropdown = Window_set_dropdown_button(172, 69, 104, 11, 0,
|
cursor_dropdown = Window_set_dropdown_button(172, 69, 104, 11, 0,
|
||||||
cursors[selected_cursor], 1, 0, 1, RIGHT_SIDE|LEFT_SIDE); // 7
|
cursors[selected_cursor], 1, 0, 1, RIGHT_SIDE|LEFT_SIDE); // 7
|
||||||
for (temp = 0; temp<3; temp++)
|
for (temp = 0; temp<3; temp++)
|
||||||
Window_dropdown_add_item(cursor_dropdown, temp, cursors[temp]);
|
Window_dropdown_add_item(cursor_dropdown, temp, cursors[temp]);
|
||||||
|
|
||||||
Window_set_normal_button(172, 87, 14, 14,
|
Window_set_normal_button(172, 87, 14, 14,
|
||||||
(Config.Display_image_limits)?"X":" ", -1, 1, SDLK_LAST); // 8
|
(Config.Display_image_limits)?"X":" ", -1, 1, SDLK_LAST); // 8
|
||||||
Print_in_window( 190, 85,"Draw picture", MC_Dark, MC_Light);
|
Print_in_window( 190, 85,"Draw picture", MC_Dark, MC_Light);
|
||||||
Print_in_window( 190, 94,"limits", MC_Dark, MC_Light);
|
Print_in_window( 190, 94,"limits", MC_Dark, MC_Light);
|
||||||
|
|
||||||
Window_set_normal_button(172, 111, 14, 14,
|
Window_set_normal_button(172, 111, 14, 14,
|
||||||
(Config.Separate_colors)?"X":" ", -1, 1, SDLK_LAST); // 9
|
(Config.Separate_colors)?"X":" ", -1, 1, SDLK_LAST); // 9
|
||||||
Print_in_window( 190, 109,"Separate", MC_Dark, MC_Light);
|
Print_in_window( 190, 109,"Separate", MC_Dark, MC_Light);
|
||||||
Print_in_window( 190, 118,"colors", MC_Dark, MC_Light);
|
Print_in_window( 190, 118,"colors", MC_Dark, MC_Light);
|
||||||
|
|
||||||
@ -1116,66 +1121,77 @@ void Button_Skins(void)
|
|||||||
|
|
||||||
switch(clicked_button)
|
switch(clicked_button)
|
||||||
{
|
{
|
||||||
case 1 : // OK
|
case 1 : // OK
|
||||||
break;
|
break;
|
||||||
case 2 : // doesn't happen
|
case 2 : // doesn't happen
|
||||||
break;
|
break;
|
||||||
case 3 : // doesn't happen
|
case 3 : // doesn't happen
|
||||||
break;
|
break;
|
||||||
case 4 : // a file is selected
|
case 4 : // a file is selected
|
||||||
|
|
||||||
// (Re-)load GUI graphics from selected skins
|
// (Re-)load GUI graphics from selected skins
|
||||||
strcpy(skinsdir, Get_item_by_index(&Skin_files_list,
|
strcpy(skinsdir, Get_item_by_index(&Skin_files_list,
|
||||||
skin_list->List_start + skin_list->Cursor_position)->Full_name);
|
skin_list->List_start + skin_list->Cursor_position)->Full_name);
|
||||||
|
|
||||||
gfx = Load_graphics(skinsdir);
|
gfx = Load_graphics(skinsdir);
|
||||||
if (gfx == NULL) // Error
|
if (gfx == NULL) // Error
|
||||||
{
|
{
|
||||||
Verbose_error_message(Gui_loading_error_message);
|
Verbose_error_message(Gui_loading_error_message);
|
||||||
// Update preview
|
// Update preview
|
||||||
Window_rectangle(4, 14, 174, 16, MC_Light);
|
Window_rectangle(4, 14, 174, 16, MC_Light);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Update preview
|
// 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 (y = 14, offs_y = 0; offs_y < 16; offs_y++, y++)
|
||||||
for (x = 6, x_pos = 0; x_pos<173; x_pos++, x++)
|
for (x = 6, x_pos = 0; x_pos<173; x_pos++, x++)
|
||||||
{
|
{
|
||||||
if (gfx->Preview[offs_y][x_pos] == gfx->Color_black)
|
if (gfx->Preview[offs_y][x_pos] == gfx->Color_black)
|
||||||
Pixel_in_window(x, y, MC_Black);
|
Pixel_in_window(x, y, MC_Black);
|
||||||
else if (gfx->Preview[offs_y][x_pos] == gfx->Color_dark)
|
else if (gfx->Preview[offs_y][x_pos] == gfx->Color_dark)
|
||||||
Pixel_in_window(x, y, MC_Dark);
|
Pixel_in_window(x, y, MC_Dark);
|
||||||
else if (gfx->Preview[offs_y][x_pos] == gfx->Color_white)
|
else if (gfx->Preview[offs_y][x_pos] == gfx->Color_white)
|
||||||
Pixel_in_window(x, y, MC_White);
|
Pixel_in_window(x, y, MC_White);
|
||||||
else if (gfx->Preview[offs_y][x_pos] == gfx->Color_light)
|
else if (gfx->Preview[offs_y][x_pos] == gfx->Color_light)
|
||||||
Pixel_in_window(x, y, MC_Light);
|
Pixel_in_window(x, y, MC_Light);
|
||||||
}
|
}
|
||||||
}
|
// Actualize current screen according to preferred GUI colors
|
||||||
Update_window_area(4, 14, 174, 16);
|
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);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 5 : // Font dropdown
|
case 5 : // Font dropdown
|
||||||
selected_font = Window_attribute2; // Get the index of the chosen font.
|
selected_font = Window_attribute2; // Get the index of the chosen font.
|
||||||
break;
|
break;
|
||||||
// 6: Cancel
|
// 6: Cancel
|
||||||
case 7 : // Cursor
|
case 7 : // Cursor
|
||||||
selected_cursor = Window_attribute2;
|
selected_cursor = Window_attribute2;
|
||||||
break;
|
break;
|
||||||
case 8: // Display limits
|
case 8: // Display limits
|
||||||
showlimits = !showlimits;
|
showlimits = !showlimits;
|
||||||
Hide_cursor();
|
Hide_cursor();
|
||||||
Print_in_window(175, 90, (showlimits)?"X":" ", MC_Black, MC_Light);
|
Print_in_window(175, 90, (showlimits)?"X":" ", MC_Black, MC_Light);
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
break;
|
break;
|
||||||
case 9: // Separate colors
|
case 9: // Separate colors
|
||||||
separatecolors = !separatecolors;
|
separatecolors = !separatecolors;
|
||||||
Hide_cursor();
|
Hide_cursor();
|
||||||
Print_in_window(175, 114, (separatecolors)?"X":" ", MC_Black, MC_Light);
|
Print_in_window(175, 114, (separatecolors)?"X":" ", MC_Black, MC_Light);
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ( (clicked_button!=1) && (clicked_button !=6) && (Key != SDLK_ESCAPE));
|
while ( (clicked_button!=1) && (clicked_button !=6) && (Key != SDLK_ESCAPE));
|
||||||
|
|
||||||
@ -1185,48 +1201,38 @@ void Button_Skins(void)
|
|||||||
|
|
||||||
if (gfx != NULL)
|
if (gfx != NULL)
|
||||||
{
|
{
|
||||||
free(Gfx);
|
Set_current_skin(skinsdir, gfx);
|
||||||
Gfx = gfx;
|
}
|
||||||
|
// (Re-)load the selected font
|
||||||
free(Config.Skin_file);
|
new_font = Load_font(Get_item_by_index(&Font_files_list,selected_font)->Full_name);
|
||||||
Config.Skin_file = strdup(skinsdir);
|
if (new_font)
|
||||||
|
{
|
||||||
Config.Fav_menu_colors[0] = gfx->Default_palette[gfx->Color_black];
|
const char * fname;
|
||||||
Config.Fav_menu_colors[1] = gfx->Default_palette[gfx->Color_dark];
|
|
||||||
Config.Fav_menu_colors[2] = gfx->Default_palette[gfx->Color_light];
|
free(Menu_font);
|
||||||
Config.Fav_menu_colors[3] = gfx->Default_palette[gfx->Color_white];
|
Menu_font = new_font;
|
||||||
|
fname = Get_item_by_index(&Font_files_list,selected_font)->Full_name;
|
||||||
MC_Black = gfx->Color_black;
|
free(Config.Font_file);
|
||||||
MC_Dark = gfx->Color_dark;
|
Config.Font_file = strdup(fname);
|
||||||
MC_Light = gfx->Color_light;
|
|
||||||
MC_White = gfx->Color_white;
|
|
||||||
MC_Trans = gfx->Color_trans;
|
|
||||||
}
|
}
|
||||||
// (Re-)load the selected font
|
|
||||||
new_font = Load_font(Get_item_by_index(&Font_files_list,selected_font)->Full_name);
|
|
||||||
if (new_font)
|
|
||||||
{
|
|
||||||
const char * fname;
|
|
||||||
|
|
||||||
free(Menu_font);
|
|
||||||
Menu_font = new_font;
|
|
||||||
fname = Get_item_by_index(&Font_files_list,selected_font)->Full_name;
|
|
||||||
free(Config.Font_file);
|
|
||||||
Config.Font_file = strdup(fname);
|
|
||||||
}
|
|
||||||
// Confirm the change of cursor shape
|
// Confirm the change of cursor shape
|
||||||
Config.Cursor = selected_cursor;
|
Config.Cursor = selected_cursor;
|
||||||
Config.Display_image_limits = showlimits;
|
Config.Display_image_limits = showlimits;
|
||||||
Config.Separate_colors = separatecolors;
|
Config.Separate_colors = separatecolors;
|
||||||
|
|
||||||
// Now find the best colors for the new skin in the current palette
|
// Now find the best colors for the new skin in the current palette
|
||||||
// and remap the skin
|
// and remap the skin
|
||||||
Compute_optimal_menu_colors(Main_palette);
|
Compute_optimal_menu_colors(Main_palette);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Set_palette(Main_palette);
|
||||||
|
}
|
||||||
|
|
||||||
Close_window();
|
Close_window();
|
||||||
Unselect_button(BUTTON_SETTINGS);
|
Unselect_button(BUTTON_SETTINGS);
|
||||||
|
|
||||||
// Raffichage du menu pour que les inscriptions qui y figurent soient retracées avec la nouvelle fonte
|
// Raffichage du menu pour que les inscriptions qui y figurent soient retracées avec la nouvelle fonte
|
||||||
Display_menu();
|
Display_menu();
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
@ -1236,7 +1242,7 @@ void Button_Skins(void)
|
|||||||
//---------------------------- Changement de page ----------------------------
|
//---------------------------- Changement de page ----------------------------
|
||||||
void Button_Page(void)
|
void Button_Page(void)
|
||||||
{
|
{
|
||||||
byte factor_index;
|
byte factor_index;
|
||||||
char Temp_buffer[256];
|
char Temp_buffer[256];
|
||||||
|
|
||||||
Hide_cursor();
|
Hide_cursor();
|
||||||
@ -1502,30 +1508,30 @@ void Display_modes_list(short list_start, short cursor_position)
|
|||||||
if(Video_mode[current_mode].Fullscreen == 0)
|
if(Video_mode[current_mode].Fullscreen == 0)
|
||||||
memcpy(str+9," Window ",20);
|
memcpy(str+9," Window ",20);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memcpy(str+9," Fullscreen ",13);
|
memcpy(str+9," Fullscreen ",13);
|
||||||
|
|
||||||
if (Video_mode[current_mode].Width*3 == Video_mode[current_mode].Height*4)
|
if (Video_mode[current_mode].Width*3 == Video_mode[current_mode].Height*4)
|
||||||
ratio=" 4:3";
|
ratio=" 4:3";
|
||||||
else if (Video_mode[current_mode].Width*9 == Video_mode[current_mode].Height*16)
|
else if (Video_mode[current_mode].Width*9 == Video_mode[current_mode].Height*16)
|
||||||
ratio=" 16:9";
|
ratio=" 16:9";
|
||||||
else if (Video_mode[current_mode].Width*10 == Video_mode[current_mode].Height*16)
|
else if (Video_mode[current_mode].Width*10 == Video_mode[current_mode].Height*16)
|
||||||
ratio=" 16:10";
|
ratio=" 16:10";
|
||||||
else if (Video_mode[current_mode].Width*145 == Video_mode[current_mode].Height*192)
|
else if (Video_mode[current_mode].Width*145 == Video_mode[current_mode].Height*192)
|
||||||
ratio="192:145";
|
ratio="192:145";
|
||||||
else if (Video_mode[current_mode].Width*2 == Video_mode[current_mode].Height*3)
|
else if (Video_mode[current_mode].Width*2 == Video_mode[current_mode].Height*3)
|
||||||
ratio=" 3:2";
|
ratio=" 3:2";
|
||||||
else if (Video_mode[current_mode].Width*3 == Video_mode[current_mode].Height*5)
|
else if (Video_mode[current_mode].Width*3 == Video_mode[current_mode].Height*5)
|
||||||
ratio=" 5:3";
|
ratio=" 5:3";
|
||||||
else if (Video_mode[current_mode].Width*4 == Video_mode[current_mode].Height*5)
|
else if (Video_mode[current_mode].Width*4 == Video_mode[current_mode].Height*5)
|
||||||
ratio=" 5:4";
|
ratio=" 5:4";
|
||||||
else if (Video_mode[current_mode].Width*16 == Video_mode[current_mode].Height*25)
|
else if (Video_mode[current_mode].Width*16 == Video_mode[current_mode].Height*25)
|
||||||
ratio=" 25:16";
|
ratio=" 25:16";
|
||||||
else
|
else
|
||||||
ratio=" ";
|
ratio=" ";
|
||||||
|
|
||||||
strcpy(str+21,ratio);
|
strcpy(str+21,ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
Print_in_window(38,y_pos,str,text_color,background_color);
|
Print_in_window(38,y_pos,str,text_color,background_color);
|
||||||
}
|
}
|
||||||
@ -2698,7 +2704,7 @@ void Load_picture(byte image)
|
|||||||
Brush_width=1;
|
Brush_width=1;
|
||||||
*Brush=Fore_color;
|
*Brush=Fore_color;
|
||||||
|
|
||||||
free(Smear_brush);
|
free(Smear_brush);
|
||||||
Smear_brush=(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE);
|
Smear_brush=(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE);
|
||||||
Smear_brush_height=MAX_PAINTBRUSH_SIZE;
|
Smear_brush_height=MAX_PAINTBRUSH_SIZE;
|
||||||
Smear_brush_width=MAX_PAINTBRUSH_SIZE;
|
Smear_brush_width=MAX_PAINTBRUSH_SIZE;
|
||||||
@ -5642,7 +5648,7 @@ void Button_Text()
|
|||||||
cursor_position = font_list->Cursor_position;
|
cursor_position = font_list->Cursor_position;
|
||||||
|
|
||||||
free(new_brush);
|
free(new_brush);
|
||||||
new_brush = NULL;
|
new_brush = NULL;
|
||||||
Close_window();
|
Close_window();
|
||||||
Unselect_button(BUTTON_TEXT);
|
Unselect_button(BUTTON_TEXT);
|
||||||
Display_cursor();
|
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_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.
|
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
|
// Input state
|
||||||
GFX2_GLOBAL word Mouse_X; ///< Current mouse cursor position.
|
GFX2_GLOBAL word Mouse_X; ///< Current mouse cursor position.
|
||||||
GFX2_GLOBAL word Mouse_Y; ///< 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;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
3
init.h
3
init.h
@ -21,8 +21,9 @@
|
|||||||
///@file init.h
|
///@file init.h
|
||||||
/// Initialization (and some de-initialization) functions.
|
/// Initialization (and some de-initialization) functions.
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
T_Gui_skin *Load_graphics(const char * skin_file);
|
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_buttons(void);
|
||||||
void Init_operations(void);
|
void Init_operations(void);
|
||||||
void Init_brush_container(void);
|
void Init_brush_container(void);
|
||||||
|
|||||||
105
main.c
105
main.c
@ -75,9 +75,6 @@
|
|||||||
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
|
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
|
||||||
#endif
|
#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 ---
|
//--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles ---
|
||||||
void Display_syntax(void)
|
void Display_syntax(void)
|
||||||
{
|
{
|
||||||
@ -173,18 +170,18 @@ void Error_function(int error_code, const char *filename, int line_number, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --------------------- Analyse de la ligne de commande ---------------------
|
// --------------------- Analyse de la ligne de commande ---------------------
|
||||||
void Analyze_command_line(int argc, char * argv[])
|
void Analyze_command_line(int argc,char * argv[])
|
||||||
{
|
{
|
||||||
char *buffer ;
|
char *buffer ;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
|
||||||
File_in_command_line = 0;
|
File_in_command_line=0;
|
||||||
Resolution_in_command_line = 0;
|
Resolution_in_command_line=0;
|
||||||
|
|
||||||
Current_resolution = Config.Default_resolution;
|
Current_resolution=Config.Default_resolution;
|
||||||
|
|
||||||
for (index = 1; index<argc; index++)
|
for (index=1; index<argc; index++)
|
||||||
{
|
{
|
||||||
if ( !strcmp(argv[index],"/?") ||
|
if ( !strcmp(argv[index],"/?") ||
|
||||||
!strcmp(argv[index],"/h") ||
|
!strcmp(argv[index],"/h") ||
|
||||||
@ -199,9 +196,9 @@ void Analyze_command_line(int argc, char * argv[])
|
|||||||
// mode
|
// mode
|
||||||
index++;
|
index++;
|
||||||
if (index<argc)
|
if (index<argc)
|
||||||
{
|
{
|
||||||
Resolution_in_command_line = 1;
|
Resolution_in_command_line = 1;
|
||||||
Current_resolution = Convert_videomode_arg(argv[index]);
|
Current_resolution=Convert_videomode_arg(argv[index]);
|
||||||
if (Current_resolution == -1)
|
if (Current_resolution == -1)
|
||||||
{
|
{
|
||||||
Error(ERROR_COMMAND_LINE);
|
Error(ERROR_COMMAND_LINE);
|
||||||
@ -278,7 +275,7 @@ void Analyze_command_line(int argc, char * argv[])
|
|||||||
index++;
|
index++;
|
||||||
if (index<argc)
|
if (index<argc)
|
||||||
{
|
{
|
||||||
strcpy(Gui_skin_file, argv[index]);
|
strcpy(Config.Skin_file,argv[index]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -290,31 +287,24 @@ void Analyze_command_line(int argc, char * argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Si ce n'est pas un paramètre, c'est le nom du fichier à ouvrir
|
// 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);
|
Error(ERROR_COMMAND_LINE);
|
||||||
Display_syntax();
|
Display_syntax();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if (File_exists(argv[index]))
|
else if (File_exists(argv[index]))
|
||||||
{
|
{
|
||||||
File_in_command_line ++;
|
File_in_command_line=1;
|
||||||
buffer = Realpath(argv[index], NULL);
|
|
||||||
|
|
||||||
if (File_in_command_line == 1)
|
// On récupère le chemin complet du paramètre
|
||||||
{
|
// Et on découpe ce chemin en répertoire(path) + fichier(.ext)
|
||||||
// Separate path from filename
|
buffer=Realpath(argv[index],NULL);
|
||||||
Extract_path(Main_file_directory, buffer);
|
Extract_path(Main_file_directory, buffer);
|
||||||
Extract_filename(Main_filename, buffer);
|
Extract_filename(Main_filename, buffer);
|
||||||
DEBUG(Main_filename, 0);
|
free(buffer);
|
||||||
free(buffer);
|
chdir(Main_file_directory);
|
||||||
} else {
|
|
||||||
Extract_path(Spare_file_directory, buffer);
|
|
||||||
Extract_filename(Spare_filename, buffer);
|
|
||||||
DEBUG(Spare_filename, 1);
|
|
||||||
free(buffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -333,6 +323,7 @@ int Init_program(int argc,char * argv[])
|
|||||||
int temp;
|
int temp;
|
||||||
int starting_videomode;
|
int starting_videomode;
|
||||||
char program_directory[MAX_PATH_CHARACTERS];
|
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
|
// 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
|
// principale et la page de brouillon afin que leurs champs ne soient pas
|
||||||
@ -555,48 +546,35 @@ int Init_program(int argc,char * argv[])
|
|||||||
if (temp)
|
if (temp)
|
||||||
Error(temp);
|
Error(temp);
|
||||||
|
|
||||||
Analyze_command_line(argc, argv);
|
Analyze_command_line(argc,argv);
|
||||||
|
|
||||||
Current_help_section=0;
|
Current_help_section=0;
|
||||||
Help_position=0;
|
Help_position=0;
|
||||||
|
|
||||||
// Load sprites, palette etc.
|
// Load sprites, palette etc.
|
||||||
strcpy(Gui_skin_file,Config.Skin_file);
|
gfx = Load_graphics(Config.Skin_file);
|
||||||
Gfx = Load_graphics(Gui_skin_file);
|
if (gfx == NULL)
|
||||||
if (Gfx == NULL)
|
|
||||||
{
|
{
|
||||||
Gfx = Load_graphics("skin_modern.png");
|
gfx = Load_graphics("skin_modern.png");
|
||||||
if (Gfx == NULL)
|
if (gfx == NULL)
|
||||||
{
|
{
|
||||||
printf("%s", Gui_loading_error_message);
|
printf("%s", Gui_loading_error_message);
|
||||||
Error(ERROR_GUI_MISSING);
|
Error(ERROR_GUI_MISSING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Config.Fav_menu_colors[0] = Gfx->Default_palette[Gfx->Color_black];
|
Set_current_skin(Config.Skin_file, gfx);
|
||||||
Config.Fav_menu_colors[1] = Gfx->Default_palette[Gfx->Color_dark];
|
Fore_color=MC_White;
|
||||||
Config.Fav_menu_colors[2] = Gfx->Default_palette[Gfx->Color_light];
|
Back_color=MC_Black;
|
||||||
Config.Fav_menu_colors[3] = Gfx->Default_palette[Gfx->Color_white];
|
// Override colors
|
||||||
|
|
||||||
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 !
|
|
||||||
// Gfx->Default_palette[MC_Black]=Fav_menu_colors[0]=Config.Fav_menu_colors[0];
|
// 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_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_Light]=Fav_menu_colors[2]=Config.Fav_menu_colors[2];
|
||||||
// Gfx->Default_palette[MC_White]=Fav_menu_colors[3]=Config.Fav_menu_colors[3];
|
// Gfx->Default_palette[MC_White]=Fav_menu_colors[3]=Config.Fav_menu_colors[3];
|
||||||
Compute_optimal_menu_colors(Gfx->Default_palette);
|
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
|
// Font
|
||||||
if (!(Menu_font=Load_font(Config.Font_file)))
|
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
|
// 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
|
// elle-même ne m'inspire pas confiance mais ça a l'air de marcher sans
|
||||||
// poser de problèmes, alors...
|
// 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_file_directory,Spare_current_directory);
|
||||||
strcpy(Spare_filename,"NO_NAME.GIF");
|
strcpy(Spare_filename,"NO_NAME.GIF");
|
||||||
@ -815,20 +793,11 @@ int main(int argc,char * argv[])
|
|||||||
if (Config.Opening_message && (!File_in_command_line))
|
if (Config.Opening_message && (!File_in_command_line))
|
||||||
Button_Message_initial();
|
Button_Message_initial();
|
||||||
|
|
||||||
switch (File_in_command_line)
|
if (File_in_command_line)
|
||||||
{
|
{
|
||||||
case 2:
|
Button_Reload();
|
||||||
Button_Reload();
|
Resolution_in_command_line=0;
|
||||||
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();
|
Main_handler();
|
||||||
|
|
||||||
|
|||||||
2
misc.c
2
misc.c
@ -159,7 +159,7 @@ void Set_color(byte color, byte red, byte green, byte blue)
|
|||||||
comp.r=red;
|
comp.r=red;
|
||||||
comp.g=green;
|
comp.g=green;
|
||||||
comp.b=blue;
|
comp.b=blue;
|
||||||
SDL_SetPalette(Screen_SDL, SDL_LOGPAL, &comp, color, 1);
|
SDL_SetPalette(Screen_SDL, SDL_PHYSPAL | SDL_LOGPAL, &comp, color, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wait_end_of_click(void)
|
void Wait_end_of_click(void)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user