mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
v1.4.09
This commit is contained in:
parent
bb0251c020
commit
617e8d4306
12 changed files with 86 additions and 163 deletions
|
|
@ -45,7 +45,7 @@ function editStates() {
|
|||
if (cl.contains("icon-coa")) stateOpenCOA(ev, state); else
|
||||
if (cl.contains("icon-star-empty")) stateCapitalZoomIn(state); else
|
||||
if (cl.contains("culturePopulation")) changePopulation(state); else
|
||||
if (cl.contains("icon-pin")) focusOnState(state, cl); else
|
||||
if (cl.contains("icon-pin")) toggleFog(state, cl); else
|
||||
if (cl.contains("icon-trash-empty")) stateRemovePrompt(state);
|
||||
});
|
||||
|
||||
|
|
@ -171,6 +171,8 @@ function editStates() {
|
|||
|
||||
function stateHighlightOn(event) {
|
||||
if (!layerIsOn("toggleStates")) return;
|
||||
if (defs.select("#fog path").size()) return;
|
||||
|
||||
const state = +event.target.dataset.id;
|
||||
if (customization || !state) return;
|
||||
const d = regions.select("#state"+state).attr("d");
|
||||
|
|
@ -405,26 +407,11 @@ function editStates() {
|
|||
recalculateStates();
|
||||
}
|
||||
|
||||
function focusOnState(state, cl) {
|
||||
function toggleFog(state, cl) {
|
||||
if (customization) return;
|
||||
|
||||
const inactive = cl.contains("inactive");
|
||||
const path = statesBody.select("#state"+state).attr("d"), id = "focusState"+state;
|
||||
cl.contains("inactive") ? fog(id, path) : unfog(id);
|
||||
cl.toggle("inactive");
|
||||
|
||||
if (inactive) {
|
||||
if (defs.select("#fog #focusState"+state).size()) return;
|
||||
fogging.style("display", "block");
|
||||
const path = statesBody.select("#state"+state).attr("d");
|
||||
defs.select("#fog").append("path").attr("d", path).attr("fill", "black").attr("id", "focusState"+state);
|
||||
fogging.append("path").attr("d", path).attr("id", "focusStateHalo"+state)
|
||||
.attr("fill", "none").attr("stroke", pack.states[state].color).attr("filter", "url(#blur5)");
|
||||
} else unfocus(state);
|
||||
}
|
||||
|
||||
function unfocus(s) {
|
||||
defs.select("#focusState"+s).remove();
|
||||
fogging.select("#focusStateHalo"+s).remove();
|
||||
if (!defs.selectAll("#fog path").size()) fogging.style("display", "none"); // all items are de-focused
|
||||
}
|
||||
|
||||
function stateRemovePrompt(state) {
|
||||
|
|
@ -446,7 +433,7 @@ function editStates() {
|
|||
statesBody.select("#state"+state).remove();
|
||||
statesBody.select("#state-gap"+state).remove();
|
||||
statesHalo.select("#state-border"+state).remove();
|
||||
unfocus(state);
|
||||
unfog("focusState"+state);
|
||||
const label = document.querySelector("#stateLabel"+state);
|
||||
if (label) label.remove();
|
||||
pack.burgs.forEach(b => {if(b.state === state) b.state = 0;});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue