show missing mod.txt

This commit is contained in:
dawnDus 2022-05-22 09:17:55 -04:00
parent 3f8c66db0f
commit 987c857b1c
No known key found for this signature in database
GPG Key ID: 972AABDE81848F21
2 changed files with 11 additions and 1 deletions

View File

@ -16,6 +16,7 @@ pub struct ModInfo {
pub path: String,
pub name: String,
pub description: String,
pub valid: bool,
}
impl ModInfo {
@ -147,11 +148,13 @@ impl ModList {
}
}
let mut valid = false;
let mut name = String::new();
let mut description = String::new();
let mut save_slot = -1;
if let Ok(file) = filesystem::open(ctx, [&path, "/mod.txt"].join("")) {
valid = true;
let reader = BufReader::new(file);
let mut lines = reader.lines();
if let Some(line) = lines.nth(1) {
@ -164,9 +167,12 @@ impl ModList {
if let Some(line) = lines.next() {
description = line.unwrap_or("No Description".to_string()).to_string();
}
} else {
name = path.clone();
description = "mod.txt not found".to_string();
}
mods.push(ModInfo { id, requirement, priority, save_slot, path, name, description })
mods.push(ModInfo { id, requirement, priority, save_slot, path, name, description, valid })
}
}

View File

@ -175,6 +175,10 @@ impl Scene for TitleScene {
let mut mutate_selection = true;
for mod_info in state.mod_list.mods.iter() {
if !mod_info.valid {
self.challenges_menu.push_entry(MenuEntry::Disabled(mod_info.path.clone()));
continue;
}
if mod_info.satisfies_requirement(&state.mod_requirements) {
self.challenges_menu.push_entry(MenuEntry::Active(mod_info.name.clone()));
mutate_selection = false;