2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
5 This file is part of Lugaru.
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
27 void DefaultSettings()
31 usermousesensitivity = 1;
32 newscreenwidth = kContextWidth = 1024;
33 newscreenheight = kContextHeight = 768;
56 crouchkey = SDL_SCANCODE_LSHIFT;
57 jumpkey = SDL_SCANCODE_SPACE;
58 leftkey = SDL_SCANCODE_A;
59 forwardkey = SDL_SCANCODE_W;
60 backkey = SDL_SCANCODE_S;
61 rightkey = SDL_SCANCODE_D;
62 drawkey = SDL_SCANCODE_E;
63 throwkey = SDL_SCANCODE_Q;
64 attackkey = MOUSEBUTTON1;
65 consolekey = SDL_SCANCODE_GRAVE;
74 if (newscreenwidth > 3000)
75 newscreenwidth = screenwidth;
76 if (newscreenwidth < 0)
77 newscreenwidth = screenwidth;
78 if (newscreenheight > 3000)
79 newscreenheight = screenheight;
80 if (newscreenheight < 0)
81 newscreenheight = screenheight;
82 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
83 opstream << "Screenwidth:\n";
84 opstream << newscreenwidth;
85 opstream << "\nScreenheight:\n";
86 opstream << newscreenheight;
87 opstream << "\nFullscreen:\n";
88 opstream << fullscreen;
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 << "\nShow Points:\n";
128 opstream << showpoints;
129 opstream << "\nAlways Blur:\n";
130 opstream << alwaysblur;
131 opstream << "\nImmediate mode (turn on on G5):\n";
132 opstream << immediate;
133 opstream << "\nVelocity blur:\n";
134 opstream << velocityblur;
135 opstream << "\nVolume:\n";
137 opstream << "\nForward key:\n";
138 opstream << forwardkey;
139 opstream << "\nBack key:\n";
141 opstream << "\nLeft key:\n";
143 opstream << "\nRight key:\n";
144 opstream << rightkey;
145 opstream << "\nJump key:\n";
147 opstream << "\nCrouch key:\n";
148 opstream << crouchkey;
149 opstream << "\nDraw key:\n";
151 opstream << "\nThrow key:\n";
152 opstream << throwkey;
153 opstream << "\nAttack key:\n";
154 opstream << attackkey;
155 opstream << "\nConsole key:\n";
156 opstream << consolekey;
157 opstream << "\nDamage bar:\n";
158 opstream << showdamagebar;
159 opstream << "\nStereoMode:\n";
160 opstream << stereomode;
161 opstream << "\nStereoSeparation:\n";
162 opstream << stereoseparation;
163 opstream << "\nStereoReverse:\n";
164 opstream << stereoreverse;
170 ifstream ipstream(ConvertFileName(":Data:config.txt"), std::ios::in);
171 if ( !ipstream || ipstream.fail() ) {
172 printf("Config file not found\n");
178 printf("Loading config\n");
179 while (!ipstream.eof()) {
180 ipstream.getline( setting, sizeof(setting) );
183 // assume lines starting with spaces are all blank
184 if ( strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t')
186 //~ printf("setting : %s\n",setting);
188 if ( ipstream.eof() || ipstream.fail() ) {
189 fprintf(stderr, "Error reading config file: Got setting name '%s', but value can't be read\n", setting);
195 if ( !strncmp(setting, "Screenwidth", 11) ) {
196 ipstream >> kContextWidth;
197 } else if ( !strncmp(setting, "Screenheight", 12) ) {
198 ipstream >> kContextHeight;
199 } else if ( !strncmp(setting, "Fullscreen", 10) ) {
200 ipstream >> fullscreen;
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) ) {
207 } else if ( !strncmp(setting, "Floating jump", 13) ) {
208 ipstream >> floatjump;
209 } else if ( !strncmp(setting, "Mouse jump", 10) ) {
210 ipstream >> mousejump;
211 } else if ( !strncmp(setting, "Ambient sound", 13) ) {
212 ipstream >> ambientsound;
213 } else if ( !strncmp(setting, "Blood ", 6) ) {
214 ipstream >> bloodtoggle;
215 } else if ( !strncmp(setting, "Auto slomo", 10) ) {
216 ipstream >> autoslomo;
217 } else if ( !strncmp(setting, "Foliage", 7) ) {
219 } else if ( !strncmp(setting, "Music", 5) ) {
220 ipstream >> musictoggle;
221 } else if ( !strncmp(setting, "Trilinear", 9) ) {
222 ipstream >> trilinear;
223 } else if ( !strncmp(setting, "Decals", 6) ) {
225 } else if ( !strncmp(setting, "Invert mouse", 12) ) {
226 ipstream >> invertmouse;
227 } else if ( !strncmp(setting, "Gamespeed", 9) ) {
228 ipstream >> gamespeed;
229 oldgamespeed = gamespeed;
230 if (oldgamespeed == 0) {
234 } else if ( !strncmp(setting, "Difficulty", 10) ) {
235 ipstream >> difficulty;
236 } else if ( !strncmp(setting, "Damage effects", 14) ) {
237 ipstream >> damageeffects;
238 } else if ( !strncmp(setting, "Text", 4) ) {
239 ipstream >> texttoggle;
240 } else if ( !strncmp(setting, "Debug", 5) ) {
241 ipstream >> debugmode;
242 } else if ( !strncmp(setting, "Show Points", 11) ) {
243 ipstream >> showpoints;
244 } else if ( !strncmp(setting, "Always Blur", 11) ) {
245 ipstream >> alwaysblur;
246 } else if ( !strncmp(setting, "Immediate mode ", 15) ) {
247 ipstream >> immediate;
248 } else if ( !strncmp(setting, "Velocity blur", 13) ) {
249 ipstream >> velocityblur;
250 } else if ( !strncmp(setting, "Volume", 6) ) {
252 } else if ( !strncmp(setting, "Forward key", 11) ) {
253 ipstream >> forwardkey;
254 } else if ( !strncmp(setting, "Back key", 8) ) {
256 } else if ( !strncmp(setting, "Left key", 8) ) {
258 } else if ( !strncmp(setting, "Right key", 9) ) {
259 ipstream >> rightkey;
260 } else if ( !strncmp(setting, "Jump key", 8) ) {
262 } else if ( !strncmp(setting, "Crouch key", 10) ) {
263 ipstream >> crouchkey;
264 } else if ( !strncmp(setting, "Draw key", 8) ) {
266 } else if ( !strncmp(setting, "Throw key", 9) ) {
267 ipstream >> throwkey;
268 } else if ( !strncmp(setting, "Attack key", 10) ) {
269 ipstream >> attackkey;
270 } else if ( !strncmp(setting, "Console key", 11) ) {
271 ipstream >> consolekey;
272 } else if ( !strncmp(setting, "Damage bar", 10) ) {
273 ipstream >> showdamagebar;
274 } else if ( !strncmp(setting, "StereoMode", 10) ) {
277 stereomode = (StereoMode)i;
278 } else if ( !strncmp(setting, "StereoSeparation", 16) ) {
279 ipstream >> stereoseparation;
280 } else if ( !strncmp(setting, "StereoReverse", 13) ) {
281 ipstream >> stereoreverse;
284 fprintf(stderr, "Unknown config option '%s' with value '%s'. Ignoring.\n", setting, string);
287 if ( ipstream.fail() ) {
288 fprintf(stderr, "Error reading config file: EOF reached when trying to read value for setting '%s'.\n", setting);
293 if ( ipstream.bad() ) {
294 fprintf(stderr, "Error reading config file: Failed to read value for setting '%s'.\n", setting);
308 if (screenheight < 0)