Added some a potential way forward with config and add/move/nothing

This commit is contained in:
2023-07-24 22:37:13 +01:00
parent 418daae284
commit d69aa1fef3
3 changed files with 14 additions and 3 deletions

View File

@@ -4,10 +4,18 @@ use std::path::PathBuf;
use toml;
use directories;
#[derive(Serialize, Deserialize, Debug)]
pub enum AddMode {
DoNothing,
Copy,
Move,
}
#[derive(Serialize, Deserialize, Debug, Default)]
pub struct Config {
pub iwads_added_folder: Option<PathBuf>,
pub iwads_removed_folder: Option<PathBuf>,
pub add_mode: Option<AddMode>,
pub iwads: Option<Vec<WadInfo>>,
pub pwads: Option<Vec<WadInfo>>,
pub launchers: Option<Vec<LauncherInfo>>,
@@ -114,6 +122,9 @@ path = \"/home/pwads/aa.pk3\"";
iwads: Some(iwads),
launchers: Some(vec![launcher]),
pwads: None,
iwads_added_folder: None,
iwads_removed_folder: None,
add_mode: None,
};
let toml_as_str = toml::to_string(&config).unwrap();
let new_config: Config = toml::from_str(&toml_as_str).unwrap();

View File

@@ -74,7 +74,7 @@ impl RustDoomLauncher {
fn get_config_file_stuff(&mut self) {
self.config = match load_config(&self.config_filename) {
Ok(c) => Some(c),
Err(e) => None,
Err(_e) => None,
};
if let Some(config) = &self.config {
if let Some(iwads) = &config.iwads {
@@ -391,8 +391,7 @@ impl eframe::App for RustDoomLauncher {
iwads: Some(self.iwad_manager.selectable.clone()),
pwads: Some(self.pwad_manager.selectable.clone()),
launchers: Some(self.launcher_manager.selectable.clone()),
iwads_added_folder: None,
iwads_removed_folder: None,
..Default::default()
};
save_config(&self.config_filename, &config).unwrap();
frame.close();

View File

@@ -316,6 +316,7 @@ mod tests {
}
#[test]
#[ignore]
fn test_guess_at_difficulty() {
let freedoom_iwad = PathBuf::from("freedoom1.wad");
let ow = open_wad(&freedoom_iwad);