MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / write

Function write

src/OpenLoco/src/Config.cpp:207–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205 }
206
207 void write()
208 {
209 auto configPath = Environment::getPathNoWarning(Environment::PathId::openlocoYML);
210 auto dir = configPath.parent_path();
211 Environment::autoCreateDirectory(dir);
212
213 auto backupLocale = std::locale::global(std::locale::classic());
214 auto& node = _configYaml;
215
216 // Display
217 const auto& displayConfig = _config.display;
218 auto displayNode = node["display"];
219 displayNode["mode"] = displayConfig.mode;
220 if (displayConfig.index != 0)
221 {
222 displayNode["index"] = displayConfig.index;
223 }
224 else
225 {
226 displayNode.remove("index");
227 }
228 displayNode["window_resolution"] = displayConfig.windowResolution;
229 displayNode["fullscreen_resolution"] = displayConfig.fullscreenResolution;
230 displayNode["vsync"] = displayConfig.vsync;
231 node["display"] = displayNode;
232
233 // Audio
234 const auto& audioConfig = _config.audio;
235 auto audioNode = node["audio"];
236 audioNode["device"] = audioConfig.device;
237 if (audioConfig.device.empty())
238 {
239 audioNode.remove("device");
240 }
241 audioNode["mainVolume"] = audioConfig.mainVolume;
242 audioNode["masterVolume"] = audioConfig.masterVolume;
243 audioNode["musicVolume"] = audioConfig.musicVolume;
244 audioNode["effectsVolume"] = audioConfig.effectsVolume;
245 audioNode["vehiclesVolume"] = audioConfig.vehiclesVolume;
246 audioNode["uiVolume"] = audioConfig.uiVolume;
247 audioNode["ambientVolume"] = audioConfig.ambientVolume;
248 audioNode["playJukeboxMusic"] = audioConfig.playJukeboxMusic;
249 audioNode["play_title_music"] = audioConfig.playTitleMusic;
250 audioNode["playNewsSounds"] = audioConfig.playNewsSounds;
251 audioNode["playlist"] = audioConfig.playlist;
252 audioNode["customJukebox"] = audioConfig.customJukebox;
253 node["audio"] = audioNode;
254
255 // Network
256 const auto& networkConfig = _config.network;
257 auto networkNode = node["network"];
258 networkNode["enabled"] = networkConfig.enabled;
259 node["network"] = networkNode;
260
261 // General
262 node["loco_install_path"] = _config.locoInstallPath;
263 node["last_save_path"] = _config.lastSavePath;
264 node["last_landscape_path"] = _config.lastLandscapePath;

Callers 15

disableMusicFunction · 0.85
enableMusicFunction · 0.85
windowPositionChangedFunction · 0.85
windowSizeChangedFunction · 0.85
setDisplayModeFunction · 0.85
setWindowScalingFunction · 0.85
resolveLocoInstallPathFunction · 0.85
resetShortcutsFunction · 0.85
onMouseDownFunction · 0.85
onMouseUpFunction · 0.85
frameLimitDropdownFunction · 0.85

Calls 6

getPathNoWarningFunction · 0.85
autoCreateDirectoryFunction · 0.85
enumValueFunction · 0.85
endFunction · 0.85
findMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected