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 << kContextWidth;
49 opstream << "\nScreenheight:\n";
50 opstream << kContextHeight;
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";
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);
123 bool LoadSettings(Game &game) {
124 ifstream ipstream(ConvertFileName(":Data:config.txt"), std::ios::in);
125 if ( !ipstream || ipstream.fail() ) {
126 printf("Config file not found\n");
132 printf("Loading config\n");
133 while(!ipstream.eof()) {
134 ipstream.getline( setting, sizeof(setting) );
137 // assume lines starting with spaces are all blank
138 if ( strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t') continue;
140 if ( ipstream.eof() || ipstream.fail() ) {
141 fprintf(stderr, "Error reading config file: Got setting name '%s', but value can't be read\n", setting);
147 if ( !strncmp(setting, "Screenwidth", 11) ) {
148 ipstream >> kContextWidth;
149 } else if ( !strncmp(setting, "Screenheight", 12) ) {
150 ipstream >> kContextHeight;
151 } else if ( !strncmp(setting, "Mouse sensitivity", 17) ) {
152 ipstream >> usermousesensitivity;
153 } else if ( !strncmp(setting, "Blur", 4) ) {
154 ipstream >> ismotionblur;
155 } else if ( !strncmp(setting, "Overall Detail", 14) ) {
157 if(detail!=0)kBitsPerPixel=32;
158 else kBitsPerPixel=16;
159 } else if ( !strncmp(setting, "Floating jump", 13) ) {
160 ipstream >> floatjump;
161 } else if ( !strncmp(setting, "Mouse jump", 10) ) {
162 ipstream >> mousejump;
163 } else if ( !strncmp(setting, "Ambient sound", 13) ) {
164 ipstream >> ambientsound;
165 } else if ( !strncmp(setting, "Blood ", 6) ) {
166 ipstream >> bloodtoggle;
167 } else if ( !strncmp(setting, "Auto slomo", 10) ) {
168 ipstream >> autoslomo;
169 } else if ( !strncmp(setting, "Foliage", 7) ) {
171 } else if ( !strncmp(setting, "Music", 5) ) {
172 ipstream >> musictoggle;
173 } else if ( !strncmp(setting, "Trilinear", 9) ) {
174 ipstream >> trilinear;
175 } else if ( !strncmp(setting, "Decals", 6) ) {
177 } else if ( !strncmp(setting, "Invert mouse", 12) ) {
178 ipstream >> invertmouse;
179 } else if ( !strncmp(setting, "Gamespeed", 9) ) {
180 ipstream >> gamespeed;
181 oldgamespeed=gamespeed;
186 } else if ( !strncmp(setting, "Difficulty", 10) ) {
187 ipstream >> difficulty;
188 } else if ( !strncmp(setting, "Damage effects", 14) ) {
189 ipstream >> damageeffects;
190 } else if ( !strncmp(setting, "Text", 4) ) {
191 ipstream >> texttoggle;
192 } else if ( !strncmp(setting, "Debug", 5) ) {
193 ipstream >> debugmode;
194 } else if ( !strncmp(setting, "VBL Sync", 8) ) {
196 } else if ( !strncmp(setting, "Show Points", 11) ) {
197 ipstream >> showpoints;
198 } else if ( !strncmp(setting, "Always Blur", 11) ) {
199 ipstream >> alwaysblur;
200 } else if ( !strncmp(setting, "Immediate mode ", 15) ) {
201 ipstream >> immediate;
202 } else if ( !strncmp(setting, "Velocity blur", 13) ) {
203 ipstream >> velocityblur;
204 } else if ( !strncmp(setting, "Volume", 6) ) {
206 } else if ( !strncmp(setting, "Forward key", 11) ) {
208 game.forwardkey = CharToKey(string);
209 } else if ( !strncmp(setting, "Back key", 8) ) {
211 game.backkey = CharToKey(string);
212 } else if ( !strncmp(setting, "Left key", 8) ) {
214 game.leftkey = CharToKey(string);
215 } else if ( !strncmp(setting, "Right key", 9) ) {
217 game.rightkey = CharToKey(string);
218 } else if ( !strncmp(setting, "Jump key", 8) ) {
220 game.jumpkey = CharToKey(string);
221 } else if ( !strncmp(setting, "Crouch key", 10) ) {
223 game.crouchkey = CharToKey(string);
224 } else if ( !strncmp(setting, "Draw key", 8) ) {
226 game.drawkey = CharToKey(string);
227 } else if ( !strncmp(setting, "Throw key", 9) ) {
229 game.throwkey = CharToKey(string);
230 } else if ( !strncmp(setting, "Attack key", 10) ) {
232 game.attackkey = CharToKey(string);
233 } else if ( !strncmp(setting, "Chat key", 8) ) {
235 game.chatkey = CharToKey(string);
238 fprintf(stderr, "Unknown config option '%s' with value '%s'. Ignoring.\n", setting, string);
241 if ( ipstream.fail() ) {
242 fprintf(stderr, "Error reading config file: EOF reached when trying to read value for setting '%s'.\n", setting);
247 if ( ipstream.bad() ) {
248 fprintf(stderr, "Error reading config file: Failed to read value for setting '%s'.\n", setting);
256 if(detail>2)detail=2;
257 if(detail<0)detail=0;
258 if(screenwidth<0)screenwidth=640;
259 if(screenheight<0)screenheight=480;