diff --git a/input/kh1/enemies/bandit.toml b/input/kh1/enemies/bandit.toml index 8656cd8..fafd23b 100644 --- a/input/kh1/enemies/bandit.toml +++ b/input/kh1/enemies/bandit.toml @@ -2,7 +2,7 @@ name = "Bandit" [[world]] name = "Agrabah" -room = ["Desert: Cave", "Treasure Room", "Lamp Chamber"] +rooms = ["Desert: Cave", "Treasure Room", "Lamp Chamber"] [[world]] name = "Monstro" diff --git a/input/kh1/enemies/bouncywild.toml b/input/kh1/enemies/bouncywild.toml index 160ea02..1b87e6a 100644 --- a/input/kh1/enemies/bouncywild.toml +++ b/input/kh1/enemies/bouncywild.toml @@ -5,7 +5,7 @@ name = "Deep Jungle" [[world]] name = "Monstro" -room = ["Bowels", "Stomach"] +rooms = ["Bowels", "Stomach"] [[world]] name = "End of the World" diff --git a/input/kh1/enemies/darkball.toml b/input/kh1/enemies/darkball.toml index 34aef05..f082b87 100644 --- a/input/kh1/enemies/darkball.toml +++ b/input/kh1/enemies/darkball.toml @@ -2,11 +2,11 @@ name = "Darkball" [[world]] name = "Traverse Town" -room = ["3rd District", "Gizmo Shop"] +rooms = ["3rd District", "Gizmo Shop"] [[world]] name = "Agrabah" -room = ["Bazaar", "Palace Gates"] +rooms = ["Bazaar", "Palace Gates"] [[world]] name = "Hollow Bastion" @@ -16,7 +16,7 @@ name = "End of the World" [[world]] name = "Neverland" -room = ["Ship: Freezer", "Captain's Cabin"] +rooms = ["Ship: Freezer", "Captain's Cabin"] [[drops]] name = "Hi-Potion" diff --git a/input/kh1/enemies/defender.toml b/input/kh1/enemies/defender.toml index 01b1109..3072c09 100644 --- a/input/kh1/enemies/defender.toml +++ b/input/kh1/enemies/defender.toml @@ -2,7 +2,7 @@ name = "Defender" [[world]] name = "Traverse Town" -room = ["3rd District", "Hotel Hallway", "Gizmo Shop"] +rooms = ["3rd District", "Hotel Hallway", "Gizmo Shop"] [[world]] name = "Hollow Bastion" diff --git a/input/kh1/enemies/green-requiem.toml b/input/kh1/enemies/green-requiem.toml index 61448c9..f583d5e 100644 --- a/input/kh1/enemies/green-requiem.toml +++ b/input/kh1/enemies/green-requiem.toml @@ -11,7 +11,7 @@ name = "Monstro" [[world]] name = "Deep Jungle" -room = ["Jungle: Cliff"] +rooms = ["Jungle: Cliff"] [[world]] name = "Hollow Bastion" diff --git a/input/kh1/enemies/pirate.toml b/input/kh1/enemies/pirate.toml index e20424f..b7a8736 100644 --- a/input/kh1/enemies/pirate.toml +++ b/input/kh1/enemies/pirate.toml @@ -2,7 +2,7 @@ name = "Pirate" [[world]] name = "Neverland" -room = ["Captain's Cabin"] +rooms = ["Captain's Cabin"] [[world]] name = "Monstro" diff --git a/input/kh1/enemies/powerwild.toml b/input/kh1/enemies/powerwild.toml index 684843c..8723a59 100644 --- a/input/kh1/enemies/powerwild.toml +++ b/input/kh1/enemies/powerwild.toml @@ -5,7 +5,7 @@ name = "Deep Jungle" [[world]] name = "Monstro" -room = ["Chamber 5", "Chamber 6"] +rooms = ["Chamber 5", "Chamber 6"] [[world]] name = "End of the World" diff --git a/input/kh1/enemies/red-nocturne.toml b/input/kh1/enemies/red-nocturne.toml index 55d6de9..bbd1151 100644 --- a/input/kh1/enemies/red-nocturne.toml +++ b/input/kh1/enemies/red-nocturne.toml @@ -2,7 +2,7 @@ name = "Red Nocturne" [[world]] name = "Monstro" -room = ["Chamber 6"] +rooms = ["Chamber 6"] [[world]] name = "End of the World" diff --git a/input/kh1/enemies/soldier.toml b/input/kh1/enemies/soldier.toml index 20245dc..33b8ed4 100644 --- a/input/kh1/enemies/soldier.toml +++ b/input/kh1/enemies/soldier.toml @@ -2,7 +2,7 @@ name = "Soldier" [[world]] name = "Agrabah" -room = ["Main Street"] +rooms = ["Main Street"] [[drops]] name = "Spirit Shard" diff --git a/input/kh3/enemies/air-soldier.toml b/input/kh3/enemies/air-soldier.toml index a3f8cc2..d528636 100644 --- a/input/kh3/enemies/air-soldier.toml +++ b/input/kh3/enemies/air-soldier.toml @@ -1,4 +1,5 @@ name = "Air Soldier" +icon = "air_soldier_kh3" [[world]] name = "Olympus" diff --git a/public/scripts/common/enemy-worlds.js b/public/scripts/common/enemy-worlds.js new file mode 100644 index 0000000..ac9a923 --- /dev/null +++ b/public/scripts/common/enemy-worlds.js @@ -0,0 +1,40 @@ +export function init() { + const enemies = document.querySelectorAll(".enemy"); + + for (const enemyWrapper of enemies) { + toggleWorldDisplay(enemyWrapper); + enemyWrapper.addEventListener("click", function () { + toggleWorldDisplay(this); + }); + } +} + +function toggleWorldDisplay(display) { + const showWorlds = display.dataset["showWorlds"] === "true"; + + const enemyWorlds = display.querySelector(".worlds"); + const worldsWrapper = display.querySelectorAll(".worlds > div"); + const worldsIcons = display.querySelectorAll(".worlds > div > img"); + + if (!showWorlds) { + enemyWorlds.style.width = "32px"; + for (const wrapper of worldsWrapper) { + wrapper.style.height = "32px"; + } + for (const icon of worldsIcons) { + icon.width = "32"; + icon.height = "32"; + } + } else { + enemyWorlds.style.width = "256px"; + for (const wrapper of worldsWrapper) { + wrapper.style.height = "auto"; + } + for (const icon of worldsIcons) { + icon.width = "64"; + icon.height = "64"; + } + } + + display.dataset["showWorlds"] = !showWorlds; +} diff --git a/public/scripts/kh1/drops.js b/public/scripts/kh1/drops.js index dab40ad..84ee074 100644 --- a/public/scripts/kh1/drops.js +++ b/public/scripts/kh1/drops.js @@ -1,12 +1,15 @@ import { - init, + init as matFilterInit, kindFilter, showOnlyTracked, track, } from "../common/mat-kind-filter.js"; +import { init as worldInit } from "../common/enemy-worlds.js"; + document.addEventListener("DOMContentLoaded", (event) => { - init(); + matFilterInit(); + worldInit(); }); Object.assign(window, { track }); diff --git a/public/styles/common/drops.css b/public/styles/common/drops.css index 805e36e..be8314b 100644 --- a/public/styles/common/drops.css +++ b/public/styles/common/drops.css @@ -7,6 +7,11 @@ display: flex; width: 100%; flex-wrap: wrap; + gap: 32px; + + .enemy { + display: flex; + } .drop { display: flex; @@ -40,4 +45,24 @@ /* } */ /* } */ } + + .worlds { + display: flex; + flex-direction: column; + width: 256px; + height: 316px; + overflow-x: hidden; + overflow-y: auto; + + div { + display: inline-flex; + margin-bottom: 16px; + font-size: 14px; + align-items: center; + + p { + margin-left: 8px; + } + } + } } diff --git a/src/common/enemy.rs b/src/common/enemy.rs index 427dc62..9ef9b9b 100644 --- a/src/common/enemy.rs +++ b/src/common/enemy.rs @@ -4,7 +4,7 @@ use serde::Deserialize; use super::materials::MaterialDetails; -#[derive(Debug, Deserialize, PartialEq, Eq)] +#[derive(Default, Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone)] pub struct Enemy { pub name: String, pub icon: Option, @@ -32,10 +32,10 @@ impl Enemy { for path in paths { let enemy_str = std::fs::read_to_string(path).unwrap(); let mut enemy = toml::from_str::(&enemy_str).unwrap(); - enemy - .drops - .iter_mut() - .for_each(|d| d.from = enemy.name.clone()); + enemy.drops.iter_mut().for_each(|d| { + d.from = enemy.name.clone(); + d.spawns = enemy.world.clone(); + }); enemies.push(enemy); } @@ -48,6 +48,8 @@ pub struct EnemyDrop { pub name: String, #[serde(skip)] pub from: String, + #[serde(skip)] + pub spawns: Vec, pub chance: EnemyDropChance, pub kind: EnemyDropKind, pub info: Option, @@ -84,9 +86,15 @@ impl Display for EnemyDropChance { } } -#[derive(Debug, Deserialize, PartialEq, Eq)] +#[derive(Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone)] pub struct SpawnLocation { pub name: String, #[serde(default)] pub rooms: Vec, } + +impl SpawnLocation { + pub fn texture(&self) -> String { + self.name.replace(" ", "-").to_lowercase() + } +} diff --git a/templates/macros/common/macros.html b/templates/macros/common/macros.html index 4b287ad..993020e 100644 --- a/templates/macros/common/macros.html +++ b/templates/macros/common/macros.html @@ -17,12 +17,41 @@
{% for drop in drops %} -
-
- {{ drop.from +}} - {{+ drop.chance }} +
+
+
+ {{ drop.from +}} + {{+ drop.chance }} +
+
+ {% for spawn in drop.spawns %} + {% if spawn.rooms.len() > 0 %} + {% for room in spawn.rooms %} +
+ +

+ {{ spawn.name +}} - {{+ room }} +

+
+ {% endfor %} + {% else %} +
+ +

{{ spawn.name }}

+
+ {% endif %} + {% endfor %} +
{% endfor %}