Merge pull request #570 from Azgaar/dev

Dev
This commit is contained in:
Azgaar 2021-02-15 23:13:33 +03:00 committed by GitHub
commit 81fd32e99f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 28 deletions

View file

@ -2863,8 +2863,8 @@
<div id="emblemsBottom"> <div id="emblemsBottom">
<button id="emblemsRegenerate" data-tip="Regenerate emblem" class="icon-shuffle"></button> <button id="emblemsRegenerate" data-tip="Regenerate emblem" class="icon-shuffle"></button>
<button id="emblemsArmoria" data-tip="Edit the emblem in Armoria - dedicated heraldry editor. Download emblem and upload it back map the generator" class="icon-brush"></button> <button id="emblemsArmoria" data-tip="Edit the emblem in Armoria - dedicated heraldry editor. Download emblem and upload it back map the generator" class="icon-brush"></button>
<button id="emblemsUpload" data-tip="Upload png, jpg or svg image from Armoria or other sources as emblem" class="icon-upload"></button>
<button id="emblemsDownload" data-tip="Set size, select file format and download emblem image" class="icon-download"></button> <button id="emblemsDownload" data-tip="Set size, select file format and download emblem image" class="icon-download"></button>
<button id="emblemsUpload" data-tip="Upload png, jpg or svg image from Armoria or other sources as emblem" class="icon-upload"></button>
<button id="emblemsGallery" data-tip="Download emblems gallery as html document (open in browser; downloading takes some time)" class="icon-layer-group"></button> <button id="emblemsGallery" data-tip="Download emblems gallery as html document (open in browser; downloading takes some time)" class="icon-layer-group"></button>
<button id="emblemsFocus" data-tip="Show emblem associated area or place" class="icon-target"></button> <button id="emblemsFocus" data-tip="Show emblem associated area or place" class="icon-target"></button>
</div> </div>

3
libs/jquery-ui.css vendored
View file

@ -434,6 +434,9 @@ body .ui-dialog {
font-family: Arial,Helvetica,sans-serif; font-family: Arial,Helvetica,sans-serif;
font-size: 1em; font-size: 1em;
} }
.ui-widget button[class^="icon-"] {
padding: 1px 6px;
}
.ui-widget.ui-widget-content { .ui-widget.ui-widget-content {
border: 1px solid #5e4fa2; border: 1px solid #5e4fa2;
color: #333333; color: #333333;

View file

@ -467,7 +467,7 @@
const emblemShape = document.getElementById("emblemShape").value; const emblemShape = document.getElementById("emblemShape").value;
if (emblemShape === "state" && state && pack.states[state].coa) return pack.states[state].coa.shield; if (emblemShape === "state" && state && pack.states[state].coa) return pack.states[state].coa.shield;
if (pack.cultures[culture].shield) return pack.cultures[culture].shield; if (pack.cultures[culture].shield) return pack.cultures[culture].shield;
console.error("Emblem shape is not defined on culture level", pack.cultures[culture]); console.error("Shield shape is not defined on culture level", pack.cultures[culture]);
return "heater"; return "heater";
} }

View file

@ -1060,27 +1060,31 @@ function parseLoadedData(data) {
} }
if (version < 1.5) { if (version < 1.5) {
// v 1.5 added emblems
emblems = viewbox.append("g").attr("id", "emblems").style("display", "none");
emblems.append("g").attr("id", "burgEmblems");
emblems.append("g").attr("id", "provinceEmblems");
emblems.append("g").attr("id", "stateEmblems");
regenerateEmblems();
toggleEmblems();
// not need to store default styles from v 1.5 // not need to store default styles from v 1.5
localStorage.removeItem("styleClean"); localStorage.removeItem("styleClean");
localStorage.removeItem("styleGloom"); localStorage.removeItem("styleGloom");
localStorage.removeItem("styleAncient"); localStorage.removeItem("styleAncient");
localStorage.removeItem("styleMonochrome"); localStorage.removeItem("styleMonochrome");
// v 1.5 cultures has shield attribute
pack.cultures.forEach(culture => {
if (culture.removed) return;
culture.shield = Cultures.getRandomShield();
});
// v 1.5 added burg type value // v 1.5 added burg type value
pack.burgs.forEach(burg => { pack.burgs.forEach(burg => {
if (!burg.i || burg.removed) return; if (!burg.i || burg.removed) return;
burg.type = BurgsAndStates.getType(burg.cell, burg.port); burg.type = BurgsAndStates.getType(burg.cell, burg.port);
}); });
BurgsAndStates.getType(cell, false); // v 1.5 added emblems
emblems = viewbox.insert("g", "#population").attr("id", "emblems").style("display", "none");
emblems.append("g").attr("id", "burgEmblems");
emblems.append("g").attr("id", "provinceEmblems");
emblems.append("g").attr("id", "stateEmblems");
regenerateEmblems();
toggleEmblems();
} }
}() }()

