mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-23 12:31:24 +01:00
Rescale style option for submaps.
This commit is contained in:
parent
53dc9a452d
commit
e85f5e39d6
1 changed files with 156 additions and 146 deletions
|
|
@ -20,10 +20,11 @@ window.UISubmap = (function () {
|
||||||
$(this).dialog("close");
|
$(this).dialog("close");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function openRemapOptions() {
|
function openRemapOptions() {
|
||||||
resetZoom(0);
|
resetZoom(0);
|
||||||
$("#remapOptionsDialog").dialog({
|
$("#remapOptionsDialog").dialog({
|
||||||
title: "Resampler options",
|
title: "Resampler options",
|
||||||
|
|
@ -38,7 +39,6 @@ window.UISubmap = (function () {
|
||||||
Cancel: function () {
|
Cancel: function () {
|
||||||
$(this).dialog("close");
|
$(this).dialog("close");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,6 +51,18 @@ window.UISubmap = (function () {
|
||||||
console.error("Unknown cell number!");
|
console.error("Unknown cell number!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* callbacks */
|
||||||
|
|
||||||
|
const resampleCurrentMap = debounce(function () {
|
||||||
|
// Resample the whole map to different cell resolution or shape
|
||||||
|
const cellNumId = Number(document.getElementById("submapPointsInput").value);
|
||||||
|
if (!cellsDensityConstants[cellNumId]) {
|
||||||
|
console.error("Unknown cell number!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
changeCellsDensity(cellNumId);
|
changeCellsDensity(cellNumId);
|
||||||
WARN && console.warn("Resampling current map");
|
WARN && console.warn("Resampling current map");
|
||||||
startResample({
|
startResample({
|
||||||
|
|
@ -64,9 +76,9 @@ window.UISubmap = (function () {
|
||||||
projection: (x, y) => [x, y],
|
projection: (x, y) => [x, y],
|
||||||
inverse: (x, y) => [x, y]
|
inverse: (x, y) => [x, y]
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
const generateSubmap = debounce(function () {
|
const generateSubmap = debounce(function () {
|
||||||
// Create submap from the current map
|
// Create submap from the current map
|
||||||
// submap limits defined by the current window size (canvas viewport)
|
// submap limits defined by the current window size (canvas viewport)
|
||||||
|
|
||||||
|
|
@ -105,9 +117,9 @@ window.UISubmap = (function () {
|
||||||
populationRateInput.value = populationRateOutput.value = rn((populationRate = populationRateOutput.value / scale), 2);
|
populationRateInput.value = populationRateOutput.value = rn((populationRate = populationRateOutput.value / scale), 2);
|
||||||
customization = 0;
|
customization = 0;
|
||||||
startResample(options);
|
startResample(options);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
async function startResample(options) {
|
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.
|
||||||
undraw();
|
undraw();
|
||||||
resetZoom(0);
|
resetZoom(0);
|
||||||
|
|
@ -140,13 +152,14 @@ window.UISubmap = (function () {
|
||||||
turnButtonOn("toggleMarkers");
|
turnButtonOn("toggleMarkers");
|
||||||
if (ThreeD.options.isOn) ThreeD.redraw();
|
if (ThreeD.options.isOn) ThreeD.redraw();
|
||||||
if ($("#worldConfigurator").is(":visible")) editWorld();
|
if ($("#worldConfigurator").is(":visible")) editWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeStyles(scale) {
|
function changeStyles(scale) {
|
||||||
// resize burgIcons
|
// resize burgIcons
|
||||||
const burgIcons = [...document.getElementById("burgIcons").querySelectorAll("g")];
|
const burgIcons = [...document.getElementById("burgIcons").querySelectorAll("g")];
|
||||||
for (const bi of burgIcons) {
|
for (const bi of burgIcons) {
|
||||||
const newRadius = rn(minmax(bi.getAttribute('size') * scale, 0.2, 10), 2);
|
const newRadius = rn(minmax(scale, 0.2, 10) * 0.8, 2);
|
||||||
|
styleRadiusInput.value = newRadius;
|
||||||
changeRadius(newRadius, bi.id);
|
changeRadius(newRadius, bi.id);
|
||||||
const swAttr = bi.attributes['stroke-width'];
|
const swAttr = bi.attributes['stroke-width'];
|
||||||
swAttr.value = +swAttr.value * scale;
|
swAttr.value = +swAttr.value * scale;
|
||||||
|
|
@ -165,9 +178,9 @@ window.UISubmap = (function () {
|
||||||
emblemsProvinceSizeInput.value = minmax(+emblemsProvinceSizeInput.value * emblemMod, 0.5, 5);
|
emblemsProvinceSizeInput.value = minmax(+emblemsProvinceSizeInput.value * emblemMod, 0.5, 5);
|
||||||
emblemsBurgSizeInput.value = minmax(+emblemsBurgSizeInput.value * emblemMod, 0.5, 5);
|
emblemsBurgSizeInput.value = minmax(+emblemsBurgSizeInput.value * emblemMod, 0.5, 5);
|
||||||
drawEmblems();
|
drawEmblems();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSubmapErrorHandler(error) {
|
function showSubmapErrorHandler(error) {
|
||||||
ERROR && console.error(error);
|
ERROR && console.error(error);
|
||||||
clearMainTip();
|
clearMainTip();
|
||||||
|
|
||||||
|
|
@ -185,7 +198,4 @@ window.UISubmap = (function () {
|
||||||
},
|
},
|
||||||
position: {my: "center", at: "center", of: "svg"}
|
position: {my: "center", at: "center", of: "svg"}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {openSubmapOptions, openRemapOptions}
|
|
||||||
})();
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue