From 00ce5099353934eab3e0e2703db4b30850bb7e9f Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 30 Apr 2024 23:15:55 +0200 Subject: [PATCH] track the source of the preferences --- src/var.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/var.rs b/src/var.rs index a1e1978..868c0b1 100644 --- a/src/var.rs +++ b/src/var.rs @@ -15,7 +15,6 @@ use bevy::prelude::*; use std::collections::HashMap; use serde::Deserialize; use toml_edit::DocumentMut; -use toml_edit::de::from_document; use std::env; use std::fs; @@ -37,6 +36,9 @@ pub struct Preferences { pub fullscreen_mode: String, pub window_mode: String, pub render_mode: String, + + #[serde(skip)] + pub source_file: Option, } impl Default for Preferences { @@ -45,6 +47,7 @@ impl Default for Preferences { fullscreen_mode: "borderless".to_string(), window_mode: "fullscreen".to_string(), render_mode: "vulkan".to_string(), + source_file: None, } } } @@ -90,9 +93,10 @@ pub fn load_prefs() -> Preferences { }; match toml.parse::() { Ok(doc) => { - match from_document::(doc) { - Ok(pref) => { + match toml_edit::de::from_document::(doc) { + Ok(mut pref) => { info!("Loaded preference file from {prefs_path}"); + pref.source_file = Some(prefs_path); dbg!(&pref); return pref; }