2021-11-23 00:58:39 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Numerics;
|
|
|
|
|
using Dalamud.Game.Text;
|
|
|
|
|
using Dalamud.Game.Text.SeStringHandling;
|
|
|
|
|
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
2021-11-23 04:21:02 +00:00
|
|
|
|
using Dalamud.Interface;
|
2021-11-23 00:58:39 +00:00
|
|
|
|
using ImGuiNET;
|
|
|
|
|
using Lumina.Excel.GeneratedSheets;
|
|
|
|
|
|
|
|
|
|
namespace Glamaholic.Ui {
|
|
|
|
|
internal class AlternativeFinder {
|
|
|
|
|
private Guid Id { get; } = Guid.NewGuid();
|
|
|
|
|
internal bool Visible = true;
|
|
|
|
|
|
|
|
|
|
private PluginUi Ui { get; }
|
|
|
|
|
private Item Item { get; }
|
|
|
|
|
private List<Item> Alternatives { get; } = new();
|
|
|
|
|
|
|
|
|
|
internal AlternativeFinder(PluginUi ui, Item item) {
|
|
|
|
|
this.Ui = ui;
|
|
|
|
|
this.Item = item;
|
|
|
|
|
|
|
|
|
|
var info = ModelInfo(item.ModelMain);
|
|
|
|
|
|
|
|
|
|
foreach (var row in this.Ui.Plugin.DataManager.GetExcelSheet<Item>()!) {
|
2021-11-23 04:23:37 +00:00
|
|
|
|
if (Util.IsItemSkipped(row) || row.EquipSlotCategory.Row != this.Item.EquipSlotCategory.Row || info != ModelInfo(row.ModelMain)) {
|
2021-11-23 00:58:39 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Alternatives.Add(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void Draw() {
|
|
|
|
|
ImGui.SetNextWindowSize(new Vector2(250, 350), ImGuiCond.Appearing);
|
|
|
|
|
ImGui.SetNextWindowPos(ImGui.GetMousePos(), ImGuiCond.Appearing);
|
|
|
|
|
|
|
|
|
|
const ImGuiWindowFlags flags = ImGuiWindowFlags.NoSavedSettings;
|
|
|
|
|
if (!ImGui.Begin($"Alternative Finder: {this.Item.Name}##{this.Id}", ref this.Visible, flags)) {
|
|
|
|
|
ImGui.End();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.DrawInner();
|
|
|
|
|
|
|
|
|
|
ImGui.End();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawInner() {
|
|
|
|
|
ImGui.Columns(2);
|
|
|
|
|
ImGui.SetColumnWidth(0, MainInterface.IconSize + ImGui.GetStyle().ItemSpacing.X * 2);
|
|
|
|
|
var icon = this.Ui.GetIcon(this.Item.Icon);
|
|
|
|
|
if (icon != null) {
|
|
|
|
|
ImGui.Image(icon.ImGuiHandle, new Vector2(48));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui.NextColumn();
|
|
|
|
|
|
|
|
|
|
ImGui.TextUnformatted("Click: link to chat");
|
|
|
|
|
ImGui.TextUnformatted("Right-click: try on");
|
|
|
|
|
|
|
|
|
|
ImGui.Columns();
|
|
|
|
|
|
|
|
|
|
ImGui.Separator();
|
|
|
|
|
|
|
|
|
|
this.DrawAlternatives();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawAlternatives() {
|
|
|
|
|
if (!ImGui.BeginChild($"{this.Id} alternatives")) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var alt in this.Alternatives) {
|
2021-11-23 04:21:02 +00:00
|
|
|
|
if (ImGui.Selectable($"##{alt.RowId}", alt.RowId == this.Item.RowId)) {
|
2021-11-23 00:58:39 +00:00
|
|
|
|
this.LinkItem(alt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) {
|
|
|
|
|
this.Ui.Plugin.Functions.TryOn(alt.RowId, 0, false);
|
|
|
|
|
}
|
2021-11-23 04:21:02 +00:00
|
|
|
|
|
|
|
|
|
ImGui.SameLine();
|
|
|
|
|
|
|
|
|
|
if (!alt.IsDyeable) {
|
|
|
|
|
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetStyle().Colors[(int) ImGuiCol.TextDisabled]);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-09 09:07:58 +00:00
|
|
|
|
Util.TextIcon(FontAwesomeIcon.FillDrip);
|
|
|
|
|
|
2021-11-23 04:21:02 +00:00
|
|
|
|
if (!alt.IsDyeable) {
|
|
|
|
|
ImGui.PopStyleColor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui.SameLine();
|
|
|
|
|
ImGui.TextUnformatted(alt.Name);
|
2021-11-23 00:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui.EndChild();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static (ushort, ushort, ushort, ushort) ModelInfo(ulong raw) {
|
|
|
|
|
// return (ushort) (raw & 0xFFFF);
|
|
|
|
|
var primaryKey = (ushort) (raw & 0xFFFF);
|
|
|
|
|
var secondaryKey = (ushort) ((raw >> 16) & 0xFFFF);
|
|
|
|
|
var variant = (ushort) ((raw >> 32) & 0xFFFF);
|
|
|
|
|
var dye = (ushort) ((raw >> 48) & 0xFFFF);
|
|
|
|
|
|
|
|
|
|
if (variant != 0) {
|
|
|
|
|
// weapon
|
|
|
|
|
return (primaryKey, secondaryKey, variant, dye);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (primaryKey, 0, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LinkItem(Item item) {
|
|
|
|
|
var payloadList = new List<Payload> {
|
|
|
|
|
new UIForegroundPayload((ushort) (0x223 + item.Rarity * 2)),
|
|
|
|
|
new UIGlowPayload((ushort) (0x224 + item.Rarity * 2)),
|
|
|
|
|
new ItemPayload(item.RowId, false),
|
|
|
|
|
new UIForegroundPayload(500),
|
|
|
|
|
new UIGlowPayload(501),
|
|
|
|
|
new TextPayload($"{(char) SeIconChar.LinkMarker}"),
|
|
|
|
|
new UIForegroundPayload(0),
|
|
|
|
|
new UIGlowPayload(0),
|
|
|
|
|
};
|
|
|
|
|
payloadList.AddRange(SeString.Parse(item.Name.RawData).Payloads);
|
|
|
|
|
payloadList.AddRange(new[] {
|
|
|
|
|
new RawPayload(new byte[] { 0x02, 0x27, 0x07, 0xCF, 0x01, 0x01, 0x01, 0xFF, 0x01, 0x03 }),
|
|
|
|
|
new RawPayload(new byte[] { 0x02, 0x13, 0x02, 0xEC, 0x03 }),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var payload = new SeString(payloadList);
|
|
|
|
|
|
2023-09-29 01:07:21 +00:00
|
|
|
|
this.Ui.Plugin.ChatGui.Print(new XivChatEntry {
|
2021-11-23 00:58:39 +00:00
|
|
|
|
Message = payload,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|