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
b00a8a2228
commit
5e6813c52c
2 changed files with 42 additions and 11 deletions
|
|
@ -4488,6 +4488,10 @@
|
||||||
<input id="submapDepressRivers" class="checkbox" type="checkbox" />
|
<input id="submapDepressRivers" class="checkbox" type="checkbox" />
|
||||||
<label for="submapDepressRivers" class="checkbox-label">Errode riverbeds.</label>
|
<label for="submapDepressRivers" class="checkbox-label">Errode riverbeds.</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div data-tip="Rescale styles (burg labels, emblem size) to match the new scale.">
|
||||||
|
<input id="submapRescaleStyles" class="checkbox" type="checkbox" checked/>
|
||||||
|
<label for="submapRescaleStyles" class="checkbox-label">Rescale Styles</label>
|
||||||
|
</div>
|
||||||
<div data-tip="Move all existing towns to the 'largetown' burg group">
|
<div data-tip="Move all existing towns to the 'largetown' burg group">
|
||||||
<input id="submapPromoteTowns" class="checkbox" type="checkbox" />
|
<input id="submapPromoteTowns" class="checkbox" type="checkbox" />
|
||||||
<label for="submapPromoteTowns" class="checkbox-label">Promote towns to largetowns</label>
|
<label for="submapPromoteTowns" class="checkbox-label">Promote towns to largetowns</label>
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,7 @@ function openRemapOptions() {
|
||||||
position: {my: "right top", at: "right-10 top+10", of: "svg", collision: "fit"},
|
position: {my: "right top", at: "right-10 top+10", of: "svg", collision: "fit"},
|
||||||
buttons: {
|
buttons: {
|
||||||
Resample: function () {
|
Resample: function () {
|
||||||
const cellNumId = Number(document.getElementById("submapPointsInput").value);
|
|
||||||
const cells = cellsDensityConstants[cellNumId];
|
|
||||||
$(this).dialog("close");
|
$(this).dialog("close");
|
||||||
if (!cells) {
|
|
||||||
console.error("Unknown cell number!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
changeCellsDensity(cellNumId);
|
|
||||||
resampleCurrentMap();
|
resampleCurrentMap();
|
||||||
},
|
},
|
||||||
Cancel: function () {
|
Cancel: function () {
|
||||||
|
|
@ -52,19 +45,24 @@ function openRemapOptions() {
|
||||||
|
|
||||||
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);
|
||||||
|
if (!cellsDensityConstants[cellNumId]) {
|
||||||
|
console.error("Unknown cell number!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
changeCellsDensity(cellNumId);
|
||||||
WARN && console.warn("Resampling current map");
|
WARN && console.warn("Resampling current map");
|
||||||
const options = {
|
startResample({
|
||||||
lockMarkers: false,
|
lockMarkers: false,
|
||||||
lockBurgs: false,
|
lockBurgs: false,
|
||||||
depressRivers: false,
|
depressRivers: false,
|
||||||
addLakesInDepressions: false,
|
addLakesInDepressions: false,
|
||||||
promoteTowns: false,
|
promoteTowns: false,
|
||||||
smoothHeightMap: false,
|
smoothHeightMap: false,
|
||||||
|
rescaleStyles: false,
|
||||||
projection: (x, y) => [x, y],
|
projection: (x, y) => [x, y],
|
||||||
inverse: (x, y) => [x, y]
|
inverse: (x, y) => [x, y]
|
||||||
};
|
});
|
||||||
|
|
||||||
startResample(options);
|
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
const generateSubmap = debounce(function () {
|
const generateSubmap = debounce(function () {
|
||||||
|
|
@ -85,6 +83,7 @@ const generateSubmap = debounce(function () {
|
||||||
depressRivers: checked("submapDepressRivers"),
|
depressRivers: checked("submapDepressRivers"),
|
||||||
addLakesInDepressions: checked("submapAddLakeInDepression"),
|
addLakesInDepressions: checked("submapAddLakeInDepression"),
|
||||||
promoteTowns: checked("submapPromoteTowns"),
|
promoteTowns: checked("submapPromoteTowns"),
|
||||||
|
rescaleStyles: checked("submapRescaleStyles"),
|
||||||
smoothHeightMap: scale > 2,
|
smoothHeightMap: scale > 2,
|
||||||
inverse: (x, y) => [x / origScale + x0, y / origScale + y0],
|
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],
|
||||||
|
|
@ -108,6 +107,7 @@ const generateSubmap = debounce(function () {
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
async function startResample(options) {
|
async function startResample(options) {
|
||||||
|
// Do model changes with Submap.resample then do view changes if needed.
|
||||||
undraw();
|
undraw();
|
||||||
resetZoom(0);
|
resetZoom(0);
|
||||||
let oldstate = {
|
let oldstate = {
|
||||||
|
|
@ -128,6 +128,7 @@ async function startResample(options) {
|
||||||
changeFontSize(svg.select(`#labels #${groupName}`), rn(oldScale * 2, 2));
|
changeFontSize(svg.select(`#labels #${groupName}`), rn(oldScale * 2, 2));
|
||||||
invokeActiveZooming();
|
invokeActiveZooming();
|
||||||
}
|
}
|
||||||
|
if (options.rescaleStyles) changeStyles(oldScale);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showSubmapErrorHandler(error);
|
showSubmapErrorHandler(error);
|
||||||
}
|
}
|
||||||
|
|
@ -140,6 +141,32 @@ async function startResample(options) {
|
||||||
if ($("#worldConfigurator").is(":visible")) editWorld();
|
if ($("#worldConfigurator").is(":visible")) editWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeStyles(scale) {
|
||||||
|
// resize burgIcons
|
||||||
|
const burgIcons = [...document.getElementById("burgIcons").querySelectorAll("g")];
|
||||||
|
for (const bi of burgIcons) {
|
||||||
|
const newRadius = rn(minmax(scale, 0.2, 10) * 0.8, 2);
|
||||||
|
styleRadiusInput.value = newRadius;
|
||||||
|
changeRadius(newRadius, bi.id);
|
||||||
|
const swAttr = bi.attributes['stroke-width'];
|
||||||
|
swAttr.value = +swAttr.value * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
// burglabels
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// emblems
|
||||||
|
const emblemMod = minmax((scale - 1) * 0.3 + 1, 0.5, 5);
|
||||||
|
emblemsStateSizeInput.value = minmax(+emblemsStateSizeInput.value * emblemMod, 0.5, 5);
|
||||||
|
emblemsProvinceSizeInput.value = minmax(+emblemsProvinceSizeInput.value * emblemMod, 0.5, 5);
|
||||||
|
emblemsBurgSizeInput.value = minmax(+emblemsBurgSizeInput.value * emblemMod, 0.5, 5);
|
||||||
|
drawEmblems();
|
||||||
|
}
|
||||||
|
|
||||||
function showSubmapErrorHandler(error) {
|
function showSubmapErrorHandler(error) {
|
||||||
ERROR && console.error(error);
|
ERROR && console.error(error);
|
||||||
clearMainTip();
|
clearMainTip();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue