| 1 |
/* |
| 2 |
Copyright (C) 2009-2010 wxLauncher Team |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or |
| 5 |
modify it under the terms of the GNU General Public License |
| 6 |
as published by the Free Software Foundation; either version 2 |
| 7 |
of the License, or (at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program; if not, write to the Free Software |
| 16 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 |
*/ |
| 18 |
|
| 19 |
#include <wx/wx.h> |
| 20 |
#include <wx/filename.h> |
| 21 |
#include <wx/ffile.h> |
| 22 |
#include <wx/wfstream.h> |
| 23 |
#include <wx/sstream.h> |
| 24 |
#include "generated/configure_launcher.h" |
| 25 |
#include "apis/ProfileManager.h" |
| 26 |
#include "apis/PlatformProfileManager.h" |
| 27 |
#include "apis/FlagListManager.h" |
| 28 |
#include "apis/JoystickManager.h" |
| 29 |
#include "global/BasicDefaults.h" |
| 30 |
#include "global/ProfileKeys.h" |
| 31 |
#include "global/RegistryKeys.h" |
| 32 |
|
| 33 |
#include <SDL_filesystem.h> |
| 34 |
|
| 35 |
|
| 36 |
// NOTE: this function is also used by PushCmdlineFSO() in PlatformProfileManagerShared.cpp |
| 37 |
wxFileName GetPlatformDefaultConfigFilePathOld() { |
| 38 |
wxFileName path; |
| 39 |
#if IS_WIN32 |
| 40 |
path.AssignDir(wxStandardPaths::Get().GetUserConfigDir()); |
| 41 |
path.AppendDir(_T("FS2 Open")); |
| 42 |
#elif IS_APPLE |
| 43 |
path.AssignHomeDir(); |
| 44 |
path.AppendDir(_T("Library")); |
| 45 |
path.AppendDir(_T("FS2_Open")); |
| 46 |
#elif IS_LINUX |
| 47 |
path.AssignHomeDir(); |
| 48 |
path.AppendDir(_T(".fs2_open")); |
| 49 |
#else |
| 50 |
# error "One of IS_WIN32, IS_LINUX, IS_APPLE must evaluate to true" |
| 51 |
#endif |
| 52 |
return path; |
| 53 |
} |
| 54 |
|
| 55 |
wxFileName GetPlatformDefaultConfigFilePathNew() { |
| 56 |
// SDL builds now use the user directory on all platforms |
| 57 |
// The sdl parameters are defined in the FSO code in the file code/osapi.cpp |
| 58 |
char* prefPath = SDL_GetPrefPath("HardLightProductions", "FreeSpaceOpen"); |
| 59 |
|
| 60 |
wxString wxPrefPath = wxString::FromUTF8(prefPath); |
| 61 |
|
| 62 |
SDL_free(prefPath); |
| 63 |
|
| 64 |
wxFileName path; |
| 65 |
path.AssignDir(wxPrefPath); |
| 66 |
|
| 67 |
return path; |
| 68 |
} |
| 69 |
|
| 70 |
wxFileName GetPlatformDefaultConfigFilePath(const wxString& tcPath) { |
| 71 |
wxFileName path; |
| 72 |
if (FlagListManager::GetFlagListManager()->GetBuildCaps() & FlagListManager::BUILD_CAPS_SDL) { |
| 73 |
path = GetPlatformDefaultConfigFilePathNew(); |
| 74 |
} |
| 75 |
else { |
| 76 |
#if IS_LINUX || IS_APPLE // write to folder in home dir |
| 77 |
path = GetPlatformDefaultConfigFilePathOld().GetFullPath().c_str(); |
| 78 |
#else |
| 79 |
path.AssignDir(tcPath); |
| 80 |
#endif |
| 81 |
} |
| 82 |
|
| 83 |
return path; |
| 84 |
} |
| 85 |
|
| 86 |
#define FSO_CONFIG_FILENAME _T("fs2_open.ini") |
| 87 |
|
| 88 |
#define ReturnChecker(retvalue, location) \ |
| 89 |
if ( retvalue != true ) {\ |
| 90 |
wxLogError(_T("Unhandled error in writing to the configuration file above line %d"), location);\ |
| 91 |
return ProMan::UnknownError;\ |
| 92 |
} |
| 93 |
|
| 94 |
ProMan::RegistryCodes FilePushProfile(wxFileConfig *cfg) { |
| 95 |
wxFileName configFileName; |
| 96 |
wxString tcPath; |
| 97 |
cfg->Read(PRO_CFG_TC_ROOT_FOLDER, &tcPath); |
| 98 |
|
| 99 |
if ( cfg->Exists(INT_CONFIG_FILE_LOCATION) ) { |
| 100 |
wxString configFileNameString; |
| 101 |
if (cfg->Read(INT_CONFIG_FILE_LOCATION, &configFileNameString)) { |
| 102 |
configFileName.Assign(configFileNameString); |
| 103 |
} else { |
| 104 |
wxLogError(_T("Unable to retrieve Config File location even though config says key exists")); |
| 105 |
return ProMan::UnknownError; |
| 106 |
} |
| 107 |
} else { |
| 108 |
configFileName = GetPlatformDefaultConfigFilePath(tcPath); |
| 109 |
} |
| 110 |
wxASSERT_MSG( configFileName.Normalize(), |
| 111 |
wxString::Format(_T("Unable to normalize PlatformDefaultConfigFilePath (%s)"), |
| 112 |
configFileName.GetFullPath().c_str())); |
| 113 |
|
| 114 |
if ( !configFileName.FileExists() && configFileName.DirExists() ) { |
| 115 |
// was given a directory name |
| 116 |
configFileName.SetFullName(FSO_CONFIG_FILENAME); |
| 117 |
} |
| 118 |
|
| 119 |
wxFFileInputStream configFileInputStream(configFileName.GetFullPath()); |
| 120 |
wxStringInputStream configBlankInputStream(_T("")); // in case ini file doesn't exist |
| 121 |
wxInputStream* configInputStreamPtr = &configFileInputStream; |
| 122 |
|
| 123 |
if (!configFileInputStream.IsOk()) { |
| 124 |
wxLogDebug(_T("Could not read from ini file %s, writing new file"), |
| 125 |
configFileName.GetFullPath().c_str()); |
| 126 |
configInputStreamPtr = &configBlankInputStream; |
| 127 |
} |
| 128 |
wxFileConfig outConfig(*configInputStreamPtr, wxMBConvUTF8()); |
| 129 |
bool ret; |
| 130 |
|
| 131 |
// most settings are written to "Default" folder |
| 132 |
outConfig.SetPath(REG_KEY_DEFAULT_FOLDER_CFG); |
| 133 |
|
| 134 |
// Video |
| 135 |
int width, height, bitdepth; |
| 136 |
cfg->Read(PRO_CFG_VIDEO_RESOLUTION_WIDTH, &width, DEFAULT_VIDEO_RESOLUTION_WIDTH); |
| 137 |
cfg->Read(PRO_CFG_VIDEO_RESOLUTION_HEIGHT, &height, DEFAULT_VIDEO_RESOLUTION_HEIGHT); |
| 138 |
cfg->Read(PRO_CFG_VIDEO_BIT_DEPTH, &bitdepth, DEFAULT_VIDEO_BIT_DEPTH); |
| 139 |
|
| 140 |
wxString videocardValue = wxString::Format(_T("OGL -(%dx%d)x%d bit"), width, height, bitdepth); |
| 141 |
|
| 142 |
ret = outConfig.Write(REG_KEY_VIDEO_RESOLUTION_DEPTH, videocardValue); |
| 143 |
ReturnChecker(ret, __LINE__); |
| 144 |
|
| 145 |
|
| 146 |
wxString filterMethod; |
| 147 |
cfg->Read(PRO_CFG_VIDEO_TEXTURE_FILTER, &filterMethod, DEFAULT_VIDEO_TEXTURE_FILTER); |
| 148 |
int filterMethodValue = ( filterMethod.StartsWith(_T("Bilinear"))) ? 0 : 1; |
| 149 |
|
| 150 |
ret = outConfig.Write(REG_KEY_VIDEO_TEXTURE_FILTER, filterMethodValue); |
| 151 |
ReturnChecker(ret, __LINE__); |
| 152 |
|
| 153 |
|
| 154 |
int oglAnisotropicFilter; |
| 155 |
cfg->Read(PRO_CFG_VIDEO_ANISOTROPIC, &oglAnisotropicFilter, DEFAULT_VIDEO_ANISOTROPIC); |
| 156 |
|
| 157 |
// Caution: FSO expects anisotropic values to be a string, |
| 158 |
// but since we're writing to an .ini file, we can write it out as an int |
| 159 |
ret = outConfig.Write(REG_KEY_VIDEO_ANISOTROPIC, oglAnisotropicFilter); |
| 160 |
ReturnChecker(ret, __LINE__); |
| 161 |
|
| 162 |
|
| 163 |
int oglAntiAliasSample; |
| 164 |
cfg->Read(PRO_CFG_VIDEO_ANTI_ALIAS, &oglAntiAliasSample, DEFAULT_VIDEO_ANTI_ALIAS); |
| 165 |
|
| 166 |
ret = outConfig.Write(REG_KEY_VIDEO_ANTI_ALIAS, oglAntiAliasSample); |
| 167 |
ReturnChecker(ret, __LINE__); |
| 168 |
|
| 169 |
|
| 170 |
// Audio |
| 171 |
wxString soundDevice; |
| 172 |
cfg->Read(PRO_CFG_OPENAL_DEVICE, &soundDevice, DEFAULT_AUDIO_OPENAL_DEVICE); |
| 173 |
|
| 174 |
ret = outConfig.Write(REG_KEY_AUDIO_OPENAL_DEVICE, soundDevice); |
| 175 |
ReturnChecker(ret, __LINE__); |
| 176 |
|
| 177 |
|
| 178 |
// new sound code settings are written to "Sound" folder |
| 179 |
outConfig.SetPath(REG_KEY_AUDIO_FOLDER_CFG); |
| 180 |
|
| 181 |
|
| 182 |
wxString playbackDevice; |
| 183 |
cfg->Read( |
| 184 |
PRO_CFG_OPENAL_DEVICE, |
| 185 |
&playbackDevice, |
| 186 |
DEFAULT_AUDIO_OPENAL_PLAYBACK_DEVICE); |
| 187 |
|
| 188 |
ret = outConfig.Write(REG_KEY_AUDIO_OPENAL_PLAYBACK_DEVICE, playbackDevice); |
| 189 |
ReturnChecker(ret, __LINE__); |
| 190 |
|
| 191 |
|
| 192 |
wxString captureDevice; |
| 193 |
bool hasEntry = cfg->Read( |
| 194 |
PRO_CFG_OPENAL_CAPTURE_DEVICE, |
| 195 |
&captureDevice, |
| 196 |
DEFAULT_AUDIO_OPENAL_CAPTURE_DEVICE); |
| 197 |
|
| 198 |
if (hasEntry) { |
| 199 |
ret = outConfig.Write(REG_KEY_AUDIO_OPENAL_CAPTURE_DEVICE, captureDevice); |
| 200 |
ReturnChecker(ret, __LINE__); |
| 201 |
} |
| 202 |
|
| 203 |
|
| 204 |
int enableEFX; |
| 205 |
hasEntry = cfg->Read(PRO_CFG_OPENAL_EFX, &enableEFX, DEFAULT_AUDIO_OPENAL_EFX); |
| 206 |
|
| 207 |
if (hasEntry) { |
| 208 |
ret = outConfig.Write(REG_KEY_AUDIO_OPENAL_EFX, enableEFX); |
| 209 |
ReturnChecker(ret, __LINE__); |
| 210 |
} |
| 211 |
|
| 212 |
|
| 213 |
int sampleRate; |
| 214 |
cfg->Read( |
| 215 |
PRO_CFG_OPENAL_SAMPLE_RATE, |
| 216 |
&sampleRate, |
| 217 |
DEFAULT_AUDIO_OPENAL_SAMPLE_RATE); |
| 218 |
|
| 219 |
if (sampleRate != DEFAULT_AUDIO_OPENAL_SAMPLE_RATE) { |
| 220 |
ret = outConfig.Write(REG_KEY_AUDIO_OPENAL_SAMPLE_RATE, sampleRate); |
| 221 |
ReturnChecker(ret, __LINE__); |
| 222 |
} |
| 223 |
|
| 224 |
|
| 225 |
outConfig.SetPath(REG_KEY_DEFAULT_FOLDER_CFG); |
| 226 |
|
| 227 |
|
| 228 |
// Speech |
| 229 |
#if IS_WIN32 // speech is currently not supported in OS X or Linux (although Windows doesn't use this code) |
| 230 |
int speechVoice; |
| 231 |
cfg->Read(PRO_CFG_SPEECH_VOICE, &speechVoice, DEFAULT_SPEECH_VOICE); |
| 232 |
|
| 233 |
ret = outConfig.Write(REG_KEY_SPEECH_VOICE, speechVoice); |
| 234 |
ReturnChecker(ret, __LINE__); |
| 235 |
|
| 236 |
|
| 237 |
int speechVolume; |
| 238 |
cfg->Read(PRO_CFG_SPEECH_VOLUME, &speechVolume, DEFAULT_SPEECH_VOLUME); |
| 239 |
|
| 240 |
ret = outConfig.Write(REG_KEY_SPEECH_VOLUME, speechVolume); |
| 241 |
ReturnChecker(ret, __LINE__); |
| 242 |
|
| 243 |
|
| 244 |
int inTechroom, inBriefings, inGame, inMulti; |
| 245 |
cfg->Read(PRO_CFG_SPEECH_IN_TECHROOM, &inTechroom, DEFAULT_SPEECH_IN_TECHROOM); |
| 246 |
cfg->Read(PRO_CFG_SPEECH_IN_BRIEFINGS, &inBriefings, DEFAULT_SPEECH_IN_BRIEFINGS); |
| 247 |
cfg->Read(PRO_CFG_SPEECH_IN_GAME, &inGame, DEFAULT_SPEECH_IN_GAME); |
| 248 |
cfg->Read(PRO_CFG_SPEECH_IN_MULTI, &inMulti, DEFAULT_SPEECH_IN_MULTI); |
| 249 |
|
| 250 |
ret = outConfig.Write(REG_KEY_SPEECH_IN_TECHROOM, inTechroom); |
| 251 |
ReturnChecker(ret, __LINE__); |
| 252 |
|
| 253 |
ret = outConfig.Write(REG_KEY_SPEECH_IN_BRIEFINGS, inBriefings); |
| 254 |
ReturnChecker(ret, __LINE__); |
| 255 |
|
| 256 |
ret = outConfig.Write(REG_KEY_SPEECH_IN_GAME, inGame); |
| 257 |
ReturnChecker(ret, __LINE__); |
| 258 |
|
| 259 |
ret = outConfig.Write(REG_KEY_SPEECH_IN_MULTI, inMulti); |
| 260 |
ReturnChecker(ret, __LINE__); |
| 261 |
#endif |
| 262 |
|
| 263 |
|
| 264 |
// Joystick |
| 265 |
int currentJoystick; |
| 266 |
cfg->Read(PRO_CFG_JOYSTICK_ID, ¤tJoystick, DEFAULT_JOYSTICK_ID); |
| 267 |
|
| 268 |
ret = outConfig.Write(REG_KEY_JOYSTICK_ID, currentJoystick); |
| 269 |
ReturnChecker(ret, __LINE__); |
| 270 |
|
| 271 |
// Joystick GUID |
| 272 |
wxString currentJoystickGUID = JoyMan::JoystickGUID(currentJoystick); |
| 273 |
|
| 274 |
ret = outConfig.Write(REG_KEY_JOYSTICK_GUID, currentJoystickGUID); |
| 275 |
ReturnChecker(ret, __LINE__); |
| 276 |
|
| 277 |
|
| 278 |
int joystickForceFeedback; |
| 279 |
cfg->Read( |
| 280 |
PRO_CFG_JOYSTICK_FORCE_FEEDBACK, |
| 281 |
&joystickForceFeedback, |
| 282 |
DEFAULT_JOYSTICK_FORCE_FEEDBACK); |
| 283 |
|
| 284 |
ret = outConfig.Write(REG_KEY_JOYSTICK_FORCE_FEEDBACK, joystickForceFeedback); |
| 285 |
ReturnChecker(ret, __LINE__); |
| 286 |
|
| 287 |
|
| 288 |
int joystickHit; |
| 289 |
cfg->Read(PRO_CFG_JOYSTICK_DIRECTIONAL, &joystickHit, DEFAULT_JOYSTICK_DIRECTIONAL); |
| 290 |
|
| 291 |
ret = outConfig.Write(REG_KEY_JOYSTICK_DIRECTIONAL, joystickHit); |
| 292 |
ReturnChecker(ret, __LINE__); |
| 293 |
|
| 294 |
|
| 295 |
// Network |
| 296 |
wxString networkConnectionValue; |
| 297 |
cfg->Read(PRO_CFG_NETWORK_TYPE, &networkConnectionValue, DEFAULT_NETWORK_TYPE); |
| 298 |
|
| 299 |
ret = outConfig.Write(REG_KEY_NETWORK_TYPE, networkConnectionValue); |
| 300 |
ReturnChecker(ret, __LINE__); |
| 301 |
|
| 302 |
|
| 303 |
wxString connectionSpeedValue; |
| 304 |
cfg->Read(PRO_CFG_NETWORK_SPEED, &connectionSpeedValue, DEFAULT_NETWORK_SPEED); |
| 305 |
|
| 306 |
ret = outConfig.Write(REG_KEY_NETWORK_SPEED, connectionSpeedValue); |
| 307 |
ReturnChecker(ret, __LINE__); |
| 308 |
|
| 309 |
|
| 310 |
int forcedport; |
| 311 |
cfg->Read(PRO_CFG_NETWORK_PORT, &forcedport, DEFAULT_NETWORK_PORT); |
| 312 |
|
| 313 |
if (forcedport != DEFAULT_NETWORK_PORT) { |
| 314 |
ret = outConfig.Write(REG_KEY_NETWORK_PORT, forcedport); |
| 315 |
ReturnChecker(ret, __LINE__); |
| 316 |
} else if (outConfig.Exists(REG_KEY_NETWORK_PORT)) { |
| 317 |
ret = outConfig.DeleteEntry(REG_KEY_NETWORK_PORT, false); |
| 318 |
ReturnChecker(ret, __LINE__); |
| 319 |
} |
| 320 |
|
| 321 |
|
| 322 |
// custom IP is written to "Network" folder |
| 323 |
outConfig.SetPath(REG_KEY_NETWORK_FOLDER_CFG); |
| 324 |
|
| 325 |
wxString networkIP; |
| 326 |
cfg->Read(PRO_CFG_NETWORK_IP, &networkIP, DEFAULT_NETWORK_IP); |
| 327 |
|
| 328 |
if (networkIP != DEFAULT_NETWORK_IP) { |
| 329 |
ret = outConfig.Write(REG_KEY_NETWORK_IP, networkIP); |
| 330 |
ReturnChecker(ret, __LINE__); |
| 331 |
} else if (outConfig.Exists(REG_KEY_NETWORK_IP)) { |
| 332 |
ret = outConfig.DeleteEntry(REG_KEY_NETWORK_IP, false); |
| 333 |
ReturnChecker(ret, __LINE__); |
| 334 |
} |
| 335 |
|
| 336 |
outConfig.SetPath(REG_KEY_DEFAULT_FOLDER_CFG); |
| 337 |
|
| 338 |
|
| 339 |
wxLogDebug(_T("Writing fs2_open.ini to %s"), configFileName.GetFullPath().c_str()); |
| 340 |
wxFFileOutputStream outFileStream(configFileName.GetFullPath()); |
| 341 |
|
| 342 |
outConfig.Save(outFileStream); |
| 343 |
|
| 344 |
return PushCmdlineFSO(cfg); |
| 345 |
} |
| 346 |
|
| 347 |
ProMan::RegistryCodes FilePullProfile(wxFileConfig *cfg) { |
| 348 |
wxFileName inFileName; |
| 349 |
if ( cfg->Exists(INT_CONFIG_FILE_LOCATION) ) { |
| 350 |
wxString inFileNameString; |
| 351 |
if (cfg->Read(INT_CONFIG_FILE_LOCATION, &inFileNameString)) { |
| 352 |
inFileName.Assign(inFileNameString); |
| 353 |
} else { |
| 354 |
wxLogError(_T("Unable to retrieve Config File location even though config says key exists")); |
| 355 |
return ProMan::UnknownError; |
| 356 |
} |
| 357 |
} else { |
| 358 |
inFileName = GetPlatformDefaultConfigFilePathNew(); |
| 359 |
inFileName.SetFullName(FSO_CONFIG_FILENAME); |
| 360 |
|
| 361 |
if (!inFileName.FileExists()) |
| 362 |
{ |
| 363 |
inFileName = GetPlatformDefaultConfigFilePathOld(); |
| 364 |
inFileName.SetFullName(FSO_CONFIG_FILENAME); |
| 365 |
} |
| 366 |
} |
| 367 |
wxASSERT( inFileName.Normalize() ); |
| 368 |
|
| 369 |
if ( !inFileName.FileExists() && inFileName.DirExists() ) { |
| 370 |
// was given a directory name |
| 371 |
inFileName.SetFullName(FSO_CONFIG_FILENAME); |
| 372 |
} |
| 373 |
|
| 374 |
if (!inFileName.FileExists()) { |
| 375 |
return ProMan::InputFileDoesNotExist; |
| 376 |
} |
| 377 |
|
| 378 |
wxFFileInputStream inConfigStream(inFileName.GetFullPath(), _T("rb")); |
| 379 |
wxFileConfig inConfig(inConfigStream, wxMBConvUTF8()); |
| 380 |
|
| 381 |
wxString readString; |
| 382 |
int readNumber; |
| 383 |
|
| 384 |
|
| 385 |
// Video |
| 386 |
if ( inConfig.Read(REG_KEY_VIDEO_RESOLUTION_DEPTH, &readString) ) { |
| 387 |
// parses VideocardFS2open into its parts |
| 388 |
wxString videoCard(readString); |
| 389 |
wxString rest, rest1, rest2, rest3; |
| 390 |
|
| 391 |
long width = 0, height = 0, bitdepth = 0; |
| 392 |
if ( videoCard.StartsWith(_T("OGL -("), &rest) ) { |
| 393 |
int xLocation = rest.Find(_T('x')); |
| 394 |
if ( xLocation != wxNOT_FOUND ) { |
| 395 |
wxString widthStr(rest.Mid(0, xLocation)); |
| 396 |
rest1 = rest.Mid(xLocation); |
| 397 |
if ( !widthStr.ToLong(&width, 10) ) { |
| 398 |
width = 0; |
| 399 |
} |
| 400 |
int bLocation = rest1.Find(_T(')')); |
| 401 |
if ( bLocation != wxNOT_FOUND ) { |
| 402 |
wxString heightStr(rest1.Mid(0, bLocation)); |
| 403 |
rest2 = rest1.Mid(bLocation+1); |
| 404 |
if ( !heightStr.ToLong(&height, 10) ) { |
| 405 |
height = 0; |
| 406 |
} |
| 407 |
int spaceLoc = rest2.Find(_T(' ')); |
| 408 |
if ( spaceLoc != wxNOT_FOUND ) { |
| 409 |
wxString bitStr(rest2.Mid(0, spaceLoc)); |
| 410 |
if ( !bitStr.ToLong(&bitdepth, 10) ) { |
| 411 |
bitdepth = 0; |
| 412 |
} |
| 413 |
} |
| 414 |
} |
| 415 |
} |
| 416 |
} |
| 417 |
if ( width > 0 ) { |
| 418 |
cfg->Write(PRO_CFG_VIDEO_RESOLUTION_WIDTH, width); |
| 419 |
} |
| 420 |
if ( height > 0 ) { |
| 421 |
cfg->Write(PRO_CFG_VIDEO_RESOLUTION_HEIGHT, height); |
| 422 |
} |
| 423 |
if ( bitdepth > 0 ) { |
| 424 |
cfg->Write(PRO_CFG_VIDEO_BIT_DEPTH, bitdepth); |
| 425 |
} |
| 426 |
} |
| 427 |
|
| 428 |
if ( inConfig.Read(REG_KEY_VIDEO_TEXTURE_FILTER, &readNumber) ) { |
| 429 |
cfg->Write(PRO_CFG_VIDEO_TEXTURE_FILTER, readNumber); |
| 430 |
} |
| 431 |
|
| 432 |
if ( inConfig.Read(REG_KEY_VIDEO_ANISOTROPIC, &readString) ) { |
| 433 |
long anisotropic; |
| 434 |
// necessary because FSO expects registry value to be a string |
| 435 |
if ( readString.ToLong(&anisotropic) ) { |
| 436 |
cfg->Write(PRO_CFG_VIDEO_ANISOTROPIC, anisotropic); |
| 437 |
} |
| 438 |
} |
| 439 |
|
| 440 |
if ( inConfig.Read(REG_KEY_VIDEO_ANTI_ALIAS, &readNumber) ) { |
| 441 |
cfg->Write(PRO_CFG_VIDEO_ANTI_ALIAS, readNumber); |
| 442 |
} |
| 443 |
|
| 444 |
|
| 445 |
// Audio |
| 446 |
if ( inConfig.Read(REG_KEY_AUDIO_OPENAL_DEVICE, &readString) ) { |
| 447 |
cfg->Write(PRO_CFG_OPENAL_DEVICE, readString); |
| 448 |
} |
| 449 |
|
| 450 |
if ( inConfig.Read(REG_KEY_AUDIO_OPENAL_PLAYBACK_DEVICE, &readString) && |
| 451 |
!inConfig.Exists(PRO_CFG_OPENAL_DEVICE)) { |
| 452 |
cfg->Write(PRO_CFG_OPENAL_DEVICE, readString); |
| 453 |
} |
| 454 |
|
| 455 |
if ( inConfig.Read(REG_KEY_AUDIO_OPENAL_CAPTURE_DEVICE, &readString) ) { |
| 456 |
cfg->Write(PRO_CFG_OPENAL_CAPTURE_DEVICE, readString); |
| 457 |
} |
| 458 |
|
| 459 |
if ( inConfig.Read(REG_KEY_AUDIO_OPENAL_EFX, &readNumber) ) { |
| 460 |
cfg->Write(PRO_CFG_OPENAL_EFX, readNumber); |
| 461 |
} |
| 462 |
|
| 463 |
if ( inConfig.Read(REG_KEY_AUDIO_OPENAL_SAMPLE_RATE, &readNumber) ) { |
| 464 |
cfg->Write(PRO_CFG_OPENAL_SAMPLE_RATE, readNumber); |
| 465 |
} |
| 466 |
|
| 467 |
|
| 468 |
// Speech |
| 469 |
#if IS_WIN32 // Linux/OS X don't yet support speech |
| 470 |
if ( inConfig.Read(REG_KEY_SPEECH_VOICE, &readNumber) ) { |
| 471 |
cfg->Write(PRO_CFG_SPEECH_VOICE, readNumber); |
| 472 |
} |
| 473 |
|
| 474 |
if ( inConfig.Read(REG_KEY_SPEECH_VOLUME, &readNumber) ) { |
| 475 |
cfg->Write(PRO_CFG_SPEECH_VOLUME, readNumber); |
| 476 |
} |
| 477 |
|
| 478 |
if ( inConfig.Read(REG_KEY_SPEECH_IN_TECHROOM, &readNumber) ) { |
| 479 |
cfg->Write(PRO_CFG_SPEECH_IN_TECHROOM, readNumber); |
| 480 |
} |
| 481 |
|
| 482 |
if ( inConfig.Read(REG_KEY_SPEECH_IN_BRIEFINGS, &readNumber) ) { |
| 483 |
cfg->Write(PRO_CFG_SPEECH_IN_BRIEFINGS, readNumber); |
| 484 |
} |
| 485 |
|
| 486 |
if ( inConfig.Read(REG_KEY_SPEECH_IN_GAME, &readNumber) ) { |
| 487 |
cfg->Write(PRO_CFG_SPEECH_IN_GAME, readNumber); |
| 488 |
} |
| 489 |
|
| 490 |
if ( inConfig.Read(REG_KEY_SPEECH_IN_MULTI, &readNumber) ) { |
| 491 |
cfg->Write(PRO_CFG_SPEECH_IN_MULTI, readNumber); |
| 492 |
} |
| 493 |
#endif |
| 494 |
|
| 495 |
|
| 496 |
// Joystick |
| 497 |
if ( inConfig.Read(REG_KEY_JOYSTICK_ID, &readNumber) ) { |
| 498 |
cfg->Write(PRO_CFG_JOYSTICK_ID, readNumber); |
| 499 |
} |
| 500 |
|
| 501 |
if ( inConfig.Read(REG_KEY_JOYSTICK_FORCE_FEEDBACK, &readNumber) ) { |
| 502 |
cfg->Write(PRO_CFG_JOYSTICK_FORCE_FEEDBACK, readNumber); |
| 503 |
} |
| 504 |
|
| 505 |
if ( inConfig.Read(REG_KEY_JOYSTICK_DIRECTIONAL, &readNumber) ) { |
| 506 |
cfg->Write(PRO_CFG_JOYSTICK_DIRECTIONAL, readNumber); |
| 507 |
} |
| 508 |
|
| 509 |
|
| 510 |
// Network |
| 511 |
if ( inConfig.Read(REG_KEY_NETWORK_TYPE, &readString) ) { |
| 512 |
cfg->Write(PRO_CFG_NETWORK_TYPE, readString); |
| 513 |
} |
| 514 |
|
| 515 |
if ( inConfig.Read(REG_KEY_NETWORK_SPEED, &readString) ) { |
| 516 |
cfg->Write(PRO_CFG_NETWORK_SPEED, readString); |
| 517 |
} |
| 518 |
|
| 519 |
if ( inConfig.Read(REG_KEY_NETWORK_PORT, &readNumber) ) { |
| 520 |
cfg->Write(PRO_CFG_NETWORK_PORT, readNumber); |
| 521 |
} |
| 522 |
|
| 523 |
if ( inConfig.Read(REG_KEY_NETWORK_IP, &readString) ) { |
| 524 |
cfg->Write(PRO_CFG_NETWORK_IP, readString); |
| 525 |
} |
| 526 |
|
| 527 |
|
| 528 |
return ProMan::NoError; |
| 529 |
} |