mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-21 19:41: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() {
|
||||
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({
|
||||
resizable: false,
|
||||
width: "22em",
|
||||
title: "Remove route and tributaries",
|
||||
title: "Remove route",
|
||||
buttons: {
|
||||
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");
|
||||
const route = +elSelected.attr("id").slice(5);
|
||||
Routes.remove(route);
|
||||
elSelected.remove();
|
||||
$("#routeEditor").dialog("close");
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue