11 usermousesensitivity = 1;
12 newscreenwidth = kContextWidth = 640;
13 newscreenheight = kContextHeight = 480;
37 crouchkey = SDLK_LSHIFT;
45 attackkey = MOUSEBUTTON1;
46 consolekey = SDLK_BACKQUOTE;
52 if (newdetail < 0) newdetail = 0;
53 if (newdetail > 2) newdetail = 2;
54 if (newscreenwidth > 3000) newscreenwidth = screenwidth;
55 if (newscreenwidth < 0) newscreenwidth = screenwidth;
56 if (newscreenheight > 3000) newscreenheight = screenheight;
57 if (newscreenheight < 0) newscreenheight = screenheight;
58 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
59 opstream << "Screenwidth:\n";
60 opstream << newscreenwidth;
61 opstream << "\nScreenheight:\n";
62 opstream << newscreenheight;
63 opstream << "\nMouse sensitivity:\n";
64 opstream << usermousesensitivity;
65 opstream << "\nBlur(0,1):\n";
66 opstream << ismotionblur;
67 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
68 opstream << newdetail;
69 opstream << "\nFloating jump:\n";
70 opstream << floatjump;
71 opstream << "\nMouse jump:\n";
72 opstream << mousejump;
73 opstream << "\nAmbient sound:\n";
74 opstream << ambientsound;
75 opstream << "\nBlood (0,1,2):\n";
76 opstream << bloodtoggle;
77 opstream << "\nAuto slomo:\n";
78 opstream << autoslomo;
79 opstream << "\nFoliage:\n";
81 opstream << "\nMusic:\n";
82 opstream << musictoggle;
83 opstream << "\nTrilinear:\n";
84 opstream << trilinear;
85 opstream << "\nDecals(shadows,blood puddles,etc):\n";
87 opstream << "\nInvert mouse:\n";
88 opstream << invertmouse;
89 opstream << "\nGamespeed:\n";
90 if (oldgamespeed == 0)oldgamespeed = 1;
91 opstream << oldgamespeed;
92 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
93 opstream << difficulty;
94 opstream << "\nDamage effects(blackout, doublevision):\n";
95 opstream << damageeffects;
96 opstream << "\nText:\n";
97 opstream << texttoggle;
98 opstream << "\nDebug:\n";
99 opstream << debugmode;
100 opstream << "\nVBL Sync:\n";
102 opstream << "\nShow Points:\n";
103 opstream << showpoints;
104 opstream << "\nAlways Blur:\n";
105 opstream << alwaysblur;
106 opstream << "\nImmediate mode (turn on on G5):\n";
107 opstream << immediate;
108 opstream << "\nVelocity blur:\n";
109 opstream << velocityblur;
110 opstream << "\nVolume:\n";
112 opstream << "\nForward key:\n";
113 opstream << Input::keyToChar(forwardkey);
114 opstream << "\nBack key:\n";
115 opstream << Input::keyToChar(backkey);
116 opstream << "\nLeft key:\n";
117 opstream << Input::keyToChar(leftkey);
118 opstream << "\nRight key:\n";
119 opstream << Input::keyToChar(rightkey);
120 opstream << "\nJump key:\n";
121 opstream << Input::keyToChar(jumpkey);
122 opstream << "\nCrouch key:\n";
123 opstream << Input::keyToChar(crouchkey);
124 opstream << "\nDraw key:\n";
125 opstream << Input::keyToChar(drawkey);
126 opstream << "\nThrow key:\n";
127 opstream << Input::keyToChar(throwkey);
128 opstream << "\nAttack key:\n";
129 opstream << Input::keyToChar(attackkey);
130 opstream << "\nConsole key:\n";
131 opstream << Input::keyToChar(consolekey);
132 opstream << "\nChat key:\n";
133 opstream << Input::keyToChar(chatkey);
134 opstream << "\nDamage bar:\n";
135 opstream << showdamagebar;
136 opstream << "\nStereoMode:\n";
137 opstream << stereomode;
138 opstream << "\nStereoSeparation:\n";
139 opstream << stereoseparation;
140 opstream << "\nStereoReverse:\n";
141 opstream << stereoreverse;
147 ifstream ipstream(ConvertFileName(":Data:config.txt"), std::ios::in);
148 if ( !ipstream || ipstream.fail() ) {
149 printf("Config file not found\n");
155 printf("Loading config\n");
156 while (!ipstream.eof()) {
157 ipstream.getline( setting, sizeof(setting) );
160 // assume lines starting with spaces are all blank
161 if ( strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t') continue;
162 //~ printf("setting : %s\n",setting);
164 if ( ipstream.eof() || ipstream.fail() ) {
165 fprintf(stderr, "Error reading config file: Got setting name '%s', but value can't be read\n", setting);
171 if ( !strncmp(setting, "Screenwidth", 11) ) {
172 ipstream >> kContextWidth;
173 } else if ( !strncmp(setting, "Screenheight", 12) ) {
174 ipstream >> kContextHeight;
175 } else if ( !strncmp(setting, "Mouse sensitivity", 17) ) {
176 ipstream >> usermousesensitivity;
177 } else if ( !strncmp(setting, "Blur", 4) ) {
178 ipstream >> ismotionblur;
179 } else if ( !strncmp(setting, "Overall Detail", 14) ) {
181 if (detail != 0)kBitsPerPixel = 32;
182 else kBitsPerPixel = 16;
183 } else if ( !strncmp(setting, "Floating jump", 13) ) {
184 ipstream >> floatjump;
185 } else if ( !strncmp(setting, "Mouse jump", 10) ) {
186 ipstream >> mousejump;
187 } else if ( !strncmp(setting, "Ambient sound", 13) ) {
188 ipstream >> ambientsound;
189 } else if ( !strncmp(setting, "Blood ", 6) ) {
190 ipstream >> bloodtoggle;
191 } else if ( !strncmp(setting, "Auto slomo", 10) ) {
192 ipstream >> autoslomo;
193 } else if ( !strncmp(setting, "Foliage", 7) ) {
195 } else if ( !strncmp(setting, "Music", 5) ) {
196 ipstream >> musictoggle;
197 } else if ( !strncmp(setting, "Trilinear", 9) ) {
198 ipstream >> trilinear;
199 } else if ( !strncmp(setting, "Decals", 6) ) {
201 } else if ( !strncmp(setting, "Invert mouse", 12) ) {
202 ipstream >> invertmouse;
203 } else if ( !strncmp(setting, "Gamespeed", 9) ) {
204 ipstream >> gamespeed;
205 oldgamespeed = gamespeed;
206 if (oldgamespeed == 0) {
210 } else if ( !strncmp(setting, "Difficulty", 10) ) {
211 ipstream >> difficulty;
212 } else if ( !strncmp(setting, "Damage effects", 14) ) {
213 ipstream >> damageeffects;
214 } else if ( !strncmp(setting, "Text", 4) ) {
215 ipstream >> texttoggle;
216 } else if ( !strncmp(setting, "Debug", 5) ) {
217 ipstream >> debugmode;
218 } else if ( !strncmp(setting, "VBL Sync", 8) ) {
220 } else if ( !strncmp(setting, "Show Points", 11) ) {
221 ipstream >> showpoints;
222 } else if ( !strncmp(setting, "Always Blur", 11) ) {
223 ipstream >> alwaysblur;
224 } else if ( !strncmp(setting, "Immediate mode ", 15) ) {
225 ipstream >> immediate;
226 } else if ( !strncmp(setting, "Velocity blur", 13) ) {
227 ipstream >> velocityblur;
228 } else if ( !strncmp(setting, "Volume", 6) ) {
230 } else if ( !strncmp(setting, "Forward key", 11) ) {
231 ipstream.getline( string, sizeof(string) );
232 forwardkey = Input::CharToKey(string);
233 } else if ( !strncmp(setting, "Back key", 8) ) {
234 ipstream.getline( string, sizeof(string) );
235 backkey = Input::CharToKey(string);
236 } else if ( !strncmp(setting, "Left key", 8) ) {
237 ipstream.getline( string, sizeof(string) );
238 leftkey = Input::CharToKey(string);
239 } else if ( !strncmp(setting, "Right key", 9) ) {
240 ipstream.getline( string, sizeof(string) );
241 rightkey = Input::CharToKey(string);
242 } else if ( !strncmp(setting, "Jump key", 8) ) {
243 ipstream.getline( string, sizeof(string) );
244 jumpkey = Input::CharToKey(string);
245 } else if ( !strncmp(setting, "Crouch key", 10) ) {
246 ipstream.getline( string, sizeof(string) );
247 crouchkey = Input::CharToKey(string);
248 } else if ( !strncmp(setting, "Draw key", 8) ) {
249 ipstream.getline( string, sizeof(string) );
250 drawkey = Input::CharToKey(string);
251 } else if ( !strncmp(setting, "Throw key", 9) ) {
252 ipstream.getline( string, sizeof(string) );
253 throwkey = Input::CharToKey(string);
254 } else if ( !strncmp(setting, "Attack key", 10) ) {
255 ipstream.getline( string, sizeof(string) );
256 attackkey = Input::CharToKey(string);
257 } else if ( !strncmp(setting, "Console key", 11) ) {
258 ipstream.getline( string, sizeof(string) );
259 consolekey = Input::CharToKey(string);
260 } else if ( !strncmp(setting, "Chat key", 8) ) {
261 ipstream.getline( string, sizeof(string) );
262 chatkey = Input::CharToKey(string);
263 } else if ( !strncmp(setting, "Damage bar", 10) ) {
264 ipstream >> showdamagebar;
265 } else if ( !strncmp(setting, "StereoMode", 10) ) {
268 stereomode = (StereoMode)i;
269 } else if ( !strncmp(setting, "StereoSeparation", 16) ) {
270 ipstream >> stereoseparation;
271 } else if ( !strncmp(setting, "StereoReverse", 13) ) {
272 ipstream >> stereoreverse;
275 fprintf(stderr, "Unknown config option '%s' with value '%s'. Ignoring.\n", setting, string);
278 if ( ipstream.fail() ) {
279 fprintf(stderr, "Error reading config file: EOF reached when trying to read value for setting '%s'.\n", setting);
284 if ( ipstream.bad() ) {
285 fprintf(stderr, "Error reading config file: Failed to read value for setting '%s'.\n", setting);
293 if (detail > 2)detail = 2;
294 if (detail < 0)detail = 0;
295 if (screenwidth < 0)screenwidth = 640;
296 if (screenheight < 0)screenheight = 480;