|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | | -using System.Linq; |
4 | 3 |
|
5 | 4 | using Elements.Core; |
6 | 5 |
|
@@ -34,48 +33,31 @@ public static void OpenFromSlot(Slot creationSlot) |
34 | 33 | return; |
35 | 34 | } |
36 | 35 |
|
37 | | - _ = Create(localUser, creationSlot); |
| 36 | + ReferenceReplacementDialog dialog = new(creationSlot); |
| 37 | + dialog.PositionFor(localUser); |
38 | 38 | } |
39 | 39 |
|
40 | | - private ReferenceReplacementDialog(User owner, Slot dialogSlot) |
| 40 | + private ReferenceReplacementDialog(Slot dialogSlot) |
41 | 41 | { |
42 | | - ArgumentNullException.ThrowIfNull(owner); |
43 | 42 | _rootSlot = dialogSlot ?? throw new ArgumentNullException(nameof(dialogSlot)); |
44 | 43 | _rootSlot.Destroyed += OnSlotDestroyed; |
45 | | - ClearSlot(_rootSlot); |
46 | 44 |
|
47 | 45 | (_processRootRef, _sourceRef, _targetRef) = CreateReferenceFields(); |
48 | 46 |
|
49 | 47 | ConfigureRootSlot(); |
50 | 48 | BuildUI(); |
51 | 49 | UpdateStatus("Select inputs to begin."); |
52 | | - Focus(); |
53 | | - RepositionFor(owner); |
54 | 50 | } |
55 | 51 |
|
56 | | - public static ReferenceReplacementDialog Create(User owner, Slot dialogSlot) |
57 | | - { |
58 | | - return new ReferenceReplacementDialog(owner, dialogSlot); |
59 | | - } |
60 | | - |
61 | | - public bool IsAlive => !_disposed && !_rootSlot.IsDestroyed && !_rootSlot.IsRemoved; |
| 52 | + private bool IsAlive => !_disposed && !_rootSlot.IsDestroyed && !_rootSlot.IsRemoved; |
62 | 53 |
|
63 | | - public void Focus() |
64 | | - { |
65 | | - if (IsAlive) |
66 | | - { |
67 | | - _rootSlot.OrderOffset = DateTime.UtcNow.Ticks; |
68 | | - } |
69 | | - } |
70 | | - |
71 | | - public void RepositionFor(User? user) |
| 54 | + private void PositionFor(User? user) |
72 | 55 | { |
73 | 56 | if (user == null || !IsAlive) |
74 | 57 | { |
75 | 58 | return; |
76 | 59 | } |
77 | 60 |
|
78 | | - ResetRootTransform(); |
79 | 61 | _rootSlot.PositionInFrontOfUser(float3.Backward); |
80 | 62 | if (user.LocalUserRoot != null) |
81 | 63 | { |
@@ -354,22 +336,4 @@ private void UpdateStatus(string message, ReferenceScanResult? detail = null) |
354 | 336 | } |
355 | 337 | } |
356 | 338 |
|
357 | | - private static void ClearSlot(Slot slot) |
358 | | - { |
359 | | - foreach (Slot child in slot.Children.ToArray()) |
360 | | - { |
361 | | - child.Destroy(); |
362 | | - } |
363 | | - |
364 | | - foreach (Component component in slot.Components.ToArray()) |
365 | | - { |
366 | | - component.Destroy(); |
367 | | - } |
368 | | - } |
369 | | - |
370 | | - private void ResetRootTransform() |
371 | | - { |
372 | | - _rootSlot.LocalPosition = float3.Zero; |
373 | | - _rootSlot.LocalRotation = floatQ.Identity; |
374 | | - } |
375 | 339 | } |
0 commit comments