diff --git a/index.css b/index.css
index 4d6f7f15..db8ccb89 100644
--- a/index.css
+++ b/index.css
@@ -1227,7 +1227,7 @@ i.resetButton:active {
}
.ui-dialog input[type="number"] {
- width: 3.5em;
+ width: 4.5em;
}
.ui-dialog .disabled {
diff --git a/modules/markers-generator.js b/modules/markers-generator.js
index 4f2376d1..ed902be6 100644
--- a/modules/markers-generator.js
+++ b/modules/markers-generator.js
@@ -28,7 +28,7 @@ window.Markers = (function () {
{type: "pirates", icon: "🏴☠️", multiplier: 1, fn: addPirates},
{type: "statues", icon: "🗿", multiplier: 1, fn: addStatues},
{type: "ruines", icon: "🏺", multiplier: 1, fn: addRuines},
- {type: "portals", icon: "🌀", multiplier: isFantasy, fn: addPortals}
+ {type: "portals", icon: "🌀", multiplier: +isFantasy, fn: addPortals}
];
}
diff --git a/modules/ui/tools.js b/modules/ui/tools.js
index 1e9359a2..8574be29 100644
--- a/modules/ui/tools.js
+++ b/modules/ui/tools.js
@@ -6,7 +6,7 @@ toolsContent.addEventListener("click", function (event) {
tip("Please exit the customization mode first", false, "warning");
return;
}
- if (event.target.tagName !== "BUTTON") return;
+ if (!["BUTTON", "I"].includes(event.target.tagName)) return;
const button = event.target.id;
// click on open Editor buttons
@@ -64,6 +64,80 @@ toolsContent.addEventListener("click", function (event) {
// click on Configure regenerate buttons
if (button === "configRegenerateMarkers") {
+ const {markers} = pack;
+ const config = Markers.getConfig();
+
+ const headers = `
+ | Type |
+ Icon |
+ Multiplier |
+ Number |
+
`;
+ const lines = config.map(({type, icon, multiplier}, index) => {
+ const inputId = `markerIconInput${index}`;
+ return `
+ |
+
+
+
+ |
+ |
+ ${markers.filter(marker => marker.type === type).length} |
+
`;
+ });
+ const table = `${headers}${lines.join("")}
`;
+ alertMessage.innerHTML = table;
+
+ alertMessage.querySelectorAll("i").forEach(selectIconButton => {
+ selectIconButton.addEventListener("click", function () {
+ const input = this.previousElementSibling;
+ selectIcon(input.value, icon => (input.value = icon));
+ });
+ });
+
+ const applyChanges = () => {
+ const rows = alertMessage.querySelectorAll("tbody > tr");
+ const rowsData = Array.from(rows).map(row => {
+ const inputs = row.querySelectorAll("input");
+ return {
+ type: inputs[0].value,
+ icon: inputs[1].value,
+ multiplier: parseFloat(inputs[2].value)
+ };
+ });
+
+ const newConfig = config.map((markerType, index) => {
+ const {type, icon, multiplier} = rowsData[index];
+ return {...markerType, type, icon, multiplier};
+ });
+ Markers.setConfig(newConfig);
+
+ Markers.regenerate();
+ turnButtonOn("toggleMarkers");
+ drawMarkers();
+
+ $("#alert").dialog("close");
+ };
+
+ $("#alert").dialog({
+ resizable: false,
+ title: "Markers generation settings",
+ position: {my: "left top", at: "left+10 top+10", of: "svg", collision: "fit"},
+ buttons: {
+ Apply: applyChanges,
+ Cancel: function () {
+ $(this).dialog("close");
+ }
+ },
+ open: function () {
+ const buttons = $(this).dialog("widget").find(".ui-dialog-buttonset > button");
+ buttons[0].addEventListener("mousemove", () => tip("Apply changes and regenerate markers"));
+ buttons[1].addEventListener("mousemove", () => tip("Cancel changes"));
+ },
+ close: function () {
+ $(this).dialog("destroy");
+ }
+ });
}
// click on Add buttons
diff --git a/modules/ui/world-configurator.js b/modules/ui/world-configurator.js
index aa83eb82..22dccacb 100644
--- a/modules/ui/world-configurator.js
+++ b/modules/ui/world-configurator.js
@@ -18,6 +18,9 @@ function editWorld() {
buttons[2].addEventListener("mousemove", () => tip("Click to set map size to cover the Tropical latitudes"));
buttons[3].addEventListener("mousemove", () => tip("Click to set map size to cover the Southern latitudes"));
buttons[4].addEventListener("mousemove", () => tip("Click to restore default wind directions"));
+ },
+ close: function () {
+ $(this).dialog("destroy");
}
});