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