Source code translated to english

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@697 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud
2009-03-27 16:50:21 +00:00
parent 6b4a8f674e
commit efbc978e6f
68 changed files with 22766 additions and 22766 deletions

678
aide.c
View File

@@ -51,21 +51,21 @@
extern char SVN_revision[]; // generated in version.c
// Recherche un raccourci clavier:
word * Raccourci(word NumeroRaccourci)
word * Shortcut(word shortcut_number)
{
if (NumeroRaccourci & 0x100)
return &(Bouton[NumeroRaccourci & 0xFF].Raccourci_gauche[0]);
if (NumeroRaccourci & 0x200)
return &(Bouton[NumeroRaccourci & 0xFF].Raccourci_droite[0]);
return &(Config_Touche[NumeroRaccourci & 0xFF][0]);
if (shortcut_number & 0x100)
return &(Button[shortcut_number & 0xFF].Left_shortcut[0]);
if (shortcut_number & 0x200)
return &(Button[shortcut_number & 0xFF].Right_shortcut[0]);
return &(Config_Key[shortcut_number & 0xFF][0]);
}
// Nom de la touche actuallement assignée à un raccourci d'après son numéro
// de type 0x100+BOUTON_* ou SPECIAL_*
const char * Valeur_Raccourci_Clavier(word NumeroRaccourci)
const char * Keyboard_shortcut_value(word shortcut_number)
{
static char Noms_raccourcis[80];
word * pointer = Raccourci(NumeroRaccourci);
static char shortcuts_name[80];
word * pointer = Shortcut(shortcut_number);
if (pointer == NULL)
return "(Problem)";
else
@@ -73,389 +73,389 @@ const char * Valeur_Raccourci_Clavier(word NumeroRaccourci)
if (pointer[0] == 0 && pointer[1] == 0)
return "None";
if (pointer[0] != 0 && pointer[1] == 0)
return Nom_touche(pointer[0]);
return Key_name(pointer[0]);
if (pointer[0] == 0 && pointer[1] != 0)
return Nom_touche(pointer[1]);
return Key_name(pointer[1]);
strcpy(Noms_raccourcis, Nom_touche(pointer[0]));
strcat(Noms_raccourcis, " or ");
strcat(Noms_raccourcis, Nom_touche(pointer[1]));
return Noms_raccourcis;
strcpy(shortcuts_name, Key_name(pointer[0]));
strcat(shortcuts_name, " or ");
strcat(shortcuts_name, Key_name(pointer[1]));
return shortcuts_name;
}
}
void Redefinir_controle(word *shortcut, int x_pos, int y_pos)
void Redefine_control(word *shortcut, int x_pos, int y_pos)
{
Effacer_curseur();
Print_dans_fenetre(x_pos,y_pos,"*PRESS KEY OR BUTTON*",CM_Noir,CM_Clair);
Afficher_curseur();
Hide_cursor();
Print_in_window(x_pos,y_pos,"*PRESS KEY OR BUTTON*",MC_Black,MC_Light);
Display_cursor();
while (1)
{
while(!Get_input())Wait_VBL();
if (Touche==TOUCHE_ESC)
if (Key==KEY_ESC)
return;
if (Touche!=0)
if (Key!=0)
{
*shortcut=Touche;
*shortcut=Key;
return;
}
}
}
void Fenetre_controle(int NumeroControle)
void Window_set_shortcut(int action_id)
{
short Bouton_clicke;
short IndiceOrdo;
short IndiceConfig;
short Redessiner_controles=1;
word * PtrRaccourci=NULL;
word Sauve_raccourci[2];
short clicked_button;
short order_index;
short config_index;
short redraw_controls=1;
word * shortcut_ptr=NULL;
word backup_shortcut[2];
PtrRaccourci=Raccourci(NumeroControle);
shortcut_ptr=Shortcut(action_id);
Sauve_raccourci[0]=PtrRaccourci[0];
Sauve_raccourci[1]=PtrRaccourci[1];
backup_shortcut[0]=shortcut_ptr[0];
backup_shortcut[1]=shortcut_ptr[1];
// Recherche dans hotkeys
IndiceOrdo=0;
while (Ordonnancement[IndiceOrdo]!=NumeroControle)
order_index=0;
while (Ordering[order_index]!=action_id)
{
IndiceOrdo++;
if (IndiceOrdo>=134)
order_index++;
if (order_index>=134)
{
Erreur(0);
Error(0);
return;
}
}
/*
IndiceConfig=0;
while (ConfigTouche[IndiceConfig].Number!=IndiceOrdo)
config_index=0;
while (ConfigKey[config_index].Number!=order_index)
{
IndiceConfig++;
if (IndiceConfig>=134)
config_index++;
if (config_index>=134)
{
Erreur(0);
Error(0);
return;
}
}
*/
IndiceConfig=IndiceOrdo; // Comprends pas... ça devrait pas marcher
config_index=order_index; // Comprends pas... ça devrait pas marcher
Ouvrir_fenetre(302,131,"Keyboard shortcut");
Fenetre_Definir_bouton_normal(181,111,55,14,"Cancel",0,1,TOUCHE_ESC); // 1
Fenetre_Definir_bouton_normal(241,111,55,14,"OK",0,1,SDLK_RETURN); // 2
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
Fenetre_Definir_bouton_normal(6,111,111,14,"Reset default",0,1,TOUCHE_AUCUNE); // 3
Window_set_normal_button(6,111,111,14,"Reset default",0,1,KEY_NONE); // 3
// Titre
Block(Fenetre_Pos_X+(Menu_Facteur_X*5),
Fenetre_Pos_Y+(Menu_Facteur_Y*16),
Menu_Facteur_X*292,Menu_Facteur_Y*11,CM_Noir);
Print_dans_fenetre(7,18,ConfigTouche[IndiceConfig].Label,CM_Blanc,CM_Noir);
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
Fenetre_Afficher_cadre_creux(5,68,292,37);
Print_dans_fenetre(9,70,ConfigTouche[IndiceConfig].Explic1,CM_Noir,CM_Clair);
Print_dans_fenetre(9,78,ConfigTouche[IndiceConfig].Explic2,CM_Noir,CM_Clair);
Print_dans_fenetre(9,86,ConfigTouche[IndiceConfig].Explic3,CM_Noir,CM_Clair);
Window_display_frame_in(5,68,292,37);
Print_in_window(9,70,ConfigKey[config_index].Explic1,MC_Black,MC_Light);
Print_in_window(9,78,ConfigKey[config_index].Explic2,MC_Black,MC_Light);
Print_in_window(9,86,ConfigKey[config_index].Explic3,MC_Black,MC_Light);
// Raccourci 0
Fenetre_Definir_bouton_normal(27,30,177,14,"",0,1,TOUCHE_AUCUNE); // 4
Fenetre_Definir_bouton_normal(209,30,56,14,"Remove",0,1,TOUCHE_AUCUNE); // 5
// 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
// Raccourci 1
Fenetre_Definir_bouton_normal(27,49,177,14,"",0,1,TOUCHE_AUCUNE); // 6
Fenetre_Definir_bouton_normal(209,49,56,14,"Remove",0,1,TOUCHE_AUCUNE); // 7
// 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
Afficher_curseur();
Display_cursor();
do
{
if (Redessiner_controles)
if (redraw_controls)
{
Effacer_curseur();
Block(Fenetre_Pos_X+(Menu_Facteur_X*32),
Fenetre_Pos_Y+(Menu_Facteur_Y*33),
Menu_Facteur_X*21*8,Menu_Facteur_Y*8,CM_Clair);
Print_dans_fenetre_limite(32,33,Nom_touche(PtrRaccourci[0]),21,CM_Noir,CM_Clair);
Block(Fenetre_Pos_X+(Menu_Facteur_X*32),
Fenetre_Pos_Y+(Menu_Facteur_Y*52),
Menu_Facteur_X*21*8,Menu_Facteur_Y*8,CM_Clair);
Print_dans_fenetre_limite(32,52,Nom_touche(PtrRaccourci[1]),21,CM_Noir,CM_Clair);
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);
UpdateRect(Fenetre_Pos_X,Fenetre_Pos_Y,302*Menu_Facteur_X,131*Menu_Facteur_Y);
Update_rect(Window_pos_X,Window_pos_Y,302*Menu_factor_X,131*Menu_factor_Y);
Afficher_curseur();
Redessiner_controles=0;
Display_cursor();
redraw_controls=0;
}
Bouton_clicke=Fenetre_Bouton_clicke();
clicked_button=Window_clicked_button();
switch (Bouton_clicke)
switch (clicked_button)
{
case -1:
case 0:
break;
case 4: // Change 0
Redefinir_controle(&PtrRaccourci[0], 32, 33);
Redessiner_controles=1;
Redefine_control(&shortcut_ptr[0], 32, 33);
redraw_controls=1;
break;
case 6: // Change 1
Redefinir_controle(&PtrRaccourci[1], 32, 52);
Redessiner_controles=1;
Redefine_control(&shortcut_ptr[1], 32, 52);
redraw_controls=1;
break;
case 5: // Remove 0
PtrRaccourci[0]=0;
Redessiner_controles=1;
shortcut_ptr[0]=0;
redraw_controls=1;
break;
case 7: // Remove 1
PtrRaccourci[1]=0;
Redessiner_controles=1;
shortcut_ptr[1]=0;
redraw_controls=1;
break;
case 3: // Defaults
PtrRaccourci[0]=ConfigTouche[IndiceConfig].Touche;
PtrRaccourci[1]=ConfigTouche[IndiceConfig].Touche2;
Redessiner_controles=1;
shortcut_ptr[0]=ConfigKey[config_index].Key;
shortcut_ptr[1]=ConfigKey[config_index].Key2;
redraw_controls=1;
break;
case 1: // Cancel
PtrRaccourci[0]=Sauve_raccourci[0];
PtrRaccourci[1]=Sauve_raccourci[1];
shortcut_ptr[0]=backup_shortcut[0];
shortcut_ptr[1]=backup_shortcut[1];
case 2: // OK
default:
break;
}
}
while ((Bouton_clicke!=1) && (Bouton_clicke!=2) && (Touche!=SDLK_RETURN));
Touche=0;
Fermer_fenetre();
Afficher_curseur();
while ((clicked_button!=1) && (clicked_button!=2) && (Key!=SDLK_RETURN));
Key=0;
Close_window();
Display_cursor();
}
// -- Menu d'aide -----------------------------------------------------------
void Afficher_aide(void)
void Display_help(void)
{
short x; // Indices d'affichage d'un caractère
short y;
short Position_X; // Parcours de remplissage du buffer de ligne
short Indice_de_ligne; // 0-15 (16 lignes de textes)
short Indice_de_caractere; // Parcours des caractères d'une ligne
short Ligne_de_depart=Position_d_aide_en_cours;
short Repeat_Menu_Facteur_X;
short Repeat_Menu_Facteur_Y;
short Pos_Reel_X;
short Pos_Reel_Y;
short x_position; // Parcours de remplissage du buffer de ligne
short line_index; // 0-15 (16 lignes de textes)
short char_index; // Parcours des caractères d'une ligne
short start_line=Help_position;
short repeat_menu_x_factor;
short repeat_menu_y_factor;
short real_x_pos;
short real_y_pos;
byte * char_pixel;
short width; // Largeur physique d'une ligne de texte
char TypeLigne; // N: Normale, T: Titre, S: Sous-titre
char line_type; // N: Normale, T: Titre, S: Sous-titre
// -: Ligne inférieur de sous-titre
const char * line;
char Buffer[45]; // Buffer texte utilisé pour formater les noms de
char buffer[45]; // buffer texte utilisé pour formater les noms de
// raccourcis clavier
short Position_lien=0; // Position du premier caractère "variable"
short Taille_lien=0; // Taille de la partie variable
short link_position=0; // Position du premier caractère "variable"
short link_size=0; // Taille de la partie variable
Pos_Reel_X=Fenetre_Pos_X+(13*Menu_Facteur_X);
Pos_Reel_Y=Fenetre_Pos_Y+(19*Menu_Facteur_Y);
real_x_pos=Window_pos_X+(13*Menu_factor_X);
real_y_pos=Window_pos_Y+(19*Menu_factor_Y);
for (Indice_de_ligne=0;Indice_de_ligne<16;Indice_de_ligne++)
for (line_index=0;line_index<16;line_index++)
{
// Raccourci au cas ou la section fait moins de 16 lignes
if (Indice_de_ligne >= Table_d_aide[Section_d_aide_en_cours].Nombre_de_lignes)
// Shortcut au cas ou la section fait moins de 16 lignes
if (line_index >= Help_section[Current_help_section].Length)
{
Block (Pos_Reel_X,
Pos_Reel_Y,
44*6*Menu_Facteur_X,
Block (real_x_pos,
real_y_pos,
44*6*Menu_factor_X,
// 44 = Nb max de char (+1 pour éviter les plantages en mode X
// causés par une largeur = 0)
(Menu_Facteur_Y<<3) * (16 - Indice_de_ligne),
CM_Noir);
(Menu_factor_Y<<3) * (16 - line_index),
MC_Black);
break;
}
// On affiche la ligne
line = Table_d_aide[Section_d_aide_en_cours].Table_aide[Ligne_de_depart + Indice_de_ligne].Text;
TypeLigne = Table_d_aide[Section_d_aide_en_cours].Table_aide[Ligne_de_depart + Indice_de_ligne].Line_type;
line = Help_section[Current_help_section].Help_table[start_line + line_index].Text;
line_type = Help_section[Current_help_section].Help_table[start_line + line_index].Line_type;
// Si c'est une sous-ligne de titre, on utilise le texte de la ligne précédente
if (TypeLigne == '-' && (Ligne_de_depart + Indice_de_ligne > 0))
line = Table_d_aide[Section_d_aide_en_cours].Table_aide[Ligne_de_depart + Indice_de_ligne - 1].Text;
else if (TypeLigne == 'K')
if (line_type == '-' && (start_line + line_index > 0))
line = Help_section[Current_help_section].Help_table[start_line + line_index - 1].Text;
else if (line_type == 'K')
{
const char *Lien;
Position_lien = strstr(line,"%s") - line;
Lien=Valeur_Raccourci_Clavier(Table_d_aide[Section_d_aide_en_cours].Table_aide[Ligne_de_depart + Indice_de_ligne].Line_parameter);
Taille_lien=strlen(Lien);
snprintf(Buffer, 44, line, Lien);
if (strlen(line)+Taille_lien-2>44)
const char *hyperlink;
link_position = strstr(line,"%s") - line;
hyperlink=Keyboard_shortcut_value(Help_section[Current_help_section].Help_table[start_line + line_index].Line_parameter);
link_size=strlen(hyperlink);
snprintf(buffer, 44, line, hyperlink);
if (strlen(line)+link_size-2>44)
{
Buffer[43]=CARACTERE_SUSPENSION;
Buffer[44]='\0';
buffer[43]=ELLIPSIS_CHARACTER;
buffer[44]='\0';
}
line = Buffer;
line = buffer;
}
// Calcul de la taille
width=strlen(line);
// Les lignes de titres prennent plus de place
if (TypeLigne == 'T' || TypeLigne == '-')
if (line_type == 'T' || line_type == '-')
width = width*2;
// Pour chaque ligne dans la fenêtre:
for (y=0;y<8;y++)
{
Position_X=0;
x_position=0;
// On crée une nouvelle ligne à splotcher
for (Indice_de_caractere=0;Indice_de_caractere<width;Indice_de_caractere++)
for (char_index=0;char_index<width;char_index++)
{
// Recherche du caractère dans les fontes de l'aide.
// Ligne titre : Si l'indice est impair on dessine le quart de caractère
// qui va a gauche, sinon celui qui va a droite.
if (TypeLigne=='T')
if (line_type=='T')
{
if (line[Indice_de_caractere/2]>'_' || line[Indice_de_caractere/2]<' ')
char_pixel=&(Fonte_help_norm['!'][0][0]); // Caractère pas géré
else if (Indice_de_caractere & 1)
char_pixel=&(Fonte_help_t2[(unsigned char)(line[Indice_de_caractere/2])-' '][0][0]);
if (line[char_index/2]>'_' || line[char_index/2]<' ')
char_pixel=&(GFX_help_font_norm['!'][0][0]); // Caractère pas géré
else if (char_index & 1)
char_pixel=&(GFX_help_font_t2[(unsigned char)(line[char_index/2])-' '][0][0]);
else
char_pixel=&(Fonte_help_t1[(unsigned char)(line[Indice_de_caractere/2])-' '][0][0]);
char_pixel=&(GFX_help_font_t1[(unsigned char)(line[char_index/2])-' '][0][0]);
}
else if (TypeLigne=='-')
else if (line_type=='-')
{
if (line[Indice_de_caractere/2]>'_' || line[Indice_de_caractere/2]<' ')
char_pixel=&(Fonte_help_norm['!'][0][0]); // Caractère pas géré
else if (Indice_de_caractere & 1)
char_pixel=&(Fonte_help_t4[(unsigned char)(line[Indice_de_caractere/2])-' '][0][0]);
if (line[char_index/2]>'_' || line[char_index/2]<' ')
char_pixel=&(GFX_help_font_norm['!'][0][0]); // Caractère pas géré
else if (char_index & 1)
char_pixel=&(GFX_help_font_t4[(unsigned char)(line[char_index/2])-' '][0][0]);
else
char_pixel=&(Fonte_help_t3[(unsigned char)(line[Indice_de_caractere/2])-' '][0][0]);
char_pixel=&(GFX_help_font_t3[(unsigned char)(line[char_index/2])-' '][0][0]);
}
else if (TypeLigne=='S')
char_pixel=&(Fonte_help_bold[(unsigned char)(line[Indice_de_caractere])][0][0]);
else if (TypeLigne=='N' || TypeLigne=='K')
char_pixel=&(Fonte_help_norm[(unsigned char)(line[Indice_de_caractere])][0][0]);
else if (line_type=='S')
char_pixel=&(GFX_bold_font[(unsigned char)(line[char_index])][0][0]);
else if (line_type=='N' || line_type=='K')
char_pixel=&(GFX_help_font_norm[(unsigned char)(line[char_index])][0][0]);
else
char_pixel=&(Fonte_help_norm['!'][0][0]); // Un garde-fou en cas de probleme
char_pixel=&(GFX_help_font_norm['!'][0][0]); // Un garde-fou en cas de probleme
for (x=0;x<6;x++)
for (Repeat_Menu_Facteur_X=0;Repeat_Menu_Facteur_X<Menu_Facteur_X;Repeat_Menu_Facteur_X++)
for (repeat_menu_x_factor=0;repeat_menu_x_factor<Menu_factor_X;repeat_menu_x_factor++)
{
byte Couleur = *(char_pixel+x+y*6);
byte Repetition = Pixel_width-1;
byte color = *(char_pixel+x+y*6);
byte repetition = Pixel_width-1;
// Surlignement pour liens
if (TypeLigne=='K' && Indice_de_caractere>=Position_lien
&& Indice_de_caractere<(Position_lien+Taille_lien))
if (line_type=='K' && char_index>=link_position
&& char_index<(link_position+link_size))
{
if (Couleur == CM_Clair)
Couleur=CM_Blanc;
else if (Couleur == CM_Fonce)
Couleur=CM_Clair;
if (color == MC_Light)
color=MC_White;
else if (color == MC_Dark)
color=MC_Light;
else if (y<7)
Couleur=CM_Fonce;
color=MC_Dark;
}
Buffer_de_ligne_horizontale[Position_X++]=Couleur;
while (Repetition--)
Buffer_de_ligne_horizontale[Position_X++]=Couleur;
Horizontal_line_buffer[x_position++]=color;
while (repetition--)
Horizontal_line_buffer[x_position++]=color;
}
}
// On la splotche
for (Repeat_Menu_Facteur_Y=0;Repeat_Menu_Facteur_Y<Menu_Facteur_Y;Repeat_Menu_Facteur_Y++)
Afficher_ligne_fast(Pos_Reel_X,Pos_Reel_Y++,width*Menu_Facteur_X*6,Buffer_de_ligne_horizontale);
for (repeat_menu_y_factor=0;repeat_menu_y_factor<Menu_factor_Y;repeat_menu_y_factor++)
Display_line_fast(real_x_pos,real_y_pos++,width*Menu_factor_X*6,Horizontal_line_buffer);
}
// On efface la fin de la ligne:
Block (Pos_Reel_X+width*Menu_Facteur_X*6,
Pos_Reel_Y-(8*Menu_Facteur_Y),
((44*6*Menu_Facteur_X)-width*Menu_Facteur_X*6)+1,
Block (real_x_pos+width*Menu_factor_X*6,
real_y_pos-(8*Menu_factor_Y),
((44*6*Menu_factor_X)-width*Menu_factor_X*6)+1,
// 44 = Nb max de char (+1 pour éviter les plantages en mode X
// causés par une largeur = 0)
Menu_Facteur_Y<<3,
CM_Noir);
Menu_factor_Y<<3,
MC_Black);
}
UpdateRect(Fenetre_Pos_X+13*Menu_Facteur_X,Fenetre_Pos_Y+19*Menu_Facteur_Y,44*6*Menu_Facteur_X,16*8*Menu_Facteur_Y);
Update_rect(Window_pos_X+13*Menu_factor_X,Window_pos_Y+19*Menu_factor_Y,44*6*Menu_factor_X,16*8*Menu_factor_Y);
}
void Scroller_aide(T_Bouton_scroller * scroller)
void Scroll_help(T_Scroller_button * scroller)
{
Effacer_curseur();
scroller->Position=Position_d_aide_en_cours;
Calculer_hauteur_curseur_jauge(scroller);
Fenetre_Dessiner_jauge(scroller);
Afficher_aide();
Afficher_curseur();
Hide_cursor();
scroller->Position=Help_position;
Compute_slider_cursor_height(scroller);
Window_draw_slider(scroller);
Display_help();
Display_cursor();
}
void Bouton_Aide(void)
void Button_Help(void)
{
short Numero_bouton;
short btn_number;
// Aide contextuelle
if (Touche!=0)
if (Key!=0)
{
Numero_bouton = Numero_bouton_sous_souris();
if (Numero_bouton != -1)
btn_number = Button_under_mouse();
if (btn_number != -1)
{
Fenetre_aide(Numero_bouton, NULL);
Window_help(btn_number, NULL);
return;
}
}
Fenetre_aide(-1, NULL);
Window_help(-1, NULL);
}
// Ouvre l'ecran d'aide. Passer -1 pour la section par défaut (ou derniere,)
// Ou un nombre de l'enumération NUMEROS_DE_BOUTONS pour l'aide contextuelle.
void Fenetre_aide(int section, const char *Sous_section)
// Ou un nombre de l'enumération BUTTON_NUMBERS pour l'aide contextuelle.
void Window_help(int section, const char *sub_section)
{
short Bouton_clicke;
short Nb_lignes;
T_Bouton_scroller * scroller;
short clicked_button;
short nb_lines;
T_Scroller_button * scroller;
if (section!=-1)
{
Section_d_aide_en_cours = 4 + section;
Position_d_aide_en_cours = 0;
Current_help_section = 4 + section;
Help_position = 0;
}
Nb_lignes=Table_d_aide[Section_d_aide_en_cours].Nombre_de_lignes;
if (section!=-1 && Sous_section!=NULL)
nb_lines=Help_section[Current_help_section].Length;
if (section!=-1 && sub_section!=NULL)
{
int Indice=0;
for (Indice=0; Indice<Nb_lignes; Indice++)
if (Table_d_aide[Section_d_aide_en_cours].Table_aide[Indice].Line_type == 'T' &&
!strcmp(Table_d_aide[Section_d_aide_en_cours].Table_aide[Indice].Text, Sous_section))
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))
{
Position_d_aide_en_cours = Indice;
Help_position = index;
break;
}
}
Ouvrir_fenetre(310,175,"Help / About...");
Open_window(310,175,"Help / About...");
// dessiner de la fenêtre où va défiler le texte
Fenetre_Afficher_cadre_creux(8,17,274,132);
Block(Fenetre_Pos_X+(Menu_Facteur_X*9),
Fenetre_Pos_Y+(Menu_Facteur_Y*18),
Menu_Facteur_X*272,Menu_Facteur_Y*130,CM_Noir);
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);
Fenetre_Definir_bouton_normal(266,153,35,14,"Exit",0,1,TOUCHE_ESC); // 1
scroller=Fenetre_Definir_bouton_scroller(290,18,130,Nb_lignes,
16,Position_d_aide_en_cours); // 2
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
Fenetre_Definir_bouton_normal( 9,154, 6*8,14,"About" ,1,1,SDLK_a); // 3
Window_set_normal_button( 9,154, 6*8,14,"About" ,1,1,SDLK_a); // 3
Fenetre_Definir_bouton_normal( 9+6*8+4,154, 8*8,14,"License",1,1,SDLK_l); // 4
Fenetre_Definir_bouton_normal( 9+6*8+4+8*8+4,154, 5*8,14,"Help",1,1,SDLK_h); // 5
Fenetre_Definir_bouton_normal(9+6*8+4+8*8+4+5*8+4,154, 8*8,14,"Credits",1,1,SDLK_c); // 6
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
Fenetre_Definir_bouton_special(9,18,272,130); // 7
Window_set_special_button(9,18,272,130); // 7
Afficher_aide();
Display_help();
UpdateRect(Fenetre_Pos_X,Fenetre_Pos_Y,310*Menu_Facteur_X,175*Menu_Facteur_Y);
Update_rect(Window_pos_X,Window_pos_Y,310*Menu_factor_X,175*Menu_factor_Y);
Afficher_curseur();
Display_cursor();
do
{
Bouton_clicke=Fenetre_Bouton_clicke();
clicked_button=Window_clicked_button();
switch (Bouton_clicke)
switch (clicked_button)
{
case -1:
case 0:
@@ -463,187 +463,187 @@ void Fenetre_aide(int section, const char *Sous_section)
break;
case 7: // Zone de texte
{
int line = ((Mouse_Y-Fenetre_Pos_Y)/Menu_Facteur_Y - 18)/8;
Attendre_fin_de_click();
if (line == ((Mouse_Y-Fenetre_Pos_Y)/Menu_Facteur_Y - 18)/8)
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 (Position_d_aide_en_cours+line<Nb_lignes)
if (Help_position+line<nb_lines)
{
switch (Table_d_aide[Section_d_aide_en_cours].Table_aide[Position_d_aide_en_cours+line].Line_type)
switch (Help_section[Current_help_section].Help_table[Help_position+line].Line_type)
{
case 'K':
Fenetre_controle(Table_d_aide[Section_d_aide_en_cours].Table_aide[Position_d_aide_en_cours+line].Line_parameter);
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;
}
Effacer_curseur();
Afficher_aide();
Afficher_curseur();
Hide_cursor();
Display_help();
Display_cursor();
}
}
break;
}
default:
Effacer_curseur();
if (Bouton_clicke>2)
Hide_cursor();
if (clicked_button>2)
{
Section_d_aide_en_cours=Bouton_clicke-3;
Position_d_aide_en_cours=0;
Nb_lignes=Table_d_aide[Section_d_aide_en_cours].Nombre_de_lignes;
Current_help_section=clicked_button-3;
Help_position=0;
nb_lines=Help_section[Current_help_section].Length;
scroller->Position=0;
scroller->Nb_elements=Nb_lignes;
Calculer_hauteur_curseur_jauge(scroller);
Fenetre_Dessiner_jauge(scroller);
scroller->Nb_elements=nb_lines;
Compute_slider_cursor_height(scroller);
Window_draw_slider(scroller);
}
else
Position_d_aide_en_cours=Fenetre_Attribut2;
Help_position=Window_attribute2;
Afficher_aide();
Afficher_curseur();
Display_help();
Display_cursor();
}
// Gestion des touches de déplacement dans la liste
switch (Touche)
switch (Key)
{
case SDLK_UP : // Haut
if (Position_d_aide_en_cours>0)
Position_d_aide_en_cours--;
Scroller_aide(scroller);
Touche=0;
if (Help_position>0)
Help_position--;
Scroll_help(scroller);
Key=0;
break;
case SDLK_DOWN : // Bas
if (Position_d_aide_en_cours<Nb_lignes-16)
Position_d_aide_en_cours++;
Scroller_aide(scroller);
Touche=0;
if (Help_position<nb_lines-16)
Help_position++;
Scroll_help(scroller);
Key=0;
break;
case SDLK_PAGEUP : // PageUp
if (Position_d_aide_en_cours>15)
Position_d_aide_en_cours-=15;
if (Help_position>15)
Help_position-=15;
else
Position_d_aide_en_cours=0;
Scroller_aide(scroller);
Touche=0;
Help_position=0;
Scroll_help(scroller);
Key=0;
break;
case (TOUCHE_MOUSEWHEELUP) : // WheelUp
if (Position_d_aide_en_cours>3)
Position_d_aide_en_cours-=3;
case (KEY_MOUSEWHEELUP) : // WheelUp
if (Help_position>3)
Help_position-=3;
else
Position_d_aide_en_cours=0;
Scroller_aide(scroller);
Touche=0;
Help_position=0;
Scroll_help(scroller);
Key=0;
break;
case SDLK_PAGEDOWN : // PageDown
if (Nb_lignes>16)
if (nb_lines>16)
{
if (Position_d_aide_en_cours<Nb_lignes-16-15)
Position_d_aide_en_cours+=15;
if (Help_position<nb_lines-16-15)
Help_position+=15;
else
Position_d_aide_en_cours=Nb_lignes-16;
Scroller_aide(scroller);
Touche=0;
Help_position=nb_lines-16;
Scroll_help(scroller);
Key=0;
}
break;
case (TOUCHE_MOUSEWHEELDOWN) : // Wheeldown
if (Nb_lignes>16)
case (KEY_MOUSEWHEELDOWN) : // Wheeldown
if (nb_lines>16)
{
if (Position_d_aide_en_cours<Nb_lignes-16-3)
Position_d_aide_en_cours+=3;
if (Help_position<nb_lines-16-3)
Help_position+=3;
else
Position_d_aide_en_cours=Nb_lignes-16;
Scroller_aide(scroller);
Touche=0;
Help_position=nb_lines-16;
Scroll_help(scroller);
Key=0;
}
break;
case SDLK_HOME : // Home
Position_d_aide_en_cours=0;
Scroller_aide(scroller);
Touche=0;
Help_position=0;
Scroll_help(scroller);
Key=0;
break;
case SDLK_END : // End
if (Nb_lignes>16)
if (nb_lines>16)
{
Position_d_aide_en_cours=Nb_lignes-16;
Scroller_aide(scroller);
Touche=0;
Help_position=nb_lines-16;
Scroll_help(scroller);
Key=0;
}
break;
}
}
while ((Bouton_clicke!=1) && (Touche!=SDLK_RETURN));
while ((clicked_button!=1) && (Key!=SDLK_RETURN));
if(Touche==SDLK_RETURN) Touche=0;
Fermer_fenetre();
Desenclencher_bouton(BOUTON_AIDE);
Afficher_curseur();
if(Key==SDLK_RETURN) Key=0;
Close_window();
Unselect_bouton(BUTTON_HELP);
Display_cursor();
}
#define STATS_COULEUR_TITRES CM_Blanc
#define STATS_COULEUR_DONNEES CM_Clair
void Bouton_Stats(void)
#define STATS_TITLE_COLOR MC_White
#define STATS_DATA_COLOR MC_Light
void Button_Stats(void)
{
short Bouton_clicke;
char Buffer[37];
dword Utilisation_couleur[256];
short clicked_button;
char buffer[37];
dword color_usage[256];
unsigned long long freeRam;
qword mem_size = 0;
Ouvrir_fenetre(310,174,"Statistics");
Open_window(310,174,"Statistics");
// Dessin de la fenetre ou va s'afficher le texte
Fenetre_Afficher_cadre_creux(8,17,294,132);
Block(Fenetre_Pos_X+(Menu_Facteur_X*9),
Fenetre_Pos_Y+(Menu_Facteur_Y*18),
Menu_Facteur_X*292,Menu_Facteur_Y*130,CM_Noir);
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);
Fenetre_Definir_bouton_normal(120,153,70,14,"OK",0,1,TOUCHE_ESC); // 1
Window_set_normal_button(120,153,70,14,"OK",0,1,KEY_ESC); // 1
// Affichage du numéro de version
Print_dans_fenetre(10,19,"Program version:",STATS_COULEUR_TITRES,CM_Noir);
sprintf(Buffer,"GrafX 2.00 %s%s",ALPHA_BETA,POURCENTAGE_VERSION);
Print_dans_fenetre(146,19,Buffer,STATS_COULEUR_DONNEES,CM_Noir);
Print_dans_fenetre(10,27,"SVN revision #:",STATS_COULEUR_TITRES,CM_Noir);
Print_dans_fenetre(146,27,SVN_revision,STATS_COULEUR_DONNEES,CM_Noir);
Print_dans_fenetre(10,35,"Build options:",STATS_COULEUR_TITRES,CM_Noir);
Print_dans_fenetre(146,35,Support_TrueType()?"TTF fonts":"no TTF fonts",STATS_COULEUR_DONNEES,CM_Noir);
Print_in_window(10,19,"Program version:",STATS_TITLE_COLOR,MC_Black);
sprintf(buffer,"GrafX 2.00 %s%s",ALPHA_BETA,PERCENTAGE_VERSION);
Print_in_window(146,19,buffer,STATS_DATA_COLOR,MC_Black);
Print_in_window(10,27,"SVN revision #:",STATS_TITLE_COLOR,MC_Black);
Print_in_window(146,27,SVN_revision,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);
// Affichage de la mémoire restante
Print_dans_fenetre(10,51,"Free memory: ",STATS_COULEUR_TITRES,CM_Noir);
Print_in_window(10,51,"Free memory: ",STATS_TITLE_COLOR,MC_Black);
freeRam = Memoire_libre();
freeRam = Memory_free();
if(freeRam > (100ULL*1024*1024*1024))
sprintf(Buffer,"%u Gigabytes",(unsigned int)(freeRam/(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)));
sprintf(buffer,"%u Megabytes",(unsigned int)(freeRam/(1024*1024)));
else if(freeRam > 100*1024)
sprintf(Buffer,"%u Kilobytes",(unsigned int)(freeRam/1024));
sprintf(buffer,"%u Kilobytes",(unsigned int)(freeRam/1024));
else
sprintf(Buffer,"%u bytes",(unsigned int)freeRam);
Print_dans_fenetre(114,51,Buffer,STATS_COULEUR_DONNEES,CM_Noir);
sprintf(buffer,"%u bytes",(unsigned int)freeRam);
Print_in_window(114,51,buffer,STATS_DATA_COLOR,MC_Black);
// Affichage de l'espace disque libre
sprintf(Buffer,"Free space on %c:",Principal_Repertoire_courant[0]);
Print_dans_fenetre(10,67,Buffer,STATS_COULEUR_TITRES,CM_Noir);
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(Principal_Repertoire_courant,&tailleU,NULL,NULL);
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 Informations_Disque;
statfs(Principal_Repertoire_courant,&Informations_Disque);
mem_size=(qword) Informations_Disque.f_bfree * (qword) Informations_Disque.f_bsize;
struct statfs disk_info;
statfs(Main_current_directory,&disk_info);
mem_size=(qword) disk_info.f_bfree * (qword) disk_info.f_bsize;
}
#else
// Free disk space is only for shows. Other platforms can display 0.
@@ -652,48 +652,48 @@ void Bouton_Stats(void)
#endif
if(mem_size > (100ULL*1024*1024*1024))
sprintf(Buffer,"%u Gigabytes",(unsigned int)(mem_size/(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)));
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));
sprintf(buffer,"%u Kilobytes",(unsigned int)(mem_size/1024));
else
sprintf(Buffer,"%u bytes",(unsigned int)mem_size);
Print_dans_fenetre(146,67,Buffer,STATS_COULEUR_DONNEES,CM_Noir);
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_dans_fenetre(10,83,"Picture info.:",STATS_COULEUR_TITRES,CM_Noir);
Print_in_window(10,83,"Picture info.:",STATS_TITLE_COLOR,MC_Black);
// Affichage des dimensions de l'image
Print_dans_fenetre(18,91,"Dimensions :",STATS_COULEUR_TITRES,CM_Noir);
sprintf(Buffer,"%dx%d",Principal_Largeur_image,Principal_Hauteur_image);
Print_dans_fenetre(122,91,Buffer,STATS_COULEUR_DONNEES,CM_Noir);
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_dans_fenetre(18,99,"Colors used:",STATS_COULEUR_TITRES,CM_Noir);
memset(Utilisation_couleur,0,sizeof(Utilisation_couleur));
sprintf(Buffer,"%d",Palette_Compter_nb_couleurs_utilisees(Utilisation_couleur));
Print_dans_fenetre(122,99,Buffer,STATS_COULEUR_DONNEES,CM_Noir);
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_dans_fenetre(10,115,"Resolution:",STATS_COULEUR_TITRES,CM_Noir);
sprintf(Buffer,"%dx%d",Largeur_ecran,Hauteur_ecran);
Print_dans_fenetre(106,115,Buffer,STATS_COULEUR_DONNEES,CM_Noir);
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);
UpdateRect(Fenetre_Pos_X,Fenetre_Pos_Y,Menu_Facteur_X*310,Menu_Facteur_Y*174);
Update_rect(Window_pos_X,Window_pos_Y,Menu_factor_X*310,Menu_factor_Y*174);
Afficher_curseur();
Display_cursor();
do
{
Bouton_clicke=Fenetre_Bouton_clicke();
clicked_button=Window_clicked_button();
}
while ( (Bouton_clicke!=1) && (Touche!=SDLK_RETURN) );
while ( (clicked_button!=1) && (Key!=SDLK_RETURN) );
if(Touche==SDLK_RETURN)Touche=0;
if(Key==SDLK_RETURN)Key=0;
Fermer_fenetre();
Desenclencher_bouton(BOUTON_AIDE);
Afficher_curseur();
Close_window();
Unselect_bouton(BUTTON_HELP);
Display_cursor();
}