3 #include <SDL/SDL_keysym.h>
14 printf("Config error:%d\n",e
);
16 printf("Writing default config\n");
24 void SetConfig(const Config c
){
30 //1 -conf.txt doesn't exists
35 fp
=(FILE*)fopen(CONFIG_FILENAME
, "r");
38 if(fscanf(fp
,"%u", &conf
.screen_width
)==EOF
)return 2;
39 if(fscanf(fp
,"%u", &conf
.screen_height
)==EOF
)return 3;
40 if(fscanf(fp
,"%u", &conf
.fullscreen
)==EOF
)return 3;
41 if(fscanf(fp
,"%u", &conf
.texture_lod
)==EOF
)return 3;
43 if(fscanf(fp
,"%u", &conf
.pl1_key_up
)==EOF
)return 4;
44 if(fscanf(fp
,"%u", &conf
.pl1_key_down
)==EOF
)return 5;
45 if(fscanf(fp
,"%u", &conf
.pl1_key_left
)==EOF
)return 6;
46 if(fscanf(fp
,"%u", &conf
.pl1_key_right
)==EOF
)return 7;
47 if(fscanf(fp
,"%u", &conf
.pl1_key_fire
)==EOF
)return 8;
48 if(fscanf(fp
,"%u", &conf
.pl1_key_suicide
)==EOF
)return 8;
49 if(fscanf(fp
,"%u", &conf
.pl1_key_switch
)==EOF
)return 8;
51 if(fscanf(fp
,"%u", &conf
.pl2_key_up
)==EOF
)return 4;
52 if(fscanf(fp
,"%u", &conf
.pl2_key_down
)==EOF
)return 5;
53 if(fscanf(fp
,"%u", &conf
.pl2_key_left
)==EOF
)return 6;
54 if(fscanf(fp
,"%u", &conf
.pl2_key_right
)==EOF
)return 7;
55 if(fscanf(fp
,"%u", &conf
.pl2_key_fire
)==EOF
)return 8;
56 if(fscanf(fp
,"%u", &conf
.pl2_key_suicide
)==EOF
)return 8;
57 if(fscanf(fp
,"%u", &conf
.pl2_key_switch
)==EOF
)return 8;
64 //1-cannot open for writing
68 fp
=(FILE*)fopen(CONFIG_FILENAME
, "w");
71 if(fprintf(fp
,"%u\n", conf
.screen_width
)<0)return 2;
72 if(fprintf(fp
,"%u\n", conf
.screen_height
)<0)return 3;
73 if(fprintf(fp
,"%u\n", conf
.fullscreen
)<0)return 3;
74 if(fprintf(fp
,"%u\n", conf
.texture_lod
)<0)return 3;
76 if(fprintf(fp
,"%u\n", conf
.pl1_key_up
)<0)return 4;
77 if(fprintf(fp
,"%u\n", conf
.pl1_key_down
)<0)return 5;
78 if(fprintf(fp
,"%u\n", conf
.pl1_key_left
)<0)return 6;
79 if(fprintf(fp
,"%u\n", conf
.pl1_key_right
)<0)return 7;
80 if(fprintf(fp
,"%u\n", conf
.pl1_key_fire
)<0)return 8;
81 if(fprintf(fp
,"%u\n", conf
.pl1_key_suicide
)<0)return 8;
82 if(fprintf(fp
,"%u\n", conf
.pl1_key_switch
)<0)return 8;
84 if(fprintf(fp
,"%u\n", conf
.pl2_key_up
)<0)return 4;
85 if(fprintf(fp
,"%u\n", conf
.pl2_key_down
)<0)return 5;
86 if(fprintf(fp
,"%u\n", conf
.pl2_key_left
)<0)return 6;
87 if(fprintf(fp
,"%u\n", conf
.pl2_key_right
)<0)return 7;
88 if(fprintf(fp
,"%u\n", conf
.pl2_key_fire
)<0)return 8;
89 if(fprintf(fp
,"%u\n", conf
.pl2_key_suicide
)<0)return 8;
90 if(fprintf(fp
,"%u\n", conf
.pl2_key_switch
)<0)return 8;
97 conf
.screen_width
=800;
98 conf
.screen_height
=600;
102 conf
.pl1_key_up
=SDLK_UP
;
103 conf
.pl1_key_down
=SDLK_DOWN
;
104 conf
.pl1_key_left
=SDLK_LEFT
;
105 conf
.pl1_key_right
=SDLK_RIGHT
;
106 conf
.pl1_key_fire
=SDLK_RCTRL
;
107 conf
.pl1_key_suicide
=SDLK_F12
;
108 conf
.pl1_key_switch
=SDLK_RSHIFT
;
110 conf
.pl2_key_up
=SDLK_w
;
111 conf
.pl2_key_down
=SDLK_s
;
112 conf
.pl2_key_left
=SDLK_a
;
113 conf
.pl2_key_right
=SDLK_d
;
114 conf
.pl2_key_fire
=SDLK_LCTRL
;
115 conf
.pl2_key_suicide
=SDLK_F11
;
116 conf
.pl2_key_switch
=SDLK_LSHIFT
;