Some more work on the config tool
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@127 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
a8d54ab31f
commit
683364bc10
140
cfg_new/gfxcfg.c
140
cfg_new/gfxcfg.c
@ -12,8 +12,16 @@
|
||||
//mine
|
||||
#include "SFont.h"
|
||||
|
||||
#include "scancodes.h"
|
||||
|
||||
/*** Constants ***/
|
||||
#define NB_MAX_OPTIONS 134
|
||||
#define HAUTEUR_DEBUT_SETUP 7
|
||||
#define HAUTEUR_FIN_SETUP 44
|
||||
|
||||
/* Colors */
|
||||
#define COULEUR_SETUP 1
|
||||
#define COULEUR_SELECT 8
|
||||
|
||||
/*** Types definitions and structs ***/
|
||||
|
||||
@ -68,6 +76,55 @@ SDL_keysym Lire_Touche(void)
|
||||
return Event.key.keysym;
|
||||
}
|
||||
|
||||
/* Writes human-readable key name to buffer Temp. Temp must be at least 35 bytes long ! */
|
||||
void Nom_touche(uint16_t Touche,char* Temp)
|
||||
{
|
||||
char Temp2[28];
|
||||
uint8_t Num_table =1;
|
||||
|
||||
Temp[0] = Temp2[0] = 0;
|
||||
|
||||
if((Touche & 0x0100) > 0)
|
||||
{
|
||||
strcat(Temp,"<Shift> + ");
|
||||
Num_table = 2;
|
||||
}
|
||||
|
||||
if((Touche & 0x0200) > 0)
|
||||
{
|
||||
strcat(Temp,"<Ctrl> + ");
|
||||
Num_table = 3;
|
||||
}
|
||||
|
||||
if((Touche & 0x0400) > 0)
|
||||
{
|
||||
strcat(Temp,"<Alt> + ");
|
||||
Num_table = 4;
|
||||
}
|
||||
|
||||
switch(Num_table)
|
||||
{
|
||||
case 1:
|
||||
strcpy(Temp2,Table_Normal[Touche & 0xFF]);
|
||||
printf("k: %x\n",Touche & 0xFF);
|
||||
if (strcmp(Temp2,"???") == 0)
|
||||
strcpy(Temp,"********** Invalid key! **********");
|
||||
else if (Temp2[0]==0)
|
||||
Temp[0]=0;
|
||||
else
|
||||
{
|
||||
strcat(Temp,"<");
|
||||
strcat(Temp,Temp2);
|
||||
strcat(Temp,">");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
strcpy(Temp2,Table_Shift[Touche & 0xFF]);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*** Drawing functions ***/
|
||||
|
||||
/* Draws a filled rectanble */
|
||||
@ -90,15 +147,54 @@ void Dessiner_ecran_principal()
|
||||
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);
|
||||
Cadre(3,46,630,400,COULEUR_SETUP);
|
||||
SFont_Write(Ecran,MyFont,8,48,"Option");
|
||||
SFont_Write(Ecran,MyFont,8*38,48,"Hot-Key");
|
||||
SFont_Write(Ecran,MyFont,8*75,48,"Err");
|
||||
|
||||
SDL_UpdateRect(Ecran,0,0,640,480);
|
||||
|
||||
}
|
||||
|
||||
/* Displays informations about an option */
|
||||
void Ecrire(uint8_t Ligne, uint16_t Num_option, uint8_t Couleur)
|
||||
{
|
||||
char NomTouche[35];
|
||||
puts(Config[Num_option].Libelle);
|
||||
SFont_Write(Ecran,MyFont,8,Ligne*9,Config[Num_option].Libelle);
|
||||
Nom_touche(Config[Num_option].Touche,NomTouche);
|
||||
SFont_Write(Ecran,MyFont,40*8,Ligne*9,NomTouche);
|
||||
if(Config[Num_option].Erreur)
|
||||
SFont_Write(Ecran,MyFont,77*8,Ligne*9,"X");
|
||||
else
|
||||
Cadre(77*8,Ligne*9,8,8,Couleur);
|
||||
}
|
||||
|
||||
/* Displays comment about an option */
|
||||
void Ecrire_commentaire(uint16_t Num_option)
|
||||
{
|
||||
SFont_Write(Ecran,MyFont,8,50*9,Config[Num_option].Explic1);
|
||||
SFont_Write(Ecran,MyFont,8,51*9,Config[Num_option].Explic2);
|
||||
}
|
||||
|
||||
/* Display the options list */
|
||||
void Tout_ecrire(uint16_t Decalage_curseur,uint16_t Position_curseur)
|
||||
{
|
||||
puts("TOUT ECRIRE UNIMPLEMENTED");
|
||||
uint8_t i = HAUTEUR_DEBUT_SETUP;
|
||||
|
||||
Cadre(3,(HAUTEUR_DEBUT_SETUP+Position_curseur - 1)*9,630,8,COULEUR_SELECT);
|
||||
|
||||
while(i<=HAUTEUR_FIN_SETUP && i <= NB_OPTIONS + HAUTEUR_DEBUT_SETUP)
|
||||
{
|
||||
Ecrire(i,Decalage_curseur+i-HAUTEUR_DEBUT_SETUP,COULEUR_SETUP);
|
||||
i++;
|
||||
}
|
||||
|
||||
Cadre(36*8,46,1,400,255);
|
||||
Cadre(78*8,46,1,400,255);
|
||||
|
||||
Ecrire_commentaire(Decalage_curseur+Position_curseur-1);
|
||||
SDL_UpdateRect(Ecran,0,0,640,480);
|
||||
}
|
||||
|
||||
/*** Configuration handling functions ***/
|
||||
@ -127,21 +223,24 @@ bool Initialiser_config()
|
||||
Numero_definition_option = 0;
|
||||
|
||||
Definir_option(0,"Scroll up",
|
||||
"Scrolls the picture upwards, both in magnify and normal mode.",
|
||||
"Scrolls the picture up, 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.",
|
||||
"Scrolls the picture down, both in magnify and normal mode.",
|
||||
"This hotkey cannot be removed.",
|
||||
false, 0x48); // HAUT
|
||||
false, 0x50); // BAS
|
||||
Definir_option(2,"Scroll left",
|
||||
"Scrolls the picture upwards, both in magnify and normal mode.",
|
||||
"Scrolls the picture to the left, both in magnify and normal mode.",
|
||||
"This hotkey cannot be removed.",
|
||||
false, 0x48); // HAUT
|
||||
false, 0x4B); // GAUCHE
|
||||
Definir_option(3,"Scroll right",
|
||||
"Scrolls the picture upwards, both in magnify and normal mode.",
|
||||
"Scrolls the picture to the right, both in magnify and normal mode.",
|
||||
"This hotkey cannot be removed.",
|
||||
false, 0x48); // HAUT
|
||||
false, 0x4D); // DROITE
|
||||
|
||||
|
||||
NB_OPTIONS = Numero_definition_option - 1;
|
||||
}
|
||||
|
||||
uint8_t Fenetre_choix(uint8_t Largeur, uint8_t Hauteur, char* Titre, char* Choix, uint8_t Choix_debut,
|
||||
@ -151,9 +250,30 @@ uint8_t Fenetre_choix(uint8_t Largeur, uint8_t Hauteur, char* Titre, char* Choix
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Checks if some key is used twice */
|
||||
void Test_duplic()
|
||||
{
|
||||
puts("TEST DUPLIC UNIMPLEMENTED");
|
||||
uint16_t i,j;
|
||||
bool Pas_encore_erreur;
|
||||
|
||||
for(i=0;i<NB_OPTIONS;i++)
|
||||
{
|
||||
if(Config[i].Touche!=0xFF)
|
||||
{
|
||||
j=1;
|
||||
Pas_encore_erreur=true;
|
||||
while(j<NB_OPTIONS && Pas_encore_erreur)
|
||||
{
|
||||
if(i!=j && Config[i].Touche==Config[j].Touche)
|
||||
{
|
||||
Pas_encore_erreur = false;
|
||||
Config[i].Erreur = true;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if (Pas_encore_erreur) Config[i].Erreur = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Checks if everything is OK */
|
||||
|
||||
1040
cfg_new/scancodes.h
Normal file
1040
cfg_new/scancodes.h
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user