From 401e6ff370933d76b0696eccefcff485804b9532 Mon Sep 17 00:00:00 2001 From: Andy Baker Date: Tue, 21 Nov 2023 13:53:37 +0000 Subject: [PATCH] This seems to fix most bugs with duplicating to multimirror. --- .../Commands/MultimirrorDuplicateCommand.cs | 41 +++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/Commands/MultimirrorDuplicateCommand.cs b/Assets/Scripts/Commands/MultimirrorDuplicateCommand.cs index 0f6e2e4838..81a0f2f662 100644 --- a/Assets/Scripts/Commands/MultimirrorDuplicateCommand.cs +++ b/Assets/Scripts/Commands/MultimirrorDuplicateCommand.cs @@ -50,8 +50,6 @@ public MultimirrorDuplicateCommand(TrTransform xf, bool stampMode, BaseCommand p else { targetCanvas = App.Scene.SelectionCanvas; - // If we're not stamping then we don't want to duplicate the original - matrices = matrices.Skip(1).ToList(); } foreach (var stroke in m_SelectedStrokes) @@ -110,6 +108,18 @@ public MultimirrorDuplicateCommand(TrTransform xf, bool stampMode, BaseCommand p protected override void OnRedo() { + if (m_SelectedStrokes != null) + { + if (m_StampMode) + { + SelectionManager.m_Instance.DeselectStrokes(m_DuplicatedStrokes); + } + else + { + SelectionManager.m_Instance.DeselectStrokes(m_SelectedStrokes); + } + } + // Place duplicated strokes. foreach (var stroke in m_DuplicatedStrokes) { @@ -135,8 +145,16 @@ protected override void OnRedo() } TiltMeterScript.m_Instance.AdjustMeter(stroke, up: true); } - SelectionManager.m_Instance.RegisterStrokesInSelectionCanvas(m_DuplicatedStrokes); - + + if (m_StampMode) + { + SelectionManager.m_Instance.RegisterStrokesInSelectionCanvas(m_SelectedStrokes); + } + else + { + SelectionManager.m_Instance.RegisterStrokesInSelectionCanvas(m_DuplicatedStrokes); + } + // Place duplicated widgets. for (int i = 0; i < m_DuplicatedWidgets.Count; ++i) { @@ -191,7 +209,6 @@ protected override void OnUndo() } TiltMeterScript.m_Instance.AdjustMeter(stroke, up: false); } - SelectionManager.m_Instance.DeregisterStrokesInSelectionCanvas(m_DuplicatedStrokes); // Deselect selected widgets. if (m_DuplicatedWidgets != null && !m_StampMode) @@ -209,10 +226,20 @@ protected override void OnUndo() // Reset the selection transform before we select strokes. SelectionManager.m_Instance.SelectionTransform = m_Transform; - // Select strokes. if (m_SelectedStrokes != null) { - SelectionManager.m_Instance.SelectStrokes(m_SelectedStrokes); + if (m_StampMode) + { + // I don't think we need to do anything here + // My original stab at this below was buggy and created lots of duplicates + // SelectionManager.m_Instance.DeregisterStrokesInSelectionCanvas(m_SelectedStrokes); + // SelectionManager.m_Instance.SelectStrokes(m_DuplicatedStrokes); + } + else + { + SelectionManager.m_Instance.DeregisterStrokesInSelectionCanvas(m_DuplicatedStrokes); + SelectionManager.m_Instance.SelectStrokes(m_SelectedStrokes); + } } SelectionManager.m_Instance.UpdateSelectionWidget();