Added some a potential way forward with config and add/move/nothing
This commit is contained in:
@@ -4,10 +4,18 @@ use std::path::PathBuf;
|
|||||||
use toml;
|
use toml;
|
||||||
use directories;
|
use directories;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub enum AddMode {
|
||||||
|
DoNothing,
|
||||||
|
Copy,
|
||||||
|
Move,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Default)]
|
#[derive(Serialize, Deserialize, Debug, Default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub iwads_added_folder: Option<PathBuf>,
|
pub iwads_added_folder: Option<PathBuf>,
|
||||||
pub iwads_removed_folder: Option<PathBuf>,
|
pub iwads_removed_folder: Option<PathBuf>,
|
||||||
|
pub add_mode: Option<AddMode>,
|
||||||
pub iwads: Option<Vec<WadInfo>>,
|
pub iwads: Option<Vec<WadInfo>>,
|
||||||
pub pwads: Option<Vec<WadInfo>>,
|
pub pwads: Option<Vec<WadInfo>>,
|
||||||
pub launchers: Option<Vec<LauncherInfo>>,
|
pub launchers: Option<Vec<LauncherInfo>>,
|
||||||
@@ -114,6 +122,9 @@ path = \"/home/pwads/aa.pk3\"";
|
|||||||
iwads: Some(iwads),
|
iwads: Some(iwads),
|
||||||
launchers: Some(vec![launcher]),
|
launchers: Some(vec![launcher]),
|
||||||
pwads: None,
|
pwads: None,
|
||||||
|
iwads_added_folder: None,
|
||||||
|
iwads_removed_folder: None,
|
||||||
|
add_mode: None,
|
||||||
};
|
};
|
||||||
let toml_as_str = toml::to_string(&config).unwrap();
|
let toml_as_str = toml::to_string(&config).unwrap();
|
||||||
let new_config: Config = toml::from_str(&toml_as_str).unwrap();
|
let new_config: Config = toml::from_str(&toml_as_str).unwrap();
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ impl RustDoomLauncher {
|
|||||||
fn get_config_file_stuff(&mut self) {
|
fn get_config_file_stuff(&mut self) {
|
||||||
self.config = match load_config(&self.config_filename) {
|
self.config = match load_config(&self.config_filename) {
|
||||||
Ok(c) => Some(c),
|
Ok(c) => Some(c),
|
||||||
Err(e) => None,
|
Err(_e) => None,
|
||||||
};
|
};
|
||||||
if let Some(config) = &self.config {
|
if let Some(config) = &self.config {
|
||||||
if let Some(iwads) = &config.iwads {
|
if let Some(iwads) = &config.iwads {
|
||||||
@@ -391,8 +391,7 @@ impl eframe::App for RustDoomLauncher {
|
|||||||
iwads: Some(self.iwad_manager.selectable.clone()),
|
iwads: Some(self.iwad_manager.selectable.clone()),
|
||||||
pwads: Some(self.pwad_manager.selectable.clone()),
|
pwads: Some(self.pwad_manager.selectable.clone()),
|
||||||
launchers: Some(self.launcher_manager.selectable.clone()),
|
launchers: Some(self.launcher_manager.selectable.clone()),
|
||||||
iwads_added_folder: None,
|
..Default::default()
|
||||||
iwads_removed_folder: None,
|
|
||||||
};
|
};
|
||||||
save_config(&self.config_filename, &config).unwrap();
|
save_config(&self.config_filename, &config).unwrap();
|
||||||
frame.close();
|
frame.close();
|
||||||
|
|||||||
@@ -316,6 +316,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[ignore]
|
||||||
fn test_guess_at_difficulty() {
|
fn test_guess_at_difficulty() {
|
||||||
let freedoom_iwad = PathBuf::from("freedoom1.wad");
|
let freedoom_iwad = PathBuf::from("freedoom1.wad");
|
||||||
let ow = open_wad(&freedoom_iwad);
|
let ow = open_wad(&freedoom_iwad);
|
||||||
|
|||||||
Reference in New Issue
Block a user