| 160 | } |
| 161 | |
| 162 | bool SaveConfiguration() |
| 163 | { |
| 164 | // Open root key. |
| 165 | HKEY rootKey = NULL; |
| 166 | if (RegOpenKeyA(HKEY_CURRENT_USER, REGKEY_ROOT, &rootKey) != ERROR_SUCCESS) |
| 167 | { |
| 168 | // Create new key. |
| 169 | if (RegCreateKeyA(HKEY_CURRENT_USER, REGKEY_ROOT, &rootKey) != ERROR_SUCCESS) |
| 170 | return false; |
| 171 | } |
| 172 | |
| 173 | // Open Graphics subkey. |
| 174 | HKEY graphicsKey = NULL; |
| 175 | if (RegCreateKeyExA(rootKey, REGKEY_GRAPHICS, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &graphicsKey, NULL) != ERROR_SUCCESS) |
| 176 | { |
| 177 | RegCloseKey(rootKey); |
| 178 | RegCloseKey(graphicsKey); |
| 179 | return false; |
| 180 | } |
| 181 | |
| 182 | // Set Graphics keys. |
| 183 | if (SetDWORDRegKey(graphicsKey, REGKEY_SCREEN_WIDTH, g_Configuration.ScreenWidth) != ERROR_SUCCESS || |
| 184 | SetDWORDRegKey(graphicsKey, REGKEY_SCREEN_HEIGHT, g_Configuration.ScreenHeight) != ERROR_SUCCESS || |
| 185 | SetBoolRegKey(graphicsKey, REGKEY_ENABLE_WINDOWED_MODE, g_Configuration.EnableWindowedMode) != ERROR_SUCCESS || |
| 186 | SetDWORDRegKey(graphicsKey, REGKEY_SHADOWS, DWORD(g_Configuration.ShadowType)) != ERROR_SUCCESS || |
| 187 | SetDWORDRegKey(graphicsKey, REGKEY_SHADOW_MAP_SIZE, g_Configuration.ShadowMapSize) != ERROR_SUCCESS || |
| 188 | SetDWORDRegKey(graphicsKey, REGKEY_SHADOW_BLOBS_MAX, g_Configuration.ShadowBlobsMax) != ERROR_SUCCESS || |
| 189 | SetBoolRegKey(graphicsKey, REGKEY_ENABLE_CAUSTICS, g_Configuration.EnableCaustics) != ERROR_SUCCESS || |
| 190 | SetBoolRegKey(graphicsKey, REGKEY_ENABLE_DECALS, g_Configuration.EnableDecals) != ERROR_SUCCESS || |
| 191 | SetDWORDRegKey(graphicsKey, REGKEY_ANTIALIASING_MODE, (DWORD)g_Configuration.AntialiasingMode) != ERROR_SUCCESS || |
| 192 | SetBoolRegKey(graphicsKey, REGKEY_AMBIENT_OCCLUSION, g_Configuration.EnableAmbientOcclusion) != ERROR_SUCCESS || |
| 193 | SetBoolRegKey(graphicsKey, REGKEY_HIGH_FRAMERATE, g_Configuration.EnableHighFramerate) != ERROR_SUCCESS) |
| 194 | { |
| 195 | RegCloseKey(rootKey); |
| 196 | RegCloseKey(graphicsKey); |
| 197 | return false; |
| 198 | } |
| 199 | |
| 200 | // Open Sound subkey. |
| 201 | HKEY soundKey = NULL; |
| 202 | if (RegCreateKeyExA(rootKey, REGKEY_SOUND, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &soundKey, NULL) != ERROR_SUCCESS) |
| 203 | { |
| 204 | RegCloseKey(rootKey); |
| 205 | RegCloseKey(graphicsKey); |
| 206 | RegCloseKey(soundKey); |
| 207 | return false; |
| 208 | } |
| 209 | |
| 210 | // Set Sound keys. |
| 211 | if (SetDWORDRegKey(soundKey, REGKEY_SOUND_DEVICE, g_Configuration.SoundDevice) != ERROR_SUCCESS || |
| 212 | SetBoolRegKey(soundKey, REGKEY_ENABLE_SOUND, g_Configuration.EnableSound) != ERROR_SUCCESS || |
| 213 | SetBoolRegKey(soundKey, REGKEY_ENABLE_REVERB, g_Configuration.EnableReverb) != ERROR_SUCCESS || |
| 214 | SetDWORDRegKey(soundKey, REGKEY_MUSIC_VOLUME, g_Configuration.MusicVolume) != ERROR_SUCCESS || |
| 215 | SetDWORDRegKey(soundKey, REGKEY_SFX_VOLUME, g_Configuration.SfxVolume) != ERROR_SUCCESS) |
| 216 | { |
| 217 | RegCloseKey(rootKey); |
| 218 | RegCloseKey(graphicsKey); |
| 219 | RegCloseKey(soundKey); |
no test coverage detected