mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-23 20:41:23 +01:00
namespace for submap ui.
This commit is contained in:
parent
5e6813c52c
commit
e6d499fa60
2 changed files with 185 additions and 181 deletions
|
|
@ -1728,8 +1728,8 @@
|
||||||
|
|
||||||
<p>Click to create a new map:</p>
|
<p>Click to create a new map:</p>
|
||||||
<div id="resamplers">
|
<div id="resamplers">
|
||||||
<button data-tip="Click to generate new (sub)map from the current viewport" onclick="openSubmapOptions()">Submap</button>
|
<button data-tip="Click to generate new (sub)map from the current viewport" onclick="UISubmap.openSubmapOptions()">Submap</button>
|
||||||
<button data-tip="Click to resample (transform) your map to different cellcount" onclick="openRemapOptions()">Resample</button>
|
<button data-tip="Click to resample (transform) your map to different cellcount" onclick="UISubmap.openRemapOptions()">Resample</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@
|
||||||
UI elements for submap generation
|
UI elements for submap generation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function openSubmapOptions() {
|
window.UISubmap = (function () {
|
||||||
|
function openSubmapOptions() {
|
||||||
$("#submapOptionsDialog").dialog({
|
$("#submapOptionsDialog").dialog({
|
||||||
title: "Submap options",
|
title: "Submap options",
|
||||||
resizable: false,
|
resizable: false,
|
||||||
|
|
@ -20,9 +21,9 @@ function openSubmapOptions() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function openRemapOptions() {
|
function openRemapOptions() {
|
||||||
resetZoom(0);
|
resetZoom(0);
|
||||||
$("#remapOptionsDialog").dialog({
|
$("#remapOptionsDialog").dialog({
|
||||||
title: "Resampler options",
|
title: "Resampler options",
|
||||||
|
|
@ -39,11 +40,11 @@ function openRemapOptions() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* callbacks */
|
/* callbacks */
|
||||||
|
|
||||||
const resampleCurrentMap = debounce(function () {
|
const resampleCurrentMap = debounce(function () {
|
||||||
// Resample the whole map to different cell resolution or shape
|
// Resample the whole map to different cell resolution or shape
|
||||||
const cellNumId = Number(document.getElementById("submapPointsInput").value);
|
const cellNumId = Number(document.getElementById("submapPointsInput").value);
|
||||||
if (!cellsDensityConstants[cellNumId]) {
|
if (!cellsDensityConstants[cellNumId]) {
|
||||||
|
|
@ -63,9 +64,9 @@ const resampleCurrentMap = debounce(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)
|
||||||
|
|
||||||
|
|
@ -104,9 +105,9 @@ const generateSubmap = debounce(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);
|
||||||
|
|
@ -139,9 +140,9 @@ async function startResample(options) {
|
||||||
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) {
|
||||||
|
|
@ -165,9 +166,9 @@ function changeStyles(scale) {
|
||||||
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,4 +186,7 @@ function showSubmapErrorHandler(error) {
|
||||||
},
|
},
|
||||||
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