mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2026-02-23 16:07:44 +01:00
Support model id input in weapon combo, support middle-mouse pipette.
This commit is contained in:
parent
fcb0660def
commit
b1abbb8e77
5 changed files with 134 additions and 10 deletions
78
Glamourer/Gui/Equipment/ItemCopyService.cs
Normal file
78
Glamourer/Gui/Equipment/ItemCopyService.cs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Glamourer.Services;
|
||||
using ImGuiNET;
|
||||
using OtterGui.OtterGuiInternal.Enums;
|
||||
using OtterGui.Services;
|
||||
using OtterGuiInternal;
|
||||
using Penumbra.GameData.Data;
|
||||
using Penumbra.GameData.DataContainers;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Structs;
|
||||
|
||||
namespace Glamourer.Gui.Equipment;
|
||||
|
||||
public class ItemCopyService(ItemManager items, IKeyState keyState, DictStain stainData) : IUiService
|
||||
{
|
||||
public EquipItem? Item { get; private set; }
|
||||
public Stain? Stain { get; private set; }
|
||||
|
||||
public void Copy(in EquipItem item)
|
||||
=> Item = item;
|
||||
|
||||
public void Copy(in Stain stain)
|
||||
=> Stain = stain;
|
||||
|
||||
public void Paste(int which, Action<int, StainId> setter)
|
||||
{
|
||||
if (Stain is { } stain)
|
||||
setter(which, stain.RowIndex);
|
||||
}
|
||||
|
||||
public void Paste(FullEquipType type, Action<EquipItem> setter)
|
||||
{
|
||||
if (Item is not { } item)
|
||||
return;
|
||||
|
||||
if (type != item.Type)
|
||||
{
|
||||
if (type.IsBonus())
|
||||
item = items.Identify(type.ToBonus(), item.PrimaryId, item.Variant);
|
||||
else if (type.IsEquipment() || type.IsAccessory())
|
||||
item = items.Identify(type.ToSlot(), item.PrimaryId, item.Variant);
|
||||
else
|
||||
item = items.Identify(type.ToSlot(), item.PrimaryId, item.SecondaryId, item.Variant);
|
||||
}
|
||||
|
||||
if (item.Valid && item.Type == type)
|
||||
setter(item);
|
||||
}
|
||||
|
||||
public void HandleCopyPaste(in EquipDrawData data)
|
||||
{
|
||||
if (ImGui.GetIO().KeyCtrl)
|
||||
{
|
||||
if (ImGui.IsItemHovered() && ImGui.IsMouseClicked(ImGuiMouseButton.Middle))
|
||||
Paste(data.CurrentItem.Type, data.SetItem);
|
||||
}
|
||||
else if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled) && ImGui.IsMouseClicked(ImGuiMouseButton.Middle))
|
||||
{
|
||||
Copy(data.CurrentItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleCopyPaste(in EquipDrawData data, int which)
|
||||
{
|
||||
if (ImGui.GetIO().KeyCtrl)
|
||||
{
|
||||
if (ImGui.IsItemHovered() && ImGui.IsMouseClicked(ImGuiMouseButton.Middle))
|
||||
Paste(which, data.SetStain);
|
||||
}
|
||||
else if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)
|
||||
&& ImGui.IsMouseClicked(ImGuiMouseButton.Middle)
|
||||
&& stainData.TryGetValue(data.CurrentStains[which].Id, out var stain))
|
||||
{
|
||||
Copy(stain);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue