mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
fix: (v1.91.00)
This commit is contained in:
parent
dafd313395
commit
1d921c18af
11 changed files with 106 additions and 46 deletions
|
|
@ -1182,7 +1182,7 @@ async function editStates() {
|
|||
|
||||
async function editCultures() {
|
||||
if (customization) return;
|
||||
const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.89.09");
|
||||
const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.91.00");
|
||||
Editor.open();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,13 +112,13 @@ function editEmblem(type, id, el) {
|
|||
if (type === "burg") name = "Burg of " + name;
|
||||
document.getElementById("emblemArmiger").innerText = name;
|
||||
|
||||
if (el.coa === "custom") emblemShapeSelector.disabled = true;
|
||||
if (el.coa.custom) emblemShapeSelector.disabled = true;
|
||||
else {
|
||||
emblemShapeSelector.disabled = false;
|
||||
emblemShapeSelector.value = el.coa.shield;
|
||||
}
|
||||
|
||||
const size = el.coaSize || 1;
|
||||
const size = el.coa.size || 1;
|
||||
document.getElementById("emblemSizeSlider").value = size;
|
||||
document.getElementById("emblemSizeNumber").value = size;
|
||||
}
|
||||
|
|
@ -178,7 +178,9 @@ function editEmblem(type, id, el) {
|
|||
}
|
||||
|
||||
function changeSize() {
|
||||
const size = (el.coaSize = +this.value);
|
||||
const size = +this.value;
|
||||
el.coa.size = size;
|
||||
|
||||
document.getElementById("emblemSizeSlider").value = size;
|
||||
document.getElementById("emblemSizeNumber").value = size;
|
||||
|
||||
|
|
@ -189,8 +191,9 @@ function editEmblem(type, id, el) {
|
|||
// re-append use element
|
||||
const categotySize = +g.attr("font-size");
|
||||
const shift = (categotySize * size) / 2;
|
||||
const x = el.x || el.pole[0];
|
||||
const y = el.y || el.pole[1];
|
||||
const x = el.coa.x || el.x || el.pole[0];
|
||||
const y = el.coa.y || el.y || el.pole[1];
|
||||
|
||||
g.append("use")
|
||||
.attr("data-i", el.i)
|
||||
.attr("x", rn(x - shift), 2)
|
||||
|
|
@ -220,7 +223,7 @@ function editEmblem(type, id, el) {
|
|||
}
|
||||
|
||||
function openInArmoria() {
|
||||
const coa = el.coa && el.coa !== "custom" ? el.coa : {t1: "sable"};
|
||||
const coa = el.coa && !el.coa.custom ? el.coa : {t1: "sable"};
|
||||
const json = JSON.stringify(coa).replaceAll("#", "%23");
|
||||
const url = `https://azgaar.github.io/Armoria/?coa=${json}&from=FMG`;
|
||||
openURL(url);
|
||||
|
|
@ -281,7 +284,13 @@ function editEmblem(type, id, el) {
|
|||
defs.insertAdjacentHTML("beforeend", svg);
|
||||
|
||||
if (oldEmblem) oldEmblem.remove();
|
||||
el.coa = "custom";
|
||||
|
||||
const customCoa = {custom: true};
|
||||
if (el.coa.size) customCoa.size = el.coa.size;
|
||||
if (el.coa.x) customCoa.x = el.coa.x;
|
||||
if (el.coa.y) customCoa.y = el.coa.y;
|
||||
el.coa = customCoa;
|
||||
|
||||
emblemShapeSelector.disabled = true;
|
||||
};
|
||||
|
||||
|
|
@ -509,13 +518,21 @@ function editEmblem(type, id, el) {
|
|||
}
|
||||
|
||||
function dragEmblem() {
|
||||
const tr = parseTransform(this.getAttribute("transform"));
|
||||
const x = +tr[0] - d3.event.x,
|
||||
y = +tr[1] - d3.event.y;
|
||||
const x = Number(this.getAttribute("x")) - d3.event.x;
|
||||
const y = Number(this.getAttribute("y")) - d3.event.y;
|
||||
|
||||
d3.event.on("drag", function () {
|
||||
const transform = `translate(${x + d3.event.x},${y + d3.event.y})`;
|
||||
this.setAttribute("transform", transform);
|
||||
this.setAttribute("x", x + d3.event.x);
|
||||
this.setAttribute("y", y + d3.event.y);
|
||||
});
|
||||
|
||||
d3.event.on("end", function () {
|
||||
const categotySize = Number(this.parentNode.getAttribute("font-size"));
|
||||
const size = el.coa.size || 1;
|
||||
const shift = (categotySize * size) / 2;
|
||||
|
||||
el.coa.x = rn(x + d3.event.x + shift, 2);
|
||||
el.coa.y = rn(y + d3.event.y + shift, 2);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1749,9 +1749,9 @@ function drawEmblems() {
|
|||
TIME && console.time("drawEmblems");
|
||||
const {states, provinces, burgs} = pack;
|
||||
|
||||
const validStates = states.filter(s => s.i && !s.removed && s.coa && s.coaSize != 0);
|
||||
const validProvinces = provinces.filter(p => p.i && !p.removed && p.coa && p.coaSize != 0);
|
||||
const validBurgs = burgs.filter(b => b.i && !b.removed && b.coa && b.coaSize != 0);
|
||||
const validStates = states.filter(s => s.i && !s.removed && s.coa && s.coa.size !== 0);
|
||||
const validProvinces = provinces.filter(p => p.i && !p.removed && p.coa && p.coa.size !== 0);
|
||||
const validBurgs = burgs.filter(b => b.i && !b.removed && b.coa && b.coa.size !== 0);
|
||||
|
||||
const getStateEmblemsSize = () => {
|
||||
const startSize = minmax((graphHeight + graphWidth) / 40, 10, 100);
|
||||
|
|
@ -1777,26 +1777,26 @@ function drawEmblems() {
|
|||
const sizeBurgs = getBurgEmblemSize();
|
||||
const burgCOAs = validBurgs.map(burg => {
|
||||
const {x, y} = burg;
|
||||
const size = burg.coaSize || 1;
|
||||
const size = burg.coa.size || 1;
|
||||
const shift = (sizeBurgs * size) / 2;
|
||||
return {type: "burg", i: burg.i, x, y, size, shift};
|
||||
return {type: "burg", i: burg.i, x: burg.coa.x || x, y: burg.coa.y || y, size, shift};
|
||||
});
|
||||
|
||||
const sizeProvinces = getProvinceEmblemsSize();
|
||||
const provinceCOAs = validProvinces.map(province => {
|
||||
if (!province.pole) getProvincesVertices();
|
||||
const [x, y] = province.pole || pack.cells.p[province.center];
|
||||
const size = province.coaSize || 1;
|
||||
const size = province.coa.size || 1;
|
||||
const shift = (sizeProvinces * size) / 2;
|
||||
return {type: "province", i: province.i, x, y, size, shift};
|
||||
return {type: "province", i: province.i, x: province.coa.x || x, y: province.coa.y || y, size, shift};
|
||||
});
|
||||
|
||||
const sizeStates = getStateEmblemsSize();
|
||||
const stateCOAs = validStates.map(state => {
|
||||
const [x, y] = state.pole || pack.cells.p[state.center];
|
||||
const size = state.coaSize || 1;
|
||||
const size = state.coa.size || 1;
|
||||
const shift = (sizeStates * size) / 2;
|
||||
return {type: "state", i: state.i, x, y, size, shift};
|
||||
return {type: "state", i: state.i, x: state.coa.x || x, y: state.coa.y || y, size, shift};
|
||||
});
|
||||
|
||||
const nodes = burgCOAs.concat(provinceCOAs).concat(stateCOAs);
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ function changeEmblemShape(emblemShape) {
|
|||
};
|
||||
|
||||
pack.states.forEach(state => {
|
||||
if (!state.i || state.removed || !state.coa || state.coa === "custom") return;
|
||||
if (!state.i || state.removed || !state.coa || state.coa.custom) return;
|
||||
const newShield = specificShape || COA.getShield(state.culture, null);
|
||||
if (newShield === state.coa.shield) return;
|
||||
state.coa.shield = newShield;
|
||||
|
|
@ -389,7 +389,7 @@ function changeEmblemShape(emblemShape) {
|
|||
});
|
||||
|
||||
pack.provinces.forEach(province => {
|
||||
if (!province.i || province.removed || !province.coa || province.coa === "custom") return;
|
||||
if (!province.i || province.removed || !province.coa || province.coa.custom) return;
|
||||
const culture = pack.cells.culture[province.center];
|
||||
const newShield = specificShape || COA.getShield(culture, province.state);
|
||||
if (newShield === province.coa.shield) return;
|
||||
|
|
@ -398,7 +398,7 @@ function changeEmblemShape(emblemShape) {
|
|||
});
|
||||
|
||||
pack.burgs.forEach(burg => {
|
||||
if (!burg.i || burg.removed || !burg.coa || burg.coa === "custom") return;
|
||||
if (!burg.i || burg.removed || !burg.coa || burg.coa.custom) return;
|
||||
const newShield = specificShape || COA.getShield(burg.culture, burg.state);
|
||||
if (newShield === burg.coa.shield) return;
|
||||
burg.coa.shield = newShield;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue