Initial project
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
namespace AetherBags.Extensions;
|
||||
|
||||
public static unsafe class AtkResNodeExtensions
|
||||
{
|
||||
extension(ref AtkResNode node)
|
||||
{
|
||||
public void ShowInventoryItemTooltip(InventoryType container, short slot) {
|
||||
fixed (AtkResNode* nodePointer = &node) {
|
||||
AtkStage.Instance()->ShowInventoryItemTooltip(nodePointer, container, slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using FFXIVClientStructs.FFXIV.Client.Enums;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
namespace AetherBags.Extensions;
|
||||
|
||||
|
||||
public static unsafe class AtkStageExtensions
|
||||
{
|
||||
extension(ref AtkStage stage)
|
||||
{
|
||||
public void ShowInventoryItemTooltip(AtkResNode* node, InventoryType container, short slot)
|
||||
{
|
||||
var tooltipArgs = stackalloc AtkTooltipManager.AtkTooltipArgs[1];
|
||||
tooltipArgs->Ctor();
|
||||
tooltipArgs->ItemArgs.Kind = DetailKind.InventoryItem;
|
||||
tooltipArgs->ItemArgs.InventoryType = container;
|
||||
tooltipArgs->ItemArgs.Slot = slot;
|
||||
tooltipArgs->ItemArgs.BuyQuantity = -1;
|
||||
tooltipArgs->ItemArgs.Flag1 = 0;
|
||||
|
||||
var addon = RaptureAtkUnitManager.Instance()->GetAddonByNode(node);
|
||||
if (addon is null) return;
|
||||
|
||||
stage.TooltipManager.ShowTooltip(
|
||||
AtkTooltipManager.AtkTooltipType.Item,
|
||||
addon->Id,
|
||||
node,
|
||||
tooltipArgs
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Dalamud.Utility;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using Lumina.Excel.Sheets;
|
||||
using Lumina.Text.ReadOnly;
|
||||
|
||||
namespace AetherBags.Extensions;
|
||||
|
||||
public static unsafe class InventoryItemExtensions {
|
||||
extension(ref InventoryItem item) {
|
||||
public uint IconId => item.GetIconId();
|
||||
public ReadOnlySeString Name => item.GetItemName();
|
||||
|
||||
private uint GetIconId() {
|
||||
uint iconId = 0;
|
||||
|
||||
if (item.GetEventItem() is { } eventItem) {
|
||||
iconId = eventItem.Icon;
|
||||
}
|
||||
else if (item.GetItem() is { } regularItem) {
|
||||
iconId = regularItem.Icon;
|
||||
|
||||
if (item.IsHighQuality()) {
|
||||
iconId += 1_000_000;
|
||||
}
|
||||
}
|
||||
|
||||
return iconId;
|
||||
}
|
||||
|
||||
private ReadOnlySeString GetItemName() {
|
||||
var itemId = item.GetItemId();
|
||||
var itemName = ItemUtil.GetItemName(itemId);
|
||||
|
||||
return new Lumina.Text.SeStringBuilder()
|
||||
.PushColorType(ItemUtil.GetItemRarityColorType(itemId))
|
||||
.Append(itemName)
|
||||
.PopColorType()
|
||||
.ToReadOnlySeString();
|
||||
}
|
||||
|
||||
private Item? GetItem() {
|
||||
var baseItemId = item.GetBaseItemId();
|
||||
|
||||
if (ItemUtil.IsNormalItem(baseItemId) &&
|
||||
Services.DataManager.GetExcelSheet<Item>().TryGetRow(baseItemId, out var baseItem)) {
|
||||
return baseItem;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private EventItem? GetEventItem() {
|
||||
var baseItemId = item.GetBaseItemId();
|
||||
|
||||
if (ItemUtil.IsEventItem(baseItemId) &&
|
||||
Services.DataManager.GetExcelSheet<EventItem>().TryGetRow(baseItemId, out var eventItem)) {
|
||||
return eventItem;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsRegexMatch(string searchString) {
|
||||
// Skip any data access if string is empty
|
||||
if (searchString.IsNullOrEmpty()) return true;
|
||||
|
||||
var isDescriptionSearch = searchString.StartsWith('$');
|
||||
|
||||
if (isDescriptionSearch) {
|
||||
searchString = searchString[1..];
|
||||
}
|
||||
|
||||
try {
|
||||
var regex = new Regex(searchString,RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
|
||||
|
||||
if (ItemUtil.IsEventItem(item.GetBaseItemId())) {
|
||||
if (!Services.DataManager.GetExcelSheet<EventItem>().TryGetRow(item.GetBaseItemId(), out var itemData)) return false;
|
||||
|
||||
if (regex.IsMatch(item.ItemId.ToString())) return true;
|
||||
if (regex.IsMatch(itemData.Name.ToString())) return true;
|
||||
}
|
||||
|
||||
else if (ItemUtil.IsNormalItem(item.GetBaseItemId())) {
|
||||
if (!Services.DataManager.GetExcelSheet<Item>().TryGetRow(item.GetBaseItemId(), out var itemData)) return false;
|
||||
|
||||
if (regex.IsMatch(item.ItemId.ToString())) return true;
|
||||
if (regex.IsMatch(itemData.Name.ToString())) return true;
|
||||
if (regex.IsMatch(itemData.Description.ToString()) && isDescriptionSearch) return true;
|
||||
if (regex.IsMatch(itemData.LevelEquip.ToString())) return true;
|
||||
if (regex.IsMatch(itemData.LevelItem.RowId.ToString())) return true;
|
||||
}
|
||||
}
|
||||
catch (RegexParseException) { }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void UseItem()
|
||||
{
|
||||
uint itemId = item.ItemId;
|
||||
InventoryType type = item.GetInventoryType() == InventoryType.KeyItems
|
||||
? InventoryType.KeyItems
|
||||
: InventoryType.Invalid;
|
||||
|
||||
if (InventoryManager.Instance()->GetInventoryItemCount(itemId, true) > 0)
|
||||
itemId += 1_000_000;
|
||||
|
||||
AgentInventoryContext.Instance()->UseItem(itemId, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Numerics;
|
||||
using KamiToolKit.Classes;
|
||||
using Lumina.Excel.Sheets;
|
||||
|
||||
namespace AetherBags.Extensions;
|
||||
|
||||
public static class ItemExtensions {
|
||||
extension(Item item) {
|
||||
public Vector4 RarityColor => item.Rarity switch {
|
||||
7 => ColorHelper.GetColor(561),
|
||||
4 => ColorHelper.GetColor(555),
|
||||
3 => ColorHelper.GetColor(553),
|
||||
2 => ColorHelper.GetColor(551),
|
||||
1 => ColorHelper.GetColor(549),
|
||||
_ => Vector4.One,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
using KamiToolKit;
|
||||
|
||||
namespace AetherBags.Extensions;
|
||||
|
||||
public static unsafe class NodeBaseExtensions {
|
||||
extension(NodeBase node) {
|
||||
public void ShowInventoryItemTooltip(InventoryType container, short slot)
|
||||
=> AtkStage.Instance()->ShowInventoryItemTooltip(node, container, slot);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user