MCPcopy Create free account
hub / github.com/RustOtomeLab/RustEng / load_user_config

Function load_user_config

src/config/user.rs:75–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73 pub(crate) fn character_volume(&self, name: &str) -> f32 {
74 *self.character_volume.volumes.get(name).unwrap()
75 }
76
77 pub(crate) fn from_weak(weak: Weak<MainWindow>) -> Self {
78 UserConfig {
79 auto: AutoConfig::from_weak(weak.clone()),
80 text: TextConfig::from_weak(weak.clone()),
81 volume: VolumeConfig::from_weak(weak.clone()),
82 character_volume: CharacterVolumeConfig::from_weak(weak),
83 }
84 }
85}
86
87fn load_user_config() -> UserConfig {
88 let path = format!("{}/user.toml", ENGINE_CONFIG.save_path());
89
90 match fs::read_to_string(&path) {
91 Ok(content) => match toml::from_str::<UserConfig>(&content) {
92 Ok(mut config) => {
93 config.character_volume.fill_missing();
94
95 let resolved = SYSTEM_FONTS.resolve(config.text.font());
96 if resolved != config.text.font() {
97 config.text.set_font(resolved);
98 let _ = write_config(&path, &config);
99 }

Callers

nothing calls this directly

Calls 2

write_configFunction · 0.85
fill_missingMethod · 0.80

Tested by

no test coverage detected