feat: add try on to examine window
This commit is contained in:
parent
f56c80080c
commit
0fb1c4758d
|
@ -1,5 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||||
using Glamaholic.Ui;
|
using Glamaholic.Ui;
|
||||||
using Glamaholic.Ui.Helpers;
|
using Glamaholic.Ui.Helpers;
|
||||||
using ImGuiScene;
|
using ImGuiScene;
|
||||||
|
@ -65,5 +67,20 @@ namespace Glamaholic {
|
||||||
internal void SwitchPlate(int idx, bool scrollTo = false) {
|
internal void SwitchPlate(int idx, bool scrollTo = false) {
|
||||||
this.MainInterface.SwitchPlate(idx, scrollTo);
|
this.MainInterface.SwitchPlate(idx, scrollTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal unsafe void TryOn(IEnumerable<SavedGlamourItem> items) {
|
||||||
|
void SetTryOnSave(bool save) {
|
||||||
|
var tryOnAgent = (IntPtr) Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.Tryon);
|
||||||
|
if (tryOnAgent != IntPtr.Zero) {
|
||||||
|
*(byte*) (tryOnAgent + 0x2E2) = (byte) (save ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetTryOnSave(false);
|
||||||
|
foreach (var mirage in items) {
|
||||||
|
this.Plugin.Functions.TryOn(mirage.ItemId, mirage.StainId);
|
||||||
|
SetTryOnSave(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Dalamud.Interface;
|
using System.Collections.Generic;
|
||||||
|
using Dalamud.Interface;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
@ -38,46 +39,14 @@ namespace Glamaholic.Ui.Helpers {
|
||||||
ImGui.SetNextItemWidth(ImGui.CalcTextSize(this.Ui.Plugin.Name).X + ImGui.GetStyle().ItemInnerSpacing.X * 2 + 32 * ImGuiHelpers.GlobalScale);
|
ImGui.SetNextItemWidth(ImGui.CalcTextSize(this.Ui.Plugin.Name).X + ImGui.GetStyle().ItemInnerSpacing.X * 2 + 32 * ImGuiHelpers.GlobalScale);
|
||||||
if (ImGui.BeginCombo("##glamaholic-helper-examine-combo", this.Ui.Plugin.Name)) {
|
if (ImGui.BeginCombo("##glamaholic-helper-examine-combo", this.Ui.Plugin.Name)) {
|
||||||
if (ImGui.Selectable("Create glamour plate")) {
|
if (ImGui.Selectable("Create glamour plate")) {
|
||||||
void DoIt() {
|
this.CopyToGlamourPlate();
|
||||||
var inventory = InventoryManager.Instance()->GetInventoryContainer(InventoryType.Examine);
|
}
|
||||||
if (inventory == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var name = this.Ui.Plugin.Functions.ExamineName;
|
if (ImGui.Selectable("Try on")) {
|
||||||
if (string.IsNullOrEmpty(name)) {
|
var items = GetItems();
|
||||||
name = "Copied glamour";
|
if (items != null) {
|
||||||
}
|
this.Ui.TryOn(items.Values);
|
||||||
|
|
||||||
var plate = new SavedPlate(name);
|
|
||||||
for (var i = 0; i < inventory->Size; i++) {
|
|
||||||
var item = inventory->Items[i];
|
|
||||||
var itemId = item.GlamourID;
|
|
||||||
if (itemId == 0) {
|
|
||||||
itemId = item.ItemID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemId == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var stainId = item.Stain;
|
|
||||||
|
|
||||||
// TODO: remove this logic in endwalker
|
|
||||||
var slot = i > 5 ? i - 1 : i;
|
|
||||||
plate.Items[(PlateSlot) slot] = new SavedGlamourItem {
|
|
||||||
ItemId = itemId,
|
|
||||||
StainId = stainId,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Ui.Plugin.Config.AddPlate(plate);
|
|
||||||
this.Ui.Plugin.SaveConfig();
|
|
||||||
this.Ui.OpenMainInterface();
|
|
||||||
this.Ui.SwitchPlate(this.Ui.Plugin.Config.Plates.Count - 1, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DoIt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndCombo();
|
ImGui.EndCombo();
|
||||||
|
@ -85,5 +54,62 @@ namespace Glamaholic.Ui.Helpers {
|
||||||
|
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static unsafe Dictionary<PlateSlot, SavedGlamourItem>? GetItems() {
|
||||||
|
var inventory = InventoryManager.Instance()->GetInventoryContainer(InventoryType.Examine);
|
||||||
|
if (inventory == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var items = new Dictionary<PlateSlot, SavedGlamourItem>();
|
||||||
|
for (var i = 0; i < inventory->Size && i < (int) (PlateSlot.LeftRing + 2); i++) {
|
||||||
|
var item = inventory->Items[i];
|
||||||
|
var itemId = item.GlamourID;
|
||||||
|
if (itemId == 0) {
|
||||||
|
itemId = item.ItemID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemId == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var stainId = item.Stain;
|
||||||
|
|
||||||
|
// TODO: remove this logic in endwalker
|
||||||
|
var slot = i > 5 ? i - 1 : i;
|
||||||
|
items[(PlateSlot) slot] = new SavedGlamourItem {
|
||||||
|
ItemId = itemId,
|
||||||
|
StainId = stainId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void CopyToGlamourPlate() {
|
||||||
|
var inventory = InventoryManager.Instance()->GetInventoryContainer(InventoryType.Examine);
|
||||||
|
if (inventory == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var name = this.Ui.Plugin.Functions.ExamineName;
|
||||||
|
if (string.IsNullOrEmpty(name)) {
|
||||||
|
name = "Copied glamour";
|
||||||
|
}
|
||||||
|
|
||||||
|
var items = GetItems();
|
||||||
|
if (items == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var plate = new SavedPlate(name) {
|
||||||
|
Items = items,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.Ui.Plugin.Config.AddPlate(plate);
|
||||||
|
this.Ui.Plugin.SaveConfig();
|
||||||
|
this.Ui.OpenMainInterface();
|
||||||
|
this.Ui.SwitchPlate(this.Ui.Plugin.Config.Plates.Count - 1, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using Dalamud.Interface.Colors;
|
using Dalamud.Interface.Colors;
|
||||||
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
@ -326,7 +324,7 @@ namespace Glamaholic.Ui {
|
||||||
|
|
||||||
ImGui.EndPopup();
|
ImGui.EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void DrawItemPopup(string itemPopup, SavedPlate plate, PlateSlot slot) {
|
private unsafe void DrawItemPopup(string itemPopup, SavedPlate plate, PlateSlot slot) {
|
||||||
if (!ImGui.BeginPopup(itemPopup)) {
|
if (!ImGui.BeginPopup(itemPopup)) {
|
||||||
return;
|
return;
|
||||||
|
@ -485,7 +483,7 @@ namespace Glamaholic.Ui {
|
||||||
ImGui.EndTable();
|
ImGui.EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void DrawPlateButtons(SavedPlate plate) {
|
private void DrawPlateButtons(SavedPlate plate) {
|
||||||
if (this._editing || !ImGui.BeginTable("plate buttons", 5, ImGuiTableFlags.SizingFixedFit)) {
|
if (this._editing || !ImGui.BeginTable("plate buttons", 5, ImGuiTableFlags.SizingFixedFit)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -497,18 +495,7 @@ namespace Glamaholic.Ui {
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
if (Util.IconButton(FontAwesomeIcon.Search, tooltip: "Try on")) {
|
if (Util.IconButton(FontAwesomeIcon.Search, tooltip: "Try on")) {
|
||||||
void SetTryOnSave(bool save) {
|
this.Ui.TryOn(plate.Items.Values);
|
||||||
var tryOnAgent = (IntPtr) Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.Tryon);
|
|
||||||
if (tryOnAgent != IntPtr.Zero) {
|
|
||||||
*(byte*) (tryOnAgent + 0x2E2) = (byte) (save ? 1 : 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SetTryOnSave(false);
|
|
||||||
foreach (var mirage in plate.Items.Values) {
|
|
||||||
this.Ui.Plugin.Functions.TryOn(mirage.ItemId, mirage.StainId);
|
|
||||||
SetTryOnSave(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
|
|
Loading…
Reference in New Issue