//C #include //POSIX #include //SDL #include #include #include //mine #include "SFont.h" /*** Constants ***/ #define NB_MAX_OPTIONS 134 /*** Types definitions and structs ***/ typedef struct{ uint16_t Numero; uint16_t Touche; uint16_t Touche2; char Libelle[36]; char Explic1[77]; char Explic2[77]; bool Erreur; bool Suppr; } Options; typedef struct{ char Signature[3]; uint8_t Version1; uint8_t Version2; uint8_t Beta1; uint8_t Beta2; } Type_header; #define Header_size 7 typedef struct{ uint8_t Numero; uint16_t Taille; } Type_chunk; #define Chunk_size 3 /*** Global variables ***/ SFont_Font* MyFont; SDL_Surface* Ecran; int Numero_definition_option; Options Config[NB_MAX_OPTIONS]; bool Choix_enreg; uint16_t NB_OPTIONS; /*** Fonctions de gestion des évènements SDL ***/ /* Attend qu'une touche soit pressée. Retourne le keysym. */ SDL_keysym Lire_Touche(void) { SDL_Event Event; do{ SDL_WaitEvent(&Event); if(Event.type==SDL_KEYDOWN) break; }while(1); return Event.key.keysym; } /*** Drawing functions ***/ /* Draws a filled rectanble */ void Cadre(int x,int y,int w,int h,uint8_t color) { SDL_Rect rct; rct.x=x; rct.y=y; rct.w=w; rct.h=h; SDL_FillRect(Ecran, &rct, color); } /* Draws the main screen and welcome message */ void Dessiner_ecran_principal() { Cadre(3,3,630,40,2); SFont_Write(Ecran, MyFont, 8,6,"Setup program for Grafx2 (c) 1996-98 Sunset Design and 2008 PulkoMandy"); SFont_Write(Ecran, MyFont, 8,18,"Use Up/Down arrows & Page-Up/Page-Down to scroll, Enter to modify, Delete to remove a hot-key, and Escape to validate or cancel."); SFont_Write(Ecran, MyFont, 8,30,"DO NOT USE Print-screen, Pause, and other special keys!"); Cadre(3,46,630,400,1); SDL_UpdateRect(Ecran,0,0,640,480); } void Tout_ecrire(uint16_t Decalage_curseur,uint16_t Position_curseur) { puts("TOUT ECRIRE UNIMPLEMENTED"); } /*** Configuration handling functions ***/ /* Defines an option */ void Definir_option(uint16_t Numero, char* Libelle, char* Explic1, char* Explic2, bool Deletable, uint16_t Default_key) { Config[Numero_definition_option].Numero = Numero; Config[Numero_definition_option].Touche = Default_key; Config[Numero_definition_option].Touche2 = 0xFF; strncpy(Config[Numero_definition_option].Libelle,Libelle,36); strncpy(Config[Numero_definition_option].Explic1,Explic1,77); strncpy(Config[Numero_definition_option].Explic2,Explic2,77); Config[Numero_definition_option].Erreur = false; Config[Numero_definition_option].Suppr = Deletable; Numero_definition_option ++ ; } /* Initialize configuration */ bool Initialiser_config() { bool Erreur = false; FILE* Fichier_INI; Numero_definition_option = 0; Definir_option(0,"Scroll up", "Scrolls the picture upwards, both in magnify and normal mode.", "This hotkey cannot be removed.", false, 0x48); // HAUT Definir_option(1,"Scroll down", "Scrolls the picture upwards, both in magnify and normal mode.", "This hotkey cannot be removed.", false, 0x48); // HAUT Definir_option(2,"Scroll left", "Scrolls the picture upwards, both in magnify and normal mode.", "This hotkey cannot be removed.", false, 0x48); // HAUT Definir_option(3,"Scroll right", "Scrolls the picture upwards, both in magnify and normal mode.", "This hotkey cannot be removed.", false, 0x48); // HAUT } uint8_t Fenetre_choix(uint8_t Largeur, uint8_t Hauteur, char* Titre, char* Choix, uint8_t Choix_debut, uint8_t Couleur,uint8_t Couleur_choix) { puts("FENETRE CHOIX UNIMPLEMENTED !!!"); return 0; } void Test_duplic() { puts("TEST DUPLIC UNIMPLEMENTED"); } /* Checks if everything is OK */ bool Validation() { bool Y_a_des_erreurs = false; uint16_t i = 0; while(i