diff --git a/aide.c b/aide.c index 36e5e7e2..5de66893 100644 --- a/aide.c +++ b/aide.c @@ -417,6 +417,7 @@ void Bouton_Stats(void) } #else // Free disk space is only for shows. Other platforms can display 0. + #warning "Missing code for your platform !!! Check and correct please :)" Taille=0; #endif diff --git a/boutons.c b/boutons.c index f48abeb5..691e2b62 100644 --- a/boutons.c +++ b/boutons.c @@ -1670,6 +1670,7 @@ void Bouton_Dessin(void) void Bouton_Dessin_Switch_mode(void) { +/* ANCIEN CODE SANS POPUPS */ Mode_de_dessin_en_cours++; if (Mode_de_dessin_en_cours>OPERATION_DESSIN_POINT) Mode_de_dessin_en_cours=OPERATION_DESSIN_CONTINU; @@ -1678,6 +1679,35 @@ void Bouton_Dessin_Switch_mode(void) Afficher_sprite_dans_menu(BOUTON_DESSIN,Mode_de_dessin_en_cours); Demarrer_pile_operation(Mode_de_dessin_en_cours); Afficher_curseur(); +/* NOUVEAU CODE AVEC POPUP (EN COURS DE TEST) *** + short Bouton_clicke; + Ouvrir_popup(16,Menu_Ordonnee/Menu_Facteur_X-32,18,50); + Fenetre_Definir_bouton_normal(1,1,16,16,"A",0,1,SDLK_ESCAPE); // 1 + Afficher_curseur(); + + UpdateRect(16*Menu_Facteur_X,Menu_Ordonnee-32*Menu_Facteur_X,18*Menu_Facteur_X,50*Menu_Facteur_X); + + do + { + while(!Get_input())Wait_VBL(); + Bouton_clicke = Fenetre_Numero_bouton_clicke(); + + switch(Bouton_clicke) + { + case 1: + Mode_de_dessin_en_cours++; + if (Mode_de_dessin_en_cours>OPERATION_DESSIN_POINT) + Mode_de_dessin_en_cours=OPERATION_DESSIN_CONTINU; + break; + } + } + while (Mouse_K); + + Fermer_popup(); + Afficher_sprite_dans_menu(BOUTON_DESSIN,Mode_de_dessin_en_cours); + Demarrer_pile_operation(Mode_de_dessin_en_cours); + Afficher_curseur(); +*/ } @@ -3024,6 +3054,7 @@ byte Bouton_Load_ou_Save(byte Load, byte Image) // On restaure les données de l'image qui ont certainement été modifiées // par la preview. memcpy(Principal_Palette,Palette_initiale,sizeof(T_Palette)); + Set_palette(Principal_Palette); Back_color=Back_color_initiale; Principal_Image_modifiee=Image_modifiee_initiale; Principal_Largeur_image=Largeur_image_initiale; diff --git a/divers.c b/divers.c index 9e7c196e..5f59d9fc 100644 --- a/divers.c +++ b/divers.c @@ -1127,17 +1127,14 @@ void Zoomer_une_ligne(byte* Ligne_originale, byte* Ligne_zoomee, // Indique quelle est la mémoire disponible unsigned long Memoire_libre(void) { - // On appelle la fonction qui optimise la mémoire libre afin d'en - // regagner un maximum. Sinon, tous les "free" libèrent une mémoire qui - // n'est pas prise en compte par la fonction, et on se retrouve avec un - // manque alarmant de mémoire. - /* - A revoir, mais est-ce vraiment utile? - _heapmin(); - */ // Memory is no longer relevant. If there is ANY problem or doubt here, // you can simply return 10*1024*1024 (10Mb), to make the "Pages"something // memory allocation functions happy. + + // However, it is still a good idea to make a proper function if you can... + // If Grafx2 thinks the memory is full, weird things may happen. And if memory + // ever becomes full and you're still saying there are 10MB free here, the + // program will crash without saving any picture backup ! You've been warned... #if defined(__WIN32__) MEMORYSTATUSEX mstt; mstt.dwLength = sizeof(MEMORYSTATUSEX); @@ -1156,6 +1153,7 @@ unsigned long Memoire_libre(void) #elif defined(__BEOS__) || defined(__HAIKU__) || defined(__SKYOS__) || defined(__amigaos4__) // No on BeOS or Haiku // AvailMem is misleading on os4 (os4 caches stuff in memory that you can still allocate) + #warning "There is missing code there for your platform ! please check and correct :)" return 10*1024*1024; #elif defined(__AROS__) || defined(__MORPHOS__) return AvailMem(MEMF_ANY); diff --git a/files.c b/files.c index d926b835..062b8efc 100644 --- a/files.c +++ b/files.c @@ -315,13 +315,16 @@ void Lire_liste_des_lecteurs(void) } // Other platforms: simply read the "static" list of Drives. + // This should be made dynamic because in the multitask world, user can mount new drives, + // connect to network ones, and so on, while Grafx2 is running. #else - for (Indice=0; Indice0) + { Erreur(0); + } if (Image_24b) { diff --git a/main.c b/main.c index 1949eefb..62e34801 100644 --- a/main.c +++ b/main.c @@ -84,13 +84,12 @@ void Erreur_fonction(int Code, const char *Nom_fichier, int Numero_ligne, const { T_Palette Palette_temporaire; int Indice; - printf("Code %d\n", Code); - printf("File %s\n", Nom_fichier); - printf("Line %d\n", Numero_ligne); - printf("Function %s\n", Nom_fonction); + printf("Error number %d occured in file %s, line %d, function %s.\n", Code, Nom_fichier,Numero_ligne,Nom_fonction); if (Code==0) { + // L'erreur 0 n'est pas une vraie erreur, elle fait seulement un flash rouge de l'écran pour dire qu'il y a un problème. + // Toutes les autres erreurs déclenchent toujours une sortie en catastrophe du programme ! memcpy(Palette_temporaire,Principal_Palette,sizeof(T_Palette)); for (Indice=0;Indice<=255;Indice++) Palette_temporaire[Indice].R=255; @@ -119,11 +118,7 @@ void Erreur_fonction(int Code, const char *Nom_fichier, int Numero_ligne, const printf("Please run GFXCFG to update this file.\n"); break; case ERREUR_MEMOIRE : printf("Error: Not enough memory!\n\n"); - printf("You should try removing memory drivers and useless TSRs to free some memory.\n\n"); - printf("If it still doesn't work, try running GFX2_MEM.BAT if you have got DOS4GW.EXE\n"); - printf("somewhere on your disk (after having edited the batch file).\n"); - printf("This also requires 16 free Megabytes on your disk to create the memory cache.\n"); - printf("This will slow down the program but, at least, you'll get GrafX2 running.\n"); + printf("You should try exiting other programs to free some bytes for Grafx2.\n\n"); break; case ERREUR_DRIVER_SOURIS : printf("Error: No mouse detected!\n"); printf("Check if a mouse driver is installed and if your mouse is correctly connected.\n"); @@ -144,7 +139,7 @@ void Erreur_fonction(int Code, const char *Nom_fichier, int Numero_ligne, const break; case ERREUR_INI_CORROMPU : printf("Error: File GFX2.INI is corrupt!\n"); printf("It contains bad values at line %d.\n",Ligne_INI); - printf("You can re-generate it by deleting the file and running grafX2 again.\n"); + printf("You can re-generate it by deleting the file and running GrafX2 again.\n"); break; case ERREUR_SAUVEGARDE_INI : printf("Error: Cannot rewrite file GFX2.INI!\n"); break; diff --git a/moteur.c b/moteur.c index 78fa33f3..4b0a1f59 100644 --- a/moteur.c +++ b/moteur.c @@ -56,7 +56,7 @@ byte Smooth_Mode_avant_annulation; byte Tiling_Mode_avant_annulation; fonction_effet Fonction_effet_avant_annulation; -byte * Fond_fenetre[8]; +byte* Fond_fenetre[8]; void Annuler_les_effets(void) { @@ -145,6 +145,7 @@ char * TITRE_BOUTON[NB_BOUTONS]= void Sauve_fond(byte **Buffer, int Pos_X, int Pos_Y, int Largeur, int Hauteur) { int Indice; + if(*Buffer != NULL) DEBUG("WARNING : Buffer already allocated !!!",0); *Buffer=(byte *) malloc(Largeur*Menu_Facteur_X*Hauteur*Menu_Facteur_Y*Pixel_width); for (Indice=0; Indice<(Hauteur*Menu_Facteur_Y); Indice++) Lire_ligne(Pos_X,Pos_Y+Indice,Largeur*Menu_Facteur_X,(*Buffer)+((int)Indice*Largeur*Menu_Facteur_X*Pixel_width)); @@ -1109,6 +1110,7 @@ void Fermer_fenetre(void) else { free(Fond_fenetre[Fenetre-1]); + Fond_fenetre[Fenetre-1]=NULL; Fenetre--; Cacher_pinceau=Cacher_pinceau_avant_fenetre; @@ -1444,6 +1446,127 @@ void Fenetre_Definir_bouton_saisie(word Pos_X,word Pos_Y,word Largeur_en_caracte +//----------------------- Ouverture d'un pop-up ----------------------- + +void Ouvrir_popup(word Pos_X, word Pos_Y, word Largeur,word Hauteur) +// Lors de l'appel à cette procédure, la souris doit être affichée. +// En sortie de cette procedure, la souris est effacée. + +// Note : les pop-ups sont gérés comme s'ils étaient des sous-fenêtres, ils ont donc leur propre boucle d'évènements et tout, on peut ajouter des widgets dedans, ... +// Les différences sont surtout graphiques : + // -Possibilité de préciser la position XY + // -Pas de titre + // -Pas de cadre en relief mais seulement un plat, et il est blanc au lieu de noir. +{ + Effacer_curseur(); + + Fenetre++; + + Fenetre_Largeur=Largeur; + Fenetre_Hauteur=Hauteur; + Fenetre_Pos_X=Pos_X*Menu_Facteur_X; + Fenetre_Pos_Y=Pos_Y*Menu_Facteur_X; + + // Sauvegarde de ce que la fenêtre remplace + Sauve_fond(&(Fond_fenetre[Fenetre-1]), Fenetre_Pos_X, Fenetre_Pos_Y, Largeur*Menu_Facteur_X, Hauteur*Menu_Facteur_X); + + // Fenêtre grise + Block(Fenetre_Pos_X+(Menu_Facteur_X),Fenetre_Pos_Y+(Menu_Facteur_Y),(Largeur-2)*Menu_Facteur_X,(Hauteur-2)*Menu_Facteur_Y,CM_Clair); + + // Cadre noir puis en relief + Fenetre_Afficher_cadre_mono(0,0,Largeur,Hauteur,CM_Blanc); + + if (Fenetre == 1) + { + Menu_visible_avant_fenetre=Menu_visible; + Menu_visible=0; + Menu_Ordonnee_avant_fenetre=Menu_Ordonnee; + Menu_Ordonnee=Hauteur_ecran; + Forme_curseur_avant_fenetre=Forme_curseur; + Forme_curseur=FORME_CURSEUR_FLECHE; + Cacher_pinceau_avant_fenetre=Cacher_pinceau; + Cacher_pinceau=1; + } + + // Initialisation des listes de boutons de la fenêtre + Fenetre_Liste_boutons_normal =NULL; + Fenetre_Liste_boutons_palette =NULL; + Fenetre_Liste_boutons_scroller=NULL; + Fenetre_Liste_boutons_special =NULL; + Nb_boutons_fenetre =0; + +} + +//----------------------- Fermer une fenêtre d'options ----------------------- + +void Fermer_popup(void) +// Lors de l'appel à cette procedure, la souris doit être affichée. +// En sortie de cette procedure, la souris est effacée. +{ + struct Fenetre_Bouton_normal * Temp1; + struct Fenetre_Bouton_palette * Temp2; + struct Fenetre_Bouton_scroller * Temp3; + struct Fenetre_Bouton_special * Temp4; + + Effacer_curseur(); + + while (Fenetre_Liste_boutons_normal) + { + Temp1=Fenetre_Liste_boutons_normal->Next; + free(Fenetre_Liste_boutons_normal); + Fenetre_Liste_boutons_normal=Temp1; + } + while (Fenetre_Liste_boutons_palette) + { + Temp2=Fenetre_Liste_boutons_palette->Next; + free(Fenetre_Liste_boutons_palette); + Fenetre_Liste_boutons_palette=Temp2; + } + while (Fenetre_Liste_boutons_scroller) + { + Temp3=Fenetre_Liste_boutons_scroller->Next; + free(Fenetre_Liste_boutons_scroller); + Fenetre_Liste_boutons_scroller=Temp3; + } + while (Fenetre_Liste_boutons_special) + { + Temp4=Fenetre_Liste_boutons_special->Next; + free(Fenetre_Liste_boutons_special); + Fenetre_Liste_boutons_special=Temp4; + } + + if (Fenetre != 1) + { + // Restore de ce que la fenêtre cachait + Restaure_fond(Fond_fenetre[Fenetre-1], Fenetre_Pos_X, Fenetre_Pos_Y, Fenetre_Largeur, Fenetre_Hauteur); + UpdateRect(Fenetre_Pos_X,Fenetre_Pos_Y,Fenetre_Largeur*Menu_Facteur_X,Fenetre_Hauteur*Menu_Facteur_Y); + Fenetre--; + } + else + { + free(Fond_fenetre[Fenetre-1]); + Fenetre--; + + Cacher_pinceau=Cacher_pinceau_avant_fenetre; + + Calculer_coordonnees_pinceau(); + + Menu_Ordonnee=Menu_Ordonnee_avant_fenetre; + Menu_visible=Menu_visible_avant_fenetre; + Forme_curseur=Forme_curseur_avant_fenetre; + + Afficher_ecran(); + Afficher_menu(); + } + + Touche=0; + Mouse_K=0; + + Old_MX = -1; + Old_MY = -1; + + +} ////////////////////////////////////////////////////////////////////////////// // // // Mini-MOTEUR utilisé dans les fenêtres (menus des boutons...) // diff --git a/pages.c b/pages.c index d0c3aa4b..b1eb3363 100644 --- a/pages.c +++ b/pages.c @@ -545,6 +545,8 @@ void Creer_nouvelle_page(S_Page * Nouvelle_page,S_Liste_de_pages * Liste_courant } else { + // Bon, alors là, on vient de vider toutes les pages et on a toujours pas asez de mémoire... C'est donc qu'un vilain programmeur a oublié de vérifier avec Noiuvelle_page_possible avant de venir ici. + // On sort méchament du programme sans sauvegarde ni rien. De toutes façons, ça ne devrait jamais se produire... Erreur(ERREUR_SORRY_SORRY_SORRY); } } diff --git a/setup.c b/setup.c index fe9b8812..5e1f1d24 100644 --- a/setup.c +++ b/setup.c @@ -57,6 +57,7 @@ int Create_ConfigDirectory(char * Config_Dir) // Determine which directory contains the executable. // IN: Main's argv[0], some platforms need it, some don't. // OUT: Write into Program_Dir. Trailing / or \ is kept. +// Note : in fact this is only used to check for the datafiles and fonts in this same directory. void Set_Program_Directory(ARG_UNUSED const char * argv0,char * Program_Dir) { #undef ARG_UNUSED