Got IWAD reading working
Still need to do something about names
This commit is contained in:
@@ -15,3 +15,4 @@ serde = "1.0.163"
|
|||||||
serde_derive = "1.0.163"
|
serde_derive = "1.0.163"
|
||||||
strsim = "0.10.0"
|
strsim = "0.10.0"
|
||||||
toml = "0.7.4"
|
toml = "0.7.4"
|
||||||
|
walkdir = "2.4.0"
|
||||||
|
|||||||
38
src/main.rs
38
src/main.rs
@@ -7,6 +7,8 @@ use infos::{
|
|||||||
use native_dialog::{MessageDialog, MessageType};
|
use native_dialog::{MessageDialog, MessageType};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
use wad::get_summary;
|
||||||
|
use walkdir::{DirEntry, WalkDir};
|
||||||
|
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod infos;
|
pub mod infos;
|
||||||
@@ -64,18 +66,46 @@ impl Default for RustDoomLauncher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_wad_file(entry: &DirEntry) -> bool {
|
||||||
|
let filename = entry.file_name().to_str().unwrap().to_lowercase();
|
||||||
|
println!("{} - > {}", filename, filename.ends_with("wad"));
|
||||||
|
filename.ends_with("wad")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_wads_in_folder(path: &PathBuf) -> Vec<WadInfo> {
|
||||||
|
let mut wads = Vec::new();
|
||||||
|
for entry in WalkDir::new(path) {
|
||||||
|
let entry = entry.unwrap();
|
||||||
|
if is_wad_file(&entry) {
|
||||||
|
wads.push(WadInfo {
|
||||||
|
name: format!("{}", entry.path().display()),
|
||||||
|
path: entry.path().to_path_buf(),
|
||||||
|
info_text: None,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wads
|
||||||
|
}
|
||||||
|
|
||||||
impl RustDoomLauncher {
|
impl RustDoomLauncher {
|
||||||
fn get_config_file_stuff(&mut self) {
|
fn get_config_file_stuff(&mut self) {
|
||||||
// TODO - Throw some kind of error if a config file isn't found and/or missing iwad folder
|
// TODO - Throw some kind of error if a config file isn't found and/or missing iwad folder
|
||||||
|
println!("{:?}", self.config_filename);
|
||||||
match load_config(&self.config_filename) {
|
match load_config(&self.config_filename) {
|
||||||
Ok(c) => {
|
Ok(c) => {
|
||||||
|
println!("{:?}", c);
|
||||||
if let Some(launchers) = &c.launchers {
|
if let Some(launchers) = &c.launchers {
|
||||||
for launcher in launchers {
|
for launcher in launchers {
|
||||||
self.launcher_manager.add(&launcher);
|
self.launcher_manager.add(&launcher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
for iwad in get_wads_in_folder(&c.iwads_folder) {
|
||||||
Err(_e) => {},
|
self.iwad_manager.add(&iwad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("{:?}", e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,7 +442,9 @@ impl eframe::App for RustDoomLauncher {
|
|||||||
self.iwad_manager.add(&WadInfo {
|
self.iwad_manager.add(&WadInfo {
|
||||||
name: self.add_name.clone(),
|
name: self.add_name.clone(),
|
||||||
path: self.selected_file_path.clone(),
|
path: self.selected_file_path.clone(),
|
||||||
info_text: Some("I'm sure you know what's in that bloody IWAD!".to_string()),
|
info_text: Some(
|
||||||
|
"I'm sure you know what's in that bloody IWAD!".to_string(),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
FileType::Pwad => {
|
FileType::Pwad => {
|
||||||
|
|||||||
Reference in New Issue
Block a user