void Scroll_help(T_Scroller_button * scroller) { Hide_cursor(); scroller->Position=Help_position; Compute_slider_cursor_length(scroller); Window_draw_slider(scroller); Display_help(); Display_cursor(); }
void Redefine_control(word *shortcut, int x_pos, int y_pos) { Hide_cursor(); Print_in_window(x_pos,y_pos,"*PRESS KEY OR BUTTON*",MC_Black,MC_Light); Display_cursor(); while (1) { Get_input(20); if (Key==KEY_ESC) return; if (Key!=0) { *shortcut=Key; return; } } }
void Button_Stats(void) { short clicked_button; char buffer[37]; dword color_usage[256]; unsigned long long freeRam; qword mem_size = 0; Open_window(310,174,"Statistics"); // Dessin de la fenetre ou va s'afficher le texte Window_display_frame_in(8,17,294,132); Block(Window_pos_X+(Menu_factor_X*9), Window_pos_Y+(Menu_factor_Y*18), Menu_factor_X*292,Menu_factor_Y*130,MC_Black); Window_set_normal_button(120,153,70,14,"OK",0,1,KEY_ESC); // 1 // Affichage du numéro de version Print_in_window(10,19,"Program version:",STATS_TITLE_COLOR,MC_Black); sprintf(buffer,"%s.%s",Program_version, SVN_revision); Print_in_window(146,19,buffer,STATS_DATA_COLOR,MC_Black); Print_in_window(10,35,"Build options:",STATS_TITLE_COLOR,MC_Black); Print_in_window(146,35,TrueType_is_supported()?"TTF fonts":"no TTF fonts",STATS_DATA_COLOR,MC_Black); #if defined (__MINT__) // Affichage de la mémoire restante Print_in_window(10,43,"Free memory: ",STATS_TITLE_COLOR,MC_Black); freeRam=0; char helpBuf[64]; unsigned long STRAM,TTRAM; Atari_Memory_free(&STRAM,&TTRAM); freeRam=STRAM+TTRAM; buffer[0]='\0'; if(STRAM > (100*1024*1024)) sprintf(helpBuf,"ST:%u Mb ",(unsigned int)(STRAM/(1024*1024))); else if(freeRam > 100*1024) sprintf(helpBuf,"ST:%u Kb ",(unsigned int)(STRAM/1024)); else sprintf(helpBuf,"ST:%u b ",(unsigned int)STRAM); strncat(buffer,helpBuf,sizeof(char)*37); if(TTRAM > (100ULL*1024*1024*1024)) sprintf(helpBuf,"TT:%u Gb",(unsigned int)(TTRAM/(1024*1024*1024))); else if(TTRAM > (100*1024*1024)) sprintf(helpBuf,"TT:%u Mb",(unsigned int)(TTRAM/(1024*1024))); else if(freeRam > 100*1024) sprintf(helpBuf,"TT:%u Kb",(unsigned int)(TTRAM/1024)); else sprintf(helpBuf,"TT:%u b",(unsigned int)TTRAM); strncat(buffer,helpBuf,sizeof(char)*37); if(freeRam > (100ULL*1024*1024*1024)) sprintf(helpBuf,"(%u Gb)",(unsigned int)(freeRam/(1024*1024*1024))); else if(freeRam > (100*1024*1024)) sprintf(helpBuf,"(%u Mb)",(unsigned int)(freeRam/(1024*1024))); else if(freeRam > 100*1024) sprintf(helpBuf,"(%u Kb)",(unsigned int)(freeRam/1024)); else sprintf(helpBuf,"(%u b)",(unsigned int)freeRam); strncat(buffer,helpBuf,sizeof(char)*37); Print_in_window(18,51,buffer,STATS_DATA_COLOR,MC_Black); #else // Affichage de la mémoire restante Print_in_window(10,51,"Free memory: ",STATS_TITLE_COLOR,MC_Black); freeRam = Memory_free(); if(freeRam > (100ULL*1024*1024*1024)) sprintf(buffer,"%u Gigabytes",(unsigned int)(freeRam/(1024*1024*1024))); else if(freeRam > (100*1024*1024)) sprintf(buffer,"%u Megabytes",(unsigned int)(freeRam/(1024*1024))); else if(freeRam > 100*1024) sprintf(buffer,"%u Kilobytes",(unsigned int)(freeRam/1024)); else sprintf(buffer,"%u bytes",(unsigned int)freeRam); Print_in_window(114,51,buffer,STATS_DATA_COLOR,MC_Black); #endif // Used memory Print_in_window(10,59,"Used memory pages: ",STATS_TITLE_COLOR,MC_Black); if(Stats_pages_memory > (100LL*1024*1024*1024)) sprintf(buffer,"%ld (%lld Gb)",Stats_pages_number, Stats_pages_memory/(1024*1024*1024)); else if(Stats_pages_memory > (100*1024*1024)) sprintf(buffer,"%ld (%lld Mb)",Stats_pages_number, Stats_pages_memory/(1024*1024)); else sprintf(buffer,"%ld (%lld Kb)",Stats_pages_number, Stats_pages_memory/1024); Print_in_window(162,59,buffer,STATS_DATA_COLOR,MC_Black); // Affichage de l'espace disque libre sprintf(buffer,"Free space on %c:",Main_current_directory[0]); Print_in_window(10,67,buffer,STATS_TITLE_COLOR,MC_Black); #if defined(__WIN32__) { ULARGE_INTEGER tailleU; GetDiskFreeSpaceEx(Main_current_directory,&tailleU,NULL,NULL); mem_size = tailleU.QuadPart; } #elif defined(__linux__) || defined(__macosx__) || defined(__FreeBSD__) // Note: under MacOSX, both macros are defined anyway. { struct statfs disk_info; statfs(Main_current_directory,&disk_info); mem_size=(qword) disk_info.f_bfree * (qword) disk_info.f_bsize; } #elif defined (__MINT__) _DISKINFO drvInfo; mem_size=0; Dfree(&drvInfo,0); //number of free clusters*sectors per cluster*bytes per sector; // reports current drive mem_size=drvInfo.b_free*drvInfo.b_clsiz*drvInfo.b_secsiz; #else // Free disk space is only for shows. Other platforms can display 0. #warning "Missing code for your platform !!! Check and correct please :)" mem_size=0; #endif if(mem_size > (100ULL*1024*1024*1024)) sprintf(buffer,"%u Gigabytes",(unsigned int)(mem_size/(1024*1024*1024))); else if(mem_size > (100*1024*1024)) sprintf(buffer,"%u Megabytes",(unsigned int)(mem_size/(1024*1024))); else if(mem_size > (100*1024)) sprintf(buffer,"%u Kilobytes",(unsigned int)(mem_size/1024)); else sprintf(buffer,"%u bytes",(unsigned int)mem_size); Print_in_window(146,67,buffer,STATS_DATA_COLOR,MC_Black); // Affichage des informations sur l'image Print_in_window(10,83,"Picture info.:",STATS_TITLE_COLOR,MC_Black); // Affichage des dimensions de l'image Print_in_window(18,91,"Dimensions :",STATS_TITLE_COLOR,MC_Black); sprintf(buffer,"%dx%d",Main_image_width,Main_image_height); Print_in_window(122,91,buffer,STATS_DATA_COLOR,MC_Black); // Affichage du nombre de couleur utilisé Print_in_window(18,99,"Colors used:",STATS_TITLE_COLOR,MC_Black); memset(color_usage,0,sizeof(color_usage)); sprintf(buffer,"%d",Count_used_colors(color_usage)); Print_in_window(122,99,buffer,STATS_DATA_COLOR,MC_Black); // Affichage des dimensions de l'écran Print_in_window(10,115,"Resolution:",STATS_TITLE_COLOR,MC_Black); sprintf(buffer,"%dx%d",Screen_width,Screen_height); Print_in_window(106,115,buffer,STATS_DATA_COLOR,MC_Black); Update_rect(Window_pos_X,Window_pos_Y,Menu_factor_X*310,Menu_factor_Y*174); Display_cursor(); do { clicked_button=Window_clicked_button(); if (Is_shortcut(Key,0x200+BUTTON_HELP)) clicked_button=1; } while ( (clicked_button!=1) && (Key!=SDLK_RETURN) ); if(Key==SDLK_RETURN)Key=0; Close_window(); Unselect_button(BUTTON_HELP); Display_cursor(); }
// Ouvre l'ecran d'aide. Passer -1 pour la section par défaut (ou derniere,) // Ou un nombre de l'enumération BUTTON_NUMBERS pour l'aide contextuelle. void Window_help(int section, const char *sub_section) { short clicked_button; short nb_lines; T_Scroller_button * scroller; if (section!=-1) { Current_help_section = 4 + section; Help_position = 0; } nb_lines=Help_section[Current_help_section].Length; if (section!=-1 && sub_section!=NULL) { int index=0; for (index=0; index<nb_lines; index++) if (Help_section[Current_help_section].Help_table[index].Line_type == 'T' && !strcmp(Help_section[Current_help_section].Help_table[index].Text, sub_section)) { Help_position = index; break; } } Open_window(310,175,"Help / About..."); // dessiner de la fenêtre où va défiler le texte Window_display_frame_in(8,17,274,132); Block(Window_pos_X+(Menu_factor_X*9), Window_pos_Y+(Menu_factor_Y*18), Menu_factor_X*272,Menu_factor_Y*130,MC_Black); Window_set_normal_button(266,153,35,14,"Exit",0,1,KEY_ESC); // 1 scroller=Window_set_scroller_button(290,18,130,nb_lines, 16,Help_position); // 2 Window_set_normal_button( 9,154, 6*8,14,"About" ,1,1,SDLK_a); // 3 Window_set_normal_button( 9+6*8+4,154, 8*8,14,"License",1,1,SDLK_l); // 4 Window_set_normal_button( 9+6*8+4+8*8+4,154, 5*8,14,"Help",1,1,SDLK_h); // 5 Window_set_normal_button(9+6*8+4+8*8+4+5*8+4,154, 8*8,14,"Credits",1,1,SDLK_c); // 6 Window_set_special_button(9,18,272,130); // 7 Display_help(); Update_rect(Window_pos_X,Window_pos_Y,310*Menu_factor_X,175*Menu_factor_Y); Display_cursor(); do { clicked_button=Window_clicked_button(); switch (clicked_button) { case -1: case 0: case 1: break; case 7: // Zone de texte { int line = ((Mouse_Y-Window_pos_Y)/Menu_factor_Y - 18)/8; Wait_end_of_click(); if (line == ((Mouse_Y-Window_pos_Y)/Menu_factor_Y - 18)/8) { if (Help_position+line<nb_lines) { switch (Help_section[Current_help_section].Help_table[Help_position+line].Line_type) { case 'K': Window_set_shortcut(Help_section[Current_help_section].Help_table[Help_position+line].Line_parameter); break; // Ici on peut gérer un cas 'lien hypertexte' default: break; } Hide_cursor(); Display_help(); Display_cursor(); } } break; } default: Hide_cursor(); if (clicked_button>2) { Current_help_section=clicked_button-3; Help_position=0; nb_lines=Help_section[Current_help_section].Length; scroller->Position=0; scroller->Nb_elements=nb_lines; Compute_slider_cursor_length(scroller); Window_draw_slider(scroller); } else Help_position=Window_attribute2; Display_help(); Display_cursor(); } // Gestion des touches de déplacement dans la liste switch (Key) { case SDLK_UP : // Haut if (Help_position>0) Help_position--; Scroll_help(scroller); Key=0; break; case SDLK_DOWN : // Bas if (Help_position<nb_lines-16) Help_position++; Scroll_help(scroller); Key=0; break; case SDLK_PAGEUP : // PageUp if (Help_position>15) Help_position-=15; else Help_position=0; Scroll_help(scroller); Key=0; break; case (KEY_MOUSEWHEELUP) : // WheelUp if (Help_position>3) Help_position-=3; else Help_position=0; Scroll_help(scroller); Key=0; break; case SDLK_PAGEDOWN : // PageDown if (nb_lines>16) { if (Help_position<nb_lines-16-15) Help_position+=15; else Help_position=nb_lines-16; Scroll_help(scroller); Key=0; } break; case (KEY_MOUSEWHEELDOWN) : // Wheeldown if (nb_lines>16) { if (Help_position<nb_lines-16-3) Help_position+=3; else Help_position=nb_lines-16; Scroll_help(scroller); Key=0; } break; case SDLK_HOME : // Home Help_position=0; Scroll_help(scroller); Key=0; break; case SDLK_END : // End if (nb_lines>16) { Help_position=nb_lines-16; Scroll_help(scroller); Key=0; } break; } if (Is_shortcut(Key,0x100+BUTTON_HELP)) clicked_button=1; } while ((clicked_button!=1) && (Key!=SDLK_RETURN)); Key=0; Close_window(); Unselect_button(BUTTON_HELP); Display_cursor(); }
void Window_set_shortcut(int action_id) { short clicked_button; short order_index; short config_index; short redraw_controls=1; word * shortcut_ptr=NULL; word backup_shortcut[2]; shortcut_ptr=Shortcut(action_id); backup_shortcut[0]=shortcut_ptr[0]; backup_shortcut[1]=shortcut_ptr[1]; // Recherche dans hotkeys order_index=0; while (Ordering[order_index]!=action_id) { order_index++; if (order_index>=NB_SHORTCUTS) { Error(0); return; } } /* config_index=0; while (ConfigKey[config_index].Number!=order_index) { config_index++; if (config_index>=NB_SHORTCUTS) { Error(0); return; } } */ config_index=order_index; // Comprends pas... ça devrait pas marcher Open_window(302,131,"Keyboard shortcut"); Window_set_normal_button(181,111,55,14,"Cancel",0,1,KEY_ESC); // 1 Window_set_normal_button(241,111,55,14,"OK",0,1,SDLK_RETURN); // 2 Window_set_normal_button(6,111,111,14,"Reset default",0,1,KEY_NONE); // 3 // Titre Block(Window_pos_X+(Menu_factor_X*5), Window_pos_Y+(Menu_factor_Y*16), Menu_factor_X*292,Menu_factor_Y*11,MC_Black); Print_in_window(7,18,ConfigKey[config_index].Label,MC_White,MC_Black); // Zone de description Window_display_frame_in(5,68,292,37); Print_in_window(8,70,ConfigKey[config_index].Explanation1,MC_Black,MC_Light); Print_in_window(8,78,ConfigKey[config_index].Explanation2,MC_Black,MC_Light); Print_in_window(8,86,ConfigKey[config_index].Explanation3,MC_Black,MC_Light); // Shortcut 0 Window_set_normal_button(27,30,177,14,"",0,1,KEY_NONE); // 4 Window_set_normal_button(209,30,56,14,"Remove",0,1,KEY_NONE); // 5 // Shortcut 1 Window_set_normal_button(27,49,177,14,"",0,1,KEY_NONE); // 6 Window_set_normal_button(209,49,56,14,"Remove",0,1,KEY_NONE); // 7 Display_cursor(); do { if (redraw_controls) { Hide_cursor(); Block(Window_pos_X+(Menu_factor_X*32), Window_pos_Y+(Menu_factor_Y*33), Menu_factor_X*21*8,Menu_factor_Y*8,MC_Light); Print_in_window_limited(32,33,Key_name(shortcut_ptr[0]),21,MC_Black,MC_Light); Block(Window_pos_X+(Menu_factor_X*32), Window_pos_Y+(Menu_factor_Y*52), Menu_factor_X*21*8,Menu_factor_Y*8,MC_Light); Print_in_window_limited(32,52,Key_name(shortcut_ptr[1]),21,MC_Black,MC_Light); Update_rect(Window_pos_X,Window_pos_Y,302*Menu_factor_X,131*Menu_factor_Y); Display_cursor(); redraw_controls=0; } clicked_button=Window_clicked_button(); switch (clicked_button) { case -1: case 0: break; case 4: // Change 0 Redefine_control(&shortcut_ptr[0], 32, 33); redraw_controls=1; break; case 6: // Change 1 Redefine_control(&shortcut_ptr[1], 32, 52); redraw_controls=1; break; case 5: // Remove 0 shortcut_ptr[0]=0; redraw_controls=1; break; case 7: // Remove 1 shortcut_ptr[1]=0; redraw_controls=1; break; case 3: // Defaults shortcut_ptr[0]=ConfigKey[config_index].Key; shortcut_ptr[1]=ConfigKey[config_index].Key2; redraw_controls=1; break; case 1: // Cancel shortcut_ptr[0]=backup_shortcut[0]; shortcut_ptr[1]=backup_shortcut[1]; case 2: // OK // Replace twice by single if (shortcut_ptr[0]==shortcut_ptr[1]) shortcut_ptr[1]=0; // Remove all other shortcuts that use same keys if (!Config.Allow_multi_shortcuts) { int n; for (n=0; n<2; n++) { if (shortcut_ptr[n]!=0) { int i; for(i=0; i<NB_SHORTCUTS; i++) { word * other_shortcut_ptr; if (Ordering[i]==action_id) continue; other_shortcut_ptr=Shortcut(Ordering[i]); if (other_shortcut_ptr[0]==shortcut_ptr[n]) other_shortcut_ptr[0]=0; if (other_shortcut_ptr[1]==shortcut_ptr[n]) other_shortcut_ptr[1]=0; } } } } default: break; } } while ((clicked_button!=1) && (clicked_button!=2) && (Key!=SDLK_RETURN)); Key=0; Close_window(); Display_cursor(); }
void Button_Stats(void) { short clicked_button; char buffer[37]; dword color_usage[256]; unsigned long long freeRam; qword mem_size = 0; int y; #if defined (__MINT__) _DISKINFO drvInfo; unsigned long STRAM=0,TTRAM=0; char helpBuf[64]={0}; #endif Open_window(310,174,"Statistics"); // Dessin de la fenetre ou va s'afficher le texte Window_display_frame_in(8,17,294,132); Block(Window_pos_X+(Menu_factor_X*9), Window_pos_Y+(Menu_factor_Y*18), Menu_factor_X*292,Menu_factor_Y*130,MC_Black); Window_set_normal_button(120,153,70,14,"OK",0,1,KEY_ESC); // 1 y=19; // row for first line Print_in_window(10,y,"Program version:",STATS_TITLE_COLOR,MC_Black); sprintf(buffer,"%s.%s",Program_version, SVN_revision); Print_in_window(146,y,buffer,STATS_DATA_COLOR,MC_Black); y+=16; Print_in_window(10,y,"Build options:",STATS_TITLE_COLOR,MC_Black); Print_in_window(146,y,TrueType_is_supported()?"TTF fonts":"no TTF fonts",STATS_DATA_COLOR,MC_Black); y+=8; Print_in_window(10,y,"Lua version:",STATS_TITLE_COLOR,MC_Black); Print_in_window_limited(146,y,Lua_version(),10,STATS_DATA_COLOR,MC_Black); y+=16; Print_in_window(10,y,"Free memory: ",STATS_TITLE_COLOR,MC_Black); y+=8; #if defined (__MINT__) // Display free TT/ST RAM freeRam=0; Atari_Memory_free(&STRAM,&TTRAM); freeRam=STRAM+TTRAM; buffer[0]='\0'; if(STRAM > (100*1024*1024)) sprintf(helpBuf,"ST:%u Mb ",(unsigned int)(STRAM/(1024*1024))); else if(freeRam > 100*1024) sprintf(helpBuf,"ST:%u Kb ",(unsigned int)(STRAM/1024)); else sprintf(helpBuf,"ST:%u b ",(unsigned int)STRAM); strncat(buffer,helpBuf,sizeof(char)*37); if(TTRAM > (100ULL*1024*1024*1024)) sprintf(helpBuf,"TT:%u Gb",(unsigned int)(TTRAM/(1024*1024*1024))); else if(TTRAM > (100*1024*1024)) sprintf(helpBuf,"TT:%u Mb",(unsigned int)(TTRAM/(1024*1024))); else if(freeRam > 100*1024) sprintf(helpBuf,"TT:%u Kb",(unsigned int)(TTRAM/1024)); else sprintf(helpBuf,"TT:%u b",(unsigned int)TTRAM); strncat(buffer,helpBuf,sizeof(char)*37); if(freeRam > (100ULL*1024*1024*1024)) sprintf(helpBuf,"(%u Gb)",(unsigned int)(freeRam/(1024*1024*1024))); else if(freeRam > (100*1024*1024)) sprintf(helpBuf,"(%u Mb)",(unsigned int)(freeRam/(1024*1024))); else if(freeRam > 100*1024) sprintf(helpBuf,"(%u Kb)",(unsigned int)(freeRam/1024)); else sprintf(helpBuf,"(%u b)",(unsigned int)freeRam); strncat(buffer,helpBuf,sizeof(char)*37); Print_in_window(18,y,buffer,STATS_DATA_COLOR,MC_Black); #else // Display free RAM (generic) freeRam = Memory_free(); if(freeRam > (100ULL*1024*1024*1024)) sprintf(buffer,"%u Gigabytes",(unsigned int)(freeRam/(1024*1024*1024))); else if(freeRam > (100*1024*1024)) sprintf(buffer,"%u Megabytes",(unsigned int)(freeRam/(1024*1024))); else if(freeRam > 100*1024) sprintf(buffer,"%u Kilobytes",(unsigned int)(freeRam/1024)); else sprintf(buffer,"%u bytes",(unsigned int)freeRam); Print_in_window(114,y,buffer,STATS_DATA_COLOR,MC_Black); #endif y+=8; // Used memory Print_in_window(10,y,"Used memory pages: ",STATS_TITLE_COLOR,MC_Black); if(Stats_pages_memory > (100LL*1024*1024*1024)) sprintf(buffer,"%ld (%lld Gb)",Stats_pages_number, Stats_pages_memory/(1024*1024*1024)); else if(Stats_pages_memory > (100*1024*1024)) sprintf(buffer,"%ld (%lld Mb)",Stats_pages_number, Stats_pages_memory/(1024*1024)); else sprintf(buffer,"%ld (%lld Kb)",Stats_pages_number, Stats_pages_memory/1024); Print_in_window(162,y,buffer,STATS_DATA_COLOR,MC_Black); y+=8; #if defined(__WIN32__) { ULARGE_INTEGER tailleU; GetDiskFreeSpaceEx(Main_selector.Directory,&tailleU,NULL,NULL); mem_size = tailleU.QuadPart; } #elif defined(__linux__) || defined(__macosx__) || defined(__FreeBSD__) || defined(__SYLLABLE__) || defined(__AROS__) { struct statfs disk_info; statfs(Main_selector.Directory,&disk_info); mem_size=(qword) disk_info.f_bfree * (qword) disk_info.f_bsize; } #elif defined(__HAIKU__) mem_size = haiku_get_free_space(Main_selector.Directory); #elif defined (__MINT__) mem_size=0; Dfree(&drvInfo,0); //number of free clusters*sectors per cluster*bytes per sector; // reports current drive mem_size=drvInfo.b_free*drvInfo.b_clsiz*drvInfo.b_secsiz; #else #define NODISKSPACESUPPORT // Free disk space is only for shows. Other platforms can display 0. #warning "Missing code for your platform !!! Check and correct please :)" mem_size=0; #endif // Display free space if (mem_size != 0) { #if defined(__AROS__) char *colon = strchr(Main_selector.Directory, ':'); int len = strlen(Main_selector.Directory); if (colon) { len = (long)colon - (long)Main_selector.Directory; } if (len > 8) len = 8; sprintf(buffer,"Free space on %.*s:",len,Main_selector.Directory); #else sprintf(buffer,"Free space on %c:",Main_selector.Directory[0]); #endif Print_in_window(10,y,buffer,STATS_TITLE_COLOR,MC_Black); if(mem_size > (100ULL*1024*1024*1024)) sprintf(buffer,"%u Gigabytes",(unsigned int)(mem_size/(1024*1024*1024))); else if(mem_size > (100*1024*1024)) sprintf(buffer,"%u Megabytes",(unsigned int)(mem_size/(1024*1024))); else if(mem_size > (100*1024)) sprintf(buffer,"%u Kilobytes",(unsigned int)(mem_size/1024)); else sprintf(buffer,"%u bytes",(unsigned int)mem_size); #if defined(__AROS__) Print_in_window(192,y,buffer,STATS_DATA_COLOR,MC_Black); #else Print_in_window(146,y,buffer,STATS_DATA_COLOR,MC_Black); #endif } else { #ifndef NODISKSPACESUPPORT Print_in_window(10,y,"Disk full!",STATS_TITLE_COLOR,MC_Black); #endif #undef NODISKSPACESUPPORT } y+=16; // Affichage des informations sur l'image Print_in_window(10,y,"Picture info.:",STATS_TITLE_COLOR,MC_Black); y+=8; // Affichage des dimensions de l'image Print_in_window(18,y,"Dimensions :",STATS_TITLE_COLOR,MC_Black); sprintf(buffer,"%dx%d",Main_image_width,Main_image_height); Print_in_window(122,y,buffer,STATS_DATA_COLOR,MC_Black); y+=8; // Affichage du nombre de couleur utilisé Print_in_window(18,y,"Colors used:",STATS_TITLE_COLOR,MC_Black); memset(color_usage,0,sizeof(color_usage)); sprintf(buffer,"%d",Count_used_colors(color_usage)); Print_in_window(122,y,buffer,STATS_DATA_COLOR,MC_Black); y+=16; // Affichage des dimensions de l'écran Print_in_window(10,y,"Resolution:",STATS_TITLE_COLOR,MC_Black); sprintf(buffer,"%dx%d",Screen_width,Screen_height); Print_in_window(106,y,buffer,STATS_DATA_COLOR,MC_Black); Update_rect(Window_pos_X,Window_pos_Y,Menu_factor_X*310,Menu_factor_Y*174); Display_cursor(); do { clicked_button=Window_clicked_button(); if (Is_shortcut(Key,0x200+BUTTON_HELP)) clicked_button=1; } while ( (clicked_button!=1) && (Key!=SDLK_RETURN) ); if(Key==SDLK_RETURN)Key=0; Close_window(); Unselect_button(BUTTON_HELP); Display_cursor(); }
//---------- Menu dans lequel on tagge des couleurs (genre Stencil) ---------- void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_cancel, const char *help_section, word close_shortcut) { short clicked_button; byte backup_table[256]; word index; word old_mouse_x; word old_mouse_y; byte old_mouse_k; byte tagged_color; byte color; byte click; Open_window(176,150,window_title); Window_set_palette_button(6,38); // 1 Window_set_normal_button( 7, 19,78,14,"Clear" ,1,1,SDLK_c); // 2 Window_set_normal_button(91, 19,78,14,"Invert",1,1,SDLK_i); // 3 if (can_cancel) { Window_set_normal_button(91,129,78,14,"OK" ,0,1,SDLK_RETURN); // 4 Window_set_normal_button( 7,129,78,14,"Cancel",0,1,KEY_ESC); // 5 // On enregistre la table dans un backup au cas où on ferait Cancel memcpy(backup_table,table,256); } else Window_set_normal_button(49,129,78,14,"OK" ,0,1,SDLK_RETURN); // 4 // On affiche l'état actuel de la table for (index=0; index<=255; index++) Stencil_tag_color(index, (table[index])?MC_Black:MC_Light); Update_window_area(0,0,Window_width, Window_height); Display_cursor(); do { old_mouse_x=Mouse_X; old_mouse_y=Mouse_Y; old_mouse_k=Mouse_K; clicked_button=Window_clicked_button(); switch (clicked_button) { case 0 : break; case -1 : case 1 : // Palette if ( (Mouse_X!=old_mouse_x) || (Mouse_Y!=old_mouse_y) || (Mouse_K!=old_mouse_k) ) { Hide_cursor(); tagged_color=(clicked_button==1) ? Window_attribute2 : Read_pixel(Mouse_X,Mouse_Y); table[tagged_color]=(Mouse_K==LEFT_SIDE); Stencil_tag_color(tagged_color,(Mouse_K==LEFT_SIDE)?MC_Black:MC_Light); Display_cursor(); Stencil_update_color(tagged_color); } break; case 2 : // Clear memset(table,0,256); Hide_cursor(); for (index=0; index<=255; index++) Stencil_tag_color(index,MC_Light); Display_cursor(); Update_window_area(0,0,Window_width, Window_height); break; case 3 : // Invert Hide_cursor(); for (index=0; index<=255; index++) Stencil_tag_color(index,(table[index]^=1)?MC_Black:MC_Light); Display_cursor(); Update_window_area(0,0,Window_width, Window_height); } if (!Mouse_K) switch (Key) { case SDLK_BACKQUOTE : // Récupération d'une couleur derrière le menu case SDLK_COMMA : Get_color_behind_window(&color,&click); if (click) { Hide_cursor(); tagged_color=color; table[tagged_color]=(click==LEFT_SIDE); Stencil_tag_color(tagged_color,(click==LEFT_SIDE)?MC_Black:MC_Light); Stencil_update_color(tagged_color); Display_cursor(); Wait_end_of_click(); } Key=0; break; default: if (Is_shortcut(Key,0x100+BUTTON_HELP)) { Window_help(BUTTON_EFFECTS, help_section); Key=0; break; } else if (Is_shortcut(Key,close_shortcut)) { clicked_button=4; } } } while (clicked_button<4); Close_window(); if (clicked_button==5) // Cancel memcpy(table,backup_table,256); else // OK *mode=1; Display_cursor(); }