Skip to content

Commit f853097

Browse files
Merge pull request #310 from donkeyProgramming/revert-309-feat/superview-batch-operations
Revert "Feat: Support batch operations (delete/move) for multi-selected tags in Super View"
2 parents 90bf50d + a2eda96 commit f853097

File tree

2 files changed

+31
-100
lines changed

2 files changed

+31
-100
lines changed

Editors/MetaDataEditor/AnimationMeta/MetaEditor/Commands/DeleteEntryCommand.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,14 @@ internal class DeleteEntryCommand : IUiCommand
77
{
88
public void Execute(MetaDataEditorViewModel controller)
99
{
10-
if (controller.ParsedFile == null) return;
11-
12-
// Get all selected items from the UI tags
13-
var itemsToRemove = controller.Tags
14-
.Where(x => x.IsSelected)
15-
.Select(x => x._input)
16-
.ToList();
17-
18-
if (!itemsToRemove.Any()) return;
19-
20-
// Batch remove all selected tags
21-
foreach (var item in itemsToRemove)
22-
{
23-
controller.ParsedFile.Attributes.Remove(item);
24-
}
10+
var itemToRemove = controller.SelectedAttribute;
11+
if (itemToRemove == null || controller.ParsedFile == null)
12+
return;
2513

14+
controller.ParsedFile.Attributes.Remove(itemToRemove);
2615
controller.UpdateView();
27-
28-
// Select the first item by default after deletion
2916
controller.SelectedTag = controller.Tags.FirstOrDefault();
3017
}
18+
3119
}
3220
}

Editors/MetaDataEditor/AnimationMeta/MetaEditor/Commands/MoveEntryCommand.cs

Lines changed: 26 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -7,96 +7,39 @@ internal class MoveEntryCommand : IUiCommand
77
{
88
public void ExecuteUp(MetaDataEditorViewModel controller)
99
{
10-
if (controller.ParsedFile == null) return;
11-
12-
var itemsToMove = controller.Tags
13-
.Where(x => x.IsSelected)
14-
.Select(x => x._input)
15-
.ToList();
16-
17-
if (!itemsToMove.Any()) return;
18-
19-
var attributes = controller.ParsedFile.Attributes;
20-
21-
// Sort ascending to move top items first, preventing them from jumping over each other
22-
var sortedItems = itemsToMove.OrderBy(x => attributes.IndexOf(x)).ToList();
23-
bool moved = false;
24-
25-
foreach (var item in sortedItems)
26-
{
27-
var currentIndex = attributes.IndexOf(item);
28-
if (currentIndex > 0)
29-
{
30-
// If the item above is also in the selection, keep them as a block
31-
var itemAbove = attributes[currentIndex - 1];
32-
if (!itemsToMove.Contains(itemAbove))
33-
{
34-
attributes.RemoveAt(currentIndex);
35-
attributes.Insert(currentIndex - 1, item);
36-
moved = true;
37-
}
38-
}
39-
}
40-
41-
if (moved)
42-
{
43-
controller.UpdateView();
44-
45-
// Restore selection state for the moved items
46-
foreach (var tag in controller.Tags.Where(t => itemsToMove.Contains(t._input)))
47-
{
48-
tag.IsSelected = true;
49-
}
50-
51-
controller.SelectedTag = controller.Tags.FirstOrDefault(x => x.IsSelected);
52-
}
10+
var itemToMove = controller.SelectedAttribute;
11+
if (itemToMove == null || controller.ParsedFile == null)
12+
return;
13+
14+
var currentIndex = controller.ParsedFile.Attributes.IndexOf(itemToMove);
15+
if (currentIndex == 0)
16+
return;
17+
18+
controller.ParsedFile.Attributes.Remove(itemToMove);
19+
controller.ParsedFile.Attributes.Insert(currentIndex - 1, itemToMove);
20+
controller.UpdateView();
21+
controller.SelectedTag = controller.Tags
22+
.Where(x => x._input == itemToMove)
23+
.FirstOrDefault();
5324
}
5425

5526
public void ExecuteDown(MetaDataEditorViewModel controller)
5627
{
57-
if (controller.ParsedFile == null) return;
58-
59-
var itemsToMove = controller.Tags
60-
.Where(x => x.IsSelected)
61-
.Select(x => x._input)
62-
.ToList();
63-
64-
if (!itemsToMove.Any()) return;
65-
66-
var attributes = controller.ParsedFile.Attributes;
67-
68-
// Sort descending to move bottom items first
69-
var sortedItems = itemsToMove.OrderByDescending(x => attributes.IndexOf(x)).ToList();
70-
bool moved = false;
71-
72-
foreach (var item in sortedItems)
73-
{
74-
var currentIndex = attributes.IndexOf(item);
75-
if (currentIndex < attributes.Count - 1)
76-
{
77-
// If the item below is also in the selection, keep them as a block
78-
var itemBelow = attributes[currentIndex + 1];
79-
if (!itemsToMove.Contains(itemBelow))
80-
{
81-
attributes.RemoveAt(currentIndex);
82-
attributes.Insert(currentIndex + 1, item);
83-
moved = true;
84-
}
85-
}
86-
}
28+
var itemToMove = controller.SelectedAttribute;
29+
if (itemToMove == null || controller.ParsedFile == null)
30+
return;
8731

88-
if (moved)
89-
{
90-
controller.UpdateView();
32+
var currentIndex = controller.ParsedFile.Attributes.IndexOf(itemToMove);
33+
if (currentIndex == controller.ParsedFile.Attributes.Count -1)
34+
return;
9135

92-
// Restore selection state for the moved items
93-
foreach (var tag in controller.Tags.Where(t => itemsToMove.Contains(t._input)))
94-
{
95-
tag.IsSelected = true;
96-
}
36+
controller.ParsedFile.Attributes.Remove(itemToMove);
37+
controller.ParsedFile.Attributes.Insert(currentIndex + 1, itemToMove);
38+
controller.UpdateView();
39+
controller.SelectedTag = controller.Tags
40+
.Where(x => x._input == itemToMove)
41+
.FirstOrDefault();
9742

98-
controller.SelectedTag = controller.Tags.FirstOrDefault(x => x.IsSelected);
99-
}
10043
}
10144
}
10245
}

0 commit comments

Comments
 (0)