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