2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 void DefaultSettings()
32 usermousesensitivity = 1;
33 newscreenwidth = kContextWidth = 640;
34 newscreenheight = kContextHeight = 480;
58 crouchkey = SDL_SCANCODE_LSHIFT;
59 jumpkey = SDL_SCANCODE_SPACE;
60 leftkey = SDL_SCANCODE_A;
61 forwardkey = SDL_SCANCODE_W;
62 backkey = SDL_SCANCODE_S;
63 rightkey = SDL_SCANCODE_D;
64 drawkey = SDL_SCANCODE_E;
65 throwkey = SDL_SCANCODE_Q;
66 attackkey = MOUSEBUTTON1;
67 consolekey = SDL_SCANCODE_GRAVE;
68 chatkey = SDL_SCANCODE_T;
77 if (newscreenwidth > 3000)
78 newscreenwidth = screenwidth;
79 if (newscreenwidth < 0)
80 newscreenwidth = screenwidth;
81 if (newscreenheight > 3000)
82 newscreenheight = screenheight;
83 if (newscreenheight < 0)
84 newscreenheight = screenheight;
85 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
86 opstream << "Screenwidth:\n";
87 opstream << newscreenwidth;
88 opstream << "\nScreenheight:\n";
89 opstream << newscreenheight;
90 opstream << "\nMouse sensitivity:\n";
91 opstream << usermousesensitivity;
92 opstream << "\nBlur(0,1):\n";
93 opstream << ismotionblur;
94 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
95 opstream << newdetail;
96 opstream << "\nFloating jump:\n";
97 opstream << floatjump;
98 opstream << "\nMouse jump:\n";
99 opstream << mousejump;
100 opstream << "\nAmbient sound:\n";
101 opstream << ambientsound;
102 opstream << "\nBlood (0,1,2):\n";
103 opstream << bloodtoggle;
104 opstream << "\nAuto slomo:\n";
105 opstream << autoslomo;
106 opstream << "\nFoliage:\n";
108 opstream << "\nMusic:\n";
109 opstream << musictoggle;
110 opstream << "\nTrilinear:\n";
111 opstream << trilinear;
112 opstream << "\nDecals(shadows,blood puddles,etc):\n";
114 opstream << "\nInvert mouse:\n";
115 opstream << invertmouse;
116 opstream << "\nGamespeed:\n";
117 if (oldgamespeed == 0)
119 opstream << oldgamespeed;
120 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
121 opstream << difficulty;
122 opstream << "\nDamage effects(blackout, doublevision):\n";
123 opstream << damageeffects;
124 opstream << "\nText:\n";
125 opstream << texttoggle;
126 opstream << "\nDebug:\n";
127 opstream << debugmode;
128 opstream << "\nVBL Sync:\n";
130 opstream << "\nShow Points:\n";
131 opstream << showpoints;
132 opstream << "\nAlways Blur:\n";
133 opstream << alwaysblur;
134 opstream << "\nImmediate mode (turn on on G5):\n";
135 opstream << immediate;
136 opstream << "\nVelocity blur:\n";
137 opstream << velocityblur;
138 opstream << "\nVolume:\n";
140 opstream << "\nForward key:\n";
141 opstream << forwardkey;
142 opstream << "\nBack key:\n";
144 opstream << "\nLeft key:\n";
146 opstream << "\nRight key:\n";
147 opstream << rightkey;
148 opstream << "\nJump key:\n";
150 opstream << "\nCrouch key:\n";
151 opstream << crouchkey;
152 opstream << "\nDraw key:\n";
154 opstream << "\nThrow key:\n";
155 opstream << throwkey;
156 opstream << "\nAttack key:\n";
157 opstream << attackkey;
158 opstream << "\nConsole key:\n";
159 opstream << consolekey;
160 opstream << "\nChat key:\n";
162 opstream << "\nDamage bar:\n";
163 opstream << showdamagebar;
164 opstream << "\nStereoMode:\n";
165 opstream << stereomode;
166 opstream << "\nStereoSeparation:\n";
167 opstream << stereoseparation;
168 opstream << "\nStereoReverse:\n";
169 opstream << stereoreverse;
175 ifstream ipstream(ConvertFileName(":Data:config.txt"), std::ios::in);
176 if ( !ipstream || ipstream.fail() ) {
177 printf("Config file not found\n");
183 printf("Loading config\n");
184 while (!ipstream.eof()) {
185 ipstream.getline( setting, sizeof(setting) );
188 // assume lines starting with spaces are all blank
189 if ( strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t')
191 //~ printf("setting : %s\n",setting);
193 if ( ipstream.eof() || ipstream.fail() ) {
194 fprintf(stderr, "Error reading config file: Got setting name '%s', but value can't be read\n", setting);
200 if ( !strncmp(setting, "Screenwidth", 11) ) {
201 ipstream >> kContextWidth;
202 } else if ( !strncmp(setting, "Screenheight", 12) ) {
203 ipstream >> kContextHeight;
204 } else if ( !strncmp(setting, "Mouse sensitivity", 17) ) {
205 ipstream >> usermousesensitivity;
206 } else if ( !strncmp(setting, "Blur", 4) ) {
207 ipstream >> ismotionblur;
208 } else if ( !strncmp(setting, "Overall Detail", 14) ) {
214 } else if ( !strncmp(setting, "Floating jump", 13) ) {
215 ipstream >> floatjump;
216 } else if ( !strncmp(setting, "Mouse jump", 10) ) {
217 ipstream >> mousejump;
218 } else if ( !strncmp(setting, "Ambient sound", 13) ) {
219 ipstream >> ambientsound;
220 } else if ( !strncmp(setting, "Blood ", 6) ) {
221 ipstream >> bloodtoggle;
222 } else if ( !strncmp(setting, "Auto slomo", 10) ) {
223 ipstream >> autoslomo;
224 } else if ( !strncmp(setting, "Foliage", 7) ) {
226 } else if ( !strncmp(setting, "Music", 5) ) {
227 ipstream >> musictoggle;
228 } else if ( !strncmp(setting, "Trilinear", 9) ) {
229 ipstream >> trilinear;
230 } else if ( !strncmp(setting, "Decals", 6) ) {
232 } else if ( !strncmp(setting, "Invert mouse", 12) ) {
233 ipstream >> invertmouse;
234 } else if ( !strncmp(setting, "Gamespeed", 9) ) {
235 ipstream >> gamespeed;
236 oldgamespeed = gamespeed;
237 if (oldgamespeed == 0) {
241 } else if ( !strncmp(setting, "Difficulty", 10) ) {
242 ipstream >> difficulty;
243 } else if ( !strncmp(setting, "Damage effects", 14) ) {
244 ipstream >> damageeffects;
245 } else if ( !strncmp(setting, "Text", 4) ) {
246 ipstream >> texttoggle;
247 } else if ( !strncmp(setting, "Debug", 5) ) {
248 ipstream >> debugmode;
249 } else if ( !strncmp(setting, "VBL Sync", 8) ) {
251 } else if ( !strncmp(setting, "Show Points", 11) ) {
252 ipstream >> showpoints;
253 } else if ( !strncmp(setting, "Always Blur", 11) ) {
254 ipstream >> alwaysblur;
255 } else if ( !strncmp(setting, "Immediate mode ", 15) ) {
256 ipstream >> immediate;
257 } else if ( !strncmp(setting, "Velocity blur", 13) ) {
258 ipstream >> velocityblur;
259 } else if ( !strncmp(setting, "Volume", 6) ) {
261 } else if ( !strncmp(setting, "Forward key", 11) ) {
262 ipstream >> forwardkey;
263 } else if ( !strncmp(setting, "Back key", 8) ) {
265 } else if ( !strncmp(setting, "Left key", 8) ) {
267 } else if ( !strncmp(setting, "Right key", 9) ) {
268 ipstream >> rightkey;
269 } else if ( !strncmp(setting, "Jump key", 8) ) {
271 } else if ( !strncmp(setting, "Crouch key", 10) ) {
272 ipstream >> crouchkey;
273 } else if ( !strncmp(setting, "Draw key", 8) ) {
275 } else if ( !strncmp(setting, "Throw key", 9) ) {
276 ipstream >> throwkey;
277 } else if ( !strncmp(setting, "Attack key", 10) ) {
278 ipstream >> attackkey;
279 } else if ( !strncmp(setting, "Console key", 11) ) {
280 ipstream >> consolekey;
281 } else if ( !strncmp(setting, "Chat key", 8) ) {
283 } else if ( !strncmp(setting, "Damage bar", 10) ) {
284 ipstream >> showdamagebar;
285 } else if ( !strncmp(setting, "StereoMode", 10) ) {
288 stereomode = (StereoMode)i;
289 } else if ( !strncmp(setting, "StereoSeparation", 16) ) {
290 ipstream >> stereoseparation;
291 } else if ( !strncmp(setting, "StereoReverse", 13) ) {
292 ipstream >> stereoreverse;
295 fprintf(stderr, "Unknown config option '%s' with value '%s'. Ignoring.\n", setting, string);
298 if ( ipstream.fail() ) {
299 fprintf(stderr, "Error reading config file: EOF reached when trying to read value for setting '%s'.\n", setting);
304 if ( ipstream.bad() ) {
305 fprintf(stderr, "Error reading config file: Failed to read value for setting '%s'.\n", setting);
319 if (screenheight < 0)