KH2 mats filtering
parent
2464e440a3
commit
438091d3b4
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "khguide"
|
name = "khguide"
|
||||||
version = "1.1.0"
|
version = "1.2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
15
src/kh2.rs
15
src/kh2.rs
|
@ -5,6 +5,21 @@ use serde::Deserialize;
|
||||||
|
|
||||||
use crate::create_file;
|
use crate::create_file;
|
||||||
|
|
||||||
|
pub const MATERIAL_KINDS: &[&str] = &[
|
||||||
|
"blazing",
|
||||||
|
"bright",
|
||||||
|
"dark",
|
||||||
|
"dense",
|
||||||
|
"energy",
|
||||||
|
"frost",
|
||||||
|
"lightning",
|
||||||
|
"lucid",
|
||||||
|
"power",
|
||||||
|
"remembrance",
|
||||||
|
"serenity",
|
||||||
|
"twilight",
|
||||||
|
];
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, PartialEq, Eq)]
|
||||||
pub struct MaterialDrops {
|
pub struct MaterialDrops {
|
||||||
kind: String,
|
kind: String,
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
{% for kind in MATERIAL_KINDS %}
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="{{ kind }}Filter"
|
||||||
|
name="kindFilter"
|
||||||
|
autocomplete="off"
|
||||||
|
value="{{ kind }}"
|
||||||
|
/>
|
||||||
|
<label for="{{ kind }}Filter">{{ kind|capitalize }}</label>
|
||||||
|
{% if loop.index0 == 6 %}
|
||||||
|
<br />
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
|
@ -0,0 +1,8 @@
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="onlyTracked"
|
||||||
|
name="onlyTracked"
|
||||||
|
autocomplete="off"
|
||||||
|
value=""
|
||||||
|
/>
|
||||||
|
<label for="onlyTracked">Show only tracked</label>
|
|
@ -58,6 +58,32 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
margin-left: 16px;
|
||||||
|
background: #444;
|
||||||
|
color: #fff;
|
||||||
|
padding: 8px;
|
||||||
|
border-color: #555;
|
||||||
|
border-bottom-color: rgb(85, 85, 85);
|
||||||
|
border-style: groove;
|
||||||
|
border-bottom-color: #0a0;
|
||||||
|
transition-duration: 0.1s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #4f4f4f;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
background: #3f3f3f;
|
||||||
|
transform: translateY(1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
{% block head %}{% endblock %}
|
{% block head %}{% endblock %}
|
||||||
|
|
|
@ -1,21 +1,28 @@
|
||||||
{% macro drop(label) %}
|
{% macro drop(label) %}
|
||||||
<div class="category">
|
<div
|
||||||
<img
|
class="category-wrapper"
|
||||||
src="../assets/materials/{{ category.kind }}/{{ label }}.webp"
|
data-mat-kind="{{ category.kind }}"
|
||||||
width="64"
|
data-mat-type="{{ label }}"
|
||||||
height="64"
|
>
|
||||||
/>
|
<div class="category">
|
||||||
<h1>{{ category.kind|capitalize +}} {{+ label|capitalize }}</h1>
|
<img
|
||||||
</div>
|
src="../assets/materials/{{ category.kind }}/{{ label }}.webp"
|
||||||
<div class="enemies">
|
width="64"
|
||||||
{% for drop in category.drops(label) %}
|
height="64"
|
||||||
<div class="drop">
|
/>
|
||||||
<div
|
<h1>{{ category.kind|capitalize +}} {{+ label|capitalize }}</h1>
|
||||||
style="background-image: url('../assets/enemies/{{ drop.texture() }}.webp');"
|
<button onclick="track(this)">Start tracking</button>
|
||||||
></div>
|
</div>
|
||||||
<span>{{ drop.from +}}</span>
|
<div class="enemies">
|
||||||
<span>{{+ drop.chance }}%</span>
|
{% for drop in category.drops(label) %}
|
||||||
</div>
|
<div class="drop">
|
||||||
{% endfor %}
|
<div
|
||||||
|
style="background-image: url('../assets/enemies/{{ drop.texture() }}.webp');"
|
||||||
|
></div>
|
||||||
|
<span>{{ drop.from +}}</span>
|
||||||
|
<span>{{+ drop.chance }}%</span>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
|
@ -26,4 +26,11 @@
|
||||||
<li><a href="./kh3/food-sim.html">Food Simulator</a></li>
|
<li><a href="./kh3/food-sim.html">Food Simulator</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if cfg!(feature = "kh2") %}
|
||||||
|
<h1>Kingdom Hearts II</h1>
|
||||||
|
<ul>
|
||||||
|
<li><a href="./kh2/drops.html">Material Drops</a></li>
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -46,9 +46,76 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<script>
|
||||||
|
let showOnlyTracked = false;
|
||||||
|
let kindFilter = new Set();
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", (event) => {
|
||||||
|
const onlyTrackedFilter = document.querySelector(
|
||||||
|
'input[name="onlyTracked"]',
|
||||||
|
);
|
||||||
|
|
||||||
|
onlyTrackedFilter.addEventListener("input", function () {
|
||||||
|
showOnlyTracked = this.checked ? true : false;
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
|
||||||
|
const kindFilters = document.querySelectorAll(
|
||||||
|
'input[type="checkbox"][name="kindFilter"]',
|
||||||
|
);
|
||||||
|
|
||||||
|
kindFilters.forEach(function (item, index) {
|
||||||
|
item.addEventListener("input", function () {
|
||||||
|
if (this.checked) {
|
||||||
|
kindFilter.add(this.value);
|
||||||
|
} else {
|
||||||
|
kindFilter.delete(this.value);
|
||||||
|
}
|
||||||
|
console.log(kindFilter);
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function track(element) {
|
||||||
|
let parent = element.parentElement.parentElement;
|
||||||
|
let isTracked = parent.dataset["isTracked"] ?? false;
|
||||||
|
isTracked = isTracked === "true" ? false : true;
|
||||||
|
parent.dataset["isTracked"] = isTracked;
|
||||||
|
element.innerHTML = isTracked ? "Stop tracking" : "Start tracking";
|
||||||
|
element.style["border-bottom-color"] = isTracked ? "#a00" : "#0a0";
|
||||||
|
filter();
|
||||||
|
}
|
||||||
|
|
||||||
|
function filter() {
|
||||||
|
const categories = document.querySelectorAll(".category-wrapper");
|
||||||
|
|
||||||
|
for (const category of categories) {
|
||||||
|
let isTracked = category.dataset["isTracked"] == "true";
|
||||||
|
let kind = category.dataset["matKind"];
|
||||||
|
let type = category.dataset["matType"];
|
||||||
|
|
||||||
|
category.style.display = "";
|
||||||
|
|
||||||
|
if (showOnlyTracked && !isTracked) {
|
||||||
|
category.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kindFilter.size > 0) {
|
||||||
|
if (!kindFilter.has(kind)) {
|
||||||
|
category.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% include "components/kh2/only-tracked-filter.html" %}
|
||||||
|
<br />
|
||||||
|
{% include "components/kh2/kind-filters.html" %}
|
||||||
|
<br />
|
||||||
|
|
||||||
{% for category in drops %}
|
{% for category in drops %}
|
||||||
{% call macros::drop("shard") %}
|
{% call macros::drop("shard") %}
|
||||||
|
|
Loading…
Reference in New Issue