Fixed pointess generate_str function return

Also added a nice little helpful close window thingy
This commit is contained in:
2023-07-05 22:13:37 +01:00
parent 6004df73f7
commit 9f62e4894b
3 changed files with 64 additions and 29 deletions

View File

@@ -35,26 +35,26 @@ impl CommandManager {
}
pub fn remove_iwad(&mut self) {
self.iwad = None;
let _ = self.generate_command_str();
self.update_command();
}
pub fn add_iwad(&mut self, iwad: &WadInfo) {
self.iwad = Some(iwad.path.clone());
let _ = self.generate_command_str();
self.update_command();
}
pub fn add_pwads(&mut self, pwads: &Vec<&WadInfo>) {
self.pwads = Vec::new();
for pwad in pwads {
self.pwads.push(pwad.path.clone());
}
let _ = self.generate_command_str();
self.update_command();
}
pub fn add_launcher(&mut self, launcher: &LauncherInfo) {
self.launcher = Some(launcher.path.clone());
let _ = self.generate_command_str();
self.update_command();
}
pub fn remove_launcher(&mut self) {
self.launcher = None;
let _ = self.generate_command_str();
self.update_command();
}
pub fn generate_command(&self) -> Result<(String, Vec<String>), CommandErrors> {
let launcher = if let Some(launcher) = &self.launcher {
@@ -93,7 +93,8 @@ impl CommandManager {
}
Ok((launcher.to_str().unwrap().to_string(), command))
}
pub fn generate_command_str(&mut self) -> Result<(), CommandErrors> {
pub fn update_command(&mut self) {
match self.generate_command() {
Err(e) => {
self.command_string = "plz add ".to_string();
@@ -112,7 +113,6 @@ impl CommandManager {
self.command_string = command;
}
}
Ok(())
}
}