mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 02:01:22 +01:00
refactor: submap - UI update
This commit is contained in:
parent
431a5aa3e9
commit
6e38c93841
4 changed files with 22 additions and 48 deletions
18
index.html
18
index.html
|
|
@ -5772,15 +5772,7 @@
|
|||
Don't forget to save the .map file to your machine first!
|
||||
</p>
|
||||
|
||||
<p>Settings to be changed: population rate, map pixel size</p>
|
||||
<p>
|
||||
Data to be copied: heightmap, biomes, religions, population, precipitation, cultures, states, provinces,
|
||||
military regiments
|
||||
</p>
|
||||
<p>Data to be regenerated: zones, routes, rivers</p>
|
||||
<p>Burgs may be remapped incorrectly, manual change is required</p>
|
||||
|
||||
<p>Experimental features:</p>
|
||||
<p>Options:</p>
|
||||
<div data-tip="Smooth heightmap to get more natural terrain">
|
||||
<input id="submapSmoothHeightmap" class="checkbox" type="checkbox" checked />
|
||||
<label for="submapSmoothHeightmap" class="checkbox-label">Smooth heightmap</label>
|
||||
|
|
@ -5789,14 +5781,6 @@
|
|||
<input id="submapDepressRivers" class="checkbox" type="checkbox" checked />
|
||||
<label for="submapDepressRivers" class="checkbox-label">Erode riverbeds</label>
|
||||
</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">
|
||||
<input id="submapPromoteTowns" class="checkbox" type="checkbox" />
|
||||
<label for="submapPromoteTowns" class="checkbox-label">Promote towns to largetowns</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="transformTool" style="display: none" class="dialog">
|
||||
|
|
|
|||
|
|
@ -45,11 +45,10 @@ window.Submap = (function () {
|
|||
restoreRoutes(parentMap, projection);
|
||||
restoreReligions(parentMap, projection);
|
||||
restoreProvinces(parentMap);
|
||||
restoreRiverDetails(parentMap, inverse);
|
||||
restoreFeatureDetails(parentMap, inverse);
|
||||
restoreMarkers(parentMap, projection);
|
||||
restoreZones(parentMap, projection, options);
|
||||
restoreFeatureDetails(parentMap, inverse);
|
||||
|
||||
Rivers.specify();
|
||||
|
||||
showStatistics();
|
||||
}
|
||||
|
|
@ -277,6 +276,15 @@ window.Submap = (function () {
|
|||
});
|
||||
}
|
||||
|
||||
// TODO: actually restore rivers
|
||||
function restoreRiverDetails(parentMap, inverse) {
|
||||
pack.rivers.forEach(river => {
|
||||
river.basin = Rivers.getBasin(river.i);
|
||||
river.name = Rivers.getName(river.mouth);
|
||||
river.type = Rivers.getType(river);
|
||||
});
|
||||
}
|
||||
|
||||
function restoreFeatureDetails(parentMap, inverse) {
|
||||
pack.features.forEach(feature => {
|
||||
if (!feature) return;
|
||||
|
|
|
|||
|
|
@ -38,37 +38,22 @@ function openSubmapTool() {
|
|||
populationRate = populationRateInput.value = rn(populationRate / scale, 2);
|
||||
|
||||
const parentMap = {grid: deepCopy(grid), pack: deepCopy(pack), notes: deepCopy(notes)};
|
||||
const options = {
|
||||
smoothHeightmap: byId("submapSmoothHeightmap").checked,
|
||||
depressRivers: byId("submapDepressRivers").checked,
|
||||
projection: (x, y) => [(x - x0) * scale, (y - y0) * scale],
|
||||
inverse: (x, y) => [x / scale + x0, y / scale + y0],
|
||||
scale
|
||||
};
|
||||
const smoothHeightmap = byId("submapSmoothHeightmap").checked;
|
||||
const depressRivers = byId("submapDepressRivers").checked;
|
||||
const projection = (x, y) => [(x - x0) * scale, (y - y0) * scale];
|
||||
const inverse = (x, y) => [x / scale + x0, y / scale + y0];
|
||||
const options = {smoothHeightmap, depressRivers, projection, inverse, scale};
|
||||
|
||||
resetZoom(0);
|
||||
undraw();
|
||||
|
||||
const oldScale = scale;
|
||||
await Submap.resample(parentMap, options);
|
||||
|
||||
if (byId("submapPromoteTowns").checked) {
|
||||
const groupName = "largetowns";
|
||||
moveAllBurgsToGroup("towns", groupName);
|
||||
changeRadius(rn(oldScale * 0.8, 2), groupName);
|
||||
changeFontSize(svg.select(`#labels #${groupName}`), rn(oldScale * 2, 2));
|
||||
invokeActiveZooming();
|
||||
}
|
||||
|
||||
if (byId("submapRescaleStyles").checked) changeStyles(oldScale);
|
||||
|
||||
rescaleBurgStyles(scale);
|
||||
drawLayers();
|
||||
|
||||
INFO && console.groupEnd("generateSubmap");
|
||||
}
|
||||
|
||||
function changeStyles(scale) {
|
||||
// resize burgIcons
|
||||
function rescaleBurgStyles(scale) {
|
||||
const burgIcons = [...byId("burgIcons").querySelectorAll("g")];
|
||||
for (const bi of burgIcons) {
|
||||
const newRadius = rn(minmax(bi.getAttribute("size") * scale, 0.2, 10), 2);
|
||||
|
|
@ -77,13 +62,10 @@ function openSubmapTool() {
|
|||
swAttr.value = +swAttr.value * scale;
|
||||
}
|
||||
|
||||
// burglabels
|
||||
const burgLabels = [...byId("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;
|
||||
}
|
||||
|
||||
drawEmblems();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,13 +123,13 @@ async function openTransformTool() {
|
|||
async function transformMap() {
|
||||
INFO && console.group("transformMap");
|
||||
|
||||
const cellsNumber = +byId("transformPointsInput").value;
|
||||
changeCellsDensity(cellsNumber);
|
||||
|
||||
const parentMap = {grid: deepCopy(grid), pack: deepCopy(pack), notes: deepCopy(notes)};
|
||||
const [projection, inverse] = getProjection();
|
||||
const options = {depressRivers: false, smoothHeightmap: false, scale: 1, inverse, projection};
|
||||
|
||||
const cellsNumber = +byId("transformPointsInput").value;
|
||||
changeCellsDensity(cellsNumber);
|
||||
|
||||
resetZoom(0);
|
||||
undraw();
|
||||
await Submap.resample(parentMap, options);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue