Lock markers and lock burgs options

This commit is contained in:
GoteGuru 2022-04-01 00:38:44 +00:00
parent 77bac478af
commit 5461685d23
3 changed files with 32 additions and 15 deletions

View file

@ -3685,10 +3685,6 @@
<input id="submapCopyRivers" class="checkbox" type="checkbox"> <input id="submapCopyRivers" class="checkbox" type="checkbox">
<label for="submapCopyRivers" class="checkbox-label">Rivers</label> <label for="submapCopyRivers" class="checkbox-label">Rivers</label>
</div> </div>
<div data-tip="Copy markers from the original map. Regenerate markers if not checked." >
<input id="submapCopyMarkers" class="checkbox" type="checkbox" checked>
<label for="submapCopyMarkers" class="checkbox-label">Markers</label>
</div>
<div data-tip="Copy Zones from the original map. Regenerate Zones if not checked." class="disabled"> <div data-tip="Copy Zones from the original map. Regenerate Zones if not checked." class="disabled">
<input id="submapCopyZones" class="checkbox" type="checkbox" disabled> <input id="submapCopyZones" class="checkbox" type="checkbox" disabled>
<label for="submapCopyZones" class="checkbox-label">Zones</label> <label for="submapCopyZones" class="checkbox-label">Zones</label>
@ -3698,6 +3694,17 @@
<label for="submapCopyRoads" class="checkbox-label">Roads</label> <label for="submapCopyRoads" class="checkbox-label">Roads</label>
</div> </div>
<hr /> <hr />
<p>Lock remapped items for:</p>
<div data-tip="Lock all markers copied from the original map." >
<input id="submapLockMarkers" class="checkbox" type="checkbox" checked>
<label for="submapLockMarkers" class="checkbox-label">Markers</label>
</div>
<div data-tip="Lock all burgs copied from the original map." >
<input id="submapLockBurgs" class="checkbox" type="checkbox" checked>
<label for="submapLockBurgs" class="checkbox-label">Burgs (cities)</label>
</div>
<p>Extra / experimental features:</p> <p>Extra / experimental features:</p>
<div data-tip="Rivers on the parent map errode land (helps to get similar river network.)" > <div data-tip="Rivers on the parent map errode land (helps to get similar river network.)" >
<input id="submapDepressRivers" class="checkbox" type="checkbox"> <input id="submapDepressRivers" class="checkbox" type="checkbox">

View file

@ -5,6 +5,7 @@ Experimental submaping module
window.Submap = (function () { window.Submap = (function () {
const isWater = (map, id) => map.grid.cells.h[map.pack.cells.g[id]] < 20? true: false; const isWater = (map, id) => map.grid.cells.h[map.pack.cells.g[id]] < 20? true: false;
const inMap = (x,y) => x>0 && x<graphWidth && y>0 && y<graphHeight;
function resample(parentMap, projection, options) { function resample(parentMap, projection, options) {
// generate new map based on an existing one (resampling parentMap) // generate new map based on an existing one (resampling parentMap)
@ -290,13 +291,21 @@ window.Submap = (function () {
} }
Military.redraw(); Military.redraw();
stage("markers and zones (if requested)."); stage("Copying markers.");
if (!options.copyMarkers) Markers.generate(); for (const m of pack.markers) {
else { const [x, y] = projection(m.x, m.y, false);
// TODO if (!inMap(x, y)) {
pack.markers = []; Markers.deleteMarker(m.i);
} else {
m.x = x;
m.y = y;
m.cell = findCell(x, y);
if (options.lockMarkers) m.lock = true;
} }
}
drawMarkers();
stage("Regenerating Zones.");
if (!options.copyZones) addZones(); if (!options.copyZones) addZones();
Names.getMapName(); Names.getMapName();
stage("Submap done."); stage("Submap done.");
@ -327,7 +336,6 @@ window.Submap = (function () {
} }
function copyBurgs(parentMap, projection, options) { function copyBurgs(parentMap, projection, options) {
const inMap = (x,y) => x>0 && x<graphWidth && y>0 && y<graphHeight;
const cells = pack.cells; const cells = pack.cells;
const childMap = { grid, pack } const childMap = { grid, pack }
const isCoast = c => cells.t[c] === 1 const isCoast = c => cells.t[c] === 1
@ -379,7 +387,7 @@ window.Submap = (function () {
b.cell = cityCell; b.cell = cityCell;
[b.x, b.y] = cells.p[cityCell]; [b.x, b.y] = cells.p[cityCell];
} }
b.lock = true; if (!b.lock) b.lock = options.lockBurgs;
pack.cells.burg[b.cell] = id; pack.cells.burg[b.cell] = id;
if (options.promoteTown) b.capital = 1; if (options.promoteTown) b.capital = 1;
}); });

View file

@ -22,10 +22,12 @@ const generateSubmap = debounce(async function () {
const checked = id => Boolean(document.getElementById(id).checked) const checked = id => Boolean(document.getElementById(id).checked)
const options = { const options = {
copyBurgs: checked("submapCopyBurgs"), copyBurgs: checked("submapCopyBurgs"),
copyMarkers: checked("submapCopyMarkers"),
copyZones: checked("submapCopyZones"), copyZones: checked("submapCopyZones"),
copyZones: checked("submapCopyRivers"), copyRivers: checked("submapCopyRivers"),
copyZones: checked("submapCopyRoads"), copyRoads: checked("submapCopyRoads"),
lockMarkers: checked("submapLockMarkers"),
lockBurgs: checked("submapLockBurgs"),
depressRivers: checked("submapDepressRivers"), depressRivers: checked("submapDepressRivers"),
addLakesInDepressions: checked("submapAddLakeInDepression"), addLakesInDepressions: checked("submapAddLakeInDepression"),