781
807
Print_in_window(256,123,"X" ,MC_Dark,MC_Light);
782
808
Print_in_window(292,123,"Y" ,MC_Dark,MC_Light);
785
Window_set_normal_button(17,28,59,14,"Classic",0,1,SDLK_LAST); // 1
786
Window_set_normal_button(91,28,59,14,"Fun" ,0,1,SDLK_LAST); // 2
788
811
// Button Show/Hide dans le fileselect
789
Window_set_normal_button(167, 28,131,14,"Hidden files: ",0,1,SDLK_LAST); // 3
790
Window_set_normal_button(167, 43,131,14,"Hidden dir. : ",0,1,SDLK_LAST); // 4
791
// Window_set_normal_button(167, 58,131,14,"System dir. : ",0,1,SDLK_LAST); // 5
812
Window_set_normal_button(167, 28,131,14,"Hidden files: ",0,1,SDLK_LAST); // 1
813
Window_set_normal_button(167, 43,131,14,"Hidden dir. : ",0,1,SDLK_LAST); // 2
814
// Window_set_normal_button(167, 58,131,14,"System dir. : ",0,1,SDLK_LAST);
793
816
// Button Show/Hide Picture limits
794
Window_set_normal_button( 9, 81,107,14,"Limits : ",0,1,SDLK_LAST); // 6
795
// Button Show/Hide Picture limits
796
Window_set_normal_button( 9, 96,107,14,"Clear pal: ",0,1,SDLK_LAST); // 7
797
// Button Show/Hide Picture limits
798
Window_set_normal_button( 9,111,107,14,"Max prev.: ",0,1,SDLK_LAST); // 8
817
Window_set_normal_button( 9, 81,107,14,"Limits : ",0,1,SDLK_LAST); // 3
818
// Button Show/Hide Picture limits
819
Window_set_normal_button( 9, 96,107,14,"Clear pal: ",0,1,SDLK_LAST); // 4
820
// Button Show/Hide Picture limits
821
Window_set_normal_button( 9,111,107,14,"Max prev.: ",0,1,SDLK_LAST); // 5
799
822
// Button Effectuer des backups � chaque sauvegarde
800
Window_set_normal_button( 9,126,107,14,"Backup : ",0,1,SDLK_LAST); // 9
801
// Button item du curseur
802
Window_set_normal_button( 9,141,107,14,"Cursor: ",0,1,SDLK_LAST); // 10
823
Window_set_normal_button( 9,126,107,14,"Backup : ",0,1,SDLK_LAST); // 6
804
825
// Button Safety colors
805
Window_set_normal_button(117, 81,131,14,"Safe. colors: ",0,1,SDLK_LAST); // 11
826
Window_set_normal_button(117, 81,131,14,"Safe. colors: ",0,1,SDLK_LAST); // 7
806
827
// Button Adjust Brush Pick
807
Window_set_normal_button(117, 96,131,14,"AdjBrushPick: ",0,1,SDLK_LAST); // 12
828
Window_set_normal_button(117, 96,131,14,"AdjBrushPick: ",0,1,SDLK_LAST); // 8
808
829
// Button Separate colors
809
Window_set_normal_button(117,111,131,14,"Separate col: ",0,1,SDLK_LAST); // 13
830
Window_set_normal_button(117,111,131,14,"Separate col: ",0,1,SDLK_LAST); // 9
810
831
// Button Passer dans la r�solution appropri�e apr�s un chargement
811
Window_set_normal_button(117,126,131,14,"Auto-set res: ",0,1,SDLK_LAST); // 14
832
Window_set_normal_button(117,126,131,14,"Auto-set res: ",0,1,SDLK_LAST); // 10
812
833
// Button Adapter la palette apr�s un chargement (<=> Shift+BkSpc)
813
Window_set_normal_button(117,141,131,14,"Coords: ",0,1,SDLK_LAST); // 15
834
Window_set_normal_button(117,141,131,14,"Coords: ",0,1,SDLK_LAST); // 11
816
Window_set_normal_button( 6,163, 51,14,"Reload" ,0,1,SDLK_LAST); // 16
837
Window_set_normal_button( 6,163, 51,14,"Reload" ,0,1,SDLK_LAST); // 12
817
838
// Button Auto-save
818
Window_set_normal_button( 73,163,107,14,"Auto-save: ",0,1,SDLK_LAST); // 17
839
Window_set_normal_button( 73,163,107,14,"Auto-save: ",0,1,SDLK_LAST); // 13
820
Window_set_normal_button(183,163, 51,14,"Save" ,0,1,SDLK_LAST); // 18
841
Window_set_normal_button(183,163, 51,14,"Save" ,0,1,SDLK_LAST); // 14
822
Window_set_normal_button(250,163, 51,14,"Close" ,0,1,KEY_ESC); // 19
843
Window_set_normal_button(250,163, 51,14,"Close" ,0,1,KEY_ESC); // 15
824
845
// Jauges de sensibilit� de la souris (X puis Y)
825
Window_set_scroller_button(265,99,56,4,1,0); // 20
826
Window_set_scroller_button(279,99,56,4,1,0); // 21
846
Window_set_scroller_button(265,99,56,4,1,0); // 16
847
Window_set_scroller_button(279,99,56,4,1,0); // 17
828
849
// Zone de saisie du nb de pages de Undo
829
Window_set_input_button(140,50,2); // 22
850
Window_set_input_button(140,50,2); // 18
831
852
Update_window_area(0,0,Window_width, Window_height);
962
971
Set_number_of_backups(Config.Max_undo_pages);
974
// Data for skin selector
975
T_Fileselector Skin_files_list;
978
// Data for font selector
979
T_Fileselector Font_files_list;
982
char * Format_font_filename(const char * fname)
984
static char result[12];
988
fname+=5; // Assume "font_" prefix
989
length=strlen(fname) - 4; // assume .png extension
991
for (c=0;c<11 && c<length ;c++)
997
result[10] = ELLIPSIS_CHARACTER;
1002
// Add a skin to the list
1003
void Add_font_or_skin(const char *name)
1008
// Cut the long name to keep only filename (no directory)
1009
fname = Find_last_slash(name);
1014
namelength = strlen(fname);
1015
if (namelength>=10 && fname[0]!='_' && !strncasecmp(fname, "skin_", 5)
1016
&& (!strcasecmp(fname+namelength-4,".png")
1017
|| !strcasecmp(fname+namelength-4,".gif")))
1019
Add_element_to_list(&Skin_files_list, name, 0);
1024
// Remove directory from full name
1025
strcpy(Skin_files_list.First->Full_name, fname);
1026
// Reformat the short name differently
1027
strcpy(Skin_files_list.First->Short_name,
1028
Format_filename(Skin_files_list.First->Full_name, 0)
1031
else if (namelength>=10 && !strncasecmp(fname, "font_", 5) && (!strcasecmp(fname+namelength-4,".png")))
1033
Add_element_to_list(&Font_files_list, name, 0);
1038
// Remove directory from full name
1039
strcpy(Font_files_list.First->Full_name, fname);
1040
// Reformat the short name differently
1041
strcpy(Font_files_list.First->Short_name,Format_font_filename(Font_files_list.First->Full_name));
1046
// Callback to display a skin name in the list
1047
void Draw_one_skin_name(word x, word y, word index, byte highlighted)
1049
T_Fileselector_item * current_item;
1051
if (Skin_files_list.Nb_elements)
1053
current_item = Get_item_by_index(&Skin_files_list, index);
1054
Print_in_window(x,y,current_item->Short_name, MC_Black, (highlighted)?MC_Dark:MC_Light);
1058
/// Skin selector window
1059
void Button_Skins(void)
1061
short clicked_button;
1063
char skinsdir[MAX_PATH_CHARACTERS];
1064
T_Dropdown_button * font_dropdown;
1065
T_Dropdown_button * cursor_dropdown;
1066
T_List_button * skin_list;
1067
T_Scroller_button * file_scroller;
1068
int selected_font=0;
1069
int selected_cursor=Config.Cursor;
1071
char * cursors[] = { "Solid", "Transparent", "Thin" };
1073
#define FILESEL_Y 52
1075
// --- Read the contents of skins/ directory ------------------
1077
// Here we use the same data container as the fileselectors.
1078
// Reinitialize the list
1079
Free_fileselector_list(&Skin_files_list);
1080
Free_fileselector_list(&Font_files_list);
1081
// Browse the "skins" directory
1082
strcpy(skinsdir,Data_directory);
1083
strcat(skinsdir,"skins");
1084
// Add each found file to the list
1085
For_each_file(skinsdir, Add_font_or_skin);
1087
Sort_list_of_files(&Skin_files_list);
1088
Sort_list_of_files(&Font_files_list);
1090
selected_font = Find_file_in_fileselector(&Font_files_list, Config.Font_file);
1092
// --------------------------------------------------------------
1094
Open_window(178,155,"Skins");
1097
Window_display_frame_in(6,FILESEL_Y-2,148,84); // File selector
1100
Print_in_window( 6, 21,"Font" ,MC_Black,MC_Light);
1101
Print_in_window( 6, 36,"Cursor" ,MC_Black,MC_Light);
1104
Window_set_normal_button(6,136, 51,14,"OK" ,0,1,SDLK_RETURN); // 1
1107
skin_list = Window_set_list_button(
1109
Window_set_special_button(8,FILESEL_Y+1,144,80), // 2
1110
// Scroller for the fileselector
1111
(file_scroller = Window_set_scroller_button(160,FILESEL_Y+1,82,
1112
Skin_files_list.Nb_elements,10,0)), // 3
1113
Draw_one_skin_name); // 4
1115
skin_list->Cursor_position = Find_file_in_fileselector(&Skin_files_list, Config.Skin_file);
1117
// Buttons to choose a font
1118
font_dropdown = Window_set_dropdown_button(60,19,104,11,0, Get_item_by_index(&Font_files_list,selected_font)->Short_name,1,0,1,RIGHT_SIDE|LEFT_SIDE); // 5
1119
for (temp=0; temp<Font_files_list.Nb_files; temp++)
1120
Window_dropdown_add_item(font_dropdown,temp,Get_item_by_index(&Font_files_list,temp)->Short_name);
1123
Window_set_normal_button(62,136, 51,14,"Cancel",0,1,SDLK_ESCAPE); // 6
1125
// Dropdown list to choose cursor type
1126
cursor_dropdown = Window_set_dropdown_button(60,34,104,11,0,cursors[selected_cursor],1,0,1,RIGHT_SIDE|LEFT_SIDE); // 7
1127
for (temp=0; temp<3; temp++)
1128
Window_dropdown_add_item(cursor_dropdown,temp,cursors[temp]);
1130
Window_redraw_list(skin_list);
1132
Update_window_area(0,0,Window_width, Window_height);
1138
clicked_button=Window_clicked_button();
1140
switch(clicked_button)
1144
case 2 : // doesn't happen
1146
case 3 : // doesn't happen
1148
case 4 : // a file is selected
1150
case 5 : // Font dropdown
1151
selected_font=Window_attribute2; // Get the index of the chosen font.
1155
selected_cursor = Window_attribute2;
1161
case SDLK_UNKNOWN : break;
1163
case SDLK_DOWN : // Bas
1164
*quicksearch_filename=0;
1166
Selector_scroll_down(&Main_fileselector_position,&Main_fileselector_offset);
1167
if (file_scroller->Position!=Main_fileselector_position)
1169
// Si c'est le cas, il faut mettre � jour la jauge
1170
file_scroller->Position=Main_fileselector_position;
1171
Window_draw_slider(file_scroller);
1175
case SDLK_UP : // Haut
1176
*quicksearch_filename=0;
1178
Selector_scroll_up(&Main_fileselector_position,&Main_fileselector_offset);
1179
if (file_scroller->Position!=Main_fileselector_position)
1181
// Si c'est le cas, il faut mettre � jour la jauge
1182
file_scroller->Position=Main_fileselector_position;
1183
Window_draw_slider(file_scroller);
1187
case SDLK_PAGEDOWN : // PageDown
1188
case KEY_MOUSEWHEELDOWN :
1189
*quicksearch_filename=0;
1191
Selector_page_down(&Main_fileselector_position,&Main_fileselector_offset,9);
1192
if (file_scroller->Position!=Main_fileselector_position)
1194
// Si c'est le cas, il faut mettre � jour la jauge
1195
file_scroller->Position=Main_fileselector_position;
1196
Window_draw_slider(file_scroller);
1200
case SDLK_PAGEUP : // PageUp
1201
case KEY_MOUSEWHEELUP :
1202
*quicksearch_filename=0;
1204
Selector_page_up(&Main_fileselector_position,&Main_fileselector_offset,9);
1205
if (file_scroller->Position!=Main_fileselector_position)
1207
// Si c'est le cas, il faut mettre � jour la jauge
1208
file_scroller->Position=Main_fileselector_position;
1209
Window_draw_slider(file_scroller);
1213
case SDLK_END : // End
1214
*quicksearch_filename=0;
1216
Selector_end(&Main_fileselector_position,&Main_fileselector_offset);
1217
if (file_scroller->Position!=Main_fileselector_position)
1219
// Si c'est le cas, il faut mettre � jour la jauge
1220
file_scroller->Position=Main_fileselector_position;
1221
Window_draw_slider(file_scroller);
1225
case SDLK_HOME : // Home
1226
*quicksearch_filename=0;
1228
Selector_home(&Main_fileselector_position,&Main_fileselector_offset);
1229
if (file_scroller->Position!=Main_fileselector_position)
1231
// Si c'est le cas, il faut mettre � jour la jauge
1232
file_scroller->Position=Main_fileselector_position;
1233
Window_draw_slider(file_scroller);
1237
default: // Autre => On se place sur le nom de fichier qui correspond
1238
if (clicked_button<=0)
1240
if (Is_shortcut(Key,0x100+BUTTON_HELP))
1242
Window_help(BUTTON_SETTINGS, NULL);
1245
temp=strlen(quicksearch_filename);
1246
if (Key_ANSI>= ' ' && Key_ANSI < 255 && temp<50)
1248
quicksearch_filename[temp]=Key_ANSI;
1249
quicksearch_filename[temp+1]='\0';
1250
most_matching_filename=Find_filename_match(Skin_files_list, quicksearch_filename);
1251
if ( (most_matching_filename) )
1253
temp=Main_fileselector_position+Main_fileselector_offset;
1255
Highlight_file(most_matching_filename);
1256
Prepare_and_display_filelist(Main_fileselector_position,Main_fileselector_offset,file_scroller);
1258
if (temp!=Main_fileselector_position+Main_fileselector_offset)
1259
New_preview_is_needed=1;
1262
*quicksearch_filename=0;
1267
*quicksearch_filename=0;
1271
while ( (clicked_button!=1) && (clicked_button !=6) && (Key != SDLK_ESCAPE));
1273
if(clicked_button == 1)
1278
// (Re-)load GUI graphics from selected skins
1279
strcpy(skinsdir, Get_item_by_index(&Skin_files_list, skin_list->List_start+skin_list->Cursor_position)->Full_name);
1280
gfx=Load_graphics(skinsdir);
1281
if (gfx == NULL) // Error
1283
Verbose_error_message(Gui_loading_error_message);
1290
free(Config.Skin_file);
1291
Config.Skin_file = strdup(skinsdir);
1293
// (Re-)load the selected font
1294
new_font = Load_font(Get_item_by_index(&Font_files_list,selected_font)->Full_name);
1300
Menu_font = new_font;
1301
fname = Get_item_by_index(&Font_files_list,selected_font)->Full_name;
1302
free(Config.Font_file);
1303
Config.Font_file = strdup(fname);
1305
// Confirm the change of cursor shape
1306
Config.Cursor = selected_cursor;
1310
Unselect_button(BUTTON_SETTINGS);
1311
// Raffichage du menu pour que les inscriptions qui y figurent soient retrac�es avec la nouvelle fonte
966
1317
//---------------------------- Changement de page ----------------------------
967
1318
void Button_Page(void)
973
1321
char Temp_buffer[256];
1323
#define SWAP_BYTES(a,b) { byte c=a; a=b; b=c;}
1324
#define SWAP_WORDS(a,b) { word c=a; a=b; b=c;}
1325
#define SWAP_SHORTS(a,b) { short c=a; a=b; b=c;}
1326
#define SWAP_FLOATS(a,b) { float c=a; a=b; b=c;}
977
1330
// On d�grossit le travail avec les infos des listes de pages
978
1331
Exchange_main_and_spare();
980
1333
// On fait le reste du travail "� la main":
981
temp_short=Spare_offset_X;
982
Spare_offset_X=Main_offset_X;
983
Main_offset_X=temp_short;
985
temp_short=Spare_offset_Y;
986
Spare_offset_Y=Main_offset_Y;
987
Main_offset_Y=temp_short;
989
temp_short=Old_spare_offset_X;
990
Old_spare_offset_X=Old_main_offset_X;
991
Old_main_offset_X=temp_short;
993
temp_short=Old_spare_offset_Y;
994
Old_spare_offset_Y=Old_main_offset_Y;
995
Old_main_offset_Y=temp_short;
997
temp_short=Spare_separator_position;
998
Spare_separator_position=Main_separator_position;
999
Main_separator_position=temp_short;
1001
temp_short=Spare_X_zoom;
1002
Spare_X_zoom=Main_X_zoom;
1003
Main_X_zoom=temp_short;
1005
temp_float=Spare_separator_proportion;
1006
Spare_separator_proportion=Main_separator_proportion;
1007
Main_separator_proportion=temp_float;
1009
temp_byte=Spare_magnifier_mode;
1010
Spare_magnifier_mode=Main_magnifier_mode;
1011
Main_magnifier_mode=temp_byte;
1334
SWAP_SHORTS(Main_offset_X,Spare_offset_X)
1335
SWAP_SHORTS(Main_offset_Y,Spare_offset_Y)
1336
SWAP_SHORTS(Old_main_offset_X,Old_spare_offset_X)
1337
SWAP_SHORTS(Old_main_offset_Y,Old_spare_offset_Y)
1338
SWAP_SHORTS(Main_separator_position,Spare_separator_position)
1339
SWAP_SHORTS(Main_X_zoom,Spare_X_zoom)
1340
SWAP_FLOATS(Main_separator_proportion,Spare_separator_proportion)
1341
SWAP_BYTES (Main_magnifier_mode,Spare_magnifier_mode)
1013
1343
Pixel_preview=(Main_magnifier_mode)?Pixel_preview_magnifier:Pixel_preview_normal;
1015
temp_word=Spare_magnifier_factor;
1016
Spare_magnifier_factor=Main_magnifier_factor;
1017
Main_magnifier_factor=temp_word;
1019
temp_word=Spare_magnifier_height;
1020
Spare_magnifier_height=Main_magnifier_height;
1021
Main_magnifier_height=temp_word;
1023
temp_word=Spare_magnifier_width;
1024
Spare_magnifier_width=Main_magnifier_width;
1025
Main_magnifier_width=temp_word;
1027
temp_short=Spare_magnifier_offset_X;
1028
Spare_magnifier_offset_X=Main_magnifier_offset_X;
1029
Main_magnifier_offset_X=temp_short;
1031
temp_short=Spare_magnifier_offset_Y;
1032
Spare_magnifier_offset_Y=Main_magnifier_offset_Y;
1033
Main_magnifier_offset_Y=temp_short;
1345
SWAP_WORDS (Main_magnifier_factor,Spare_magnifier_factor)
1346
SWAP_WORDS (Main_magnifier_height,Spare_magnifier_height)
1347
SWAP_WORDS (Main_magnifier_width,Spare_magnifier_width)
1348
SWAP_SHORTS(Main_magnifier_offset_X,Spare_magnifier_offset_X)
1349
SWAP_SHORTS(Main_magnifier_offset_Y,Spare_magnifier_offset_Y)
1035
1350
// Swap du bool�en "Image modifi�e"
1036
temp_byte =Spare_image_is_modified;
1037
Spare_image_is_modified=Main_image_is_modified;
1038
Main_image_is_modified=temp_byte;
1351
SWAP_BYTES (Main_image_is_modified,Spare_image_is_modified)
1040
1353
// Swap des infos sur les fileselects
1041
1354
strcpy(Temp_buffer ,Spare_current_directory);
1042
1355
strcpy(Spare_current_directory,Main_current_directory);
1043
1356
strcpy(Main_current_directory,Temp_buffer );
1045
temp_byte=Spare_format;
1046
Spare_format=Main_format;
1047
Main_format=temp_byte;
1049
temp_word =Spare_fileselector_position;
1050
Spare_fileselector_position=Main_fileselector_position;
1051
Main_fileselector_position=temp_word;
1053
temp_word =Spare_fileselector_offset;
1054
Spare_fileselector_offset=Main_fileselector_offset;
1055
Main_fileselector_offset=temp_word;
1358
SWAP_BYTES (Main_format,Spare_format)
1359
SWAP_WORDS (Main_fileselector_position,Spare_fileselector_position)
1360
SWAP_WORDS (Main_fileselector_offset,Spare_fileselector_offset)
1057
1362
// A la fin, on affiche l'�cran
1058
for (temp_byte=0; ZOOM_FACTOR[temp_byte]!=Main_magnifier_factor; temp_byte++);
1059
Change_magnifier_factor(temp_byte);
1363
for (factor_index=0; ZOOM_FACTOR[factor_index]!=Main_magnifier_factor; factor_index++);
1364
Change_magnifier_factor(factor_index);
1061
1366
Set_palette(Main_palette);
1062
1367
Compute_optimal_menu_colors(Main_palette);
5137
5595
clicked_button=Window_clicked_button();
5138
5596
if (clicked_button==0)
5140
if (Key==SDLK_UP && (cursor_position+list_start)>0)
5145
if (cursor_position<0)
5147
list_start=list_start+cursor_position;
5149
// Mise � jour du scroller
5150
font_scroller->Position=list_start;
5151
Window_draw_slider(font_scroller);
5154
preview_is_needed=1;
5156
if (Key==SDLK_DOWN && (cursor_position+list_start)<(Nb_fonts-1))
5161
if (cursor_position>(NB_FONTS-1))
5163
list_start=list_start+cursor_position-(NB_FONTS-1);
5164
cursor_position=(NB_FONTS-1);
5165
// Mise � jour du scroller
5166
font_scroller->Position=list_start;
5167
Window_draw_slider(font_scroller);
5170
preview_is_needed=1;
5172
if (Key==SDLK_HOME && (cursor_position!=0 || list_start!=0))
5178
// Mise � jour du scroller
5179
font_scroller->Position=list_start;
5180
Window_draw_slider(font_scroller);
5182
preview_is_needed=1;
5184
if (Key==SDLK_END && (cursor_position+list_start)<(Nb_fonts-1))
5188
cursor_position=(Nb_fonts-1)-list_start;
5189
if (cursor_position>(NB_FONTS-1))
5191
list_start=list_start+cursor_position-(NB_FONTS-1);
5192
cursor_position=(NB_FONTS-1);
5193
// Mise � jour du scroller
5194
font_scroller->Position=list_start;
5195
Window_draw_slider(font_scroller);
5198
preview_is_needed=1;
5200
if (Key==SDLK_PAGEDOWN && (cursor_position+list_start)<(Nb_fonts-1))
5204
if (Nb_fonts<NB_FONTS)
5206
cursor_position=Nb_fonts-1;
5208
else if(cursor_position!=NB_FONTS-1)
5210
cursor_position=NB_FONTS-1;
5214
list_start+=NB_FONTS;
5215
if (list_start+NB_FONTS>Nb_fonts)
5217
list_start=Nb_fonts-NB_FONTS;
5219
// Mise � jour du scroller
5220
font_scroller->Position=list_start;
5221
Window_draw_slider(font_scroller);
5224
preview_is_needed=1;
5226
if (Key==SDLK_PAGEUP && (cursor_position+list_start)>0)
5230
if(cursor_position!=0)
5236
list_start-=NB_FONTS;
5241
// Mise � jour du scroller
5242
font_scroller->Position=list_start;
5243
Window_draw_slider(font_scroller);
5246
preview_is_needed=1;
5248
if (Key == KEY_MOUSEWHEELUP && list_start>0)
5250
cursor_position+=list_start;
5255
cursor_position-=list_start;
5256
// On affiche � nouveau la liste
5259
// Mise � jour du scroller
5260
font_scroller->Position=list_start;
5261
Window_draw_slider(font_scroller);
5263
if (Key==KEY_MOUSEWHEELDOWN && list_start<Nb_fonts-NB_FONTS)
5265
cursor_position+=list_start;
5267
if (list_start+NB_FONTS>Nb_fonts)
5269
list_start=Nb_fonts-NB_FONTS;
5271
cursor_position-=list_start;
5272
// On affiche � nouveau la liste
5275
// Mise � jour du scroller
5276
font_scroller->Position=list_start;
5277
Window_draw_slider(font_scroller);
5279
5598
if (Is_shortcut(Key,0x100+BUTTON_HELP))
5280
5599
Window_help(BUTTON_TEXT, NULL);
5600
else if (Is_shortcut(Key,0x100+BUTTON_TEXT))
5282
5603
switch(clicked_button)
5425
-BUTTON_SPHERES (Ellipses d�grad�es � am�liorer)
5427
-BUTTON_ADJUST (Effets sur l'image)
5428
-BUTTON_BRUSH_EFFECTS (Distort, Rot. any angle)
5740
void Display_stored_brush_in_window(word x_pos,word y_pos,int index)
5742
if (Brush_container[index].Paintbrush_shape < PAINTBRUSH_SHAPE_MAX)
5745
int offset_x=0, offset_y=0;
5746
//int brush_offset_x=0, brush_offset_y=0;
5748
// Determine draw offset (small brushes are stacked on corner of their preview)
5749
if (Brush_container[index].Width<BRUSH_CONTAINER_PREVIEW_WIDTH)
5750
offset_x = (BRUSH_CONTAINER_PREVIEW_WIDTH-Brush_container[index].Width)/2;
5751
if (Brush_container[index].Height<BRUSH_CONTAINER_PREVIEW_HEIGHT)
5752
offset_y = (BRUSH_CONTAINER_PREVIEW_HEIGHT-Brush_container[index].Height)/2;
5753
// Determine corner pixel of paintbrush to draw (if bigger than preview area)
5757
Window_rectangle(x_pos,y_pos,BRUSH_CONTAINER_PREVIEW_WIDTH,BRUSH_CONTAINER_PREVIEW_HEIGHT,MC_Light);
5760
for (y=0; y<Brush_container[index].Height && y<BRUSH_CONTAINER_PREVIEW_HEIGHT; y++)
5762
for (x=0; x<Brush_container[index].Width && x<BRUSH_CONTAINER_PREVIEW_WIDTH; x++)
5765
if (Brush_container[index].Paintbrush_shape <= PAINTBRUSH_SHAPE_MISC)
5766
color = Brush_container[index].Thumbnail[y][x]?MC_Black:MC_Light;
5768
color = Brush_container[index].Thumbnail[y][x];
5769
Pixel_in_window(x_pos+x+offset_x,y_pos+y+offset_y,color);
5772
Update_window_area(x_pos,y_pos,BRUSH_CONTAINER_PREVIEW_WIDTH,BRUSH_CONTAINER_PREVIEW_HEIGHT);
5777
void Store_brush(int index)
5779
if (Brush_container[index].Paintbrush_shape < PAINTBRUSH_SHAPE_MAX)
5781
// Free previous stored brush
5782
Brush_container[index].Paintbrush_shape = PAINTBRUSH_SHAPE_MAX;
5783
free(Brush_container[index].Brush);
5784
Brush_container[index].Brush = NULL;
5787
// Store a mono brush
5788
if (Paintbrush_shape <= PAINTBRUSH_SHAPE_MISC)
5791
int brush_offset_x=0, brush_offset_y=0;
5793
Brush_container[index].Paintbrush_shape=Paintbrush_shape;
5794
Brush_container[index].Width=Paintbrush_width;
5795
Brush_container[index].Height=Paintbrush_height;
5796
//memcpy(Brush_container[index].Palette,Main_palette,sizeof(T_Palette));
5797
// Preview: pick center for big mono brush
5798
if (Paintbrush_width>BRUSH_CONTAINER_PREVIEW_WIDTH)
5799
brush_offset_x = (Paintbrush_width-BRUSH_CONTAINER_PREVIEW_WIDTH)/2;
5800
if (Paintbrush_height>BRUSH_CONTAINER_PREVIEW_HEIGHT)
5801
brush_offset_y = (Paintbrush_height-BRUSH_CONTAINER_PREVIEW_HEIGHT)/2;
5803
for (y=0; y<BRUSH_CONTAINER_PREVIEW_HEIGHT && y<Paintbrush_height; y++)
5804
for (x=0; x<BRUSH_CONTAINER_PREVIEW_WIDTH && x<Paintbrush_width; x++)
5805
Brush_container[index].Thumbnail[y][x]=Paintbrush_sprite[((y+brush_offset_y)*MAX_PAINTBRUSH_SIZE)+x+brush_offset_x];
5807
Brush_container[index].Transp_color=0;
5809
if (Paintbrush_shape == PAINTBRUSH_SHAPE_COLOR_BRUSH ||
5810
Paintbrush_shape == PAINTBRUSH_SHAPE_MONO_BRUSH)
5812
Brush_container[index].Brush=(byte *)malloc(Brush_width*Brush_height);
5813
if (Brush_container[index].Brush)
5815
Brush_container[index].Paintbrush_shape=Paintbrush_shape;
5816
Brush_container[index].Width=Brush_width;
5817
Brush_container[index].Height=Brush_height;
5819
memcpy(Brush_container[index].Brush, Brush,Brush_height*Brush_width);
5821
// Scale for preview
5822
if (Brush_width>BRUSH_CONTAINER_PREVIEW_WIDTH ||
5823
Brush_height>BRUSH_CONTAINER_PREVIEW_HEIGHT)
5826
Rescale(Brush, Brush_width, Brush_height, (byte *)(Brush_container[index].Thumbnail), BRUSH_CONTAINER_PREVIEW_WIDTH, BRUSH_CONTAINER_PREVIEW_HEIGHT, 0, 0);
5831
Copy_part_of_image_to_another(Brush, 0,0,Brush_width, Brush_height,Brush_width,(byte *)(Brush_container[index].Thumbnail),0,0,BRUSH_CONTAINER_PREVIEW_WIDTH);
5841
byte Restore_brush(int index)
5847
shape = Brush_container[index].Paintbrush_shape;
5849
if (shape == PAINTBRUSH_SHAPE_MAX)
5852
if (shape <= PAINTBRUSH_SHAPE_MISC)
5854
Paintbrush_shape=shape;
5855
Paintbrush_width=Brush_container[index].Width;
5856
Paintbrush_height=Brush_container[index].Height;
5857
if (shape == PAINTBRUSH_SHAPE_HORIZONTAL_BAR)
5858
Paintbrush_height=1;
5859
else if (shape == PAINTBRUSH_SHAPE_VERTICAL_BAR)
5862
if (Paintbrush_width <= BRUSH_CONTAINER_PREVIEW_WIDTH &&
5863
Paintbrush_height <= BRUSH_CONTAINER_PREVIEW_HEIGHT)
5865
// Manually copy the "pixels"
5866
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
5867
for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
5868
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=Brush_container[index].Thumbnail[y_pos][x_pos];
5870
Paintbrush_offset_X=Paintbrush_width>>1;
5871
Paintbrush_offset_Y=Paintbrush_height>>1;
5875
// Recreate the brush pixels from its shape and dimensions
5876
Set_paintbrush_size(Paintbrush_width,Paintbrush_height);
5880
if (shape == PAINTBRUSH_SHAPE_COLOR_BRUSH ||
5881
shape == PAINTBRUSH_SHAPE_MONO_BRUSH)
5883
Paintbrush_shape=shape;
5884
Realloc_brush(Brush_container[index].Width,Brush_container[index].Height);
5885
// Realloc sets Brush_width and Brush_height to new size.
5886
memcpy(Brush, Brush_container[index].Brush, Brush_height*Brush_width);
5888
Brush_offset_X=Brush_width>>1;
5889
Brush_offset_Y=Brush_height>>1;
5892
Change_paintbrush_shape(shape);
5897
void Button_Brush_container(void)
5899
short clicked_button;
5903
Open_window(BRUSH_CONTAINER_COLUMNS*(BRUSH_CONTAINER_PREVIEW_WIDTH+8)+8,
5904
BRUSH_CONTAINER_ROWS*(BRUSH_CONTAINER_PREVIEW_HEIGHT+8)+40,
5907
Window_set_normal_button(
5908
(BRUSH_CONTAINER_COLUMNS*(BRUSH_CONTAINER_PREVIEW_WIDTH+8)-59)/2,
5909
(BRUSH_CONTAINER_ROWS)*(BRUSH_CONTAINER_PREVIEW_HEIGHT+8)+18,
5910
67,14,"Cancel",0,1,KEY_ESC); // 1
5913
for (index=0; index < BRUSH_CONTAINER_ROWS*BRUSH_CONTAINER_COLUMNS; index++)
5915
x_pos = (index % BRUSH_CONTAINER_COLUMNS)*(BRUSH_CONTAINER_PREVIEW_WIDTH+8)+7;
5916
y_pos = (index / BRUSH_CONTAINER_COLUMNS)*(BRUSH_CONTAINER_PREVIEW_HEIGHT+8)+18;
5917
Window_set_normal_button(
5920
BRUSH_CONTAINER_PREVIEW_WIDTH+2,
5921
BRUSH_CONTAINER_PREVIEW_HEIGHT+2,
5923
Display_stored_brush_in_window(x_pos+1, y_pos+1, index);
5925
Update_window_area(0,0,Window_width, Window_height);
5931
clicked_button=Window_clicked_button();
5932
//if (Is_shortcut(Key,0x100+BUTTON_HELP))
5933
// Window_help(BUTTON_PAINTBRUSHES, NULL);
5935
if (clicked_button == 1)
5938
if (clicked_button>1)
5940
index = clicked_button-2;
5942
if (Window_attribute1==RIGHT_SIDE)
5946
x_pos = (index % BRUSH_CONTAINER_COLUMNS)*(BRUSH_CONTAINER_PREVIEW_WIDTH+8)+7;
5947
y_pos = (index / BRUSH_CONTAINER_COLUMNS)*(BRUSH_CONTAINER_PREVIEW_HEIGHT+8)+18;
5951
Display_stored_brush_in_window(x_pos+1, y_pos+1, index);
5958
if (Restore_brush(index))
5966
//Unselect_button(BUTTON_PAINTBRUSHES);
b'\\ No newline at end of file'