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