From 866f548daa041d32fe0442360ce6fa35f39be285 Mon Sep 17 00:00:00 2001 From: littlefean <2028140990@qq.com> Date: Sun, 15 Dec 2024 11:04:15 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8Dsection?= =?UTF-8?q?=E6=B2=A1=E6=B3=95jump=E7=A7=BB=E5=8A=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../concrete/ControllerEntityLayerMoving.tsx | 12 +++++++----- src/core/stage/stageManager/StageManager.tsx | 4 ++++ .../concreteMethods/StageEntityMoveManager.tsx | 8 +++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/core/controller/concrete/ControllerEntityLayerMoving.tsx b/src/core/controller/concrete/ControllerEntityLayerMoving.tsx index ccc2d28d..a367db24 100644 --- a/src/core/controller/concrete/ControllerEntityLayerMoving.tsx +++ b/src/core/controller/concrete/ControllerEntityLayerMoving.tsx @@ -28,9 +28,11 @@ ControllerLayerMoving.mouseup = (event: MouseEvent) => { const mouseLocation = Renderer.transformView2World( new Vector(event.clientX, event.clientY), ); - const sections = + + // 即将跳入的sections区域 + const targetSections = StageManager.SectionOptions.getSectionsByInnerLocation(mouseLocation); - console.log(sections); + console.log(targetSections); const selectedEntities = StageManager.getSelectedEntities(); // 移动位置 @@ -43,10 +45,10 @@ ControllerLayerMoving.mouseup = (event: MouseEvent) => { Rectangle.getBoundingRectangle(rectangles).center, ); // 3 移动所有选中的实体 - StageManager.moveNodes(delta); + StageManager.moveEntities(delta); // 改变层级 - if (sections.length === 0) { + if (targetSections.length === 0) { // 代表想要走出当前section for (const entity of selectedEntities) { const currentFatherSections = @@ -57,7 +59,7 @@ ControllerLayerMoving.mouseup = (event: MouseEvent) => { StageManager.goOutSection([entity], currentFatherSections[0]); } } else { - for (const section of sections) { + for (const section of targetSections) { StageManager.goInSection(selectedEntities, section); // 特效 for (const entity of selectedEntities) { diff --git a/src/core/stage/stageManager/StageManager.tsx b/src/core/stage/stageManager/StageManager.tsx index 6fcd7895..33998bc3 100644 --- a/src/core/stage/stageManager/StageManager.tsx +++ b/src/core/stage/stageManager/StageManager.tsx @@ -665,6 +665,10 @@ export namespace StageManager { return res; } + export function moveEntities(delta: Vector) { + StageEntityMoveManager.moveEntities(delta); // 连续过程,不记录历史,只在结束时记录 + } + /** * 拖动所有选中的节点一起移动 * @param delta diff --git a/src/core/stage/stageManager/concreteMethods/StageEntityMoveManager.tsx b/src/core/stage/stageManager/concreteMethods/StageEntityMoveManager.tsx index 08a6e3eb..8c037da3 100644 --- a/src/core/stage/stageManager/concreteMethods/StageEntityMoveManager.tsx +++ b/src/core/stage/stageManager/concreteMethods/StageEntityMoveManager.tsx @@ -40,7 +40,13 @@ export namespace StageEntityMoveManager { } } } - + export function moveEntities(delta: Vector) { + for (const node of StageManager.getEntities()) { + if (node.isSelected) { + moveEntityUtils(node, delta); + } + } + } /** * 拖动所有选中的节点一起移动 * @param delta