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"
|
||||
class="icon-map-pin"
|
||||
></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
|
||||
id="routeSplit"
|
||||
data-tip="Click on a control point to split the route there"
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ function editRoute(id) {
|
|||
|
||||
// add listeners
|
||||
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("routeLegend").on("click", editRouteLegend);
|
||||
byId("routeRemove").on("click", removeRoute);
|
||||
|
|
@ -173,8 +174,16 @@ function editRoute(id) {
|
|||
|
||||
function handleControlPointClick() {
|
||||
const controlPoint = d3.select(this);
|
||||
|
||||
const isJoinMode = byId("routeJoin").classList.contains("pressed");
|
||||
if (isJoinMode) return joinRoute(controlPoint);
|
||||
|
||||
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) {
|
||||
const allPoints = debug.selectAll("#controlPoints > *").data();
|
||||
|
|
@ -248,7 +257,7 @@ function editRoute(id) {
|
|||
createRoute(route.group);
|
||||
}
|
||||
|
||||
function toggleSplitRoute() {
|
||||
function togglePressed() {
|
||||
this.classList.toggle("pressed");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue