feat: routes - regenerateRoutes

This commit is contained in:
Azgaar 2024-08-09 17:00:45 +02:00
parent 19723bd513
commit 16b441c5cf
4 changed files with 12 additions and 9 deletions

View file

@ -271,7 +271,7 @@ window.Submap = (function () {
BurgsAndStates.drawBurgs();
stage("Regenerating routes network.");
Routes.regenerate();
regenerateRoutes();
drawStates();
drawBorders();

View file

@ -113,8 +113,7 @@ function overviewRoutes() {
function triggerRouteRemove() {
const routeId = +this.parentNode.dataset.id;
alertMessage.innerHTML = /* html */ `Are you sure you want to remove the route? All tributaries will be auto-removed`;
alertMessage.innerHTML = `Are you sure you want to remove the route?`;
$("#alert").dialog({
resizable: false,
width: "22em",

View file

@ -80,7 +80,7 @@ function processFeatureRegeneration(event, button) {
ReliefIcons();
if (!layerIsOn("toggleRelief")) toggleRelief();
} else if (button === "regenerateRoutes") {
Routes.regenerate();
regenerateRoutes();
if (!layerIsOn("toggleRoutes")) toggleRoutes();
} else if (button === "regenerateRivers") regenerateRivers();
else if (button === "regeneratePopulation") recalculatePopulation();
@ -116,6 +116,14 @@ async function openEmblemEditor() {
editEmblem(type, id, el);
}
function regenerateRoutes() {
pack.routes = [];
pack.cells.routes = {};
routes.selectAll("path").remove();
Routes.generate();
if (layerIsOn("toggleRoutes")) drawRoutes();
}
function regenerateRivers() {
Rivers.generate();
Lakes.defineGroup();
@ -430,7 +438,7 @@ function regenerateBurgs() {
BurgsAndStates.specifyBurgs();
BurgsAndStates.defineBurgFeatures();
BurgsAndStates.drawBurgs();
Routes.regenerate();
regenerateRoutes();
// remove emblems
document.querySelectorAll("[id^=burgCOA]").forEach(el => el.remove());