Allow drag&drop on stains.

This commit is contained in:
Ottermandias 2024-07-30 20:23:59 +02:00
parent d0d518ddc2
commit 6446309bd7
2 changed files with 28 additions and 1 deletions

View file

@ -1,6 +1,5 @@
using Glamourer.Api.Enums;
using Glamourer.Designs;
using Glamourer.GameData;
using Glamourer.State;
using OtterGui;
using OtterGui.Log;

View file

@ -9,6 +9,7 @@ using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
using OtterGui.Text;
using OtterGui.Text.EndObjects;
using OtterGui.Widgets;
using Penumbra.GameData.DataContainers;
using Penumbra.GameData.Enums;
@ -35,6 +36,8 @@ public class EquipmentDrawer
private float _requiredComboWidthUnscaled;
private float _requiredComboWidth;
private Stain? _draggedStain;
public EquipmentDrawer(FavoriteManager favorites, IDataManager gameData, ItemManager items, CodeService codes, TextureService textures,
Configuration config, GPoseService gPose, AdvancedDyePopup advancedDyes)
{
@ -512,6 +515,10 @@ public class EquipmentDrawer
var change = small
? _stainCombo.Draw($"##stain{data.Slot}", stain.RgbaColor, stain.Name, found, stain.Gloss)
: _stainCombo.Draw($"##stain{data.Slot}", stain.RgbaColor, stain.Name, found, stain.Gloss, width);
if (!change)
DrawStainDragDrop(data, index, stain, found);
if (index < data.CurrentStains.Count - 1)
ImUtf8.SameLineInner();
@ -526,6 +533,27 @@ public class EquipmentDrawer
}
}
private void DrawStainDragDrop(in EquipDrawData data, int index, Stain stain, bool found)
{
if (found)
{
using var dragSource = ImUtf8.DragDropSource();
if (dragSource.Success)
{
if (DragDropSource.SetPayload("stainDragDrop"u8))
_draggedStain = stain;
ImUtf8.Text($"Dragging {stain.Name}...");
}
}
using var dragTarget = ImUtf8.DragDropTarget();
if (dragTarget.IsDropping("stainDragDrop"u8) && _draggedStain.HasValue)
{
data.SetStains(data.CurrentStains.With(index, _draggedStain.Value.RowIndex));
_draggedStain = null;
}
}
private void DrawItem(in EquipDrawData data, out string label, bool small, bool clear, bool open)
{
Debug.Assert(data.Slot.IsEquipment() || data.Slot.IsAccessory(), $"Called {nameof(DrawItem)} on {data.Slot}.");