Material filtering is now based on existing categories instead of predefined lists

master
Wynd 2025-06-26 01:20:38 +03:00
parent d8fd3d7111
commit 0cc8865028
3 changed files with 9 additions and 8 deletions

View File

@ -2,6 +2,7 @@ use std::sync::OnceLock;
use askama::Template;
use blake3::Hash;
use itertools::Itertools;
use crate::{
RuntimeModule,
@ -9,11 +10,6 @@ use crate::{
create_file, create_hashes,
};
const MATERIAL_KINDS: &[&str] = &[
"lucid", "spirit", "power", "blaze", "frost", "thunder", "shiny", "bright", "mystery", "gale",
"mythril",
];
const DROPS_PATH: &str = "./input/kh1/drops";
const ENEMIES_PATH: &str = "./input/kh1/enemies";
static JS_HASH: OnceLock<Hash> = OnceLock::new();
@ -21,6 +17,7 @@ static JS_HASH: OnceLock<Hash> = OnceLock::new();
#[template(path = "pages/kh1/drops.html")]
struct DropsTemplate {
pub drops: Vec<MaterialDrops>,
pub material_kinds: Vec<String>,
}
pub struct Module;
@ -30,11 +27,14 @@ impl RuntimeModule for Module {
tracing::info!("Loading enemy data from {}", ENEMIES_PATH);
let enemies = Enemy::import(ENEMIES_PATH);
tracing::info!("Loading enemy drops data from {}", DROPS_PATH);
let drops = MaterialDrops::new(enemies);
let material_kinds = drops.iter().map(|d| d.category.clone()).dedup().collect();
tracing::info!("Generating the KH1 drops template");
let drops_template = DropsTemplate { drops };
let drops_template = DropsTemplate {
drops,
material_kinds,
};
create_file("./out/kh1", "drops", drops_template.render().unwrap()).unwrap();
}

View File

@ -26,6 +26,7 @@ static JS_HASH: OnceLock<Hash> = OnceLock::new();
#[template(path = "pages/kh2/drops.html")]
struct DropsTemplate {
pub drops: Vec<MaterialDrops>,
pub material_kinds: Vec<String>,
}
pub struct Module;

View File

@ -1,4 +1,4 @@
{% for kind in MATERIAL_KINDS %}
{% for kind in material_kinds %}
<input
type="checkbox"
id="{{ kind }}Filter"