Compare commits
No commits in common. "master" and "v1.1" have entirely different histories.
3
Gearsetter.IpcTest/.gitignore
vendored
3
Gearsetter.IpcTest/.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
/dist
|
||||
/obj
|
||||
/bin
|
@ -1,8 +0,0 @@
|
||||
<Project Sdk="Dalamud.NET.Sdk/9.0.2">
|
||||
<PropertyGroup>
|
||||
<Version>1.0</Version>
|
||||
<OutputPath>dist</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\LLib\LLib.targets"/>
|
||||
</Project>
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"Name": "Gearsetter (IPC Test)",
|
||||
"Author": "Liza Carvelli",
|
||||
"Punchline": "dev only plugin",
|
||||
"Description": "dev only plugin"
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Dalamud.Game.Command;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||
|
||||
namespace Gearsetter.IpcTest;
|
||||
|
||||
public class GearsetterIpcTestPlugin : IDalamudPlugin
|
||||
{
|
||||
private readonly IDalamudPluginInterface _pluginInterface;
|
||||
private readonly ICommandManager _commandManager;
|
||||
private readonly IChatGui _chatGui;
|
||||
|
||||
public GearsetterIpcTestPlugin(IDalamudPluginInterface pluginInterface, ICommandManager commandManager,
|
||||
IChatGui chatGui)
|
||||
{
|
||||
_pluginInterface = pluginInterface;
|
||||
_commandManager = commandManager;
|
||||
_chatGui = chatGui;
|
||||
|
||||
_commandManager.AddHandler("/recommendedgear", new CommandInfo(ProcessCommand));
|
||||
}
|
||||
|
||||
private unsafe void ProcessCommand(string command, string arguments)
|
||||
{
|
||||
int currentGearsetIndex = RaptureGearsetModule.Instance()->CurrentGearsetIndex;
|
||||
var recommendations = _pluginInterface
|
||||
.GetIpcSubscriber<byte, List<(uint ItemId, InventoryType? SourceInventory, byte? SourceInventorySlot, RaptureGearsetModule.GearsetItemIndex TargetSlot)>>(
|
||||
"Gearsetter.GetRecommendationsForGearset").InvokeFunc((byte)currentGearsetIndex);
|
||||
if (recommendations.Count == 0)
|
||||
_chatGui.Print($"No recommendations for gearset #{currentGearsetIndex}.");
|
||||
else
|
||||
{
|
||||
foreach (var recommendation in recommendations)
|
||||
_chatGui.Print(
|
||||
$"Recommendation: Equip item {recommendation.ItemId} from {recommendation.SourceInventory} (slot {recommendation.SourceInventorySlot}) as {recommendation.TargetSlot}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_commandManager.RemoveHandler("/recommendedgear");
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"dependencies": {
|
||||
"net8.0-windows7.0": {
|
||||
"DalamudPackager": {
|
||||
"type": "Direct",
|
||||
"requested": "[2.1.13, )",
|
||||
"resolved": "2.1.13",
|
||||
"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
|
||||
},
|
||||
"DotNet.ReproducibleBuilds": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.1.1, )",
|
||||
"resolved": "1.1.1",
|
||||
"contentHash": "+H2t/t34h6mhEoUvHi8yGXyuZ2GjSovcGYehJrS2MDm2XgmPfZL2Sdxg+uL2lKgZ4M6tTwKHIlxOob2bgh0NRQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.SourceLink.AzureRepos.Git": "1.1.1",
|
||||
"Microsoft.SourceLink.Bitbucket.Git": "1.1.1",
|
||||
"Microsoft.SourceLink.GitHub": "1.1.1",
|
||||
"Microsoft.SourceLink.GitLab": "1.1.1"
|
||||
}
|
||||
},
|
||||
"Microsoft.SourceLink.Gitea": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.0, )",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "KOBodmDnlWGIqZt2hT47Q69TIoGhIApDVLCyyj9TT5ct8ju16AbHYcB4XeknoHX562wO1pMS/1DfBIZK+V+sxg==",
|
||||
"dependencies": {
|
||||
"Microsoft.Build.Tasks.Git": "8.0.0",
|
||||
"Microsoft.SourceLink.Common": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Build.Tasks.Git": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ=="
|
||||
},
|
||||
"Microsoft.SourceLink.AzureRepos.Git": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.1.1",
|
||||
"contentHash": "qB5urvw9LO2bG3eVAkuL+2ughxz2rR7aYgm2iyrB8Rlk9cp2ndvGRCvehk3rNIhRuNtQaeKwctOl1KvWiklv5w==",
|
||||
"dependencies": {
|
||||
"Microsoft.Build.Tasks.Git": "1.1.1",
|
||||
"Microsoft.SourceLink.Common": "1.1.1"
|
||||
}
|
||||
},
|
||||
"Microsoft.SourceLink.Bitbucket.Git": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.1.1",
|
||||
"contentHash": "cDzxXwlyWpLWaH0em4Idj0H3AmVo3L/6xRXKssYemx+7W52iNskj/SQ4FOmfCb8YQt39otTDNMveCZzYtMoucQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.Build.Tasks.Git": "1.1.1",
|
||||
"Microsoft.SourceLink.Common": "1.1.1"
|
||||
}
|
||||
},
|
||||
"Microsoft.SourceLink.Common": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
|
||||
},
|
||||
"Microsoft.SourceLink.GitHub": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.1.1",
|
||||
"contentHash": "IaJGnOv/M7UQjRJks7B6p7pbPnOwisYGOIzqCz5ilGFTApZ3ktOR+6zJ12ZRPInulBmdAf1SrGdDG2MU8g6XTw==",
|
||||
"dependencies": {
|
||||
"Microsoft.Build.Tasks.Git": "1.1.1",
|
||||
"Microsoft.SourceLink.Common": "1.1.1"
|
||||
}
|
||||
},
|
||||
"Microsoft.SourceLink.GitLab": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.1.1",
|
||||
"contentHash": "tvsg47DDLqqedlPeYVE2lmiTpND8F0hkrealQ5hYltSmvruy/Gr5nHAKSsjyw5L3NeM/HLMI5ORv7on/M4qyZw==",
|
||||
"dependencies": {
|
||||
"Microsoft.Build.Tasks.Git": "1.1.1",
|
||||
"Microsoft.SourceLink.Common": "1.1.1"
|
||||
}
|
||||
},
|
||||
"llib": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"DalamudPackager": "[2.1.13, )"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Gearsetter.GameData;
|
||||
using Gearsetter.Model;
|
||||
using LLib.GameData;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using Xunit;
|
||||
|
||||
|
@ -6,8 +6,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gearsetter.Test", "Gearsett
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LLib", "LLib\LLib.csproj", "{66144F9D-AC38-4F16-B269-A610F8EB7A3F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gearsetter.IpcTest", "Gearsetter.IpcTest\Gearsetter.IpcTest.csproj", "{D5BFA879-0A33-4640-B75E-D92D8F23D6F1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -26,9 +24,5 @@ Global
|
||||
{66144F9D-AC38-4F16-B269-A610F8EB7A3F}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{66144F9D-AC38-4F16-B269-A610F8EB7A3F}.Release|Any CPU.ActiveCfg = Debug|x64
|
||||
{66144F9D-AC38-4F16-B269-A610F8EB7A3F}.Release|Any CPU.Build.0 = Debug|x64
|
||||
{D5BFA879-0A33-4640-B75E-D92D8F23D6F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D5BFA879-0A33-4640-B75E-D92D8F23D6F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D5BFA879-0A33-4640-B75E-D92D8F23D6F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D5BFA879-0A33-4640-B75E-D92D8F23D6F1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
64
Gearsetter/External/GearsetterIpc.cs
vendored
64
Gearsetter/External/GearsetterIpc.cs
vendored
@ -1,64 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||
|
||||
namespace Gearsetter.External;
|
||||
|
||||
internal sealed class GearsetterIpc : IDisposable
|
||||
{
|
||||
private const string IpcGetRecommendationsForGearset = "Gearsetter.GetRecommendationsForGearset";
|
||||
|
||||
private readonly GearsetterPlugin _plugin;
|
||||
private readonly IPluginLog _pluginLog;
|
||||
|
||||
private readonly ICallGateProvider<byte,
|
||||
List<(uint ItemId, InventoryType? SourceInventory, int? SourceInventorySlot,
|
||||
RaptureGearsetModule.GearsetItemIndex TargetSlot)>>
|
||||
_getRecommendationsForGearset;
|
||||
|
||||
public GearsetterIpc(GearsetterPlugin plugin, IDalamudPluginInterface pluginInterface, IPluginLog pluginLog)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_pluginLog = pluginLog;
|
||||
_getRecommendationsForGearset =
|
||||
pluginInterface
|
||||
.GetIpcProvider<byte,
|
||||
List<(uint, InventoryType?, int?, RaptureGearsetModule.GearsetItemIndex TargetSlot)>>(
|
||||
IpcGetRecommendationsForGearset);
|
||||
_getRecommendationsForGearset.RegisterFunc(GetRecommendationsForGearset);
|
||||
}
|
||||
|
||||
private unsafe List<(uint ItemId, InventoryType? SourceInventory, int? SourceInventorySlot,
|
||||
RaptureGearsetModule.GearsetItemIndex TargetSlot)>
|
||||
GetRecommendationsForGearset(byte gearsetId)
|
||||
{
|
||||
if (gearsetId > 100)
|
||||
throw new ArgumentOutOfRangeException(nameof(gearsetId));
|
||||
|
||||
var gearsetModule = RaptureGearsetModule.Instance();
|
||||
if (gearsetModule == null)
|
||||
throw new InvalidOperationException($"{nameof(RaptureGearsetModule)} is null");
|
||||
|
||||
var gearset = gearsetModule->GetGearset(gearsetId);
|
||||
if (gearset == null)
|
||||
throw new InvalidOperationException($"Gearset {gearsetId} is null");
|
||||
|
||||
if (!gearset->Flags.HasFlag(RaptureGearsetModule.GearsetFlag.Exists))
|
||||
throw new InvalidOperationException($"Gearset {gearsetId} does not exist");
|
||||
|
||||
_pluginLog.Verbose($"Checking for gearset upgrades for gearset {gearset->Id}.");
|
||||
return _plugin.GetRecommendedUpgrades(gearset)
|
||||
.Select(x => (x.ItemId, x.SourceInventory, x.SourceInventorySlot, x.TargetSlot))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_getRecommendationsForGearset.UnregisterFunc();
|
||||
}
|
||||
}
|
117
Gearsetter/GameData/EClassJob.cs
Normal file
117
Gearsetter/GameData/EClassJob.cs
Normal file
@ -0,0 +1,117 @@
|
||||
namespace Gearsetter.GameData;
|
||||
|
||||
internal enum EClassJob : uint
|
||||
{
|
||||
Adventurer = 0,
|
||||
Gladiator = 1,
|
||||
Pugilist = 2,
|
||||
Marauder = 3,
|
||||
Lancer = 4,
|
||||
Archer = 5,
|
||||
Conjurer = 6,
|
||||
Thaumaturge = 7,
|
||||
Carpenter = 8,
|
||||
Blacksmith = 9,
|
||||
Armorer = 10,
|
||||
Goldsmith = 11,
|
||||
Leatherworker = 12,
|
||||
Weaver = 13,
|
||||
Alchemist = 14,
|
||||
Culinarian = 15,
|
||||
Miner = 16,
|
||||
Botanist = 17,
|
||||
Fisher = 18,
|
||||
Paladin = 19,
|
||||
Monk = 20,
|
||||
Warrior = 21,
|
||||
Dragoon = 22,
|
||||
Bard = 23,
|
||||
WhiteMage = 24,
|
||||
BlackMage = 25,
|
||||
Arcanist = 26,
|
||||
Summoner = 27,
|
||||
Scholar = 28,
|
||||
Rogue = 29,
|
||||
Ninja = 30,
|
||||
Machinist = 31,
|
||||
DarkKnight = 32,
|
||||
Astrologian = 33,
|
||||
Samurai = 34,
|
||||
RedMage = 35,
|
||||
BlueMage = 36,
|
||||
Gunbreaker = 37,
|
||||
Dancer = 38,
|
||||
Reaper = 39,
|
||||
Sage = 40,
|
||||
Viper = 41,
|
||||
Pictomancer = 42,
|
||||
}
|
||||
|
||||
internal static class EClassJobExtensions
|
||||
{
|
||||
public static EClassJob AsJob(this EClassJob classJob) => classJob switch
|
||||
{
|
||||
EClassJob.Gladiator => EClassJob.Paladin,
|
||||
EClassJob.Marauder => EClassJob.Warrior,
|
||||
EClassJob.Pugilist => EClassJob.Monk,
|
||||
EClassJob.Lancer => EClassJob.Dragoon,
|
||||
EClassJob.Rogue => EClassJob.Ninja,
|
||||
EClassJob.Archer => EClassJob.Bard,
|
||||
EClassJob.Conjurer => EClassJob.WhiteMage,
|
||||
EClassJob.Thaumaturge => EClassJob.BlackMage,
|
||||
EClassJob.Arcanist => EClassJob.Summoner,
|
||||
_ => classJob,
|
||||
};
|
||||
|
||||
public static bool IsTank(this EClassJob classJob) =>
|
||||
classJob is EClassJob.Gladiator
|
||||
or EClassJob.Paladin
|
||||
or EClassJob.Marauder
|
||||
or EClassJob.Warrior
|
||||
or EClassJob.DarkKnight
|
||||
or EClassJob.Gunbreaker;
|
||||
|
||||
public static bool IsHealer(this EClassJob classJob) =>
|
||||
classJob is EClassJob.Conjurer
|
||||
or EClassJob.WhiteMage
|
||||
or EClassJob.Scholar
|
||||
or EClassJob.Astrologian
|
||||
or EClassJob.Sage;
|
||||
|
||||
public static bool IsMelee(this EClassJob classJob) =>
|
||||
classJob is EClassJob.Pugilist
|
||||
or EClassJob.Monk
|
||||
or EClassJob.Lancer
|
||||
or EClassJob.Dragoon
|
||||
or EClassJob.Rogue
|
||||
or EClassJob.Ninja
|
||||
or EClassJob.Samurai
|
||||
or EClassJob.Reaper
|
||||
or EClassJob.Viper;
|
||||
|
||||
public static bool IsPhysicalRanged(this EClassJob classJob) =>
|
||||
classJob is EClassJob.Archer
|
||||
or EClassJob.Bard
|
||||
or EClassJob.Machinist
|
||||
or EClassJob.Dancer;
|
||||
|
||||
public static bool IsCaster(this EClassJob classJob) =>
|
||||
classJob is EClassJob.Thaumaturge
|
||||
or EClassJob.BlackMage
|
||||
or EClassJob.Arcanist
|
||||
or EClassJob.Summoner
|
||||
or EClassJob.RedMage
|
||||
or EClassJob.BlueMage
|
||||
or EClassJob.Pictomancer;
|
||||
|
||||
public static bool DealsPhysicalDamage(this EClassJob classJob) =>
|
||||
classJob.IsTank() || classJob.IsMelee() || classJob.IsPhysicalRanged();
|
||||
|
||||
public static bool DealsMagicDamage(this EClassJob classJob) =>
|
||||
classJob.IsHealer() || classJob.IsCaster();
|
||||
|
||||
public static bool IsCrafter(this EClassJob classJob) =>
|
||||
classJob is >= EClassJob.Carpenter and <= EClassJob.Culinarian;
|
||||
|
||||
public static bool IsGatherer(this EClassJob classJob) => classJob is >= EClassJob.Miner and <= EClassJob.Fisher;
|
||||
}
|
@ -6,7 +6,6 @@ using Dalamud.Game;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using Gearsetter.Model;
|
||||
using LLib.GameData;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
||||
namespace Gearsetter.GameData;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Dalamud.NET.Sdk/9.0.2">
|
||||
<PropertyGroup>
|
||||
<Version>1.3</Version>
|
||||
<Version>1.1</Version>
|
||||
<OutputPath>dist</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -12,11 +12,9 @@ using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||
using Gearsetter.External;
|
||||
using Gearsetter.GameData;
|
||||
using Gearsetter.Model;
|
||||
using Gearsetter.Windows;
|
||||
using LLib.GameData;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using GrandCompany = FFXIVClientStructs.FFXIV.Client.UI.Agent.GrandCompany;
|
||||
using InventoryItem = FFXIVClientStructs.FFXIV.Client.Game.InventoryItem;
|
||||
@ -33,11 +31,11 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
private readonly IDataManager _dataManager;
|
||||
private readonly IPluginLog _pluginLog;
|
||||
private readonly IClientState _clientState;
|
||||
private readonly GearsetterIpc _gearsetterIpc;
|
||||
private readonly Configuration _configuration;
|
||||
private readonly GameDataHolder _gameDataHolder;
|
||||
private readonly EquipmentBrowserWindow _equipmentBrowserWindow;
|
||||
private readonly ConfigWindow _configWindow;
|
||||
|
||||
private readonly IReadOnlyDictionary<byte, DalamudLinkPayload> _linkPayloads;
|
||||
private readonly Dictionary<EClassJob, byte> _classJobToArrayIndex;
|
||||
|
||||
@ -52,7 +50,6 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
_dataManager = dataManager;
|
||||
_pluginLog = pluginLog;
|
||||
_clientState = clientState;
|
||||
_gearsetterIpc = new GearsetterIpc(this, _pluginInterface, _pluginLog);
|
||||
|
||||
Configuration? configuration = (Configuration?)_pluginInterface.GetPluginConfig();
|
||||
if (configuration == null)
|
||||
@ -178,57 +175,36 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
return new GearsetData(_dataManager, gearset, name);
|
||||
}
|
||||
|
||||
internal unsafe List<RecommendedItemChange> GetRecommendedUpgrades(RaptureGearsetModule.GearsetEntry* gearset,
|
||||
byte? level = null)
|
||||
private bool HandleGearset(GearsetData gearset,
|
||||
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems, byte? level)
|
||||
{
|
||||
GearsetData gearsetData = new GearsetData(_dataManager, gearset, GetGearsetName(gearset));
|
||||
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems = GetAllInventoryItems();
|
||||
return GetRecommendedUpgrades(gearsetData, inventoryItems, level);
|
||||
}
|
||||
|
||||
private List<RecommendedItemChange> GetRecommendedUpgrades(GearsetData gearset,
|
||||
Dictionary<(uint ItemId, bool Hql), List<MateriaStats>> inventoryItems, byte? level)
|
||||
{
|
||||
List<RecommendedItemChange> Handle(string label,
|
||||
(EquipmentItem?, RaptureGearsetModule.GearsetItemIndex)[] gearsetItems,
|
||||
List<SeString> Handle(string label, EquipmentItem?[] gearsetItems,
|
||||
EEquipSlotCategory category)
|
||||
{
|
||||
return HandleGearsetItem(label, gearset, gearsetItems, inventoryItems, category, level);
|
||||
}
|
||||
|
||||
List<List<RecommendedItemChange>> upgrades = new()
|
||||
List<List<SeString>> upgrades = new()
|
||||
{
|
||||
Handle("Main Hand", [(gearset.MainHand, RaptureGearsetModule.GearsetItemIndex.MainHand)],
|
||||
EEquipSlotCategory.None),
|
||||
Handle("Main Hand", [gearset.MainHand], EEquipSlotCategory.None),
|
||||
HandleOffHand(gearset, inventoryItems, level),
|
||||
|
||||
Handle("Head", [(gearset.Head, RaptureGearsetModule.GearsetItemIndex.Head)], EEquipSlotCategory.Head),
|
||||
Handle("Body", [(gearset.Body, RaptureGearsetModule.GearsetItemIndex.Body)], EEquipSlotCategory.Body),
|
||||
Handle("Hands", [(gearset.Hands, RaptureGearsetModule.GearsetItemIndex.Hands)], EEquipSlotCategory.Hands),
|
||||
Handle("Legs", [(gearset.Legs, RaptureGearsetModule.GearsetItemIndex.Legs)], EEquipSlotCategory.Legs),
|
||||
Handle("Feet", [(gearset.Feet, RaptureGearsetModule.GearsetItemIndex.Feet)], EEquipSlotCategory.Feet),
|
||||
Handle("Head", [gearset.Head], EEquipSlotCategory.Head),
|
||||
Handle("Body", [gearset.Body], EEquipSlotCategory.Body),
|
||||
Handle("Hands", [gearset.Hands], EEquipSlotCategory.Hands),
|
||||
Handle("Legs", [gearset.Legs], EEquipSlotCategory.Legs),
|
||||
Handle("Feet", [gearset.Feet], EEquipSlotCategory.Feet),
|
||||
|
||||
Handle("Ears", [(gearset.Ears, RaptureGearsetModule.GearsetItemIndex.Ears)], EEquipSlotCategory.Ears),
|
||||
Handle("Neck", [(gearset.Neck, RaptureGearsetModule.GearsetItemIndex.Neck)], EEquipSlotCategory.Neck),
|
||||
Handle("Wrists", [(gearset.Wrists, RaptureGearsetModule.GearsetItemIndex.Wrists)],
|
||||
EEquipSlotCategory.Wrists),
|
||||
Handle("Ears", [gearset.Ears], EEquipSlotCategory.Ears),
|
||||
Handle("Neck", [gearset.Neck], EEquipSlotCategory.Neck),
|
||||
Handle("Wrists", [gearset.Wrists], EEquipSlotCategory.Wrists),
|
||||
Handle("Rings",
|
||||
[
|
||||
(gearset.RingLeft, RaptureGearsetModule.GearsetItemIndex.RingLeft),
|
||||
(gearset.RingRight, RaptureGearsetModule.GearsetItemIndex.RingRight)
|
||||
],
|
||||
[gearset.RingLeft, gearset.RingRight],
|
||||
EEquipSlotCategory.Rings),
|
||||
};
|
||||
|
||||
return upgrades.SelectMany(x => x).ToList();
|
||||
}
|
||||
|
||||
|
||||
private bool HandleGearset(GearsetData gearset,
|
||||
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems, byte? level)
|
||||
{
|
||||
List<RecommendedItemChange> upgrades = GetRecommendedUpgrades(gearset, inventoryItems, level);
|
||||
if (upgrades.Count == 0)
|
||||
List<SeString> flatUpgrades = upgrades.SelectMany(x => x).ToList();
|
||||
if (flatUpgrades.Count == 0)
|
||||
return false;
|
||||
|
||||
_chatGui.Print(
|
||||
@ -243,8 +219,8 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
.AddText(level != null ? $" at {level}" : "")
|
||||
.Build());
|
||||
|
||||
foreach (var upgrade in upgrades)
|
||||
_chatGui.Print(new SeString(new TextPayload(" - ")).Append(upgrade.Text));
|
||||
foreach (var upgrade in flatUpgrades)
|
||||
_chatGui.Print(new SeString(new TextPayload(" - ")).Append(upgrade));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -256,43 +232,41 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
private unsafe string GetGearsetName(RaptureGearsetModule.GearsetEntry* gearset)
|
||||
=> gearset->NameString.Split((char)0)[0];
|
||||
|
||||
private List<RecommendedItemChange> HandleGearsetItem(string label, GearsetData gearset,
|
||||
(EquipmentItem? Item, RaptureGearsetModule.GearsetItemIndex Slot)[] gearsetItems,
|
||||
private List<SeString> HandleGearsetItem(string label, GearsetData gearset,
|
||||
EquipmentItem?[] gearsetItems,
|
||||
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems,
|
||||
EEquipSlotCategory equipSlotCategory, byte? level)
|
||||
{
|
||||
EClassJob classJob = gearset.ClassJob;
|
||||
List<RaptureGearsetModule.GearsetItemIndex> availableGearsetSlots = gearsetItems.Select(x => x.Slot).ToList();
|
||||
var itemLists = _gameDataHolder.GetItemLists(classJob);
|
||||
|
||||
if (equipSlotCategory == EEquipSlotCategory.None && gearsetItems.Any(x => x.Item != null))
|
||||
if (equipSlotCategory == EEquipSlotCategory.None && gearsetItems.Any(x => x != null))
|
||||
{
|
||||
var firstEquippedItem = gearsetItems.First(x => x.Item != null);
|
||||
equipSlotCategory = firstEquippedItem.Item!.EquipSlotCategory;
|
||||
var firstEquippedItem = gearsetItems.First(x => x != null);
|
||||
equipSlotCategory = firstEquippedItem!.EquipSlotCategory;
|
||||
}
|
||||
|
||||
if (equipSlotCategory == EEquipSlotCategory.None)
|
||||
{
|
||||
_pluginLog.Warning("Unable to find item to determine equip slot category");
|
||||
return [];
|
||||
_pluginLog.Warning($"Unable to find item to determine equip slot category");
|
||||
return new List<SeString>();
|
||||
}
|
||||
|
||||
(BaseItem? Item, RaptureGearsetModule.GearsetItemIndex Slot)[] currentItems = gearsetItems
|
||||
BaseItem?[] currentItems = gearsetItems
|
||||
.Select(x =>
|
||||
{
|
||||
if (x.Item == null)
|
||||
return (null, x.Slot);
|
||||
if (x == null)
|
||||
return null;
|
||||
|
||||
var baseItem = itemLists
|
||||
.SelectMany(y => y.Items.Where(z => x.Item.ItemId == z.ItemId && x.Item.Hq == z.Hq))
|
||||
return itemLists
|
||||
.SelectMany(y => y.Items.Where(z => x.ItemId == z.ItemId && x.Hq == z.Hq))
|
||||
.FirstOrDefault();
|
||||
return (baseItem, x.Slot);
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
var availableList = _gameDataHolder.GetItemList(classJob, equipSlotCategory);
|
||||
if (availableList == null)
|
||||
return [];
|
||||
return new List<SeString>();
|
||||
|
||||
if (level == null)
|
||||
level = GetLevel(classJob);
|
||||
@ -307,29 +281,18 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
.Take(gearsetItems.Length)
|
||||
.ToList();
|
||||
//_pluginLog.Debug(
|
||||
// $"{equipSlotCategory}: {string.Join(" ", currentItems.Select(x => $"{x.Item}, {x.Slot}"))}");
|
||||
// $"{equipSlotCategory}: {string.Join(" ", currentItems.Select(x => $"{x?.ItemId}|{x?.Hq}"))}");
|
||||
foreach (var currentItem in currentItems)
|
||||
{
|
||||
var foundIndex = bestItems.FindIndex(x =>
|
||||
currentItem.Item != null && currentItem.Item.ItemId == x.ItemId && currentItem.Item.Hq == x.Hq);
|
||||
currentItem != null && currentItem.ItemId == x.ItemId && currentItem.Hq == x.Hq);
|
||||
if (foundIndex >= 0)
|
||||
{
|
||||
bestItems.RemoveAt(foundIndex);
|
||||
availableGearsetSlots.Remove(currentItem.Slot);
|
||||
}
|
||||
}
|
||||
|
||||
return bestItems
|
||||
.Select(x =>
|
||||
{
|
||||
var slot = availableGearsetSlots[0];
|
||||
availableGearsetSlots.RemoveAt(0);
|
||||
|
||||
return ToItemRecommendation(x, slot,
|
||||
new SeString(new TextPayload($"{label}: "))
|
||||
.Append(SeString.CreateItemLink(x.ItemId, x.Hq)));
|
||||
})
|
||||
.ToList();
|
||||
.Select(x => new SeString(new TextPayload($"{label}: "))
|
||||
.Append(SeString.CreateItemLink(x.ItemId, x.Hq))).ToList();
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -337,20 +300,20 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
}
|
||||
}
|
||||
|
||||
private List<RecommendedItemChange> HandleOffHand(GearsetData gearset,
|
||||
|
||||
private unsafe List<SeString> HandleOffHand(GearsetData gearset,
|
||||
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems, byte? level)
|
||||
{
|
||||
var mainHand = gearset.MainHand;
|
||||
if (mainHand == null)
|
||||
return [];
|
||||
return new List<SeString>();
|
||||
|
||||
// if it's a twohanded weapon, ignore it
|
||||
EEquipSlotCategory equipSlotCategory = mainHand.EquipSlotCategory;
|
||||
if (equipSlotCategory != EEquipSlotCategory.OneHandedMainHand)
|
||||
return [];
|
||||
return new List<SeString>();
|
||||
|
||||
return HandleGearsetItem("Off Hand", gearset,
|
||||
[(gearset.OffHand, RaptureGearsetModule.GearsetItemIndex.OffHand)],
|
||||
return HandleGearsetItem("Off Hand", gearset, [gearset.OffHand],
|
||||
inventoryItems,
|
||||
EEquipSlotCategory.Shield, level);
|
||||
}
|
||||
@ -358,32 +321,6 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
private unsafe void ChangeGearset(uint commandId, SeString seString)
|
||||
=> RaptureGearsetModule.Instance()->EquipGearset((byte)commandId);
|
||||
|
||||
|
||||
private unsafe RecommendedItemChange ToItemRecommendation(BaseItem baseItem,
|
||||
RaptureGearsetModule.GearsetItemIndex targetSlot, SeString text)
|
||||
{
|
||||
InventoryManager* inventoryManager = InventoryManager.Instance();
|
||||
foreach (var inventoryType in _gameDataHolder.DefaultInventoryTypes)
|
||||
{
|
||||
var container = inventoryManager->GetInventoryContainer(inventoryType);
|
||||
for (int i = 0; i < container->Size; ++i)
|
||||
{
|
||||
var item = container->GetInventorySlot(i);
|
||||
if (item != null && item->ItemId == baseItem.ItemId &&
|
||||
item->Flags.HasFlag(InventoryItem.ItemFlags.HighQuality) == baseItem.Hq)
|
||||
{
|
||||
MateriaStats expectedMateriaStats = baseItem.MateriaStats ?? new([]);
|
||||
MateriaStats actualMateriaStats = FetchMateriaStats(item);
|
||||
|
||||
if (expectedMateriaStats == actualMateriaStats)
|
||||
return new RecommendedItemChange(item->ItemId, inventoryType, i, targetSlot, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new RecommendedItemChange(baseItem.ItemId, null, null, targetSlot, text);
|
||||
}
|
||||
|
||||
internal unsafe Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> GetAllInventoryItems()
|
||||
{
|
||||
Dictionary<(uint, bool), List<MateriaStats>> inventoryItems = new();
|
||||
@ -403,7 +340,19 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
inventoryItems[key] = list;
|
||||
}
|
||||
|
||||
list.Add(FetchMateriaStats(item));
|
||||
// FIXME item->GetMateriaCount is broken on API 10, so this seems to be somewhat slow
|
||||
List<(MateriaStat, byte)> materias = new();
|
||||
for (int slot = 0; slot < 5; ++slot)
|
||||
{
|
||||
var materiaId = item->Materia[slot];
|
||||
if (materiaId == 0)
|
||||
break;
|
||||
|
||||
if (_gameDataHolder.Materias.TryGetValue(materiaId, out MateriaStat? value))
|
||||
materias.Add((value, item->MateriaGrades[slot]));
|
||||
}
|
||||
|
||||
list.Add(new MateriaStats(materias));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -411,23 +360,6 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
return inventoryItems;
|
||||
}
|
||||
|
||||
private unsafe MateriaStats FetchMateriaStats(InventoryItem* item)
|
||||
{
|
||||
// FIXME item->GetMateriaCount is broken on API 10, so this seems to be somewhat slow
|
||||
List<(MateriaStat, byte)> materias = new();
|
||||
for (int slot = 0; slot < 5; ++slot)
|
||||
{
|
||||
var materiaId = item->Materia[slot];
|
||||
if (materiaId == 0)
|
||||
break;
|
||||
|
||||
if (_gameDataHolder.Materias.TryGetValue(materiaId, out MateriaStat? value))
|
||||
materias.Add((value, item->MateriaGrades[slot]));
|
||||
}
|
||||
|
||||
return new MateriaStats(materias);
|
||||
}
|
||||
|
||||
internal unsafe byte GetLevel(EClassJob classJob)
|
||||
{
|
||||
var playerState = PlayerState.Instance();
|
||||
@ -446,6 +378,5 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
_pluginInterface.RemoveChatLinkHandler();
|
||||
_commandManager.RemoveHandler("/gbrowser");
|
||||
_commandManager.RemoveHandler("/gup");
|
||||
_gearsetterIpc.Dispose();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Gearsetter.GameData;
|
||||
using LLib.GameData;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Gearsetter.GameData;
|
||||
using LLib.GameData;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
@ -2,7 +2,6 @@
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||
using Gearsetter.GameData;
|
||||
using LLib.GameData;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Gearsetter.GameData;
|
||||
using LLib.GameData;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Gearsetter.GameData;
|
||||
using LLib.GameData;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
||||
@ -11,10 +10,10 @@ internal sealed class ItemList
|
||||
{
|
||||
private static readonly ReadOnlyDictionary<uint, byte> PreferredItems = new Dictionary<uint, byte>()
|
||||
{
|
||||
{ 16039, 50 },
|
||||
{ 24589, 70 },
|
||||
{ 33648, 80 },
|
||||
{ 41081, 90 },
|
||||
{ 33648, 80 },
|
||||
{ 24589, 70 },
|
||||
{ 16039, 50 }
|
||||
}.AsReadOnly();
|
||||
|
||||
public required EClassJob ClassJob { get; init; }
|
||||
@ -26,9 +25,28 @@ internal sealed class ItemList
|
||||
|
||||
public void Sort()
|
||||
{
|
||||
Items = Items
|
||||
var preferredItems = Items
|
||||
.Where(x => PreferredItems.ContainsKey(x.ItemId))
|
||||
// don't show azeyma's earring for lv90 blue mage
|
||||
.Where(x => x.ItemId != 41081 || ClassJob != EClassJob.BlueMage)
|
||||
.ToList();
|
||||
var defaultItems = Items
|
||||
.Except(preferredItems)
|
||||
.OrderDescending(new ItemComparer(SubstatPriorities))
|
||||
.ToList();
|
||||
|
||||
// insert the preferred items
|
||||
foreach (BaseItem preferredItem in preferredItems)
|
||||
{
|
||||
int level = PreferredItems[preferredItem.ItemId];
|
||||
int index = defaultItems.FindIndex(x => x.Level < level);
|
||||
if (index >= 0)
|
||||
defaultItems.Insert(index, preferredItem);
|
||||
else
|
||||
defaultItems.Add(preferredItem);
|
||||
}
|
||||
|
||||
Items = defaultItems;
|
||||
}
|
||||
|
||||
public void UpdateStats(Dictionary<EClassJob, EBaseParam> primaryStats, Configuration configuration)
|
||||
@ -104,11 +122,6 @@ internal sealed class ItemList
|
||||
if (damageA != damageB)
|
||||
return damageA.CompareTo(damageB);
|
||||
|
||||
bool hasPriorityA = TryGetPreferredItemPriority(a, b, out byte priorityA);
|
||||
bool hasPriorityB = TryGetPreferredItemPriority(b, a, out byte priorityB);
|
||||
if ((hasPriorityA || hasPriorityB) && priorityA != priorityB)
|
||||
return priorityA.CompareTo(priorityB);
|
||||
|
||||
// gear: primary stat wins
|
||||
//
|
||||
// we pretend every gear item has at least 1 primary stat to ensure weathered items are sorted last(ish),
|
||||
@ -171,33 +184,5 @@ internal sealed class ItemList
|
||||
// fallback
|
||||
return string.CompareOrdinal(a.Name, b.Name);
|
||||
}
|
||||
|
||||
public static bool TryGetPreferredItemPriority(BaseItem self, BaseItem other, out byte priority)
|
||||
{
|
||||
if (PreferredItems.TryGetValue(self.ItemId, out byte levelSelf))
|
||||
{
|
||||
// both items are preferred, sort by level only
|
||||
if (PreferredItems.TryGetValue(other.ItemId, out byte _))
|
||||
{
|
||||
priority = levelSelf;
|
||||
return true;
|
||||
}
|
||||
|
||||
// if they're the same level, place the preferrd item last
|
||||
if (levelSelf == other.Level)
|
||||
{
|
||||
priority = (byte)(levelSelf - 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
priority = levelSelf;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
priority = self.Level;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ using Gearsetter.GameData;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
||||
internal sealed class MateriaStats : IEquatable<MateriaStats>
|
||||
internal sealed class MateriaStats
|
||||
{
|
||||
private readonly List<(EBaseParam, short)> _list;
|
||||
|
||||
@ -32,33 +32,18 @@ internal sealed class MateriaStats : IEquatable<MateriaStats>
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return ReferenceEquals(this, obj) || obj is MateriaStats other && Equals(other);
|
||||
if (obj is not MateriaStats other)
|
||||
return false;
|
||||
|
||||
return _list == other._list;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _list.GetHashCode();
|
||||
}
|
||||
|
||||
public bool Equals(MateriaStats? other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
return _list.SequenceEqual(other._list);
|
||||
}
|
||||
|
||||
public static bool operator ==(MateriaStats? left, MateriaStats? right)
|
||||
{
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
public static bool operator !=(MateriaStats? left, MateriaStats? right)
|
||||
{
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Materias[{string.Join(", ", _list.Select(x => $"{x.Item1}:{x.Item2}"))}]";
|
||||
int hash = 19;
|
||||
hash = hash * 31 + Count;
|
||||
foreach (var item in _list)
|
||||
hash = hash * 31 + item.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||
|
||||
namespace Gearsetter.Model;
|
||||
|
||||
internal sealed record RecommendedItemChange(
|
||||
uint ItemId,
|
||||
InventoryType? SourceInventory,
|
||||
int? SourceInventorySlot,
|
||||
RaptureGearsetModule.GearsetItemIndex TargetSlot,
|
||||
SeString Text);
|
@ -10,7 +10,6 @@ using Dalamud.Plugin.Services;
|
||||
using Gearsetter.GameData;
|
||||
using Gearsetter.Model;
|
||||
using ImGuiNET;
|
||||
using LLib.GameData;
|
||||
using LLib.ImGui;
|
||||
|
||||
namespace Gearsetter.Windows;
|
||||
@ -137,8 +136,7 @@ internal sealed class EquipmentBrowserWindow : LWindow
|
||||
if (includeDamage)
|
||||
ImGui.TableSetupColumn("Damage", ImGuiTableColumnFlags.WidthFixed, 50);
|
||||
foreach (var substat in itemList.SubstatPriorities)
|
||||
ImGui.TableSetupColumn(_dataHolder.StatNames.GetValueOrDefault(substat, substat.ToString()),
|
||||
ImGuiTableColumnFlags.WidthFixed, 50);
|
||||
ImGui.TableSetupColumn(_dataHolder.StatNames[substat], ImGuiTableColumnFlags.WidthFixed, 50);
|
||||
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
|
2
LLib
2
LLib
@ -1 +1 @@
|
||||
Subproject commit 9db9f95b8cd3f36262b5b4b14f12b7331d3c7279
|
||||
Subproject commit 7027d291efbbff6a55944dd521d3907210ddecbe
|
Loading…
Reference in New Issue
Block a user