mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Add drag & drop of automated designs to other automated design sets.
This commit is contained in:
parent
455bdae717
commit
363d1619bc
3 changed files with 42 additions and 7 deletions
|
|
@ -247,6 +247,21 @@ public class AutoDesignManager : ISavable, IReadOnlyList<AutoDesignSet>, IDispos
|
||||||
_event.Invoke(AutomationChanged.Type.AddedDesign, set, set.Designs.Count - 1);
|
_event.Invoke(AutomationChanged.Type.AddedDesign, set, set.Designs.Count - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <remarks> Only used to move between sets. </remarks>
|
||||||
|
public void MoveDesignToSet(AutoDesignSet from, int idx, AutoDesignSet to)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(from, to))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var design = from.Designs[idx];
|
||||||
|
to.Designs.Add(design);
|
||||||
|
from.Designs.RemoveAt(idx);
|
||||||
|
Save();
|
||||||
|
Glamourer.Log.Debug($"Moved design {idx} from design set {from.Name} to design set {to.Name}.");
|
||||||
|
_event.Invoke(AutomationChanged.Type.AddedDesign, to, to.Designs.Count - 1);
|
||||||
|
_event.Invoke(AutomationChanged.Type.DeletedDesign, from, idx);
|
||||||
|
}
|
||||||
|
|
||||||
public void DeleteDesign(AutoDesignSet set, int which)
|
public void DeleteDesign(AutoDesignSet set, int which)
|
||||||
{
|
{
|
||||||
if (which >= set.Designs.Count || which < 0)
|
if (which >= set.Designs.Count || which < 0)
|
||||||
|
|
|
||||||
|
|
@ -346,7 +346,10 @@ public class SetPanel
|
||||||
{
|
{
|
||||||
ImGui.TextUnformatted($"Moving design #{index + 1:D2}...");
|
ImGui.TextUnformatted($"Moving design #{index + 1:D2}...");
|
||||||
if (ImGui.SetDragDropPayload(dragDropLabel, nint.Zero, 0))
|
if (ImGui.SetDragDropPayload(dragDropLabel, nint.Zero, 0))
|
||||||
_dragIndex = index;
|
{
|
||||||
|
_dragIndex = index;
|
||||||
|
_selector._dragDesignIndex = index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@ public class SetSelector : IDisposable
|
||||||
private int _dragIndex = -1;
|
private int _dragIndex = -1;
|
||||||
private Action? _endAction;
|
private Action? _endAction;
|
||||||
|
|
||||||
|
internal int _dragDesignIndex = -1;
|
||||||
|
|
||||||
public SetSelector(AutoDesignManager manager, AutomationChanged @event, Configuration config, ActorService actors, ObjectManager objects)
|
public SetSelector(AutoDesignManager manager, AutomationChanged @event, Configuration config, ActorService actors, ObjectManager objects)
|
||||||
{
|
{
|
||||||
_manager = manager;
|
_manager = manager;
|
||||||
|
|
@ -320,15 +322,30 @@ public class SetSelector : IDisposable
|
||||||
const string dragDropLabel = "DesignSetDragDrop";
|
const string dragDropLabel = "DesignSetDragDrop";
|
||||||
using (var target = ImRaii.DragDropTarget())
|
using (var target = ImRaii.DragDropTarget())
|
||||||
{
|
{
|
||||||
if (target.Success && ImGuiUtil.IsDropping(dragDropLabel))
|
if (target.Success)
|
||||||
{
|
{
|
||||||
if (_dragIndex >= 0)
|
if (ImGuiUtil.IsDropping(dragDropLabel))
|
||||||
{
|
{
|
||||||
var idx = _dragIndex;
|
if (_dragIndex >= 0)
|
||||||
_endAction = () => _manager.MoveSet(idx, index);
|
{
|
||||||
}
|
var idx = _dragIndex;
|
||||||
|
_endAction = () => _manager.MoveSet(idx, index);
|
||||||
|
}
|
||||||
|
|
||||||
_dragIndex = -1;
|
_dragIndex = -1;
|
||||||
|
}
|
||||||
|
else if (ImGuiUtil.IsDropping("DesignDragDrop"))
|
||||||
|
{
|
||||||
|
if (_dragDesignIndex >= 0)
|
||||||
|
{
|
||||||
|
var idx = _dragDesignIndex;
|
||||||
|
var setTo = set;
|
||||||
|
var setFrom = Selection!;
|
||||||
|
_endAction = () => _manager.MoveDesignToSet(setFrom, idx, setTo);
|
||||||
|
}
|
||||||
|
|
||||||
|
_dragDesignIndex = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue