Default config is set when gfx2.cfg is missing or corrupt

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@231 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2008-10-12 01:23:13 +00:00
parent f4ec27a25f
commit f293fd4694
6 changed files with 173 additions and 780 deletions

View File

@ -62,12 +62,12 @@ release : $(BIN) $(CFGBIN)
# A raw source archive
zip :
tar cvzf gfx2-src.tgz *.c *.h Makefile Makefile.dep gfx2.dat gfx2.ini gfx2.cfg doc/gpl-2.0.txt \
tar cvzf gfx2-src.tgz *.c *.h Makefile Makefile.dep gfx2.dat gfx2.ini doc/gpl-2.0.txt \
8pxfont.png
# A release zip archive
ziprelease:
zip grafx2-beta-svn`svnversion`.zip $(BIN) $(CFGBIN) gfx2.dat gfx2.ico doc/gpl-2.0.txt SDL.dll gfx2.cfg
zip grafx2-beta-svn`svnversion`.zip $(BIN) $(CFGBIN) gfx2.dat gfx2.ico doc/gpl-2.0.txt SDL.dll
$(BIN) : $(OBJ)
$(CC) $(OBJ) -o $(BIN) $(LOPT)

View File

@ -2,7 +2,7 @@ main.o: main.c const.h struct.h global.h loadsave.h graph.h divers.h \
init.h boutons.h moteur.h pages.h files.h sdlscreen.h erreurs.h \
readini.h saveini.h linux.h io.h
init.o: init.c const.h struct.h global.h loadsave.h graph.h boutons.h \
palette.h aide.h operatio.h divers.h erreurs.h clavier.h io.h
palette.h aide.h operatio.h divers.h erreurs.h clavier.h io.h hotkeys.h
graph.o: graph.c sdlscreen.h struct.h const.h graph.h divers.h moteur.h \
boutons.h pages.h global.h loadsave.h erreurs.h
sdlscreen.o: sdlscreen.c global.h struct.h const.h loadsave.h sdlscreen.h \
@ -40,5 +40,7 @@ shade.o: shade.c global.h struct.h const.h loadsave.h graph.h moteur.h \
divers.h readline.h
clavier.o: clavier.c global.h struct.h const.h loadsave.h
io.o: io.c struct.h const.h io.h
gfxcfg.o: gfxcfg.c SFont.h struct.h const.h clavier.h io.h
gfxcfg.o: gfxcfg.c SFont.h struct.h const.h clavier.h io.h hotkeys.h
SFont.o: SFont.c SFont.h
clavier.o: clavier.c global.h struct.h const.h loadsave.h
io.o: io.c struct.h const.h io.h

694
gfxcfg.c
View File

