diff --git a/index.css b/index.css index c8d5efb02..d129d5a5b 100644 --- a/index.css +++ b/index.css @@ -2271,6 +2271,7 @@ svg.button { user-select: none; } + .dontAsk { display: inline-block; margin: 0.9em 0 0 0.6em; diff --git a/index.html b/index.html index ab9a073a5..4071ba58d 100644 --- a/index.html +++ b/index.html @@ -274,7 +274,7 @@
Click to create a new map:
-Warning! This operation is destructive and irreversible. Don't forget to save your map!
-Points number | -- - | -- - | -
Shift | -- X: - Y: - | -|
Rotate | -- - | -- - | -
Mirror | -- - - - - - | -
+ This operation is destructive and irreversible. It will create a completely new map based on the current one. Don't forget to save the current project + as a .map file first! +
+- Warning! This operation is destructive and irreversible. Don't forget to save your original map! + +
+ This operation is destructive and irreversible. It will create a completely new map based on the current one. Don't forget to save the current project + as a .map file first!
-Settings to be changed: Population rate, map pixel size.
-Data to be copied: Heightmap, Biome, Religion, Population, Precipitation, Cultures, States, Provinces, Regiments (military), Markers.
-Data to be destroyed (regenerated): Zones, Roads, Rivers (mostly regenerate at the same place).
-Remapping Burgs (cities) may be imprecise, you will need to fix missing or wrongly mapped burgs manually.
-Lock remapped items for:
-Settings to be changed: population rate, map pixel size
+Data to be copied: heightmap, biomes, religions, population, precipitation, cultures, states, provinces, military regiments
+Data to be regenerated: zones, roads, rivers
+Burgs may be remapped incorrectly, manual change is required
+ +Keep data for:
+Extra / experimental features:
-Experimental features:
+Join our ${discord} and ${reddit} to ask questions, share maps, discuss the Generator and Worlbuilding, report bugs and propose new features.
diff --git a/modules/submap.js b/modules/submap.js index 6c1611fe2..6ec6d2e9c 100644 --- a/modules/submap.js +++ b/modules/submap.js @@ -308,7 +308,7 @@ window.Submap = (function () { if (options.lockMarkers) m.lock = true; } } - drawMarkers(); + if (layerIsOn("toggleMarkers")) drawMarkers(); stage("Redraw emblems."); drawEmblems(); diff --git a/modules/ui/options.js b/modules/ui/options.js index 89642f5d9..fde657c18 100644 --- a/modules/ui/options.js +++ b/modules/ui/options.js @@ -335,27 +335,35 @@ function copyMapURL() { .catch(err => tip("Could not copy URL: " + err, false, "error", 5000)); } -const cellsDensityConstants = { - 1: 1000, - 2: 2000, - 3: 5000, - 4: 10000, - 5: 20000, - 6: 30000, - 7: 40000, - 8: 50000, - 9: 60000, - 10: 70000, - 11: 80000, - 12: 90000, - 13: 100000, +const cellsDensityMap = { + 1: 1000, + 2: 2000, + 3: 5000, + 4: 10000, + 5: 20000, + 6: 30000, + 7: 40000, + 8: 50000, + 9: 60000, + 10: 70000, + 11: 80000, + 12: 90000, + 13: 100000 }; function changeCellsDensity(value) { - const cells = value in cellsDensityConstants? cellsDensityConstants[value]: 1000; + const cells = cellsDensityMap[value] || 1000; pointsInput.dataset.cells = cells; - pointsOutput_formatted.value = cells / 1000 + "K"; - pointsOutput_formatted.style.color = cells > 50000 ? "#b12117" : cells !== 10000 ? "#dfdf12" : "#053305"; + pointsOutputFormatted.value = getCellsDensityValue(cells); + pointsOutputFormatted.style.color = getCellsDensityColor(cells); +} + +function getCellsDensityValue(cells) { + return cells / 1000 + "K"; +} + +function getCellsDensityColor(cells) { + return cells > 50000 ? "#b12117" : cells !== 10000 ? "#dfdf12" : "#053305"; } function changeCultureSet() { diff --git a/modules/ui/submap.js b/modules/ui/submap.js index e08665ef8..a2fae5f73 100644 --- a/modules/ui/submap.js +++ b/modules/ui/submap.js @@ -1,16 +1,21 @@ "use strict"; - -/* -UI elements for submap generation -*/ +// UI elements for submap generation window.UISubmap = (function () { - function openSubmapOptions() { + document.getElementById("submapPointsInput").addEventListener("input", function () { + const output = document.getElementById("submapPointsOutputFormatted"); + const cells = cellsDensityMap[+this.value] || 1000; + this.dataset.cells = cells; + output.value = getCellsDensityValue(cells); + output.style.color = getCellsDensityColor(cells); + }); + + function openSubmapMenu() { $("#submapOptionsDialog").dialog({ - title: "Submap options", + title: "Create a submap", + width: "30em", resizable: false, - width: fitContent(), - position: {my: "right top", at: "right-10 top+10", of: "svg", collision: "fit"}, + position: {my: "center", at: "center", of: "svg"}, buttons: { Submap: function () { $(this).dialog("close"); @@ -23,19 +28,21 @@ window.UISubmap = (function () { }); } - function openRemapOptions() { + function openResampleMenu() { resetZoom(0); - document.getElementById("submapRotationAngle").value = 0; - document.getElementById("submapRotationAngleOutput").value = "0°"; + + document.getElementById("submapAngleInput").value = 0; + document.getElementById("submapAngleOutput").value = "0°"; document.getElementById("submapShiftX").value = 0; document.getElementById("submapShiftY").value = 0; document.getElementById("submapMirrorH").checked = false; document.getElementById("submapMirrorV").checked = false; - $("#remapOptionsDialog").dialog({ - title: "Resampler options", + + $("#resampleDialog").dialog({ + title: "Resample map", + width: "30em", resizable: false, - width: fitContent(), - position: {my: "right top", at: "right-10 top+10", of: "svg", collision: "fit"}, + position: {my: "center", at: "center", of: "svg"}, buttons: { Resample: function () { $(this).dialog("close"); @@ -48,32 +55,28 @@ window.UISubmap = (function () { }); } - /* callbacks */ - + // Resample the whole map to different cell resolution or shape const resampleCurrentMap = debounce(function () { - // Resample the whole map to different cell resolution or shape - const cellNumId = Number(document.getElementById("submapPointsInput").value); - const angle = Number(document.getElementById("submapRotationAngle").value) / 180 * Math.PI; - const shiftX = Number(document.getElementById("submapShiftX").value); - const shiftY = Number(document.getElementById("submapShiftY").value); + WARN && console.warn("Resampling current map"); + const cellNumId = +document.getElementById("submapPointsInput").value; + if (!cellsDensityMap[cellNumId]) return console.error("Unknown cell number!"); + + const angle = (+document.getElementById("submapAngleInput").value / 180) * Math.PI; + const shiftX = +document.getElementById("submapShiftX").value; + const shiftY = +document.getElementById("submapShiftY").value; const mirrorH = document.getElementById("submapMirrorH").checked; const mirrorV = document.getElementById("submapMirrorV").checked; - if (!cellsDensityConstants[cellNumId]) { - console.error("Unknown cell number!"); - return; - } const [cx, cy] = [graphWidth / 2, graphHeight / 2]; - const rot = alfa => (x, y) => [ - (x - cx) * Math.cos(alfa) - (y - cy) * Math.sin(alfa) + cx, - (y - cy) * Math.cos(alfa) + (x - cx) * Math.sin(alfa) + cy - ]; + const rot = alfa => (x, y) => [(x - cx) * Math.cos(alfa) - (y - cy) * Math.sin(alfa) + cx, (y - cy) * Math.cos(alfa) + (x - cx) * Math.sin(alfa) + cy]; const shift = (dx, dy) => (x, y) => [x + dx, y + dy]; const flipH = (x, y) => [-x + 2 * cx, y]; const flipV = (x, y) => [x, -y + 2 * cy]; const app = (f, g) => (x, y) => f(...g(x, y)); const id = (x, y) => [x, y]; - let projection = id, inverse = id; + + let projection = id; + let inverse = id; if (angle) [projection, inverse] = [rot(angle), rot(-angle)]; if (shiftX || shiftY) { @@ -84,7 +87,6 @@ window.UISubmap = (function () { if (mirrorV) [projection, inverse] = [app(flipV, projection), app(inverse, flipV)]; changeCellsDensity(cellNumId); - WARN && console.warn("Resampling current map"); startResample({ lockMarkers: false, lockBurgs: false, @@ -94,17 +96,16 @@ window.UISubmap = (function () { smoothHeightMap: false, rescaleStyles: false, projection, - inverse, + inverse }); }, 1000); + // Create submap from the current map. Submap limits defined by the current window size (canvas viewport) const generateSubmap = debounce(function () { - // Create submap from the current map - // submap limits defined by the current window size (canvas viewport) - WARN && console.warn("Resampling current map"); closeDialogs("#worldConfigurator, #options3d"); const checked = id => Boolean(document.getElementById(id).checked); + // Create projection func from current zoom extents const [[x0, y0], [x1, y1]] = getViewBoxExtent(); const origScale = scale; @@ -119,7 +120,7 @@ window.UISubmap = (function () { rescaleStyles: checked("submapRescaleStyles"), smoothHeightMap: scale > 2, inverse: (x, y) => [x / origScale + x0, y / origScale + y0], - projection: (x, y) => [(x - x0) * origScale, (y - y0) * origScale], + projection: (x, y) => [(x - x0) * origScale, (y - y0) * origScale] }; // converting map position on the planet @@ -140,7 +141,7 @@ window.UISubmap = (function () { }, 1000); async function startResample(options) { - // Do model changes with Submap.resample then do view changes if needed. + // Do model changes with Submap.resample then do view changes if needed resetZoom(0); let oldstate = { grid: deepCopy(grid), @@ -169,7 +170,6 @@ window.UISubmap = (function () { oldstate = null; // destroy old state to free memory restoreLayers(); - turnButtonOn("toggleMarkers"); if (ThreeD.options.isOn) ThreeD.redraw(); if ($("#worldConfigurator").is(":visible")) editWorld(); } @@ -178,17 +178,17 @@ window.UISubmap = (function () { // resize burgIcons const burgIcons = [...document.getElementById("burgIcons").querySelectorAll("g")]; for (const bi of burgIcons) { - const newRadius = rn(minmax(bi.getAttribute('size') * scale, 0.2, 10), 2); + const newRadius = rn(minmax(bi.getAttribute("size") * scale, 0.2, 10), 2); changeRadius(newRadius, bi.id); - const swAttr = bi.attributes['stroke-width']; + const swAttr = bi.attributes["stroke-width"]; swAttr.value = +swAttr.value * scale; } // burglabels - const burgLabels= [...document.getElementById("burgLabels").querySelectorAll("g")]; + const burgLabels = [...document.getElementById("burgLabels").querySelectorAll("g")]; for (const bl of burgLabels) { - const size = +bl.dataset['size']; - bl.dataset['size'] = Math.max(rn((size + size / scale) / 2, 2), 1) * scale; + const size = +bl.dataset["size"]; + bl.dataset["size"] = Math.max(rn((size + size / scale) / 2, 2), 1) * scale; } // emblems @@ -203,12 +203,12 @@ window.UISubmap = (function () { ERROR && console.error(error); clearMainTip(); - alertMessage.innerHTML = `Map resampling failed :_(. + alertMessage.innerHTML = `Map resampling failed:${parseError(error)}
`; $("#alert").dialog({ resizable: false, - title: "Generation error", + title: "Resampling error", width: "32em", buttons: { Ok: function () { @@ -219,5 +219,5 @@ window.UISubmap = (function () { }); } - return {openSubmapOptions, openRemapOptions} + return {openSubmapMenu, openResampleMenu}; })(); diff --git a/modules/ui/tools.js b/modules/ui/tools.js index aec92311a..ea297ddd7 100644 --- a/modules/ui/tools.js +++ b/modules/ui/tools.js @@ -72,6 +72,9 @@ toolsContent.addEventListener("click", function (event) { else if (button === "addRiver") toggleAddRiver(); else if (button === "addRoute") toggleAddRoute(); else if (button === "addMarker") toggleAddMarker(); + // click to create a new map buttons + else if (button === "openSubmapMenu") UISubmap.openSubmapMenu(); + else if (button === "openResampleMenu") UISubmap.openResampleMenu(); }); function processFeatureRegeneration(event, button) {