View file

@ -13,7 +13,7 @@ function editEmblem(type, id, el) {
updateElementSelectors(type, id, el); updateElementSelectors(type, id, el);
$("#emblemEditor").dialog({ $("#emblemEditor").dialog({
title: "Edit Emblem", resizable: true, width: "18em", height: "auto", title: "Edit Emblem", resizable: true, width: "18.2em", height: "auto",
position: {my: "left top", at: "left+10 top+10", of: "svg", collision: "fit"}, position: {my: "left top", at: "left+10 top+10", of: "svg", collision: "fit"},
close: closeEmblemEditor close: closeEmblemEditor
}); });
@ -181,7 +181,7 @@ function editEmblem(type, id, el) {
function openInArmoria() { 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 json = JSON.stringify(coa).replaceAll("#", "%23");
const url = `http://azgaar.github.io/Armoria/?coa=${json}&from=FMG`; const url = `https://azgaar.github.io/Armoria/?coa=${json}&from=FMG`;
openURL(url); openURL(url);
} }
@ -233,10 +233,10 @@ function editEmblem(type, id, el) {
buttons.classList.toggle("hidden"); buttons.classList.toggle("hidden");
} }
function download(format) { async function download(format) {
const coa = document.getElementById(id); const coa = document.getElementById(id);
const size = +emblemsDownloadSize.value; const size = +emblemsDownloadSize.value;
const url = getURL(coa, el.coa, size); const url = await getURL(coa, size);
const link = document.createElement("a"); const link = document.createElement("a");
link.download = getFileName(`Emblem ${el.fullName || el.name}`) + "." + format; link.download = getFileName(`Emblem ${el.fullName || el.name}`) + "." + format;
@ -247,7 +247,6 @@ function editEmblem(type, id, el) {
function downloadSVG(url, link) { function downloadSVG(url, link) {
link.href = url; link.href = url;
link.click(); link.click();
window.setTimeout(() => window.URL.revokeObjectURL(URL), 5000);
} }
function downloadRaster(format, url, link, size) { function downloadRaster(format, url, link, size) {
@ -264,25 +263,22 @@ function editEmblem(type, id, el) {
ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillRect(0, 0, canvas.width, canvas.height);
} }
ctx.drawImage(img, 0, 0, canvas.width, canvas.height); ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
const URL = canvas.toDataURL("image/" + format, .92); const dataURL = canvas.toDataURL("image/" + format, .92);
link.href = URL; link.href = dataURL;
link.click(); link.click();
window.setTimeout(() => window.URL.revokeObjectURL(URL), 5000); window.setTimeout(() => window.URL.revokeObjectURL(dataURL), 6000);
} }
} }
function getURL(svg, coa, size) { async function getURL(svg, size) {
const serialized = getSVG(svg, coa, size);
const blob = new Blob([serialized], { type: 'image/svg+xml;charset=utf-8' });
const url = window.URL.createObjectURL(blob);
return url;
}
function getSVG(svg, size) {
const clone = svg.cloneNode(true); // clone svg const clone = svg.cloneNode(true); // clone svg
clone.setAttribute("width", size); clone.setAttribute("width", size);
clone.setAttribute("height", size); clone.setAttribute("height", size);
return (new XMLSerializer()).serializeToString(clone); const serialized = (new XMLSerializer()).serializeToString(clone);
const blob = new Blob([serialized], {type: 'image/svg+xml;charset=utf-8'});
const url = window.URL.createObjectURL(blob);
window.setTimeout(() => window.URL.revokeObjectURL(url), 6000);
return url;
} }
function downloadGallery() { function downloadGallery() {