From f26c8fe9f1c745075f6d29675324f7e534221473 Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Fri, 19 Sep 2008 00:24:00 +0000 Subject: [PATCH] Save/Load: Much better filename input, can enter French keys and characters. The text functions now apply a Windows-1252 -> OEM conversion, since the two main fonts are an OEM code page. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@161 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- boutons.c | 2 +- const.h | 6 +-- divers.c | 111 +++++++++++++++++++++++++++++++++++++++++++----------- graph.c | 24 ++++++++++-- main.c | 5 +++ 5 files changed, 120 insertions(+), 28 deletions(-) diff --git a/boutons.c b/boutons.c index a914e7e4..843c61b4 100644 --- a/boutons.c +++ b/boutons.c @@ -133,7 +133,7 @@ void Bouton_Message_initial(void) Print_dans_fenetre( 7,128,"file before using this program",CM_Fonce,CM_Clair); Print_dans_fenetre( 7,136,"for the first time.",CM_Fonce,CM_Clair); - if ((*ALPHA_BETA)=='á') + if ((*ALPHA_BETA)=='ß') { Print_char_transparent_dans_fenetre(43,119,'M',CM_Noir); Print_char_transparent_dans_fenetre(53,121,'U',CM_Noir); diff --git a/const.h b/const.h index 8e9e8b11..e8602e29 100644 --- a/const.h +++ b/const.h @@ -8,12 +8,12 @@ #define M_2PI 6.28318530717958647692528676656 // Note: La taille du fichier GFX2.DAT est définie au début de INIT.C ! -#define POURCENTAGE_VERSION "96.5%" // Libellé du pourcentage de la version á +#define POURCENTAGE_VERSION "96.5%" // Libellé du pourcentage de la version ß #define VERSION1 2 // | #define VERSION2 0 // |_ Numéro de version découpé en -#define BETA1 96 // | plusieurs parties => 2.0 á95.5% +#define BETA1 96 // | plusieurs parties => 2.0 ß95.5% #define BETA2 5 // | -#define ALPHA_BETA "á" // Type de la version "à" ou "á" +#define ALPHA_BETA "ß" // Type de la version "Þ" ou "ß" #define TAILLE_FICHIER_CONFIG 10351 // Taille du fichier GFX2.CFG #define NB_MODES_VIDEO 60 // Nombre de modes vidéo #define NB_BOUTONS 38 // Nombre de boutons à gérer diff --git a/divers.c b/divers.c index e1c06fb4..f1177613 100644 --- a/divers.c +++ b/divers.c @@ -358,12 +358,13 @@ byte Lit_pixel_dans_brosse (word X,word Y) void Clavier_de_depart(void) { - SDL_EnableKeyRepeat(250, 32); + //SDL_EnableUNICODE(SDL_ENABLE); + //SDL_EnableKeyRepeat(250, 32); // TODO … placer … un meilleur endroit } void Clavier_americain(void) { - UNIMPLEMENTED + //SDL_EnableUNICODE(SDL_DISABLE); } word Detection_souris(void) @@ -870,25 +871,93 @@ word Get_key(void) SDL_Event event; Attendre_fin_de_click(); // On prend le controle de la boucle d'évènements, donc il ne faut pas qu'on rate la fin de click ! - - SDL_EnableUNICODE(SDL_ENABLE); // On a besoin du caractère - - while(1) - { - SDL_PollEvent(&event); - if(event.type == SDL_KEYDOWN) - { - // On retourne en mode standard pour la gestion normale - SDL_EnableUNICODE(SDL_DISABLE); - if (event.key.keysym.unicode <= 127 && event.key.keysym.unicode > 31) - return event.key.keysym.unicode; // Pas de souci, on est en ASCII standard - else - { - // Sinon c'est une touche spéciale, on retourne son scancode - return event.key.keysym.sym; - } - } - } + Clavier_de_depart(); + while(1) + { + SDL_WaitEvent(&event); + if(event.type == SDL_KEYDOWN) + { + if ( event.key.keysym.unicode == 0) + { + return event.key.keysym.sym; + } + if ( event.key.keysym.unicode < 127) + { + //printf("ascii %x, %d %s\n",event.key.keysym.unicode, event.key.keysym.sym ,SDL_GetKeyName(event.key.keysym.sym) ); + return event.key.keysym.unicode; // Pas de souci, on est en ASCII standard + } + + // Quelques conversions Unicode-ANSI + switch(event.key.keysym.unicode) + { + case 0x8100: + return 'ü'; // ü + case 0x1A20: + return 'é'; // é + case 0x201A: + return 'è'; // è + case 0x9201: + return 'â'; // â + case 0x1E20: + return 'ä'; // ä + case 0x2620: + return 'à'; // à + case 0x2020: + return 'å'; // å + case 0x2120: + return 'ç'; // ç + case 0xC602: + return 'ê'; // ê + case 0x3020: + return 'ë'; // ë + case 0x6001: + return 'è'; // è + case 0x3920: + return 'ï'; // ï + case 0x5201: + return 'î'; // î + case 0x8D00: + return 'ì'; // ì + case 0x1C20: + return 'ô'; // ô + case 0x1D20: + return 'ö'; // ö + case 0x2220: + return 'ò'; // ò + case 0x1320: + return 'û'; // û + case 0x1420: + return 'ù'; // ù + case 0xDC02: + return 'ÿ'; // ÿ + case 0x5301: + return '£'; // £ + case 0xA000: + return 'á'; // á + case 0xA100: + return 'í'; // í + case 0xA200: + return 'ó'; // ó + case 0xA300: + return 'ú'; // ú + case 0xA400: + return 'ñ'; // ñ + case 0xA700: + return 'º'; // º + case 0xC600: + return 'ã'; // ã + } + // Touche entre 127 et 255 + if (event.key.keysym.unicode<256) + { + //printf("ascii etendu %x, %d %s\n",event.key.keysym.unicode, event.key.keysym.sym ,SDL_GetKeyName(event.key.keysym.sym) ); + return event.key.keysym.unicode; + } + // Sinon c'est une touche spéciale, on retourne son scancode + //printf("non ascii %x, %d %s\n",event.key.keysym.unicode, event.key.keysym.sym ,SDL_GetKeyName(event.key.keysym.sym) ); + return event.key.keysym.sym; + } + } } void Zoomer_une_ligne(byte* Ligne_originale, byte* Ligne_zoomee, diff --git a/graph.c b/graph.c index d4ccaf5e..f38620b5 100644 --- a/graph.c +++ b/graph.c @@ -1333,6 +1333,24 @@ void Afficher_menu(void) } } +// Table de conversion ANSI->OEM +// Les deux fontes générales sont en encodage OEM +unsigned char Caractere_OEM[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, + 63, 63, 39, 159, 34, 46, 197, 206, 94, 37, 83, 60, 79, 63, 90, 63, + 63, 39, 39, 34, 34, 7, 45, 45, 126, 84, 115, 62, 111, 63, 122, 89, + 255, 173, 189, 156, 207, 190, 221, 245, 249, 184, 166, 174, 170, 240, 169, 238, + 248, 241, 253, 252, 239, 230, 244, 250, 247, 251, 167, 175, 172, 171, 243, 168, + 183, 181, 182, 199, 142, 143, 146, 128, 212, 144, 210, 211, 222, 214, 215, 216, + 209, 165, 227, 224, 226, 229, 153, 158, 157, 235, 233, 234, 154, 237, 232, 225, + 133, 160, 131, 198, 132, 134, 145, 135, 138, 130, 136, 137, 141, 161, 140, 139, + 208, 164, 149, 162, 147, 228, 148, 246, 155, 151, 163, 150, 129, 236, 231}; // -- Affichage de texte ----------------------------------------------------- @@ -1360,7 +1378,7 @@ void Print_general(short X,short Y,char * Chaine,byte Couleur_texte,byte Couleur Caractere=Chaine[Indice]; for (Pos_X=0;Pos_X<8;Pos_X++) for (Repeat_Menu_Facteur_X=0;Repeat_Menu_Facteur_X