Bookmarks (issue 92) are now functional in Save/Load screens
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@656 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
5040a57bd1
commit
9f85f5f1bb
87
boutons.c
87
boutons.c
@ -2552,16 +2552,15 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
||||
Fenetre_Definir_bouton_normal(8,17,117,23,"Select drive",0,1,SDLK_LAST); // 9
|
||||
|
||||
// Bookmarks
|
||||
for (Temp=0;Temp<4;Temp++)
|
||||
for (Temp=0;Temp<NB_BOOKMARKS;Temp++)
|
||||
{
|
||||
static const char *Lib[4] = {"My Docs", "USBdrive", "Desktop", "--------"};
|
||||
Dropdown_bookmark[Temp]=
|
||||
Fenetre_Definir_bouton_dropdown(126+(88+1)*(Temp%2),17+(Temp/2)*12,88,11,56,"",0,0,1,A_DROITE); // 10-13
|
||||
Fenetre_Afficher_sprite_drive(Dropdown_bookmark[Temp]->Pos_X+3,Dropdown_bookmark[Temp]->Pos_Y+2,5);
|
||||
Print_dans_fenetre(Dropdown_bookmark[Temp]->Pos_X+3+10,Dropdown_bookmark[Temp]->Pos_Y+2,Lib[Temp],Temp<3?CM_Noir:CM_Fonce,CM_Clair);
|
||||
Fenetre_Dropdown_choix(Dropdown_bookmark[Temp],0,"Set");
|
||||
Fenetre_Dropdown_choix(Dropdown_bookmark[Temp],1,"Rename");
|
||||
Fenetre_Dropdown_choix(Dropdown_bookmark[Temp],2,"Clear");
|
||||
Afficher_bookmark(Dropdown_bookmark[Temp],Temp);
|
||||
}
|
||||
// On prend bien soin de passer dans le répertoire courant (le bon qui faut! Oui madame!)
|
||||
if (Load)
|
||||
@ -2837,7 +2836,67 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
||||
Nouvelle_preview=1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (Bouton_clicke>=10 && Bouton_clicke<10+NB_BOOKMARKS)
|
||||
{
|
||||
// Bookmark
|
||||
char * Nom_repertoire;
|
||||
|
||||
switch(Fenetre_Attribut2)
|
||||
{
|
||||
case -1: // bouton lui-même: aller au répertoire mémorisé
|
||||
if (Config.Bookmark_directory[Bouton_clicke-10])
|
||||
{
|
||||
*Fichier_recherche=0;
|
||||
strcpy(Principal_Nom_fichier,Config.Bookmark_directory[Bouton_clicke-10]);
|
||||
Type_selectionne=1;
|
||||
On_a_clicke_sur_OK=1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0: // Set
|
||||
if (Config.Bookmark_directory[Bouton_clicke-10])
|
||||
free(Config.Bookmark_directory[Bouton_clicke-10]);
|
||||
Config.Bookmark_label[Bouton_clicke-10][0]='\0';
|
||||
Temp=strlen(Principal_Repertoire_courant);
|
||||
Config.Bookmark_directory[Bouton_clicke-10]=malloc(Temp+1);
|
||||
strcpy(Config.Bookmark_directory[Bouton_clicke-10],Principal_Repertoire_courant);
|
||||
|
||||
Nom_repertoire=Position_dernier_slash(Principal_Repertoire_courant);
|
||||
if (Nom_repertoire && Nom_repertoire[1]!='\0')
|
||||
Nom_repertoire++;
|
||||
else
|
||||
Nom_repertoire=Principal_Repertoire_courant;
|
||||
Temp=strlen(Nom_repertoire);
|
||||
strncpy(Config.Bookmark_label[Bouton_clicke-10],Nom_repertoire,8);
|
||||
if (Temp>8)
|
||||
{
|
||||
Config.Bookmark_label[Bouton_clicke-10][7]=CARACTERE_SUSPENSION;
|
||||
Config.Bookmark_label[Bouton_clicke-10][8]='\0';
|
||||
}
|
||||
Afficher_bookmark(Dropdown_bookmark[Bouton_clicke-10],Bouton_clicke-10);
|
||||
break;
|
||||
|
||||
case 1: // Rename
|
||||
if (Config.Bookmark_directory[Bouton_clicke-10])
|
||||
{
|
||||
Readline_ex(Dropdown_bookmark[Bouton_clicke-10]->Pos_X+3+10,Dropdown_bookmark[Bouton_clicke-10]->Pos_Y+2,Config.Bookmark_label[Bouton_clicke-10],8,8,0);
|
||||
Afficher_bookmark(Dropdown_bookmark[Bouton_clicke-10],Bouton_clicke-10);
|
||||
Afficher_curseur();
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // Clear
|
||||
if (Config.Bookmark_directory[Bouton_clicke-10])
|
||||
{
|
||||
free(Config.Bookmark_directory[Bouton_clicke-10]);
|
||||
Config.Bookmark_directory[Bouton_clicke-10]=NULL;
|
||||
Config.Bookmark_label[Bouton_clicke-10][0]='\0';
|
||||
Afficher_bookmark(Dropdown_bookmark[Bouton_clicke-10],Bouton_clicke-10);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch (Touche)
|
||||
@ -2964,14 +3023,18 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
||||
}
|
||||
|
||||
// On doit rentrer dans le répertoire:
|
||||
chdir(Principal_Nom_fichier);
|
||||
Determiner_repertoire_courant();
|
||||
|
||||
// On lit le nouveau répertoire
|
||||
Lire_liste_des_fichiers(Principal_Format);
|
||||
Trier_la_liste_des_fichiers();
|
||||
// On place la barre de sélection sur le répertoire d'où l'on vient
|
||||
Placer_barre_de_selection_sur(Repertoire_precedent);
|
||||
if (!chdir(Principal_Nom_fichier))
|
||||
{
|
||||
Determiner_repertoire_courant();
|
||||
|
||||
// On lit le nouveau répertoire
|
||||
Lire_liste_des_fichiers(Principal_Format);
|
||||
Trier_la_liste_des_fichiers();
|
||||
// On place la barre de sélection sur le répertoire d'où l'on vient
|
||||
Placer_barre_de_selection_sur(Repertoire_precedent);
|
||||
}
|
||||
else
|
||||
Erreur(0);
|
||||
// Affichage des premiers fichiers visibles:
|
||||
Preparer_et_afficher_liste_fichiers(Principal_File_list_Position,Principal_File_list_Decalage,Scroller_de_fichiers);
|
||||
Afficher_curseur();
|
||||
|
||||
2
const.h
2
const.h
@ -63,7 +63,7 @@
|
||||
#define NB_PAGES_UNDO_MAX 99 // Nombre maximal de pages d'undo
|
||||
#define FACTEUR_DE_ZOOM_PAR_DEFAUT 4 // Facteur de zoom initial
|
||||
#define TAILLE_CHEMIN_FICHIER 260 // Le nombre de caractères maxi pour un nom de fichier avec chemin complet
|
||||
|
||||
#define NB_BOOKMARKS 4 // Nombre de boutons "signet" dans l'ecran Save/Load
|
||||
// Caractères présents dans les deux fontes
|
||||
#define CARACTERE_TRIANGLE_DROIT 16
|
||||
#define CARACTERE_TRIANGLE_GAUCHE 17
|
||||
|
||||
15
files.c
15
files.c
@ -713,6 +713,21 @@ short Calculer_decalage_click_dans_fileselector(void)
|
||||
return Decalage_calcule;
|
||||
}
|
||||
|
||||
void Afficher_bookmark(struct Fenetre_Bouton_dropdown * Bouton, int Numero_bookmark)
|
||||
{
|
||||
if (Config.Bookmark_directory[Numero_bookmark])
|
||||
{
|
||||
int Taille;
|
||||
Print_dans_fenetre_limite(Bouton->Pos_X+3+10,Bouton->Pos_Y+2,Config.Bookmark_label[Numero_bookmark],8,CM_Noir,CM_Clair);
|
||||
Taille=strlen(Config.Bookmark_label[Numero_bookmark]);
|
||||
if (Taille<8)
|
||||
Block(Fenetre_Pos_X+(Menu_Facteur_X*(Bouton->Pos_X+3+10+Taille*8)),Fenetre_Pos_Y+(Menu_Facteur_Y*(Bouton->Pos_Y+2)),Menu_Facteur_X*(8-Taille)*8,Menu_Facteur_Y*8,CM_Clair);
|
||||
}
|
||||
else
|
||||
Print_dans_fenetre(Bouton->Pos_X+3+10,Bouton->Pos_Y+2,"--------",CM_Fonce,CM_Clair);
|
||||
}
|
||||
|
||||
|
||||
void for_each_file(const char * Nom_repertoire, void Callback(const char *))
|
||||
{
|
||||
// Pour scan de répertoire
|
||||
|
||||
2
files.h
2
files.h
@ -35,6 +35,8 @@ void Afficher_la_liste_des_fichiers(short Decalage_premier,short Decalage_select
|
||||
// -- Récupérer le libellé d'un élément de la liste -------------------------
|
||||
void Determiner_element_de_la_liste(short Decalage_premier,short Decalage_select,char * Libelle,int *Type);
|
||||
|
||||
void Afficher_bookmark(struct Fenetre_Bouton_dropdown * Bouton, int Numero_bookmark);
|
||||
|
||||
// -- Déplacements dans la liste des fichiers -------------------------------
|
||||
|
||||
void Select_Scroll_Down(short * Decalage_premier,short * Decalage_select);
|
||||
|
||||
16
gfx2def.ini
16
gfx2def.ini
@ -308,3 +308,19 @@
|
||||
; 1 to 16. The menu can always display the number of lines you request.
|
||||
;
|
||||
Palette_Cells_Y = 8; (Default 8)
|
||||
|
||||
; Bookmarked directories. Leave the directory blank for unused ones.
|
||||
;
|
||||
Bookmark_label =
|
||||
Bookmark_directory =
|
||||
|
||||
Bookmark_label =
|
||||
Bookmark_directory =
|
||||
|
||||
Bookmark_label =
|
||||
Bookmark_directory =
|
||||
|
||||
Bookmark_label =
|
||||
Bookmark_directory =
|
||||
|
||||
; end of configuration
|
||||
|
||||
2
global.h
2
global.h
@ -83,6 +83,8 @@ GFX2_GLOBAL struct S_Config
|
||||
byte Taille_ecran_dans_GIF;
|
||||
byte Auto_nb_used;
|
||||
byte Resolution_par_defaut;
|
||||
char *Bookmark_directory[NB_BOOKMARKS]; // independant malloc of adaptive size
|
||||
char Bookmark_label[NB_BOOKMARKS][8+1];
|
||||
} Config;
|
||||
|
||||
// Tableau des touches spéciales
|
||||
|
||||
5
moteur.c
5
moteur.c
@ -2217,7 +2217,6 @@ short Fenetre_Dropdown_click(struct Fenetre_Bouton_dropdown *Bouton)
|
||||
Fenetre_Desenfoncer_bouton_normal(Bouton->Pos_X,Bouton->Pos_Y,Bouton->Largeur,Bouton->Hauteur);
|
||||
Afficher_curseur();
|
||||
|
||||
Fenetre_Attribut2=0;
|
||||
if (Indice_selectionne>=0 && Indice_selectionne<Nb_choix)
|
||||
{
|
||||
for(Choix=Bouton->Premier_choix; Indice_selectionne; Choix=Choix->Next,Indice_selectionne--)
|
||||
@ -2230,6 +2229,7 @@ short Fenetre_Dropdown_click(struct Fenetre_Bouton_dropdown *Bouton)
|
||||
}
|
||||
return Bouton->Numero;
|
||||
}
|
||||
Fenetre_Attribut2=-1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2434,7 +2434,10 @@ short Fenetre_Numero_bouton_clicke(void)
|
||||
if (Mouse_K & Temp5->Bouton_actif)
|
||||
return Fenetre_Dropdown_click(Temp5);
|
||||
else
|
||||
{
|
||||
Fenetre_Attribut2=-1;
|
||||
return Fenetre_bouton_normal_click(Temp5->Pos_X,Temp5->Pos_Y,Temp5->Largeur,Temp5->Hauteur,Temp5->Numero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
94
readini.c
94
readini.c
@ -31,14 +31,21 @@
|
||||
void Charger_INI_Clear_string(char * String)
|
||||
{
|
||||
int Indice;
|
||||
int Egal_trouve=0;
|
||||
|
||||
for (Indice=0;String[Indice]!='\0';)
|
||||
{
|
||||
if ((String[Indice]==' ') ||
|
||||
(String[Indice]=='\t'))
|
||||
if ((String[Indice]=='='))
|
||||
{
|
||||
Egal_trouve=1;
|
||||
Indice++;
|
||||
// On enleve les espaces après le '='
|
||||
while (String[Indice]==' ' || String[Indice]=='\t')
|
||||
memmove(String+Indice,String+Indice+1,strlen(String+Indice));
|
||||
}
|
||||
else if ((String[Indice]==' ' && !Egal_trouve) || (String[Indice]=='\t'))
|
||||
{
|
||||
// Suppression d'un espace ou d'un tab:
|
||||
|
||||
memmove(String+Indice,String+Indice+1,strlen(String+Indice));
|
||||
}
|
||||
else
|
||||
@ -48,17 +55,25 @@ void Charger_INI_Clear_string(char * String)
|
||||
(String[Indice]=='\n'))
|
||||
{
|
||||
// Rencontre d'un commentaire ou d'un saut de ligne:
|
||||
|
||||
String[Indice]='\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Passage en majuscule d'un caractère:
|
||||
|
||||
String[Indice]=toupper((int)String[Indice]);
|
||||
if (!Egal_trouve)
|
||||
{
|
||||
// Passage en majuscule d'un caractère:
|
||||
|
||||
String[Indice]=toupper((int)String[Indice]);
|
||||
}
|
||||
Indice++;
|
||||
}
|
||||
}
|
||||
// On enlève les espaces avant la fin de chaine
|
||||
while (Indice>0 && (String[Indice-1]==' ' || String[Indice-1]=='\t'))
|
||||
{
|
||||
Indice--;
|
||||
String[Indice]='\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -173,10 +188,6 @@ int Charger_INI_Get_string(FILE * File,char * Buffer,char * Option,char * Retour
|
||||
Indice_buffer=Charger_INI_Seek_pattern(Buffer_upper,"=");
|
||||
|
||||
strcpy(Retour, Buffer_upper + Indice_buffer);
|
||||
// On coupe la chaine au premier espace ou ; (commentaire)
|
||||
for (Indice_buffer=0; Retour[Indice_buffer]!='\0' && Retour[Indice_buffer]!=' ' && Retour[Indice_buffer]!=';'; Indice_buffer++)
|
||||
;
|
||||
Retour[Indice_buffer]='\0';
|
||||
}
|
||||
}
|
||||
while (!Arret);
|
||||
@ -191,28 +202,28 @@ int Charger_INI_Get_value(char * String,int * Index,int * Value)
|
||||
{
|
||||
// On teste si la valeur actuelle est YES (ou Y):
|
||||
|
||||
if (Charger_INI_Seek_pattern(String+(*Index),"YES,")==1)
|
||||
if (Charger_INI_Seek_pattern(String+(*Index),"yes,")==1)
|
||||
{
|
||||
(*Value)=1;
|
||||
(*Index)+=4;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if (strcmp(String+(*Index),"YES")==0)
|
||||
if (strcmp(String+(*Index),"yes")==0)
|
||||
{
|
||||
(*Value)=1;
|
||||
(*Index)+=3;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if (Charger_INI_Seek_pattern(String+(*Index),"Y,")==1)
|
||||
if (Charger_INI_Seek_pattern(String+(*Index),"y,")==1)
|
||||
{
|
||||
(*Value)=1;
|
||||
(*Index)+=2;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if (strcmp(String+(*Index),"Y")==0)
|
||||
if (strcmp(String+(*Index),"y")==0)
|
||||
{
|
||||
(*Value)=1;
|
||||
(*Index)+=1;
|
||||
@ -222,28 +233,28 @@ int Charger_INI_Get_value(char * String,int * Index,int * Value)
|
||||
|
||||
// On teste si la valeur actuelle est NO (ou N):
|
||||
|
||||
if (Charger_INI_Seek_pattern(String+(*Index),"NO,")==1)
|
||||
if (Charger_INI_Seek_pattern(String+(*Index),"no,")==1)
|
||||
{
|
||||
(*Value)=0;
|
||||
(*Index)+=3;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if (strcmp(String+(*Index),"NO")==0)
|
||||
if (strcmp(String+(*Index),"no")==0)
|
||||
{
|
||||
(*Value)=0;
|
||||
(*Index)+=2;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if (Charger_INI_Seek_pattern(String+(*Index),"N,")==1)
|
||||
if (Charger_INI_Seek_pattern(String+(*Index),"n,")==1)
|
||||
{
|
||||
(*Value)=0;
|
||||
(*Index)+=2;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if (strcmp(String+(*Index),"N")==0)
|
||||
if (strcmp(String+(*Index),"n")==0)
|
||||
{
|
||||
(*Value)=0;
|
||||
(*Index)+=1;
|
||||
@ -391,10 +402,10 @@ int Charger_INI(struct S_Config * Conf)
|
||||
FILE * Fichier;
|
||||
char * Buffer;
|
||||
int Valeurs[3];
|
||||
//int Indice;
|
||||
int Indice;
|
||||
char * Nom_du_fichier;
|
||||
int Retour;
|
||||
char Libelle_resolution[1024];
|
||||
char Libelle_valeur[1024];
|
||||
|
||||
Ligne_INI=0;
|
||||
|
||||
@ -676,9 +687,9 @@ int Charger_INI(struct S_Config * Conf)
|
||||
|
||||
// Optionnel, le mode video par défaut (à partir de beta 97.0%)
|
||||
Conf->Resolution_par_defaut=0;
|
||||
if (!Charger_INI_Get_string (Fichier,Buffer,"Default_video_mode",Libelle_resolution))
|
||||
if (!Charger_INI_Get_string (Fichier,Buffer,"Default_video_mode",Libelle_valeur))
|
||||
{
|
||||
int Mode = Conversion_argument_mode(Libelle_resolution);
|
||||
int Mode = Conversion_argument_mode(Libelle_valeur);
|
||||
if (Mode>=0)
|
||||
Conf->Resolution_par_defaut=Mode;
|
||||
}
|
||||
@ -719,6 +730,41 @@ int Charger_INI(struct S_Config * Conf)
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
Conf->Palette_Cells_Y=Valeurs[0];
|
||||
}
|
||||
// Optionnel, bookmarks (>98.0%)
|
||||
for (Indice=0;Indice<NB_BOOKMARKS;Indice++)
|
||||
{
|
||||
Conf->Bookmark_directory[Indice]=NULL;
|
||||
Conf->Bookmark_label[Indice][0]='\0';
|
||||
}
|
||||
for (Indice=0;Indice<NB_BOOKMARKS;Indice++)
|
||||
{
|
||||
if (!Charger_INI_Get_string (Fichier,Buffer,"Bookmark_label",Libelle_valeur))
|
||||
{
|
||||
int Taille=0;
|
||||
if (Libelle_valeur && (Taille=strlen(Libelle_valeur))!=0)
|
||||
{
|
||||
if (Taille>8)
|
||||
{
|
||||
Libelle_valeur[7]=CARACTERE_SUSPENSION;
|
||||
Libelle_valeur[8]='\0';
|
||||
}
|
||||
strcpy(Conf->Bookmark_label[Indice],Libelle_valeur);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
if (!Charger_INI_Get_string (Fichier,Buffer,"Bookmark_directory",Libelle_valeur))
|
||||
{
|
||||
int Taille=0;
|
||||
if (Libelle_valeur && (Taille=strlen(Libelle_valeur))!=0)
|
||||
{
|
||||
Conf->Bookmark_directory[Indice]=(char *)malloc(Taille+1);
|
||||
strcpy(Conf->Bookmark_directory[Indice],Libelle_valeur);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
fclose(Fichier);
|
||||
|
||||
@ -729,7 +775,7 @@ int Charger_INI(struct S_Config * Conf)
|
||||
// Gestion des erreurs:
|
||||
|
||||
Erreur_Retour:
|
||||
|
||||
printf(Buffer);
|
||||
fclose(Fichier);
|
||||
free(Nom_du_fichier);
|
||||
free(Buffer);
|
||||
|
||||
13
saveini.c
13
saveini.c
@ -244,6 +244,10 @@ int Sauver_INI_Set_strings(FILE * Old_file,FILE * New_file,char * Buffer,char *
|
||||
Buffer_upper=(char *)malloc(1024);
|
||||
Buffer_resultat=(char *)malloc(1024);
|
||||
|
||||
// On convertit un eventuel argument NULL en chaine vide.
|
||||
if (Value == NULL)
|
||||
Value="";
|
||||
|
||||
// On commence par se faire une version majuscule de l'option à rechercher:
|
||||
strcpy(Option_upper,Option);
|
||||
Charger_INI_Clear_string(Option_upper);
|
||||
@ -394,6 +398,7 @@ int Sauver_INI(struct S_Config * Conf)
|
||||
int Retour;
|
||||
char Nom_du_fichier_DAT[TAILLE_CHEMIN_FICHIER];
|
||||
int Ini_existe;
|
||||
int Indice;
|
||||
|
||||
// On alloue les zones de mémoire:
|
||||
Buffer=(char *)malloc(1024);
|
||||
@ -614,6 +619,14 @@ int Sauver_INI(struct S_Config * Conf)
|
||||
Valeurs[0]=(Conf->Palette_Cells_Y);
|
||||
if ((Retour=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Palette_Cells_Y",1,Valeurs,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
for (Indice=0;Indice<NB_BOOKMARKS;Indice++)
|
||||
{
|
||||
if ((Retour=Sauver_INI_Set_strings (Ancien_fichier,Nouveau_fichier,Buffer,"Bookmark_label",Conf->Bookmark_label[Indice])))
|
||||
goto Erreur_Retour;
|
||||
if ((Retour=Sauver_INI_Set_strings (Ancien_fichier,Nouveau_fichier,Buffer,"Bookmark_directory",Conf->Bookmark_directory[Indice])))
|
||||
goto Erreur_Retour;
|
||||
}
|
||||
|
||||
Sauver_INI_Flush(Ancien_fichier,Nouveau_fichier,Buffer);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user