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