5 void DefaultSettings(Game &game) {
8 usermousesensitivity=1;
33 game.crouchkey=MAC_SHIFT_KEY;
34 game.jumpkey=MAC_SPACE_KEY;
35 game.leftkey=MAC_A_KEY;
36 game.forwardkey=MAC_W_KEY;
37 game.backkey=MAC_S_KEY;
38 game.rightkey=MAC_D_KEY;
39 game.drawkey=MAC_E_KEY;
40 game.throwkey=MAC_Q_KEY;
41 game.attackkey=MAC_MOUSEBUTTON1;
42 game.chatkey=MAC_T_KEY;
45 void SaveSettings(Game &game) {
46 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
47 opstream << "Screenwidth:\n";
48 opstream << game.newscreenwidth;
49 opstream << "\nScreenheight:\n";
50 opstream << game.newscreenheight;
51 opstream << "\nMouse sensitivity:\n";
52 opstream << usermousesensitivity;
53 opstream << "\nBlur(0,1):\n";
54 opstream << ismotionblur;
55 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
56 opstream << game.newdetail;
57 opstream << "\nFloating jump:\n";
58 opstream << floatjump;
59 opstream << "\nMouse jump:\n";
60 opstream << mousejump;
61 opstream << "\nAmbient sound:\n";
62 opstream << ambientsound;
63 opstream << "\nBlood (0,1,2):\n";
64 opstream << bloodtoggle;
65 opstream << "\nAuto slomo:\n";
66 opstream << autoslomo;
67 opstream << "\nFoliage:\n";
69 opstream << "\nMusic:\n";
70 opstream << musictoggle;
71 opstream << "\nTrilinear:\n";
72 opstream << trilinear;
73 opstream << "\nDecals(shadows,blood puddles,etc):\n";
75 opstream << "\nInvert mouse:\n";
76 opstream << invertmouse;
77 opstream << "\nGamespeed:\n";
78 if(oldgamespeed==0)oldgamespeed=1;
79 opstream << oldgamespeed;
80 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
81 opstream << difficulty;
82 opstream << "\nDamage effects(blackout, doublevision):\n";
83 opstream << damageeffects;
84 opstream << "\nText:\n";
85 opstream << texttoggle;
86 opstream << "\nDebug:\n";
87 opstream << debugmode;
88 opstream << "\nVBL Sync:\n";
90 opstream << "\nShow Points:\n";
91 opstream << showpoints;
92 opstream << "\nAlways Blur:\n";
93 opstream << alwaysblur;
94 opstream << "\nImmediate mode (turn on on G5):\n";
95 opstream << immediate;
96 opstream << "\nVelocity blur:\n";
97 opstream << velocityblur;
98 opstream << "\nVolume:\n";
100 opstream << "\nForward key:\n";
101 opstream << KeyToChar(game.forwardkey);
102 opstream << "\nBack key:\n";
103 opstream << KeyToChar(game.backkey);
104 opstream << "\nLeft key:\n";
105 opstream << KeyToChar(game.leftkey);
106 opstream << "\nRight key:\n";
107 opstream << KeyToChar(game.rightkey);
108 opstream << "\nJump key:\n";
109 opstream << KeyToChar(game.jumpkey);
110 opstream << "\nCrouch key:\n";
111 opstream << KeyToChar(game.crouchkey);
112 opstream << "\nDraw key:\n";
113 opstream << KeyToChar(game.drawkey);
114 opstream << "\nThrow key:\n";
115 opstream << KeyToChar(game.throwkey);
116 opstream << "\nAttack key:\n";
117 opstream << KeyToChar(game.attackkey);
118 opstream << "\nChat key:\n";
119 opstream << KeyToChar(game.chatkey);
120 opstream << "\nStereoMode:\n";
121 opstream << stereomode;
122 opstream << "\nStereoSeparation:\n";
123 opstream << stereoseparation;
124 opstream << "\nStereoReverse:\n";
125 opstream << stereoreverse;
130 bool LoadSettings(Game &game) {
131 ifstream ipstream(ConvertFileName(":Data:config.txt"), std::ios::in);
132 if ( !ipstream || ipstream.fail() ) {
133 printf("Config file not found\n");
139 printf("Loading config\n");
140 while(!ipstream.eof()) {
141 ipstream.getline( setting, sizeof(setting) );
144 // assume lines starting with spaces are all blank
145 if ( strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t') continue;
147 if ( ipstream.eof() || ipstream.fail() ) {
148 fprintf(stderr, "Error reading config file: Got setting name '%s', but value can't be read\n", setting);
154 if ( !strncmp(setting, "Screenwidth", 11) ) {
155 ipstream >> kContextWidth;
156 } else if ( !strncmp(setting, "Screenheight", 12) ) {
157 ipstream >> kContextHeight;
158 } else if ( !strncmp(setting, "Mouse sensitivity", 17) ) {
159 ipstream >> usermousesensitivity;
160 } else if ( !strncmp(setting, "Blur", 4) ) {
161 ipstream >> ismotionblur;
162 } else if ( !strncmp(setting, "Overall Detail", 14) ) {
164 if(detail!=0)kBitsPerPixel=32;
165 else kBitsPerPixel=16;
166 } else if ( !strncmp(setting, "Floating jump", 13) ) {
167 ipstream >> floatjump;
168 } else if ( !strncmp(setting, "Mouse jump", 10) ) {
169 ipstream >> mousejump;
170 } else if ( !strncmp(setting, "Ambient sound", 13) ) {
171 ipstream >> ambientsound;
172 } else if ( !strncmp(setting, "Blood ", 6) ) {
173 ipstream >> bloodtoggle;
174 } else if ( !strncmp(setting, "Auto slomo", 10) ) {
175 ipstream >> autoslomo;
176 } else if ( !strncmp(setting, "Foliage", 7) ) {
178 } else if ( !strncmp(setting, "Music", 5) ) {
179 ipstream >> musictoggle;
180 } else if ( !strncmp(setting, "Trilinear", 9) ) {
181 ipstream >> trilinear;
182 } else if ( !strncmp(setting, "Decals", 6) ) {
184 } else if ( !strncmp(setting, "Invert mouse", 12) ) {
185 ipstream >> invertmouse;
186 } else if ( !strncmp(setting, "Gamespeed", 9) ) {
187 ipstream >> gamespeed;
188 oldgamespeed=gamespeed;
193 } else if ( !strncmp(setting, "Difficulty", 10) ) {
194 ipstream >> difficulty;
195 } else if ( !strncmp(setting, "Damage effects", 14) ) {
196 ipstream >> damageeffects;
197 } else if ( !strncmp(setting, "Text", 4) ) {
198 ipstream >> texttoggle;
199 } else if ( !strncmp(setting, "Debug", 5) ) {
200 ipstream >> debugmode;
201 } else if ( !strncmp(setting, "VBL Sync", 8) ) {
203 } else if ( !strncmp(setting, "Show Points", 11) ) {
204 ipstream >> showpoints;
205 } else if ( !strncmp(setting, "Always Blur", 11) ) {
206 ipstream >> alwaysblur;
207 } else if ( !strncmp(setting, "Immediate mode ", 15) ) {
208 ipstream >> immediate;
209 } else if ( !strncmp(setting, "Velocity blur", 13) ) {
210 ipstream >> velocityblur;
211 } else if ( !strncmp(setting, "Volume", 6) ) {
213 } else if ( !strncmp(setting, "Forward key", 11) ) {
215 game.forwardkey = CharToKey(string);
216 } else if ( !strncmp(setting, "Back key", 8) ) {
218 game.backkey = CharToKey(string);
219 } else if ( !strncmp(setting, "Left key", 8) ) {
221 game.leftkey = CharToKey(string);
222 } else if ( !strncmp(setting, "Right key", 9) ) {
224 game.rightkey = CharToKey(string);
225 } else if ( !strncmp(setting, "Jump key", 8) ) {
227 game.jumpkey = CharToKey(string);
228 } else if ( !strncmp(setting, "Crouch key", 10) ) {
230 game.crouchkey = CharToKey(string);
231 } else if ( !strncmp(setting, "Draw key", 8) ) {
233 game.drawkey = CharToKey(string);
234 } else if ( !strncmp(setting, "Throw key", 9) ) {
236 game.throwkey = CharToKey(string);
237 } else if ( !strncmp(setting, "Attack key", 10) ) {
239 game.attackkey = CharToKey(string);
240 } else if ( !strncmp(setting, "Chat key", 8) ) {
242 game.chatkey = CharToKey(string);
243 } else if ( !strncmp(setting, "StereoMode", 10) ) {
246 stereomode = (StereoMode)i;
247 } else if ( !strncmp(setting, "StereoSeparation", 16) ) {
248 ipstream >> stereoseparation;
249 } else if ( !strncmp(setting, "StereoReverse", 13) ) {
250 ipstream >> stereoreverse;
253 fprintf(stderr, "Unknown config option '%s' with value '%s'. Ignoring.\n", setting, string);
256 if ( ipstream.fail() ) {
257 fprintf(stderr, "Error reading config file: EOF reached when trying to read value for setting '%s'.\n", setting);
262 if ( ipstream.bad() ) {
263 fprintf(stderr, "Error reading config file: Failed to read value for setting '%s'.\n", setting);
271 if(detail>2)detail=2;
272 if(detail<0)detail=0;
273 if(screenwidth<0)screenwidth=640;
274 if(screenheight<0)screenheight=480;