mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-21 19:41:23 +01:00
feat: add join route functionality to routes editor
This commit is contained in:
parent
41354a857e
commit
432bc8bf09
2 changed files with 17 additions and 3 deletions
|
|
@ -2937,6 +2937,11 @@
|
||||||
data-tip="Create a new route selecting route cells"
|
data-tip="Create a new route selecting route cells"
|
||||||
class="icon-map-pin"
|
class="icon-map-pin"
|
||||||
></button>
|
></button>
|
||||||
|
<button
|
||||||
|
id="routeJoin"
|
||||||
|
data-tip="Click on control point to join the route to another route that starts or ends there"
|
||||||
|
class="icon-link"
|
||||||
|
></button>
|
||||||
<button
|
<button
|
||||||
id="routeSplit"
|
id="routeSplit"
|
||||||
data-tip="Click on a control point to split the route there"
|
data-tip="Click on a control point to split the route there"
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ function editRoute(id) {
|
||||||
|
|
||||||
// add listeners
|
// add listeners
|
||||||
byId("routeCreateSelectingCells").on("click", showCreationDialog);
|
byId("routeCreateSelectingCells").on("click", showCreationDialog);
|
||||||
byId("routeSplit").on("click", toggleSplitRoute);
|
byId("routeSplit").on("click", togglePressed);
|
||||||
|
byId("routeJoin").on("click", togglePressed);
|
||||||
byId("routeElevationProfile").on("click", showRouteElevationProfile);
|
byId("routeElevationProfile").on("click", showRouteElevationProfile);
|
||||||
byId("routeLegend").on("click", editRouteLegend);
|
byId("routeLegend").on("click", editRouteLegend);
|
||||||
byId("routeRemove").on("click", removeRoute);
|
byId("routeRemove").on("click", removeRoute);
|
||||||
|
|
@ -173,8 +174,16 @@ function editRoute(id) {
|
||||||
|
|
||||||
function handleControlPointClick() {
|
function handleControlPointClick() {
|
||||||
const controlPoint = d3.select(this);
|
const controlPoint = d3.select(this);
|
||||||
|
|
||||||
|
const isJoinMode = byId("routeJoin").classList.contains("pressed");
|
||||||
|
if (isJoinMode) return joinRoute(controlPoint);
|
||||||
|
|
||||||
const isSplitMode = byId("routeSplit").classList.contains("pressed");
|
const isSplitMode = byId("routeSplit").classList.contains("pressed");
|
||||||
isSplitMode ? splitRoute(controlPoint) : removeControlPoint(controlPoint);
|
if (isSplitMode) return splitRoute(controlPoint);
|
||||||
|
|
||||||
|
return removeControlPoint(controlPoint);
|
||||||
|
|
||||||
|
function joinRoute(controlPoint) {}
|
||||||
|
|
||||||
function splitRoute(controlPoint) {
|
function splitRoute(controlPoint) {
|
||||||
const allPoints = debug.selectAll("#controlPoints > *").data();
|
const allPoints = debug.selectAll("#controlPoints > *").data();
|
||||||
|
|
@ -248,7 +257,7 @@ function editRoute(id) {
|
||||||
createRoute(route.group);
|
createRoute(route.group);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleSplitRoute() {
|
function togglePressed() {
|
||||||
this.classList.toggle("pressed");
|
this.classList.toggle("pressed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue