From bd7b7c2a5dd82d1c5767af2799e00eb22d85144f Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sat, 20 Feb 2021 18:10:18 +0300 Subject: [PATCH] v1.5.42 edit emblem button --- index.html | 1 + modules/ui/general.js | 6 ++++++ modules/ui/tools.js | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/index.html b/index.html index 06032157..5a33c573 100644 --- a/index.html +++ b/index.html @@ -1289,6 +1289,7 @@ + diff --git a/modules/ui/general.js b/modules/ui/general.js index 90070057..4ad5a21f 100644 --- a/modules/ui/general.js +++ b/modules/ui/general.js @@ -19,6 +19,12 @@ document.getElementById("dialogs").addEventListener("mousemove", showDataTip); document.getElementById("optionsContainer").addEventListener("mousemove", showDataTip); document.getElementById("exitCustomization").addEventListener("mousemove", showDataTip); +/** + * @param {string} tip Tooltip text + * @param {boolean} main Show above other tooltips + * @param {string} type Message type (color): error, warn, success + * @param {number} time Timeout to auto hide, ms + */ function tip(tip = "Tip is undefined", main, type, time) { tooltip.innerHTML = tip; tooltip.style.background = "linear-gradient(0.1turn, #ffffff00, #5e5c5c80, #ffffff00)"; diff --git a/modules/ui/tools.js b/modules/ui/tools.js index 5269e185..51abcab0 100644 --- a/modules/ui/tools.js +++ b/modules/ui/tools.js @@ -14,6 +14,7 @@ toolsContent.addEventListener("click", function(event) { if (button === "editDiplomacyButton") editDiplomacy(); else if (button === "editCulturesButton") editCultures(); else if (button === "editReligions") editReligions(); else + if (button === "editEmblemButton") openEmblemEditor(); else if (button === "editNamesBaseButton") editNamesbase(); else if (button === "editUnitsButton") editUnits(); else if (button === "editNotesButton") editNotes(); else @@ -72,6 +73,26 @@ function processFeatureRegeneration(event, button) { if (button === "regenerateZones") regenerateZones(event); } +async function openEmblemEditor() { + let type, id, el; + + if (pack.states[1]?.coa) { + type = "state"; + id = "stateCOA1"; + el = pack.states[1]; + } else if (pack.burgs[1]?.coa) { + type = "burg"; + id = "burgCOA1"; + el = pack.burgs[1]; + } else { + tip("No emblems to edit, please generate states and burgs first", false, "error"); + return; + } + + await COArenderer.trigger(id, el.coa); + editEmblem(type, id, el); +} + function regenerateRivers() { Rivers.generate(); Rivers.specify();