@ -45,10 +45,11 @@
#include "clavier.h"
#include "const.h"
#include "io.h"
#include "hotkeys.h"
/*** Constants ***/
#define NB_MAX_OPTIONS 134
#define NB_MAX_TOUCHES 134
#define HAUTEUR_DEBUT_SETUP 7
#define HAUTEUR_FIN_SETUP 44
#define Header_size sizeof(struct Config_Header)
@ -58,26 +59,15 @@
#define COULEUR_SETUP 1
#define COULEUR_SELECT 8
/*** 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;
} __attribute__((__packed__)) Options;
/*** Global variables ***/
SFont_Font* MyFont;
SDL_Surface* Ecran;
int Numero_definition_option;
Options Config[NB_MAX_OPTIONS];
bool Erreur[NB_MAX_TOUCHES];
uint8_t Choix_enreg;
uint16_t NB_OPTIONS;
uint16_t Decalage_curseur=0;
uint16_t Position_curseur=0;
@ -141,9 +131,9 @@ void Dessiner_ecran_principal()
void Ecrire(uint8_t Ligne, uint16_t Num_option, uint8_t Couleur)
{
Cadre(3,Ligne*9,630,9,Couleur);
SFont_Write(Ecran,MyFont,8,Ligne*9,Config[Num_option].Libelle);
SFont_Write(Ecran,MyFont,40*8,Ligne*9,Nom_touche(Config[Num_option].Touche));
if(Config[Num_option].Erreur)
SFont_Write(Ecran,MyFont,8,Ligne*9,ConfigTouche[Num_option].Libelle);
SFont_Write(Ecran,MyFont,40*8,Ligne*9,Nom_touche(ConfigTouche[Num_option].Touche));
if(Erreur[Num_option])
SFont_Write(Ecran,MyFont,77*8,Ligne*9,"X");
Cadre(36*8,Ligne*9,1,9,255);
Cadre(74*8,Ligne*9,1,9,255);
@ -154,8 +144,8 @@ void Ecrire(uint8_t Ligne, uint16_t Num_option, uint8_t Couleur)
void Ecrire_commentaire(uint16_t Num_option)
{
Cadre(8,50*9,630,18,0);
SFont_Write(Ecran,MyFont,8,50*9,Config[Num_option].Explic1);
SFont_Write(Ecran,MyFont,8,51*9,Config[Num_option].Explic2);
SFont_Write(Ecran,MyFont,8,50*9,ConfigTouche[Num_option].Explic1);
SFont_Write(Ecran,MyFont,8,51*9,ConfigTouche[Num_option].Explic2);
SDL_UpdateRect(Ecran,8,50*9,631,19);
}
@ -165,7 +155,7 @@ void Tout_ecrire()
uint8_t i = HAUTEUR_DEBUT_SETUP;
Cadre(3,46,630,400,COULEUR_SETUP);
while(i<=HAUTEUR_FIN_SETUP && i <= NB_OPTIONS + HAUTEUR_DEBUT_SETUP)
while(i<=HAUTEUR_FIN_SETUP && i < NB_MAX_TOUCHES + HAUTEUR_DEBUT_SETUP)
{
Ecrire(i,Decalage_curseur+i-HAUTEUR_DEBUT_SETUP,
(i==HAUTEUR_DEBUT_SETUP+Position_curseur)?COULEUR_SELECT:COULEUR_SETUP);
@ -266,17 +256,17 @@ char * Interpretation_du_fichier_config()
Ptr+=2;
//printf("%4d %4X %4X\t", Numero, Touche, Touche2);
// Recherche de la touche qui porte ce numéro
for (Indice_touche=0; Indice_touche <= NB_OPTIONS; Indice_touche ++)
for (Indice_touche=0; Indice_touche < NB_MAX_TOUCHES; Indice_touche ++)
{
if (Config[Indice_touche].Numero == Numero)
if (ConfigTouche[Indice_touche].Numero == Numero)
{
Config[Indice_touche].Touche = Touche;
Config[Indice_touche].Touche2 = Touche2;
ConfigTouche[Indice_touche].Touche = Touche;
// Utilisé pour afficher la liste complète des raccourcis dans le format du wiki...
/* printf("||%s||%s||%s %s||\n", Config[Indice_touche].Libelle,
/* printf("||%s||%s||%s %s||\n", ConfigTouche[Indice_touche].Libelle,
Nom_touche(Touche),
Config[Indice_touche].Explic1,
Config[Indice_touche].Explic2); */
ConfigTouche[Indice_touche].Explic1,
ConfigTouche[Indice_touche].Explic2); */
break;
}
}
@ -286,568 +276,11 @@ char * Interpretation_du_fichier_config()
return NULL;
}
/* 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()
{
char * MessageErreur = NULL;
Numero_definition_option = 0;
Definir_option(0,"Scroll up",
"Scrolls the picture up, both in magnify and normal mode.",
"This hotkey cannot be removed.",
false, SDLK_UP); // HAUT
Definir_option(1,"Scroll down",
"Scrolls the picture down, both in magnify and normal mode.",
"This hotkey cannot be removed.",
false, SDLK_DOWN); // BAS
Definir_option(2,"Scroll left",
"Scrolls the picture to the left, both in magnify and normal mode.",
"This hotkey cannot be removed.",
false, SDLK_LEFT); // GAUCHE
Definir_option(3,"Scroll right",
"Scrolls the picture to the right, both in magnify and normal mode.",
"This hotkey cannot be removed.",
false, SDLK_RIGHT); // DROITE
Definir_option(4,"Faster scroll up",
"Used to scroll upwards in the picture fast, either in magnify and normal",
"mode.",
true,SDLK_UP|MOD_SHIFT); /*Shift + Haut*/
Definir_option(5,"Faster scroll down",
"Used to scroll downwards in the picture fast, either in magnify and normal",
"mode.",
true,SDLK_DOWN|MOD_SHIFT); /*Shift + Bas*/
Definir_option(6,"Faster scroll left",
"Used to scroll to the left in the picture fast, either in magnify and normal",
"mode.",
true,SDLK_LEFT|MOD_SHIFT); /*Shift + Gauche*/
Definir_option(7,"Faster scroll right",
"Used to scroll to the right in the picture fast, either in magnify and",
"normal mode.",
true,SDLK_RIGHT|MOD_SHIFT); /*Shift + Droite*/
Definir_option(8,"Slower scroll up",
"Used to scroll upwards in the picture pixel by pixel, either in magnify and",
"normal mode.",
true,SDLK_UP|MOD_ALT); /*Alt + Haut*/
Definir_option(9,"Slower scroll down",
"Used to scroll downwards in the picture pixel by pixel, either in magnify and",
"normal mode.",
true,SDLK_DOWN|MOD_ALT); /*Alt + Bas*/
Definir_option(10,"Slower scroll left",
"Used to scroll to the left in the picture pixel by pixel, either in magnify",
"and normal mode.",
true,SDLK_LEFT|MOD_ALT); /*Alt + Gauche*/
Definir_option(11,"Slower scroll right",
"Used to scroll to the right in the picture pixel by pixel, either in magnify",
"and normal mode.",
true,SDLK_RIGHT|MOD_ALT); /*Alt + Droite*/
Definir_option(12,"Move mouse cursor 1 pixel up",
"Used to simulate a very small mouse deplacement upwards.",
"It""s very useful when you want a ultra-high precision.",
true,SDLK_UP|MOD_CTRL); /*Ctrl + Haut*/
Definir_option(13,"Move mouse cursor 1 pixel down",
"Used to simulate a very small mouse deplacement downwards.",
"It""s very useful when you want a ultra-high precision.",
true,SDLK_DOWN|MOD_CTRL); /*Ctrl + Bas*/
Definir_option(14,"Move mouse cursor 1 pixel left",
"Used to simulate a very small mouse deplacement to the left.",
"It""s very useful when you want a ultra-high precision.",
true,SDLK_LEFT|MOD_CTRL); /*Ctrl + Gauche*/
Definir_option(15,"Move mouse cursor 1 pixel right",
"Used to simulate a very small mouse deplacement to the right.",
"It""s very useful when you want a ultra-high precision.",
true,SDLK_RIGHT|MOD_CTRL); /*Ctrl + Droite*/
Definir_option(16,"Simulate left mouse click",
"Used to simulate a click with the left mouse button..",
"It""s very useful when you want a ultra-high precision.",
true,SDLK_SPACE); /*Space*/
Definir_option(17,"Simulate right mouse click",
"Used to simulate a click with the right mouse button..",
"It""s very useful when you want a ultra-high precision.",
true,SDLK_SPACE|MOD_SHIFT); /*Shift + Space*/
Definir_option(18,"Show/hide option menu",
"Switch the tool bar display on/off.",
"This hot-key cannot be removed.",
false,SDLK_F10); /*F10*/
Definir_option(19,"Show/hide cursor",
"Switch the cursor display on/off.",
"This only works on the \"small cross\" and \"hand\" cursors.",
true,SDLK_F9); /*F9*/
Definir_option(20,"Set paintbrush to 1 pixel",
"Useful when you want to use a \"single-pixel-brush\".",
"",
true,SDLK_DELETE); /*Del*/
Definir_option(21,"Paintbrush choice",
"Opens a menu where you can choose a paintbrush out of 24 predefined ones.",
"",
true,SDLK_F4); /*F4*/
Definir_option(22,"Monochrome brush",
"Turn your current user-defined brush into a single colored one.",
"All non-transparent colors are set to current foreground color.",
true,SDLK_F4|MOD_SHIFT); /*Shift + F4*/
Definir_option(23,"Freehand drawing",
"Set the drawing mode to the classical freehand one.",
"",
true,SDLK_d); /*D*/
Definir_option(24,"Switch freehand drawing mode",
"Switch between the 3 ways to use freehand drawing.",
"These modes are: continuous, discontinuous and point by point.",
true,SDLK_d|MOD_SHIFT); /*Shift + D*/
Definir_option(25,"Continuous freehand drawing",
"Switch directly to continuous freehand drawing mode.",
"",
true,SDLK_d|MOD_CTRL); /*Ctrl + D*/
Definir_option(26,"Line",
"Allows you to draw lines.",
"",
true,SDLK_l); /*L*/
Definir_option(27,"Knotted lines",
"Allows you to draw linked lines.",
"This mode can also be called \"Polyline\".",
true,SDLK_l|MOD_SHIFT); /*Shift + L*/
Definir_option(28,"Spray",
"Allows you to spray brushes randomly in the picture.",
"",
true,SDLK_a); /*A (Q en AZERTY)*/
Definir_option(29,"Spray menu",
"Opens a menu in which you can configure the spray flow and size.",
"",
true,SDLK_a|MOD_SHIFT); /*Shift + A*/
Definir_option(30,"Flood-fill",
"Allows you to fill an area of the picture made of pixels of the same color.",
"",
true,SDLK_f); /*F*/
Definir_option(124,"Replace color",
"Allows you to replace all the pixels of the color pointed by the mouse with",
"the fore-color or the back-color.",
true,SDLK_f|MOD_SHIFT); /*Shift + F*/
Definir_option(31,"Bezier""s curves",
"Allows you to draw Bezier""s curves.",
"",
true,SDLK_i); /*I*/
Definir_option(32,"Bezier""s curve with 3 or 4 points",
"Allows you to choose whether you want to draw Bezier""s curves with 3 or 4",
"points.",
true,SDLK_i|MOD_SHIFT); /*Shift + I*/
Definir_option(33,"Empty rectangle",
"Allows you to draw a rectangle using the brush.",
"",
true,SDLK_r); /*R*/
Definir_option(34,"Filled rectangle",
"Allows you to draw a filled rectangle.",
"",
true,SDLK_r|MOD_SHIFT); /*Shift + R*/
Definir_option(35,"Empty circle",
"Allows you to draw a circle using the brush.",
"",
true,SDLK_c); /*C*/
Definir_option(36,"Empty ellipse",
"Allows you to draw an ellipse using the brush.",
"",
true,SDLK_c|MOD_CTRL); /*Ctrl + C*/
Definir_option(37,"Filled circle",
"Allows you to draw a filled circle.",
"",
true,SDLK_c|MOD_SHIFT); /*Shift + C*/
Definir_option(38,"Filled ellipse",
"Allows you to draw a filled ellipse.",
"",
true,SDLK_c|MOD_SHIFT|MOD_CTRL); /*Shift + Ctrl + C*/
Definir_option(39,"Empty polygon",
"Allows you to draw a polygon using the brush.",
"",
true,SDLK_n); /*N*/
Definir_option(40,"Empty \"polyform\"",
"Allows you to draw a freehand polygon using the brush.",
"",
true,SDLK_n|MOD_CTRL); /*Ctrl + N*/
Definir_option(41,"Filled polygon",
"Allows you to draw a filled polygon.",
"",
true,SDLK_n|MOD_SHIFT); /*Shift + N*/
Definir_option(42,"Filled \"polyform\"",
"Allows you to draw a filled freehand polygon.",
"",
true,SDLK_n|MOD_SHIFT|MOD_CTRL); /*Shift + Ctrl + N*/
Definir_option(43,"Rectangle with gradation",
"Allows you to draw a rectangle with a color gradation.",
"",
true,SDLK_r|MOD_ALT); /*Alt + R*/
Definir_option(44,"Gradation menu",
"Allows you to configure the way color gradations are calculated.",
"",
true,SDLK_g|MOD_ALT); /*Alt + G*/
Definir_option(45,"Sphere with gradation",
"Allows you to draw a rectangle with a color gradation.",
"",
true,SDLK_c|MOD_ALT); /*Alt + C*/
Definir_option(46,"Ellipse with gradation",
"Allows you to draw an ellipse filled with a color gradation.",
"",
true,SDLK_c|MOD_SHIFT|MOD_ALT); /*Shift + Alt + C*/
Definir_option(47,"Adjust picture",
"Allows you to move the whole picture in order to re-center it.",
"Notice that what gets out from a side reappears on the other.",
true,SDLK_KP5); /*Kpad5*/
Definir_option(48,"Flip/shrink picture menu",
"Opens a menu which allows you to flip the picture horizontally/vertically or",
"to shrink it to half-scale horizontally and/or vertically.",
true,SDLK_KP5|MOD_SHIFT); /*Shift + Kpad5*/
Definir_option(49,"Drawing effects",
"Opens a menu where you can enable/disable and configure the drawing effects",
"listed below.",
true,SDLK_e); /*E*/
Definir_option(50,"Shade mode",
"Allows you to shade or lighten some pixels of the picture belonging to a",
"color range, in addition of any drawing tool.",
true,SDLK_F5); /*F5*/
Definir_option(51,"Shade menu",
"Opens a menu where you can choose color ranges to use with the Shade mode.",
"This menu also contains parameters used both in Shade and Quick-shade modes.",
true,SDLK_F5|MOD_SHIFT); /*Shift + F5*/
Definir_option(131,"Quick-shade mode",
"Does the same thing as shade mode with a simpler method (faster to define",
"but a bit less powerful).",
true,SDLK_F5|MOD_CTRL); /*Ctrl + F5*/
Definir_option(132,"Quick-shade menu",
"Opens a menu where you can define the parameters of the quick-shade mode.",
"",
true,SDLK_F5|MOD_SHIFT|MOD_CTRL); /*Shift + Ctrl + F5*/
Definir_option(52,"Stencil mode",
"Allows you to mask colors that must not be affected when you are drawing.",
"",
true,SDLK_F6); /*F6*/
Definir_option(53,"Stencil menu",
"Opens a menu where you can choose colors masked by the Stencil mode.",
"",
true,SDLK_F6|MOD_SHIFT); /*Shift + F6*/
Definir_option(54,"Mask mode",
"Allows you to mask colors of the spare page that will keep you from ",
"drawing. This mode should be called \"True stencil\".",
true,SDLK_F6|MOD_ALT); /*Alt + F6*/
Definir_option(55,"Mask menu",
"Opens a menu where you can choose colors for the Mask mode.",
"",
true,SDLK_F6|MOD_SHIFT|MOD_ALT); /*Shift + Alt + F6*/
Definir_option(56,"Grid mode",
"Force the cursor to snap up grid points.",
"",
true,SDLK_g); /*G*/
Definir_option(57,"Grid menu",
"Open a menu where you can configure the grid used by Grid mode.",
"",
true,SDLK_g|MOD_SHIFT); /*Shift + G*/
Definir_option(58,"Sieve mode",
"Only draws pixels on certain positions matching with a sieve.",
"",
true,SDLK_g|MOD_CTRL); /*Ctrl + G*/
Definir_option(59,"Sieve menu",
"Opens a menu where you can configure the sieve.",
"",
true,SDLK_g|MOD_SHIFT|MOD_CTRL); /*Shift + Ctrl + G*/
Definir_option(60,"Invert sieve",
"Inverts the pattern defined in the Sieve menu.",
"",
true,SDLK_g|MOD_CTRL|MOD_ALT); /*Ctrl + Alt + G*/
Definir_option(61,"Colorize mode",
"Allows you to colorize the pixels on which your brush is pasted.",
"This permits you to make transparency effects.",
true,SDLK_F7); /*F7*/
Definir_option(62,"Colorize menu",
"Opens a menu where you can give the opacity percentage for Colorize mode.",
"",
true,SDLK_F7|MOD_SHIFT); /*Shift + F7*/
Definir_option(63,"Smooth mode",
"Soften pixels on which your brush is pasted.",
"",
true,SDLK_F8); /*F8*/
Definir_option(123,"Smooth menu",
"Opens a menu where you can define the Smooth matrix.",
"",
true,SDLK_F8|MOD_SHIFT); /*Shift + F8*/
Definir_option(64,"Smear mode",
"Smears the pixels when you move your brush on the picture.",
"",
true,SDLK_F8|MOD_ALT); /*Alt + F8*/
Definir_option(65,"Tiling mode",
"Puts parts of the brush where you draw.",
"",
true,SDLK_b|MOD_ALT); /*Alt + B*/
Definir_option(66,"Tiling menu",
"Opens a menu where you can configure the origin of the tiling.",
"",
true,SDLK_b|MOD_SHIFT|MOD_ALT); /*Shift + Alt + B*/
Definir_option(67,"Classical brush grabbing",
"Allows you to pick a brush defined within a rectangle.",
"",
true,SDLK_b); /*B*/
Definir_option(68,"\"Lasso\" brush grabbing",
"Allows you to pick a brush defined within a freehand polygon.",
"",
true,SDLK_b|MOD_CTRL); /*Ctrl + B*/
Definir_option(69,"Get previous brush back",
"Restore the last user-defined brush.",
"",
true,SDLK_b|MOD_SHIFT); /*Shift + B*/
Definir_option(70,"Horizontal brush flipping",
"Reverse brush horizontally.",
"",
true,SDLK_x); /*X*/
Definir_option(71,"Vertical brush flipping",
"Reverse brush vertically.",
"",
true,SDLK_y); /*Y*/
Definir_option(72,"90ø brush rotation",
"Rotate the user-defined brush by 90ø (counter-clockwise).",
"",
true,SDLK_z); /*Z (W en AZERTY)*/
Definir_option(73,"180ø brush rotation",
"Rotate the user-defined brush by 180ø.",
"",
true,SDLK_z|MOD_SHIFT); /*Shift + Z*/
Definir_option(74,"Strech brush",
"Allows you to resize the user-defined brush.",
"",
true,SDLK_s); /*S*/
Definir_option(75,"Distort brush",
"Allows you to distort the user-defined brush.",
"",
true,SDLK_s|MOD_SHIFT); /*Shift + S*/
Definir_option(76,"Outline brush",
"Outlines the user-defined brush with the fore color.",
"",
true,SDLK_o); /*O*/
Definir_option(77,"Nibble brush",
"Deletes the borders of the user-defined brush.",
"This does the opposite of the Outline option.",
true,SDLK_o|MOD_SHIFT); /*Shift + O*/
Definir_option(78,"Get colors from brush",
"Copy colors of the spare page that are used in the brush.",
"",
true,SDLK_F11); /*F11*/
Definir_option(79,"Recolorize brush",
"Recolorize pixels of the user-defined brush in order to get a brush which",
"looks like the one grabbed in the spare page.",
true,SDLK_F12); /*F12*/
Definir_option(80,"Rotate by any angle",
"Rotate the brush by an angle that you can define.",
"",
true,SDLK_w); /*W (Z en AZERTY)*/
Definir_option(81,"Pipette",
"Allows you to copy the color of a pixel in the picture into the foreground",
"or background color.",
true,SDLK_BACKQUOTE); /*`~ (Touche sous le Esc - ² en AZERTY)*/
Definir_option(82,"Swap foreground/background colors",
"Invert foreground and background colors.",
"",
true,SDLK_BACKQUOTE|MOD_SHIFT); /*Shift + `~*/
Definir_option(83,"Magnifier mode",
"Allows you to zoom into the picture.",
"",
true,SDLK_m); /*M (,? sur AZERTY)*/
Definir_option(84,"Zoom factor menu",
"Opens a menu where you can choose a magnifying factor.",
"",
true,SDLK_m|MOD_SHIFT); /*Shift + M*/
Definir_option(85,"Zoom in",
"Increase magnifying factor.",
"",
true,SDLK_KP_PLUS); /*Grey +*/
Definir_option(86,"Zoom out",
"Decrease magnifying factor.",
"",
true,SDLK_KP_MINUS); /*Grey -*/
Definir_option(87,"Brush effects menu",
"Opens a menu which proposes different effects on the user-defined brush.",
"",
true,SDLK_b|MOD_CTRL|MOD_ALT); /*Ctrl + Alt + B*/
Definir_option(88,"Text",
"Opens a menu which permits you to type in a character string and to choose a",
"font, and then creates a new user-defined brush fitting to your choices.",
true,SDLK_t); /*T*/
Definir_option(89,"Screen resolution menu",
"Opens a menu where you can choose the dimensions of the screen in which you",
"want to draw among the numerous X and SVGA proposed modes.",
true,SDLK_RETURN); /*Enter*/
Definir_option(90,"\"Safety\" resolution",
"Set resolution to 320x200. This can be useful if you choosed a resolution",
"that is not supported by your monitor and video card. Cannot be removed.",
false,SDLK_RETURN|MOD_SHIFT); /*Shift + Enter*/
Definir_option(91,"Help and credits",
"Opens a window where you can get information about the program.",
"",
true,SDLK_F1); /*F1*/
Definir_option(92,"Statistics",
"Displays miscellaneous more or less useful information.",
"",
true,SDLK_F1|MOD_SHIFT); /*Shift + F1*/
Definir_option(93,"Jump to spare page",
"Swap current page and spare page.",
"",
true,SDLK_TAB); /*Tab*/
Definir_option(94,"Copy current page to spare page",
"Copy current page to spare page.",
"",
true,SDLK_TAB|MOD_SHIFT); /*Shift + Tab*/
Definir_option(95,"Save picture as...",
"Opens a file-selector that allows you to save your picture with a new",
"path-name.",
true,SDLK_F2); /*F2*/
Definir_option(96,"Save picture",
"Saves your picture with the last name you gave it.",
"",
true,SDLK_F2|MOD_SHIFT); /*Shift + F2*/
Definir_option(97,"Load picture",
"Opens a file-selector that allows you to load a new picture.",
"",
true,SDLK_F3); /*F3*/
Definir_option(98,"Re-load picture",
"Re-load the current picture.",
"This allows you to cancel modifications made since last saving.",
true,SDLK_F3|MOD_SHIFT); /*Shift + F3*/
Definir_option(99,"Save brush",
"Opens a file-selector that allows you to save your current user-defined",
"brush.",
true,SDLK_F2|MOD_CTRL); /*Ctrl + F2*/
Definir_option(100,"Load brush",
"Opens a file-selector that allows you to load a brush.",
"",
true,SDLK_F3|MOD_CTRL); /*Ctrl + F3*/
Definir_option(101,"Settings",
"Opens a menu which permits you to set the dimension of your picture, and to",
"modify some parameters of the program.",
true,SDLK_F10|MOD_SHIFT); /*Shift + F10*/
Definir_option(102,"Undo (Oops!)",
"Cancel the last action which modified the picture. This has no effect after",
"a jump to the spare page, loading a picture or modifying its size.",
true,SDLK_u); /*U*/
Definir_option(103,"Redo",
"Redo the last undone action. This has no effect after a jump to the spare",
"page, loading a picture or modifying its size.",
true,SDLK_u|MOD_SHIFT); /*Shift + U*/
Definir_option(133,"Kill",
"Kills the current page. It actually removes the current page from the list",
"of \"Undo\" pages.",
true,SDLK_DELETE|MOD_SHIFT); /*Shift + Suppr*/
Definir_option(104,"Clear page",
"Clears the picture with the first color of the palette (usually black).",
"",
true,SDLK_BACKSPACE); /*BackSpace*/
Definir_option(105,"Clear page with backcolor",
"Clears the picture with the backcolor.",
"",
true,SDLK_BACKSPACE|MOD_SHIFT); /*Shift + BackSpace*/
Definir_option(106,"Quit program",
"Allows you to leave the program.",
"If modifications were not saved, confirmation is asked.",
false,SDLK_q); /*Q (A en AZERTY)*/
Definir_option(107,"Palette menu",
"Opens a menu which allows you to modify the current palette.",
"",
true,SDLK_p); /*P*/
Definir_option(125,"Secondary palette menu",
"Opens a menu which allows you to define color series and some tagged colors.",
"",
true,SDLK_p|MOD_SHIFT); /*Shift + P*/
Definir_option(130,"Exclude colors menu",
"Opens a menu which allows you to define the colors you don""t want to use in",
"modes such as Smooth and Transparency, or when remapping a brush.",
true,SDLK_p|MOD_CTRL); /*Ctrl + P*/
Definir_option(108,"Scroll palette to the left",
"Scroll palette in the tool bar to the left, column by column.",
"",
true,SDLK_PAGEUP); /*PgUp*/
Definir_option(109,"Scroll palette to the right",
"Scroll palette in the tool bar to the right, column by column.",
"",
true,SDLK_PAGEDOWN); /*PgDn*/
Definir_option(110,"Scroll palette to the left faster",
"Scroll palette in the tool bar to the left, 8 columns by 8 columns.",
"",
true,SDLK_PAGEUP|MOD_SHIFT); /*Shift + PgUp*/
Definir_option(111,"Scroll palette to the right faster",
"Scroll palette in the tool bar to the right, 8 columns by 8 columns.",
"",
true,SDLK_PAGEDOWN|MOD_SHIFT); /*Shift + PgDn*/
Definir_option(112,"Center brush attachment point",
"Set the attachement of the user-defined brush to its center.",
"",
true,SDLK_KP5|MOD_CTRL); /*Ctrl + 5 (pavé numérique)*/
Definir_option(113,"Top-left brush attachment point",
"Set the attachement of the user-defined brush to its top-left corner.",
"",
true,SDLK_HOME|MOD_CTRL); /*Ctrl + 7*/
Definir_option(114,"Top-right brush attachment point",
"Set the attachement of the user-defined brush to its top-right corner.",
"",
true,SDLK_PAGEUP|MOD_CTRL); /*Ctrl + 9*/
Definir_option(115,"Bottom-left brush attachment point",
"Set the attachement of the user-defined brush to its bottom-left corner.",
"",
true,SDLK_END|MOD_CTRL); /*Ctrl + 1*/
Definir_option(116,"Bottom-right brush attachment point",
"Set the attachement of the user-defined brush to its bottom-right corner.",
"",
true,SDLK_PAGEDOWN|MOD_CTRL); /*Ctrl + 3*/
Definir_option(117,"Next foreground color",
"Set the foreground color to the next in the palette.",
"",
true,SDLK_RIGHTBRACKET); /*] (0x en AZERTY)*/
Definir_option(118,"Previous foreground color",
"Set the foreground color to the previous in the palette.",
"",
true,SDLK_LEFTBRACKET); /*[ (^ en AZERTY)*/
Definir_option(119,"Next background color",
"Set the background color to the next in the palette.",
"",
true,SDLK_RIGHTBRACKET|MOD_SHIFT); /*Shift + ]*/
Definir_option(120,"Previous background color",
"Set the background color to the previous in the palette.",
"",
true,SDLK_LEFTBRACKET|MOD_SHIFT); /*Shift + [*/
Definir_option(126,"Next user-defined forecolor",
"Set the foreground color to the next in the user-defined color series.",
"",
true,SDLK_EQUALS); /*"=+"*/
Definir_option(127,"Previous user-defined forecolor",
"Set the foreground color to the previous in the user-defined color series.",
"",
true,SDLK_MINUS); /*"-_" (")ø" en AZERTY*/
Definir_option(128,"Next user-defined backcolor",
"Set the background color to the next in the user-defined color series.",
"",
true,SDLK_EQUALS|MOD_SHIFT); /*Shift + "=+"*/
Definir_option(129,"Previous user-defined backcolor",
"Set the background color to the previous in the user-defined color series.",
"",
true,SDLK_MINUS|MOD_SHIFT); /*Shift + "-_" (")ø" en AZERTY*/
Definir_option(121,"Shrink paintbrush",
"Decrease the width of the paintbrush if it is special circle or square.",
"",
true,SDLK_COMMA); /*,< (;. en AZERTY)*/
Definir_option(122,"Enlarge paintbrush",
"Increase the width of the paintbrush if it is special circle or square.",
"",
true,SDLK_PERIOD); /*.> (:/ en AZERTY)*/
NB_OPTIONS = Numero_definition_option - 1;
MessageErreur = Interpretation_du_fichier_config();
if (MessageErreur)
@ -945,22 +378,22 @@ void Test_duplic()
uint16_t i,j;
bool Pas_encore_erreur;
for(i=0;i<=NB_OPTIONS;i++)
for(i=0;i<NB_MAX_TOUCHES;i++)
{
if(Config[i].Touche!=0xFF) // FIXME
if(ConfigTouche[i].Touche!=0xFF) // FIXME
{
j=0;
Pas_encore_erreur=true;
while(j<=NB_OPTIONS && Pas_encore_erreur)
while(j<NB_MAX_TOUCHES && Pas_encore_erreur)
{
if(i!=j && Config[i].Touche==Config[j].Touche)
if(i!=j && ConfigTouche[i].Touche==ConfigTouche[j].Touche)
{
Pas_encore_erreur = false;
Config[i].Erreur = true;
Erreur[i] = true;
}
j++;
}
if (Pas_encore_erreur) Config[i].Erreur = false;
if (Pas_encore_erreur) Erreur[i] = false;
}
}
}
@ -971,9 +404,9 @@ bool Validation()
bool Y_a_des_erreurs = false;
uint16_t i = 0;
while(i<=NB_OPTIONS && !Y_a_des_erreurs)
while(i<NB_MAX_TOUCHES && !Y_a_des_erreurs)
{
Y_a_des_erreurs = Config[i].Erreur;
Y_a_des_erreurs = Erreur[i];
i++;
}
@ -1010,23 +443,23 @@ void Scroll_haut()
/* Moves one line down */
void Scroll_bas()
{
if(Position_curseur + Decalage_curseur < NB_OPTIONS)
{
if(Position_curseur < HAUTEUR_FIN_SETUP - HAUTEUR_DEBUT_SETUP)
{
Ecrire(HAUTEUR_DEBUT_SETUP + (Position_curseur) ,Position_curseur + Decalage_curseur,
COULEUR_SETUP);
(Position_curseur) ++ ;
Ecrire(HAUTEUR_DEBUT_SETUP + (Position_curseur) ,Position_curseur + Decalage_curseur,
COULEUR_SELECT);
}
else if(Decalage_curseur < NB_OPTIONS)
{
(Decalage_curseur) ++ ;
Tout_ecrire();
}
Ecrire_commentaire(Position_curseur + Decalage_curseur );
}
if(Position_curseur + Decalage_curseur < (NB_MAX_TOUCHES-1))
{
if(Position_curseur < HAUTEUR_FIN_SETUP - HAUTEUR_DEBUT_SETUP)
{
Ecrire(HAUTEUR_DEBUT_SETUP + (Position_curseur) ,Position_curseur + Decalage_curseur,
COULEUR_SETUP);
(Position_curseur) ++ ;
Ecrire(HAUTEUR_DEBUT_SETUP + (Position_curseur) ,Position_curseur + Decalage_curseur,
COULEUR_SELECT);
}
else if(Decalage_curseur < (NB_MAX_TOUCHES-1))
{
(Decalage_curseur) ++ ;
Tout_ecrire();
}
Ecrire_commentaire(Position_curseur + Decalage_curseur );
}
}
/* Moves one screen up */
@ -1057,28 +490,29 @@ void Page_up()
/* Moves one screen down */
void Page_down()
{
if(Position_curseur+Decalage_curseur<NB_OPTIONS)
{
if(Position_curseur<HAUTEUR_FIN_SETUP-HAUTEUR_DEBUT_SETUP)
{
if(Position_curseur+Decalage_curseur<(NB_MAX_TOUCHES-1))
{
if(Position_curseur<HAUTEUR_FIN_SETUP-HAUTEUR_DEBUT_SETUP)
{
Ecrire(HAUTEUR_DEBUT_SETUP + (Position_curseur),Position_curseur + Decalage_curseur,
COULEUR_SETUP);
Position_curseur = HAUTEUR_FIN_SETUP-HAUTEUR_DEBUT_SETUP ;
Ecrire(HAUTEUR_DEBUT_SETUP + (Position_curseur),Position_curseur + Decalage_curseur,
COULEUR_SELECT);
}
else if(Decalage_curseur<NB_OPTIONS)
{
if(Decalage_curseur + Position_curseur + HAUTEUR_FIN_SETUP-HAUTEUR_DEBUT_SETUP < NB_OPTIONS)
}
else if(Decalage_curseur<(NB_MAX_TOUCHES-1))
{
if(Decalage_curseur + Position_curseur + HAUTEUR_FIN_SETUP-HAUTEUR_DEBUT_SETUP < (NB_MAX_TOUCHES-1))
{
Decalage_curseur+=HAUTEUR_FIN_SETUP-HAUTEUR_DEBUT_SETUP;
}
else Decalage_curseur=NB_OPTIONS-HAUTEUR_FIN_SETUP+HAUTEUR_DEBUT_SETUP;
Decalage_curseur+=HAUTEUR_FIN_SETUP-HAUTEUR_DEBUT_SETUP;
}
else
Decalage_curseur=NB_MAX_TOUCHES-1-HAUTEUR_FIN_SETUP+HAUTEUR_DEBUT_SETUP;
Tout_ecrire();
}
Tout_ecrire();
}
Ecrire_commentaire(Position_curseur+Decalage_curseur);
}
}
}
void Select()
@ -1099,7 +533,7 @@ void Select()
}
if (Touche != 0)
{
Config[Position_curseur+Decalage_curseur].Touche = Touche;
ConfigTouche[Position_curseur+Decalage_curseur].Touche = Touche;
Test_duplic();
// Des X ont pu être ajoutés ou enlevés sur n'importe quelle ligne..
// pour faire simple, on rafraîchit toute la page.
@ -1175,7 +609,7 @@ void Enregistrer_config()
Header.Beta2 = BETA2;
write_bytes(Fichier, &Header, sizeof(Header));
Chunk[CHUNK_TOUCHES].Taille=sizeof(struct Config_Infos_touche)*(NB_OPTIONS+1);
Chunk[CHUNK_TOUCHES].Taille=sizeof(struct Config_Infos_touche)*(NB_MAX_TOUCHES);
Chunk[CHUNK_TOUCHES].Numero=CHUNK_TOUCHES;
for (Indice_chunk=0; Indice_chunk<CHUNK_MAX; Indice_chunk++)
@ -1188,11 +622,11 @@ void Enregistrer_config()
{
int Indice_touche;
for(Indice_touche=0; Indice_touche<=NB_OPTIONS;Indice_touche++)
for(Indice_touche=0; Indice_touche<NB_MAX_TOUCHES;Indice_touche++)
{
write_word_le(Fichier,Config[Indice_touche].Numero);
write_word_le(Fichier,Config[Indice_touche].Touche);
write_word_le(Fichier,Config[Indice_touche].Touche2);
write_word_le(Fichier,ConfigTouche[Indice_touche].Numero);
write_word_le(Fichier,ConfigTouche[Indice_touche].Touche);
write_word_le(Fichier,0xFF);
}
}
else

230
init.c
View File

@ -42,6 +42,7 @@
#include "erreurs.h"
#include "clavier.h"
#include "io.h"
#include "hotkeys.h"
#include "errno.h"
@ -1604,145 +1605,6 @@ word Ordonnancement[NB_TOUCHES]=
SPECIAL_GROSSIR_PINCEAU // Grossir le pinceau
};
byte Numero_option[NB_TOUCHES]=
{
0, // Scroll up
1, // Scroll down
2, // Scroll left
3, // Scroll right
4, // Scroll up faster
5, // Scroll down faster
6, // Scroll left faster
7, // Scroll right faster
8, // Scroll up slower
9, // Scroll down slower
10, // Scroll left slower
11, // Scroll right slower
12, // Emulate mouse up
13, // Emulate mouse down
14, // Emulate mouse left
15, // Emulate mouse right
16, // Emulate mouse click left
17, // Emulate mouse click right
18, // Show / Hide menu
19, // Show / Hide cursor
20, // Paintbrush = "."
21, // Paintbrush choice
22, // Monochrome brush
23, // Freehand drawing
24, // Switch freehand drawing mode
25, // Continuous freehand drawing
26, // Line
27, // Knotted lines
28, // Spray
29, // Spray menu
30, // Floodfill
124, // Replace color
31, // Bézier's curves
32, // Bézier's curve with 3 or 4 points
33, // Empty rectangle
34, // Filled rectangle
35, // Empty circle
36, // Empty ellipse
37, // Filled circle
38, // Filled ellipse
39, // Empty polygon
40, // Empty polyform
41, // Polyfill
42, // Filled polyform
43, // Gradient rectangle
44, // Gradation menu
45, // Spheres
46, // Gradient ellipses
47, // Adjust picture
48, // Flip picture menu
49, // Menu des effets
50, // Shade mode
51, // Shade menu
131, // Quick-shade mode
132, // Quick-shade menu
52, // Stencil mode
53, // Stencil menu
54, // Mask mode
55, // Mask menu
56, // Grid mode
57, // Grid menu
58, // Sieve mode
59, // Sieve menu
60, // Inverser la trame du mode Sieve
61, // Colorize mode
62, // Colorize menu
63, // Smooth mode
123, // Smooth menu
64, // Smear mode
65, // Tiling mode
66, // Tiling menu
67, // Pick brush
68, // Pick polyform brush
69, // Restore brush
70, // Flip X
71, // Flip Y
72, // 90° brush rotation
73, // 180° brush rotation
74, // Stretch brush
75, // Distort brush
76, // Outline brush
77, // Nibble brush
78, // Get colors from brush
79, // Recolorize brush
80, // Rotate brush by any angle
81, // Pipette
82, // Swap fore/back color
83, // Magnifier mode
84, // Zoom factor menu
85, // Zoom in
86, // Zoom out
87, // Brush effects menu
88, // Text
89, // Resolution menu
90, // Safety resolution
91, // Help & credits
92, // Statistics
93, // Go to spare page
94, // Copy to spare page
95, // Save as
96, // Save
97, // Load
98, // Re-load
99, // Save brush
100, // Load brush
101, // Settings
102, // Undo
103, // Redo
133, // Kill
104, // Clear
105, // Clear with backcolor
106, // Quit
107, // Palette menu
125, // Palette menu secondaire
130, // Exclude colors menu
108, // Scroll palette left
109, // Scroll palette right
110, // Scroll palette left faster
111, // Scroll palette right faster
112, // Center brush attachement
113, // Top-left brush attachement
114, // Top-right brush attachement
115, // Bottom-left brush attachement
116, // Bottom right brush attachement
117, // Next foreground color
118, // Previous foreground color
119, // Next background color
120, // Previous background color
126, // Next user-defined foreground color
127, // Previous user-defined foreground color
128, // Next user-defined background color
129, // Previous user-defined background color
121, // Rétrécir le pinceau
122 // Grossir le pinceau
};
int Charger_CFG(int Tout_charger)
{
FILE* Handle;
@ -1811,7 +1673,7 @@ int Charger_CFG(int Tout_charger)
CFG_Infos_touche.Touche = Touche_pour_scancode(CFG_Infos_touche.Touche);
}
for (Indice2=0;
((Indice2<NB_TOUCHES) && (Numero_option[Indice2]!=CFG_Infos_touche.Numero));
((Indice2<NB_TOUCHES) && (ConfigTouche[Indice2].Numero!=CFG_Infos_touche.Numero));
Indice2++);
if (Indice2<NB_TOUCHES)
{
@ -1918,7 +1780,6 @@ int Charger_CFG(int Tout_charger)
case CHUNK_DEGRADES: // Infos sur les dégradés
if (Tout_charger)
{
// fixme endianness : Degrade_Courant est un int, enregistre en byte
if (! read_byte(Handle, &Degrade_Courant))
goto Erreur_lecture_config;
for(Indice=0;Indice<16;Indice++)
@ -2057,7 +1918,7 @@ int Sauver_CFG(void)
goto Erreur_sauvegarde_config;
for (Indice=0; Indice<NB_TOUCHES; Indice++)
{
CFG_Infos_touche.Numero =Numero_option[Indice];
CFG_Infos_touche.Numero = ConfigTouche[Indice].Numero;
switch(Ordonnancement[Indice]>>8)
{
case 0 : CFG_Infos_touche.Touche=Config_Touche[Ordonnancement[Indice]&0xFF]; break;
@ -2269,3 +2130,88 @@ void Initialiser_la_table_precalculee_des_distances_de_couleur(void)
}
}
}
// (Ré)assigne toutes les valeurs de configuration par défaut
void Config_par_defaut(void)
{
int Indice, Indice2;
// Raccourcis clavier
for (Indice=0; Indice<NB_TOUCHES; Indice++)
{
switch(Ordonnancement[Indice]>>8)
{
case 0 :
Config_Touche[Ordonnancement[Indice]&0xFF]=ConfigTouche[Indice].Touche;
break;
case 1 :
Bouton[Ordonnancement[Indice]&0xFF].Raccourci_gauche = ConfigTouche[Indice].Touche;
break;
case 2 :
Bouton[Ordonnancement[Indice]&0xFF].Raccourci_droite = ConfigTouche[Indice].Touche;
break;
}
}
// Shade
Shade_Actuel=0;
for (Indice=0; Indice<8; Indice++)
{
Shade_Liste[Indice].Pas=1;
Shade_Liste[Indice].Mode=0;
for (Indice2=0; Indice2<512; Indice2++)
Shade_Liste[Indice].Liste[Indice2]=256;
}
// Shade par défaut pour la palette standard
for (Indice=0; Indice<7; Indice++)
for (Indice2=0; Indice2<16; Indice2++)
Shade_Liste[0].Liste[Indice*17+Indice2]=Indice*16+Indice2+16;
Liste2tables(Shade_Liste[Shade_Actuel].Liste,
Shade_Liste[Shade_Actuel].Pas,
Shade_Liste[Shade_Actuel].Mode,
Shade_Table_gauche,Shade_Table_droite);
// Masque
for (Indice=0; Indice<256; Indice++)
Mask[Indice]=0;
// Stencil
for (Indice=0; Indice<256; Indice++)
Stencil[Indice]=1;
// Dégradés
Degrade_Courant=0;
for(Indice=0;Indice<16;Indice++)
{
Degrade_Tableau[Indice].Debut=0;
Degrade_Tableau[Indice].Fin=0;
Degrade_Tableau[Indice].Inverse=0;
Degrade_Tableau[Indice].Melange=0;
Degrade_Tableau[Indice].Technique=0;
}
Degrade_Charger_infos_du_tableau(Degrade_Courant);
// Smooth
Smooth_Matrice[0][0]=1;
Smooth_Matrice[0][1]=2;
Smooth_Matrice[0][2]=1;
Smooth_Matrice[1][0]=2;
Smooth_Matrice[1][1]=4;
Smooth_Matrice[1][2]=2;
Smooth_Matrice[2][0]=1;
Smooth_Matrice[2][1]=2;
Smooth_Matrice[2][2]=1;
// Exclude colors
for (Indice=0; Indice<256; Indice++)
Exclude_color[Indice]=0;
// Quick shade
Quick_shade_Step=1;
Quick_shade_Loop=0;
// Grille
Snap_Largeur=Snap_Hauteur=8;
Snap_Decalage_X=Snap_Decalage_Y=0;
}

1
init.h
View File

@ -31,3 +31,4 @@ void Initialiser_la_table_precalculee_des_distances_de_couleur(void);
void Definition_des_modes_video(void);
int ActiverLecteur(int);
void Config_par_defaut(void);

18
main.c
View File

@ -420,13 +420,23 @@ void Initialisation_du_programme(int argc,char * argv[])
Initialisation_des_operations();
Une_fenetre_est_ouverte=0;
// Charger les sprites et la palette
Charger_DAT();
// Charger la configuration des touches
Temp=Charger_CFG(1);
if (Temp)
Erreur(Temp);
Config_par_defaut();
switch(Charger_CFG(1))
{
case ERREUR_CFG_ABSENT:
// Pas un problème, on a les valeurs par défaut.
break;
case ERREUR_CFG_CORROMPU:
DEBUG("Corrupted CFG file.",0);
break;
case ERREUR_CFG_ANCIEN:
DEBUG("Unknown CFG file version, not loaded.",0);
break;
}
// Charger la configuration du .INI
Temp=Charger_INI(&Config);
if (Temp)