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;
148 printf("setting : %s\n",setting);
150 if ( ipstream.eof() || ipstream.fail() ) {
151 fprintf(stderr, "Error reading config file: Got setting name '%s', but value can't be read\n", setting);
157 if ( !strncmp(setting, "Screenwidth", 11) ) {
158 ipstream >> kContextWidth;
159 } else if ( !strncmp(setting, "Screenheight", 12) ) {
160 ipstream >> kContextHeight;
161 } else if ( !strncmp(setting, "Mouse sensitivity", 17) ) {
162 ipstream >> usermousesensitivity;
163 } else if ( !strncmp(setting, "Blur", 4) ) {
164 ipstream >> ismotionblur;
165 } else if ( !strncmp(setting, "Overall Detail", 14) ) {
167 if(detail!=0)kBitsPerPixel=32;
168 else kBitsPerPixel=16;
169 } else if ( !strncmp(setting, "Floating jump", 13) ) {
170 ipstream >> floatjump;
171 } else if ( !strncmp(setting, "Mouse jump", 10) ) {
172 ipstream >> mousejump;
173 } else if ( !strncmp(setting, "Ambient sound", 13) ) {
174 ipstream >> ambientsound;
175 } else if ( !strncmp(setting, "Blood ", 6) ) {
176 ipstream >> bloodtoggle;
177 } else if ( !strncmp(setting, "Auto slomo", 10) ) {
178 ipstream >> autoslomo;
179 } else if ( !strncmp(setting, "Foliage", 7) ) {
181 } else if ( !strncmp(setting, "Music", 5) ) {
182 ipstream >> musictoggle;
183 } else if ( !strncmp(setting, "Trilinear", 9) ) {
184 ipstream >> trilinear;
185 } else if ( !strncmp(setting, "Decals", 6) ) {
187 } else if ( !strncmp(setting, "Invert mouse", 12) ) {
188 ipstream >> invertmouse;
189 } else if ( !strncmp(setting, "Gamespeed", 9) ) {
190 ipstream >> gamespeed;
191 oldgamespeed=gamespeed;
196 } else if ( !strncmp(setting, "Difficulty", 10) ) {
197 ipstream >> difficulty;
198 } else if ( !strncmp(setting, "Damage effects", 14) ) {
199 ipstream >> damageeffects;
200 } else if ( !strncmp(setting, "Text", 4) ) {
201 ipstream >> texttoggle;
202 } else if ( !strncmp(setting, "Debug", 5) ) {
203 ipstream >> debugmode;
204 } else if ( !strncmp(setting, "VBL Sync", 8) ) {
206 } else if ( !strncmp(setting, "Show Points", 11) ) {
207 ipstream >> showpoints;
208 } else if ( !strncmp(setting, "Always Blur", 11) ) {
209 ipstream >> alwaysblur;
210 } else if ( !strncmp(setting, "Immediate mode ", 15) ) {
211 ipstream >> immediate;
212 } else if ( !strncmp(setting, "Velocity blur", 13) ) {
213 ipstream >> velocityblur;
214 } else if ( !strncmp(setting, "Volume", 6) ) {
216 } else if ( !strncmp(setting, "Forward key", 11) ) {
217 ipstream.getline( string, sizeof(string) );
218 game.forwardkey = Input::CharToKey(string);
219 } else if ( !strncmp(setting, "Back key", 8) ) {
220 ipstream.getline( string, sizeof(string) );
221 game.backkey = Input::CharToKey(string);
222 } else if ( !strncmp(setting, "Left key", 8) ) {
223 ipstream.getline( string, sizeof(string) );
224 game.leftkey = Input::CharToKey(string);
225 } else if ( !strncmp(setting, "Right key", 9) ) {
226 ipstream.getline( string, sizeof(string) );
227 game.rightkey = Input::CharToKey(string);
228 } else if ( !strncmp(setting, "Jump key", 8) ) {
229 ipstream.getline( string, sizeof(string) );
230 game.jumpkey = Input::CharToKey(string);
231 } else if ( !strncmp(setting, "Crouch key", 10) ) {
232 ipstream.getline( string, sizeof(string) );
233 game.crouchkey = Input::CharToKey(string);
234 } else if ( !strncmp(setting, "Draw key", 8) ) {
235 ipstream.getline( string, sizeof(string) );
236 game.drawkey = Input::CharToKey(string);
237 } else if ( !strncmp(setting, "Throw key", 9) ) {
238 ipstream.getline( string, sizeof(string) );
239 game.throwkey = Input::CharToKey(string);
240 } else if ( !strncmp(setting, "Attack key", 10) ) {
241 ipstream.getline( string, sizeof(string) );
242 game.attackkey = Input::CharToKey(string);
243 } else if ( !strncmp(setting, "Chat key", 8) ) {
244 ipstream.getline( string, sizeof(string) );
245 game.chatkey = Input::CharToKey(string);
246 } else if ( !strncmp(setting, "Damage bar", 10) ) {
247 ipstream >> showdamagebar;
248 } else if ( !strncmp(setting, "StereoMode", 10) ) {
251 stereomode = (StereoMode)i;
252 } else if ( !strncmp(setting, "StereoSeparation", 16) ) {
253 ipstream >> stereoseparation;
254 } else if ( !strncmp(setting, "StereoReverse", 13) ) {
255 ipstream >> stereoreverse;
258 fprintf(stderr, "Unknown config option '%s' with value '%s'. Ignoring.\n", setting, string);
261 if ( ipstream.fail() ) {
262 fprintf(stderr, "Error reading config file: EOF reached when trying to read value for setting '%s'.\n", setting);
267 if ( ipstream.bad() ) {
268 fprintf(stderr, "Error reading config file: Failed to read value for setting '%s'.\n", setting);
276 if(detail>2)detail=2;
277 if(detail<0)detail=0;
278 if(screenwidth<0)screenwidth=640;
279 if(screenheight<0)screenheight=480;