Material filtering is now based on existing categories instead of predefined lists
parent
d8fd3d7111
commit
0cc8865028
14
src/kh1.rs
14
src/kh1.rs
|
@ -2,6 +2,7 @@ use std::sync::OnceLock;
|
||||||
|
|
||||||
use askama::Template;
|
use askama::Template;
|
||||||
use blake3::Hash;
|
use blake3::Hash;
|
||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
RuntimeModule,
|
RuntimeModule,
|
||||||
|
@ -9,11 +10,6 @@ use crate::{
|
||||||
create_file, create_hashes,
|
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";
|
const ENEMIES_PATH: &str = "./input/kh1/enemies";
|
||||||
static JS_HASH: OnceLock<Hash> = OnceLock::new();
|
static JS_HASH: OnceLock<Hash> = OnceLock::new();
|
||||||
|
|
||||||
|
@ -21,6 +17,7 @@ static JS_HASH: OnceLock<Hash> = OnceLock::new();
|
||||||
#[template(path = "pages/kh1/drops.html")]
|
#[template(path = "pages/kh1/drops.html")]
|
||||||
struct DropsTemplate {
|
struct DropsTemplate {
|
||||||
pub drops: Vec<MaterialDrops>,
|
pub drops: Vec<MaterialDrops>,
|
||||||
|
pub material_kinds: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Module;
|
pub struct Module;
|
||||||
|
@ -30,11 +27,14 @@ impl RuntimeModule for Module {
|
||||||
tracing::info!("Loading enemy data from {}", ENEMIES_PATH);
|
tracing::info!("Loading enemy data from {}", ENEMIES_PATH);
|
||||||
let enemies = Enemy::import(ENEMIES_PATH);
|
let enemies = Enemy::import(ENEMIES_PATH);
|
||||||
|
|
||||||
tracing::info!("Loading enemy drops data from {}", DROPS_PATH);
|
|
||||||
let drops = MaterialDrops::new(enemies);
|
let drops = MaterialDrops::new(enemies);
|
||||||
|
let material_kinds = drops.iter().map(|d| d.category.clone()).dedup().collect();
|
||||||
|
|
||||||
tracing::info!("Generating the KH1 drops template");
|
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();
|
create_file("./out/kh1", "drops", drops_template.render().unwrap()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ static JS_HASH: OnceLock<Hash> = OnceLock::new();
|
||||||
#[template(path = "pages/kh2/drops.html")]
|
#[template(path = "pages/kh2/drops.html")]
|
||||||
struct DropsTemplate {
|
struct DropsTemplate {
|
||||||
pub drops: Vec<MaterialDrops>,
|
pub drops: Vec<MaterialDrops>,
|
||||||
|
pub material_kinds: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Module;
|
pub struct Module;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% for kind in MATERIAL_KINDS %}
|
{% for kind in material_kinds %}
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="{{ kind }}Filter"
|
id="{{ kind }}Filter"
|
||||||
|
|
Loading…
Reference in New Issue