Some more organization and splits

master
Wynd 2025-07-13 23:56:34 +03:00
parent fb7509ec14
commit 1d1b3c02dd
10 changed files with 88 additions and 76 deletions

View File

@ -84,6 +84,10 @@ input[type="checkbox"] {
height: 24px;
padding-top: 8px;
& + label {
cursor: pointer;
}
&::before {
position: absolute;
width: 100%;

View File

@ -89,11 +89,11 @@
.material-filters {
display: flex;
flex-wrap: wrap;
width: 25%;
width: 40%;
row-gap: 20px;
position: relative;
}
div {
flex-basis: 25%;
}
.tracked-filter {
margin-bottom: 16px;
}

View File

@ -1,6 +1,7 @@
use serde::Deserialize;
pub mod direction;
pub mod drops;
pub mod enemy;
pub mod materials;
pub mod synthesis;

View File

@ -0,0 +1,45 @@
use itertools::Itertools;
use super::{Game, enemy::Enemy, materials::MaterialDrops};
#[derive(Debug, PartialEq, Eq)]
pub struct Drops {
pub game: Game,
pub drops: Vec<MaterialDrops>,
pub material_kinds: Vec<String>,
filter_max_len: usize,
}
impl Drops {
pub fn new(game: Game, enemies: Vec<Enemy>) -> Self {
let drops = MaterialDrops::new(enemies);
let material_kinds = drops
.iter()
.map(|d| d.category.get_category(&Game::Kh1))
.dedup()
.collect::<Vec<_>>();
let mut filter_max_len: usize = 0;
for kind in &material_kinds {
if kind.len() > filter_max_len {
filter_max_len = kind.len();
}
}
filter_max_len *= 10;
filter_max_len += 60;
Self {
game,
drops,
material_kinds,
filter_max_len,
}
}
pub fn get_filter_len(&self) -> usize {
self.filter_max_len
}
}

View File

@ -3,15 +3,15 @@ use std::collections::HashMap;
use serde::Deserialize;
#[derive(Debug, Default, Clone, Deserialize, PartialEq, Eq)]
pub struct SynthesisData {
pub struct Synthesis {
pub sets: Vec<SynthesisSet>,
pub recipes: Vec<SynthesisRecipe>,
}
impl SynthesisData {
pub fn new(path: &str) -> SynthesisData {
impl Synthesis {
pub fn new(path: &str) -> Synthesis {
let str = std::fs::read_to_string(path).unwrap();
let mut data = toml::from_str::<SynthesisData>(&str).unwrap();
let mut data = toml::from_str::<Synthesis>(&str).unwrap();
for recipe in &mut data.recipes {
for set in &data.sets {

View File

@ -1,9 +1,8 @@
use askama::Template;
use itertools::Itertools;
use crate::{
RuntimeModule,
common::{Game, enemy::Enemy, materials::MaterialDrops, synthesis::SynthesisData},
common::{Game, drops::Drops, enemy::Enemy, synthesis::Synthesis},
create_file,
};
@ -13,15 +12,13 @@ const SYNTHESIS_PATH: &str = "./input/kh1/synthesis.toml";
#[derive(Template)]
#[template(path = "pages/kh1/drops.html")]
struct DropsTemplate {
pub game: Game,
pub drops: Vec<MaterialDrops>,
pub material_kinds: Vec<String>,
pub data: Drops,
}
#[derive(Template)]
#[template(path = "pages/kh1/synth.html")]
struct SynthTemplate {
pub data: SynthesisData,
pub data: Synthesis,
}
pub struct Module;
@ -31,22 +28,13 @@ impl RuntimeModule for Module {
tracing::info!("Loading enemy data from {}", ENEMIES_PATH);
let enemies = Enemy::import(ENEMIES_PATH);
let drops = MaterialDrops::new(enemies);
let material_kinds = drops
.iter()
.map(|d| d.category.get_category(&Game::Kh1))
.dedup()
.collect();
let drops = Drops::new(Game::Kh1, enemies);
tracing::info!("Loading synthesis data from {}", SYNTHESIS_PATH);
let synth = SynthesisData::new(SYNTHESIS_PATH);
let synth = Synthesis::new(SYNTHESIS_PATH);
tracing::info!("Generating the KH1 drops template");
let drops_template = DropsTemplate {
game: Game::Kh1,
drops,
material_kinds,
};
let drops_template = DropsTemplate { data: drops };
create_file("./out/kh1", "drops", drops_template).unwrap();

View File

@ -1,9 +1,8 @@
use askama::Template;
use itertools::Itertools;
use crate::{
RuntimeModule,
common::{Game, enemy::Enemy, materials::MaterialDrops},
common::{Game, drops::Drops, enemy::Enemy},
create_file,
};
@ -12,9 +11,7 @@ const ENEMIES_PATH: &str = "./input/kh2/enemies";
#[derive(Template)]
#[template(path = "pages/kh2/drops.html")]
struct DropsTemplate {
pub game: Game,
pub drops: Vec<MaterialDrops>,
pub material_kinds: Vec<String>,
pub data: Drops,
}
pub struct Module;
@ -24,19 +21,10 @@ impl RuntimeModule for Module {
tracing::info!("Loading enemy data from {}", ENEMIES_PATH);
let enemies = Enemy::import(ENEMIES_PATH);
let drops = MaterialDrops::new(enemies);
let material_kinds = drops
.iter()
.map(|d| d.category.get_category(&Game::Kh2))
.dedup()
.collect();
let drops = Drops::new(Game::Kh2, enemies);
tracing::info!("Generating the KH2 drops template");
let drops_template = DropsTemplate {
game: Game::Kh2,
drops,
material_kinds,
};
let drops_template = DropsTemplate { data: drops };
create_file("./out/kh2", "drops", drops_template).unwrap();
}

View File

@ -1,10 +1,9 @@
use askama::Template;
use food::Recipes;
use itertools::Itertools;
use crate::{
RuntimeModule,
common::{Game, enemy::Enemy, materials::MaterialDrops},
common::{Game, drops::Drops, enemy::Enemy},
create_file,
};
@ -16,9 +15,7 @@ const RECIPES_PATH: &str = "./input/kh3/recipes.toml";
#[derive(Template)]
#[template(path = "pages/kh3/drops.html")]
struct DropsTemplate {
pub game: Game,
pub drops: Vec<MaterialDrops>,
pub material_kinds: Vec<String>,
pub data: Drops,
}
#[derive(Template)]
@ -34,23 +31,14 @@ impl RuntimeModule for Module {
tracing::info!("Loading enemy data from {}", ENEMIES_PATH);
let enemies = Enemy::import(ENEMIES_PATH);
let drops = MaterialDrops::new(enemies);
let material_kinds = drops
.iter()
.map(|d| d.category.get_category(&Game::Kh3))
.dedup()
.collect();
let drops = Drops::new(Game::Kh3, enemies);
tracing::info!("Loading recipes data from {}", RECIPES_PATH);
let recipes_str = std::fs::read_to_string(RECIPES_PATH).unwrap();
let recipes = toml::from_str::<Recipes>(&recipes_str).unwrap();
tracing::info!("Generating the KH3 drops template");
let drops_template = DropsTemplate {
game: Game::Kh3,
drops,
material_kinds,
};
let drops_template = DropsTemplate { data: drops };
create_file("./out/kh3", "drops", drops_template).unwrap();

View File

@ -1,3 +1,4 @@
<div class="tracked-filter">
<input
type="checkbox"
id="onlyTracked"
@ -6,11 +7,11 @@
value=""
/>
<label for="onlyTracked">Show only tracked</label>
<br />
</div>
<div class="material-filters">
{% for kind in material_kinds %}
<div>
{% for kind in data.material_kinds %}
<div style="flex: 0 1 {{+ data.get_filter_len() }}px;">
<input
type="checkbox"
id="{{ kind }}Filter"
@ -20,14 +21,11 @@
/>
<label for="{{ kind }}Filter">{{ kind|capitalize }}</label>
</div>
{#{% if loop.index0 == 6 %}
<br />
{% endif %}#}
{% endfor %}
</div>
<br />
{% for drop in drops %}
{% for drop in data.drops %}
{% call macros::drop("shard") %}
{% call macros::drop("stone") %}
{% call macros::drop("gem") %}

View File

@ -3,12 +3,12 @@
{% if drops.len() > 0 %}
<div
class="category-wrapper"
data-mat-kind="{{ drop.category.get_category(game) }}"
data-mat-kind="{{ drop.category.get_category(data.game) }}"
data-mat-type="{{ label }}"
>
<div class="category">
<img
src="../public/assets/materials/{{ drop.texture(game) }}.webp"
src="../public/assets/materials/{{ drop.texture(data.game) }}.webp"
width="64"
height="64"
/>