3 #include <SDL/SDL_keysym.h>
10 const Config
GetConfig(){
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;
50 if(fscanf(fp
,"%u", &conf
.pl2_key_up
)==EOF
)return 4;
51 if(fscanf(fp
,"%u", &conf
.pl2_key_down
)==EOF
)return 5;
52 if(fscanf(fp
,"%u", &conf
.pl2_key_left
)==EOF
)return 6;
53 if(fscanf(fp
,"%u", &conf
.pl2_key_right
)==EOF
)return 7;
54 if(fscanf(fp
,"%u", &conf
.pl2_key_fire
)==EOF
)return 8;
55 if(fscanf(fp
,"%u", &conf
.pl2_key_suicide
)==EOF
)return 8;
62 //1-cannot open for writing
66 fp
=(FILE*)fopen(CONFIG_FILENAME
, "w");
69 if(fprintf(fp
,"%u\n", conf
.screen_width
)<0)return 2;
70 if(fprintf(fp
,"%u\n", conf
.screen_height
)<0)return 3;
71 if(fprintf(fp
,"%u\n", conf
.fullscreen
)<0)return 3;
72 if(fprintf(fp
,"%u\n", conf
.texture_lod
)<0)return 3;
74 if(fprintf(fp
,"%u\n", conf
.pl1_key_up
)<0)return 4;
75 if(fprintf(fp
,"%u\n", conf
.pl1_key_down
)<0)return 5;
76 if(fprintf(fp
,"%u\n", conf
.pl1_key_left
)<0)return 6;
77 if(fprintf(fp
,"%u\n", conf
.pl1_key_right
)<0)return 7;
78 if(fprintf(fp
,"%u\n", conf
.pl1_key_fire
)<0)return 8;
79 if(fprintf(fp
,"%u\n", conf
.pl1_key_suicide
)<0)return 8;
81 if(fprintf(fp
,"%u\n", conf
.pl2_key_up
)<0)return 4;
82 if(fprintf(fp
,"%u\n", conf
.pl2_key_down
)<0)return 5;
83 if(fprintf(fp
,"%u\n", conf
.pl2_key_left
)<0)return 6;
84 if(fprintf(fp
,"%u\n", conf
.pl2_key_right
)<0)return 7;
85 if(fprintf(fp
,"%u\n", conf
.pl2_key_fire
)<0)return 8;
86 if(fprintf(fp
,"%u\n", conf
.pl2_key_suicide
)<0)return 8;
93 conf
.screen_width
=800;
94 conf
.screen_height
=600;
98 conf
.pl1_key_up
=SDLK_UP
;
99 conf
.pl1_key_down
=SDLK_DOWN
;
100 conf
.pl1_key_left
=SDLK_LEFT
;
101 conf
.pl1_key_right
=SDLK_RIGHT
;
102 conf
.pl1_key_fire
=SDLK_RCTRL
;
103 conf
.pl1_key_suicide
=SDLK_F12
;
105 conf
.pl2_key_up
=SDLK_w
;
106 conf
.pl2_key_down
=SDLK_s
;
107 conf
.pl2_key_left
=SDLK_a
;
108 conf
.pl2_key_right
=SDLK_d
;
109 conf
.pl2_key_fire
=SDLK_LCTRL
;
110 conf
.pl2_key_suicide
=SDLK_F11
;