mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 03:51:23 +01:00
feat: edit routes - remove route
This commit is contained in:
parent
9b46e7b877
commit
865c10cec6
1 changed files with 16 additions and 4 deletions
|
|
@ -273,16 +273,28 @@ function editRoute(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeRoute() {
|
function removeRoute() {
|
||||||
alertMessage.innerHTML = "Are you sure you want to remove the route and all its tributaries";
|
alertMessage.innerHTML = "Are you sure you want to remove the route";
|
||||||
$("#alert").dialog({
|
$("#alert").dialog({
|
||||||
resizable: false,
|
resizable: false,
|
||||||
width: "22em",
|
width: "22em",
|
||||||
title: "Remove route and tributaries",
|
title: "Remove route",
|
||||||
buttons: {
|
buttons: {
|
||||||
Remove: function () {
|
Remove: function () {
|
||||||
|
const route = getRoute();
|
||||||
|
const routes = pack.cells.routes;
|
||||||
|
|
||||||
|
for (const from of route.cells) {
|
||||||
|
for (const [to, routeId] of Object.entries(routes[from])) {
|
||||||
|
if (routeId === route.i) {
|
||||||
|
delete routes[from][to];
|
||||||
|
delete routes[to][from];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pack.routes = pack.routes.filter(r => r.i !== route.i);
|
||||||
|
|
||||||
$(this).dialog("close");
|
$(this).dialog("close");
|
||||||
const route = +elSelected.attr("id").slice(5);
|
|
||||||
Routes.remove(route);
|
|
||||||
elSelected.remove();
|
elSelected.remove();
|
||||||
$("#routeEditor").dialog("close");
|
$("#routeEditor").dialog("close");
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue