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;
76 if (newscreenwidth > 3000)
77 newscreenwidth = screenwidth;
78 if (newscreenwidth < 0)
79 newscreenwidth = screenwidth;
80 if (newscreenheight > 3000)
81 newscreenheight = screenheight;
82 if (newscreenheight < 0)
83 newscreenheight = screenheight;
84 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
85 opstream << "Screenwidth:\n";
86 opstream << newscreenwidth;
87 opstream << "\nScreenheight:\n";
88 opstream << newscreenheight;
89 opstream << "\nMouse sensitivity:\n";
90 opstream << usermousesensitivity;
91 opstream << "\nBlur(0,1):\n";
92 opstream << ismotionblur;
93 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
94 opstream << newdetail;
95 opstream << "\nFloating jump:\n";
96 opstream << floatjump;
97 opstream << "\nMouse jump:\n";
98 opstream << mousejump;
99 opstream << "\nAmbient sound:\n";
100 opstream << ambientsound;
101 opstream << "\nBlood (0,1,2):\n";
102 opstream << bloodtoggle;
103 opstream << "\nAuto slomo:\n";
104 opstream << autoslomo;
105 opstream << "\nFoliage:\n";
107 opstream << "\nMusic:\n";
108 opstream << musictoggle;
109 opstream << "\nTrilinear:\n";
110 opstream << trilinear;
111 opstream << "\nDecals(shadows,blood puddles,etc):\n";
113 opstream << "\nInvert mouse:\n";
114 opstream << invertmouse;
115 opstream << "\nGamespeed:\n";
116 if (oldgamespeed == 0)
118 opstream << oldgamespeed;
119 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
120 opstream << difficulty;
121 opstream << "\nDamage effects(blackout, doublevision):\n";
122 opstream << damageeffects;
123 opstream << "\nText:\n";
124 opstream << texttoggle;
125 opstream << "\nDebug:\n";
126 opstream << debugmode;
127 opstream << "\nVBL Sync:\n";
129 opstream << "\nShow Points:\n";
130 opstream << showpoints;
131 opstream << "\nAlways Blur:\n";
132 opstream << alwaysblur;
133 opstream << "\nImmediate mode (turn on on G5):\n";
134 opstream << immediate;
135 opstream << "\nVelocity blur:\n";
136 opstream << velocityblur;
137 opstream << "\nVolume:\n";
139 opstream << "\nForward key:\n";
140 opstream << forwardkey;
141 opstream << "\nBack key:\n";
143 opstream << "\nLeft key:\n";
145 opstream << "\nRight key:\n";
146 opstream << rightkey;
147 opstream << "\nJump key:\n";
149 opstream << "\nCrouch key:\n";
150 opstream << crouchkey;
151 opstream << "\nDraw key:\n";
153 opstream << "\nThrow key:\n";
154 opstream << throwkey;
155 opstream << "\nAttack key:\n";
156 opstream << attackkey;
157 opstream << "\nConsole key:\n";
158 opstream << consolekey;
159 opstream << "\nDamage bar:\n";
160 opstream << showdamagebar;
161 opstream << "\nStereoMode:\n";
162 opstream << stereomode;
163 opstream << "\nStereoSeparation:\n";
164 opstream << stereoseparation;
165 opstream << "\nStereoReverse:\n";
166 opstream << stereoreverse;
172 ifstream ipstream(ConvertFileName(":Data:config.txt"), std::ios::in);
173 if ( !ipstream || ipstream.fail() ) {
174 printf("Config file not found\n");
180 printf("Loading config\n");
181 while (!ipstream.eof()) {
182 ipstream.getline( setting, sizeof(setting) );
185 // assume lines starting with spaces are all blank
186 if ( strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t')
188 //~ printf("setting : %s\n",setting);
190 if ( ipstream.eof() || ipstream.fail() ) {
191 fprintf(stderr, "Error reading config file: Got setting name '%s', but value can't be read\n", setting);
197 if ( !strncmp(setting, "Screenwidth", 11) ) {
198 ipstream >> kContextWidth;
199 } else if ( !strncmp(setting, "Screenheight", 12) ) {
200 ipstream >> kContextHeight;
201 } else if ( !strncmp(setting, "Mouse sensitivity", 17) ) {
202 ipstream >> usermousesensitivity;
203 } else if ( !strncmp(setting, "Blur", 4) ) {
204 ipstream >> ismotionblur;
205 } else if ( !strncmp(setting, "Overall Detail", 14) ) {
211 } else if ( !strncmp(setting, "Floating jump", 13) ) {
212 ipstream >> floatjump;
213 } else if ( !strncmp(setting, "Mouse jump", 10) ) {
214 ipstream >> mousejump;
215 } else if ( !strncmp(setting, "Ambient sound", 13) ) {
216 ipstream >> ambientsound;
217 } else if ( !strncmp(setting, "Blood ", 6) ) {
218 ipstream >> bloodtoggle;
219 } else if ( !strncmp(setting, "Auto slomo", 10) ) {
220 ipstream >> autoslomo;
221 } else if ( !strncmp(setting, "Foliage", 7) ) {
223 } else if ( !strncmp(setting, "Music", 5) ) {
224 ipstream >> musictoggle;
225 } else if ( !strncmp(setting, "Trilinear", 9) ) {
226 ipstream >> trilinear;
227 } else if ( !strncmp(setting, "Decals", 6) ) {
229 } else if ( !strncmp(setting, "Invert mouse", 12) ) {
230 ipstream >> invertmouse;
231 } else if ( !strncmp(setting, "Gamespeed", 9) ) {
232 ipstream >> gamespeed;
233 oldgamespeed = gamespeed;
234 if (oldgamespeed == 0) {
238 } else if ( !strncmp(setting, "Difficulty", 10) ) {
239 ipstream >> difficulty;
240 } else if ( !strncmp(setting, "Damage effects", 14) ) {
241 ipstream >> damageeffects;
242 } else if ( !strncmp(setting, "Text", 4) ) {
243 ipstream >> texttoggle;
244 } else if ( !strncmp(setting, "Debug", 5) ) {
245 ipstream >> debugmode;
246 } else if ( !strncmp(setting, "VBL Sync", 8) ) {
248 } else if ( !strncmp(setting, "Show Points", 11) ) {
249 ipstream >> showpoints;
250 } else if ( !strncmp(setting, "Always Blur", 11) ) {
251 ipstream >> alwaysblur;
252 } else if ( !strncmp(setting, "Immediate mode ", 15) ) {
253 ipstream >> immediate;
254 } else if ( !strncmp(setting, "Velocity blur", 13) ) {
255 ipstream >> velocityblur;
256 } else if ( !strncmp(setting, "Volume", 6) ) {
258 } else if ( !strncmp(setting, "Forward key", 11) ) {
259 ipstream >> forwardkey;
260 } else if ( !strncmp(setting, "Back key", 8) ) {
262 } else if ( !strncmp(setting, "Left key", 8) ) {
264 } else if ( !strncmp(setting, "Right key", 9) ) {
265 ipstream >> rightkey;
266 } else if ( !strncmp(setting, "Jump key", 8) ) {
268 } else if ( !strncmp(setting, "Crouch key", 10) ) {
269 ipstream >> crouchkey;
270 } else if ( !strncmp(setting, "Draw key", 8) ) {
272 } else if ( !strncmp(setting, "Throw key", 9) ) {
273 ipstream >> throwkey;
274 } else if ( !strncmp(setting, "Attack key", 10) ) {
275 ipstream >> attackkey;
276 } else if ( !strncmp(setting, "Console key", 11) ) {
277 ipstream >> consolekey;
278 } else if ( !strncmp(setting, "Damage bar", 10) ) {
279 ipstream >> showdamagebar;
280 } else if ( !strncmp(setting, "StereoMode", 10) ) {
283 stereomode = (StereoMode)i;
284 } else if ( !strncmp(setting, "StereoSeparation", 16) ) {
285 ipstream >> stereoseparation;
286 } else if ( !strncmp(setting, "StereoReverse", 13) ) {
287 ipstream >> stereoreverse;
290 fprintf(stderr, "Unknown config option '%s' with value '%s'. Ignoring.\n", setting, string);
293 if ( ipstream.fail() ) {
294 fprintf(stderr, "Error reading config file: EOF reached when trying to read value for setting '%s'.\n", setting);
299 if ( ipstream.bad() ) {
300 fprintf(stderr, "Error reading config file: Failed to read value for setting '%s'.\n", setting);
314 if (screenheight < 0)