Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
49e16ab278 | |||
18c62ba0b7 | |||
e75e4b1248 | |||
58040f4b16 | |||
3a8f9b8f66 | |||
1845ebf701 | |||
ae706b0461 | |||
52a8ea6066 | |||
517dcd5ed5 | |||
bdffc18c39 | |||
92cf0f0ff3 | |||
6c172a84f4 | |||
c60c929502 | |||
85349573d9 | |||
74a798816c | |||
894c0d2f69 | |||
6dd5148599 | |||
21e3f7c0a9 | |||
7febb06f3e |
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "LLib"]
|
||||||
|
path = LLib
|
||||||
|
url = https://git.carvel.li/liza/LLib
|
3
Gearsetter.IpcTest/.gitignore
vendored
Normal file
3
Gearsetter.IpcTest/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/dist
|
||||||
|
/obj
|
||||||
|
/bin
|
8
Gearsetter.IpcTest/Gearsetter.IpcTest.csproj
Normal file
8
Gearsetter.IpcTest/Gearsetter.IpcTest.csproj
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<Project Sdk="Dalamud.NET.Sdk/9.0.2">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Version>1.0</Version>
|
||||||
|
<OutputPath>dist</OutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="..\LLib\LLib.targets"/>
|
||||||
|
</Project>
|
6
Gearsetter.IpcTest/Gearsetter.IpcTest.json
Normal file
6
Gearsetter.IpcTest/Gearsetter.IpcTest.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"Name": "Gearsetter (IPC Test)",
|
||||||
|
"Author": "Liza Carvelli",
|
||||||
|
"Punchline": "dev only plugin",
|
||||||
|
"Description": "dev only plugin"
|
||||||
|
}
|
47
Gearsetter.IpcTest/GearsetterIpcTestPlugin.cs
Normal file
47
Gearsetter.IpcTest/GearsetterIpcTestPlugin.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
87
Gearsetter.IpcTest/packages.lock.json
Normal file
87
Gearsetter.IpcTest/packages.lock.json
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
{
|
||||||
|
"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
Gearsetter.Test/.gitignore
vendored
Normal file
3
Gearsetter.Test/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/dist
|
||||||
|
/obj
|
||||||
|
/bin
|
26
Gearsetter.Test/Gearsetter.Test.csproj
Normal file
26
Gearsetter.Test/Gearsetter.Test.csproj
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<Project Sdk="Dalamud.NET.Sdk/9.0.2">
|
||||||
|
<PropertyGroup>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<IsTestProject>true</IsTestProject>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="..\LLib\LLib.targets"/>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
|
||||||
|
<PackageReference Include="xunit" Version="2.5.3"/>
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Need to be explicitly added for test projects, as it otherwise won't find the DLLs -->
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Dalamud"/>
|
||||||
|
<Reference Include="Lumina"/>
|
||||||
|
<Reference Include="Lumina.Excel"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Gearsetter\Gearsetter.csproj"/>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
6
Gearsetter.Test/Gearsetter.Test.json
Normal file
6
Gearsetter.Test/Gearsetter.Test.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"Name": "Gearsetter.Test",
|
||||||
|
"Author": "Liza Carvelli",
|
||||||
|
"Punchline": "",
|
||||||
|
"Description": ""
|
||||||
|
}
|
65
Gearsetter.Test/ItemSortingTest.cs
Normal file
65
Gearsetter.Test/ItemSortingTest.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Gearsetter.GameData;
|
||||||
|
using Gearsetter.Model;
|
||||||
|
using LLib.GameData;
|
||||||
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Gearsetter.Test;
|
||||||
|
|
||||||
|
public sealed class ItemSortingTest
|
||||||
|
{
|
||||||
|
Lumina.GameData _lumina = new("C:/Program Files (x86)/steam/steamapps/common/FINAL FANTASY XIV Online/game/sqpack");
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Test1()
|
||||||
|
{
|
||||||
|
var items = _lumina.GetExcelSheet<Item>()!;
|
||||||
|
List<uint> initialItemIds =
|
||||||
|
[
|
||||||
|
11851,
|
||||||
|
11853,
|
||||||
|
14447,
|
||||||
|
15131,
|
||||||
|
16039,
|
||||||
|
16240,
|
||||||
|
17436,
|
||||||
|
25928,
|
||||||
|
32558,
|
||||||
|
];
|
||||||
|
|
||||||
|
var itemList = new ItemList
|
||||||
|
{
|
||||||
|
ClassJob = EClassJob.Marauder,
|
||||||
|
EquipSlotCategory = EEquipSlotCategory.Ears,
|
||||||
|
ItemUiCategory = 41,
|
||||||
|
Items = initialItemIds.Select(rowId => new EquipmentItem(items.GetRow(rowId)!, false))
|
||||||
|
.Cast<BaseItem>()
|
||||||
|
.ToList(),
|
||||||
|
};
|
||||||
|
|
||||||
|
var primaryStats = _lumina.GetExcelSheet<ClassJob>()!
|
||||||
|
.Where(x => x.RowId > 0 && Enum.IsDefined(typeof(EClassJob), x.RowId))
|
||||||
|
.Where(x => x.PrimaryStat > 0)
|
||||||
|
.ToDictionary(x => (EClassJob)x.RowId, x => (EBaseParam)x.PrimaryStat);
|
||||||
|
|
||||||
|
itemList.UpdateStats(primaryStats, new Configuration());
|
||||||
|
itemList.Sort();
|
||||||
|
|
||||||
|
List<uint> expectedItems =
|
||||||
|
[
|
||||||
|
32558,
|
||||||
|
25928,
|
||||||
|
11851,
|
||||||
|
17436,
|
||||||
|
16240,
|
||||||
|
14447,
|
||||||
|
11853,
|
||||||
|
16039,
|
||||||
|
15131, // weathered earrings benefit from having primary stats
|
||||||
|
];
|
||||||
|
Assert.Equal(expectedItems, itemList.Items.Select(x => x.ItemId).ToList());
|
||||||
|
}
|
||||||
|
}
|
1108
Gearsetter.Test/packages.lock.json
Normal file
1108
Gearsetter.Test/packages.lock.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,12 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gearsetter", "Gearsetter\Gearsetter.csproj", "{3E87693D-1FEE-486D-80E9-C6D95E68160F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gearsetter", "Gearsetter\Gearsetter.csproj", "{3E87693D-1FEE-486D-80E9-C6D95E68160F}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gearsetter.Test", "Gearsetter.Test\Gearsetter.Test.csproj", "{19044F87-4C6D-4926-B5C8-5BB7760DC44C}"
|
||||||
|
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
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -12,5 +18,17 @@ Global
|
|||||||
{3E87693D-1FEE-486D-80E9-C6D95E68160F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{3E87693D-1FEE-486D-80E9-C6D95E68160F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{3E87693D-1FEE-486D-80E9-C6D95E68160F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{3E87693D-1FEE-486D-80E9-C6D95E68160F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{3E87693D-1FEE-486D-80E9-C6D95E68160F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{3E87693D-1FEE-486D-80E9-C6D95E68160F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{19044F87-4C6D-4926-B5C8-5BB7760DC44C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{19044F87-4C6D-4926-B5C8-5BB7760DC44C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{19044F87-4C6D-4926-B5C8-5BB7760DC44C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{19044F87-4C6D-4926-B5C8-5BB7760DC44C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{66144F9D-AC38-4F16-B269-A610F8EB7A3F}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||||
|
{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
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
3
Gearsetter/AssemblyInfo.cs
Normal file
3
Gearsetter/AssemblyInfo.cs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
[assembly: InternalsVisibleTo("Gearsetter.Test")]
|
@ -8,6 +8,7 @@ internal sealed class Configuration : IPluginConfiguration
|
|||||||
{
|
{
|
||||||
public int Version { get; set; } = 1;
|
public int Version { get; set; } = 1;
|
||||||
|
|
||||||
|
public bool ShowRecommendationsWhenEnteringGcArea { get; set; } = true;
|
||||||
public List<EBaseParam> StatPriorityTanks { get; set; } = new();
|
public List<EBaseParam> StatPriorityTanks { get; set; } = new();
|
||||||
public List<EBaseParam> StatPriorityHealer { get; set; } = new();
|
public List<EBaseParam> StatPriorityHealer { get; set; } = new();
|
||||||
public List<EBaseParam> StatPriorityMelee { get; set; } = new();
|
public List<EBaseParam> StatPriorityMelee { get; set; } = new();
|
||||||
|
64
Gearsetter/External/GearsetterIpc.cs
vendored
Normal file
64
Gearsetter/External/GearsetterIpc.cs
vendored
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
@ -1,33 +1,32 @@
|
|||||||
namespace Gearsetter.GameData
|
namespace Gearsetter.GameData;
|
||||||
|
|
||||||
|
internal enum EBaseParam : byte
|
||||||
{
|
{
|
||||||
internal enum EBaseParam : byte
|
Strength = 1,
|
||||||
{
|
Dexterity = 2,
|
||||||
Strength = 1,
|
Vitality = 3,
|
||||||
Dexterity = 2,
|
Intelligence = 4,
|
||||||
Vitality = 3,
|
Mind = 5,
|
||||||
Intelligence = 4,
|
Piety = 6,
|
||||||
Mind = 5,
|
|
||||||
Piety = 6,
|
|
||||||
|
|
||||||
GP = 10,
|
GP = 10,
|
||||||
CP = 11,
|
CP = 11,
|
||||||
|
|
||||||
DamagePhys = 12,
|
DamagePhys = 12,
|
||||||
DamageMag = 13,
|
DamageMag = 13,
|
||||||
|
|
||||||
DefensePhys = 21,
|
DefensePhys = 21,
|
||||||
DefenseMag = 24,
|
DefenseMag = 24,
|
||||||
|
|
||||||
Tenacity = 19,
|
Tenacity = 19,
|
||||||
Crit = 27,
|
Crit = 27,
|
||||||
DirectHit = 22,
|
DirectHit = 22,
|
||||||
Determination = 44,
|
Determination = 44,
|
||||||
SpellSpeed = 46,
|
SpellSpeed = 46,
|
||||||
SkillSpeed = 23,
|
SkillSpeed = 45,
|
||||||
|
|
||||||
Craftsmanship = 70,
|
Craftsmanship = 70,
|
||||||
Control = 71,
|
Control = 71,
|
||||||
Gathering = 72,
|
Gathering = 72,
|
||||||
Perception = 73,
|
Perception = 73,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,99 +0,0 @@
|
|||||||
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,
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static class EClassJobExtensions
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
@ -2,9 +2,11 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Dalamud;
|
using Dalamud;
|
||||||
|
using Dalamud.Game;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||||
using Gearsetter.Model;
|
using Gearsetter.Model;
|
||||||
|
using LLib.GameData;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
|
||||||
namespace Gearsetter.GameData;
|
namespace Gearsetter.GameData;
|
||||||
@ -63,6 +65,8 @@ internal sealed class GameDataHolder
|
|||||||
{ EClassJob.Dancer, x.DNC },
|
{ EClassJob.Dancer, x.DNC },
|
||||||
{ EClassJob.Reaper, x.RPR },
|
{ EClassJob.Reaper, x.RPR },
|
||||||
{ EClassJob.Sage, x.SGE },
|
{ EClassJob.Sage, x.SGE },
|
||||||
|
{ EClassJob.Viper, x.VPR },
|
||||||
|
{ EClassJob.Pictomancer, x.PCT }
|
||||||
}
|
}
|
||||||
.Where(y => y.Value)
|
.Where(y => y.Value)
|
||||||
.Select(y => y.Key)
|
.Select(y => y.Key)
|
||||||
@ -83,6 +87,9 @@ internal sealed class GameDataHolder
|
|||||||
.ThenBy(x => x.OrderMinor)
|
.ThenBy(x => x.OrderMinor)
|
||||||
.Select(x => (x.RowId, x.Name.ToString()))
|
.Select(x => (x.RowId, x.Name.ToString()))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
Materias = dataManager.GetExcelSheet<Materia>()!
|
||||||
|
.Where(x => x.RowId > 0 && Enum.IsDefined(typeof(EBaseParam), (byte)x.BaseParam.Row))
|
||||||
|
.ToDictionary(x => x.RowId, x => new MateriaStat((EBaseParam)x.BaseParam.Row, x.Value));
|
||||||
|
|
||||||
_allItemLists =
|
_allItemLists =
|
||||||
dataManager.GetExcelSheet<Item>()!
|
dataManager.GetExcelSheet<Item>()!
|
||||||
@ -90,8 +97,10 @@ internal sealed class GameDataHolder
|
|||||||
.Where(x => x.EquipSlotCategory.Row > 0 &&
|
.Where(x => x.EquipSlotCategory.Row > 0 &&
|
||||||
Enum.IsDefined(typeof(EEquipSlotCategory), x.EquipSlotCategory.Row))
|
Enum.IsDefined(typeof(EEquipSlotCategory), x.EquipSlotCategory.Row))
|
||||||
.Where(x => x.LevelItem.Row > 1) // ignore ilvl 1 glamour items (also includes starter weapons)
|
.Where(x => x.LevelItem.Row > 1) // ignore ilvl 1 glamour items (also includes starter weapons)
|
||||||
|
.Where(x => x.ItemSeries.Row is <= 3 or >= 28)
|
||||||
.SelectMany(LoadItem)
|
.SelectMany(LoadItem)
|
||||||
.SelectMany(x => x.ClassJobs.Select(y => x.Item with { ClassJob = y }))
|
.SelectMany(x => x.ClassJobs.Select(y => x.Item with { ClassJob = y }))
|
||||||
|
.Where(x => x.ClassJob != EClassJob.Scholar || x.ItemUiCategory != 10) // exclude ACN weapon as scholar
|
||||||
.Where(x =>
|
.Where(x =>
|
||||||
{
|
{
|
||||||
bool isGatheringItem = x.HasAnyStat(EBaseParam.Gathering, EBaseParam.Perception, EBaseParam.GP);
|
bool isGatheringItem = x.HasAnyStat(EBaseParam.Gathering, EBaseParam.Perception, EBaseParam.GP);
|
||||||
@ -99,7 +108,7 @@ internal sealed class GameDataHolder
|
|||||||
return isGatheringItem;
|
return isGatheringItem;
|
||||||
|
|
||||||
bool isCraftingItem = x.HasAnyStat(EBaseParam.Craftsmanship, EBaseParam.Control, EBaseParam.CP);
|
bool isCraftingItem = x.HasAnyStat(EBaseParam.Craftsmanship, EBaseParam.Control, EBaseParam.CP);
|
||||||
if (x.ClassJob.IsGatherer())
|
if (x.ClassJob.IsCrafter())
|
||||||
return isCraftingItem;
|
return isCraftingItem;
|
||||||
|
|
||||||
return !isGatheringItem && !isCraftingItem;
|
return !isGatheringItem && !isCraftingItem;
|
||||||
@ -113,19 +122,20 @@ internal sealed class GameDataHolder
|
|||||||
.Select(x => new ItemList
|
.Select(x => new ItemList
|
||||||
{
|
{
|
||||||
ClassJob = x.Key.ClassJob,
|
ClassJob = x.Key.ClassJob,
|
||||||
EquipSlotCategory = (EEquipSlotCategory)x.Key.EquipSlotCategory,
|
EquipSlotCategory = x.Key.EquipSlotCategory,
|
||||||
ItemUiCategory = x.Key.ItemUiCategory,
|
ItemUiCategory = x.Key.ItemUiCategory,
|
||||||
Items = x.ToList(),
|
Items = x.Cast<BaseItem>().ToList(),
|
||||||
}).ToList()
|
})
|
||||||
|
.ToList()
|
||||||
.AsReadOnly();
|
.AsReadOnly();
|
||||||
|
|
||||||
UpdateAndSortLists();
|
UpdateAndSortLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IReadOnlyList<(EClassJob ClassJob, string Name)> ClassJobNames { get; }
|
public IReadOnlyList<(EClassJob ClassJob, string Name)> ClassJobNames { get; }
|
||||||
public IReadOnlyList<(uint ItemUiCategory, string Name)> ItemUiCategoryNames { get; }
|
public IReadOnlyList<(uint ItemUiCategory, string Name)> ItemUiCategoryNames { get; }
|
||||||
public Dictionary<EClassJob, EBaseParam> PrimaryStats { get; }
|
public Dictionary<EClassJob, EBaseParam> PrimaryStats { get; }
|
||||||
|
public Dictionary<uint, MateriaStat> Materias { get; set; }
|
||||||
|
|
||||||
public Dictionary<EBaseParam, string> StatNames { get; } = new()
|
public Dictionary<EBaseParam, string> StatNames { get; } = new()
|
||||||
{
|
{
|
||||||
|
@ -1,60 +1,13 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Dalamud.NET.Sdk/9.0.2">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0-windows</TargetFramework>
|
<Version>1.3</Version>
|
||||||
<Version>0.4</Version>
|
|
||||||
<LangVersion>12</LangVersion>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
|
||||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
|
||||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
|
||||||
<OutputPath>dist</OutputPath>
|
<OutputPath>dist</OutputPath>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
|
||||||
<DebugType>portable</DebugType>
|
|
||||||
<PathMap Condition="$(SolutionDir) != ''">$(SolutionDir)=X:\</PathMap>
|
|
||||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
|
||||||
<DebugType>portable</DebugType>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<Import Project="..\LLib\LLib.targets"/>
|
||||||
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
|
<Import Project="..\LLib\RenameZip.targets"/>
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
|
|
||||||
<DalamudLibPath>$(DALAMUD_HOME)/</DalamudLibPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DalamudPackager" Version="2.1.12"/>
|
<ProjectReference Include="..\LLib\LLib.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Dalamud">
|
|
||||||
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
|
|
||||||
<Private>false</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="ImGui.NET">
|
|
||||||
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
|
|
||||||
<Private>false</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Lumina">
|
|
||||||
<HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
|
|
||||||
<Private>false</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Lumina.Excel">
|
|
||||||
<HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath>
|
|
||||||
<Private>false</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Newtonsoft.Json">
|
|
||||||
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
|
|
||||||
<Private>false</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="FFXIVClientStructs">
|
|
||||||
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
|
|
||||||
<Private>false</Private>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<Target Name="RenameLatestZip" AfterTargets="PackagePlugin" Condition="'$(Configuration)' == 'Release'">
|
|
||||||
<Exec Command="rename $(OutDir)$(AssemblyName)\latest.zip $(AssemblyName)-$(Version).zip"/>
|
|
||||||
</Target>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Threading.Tasks;
|
||||||
using Dalamud.Game.Command;
|
using Dalamud.Game.Command;
|
||||||
using Dalamud.Game.Text.SeStringHandling;
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||||
@ -12,10 +12,14 @@ using Dalamud.Plugin.Services;
|
|||||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||||
|
using Gearsetter.External;
|
||||||
using Gearsetter.GameData;
|
using Gearsetter.GameData;
|
||||||
using Gearsetter.Model;
|
using Gearsetter.Model;
|
||||||
using Gearsetter.Windows;
|
using Gearsetter.Windows;
|
||||||
|
using LLib.GameData;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
using GrandCompany = FFXIVClientStructs.FFXIV.Client.UI.Agent.GrandCompany;
|
||||||
|
using InventoryItem = FFXIVClientStructs.FFXIV.Client.Game.InventoryItem;
|
||||||
|
|
||||||
namespace Gearsetter;
|
namespace Gearsetter;
|
||||||
|
|
||||||
@ -23,20 +27,21 @@ namespace Gearsetter;
|
|||||||
public sealed class GearsetterPlugin : IDalamudPlugin
|
public sealed class GearsetterPlugin : IDalamudPlugin
|
||||||
{
|
{
|
||||||
private readonly WindowSystem _windowSystem = new(nameof(GearsetterPlugin));
|
private readonly WindowSystem _windowSystem = new(nameof(GearsetterPlugin));
|
||||||
private readonly DalamudPluginInterface _pluginInterface;
|
private readonly IDalamudPluginInterface _pluginInterface;
|
||||||
private readonly ICommandManager _commandManager;
|
private readonly ICommandManager _commandManager;
|
||||||
private readonly IChatGui _chatGui;
|
private readonly IChatGui _chatGui;
|
||||||
private readonly IDataManager _dataManager;
|
private readonly IDataManager _dataManager;
|
||||||
private readonly IPluginLog _pluginLog;
|
private readonly IPluginLog _pluginLog;
|
||||||
private readonly IClientState _clientState;
|
private readonly IClientState _clientState;
|
||||||
|
private readonly GearsetterIpc _gearsetterIpc;
|
||||||
private readonly Configuration _configuration;
|
private readonly Configuration _configuration;
|
||||||
private readonly GameDataHolder _gameDataHolder;
|
private readonly GameDataHolder _gameDataHolder;
|
||||||
private readonly EquipmentBrowserWindow _equipmentBrowserWindow;
|
private readonly EquipmentBrowserWindow _equipmentBrowserWindow;
|
||||||
|
private readonly ConfigWindow _configWindow;
|
||||||
private readonly IReadOnlyDictionary<byte, DalamudLinkPayload> _linkPayloads;
|
private readonly IReadOnlyDictionary<byte, DalamudLinkPayload> _linkPayloads;
|
||||||
private readonly Dictionary<EClassJob, byte> _classJobToArrayIndex;
|
private readonly Dictionary<EClassJob, byte> _classJobToArrayIndex;
|
||||||
|
|
||||||
public GearsetterPlugin(DalamudPluginInterface pluginInterface, ICommandManager commandManager, IChatGui chatGui,
|
public GearsetterPlugin(IDalamudPluginInterface pluginInterface, ICommandManager commandManager, IChatGui chatGui,
|
||||||
IDataManager dataManager, IPluginLog pluginLog, IClientState clientState)
|
IDataManager dataManager, IPluginLog pluginLog, IClientState clientState)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(dataManager);
|
ArgumentNullException.ThrowIfNull(dataManager);
|
||||||
@ -47,6 +52,7 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
|||||||
_dataManager = dataManager;
|
_dataManager = dataManager;
|
||||||
_pluginLog = pluginLog;
|
_pluginLog = pluginLog;
|
||||||
_clientState = clientState;
|
_clientState = clientState;
|
||||||
|
_gearsetterIpc = new GearsetterIpc(this, _pluginInterface, _pluginLog);
|
||||||
|
|
||||||
Configuration? configuration = (Configuration?)_pluginInterface.GetPluginConfig();
|
Configuration? configuration = (Configuration?)_pluginInterface.GetPluginConfig();
|
||||||
if (configuration == null)
|
if (configuration == null)
|
||||||
@ -59,6 +65,8 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
|||||||
_gameDataHolder = new GameDataHolder(dataManager, _configuration);
|
_gameDataHolder = new GameDataHolder(dataManager, _configuration);
|
||||||
_equipmentBrowserWindow = new EquipmentBrowserWindow(this, _gameDataHolder, _clientState, _chatGui);
|
_equipmentBrowserWindow = new EquipmentBrowserWindow(this, _gameDataHolder, _clientState, _chatGui);
|
||||||
_windowSystem.AddWindow(_equipmentBrowserWindow);
|
_windowSystem.AddWindow(_equipmentBrowserWindow);
|
||||||
|
_configWindow = new ConfigWindow(_pluginInterface, _configuration);
|
||||||
|
_windowSystem.AddWindow(_configWindow);
|
||||||
|
|
||||||
_commandManager.AddHandler("/gup", new CommandInfo(ShowUpgrades)
|
_commandManager.AddHandler("/gup", new CommandInfo(ShowUpgrades)
|
||||||
{
|
{
|
||||||
@ -72,90 +80,171 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
|||||||
.ToDictionary(x => (byte)x, x => _pluginInterface.AddChatLinkHandler((byte)x, ChangeGearset)).AsReadOnly();
|
.ToDictionary(x => (byte)x, x => _pluginInterface.AddChatLinkHandler((byte)x, ChangeGearset)).AsReadOnly();
|
||||||
_clientState.TerritoryChanged += TerritoryChanged;
|
_clientState.TerritoryChanged += TerritoryChanged;
|
||||||
_pluginInterface.UiBuilder.Draw += _windowSystem.Draw;
|
_pluginInterface.UiBuilder.Draw += _windowSystem.Draw;
|
||||||
|
_pluginInterface.UiBuilder.OpenMainUi += _equipmentBrowserWindow.Toggle;
|
||||||
|
_pluginInterface.UiBuilder.OpenConfigUi += _configWindow.Toggle;
|
||||||
|
|
||||||
_classJobToArrayIndex = dataManager.GetExcelSheet<ClassJob>()!
|
_classJobToArrayIndex = dataManager.GetExcelSheet<ClassJob>()!
|
||||||
.Where(x => x.RowId > 0 && Enum.IsDefined(typeof(EClassJob), x.RowId))
|
.Where(x => x.RowId > 0 && Enum.IsDefined(typeof(EClassJob), x.RowId))
|
||||||
.ToDictionary(x => (EClassJob)x.RowId, x => (byte)x.ExpArrayIndex);
|
.ToDictionary(x => (EClassJob)x.RowId, x => (byte)x.ExpArrayIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TerritoryChanged(ushort territory)
|
private unsafe void TerritoryChanged(ushort territory)
|
||||||
{
|
{
|
||||||
if (territory == 128)
|
if (!_configuration.ShowRecommendationsWhenEnteringGcArea)
|
||||||
ShowUpgrades();
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var playerState = PlayerState.Instance();
|
||||||
|
if (playerState == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var grandCompany = (GrandCompany)playerState->GrandCompany;
|
||||||
|
if ((grandCompany == GrandCompany.Maelstrom && territory == 128) ||
|
||||||
|
(grandCompany == GrandCompany.TwinAdder && territory == 132) ||
|
||||||
|
(grandCompany == GrandCompany.ImmortalFlames && territory == 130))
|
||||||
|
ShowUpgrades();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_pluginLog.Warning(e, "Could not show upgrades when entering Grand Company area.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ToggleEquipmentBrowser(string command, string arguments)
|
private void ToggleEquipmentBrowser(string command, string arguments)
|
||||||
=> _equipmentBrowserWindow.Toggle();
|
=> _equipmentBrowserWindow.Toggle();
|
||||||
|
|
||||||
private void ShowUpgrades(string command, string arguments) => ShowUpgrades();
|
private void ShowUpgrades(string command, string arguments)
|
||||||
|
|
||||||
private unsafe void ShowUpgrades()
|
|
||||||
{
|
{
|
||||||
|
byte? level = null;
|
||||||
|
if (arguments.Length > 0 && byte.TryParse(arguments, out byte parsedLevel))
|
||||||
|
level = parsedLevel;
|
||||||
|
ShowUpgrades(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void ShowUpgrades(byte? level = null)
|
||||||
|
{
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
var inventoryItems = GetAllInventoryItems();
|
var inventoryItems = GetAllInventoryItems();
|
||||||
|
|
||||||
var gearsetModule = RaptureGearsetModule.Instance();
|
var gearsetModule = RaptureGearsetModule.Instance();
|
||||||
if (gearsetModule == null)
|
if (gearsetModule == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool anyUpgrade = false;
|
bool onlyCurrentJob = level != null;
|
||||||
|
if (onlyCurrentJob)
|
||||||
|
_chatGui.Print("Checking only gearsets for your current class/job...");
|
||||||
|
|
||||||
|
List<GearsetData> gearsets = new List<GearsetData>();
|
||||||
for (int i = 0; i < 100; ++i)
|
for (int i = 0; i < 100; ++i)
|
||||||
{
|
{
|
||||||
var gearset = gearsetModule->GetGearset(i);
|
var gearset = gearsetModule->GetGearset(i);
|
||||||
if (gearset != null && gearset->Flags.HasFlag(RaptureGearsetModule.GearsetFlag.Exists))
|
if (gearset != null && gearset->Flags.HasFlag(RaptureGearsetModule.GearsetFlag.Exists))
|
||||||
{
|
{
|
||||||
anyUpgrade |= HandleGearset(gearset, inventoryItems);
|
if (onlyCurrentJob && gearset->ClassJob != _clientState.LocalPlayer!.ClassJob.Id)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var gearsetData = PrepareGearset(gearset);
|
||||||
|
if (gearsetData != null)
|
||||||
|
gearsets.Add(gearsetData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!anyUpgrade)
|
_pluginLog.Information($"Preparing gearsets took {DateTime.Now - start}");
|
||||||
_chatGui.Print("All your gearsets are OK.");
|
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
start = DateTime.Now;
|
||||||
|
bool anyUpgrade = false;
|
||||||
|
foreach (GearsetData gearset in gearsets)
|
||||||
|
anyUpgrade |= HandleGearset(gearset, inventoryItems, level);
|
||||||
|
|
||||||
|
if (!anyUpgrade)
|
||||||
|
_chatGui.Print("All your gearsets are OK.");
|
||||||
|
|
||||||
|
_pluginLog.Information($"Evaluating gearsets took {DateTime.Now - start}");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe bool HandleGearset(RaptureGearsetModule.GearsetEntry* gearset,
|
private unsafe GearsetData? PrepareGearset(RaptureGearsetModule.GearsetEntry* gearset)
|
||||||
Dictionary<(uint ItemId, bool Hq), int> inventoryItems)
|
|
||||||
{
|
{
|
||||||
string name = GetGearsetName(gearset);
|
string name = GetGearsetName(gearset);
|
||||||
if (name.Contains('_', StringComparison.Ordinal) ||
|
if (name.Contains('_', StringComparison.Ordinal) ||
|
||||||
name.Contains("Eureka", StringComparison.OrdinalIgnoreCase) ||
|
name.Contains("Eureka", StringComparison.OrdinalIgnoreCase) ||
|
||||||
name.Contains("Bozja", StringComparison.OrdinalIgnoreCase))
|
name.Contains("Bozja", StringComparison.OrdinalIgnoreCase))
|
||||||
return false;
|
return null;
|
||||||
|
|
||||||
List<List<SeString>> upgrades = new()
|
return new GearsetData(_dataManager, gearset, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal unsafe List<RecommendedItemChange> GetRecommendedUpgrades(RaptureGearsetModule.GearsetEntry* gearset,
|
||||||
|
byte? level = null)
|
||||||
|
{
|
||||||
|
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,
|
||||||
|
EEquipSlotCategory category)
|
||||||
{
|
{
|
||||||
HandleGearsetItem("Main Hand", gearset, [gearset->ItemsSpan[0]], inventoryItems, EEquipSlotCategory.None),
|
return HandleGearsetItem(label, gearset, gearsetItems, inventoryItems, category, level);
|
||||||
HandleOffHand(gearset, inventoryItems),
|
}
|
||||||
|
|
||||||
HandleGearsetItem("Head", gearset, [gearset->ItemsSpan[2]], inventoryItems, EEquipSlotCategory.Head),
|
List<List<RecommendedItemChange>> upgrades = new()
|
||||||
HandleGearsetItem("Body", gearset, [gearset->ItemsSpan[3]], inventoryItems, EEquipSlotCategory.Body),
|
{
|
||||||
HandleGearsetItem("Hands", gearset, [gearset->ItemsSpan[4]], inventoryItems, EEquipSlotCategory.Hands),
|
Handle("Main Hand", [(gearset.MainHand, RaptureGearsetModule.GearsetItemIndex.MainHand)],
|
||||||
HandleGearsetItem("Legs", gearset, [gearset->ItemsSpan[6]], inventoryItems, EEquipSlotCategory.Legs),
|
EEquipSlotCategory.None),
|
||||||
HandleGearsetItem("Feet", gearset, [gearset->ItemsSpan[7]], inventoryItems, EEquipSlotCategory.Feet),
|
HandleOffHand(gearset, inventoryItems, level),
|
||||||
|
|
||||||
HandleGearsetItem("Ears", gearset, [gearset->ItemsSpan[8]], inventoryItems, EEquipSlotCategory.Ears),
|
Handle("Head", [(gearset.Head, RaptureGearsetModule.GearsetItemIndex.Head)], EEquipSlotCategory.Head),
|
||||||
HandleGearsetItem("Neck", gearset, [gearset->ItemsSpan[9]], inventoryItems, EEquipSlotCategory.Neck),
|
Handle("Body", [(gearset.Body, RaptureGearsetModule.GearsetItemIndex.Body)], EEquipSlotCategory.Body),
|
||||||
HandleGearsetItem("Wrists", gearset, [gearset->ItemsSpan[10]], inventoryItems, EEquipSlotCategory.Wrists),
|
Handle("Hands", [(gearset.Hands, RaptureGearsetModule.GearsetItemIndex.Hands)], EEquipSlotCategory.Hands),
|
||||||
HandleGearsetItem("Rings", gearset, [gearset->ItemsSpan[11], gearset->ItemsSpan[12]], inventoryItems,
|
Handle("Legs", [(gearset.Legs, RaptureGearsetModule.GearsetItemIndex.Legs)], EEquipSlotCategory.Legs),
|
||||||
|
Handle("Feet", [(gearset.Feet, RaptureGearsetModule.GearsetItemIndex.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("Rings",
|
||||||
|
[
|
||||||
|
(gearset.RingLeft, RaptureGearsetModule.GearsetItemIndex.RingLeft),
|
||||||
|
(gearset.RingRight, RaptureGearsetModule.GearsetItemIndex.RingRight)
|
||||||
|
],
|
||||||
EEquipSlotCategory.Rings),
|
EEquipSlotCategory.Rings),
|
||||||
};
|
};
|
||||||
|
|
||||||
List<SeString> flatUpgrades = upgrades.SelectMany(x => x).ToList();
|
return upgrades.SelectMany(x => x).ToList();
|
||||||
if (flatUpgrades.Count == 0)
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_chatGui.Print(
|
_chatGui.Print(
|
||||||
new SeStringBuilder()
|
new SeStringBuilder()
|
||||||
.Append("Gearset ")
|
.Append("Gearset ")
|
||||||
.AddUiForeground(1)
|
.AddUiForeground(1)
|
||||||
.Add(_linkPayloads[gearset->ID])
|
.Add(_linkPayloads[gearset.Id])
|
||||||
.Append($"#{gearset->ID + 1}: ")
|
.Append($"#{gearset.Id + 1}: ")
|
||||||
.Append(name)
|
.Append(gearset.Name)
|
||||||
.Add(RawPayload.LinkTerminator)
|
.Add(RawPayload.LinkTerminator)
|
||||||
.AddUiForegroundOff()
|
.AddUiForegroundOff()
|
||||||
|
.AddText(level != null ? $" at {level}" : "")
|
||||||
.Build());
|
.Build());
|
||||||
|
|
||||||
foreach (var upgrade in flatUpgrades)
|
foreach (var upgrade in upgrades)
|
||||||
_chatGui.Print(new SeString(new TextPayload(" - ")).Append(upgrade));
|
_chatGui.Print(new SeString(new TextPayload(" - ")).Append(upgrade.Text));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -165,100 +254,114 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
|||||||
/// the string ends after the name (and not render ANY text on the same line after the name).
|
/// the string ends after the name (and not render ANY text on the same line after the name).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private unsafe string GetGearsetName(RaptureGearsetModule.GearsetEntry* gearset)
|
private unsafe string GetGearsetName(RaptureGearsetModule.GearsetEntry* gearset)
|
||||||
=> Encoding.UTF8.GetString(gearset->Name, 0x2F).Split((char)0)[0];
|
=> gearset->NameString.Split((char)0)[0];
|
||||||
|
|
||||||
private unsafe List<SeString> HandleGearsetItem(string label, RaptureGearsetModule.GearsetEntry* gearset,
|
private List<RecommendedItemChange> HandleGearsetItem(string label, GearsetData gearset,
|
||||||
RaptureGearsetModule.GearsetItem[] gearsetItem, Dictionary<(uint ItemId, bool Hq), int> inventoryItems,
|
(EquipmentItem? Item, RaptureGearsetModule.GearsetItemIndex Slot)[] gearsetItems,
|
||||||
EEquipSlotCategory equipSlotCategory)
|
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems,
|
||||||
|
EEquipSlotCategory equipSlotCategory, byte? level)
|
||||||
{
|
{
|
||||||
EClassJob classJob = (EClassJob)gearset->ClassJob;
|
EClassJob classJob = gearset.ClassJob;
|
||||||
|
List<RaptureGearsetModule.GearsetItemIndex> availableGearsetSlots = gearsetItems.Select(x => x.Slot).ToList();
|
||||||
var itemLists = _gameDataHolder.GetItemLists(classJob);
|
var itemLists = _gameDataHolder.GetItemLists(classJob);
|
||||||
|
|
||||||
if (gearsetItem.Any(x => x.ItemID > 0))
|
if (equipSlotCategory == EEquipSlotCategory.None && gearsetItems.Any(x => x.Item != null))
|
||||||
{
|
{
|
||||||
var firstEquippedItem = gearsetItem.First(x => x.ItemID > 0);
|
var firstEquippedItem = gearsetItems.First(x => x.Item != null);
|
||||||
equipSlotCategory = (EEquipSlotCategory)(_dataManager.GetExcelSheet<Item>()!
|
equipSlotCategory = firstEquippedItem.Item!.EquipSlotCategory;
|
||||||
.GetRow(firstEquippedItem.ItemID % 1_000_000)
|
|
||||||
?.EquipSlotCategory?.Row ?? 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (equipSlotCategory == EEquipSlotCategory.None)
|
if (equipSlotCategory == EEquipSlotCategory.None)
|
||||||
{
|
{
|
||||||
_pluginLog.Warning($"Unable to find item to determine equip slot category");
|
_pluginLog.Warning("Unable to find item to determine equip slot category");
|
||||||
return new List<SeString>();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
EquipmentItem?[] currentItems = gearsetItem.Select(x => new
|
(BaseItem? Item, RaptureGearsetModule.GearsetItemIndex Slot)[] currentItems = gearsetItems
|
||||||
{
|
|
||||||
ItemId = x.ItemID % 1_000_000,
|
|
||||||
Hq = x.ItemID > 1_000_000
|
|
||||||
})
|
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
{
|
{
|
||||||
if (x.ItemId == 0)
|
if (x.Item == null)
|
||||||
return null;
|
return (null, x.Slot);
|
||||||
|
|
||||||
return itemLists
|
var baseItem = itemLists
|
||||||
.SelectMany(y => y.Items.Where(z => x.ItemId == z.ItemId && x.Hq == z.Hq))
|
.SelectMany(y => y.Items.Where(z => x.Item.ItemId == z.ItemId && x.Item.Hq == z.Hq))
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
return (baseItem, x.Slot);
|
||||||
})
|
})
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
var availableList = _gameDataHolder.GetItemList(classJob, equipSlotCategory);
|
var availableList = _gameDataHolder.GetItemList(classJob, equipSlotCategory);
|
||||||
if (availableList == null)
|
if (availableList == null)
|
||||||
return new List<SeString>();
|
return [];
|
||||||
|
|
||||||
var level = GetLevel(classJob);
|
if (level == null)
|
||||||
var bestItems = availableList.Items
|
level = GetLevel(classJob);
|
||||||
.Where(x => x.Level <= level)
|
|
||||||
.SelectMany(x =>
|
try
|
||||||
{
|
|
||||||
if (inventoryItems.TryGetValue((x.ItemId, x.Hq), out int count) && count > 0)
|
|
||||||
return Enumerable.Repeat(x, count);
|
|
||||||
else
|
|
||||||
return [];
|
|
||||||
})
|
|
||||||
.Take(gearsetItem.Length)
|
|
||||||
.ToList();
|
|
||||||
_pluginLog.Information(
|
|
||||||
$"{equipSlotCategory}: {string.Join(" ", currentItems.Select(x => $"{x?.ItemId}|{x?.Hq}"))}");
|
|
||||||
foreach (var currentItem in currentItems)
|
|
||||||
{
|
{
|
||||||
var foundIndex = bestItems.FindIndex(x =>
|
availableList.ApplyFromInventory(inventoryItems, true);
|
||||||
currentItem != null && currentItem.ItemId == x.ItemId && currentItem.Hq == x.Hq);
|
|
||||||
if (foundIndex >= 0)
|
|
||||||
bestItems.RemoveAt(foundIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return bestItems
|
var bestItems = availableList.Items
|
||||||
.Select(x => new SeString(new TextPayload($"{label}: "))
|
.Where(x => x.Level <= level)
|
||||||
.Append(SeString.CreateItemLink(x.ItemId, x.Hq))).ToList();
|
.Where(x => x is Model.InventoryItem)
|
||||||
|
.Take(gearsetItems.Length)
|
||||||
|
.ToList();
|
||||||
|
//_pluginLog.Debug(
|
||||||
|
// $"{equipSlotCategory}: {string.Join(" ", currentItems.Select(x => $"{x.Item}, {x.Slot}"))}");
|
||||||
|
foreach (var currentItem in currentItems)
|
||||||
|
{
|
||||||
|
var foundIndex = bestItems.FindIndex(x =>
|
||||||
|
currentItem.Item != null && currentItem.Item.ItemId == x.ItemId && currentItem.Item.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();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
availableList.ClearFromInventory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<RecommendedItemChange> HandleOffHand(GearsetData gearset,
|
||||||
private unsafe List<SeString> HandleOffHand(RaptureGearsetModule.GearsetEntry* gearset,
|
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems, byte? level)
|
||||||
Dictionary<(uint ItemId, bool Hq), int> inventoryItems)
|
|
||||||
{
|
{
|
||||||
var mainHand = gearset->ItemsSpan[0];
|
var mainHand = gearset.MainHand;
|
||||||
if (mainHand.ItemID == 0)
|
if (mainHand == null)
|
||||||
return new List<SeString>();
|
return [];
|
||||||
|
|
||||||
// if it's a twohanded weapon, ignore it
|
// if it's a twohanded weapon, ignore it
|
||||||
EEquipSlotCategory equipSlotCategory =
|
EEquipSlotCategory equipSlotCategory = mainHand.EquipSlotCategory;
|
||||||
(EEquipSlotCategory)(_dataManager.GetExcelSheet<Item>()!.GetRow(mainHand.ItemID % 1_000_000)?.RowId ?? 0);
|
|
||||||
if (equipSlotCategory != EEquipSlotCategory.OneHandedMainHand)
|
if (equipSlotCategory != EEquipSlotCategory.OneHandedMainHand)
|
||||||
return new List<SeString>();
|
return [];
|
||||||
|
|
||||||
return HandleGearsetItem("Off Hand", gearset, [gearset->ItemsSpan[1]], inventoryItems,
|
return HandleGearsetItem("Off Hand", gearset,
|
||||||
EEquipSlotCategory.Shield);
|
[(gearset.OffHand, RaptureGearsetModule.GearsetItemIndex.OffHand)],
|
||||||
|
inventoryItems,
|
||||||
|
EEquipSlotCategory.Shield, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void ChangeGearset(uint commandId, SeString seString)
|
private unsafe void ChangeGearset(uint commandId, SeString seString)
|
||||||
=> RaptureGearsetModule.Instance()->EquipGearset((byte)commandId);
|
=> RaptureGearsetModule.Instance()->EquipGearset((byte)commandId);
|
||||||
|
|
||||||
public unsafe Dictionary<(uint ItemId, bool Hq), int> GetAllInventoryItems()
|
|
||||||
|
private unsafe RecommendedItemChange ToItemRecommendation(BaseItem baseItem,
|
||||||
|
RaptureGearsetModule.GearsetItemIndex targetSlot, SeString text)
|
||||||
{
|
{
|
||||||
Dictionary<(uint, bool), int> inventoryItems = new();
|
|
||||||
InventoryManager* inventoryManager = InventoryManager.Instance();
|
InventoryManager* inventoryManager = InventoryManager.Instance();
|
||||||
foreach (var inventoryType in _gameDataHolder.DefaultInventoryTypes)
|
foreach (var inventoryType in _gameDataHolder.DefaultInventoryTypes)
|
||||||
{
|
{
|
||||||
@ -266,13 +369,41 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
|||||||
for (int i = 0; i < container->Size; ++i)
|
for (int i = 0; i < container->Size; ++i)
|
||||||
{
|
{
|
||||||
var item = container->GetInventorySlot(i);
|
var item = container->GetInventorySlot(i);
|
||||||
if (item != null && item->ItemID != 0)
|
if (item != null && item->ItemId == baseItem.ItemId &&
|
||||||
|
item->Flags.HasFlag(InventoryItem.ItemFlags.HighQuality) == baseItem.Hq)
|
||||||
{
|
{
|
||||||
var key = (item->ItemID, item->Flags.HasFlag(InventoryItem.ItemFlags.HQ));
|
MateriaStats expectedMateriaStats = baseItem.MateriaStats ?? new([]);
|
||||||
if (inventoryItems.TryGetValue(key, out var value))
|
MateriaStats actualMateriaStats = FetchMateriaStats(item);
|
||||||
inventoryItems[key] = value + 1;
|
|
||||||
else
|
if (expectedMateriaStats == actualMateriaStats)
|
||||||
inventoryItems[key] = 1;
|
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();
|
||||||
|
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 != 0)
|
||||||
|
{
|
||||||
|
var key = (item->ItemId, item->Flags.HasFlag(InventoryItem.ItemFlags.HighQuality));
|
||||||
|
if (!inventoryItems.TryGetValue(key, out var list))
|
||||||
|
{
|
||||||
|
list = new List<MateriaStats>();
|
||||||
|
inventoryItems[key] = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Add(FetchMateriaStats(item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,21 +411,41 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
|||||||
return inventoryItems;
|
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)
|
internal unsafe byte GetLevel(EClassJob classJob)
|
||||||
{
|
{
|
||||||
var playerState = PlayerState.Instance();
|
var playerState = PlayerState.Instance();
|
||||||
if (playerState == null)
|
if (playerState == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (byte)playerState->ClassJobLevelArray[_classJobToArrayIndex[classJob]];
|
return (byte)playerState->ClassJobLevels[_classJobToArrayIndex[classJob]];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
_pluginInterface.UiBuilder.OpenConfigUi -= _configWindow.Toggle;
|
||||||
|
_pluginInterface.UiBuilder.OpenMainUi -= _equipmentBrowserWindow.Toggle;
|
||||||
_pluginInterface.UiBuilder.Draw -= _windowSystem.Draw;
|
_pluginInterface.UiBuilder.Draw -= _windowSystem.Draw;
|
||||||
_clientState.TerritoryChanged -= TerritoryChanged;
|
_clientState.TerritoryChanged -= TerritoryChanged;
|
||||||
_pluginInterface.RemoveChatLinkHandler();
|
_pluginInterface.RemoveChatLinkHandler();
|
||||||
_commandManager.RemoveHandler("/gbrowser");
|
_commandManager.RemoveHandler("/gbrowser");
|
||||||
_commandManager.RemoveHandler("/gup");
|
_commandManager.RemoveHandler("/gup");
|
||||||
|
_gearsetterIpc.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
60
Gearsetter/Model/BaseItem.cs
Normal file
60
Gearsetter/Model/BaseItem.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using Gearsetter.GameData;
|
||||||
|
using LLib.GameData;
|
||||||
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
|
||||||
|
namespace Gearsetter.Model;
|
||||||
|
|
||||||
|
internal abstract record BaseItem(Item Item, bool Hq, MateriaStats? MateriaStats = null)
|
||||||
|
{
|
||||||
|
public Item Item { get; } = Item;
|
||||||
|
public uint ItemId { get; } = Item.RowId;
|
||||||
|
public bool Hq { get; } = Hq;
|
||||||
|
public bool CanBeHq { get; } = Item.CanBeHq;
|
||||||
|
public string Name { get; } = Item.Name.ToString();
|
||||||
|
public byte Level { get; } = Item.LevelEquip;
|
||||||
|
public uint ItemLevel { get; } = Item.LevelItem.Row;
|
||||||
|
public byte Rarity { get; } = Item.Rarity;
|
||||||
|
public EEquipSlotCategory EquipSlotCategory { get; } = (EEquipSlotCategory)Item.EquipSlotCategory.Row;
|
||||||
|
public uint ItemUiCategory { get; } = Item.ItemUICategory.Row;
|
||||||
|
public abstract EClassJob ClassJob { get; init; }
|
||||||
|
public EquipmentStats Stats { get; } = new(Item, Hq, MateriaStats);
|
||||||
|
|
||||||
|
public int PrimaryStat { get; init; } = -1;
|
||||||
|
|
||||||
|
public int Damage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ClassJob.DealsMagicDamage())
|
||||||
|
return Item.DamageMag + Stats.Get(EBaseParam.DamageMag);
|
||||||
|
else if (ClassJob.DealsPhysicalDamage())
|
||||||
|
return Item.DamagePhys + Stats.Get(EBaseParam.DamagePhys);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasAnyStat(params EBaseParam[] substats)
|
||||||
|
{
|
||||||
|
foreach (EBaseParam substat in substats)
|
||||||
|
{
|
||||||
|
if (Stats.Get(substat) > 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsCombatRelicWithoutSubstats()
|
||||||
|
{
|
||||||
|
return Rarity == 4
|
||||||
|
&& EquipSlotCategory is EEquipSlotCategory.OneHandedMainHand
|
||||||
|
or EEquipSlotCategory.TwoHandedMainHand
|
||||||
|
or EEquipSlotCategory.Shield
|
||||||
|
&& !ClassJob.IsCrafter()
|
||||||
|
&& !ClassJob.IsGatherer()
|
||||||
|
&& !HasAnyStat(EBaseParam.Crit,
|
||||||
|
EBaseParam.DirectHit, EBaseParam.Determination, EBaseParam.SkillSpeed,
|
||||||
|
EBaseParam.SpellSpeed, EBaseParam.Tenacity);
|
||||||
|
}
|
||||||
|
}
|
@ -1,50 +1,10 @@
|
|||||||
using Gearsetter.GameData;
|
using Gearsetter.GameData;
|
||||||
|
using LLib.GameData;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
|
||||||
namespace Gearsetter.Model;
|
namespace Gearsetter.Model;
|
||||||
|
|
||||||
internal sealed record EquipmentItem(Item Item, bool Hq)
|
internal sealed record EquipmentItem(Item Item, bool Hq) : BaseItem(Item, Hq)
|
||||||
{
|
{
|
||||||
public Item Item { get; } = Item;
|
public override EClassJob ClassJob { get; init; } = EClassJob.Adventurer;
|
||||||
public uint ItemId { get; } = Item.RowId;
|
|
||||||
public bool Hq { get; } = Hq;
|
|
||||||
public bool CanBeHq { get; } = Item.CanBeHq;
|
|
||||||
public string Name { get; } = Item.Name.ToString();
|
|
||||||
public byte Level { get; } = Item.LevelEquip;
|
|
||||||
public uint ItemLevel { get; } = Item.LevelItem.Row;
|
|
||||||
public byte Rarity { get; } = Item.Rarity;
|
|
||||||
public EEquipSlotCategory EquipSlotCategory { get; } = (EEquipSlotCategory)Item.EquipSlotCategory.Row;
|
|
||||||
public uint ItemUiCategory { get; } = Item.ItemUICategory.Row;
|
|
||||||
public EClassJob ClassJob { get; init; } = EClassJob.Adventurer;
|
|
||||||
public EquipmentStats Stats { get; } = new(Item, Hq);
|
|
||||||
|
|
||||||
public int PrimaryStat { get; init; } = -1;
|
|
||||||
|
|
||||||
public int Damage => ClassJob.DealsMagicDamage()
|
|
||||||
? Item.DamageMag + Stats.Get(EBaseParam.DamageMag)
|
|
||||||
: Item.DamagePhys + Stats.Get(EBaseParam.DamagePhys);
|
|
||||||
|
|
||||||
public bool HasAnyStat(params EBaseParam[] substats)
|
|
||||||
{
|
|
||||||
foreach (EBaseParam substat in substats)
|
|
||||||
{
|
|
||||||
if (Stats.Get(substat) > 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsCombatRelicWithoutSubstats()
|
|
||||||
{
|
|
||||||
return Rarity == 4
|
|
||||||
&& EquipSlotCategory is EEquipSlotCategory.OneHandedMainHand
|
|
||||||
or EEquipSlotCategory.TwoHandedMainHand
|
|
||||||
or EEquipSlotCategory.Shield
|
|
||||||
&& !ClassJob.IsCrafter()
|
|
||||||
&& !ClassJob.IsGatherer()
|
|
||||||
&& !HasAnyStat(EBaseParam.Crit,
|
|
||||||
EBaseParam.DirectHit, EBaseParam.Determination, EBaseParam.SkillSpeed,
|
|
||||||
EBaseParam.SpellSpeed, EBaseParam.Tenacity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,33 +3,56 @@ using System.Linq;
|
|||||||
using Gearsetter.GameData;
|
using Gearsetter.GameData;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
|
||||||
namespace Gearsetter.Model
|
namespace Gearsetter.Model;
|
||||||
{
|
|
||||||
internal sealed class EquipmentStats
|
|
||||||
{
|
|
||||||
private readonly Dictionary<EBaseParam, short> _values;
|
|
||||||
|
|
||||||
public EquipmentStats(Item item, bool hq)
|
internal sealed class EquipmentStats
|
||||||
|
{
|
||||||
|
private readonly Dictionary<EBaseParam, short> _equipmentValues;
|
||||||
|
private readonly Dictionary<EBaseParam, short> _materiaValues;
|
||||||
|
|
||||||
|
public EquipmentStats(Item item, bool hq, MateriaStats? materiaStats)
|
||||||
|
{
|
||||||
|
_equipmentValues = item.UnkData59.Where(x => x.BaseParam > 0)
|
||||||
|
.ToDictionary(x => (EBaseParam)x.BaseParam, x => x.BaseParamValue);
|
||||||
|
if (hq)
|
||||||
{
|
{
|
||||||
_values = item.UnkData59.Where(x => x.BaseParam > 0)
|
foreach (var hqstat in item.UnkData73.Select(x =>
|
||||||
.ToDictionary(x => (EBaseParam)x.BaseParam, x => x.BaseParamValue);
|
((EBaseParam)x.BaseParamSpecial, x.BaseParamValueSpecial)))
|
||||||
if (hq)
|
|
||||||
{
|
{
|
||||||
foreach (var hqstat in item.UnkData73.Select(x =>
|
if (_equipmentValues.TryGetValue(hqstat.Item1, out var stat))
|
||||||
((EBaseParam)x.BaseParamSpecial, x.BaseParamValueSpecial)))
|
_equipmentValues[hqstat.Item1] = (short)(stat + hqstat.BaseParamValueSpecial);
|
||||||
{
|
else
|
||||||
if (_values.TryGetValue(hqstat.Item1, out var stat))
|
_equipmentValues[hqstat.Item1] = hqstat.BaseParamValueSpecial;
|
||||||
_values[hqstat.Item1] = (short)(stat + hqstat.BaseParamValueSpecial);
|
|
||||||
else
|
|
||||||
_values[hqstat.Item1] = hqstat.BaseParamValueSpecial;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public short Get(EBaseParam param)
|
_materiaValues = new();
|
||||||
|
if (materiaStats != null)
|
||||||
{
|
{
|
||||||
_values.TryGetValue(param, out short v);
|
foreach (var materiaStat in materiaStats.Values)
|
||||||
return v;
|
{
|
||||||
|
if (_materiaValues.TryGetValue(materiaStat.Key, out var stat))
|
||||||
|
_materiaValues[materiaStat.Key] = (short)(stat + materiaStat.Value);
|
||||||
|
else
|
||||||
|
_materiaValues[materiaStat.Key] = materiaStat.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public short Get(EBaseParam param)
|
||||||
|
{
|
||||||
|
return (short)(GetEquipment(param) + GetMateria(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
public short GetEquipment(EBaseParam param)
|
||||||
|
{
|
||||||
|
_equipmentValues.TryGetValue(param, out short v);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short GetMateria(EBaseParam param)
|
||||||
|
{
|
||||||
|
_materiaValues.TryGetValue(param, out short v);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
57
Gearsetter/Model/GearsetData.cs
Normal file
57
Gearsetter/Model/GearsetData.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||||
|
using Gearsetter.GameData;
|
||||||
|
using LLib.GameData;
|
||||||
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
|
||||||
|
namespace Gearsetter.Model;
|
||||||
|
|
||||||
|
internal sealed class GearsetData
|
||||||
|
{
|
||||||
|
public unsafe GearsetData(IDataManager dataManager, RaptureGearsetModule.GearsetEntry* gearset, string name)
|
||||||
|
{
|
||||||
|
Id = gearset->Id;
|
||||||
|
ClassJob = (EClassJob)gearset->ClassJob;
|
||||||
|
Name = name;
|
||||||
|
MainHand = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.MainHand);
|
||||||
|
OffHand = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.OffHand);
|
||||||
|
Head = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Head);
|
||||||
|
Body = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Body);
|
||||||
|
Hands = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Hands);
|
||||||
|
Legs = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Legs);
|
||||||
|
Feet = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Feet);
|
||||||
|
Ears = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Ears);
|
||||||
|
Neck = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Neck);
|
||||||
|
Wrists = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Wrists);
|
||||||
|
RingLeft = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.RingLeft);
|
||||||
|
RingRight = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.RingRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static unsafe EquipmentItem? GetItem(IDataManager dataManager, RaptureGearsetModule.GearsetEntry* gearset,
|
||||||
|
RaptureGearsetModule.GearsetItemIndex index)
|
||||||
|
{
|
||||||
|
var gearsetItem = gearset->GetItem(index);
|
||||||
|
if (gearsetItem.ItemId == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var item = dataManager.GetExcelSheet<Item>()!.GetRow(gearsetItem.ItemId % 1_000_000)!;
|
||||||
|
return new EquipmentItem(item, gearsetItem.ItemId > 1_000_000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte Id { get; }
|
||||||
|
public EClassJob ClassJob { get; }
|
||||||
|
public string Name { get; }
|
||||||
|
public EquipmentItem? MainHand { get; }
|
||||||
|
public EquipmentItem? OffHand { get; }
|
||||||
|
public EquipmentItem? Head { get; }
|
||||||
|
public EquipmentItem? Body { get; }
|
||||||
|
public EquipmentItem? Hands { get; }
|
||||||
|
public EquipmentItem? Legs { get; }
|
||||||
|
public EquipmentItem? Feet { get; }
|
||||||
|
public EquipmentItem? Ears { get; set; }
|
||||||
|
public EquipmentItem? Neck { get; set; }
|
||||||
|
public EquipmentItem? Wrists { get; }
|
||||||
|
public EquipmentItem? RingLeft { get; }
|
||||||
|
public EquipmentItem? RingRight { get; }
|
||||||
|
}
|
10
Gearsetter/Model/InventoryItem.cs
Normal file
10
Gearsetter/Model/InventoryItem.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using Gearsetter.GameData;
|
||||||
|
using LLib.GameData;
|
||||||
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
|
||||||
|
namespace Gearsetter.Model;
|
||||||
|
|
||||||
|
internal sealed record InventoryItem(Item Item, bool Hq, MateriaStats MateriaStats, EClassJob ClassJob)
|
||||||
|
: BaseItem(Item, Hq, MateriaStats)
|
||||||
|
{
|
||||||
|
}
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Gearsetter.GameData;
|
using Gearsetter.GameData;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using LLib.GameData;
|
||||||
|
|
||||||
namespace Gearsetter.Model;
|
namespace Gearsetter.Model;
|
||||||
|
|
||||||
@ -11,102 +11,24 @@ internal sealed class ItemList
|
|||||||
{
|
{
|
||||||
private static readonly ReadOnlyDictionary<uint, byte> PreferredItems = new Dictionary<uint, byte>()
|
private static readonly ReadOnlyDictionary<uint, byte> PreferredItems = new Dictionary<uint, byte>()
|
||||||
{
|
{
|
||||||
{ 41081, 90 },
|
{ 16039, 50 },
|
||||||
{ 33648, 80 },
|
|
||||||
{ 24589, 70 },
|
{ 24589, 70 },
|
||||||
{ 16039, 50 }
|
{ 33648, 80 },
|
||||||
|
{ 41081, 90 },
|
||||||
}.AsReadOnly();
|
}.AsReadOnly();
|
||||||
|
|
||||||
public required EClassJob ClassJob { get; init; }
|
public required EClassJob ClassJob { get; init; }
|
||||||
public required EEquipSlotCategory EquipSlotCategory { get; init; }
|
public required EEquipSlotCategory EquipSlotCategory { get; init; }
|
||||||
public required uint ItemUiCategory { get; init; }
|
public required uint ItemUiCategory { get; init; }
|
||||||
public required List<EquipmentItem> Items { get; set; }
|
public required List<BaseItem> Items { get; set; }
|
||||||
|
public EBaseParam PrimaryStat { get; set; }
|
||||||
public IReadOnlyList<EBaseParam> SubstatPriorities { get; set; } = new List<EBaseParam>();
|
public IReadOnlyList<EBaseParam> SubstatPriorities { get; set; } = new List<EBaseParam>();
|
||||||
|
|
||||||
public void Sort()
|
public void Sort()
|
||||||
{
|
{
|
||||||
Items.Sort((a, b) => -Sort(a, b));
|
Items = Items
|
||||||
}
|
.OrderDescending(new ItemComparer(SubstatPriorities))
|
||||||
|
.ToList();
|
||||||
private int Sort(EquipmentItem a, EquipmentItem b)
|
|
||||||
{
|
|
||||||
// special items
|
|
||||||
if (PreferredItems.ContainsKey(a.ItemId) || PreferredItems.ContainsKey(b.ItemId))
|
|
||||||
{
|
|
||||||
byte? levelA = null;
|
|
||||||
byte? levelB = null;
|
|
||||||
if (PreferredItems.TryGetValue(a.ItemId, out byte overrideA))
|
|
||||||
levelA = overrideA;
|
|
||||||
if (PreferredItems.TryGetValue(b.ItemId, out byte overrideB))
|
|
||||||
levelB = overrideB;
|
|
||||||
|
|
||||||
if (levelA != null && levelB != null)
|
|
||||||
return levelA.Value.CompareTo(levelB.Value);
|
|
||||||
else if (levelA != null)
|
|
||||||
{
|
|
||||||
if (levelA == b.Level)
|
|
||||||
return (a.ItemLevel - 1).CompareTo(b.ItemLevel);
|
|
||||||
return levelA.Value.CompareTo(b.Level);
|
|
||||||
}
|
|
||||||
else if (levelB != null)
|
|
||||||
{
|
|
||||||
if (a.Level == levelB)
|
|
||||||
return a.ItemLevel.CompareTo(b.ItemLevel - 1);
|
|
||||||
return a.Level.CompareTo(levelB.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// weapons: most damage wins
|
|
||||||
int damageA = a.Damage;
|
|
||||||
int damageB = b.Damage;
|
|
||||||
if (damageA != damageB)
|
|
||||||
return damageA.CompareTo(damageB);
|
|
||||||
|
|
||||||
// gear: primary stat wins
|
|
||||||
int primaryStatA = a.PrimaryStat;
|
|
||||||
int primaryStatB = b.PrimaryStat;
|
|
||||||
if (primaryStatA != primaryStatB)
|
|
||||||
return primaryStatA.CompareTo(primaryStatB);
|
|
||||||
|
|
||||||
// gear: vitality wins
|
|
||||||
int vitalityA = a.Stats.Get(EBaseParam.Vitality);
|
|
||||||
int vitalityB = b.Stats.Get(EBaseParam.Vitality);
|
|
||||||
if (vitalityA != vitalityB)
|
|
||||||
return vitalityA.CompareTo(vitalityB);
|
|
||||||
|
|
||||||
// sum of relevant substats
|
|
||||||
int sumOfSubstatsA = SubstatPriorities.Sum(x => a.Stats.Get(x));
|
|
||||||
int sumOfSubstatsB = SubstatPriorities.Sum(x => b.Stats.Get(x));
|
|
||||||
|
|
||||||
// some relics have no substats in the sheets, since they can be allocated dynamically
|
|
||||||
// they are -generally- better/equal to any other weapon on that ilvl
|
|
||||||
if (sumOfSubstatsA == 0 && a.IsCombatRelicWithoutSubstats())
|
|
||||||
sumOfSubstatsA = int.MaxValue;
|
|
||||||
if (sumOfSubstatsB == 0 && b.IsCombatRelicWithoutSubstats())
|
|
||||||
sumOfSubstatsB = int.MaxValue;
|
|
||||||
|
|
||||||
if (sumOfSubstatsA != sumOfSubstatsB)
|
|
||||||
return sumOfSubstatsA.CompareTo(sumOfSubstatsB);
|
|
||||||
|
|
||||||
// level-based sorting
|
|
||||||
if (a.Level != b.Level)
|
|
||||||
return a.Level.CompareTo(b.Level);
|
|
||||||
if (a.ItemLevel != b.ItemLevel)
|
|
||||||
return a.ItemLevel.CompareTo(b.ItemLevel);
|
|
||||||
if (a.Rarity != b.Rarity)
|
|
||||||
return a.Rarity.CompareTo(b.Rarity);
|
|
||||||
|
|
||||||
// individual substats
|
|
||||||
foreach (EBaseParam substat in SubstatPriorities)
|
|
||||||
{
|
|
||||||
int substatA = a.Stats.Get(substat);
|
|
||||||
int substatB = b.Stats.Get(substat);
|
|
||||||
if (substatA != substatB)
|
|
||||||
return substatA.CompareTo(substatB);
|
|
||||||
}
|
|
||||||
|
|
||||||
// fallback
|
|
||||||
return string.CompareOrdinal(a.Name, b.Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateStats(Dictionary<EClassJob, EBaseParam> primaryStats, Configuration configuration)
|
public void UpdateStats(Dictionary<EClassJob, EBaseParam> primaryStats, Configuration configuration)
|
||||||
@ -130,9 +52,152 @@ internal sealed class ItemList
|
|||||||
|
|
||||||
if (primaryStats.TryGetValue(ClassJob, out EBaseParam primaryStat))
|
if (primaryStats.TryGetValue(ClassJob, out EBaseParam primaryStat))
|
||||||
{
|
{
|
||||||
|
PrimaryStat = primaryStat;
|
||||||
Items = Items
|
Items = Items
|
||||||
|
.Where(x => x is EquipmentItem)
|
||||||
|
.Cast<EquipmentItem>()
|
||||||
.Select(x => x with { PrimaryStat = x.Stats.Get(primaryStat) })
|
.Select(x => x with { PrimaryStat = x.Stats.Get(primaryStat) })
|
||||||
|
.Cast<BaseItem>()
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ApplyFromInventory(Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems,
|
||||||
|
bool includeWithoutMateria)
|
||||||
|
{
|
||||||
|
foreach (var inventoryItem in inventoryItems)
|
||||||
|
{
|
||||||
|
var basicItem = Items.SingleOrDefault(x =>
|
||||||
|
x.ItemId == inventoryItem.Key.ItemId && x.Hq == inventoryItem.Key.Hq);
|
||||||
|
if (basicItem == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (var materias in inventoryItem.Value)
|
||||||
|
{
|
||||||
|
if (includeWithoutMateria || materias.Values.Count > 0)
|
||||||
|
Items.Add(
|
||||||
|
new InventoryItem(basicItem.Item, basicItem.Hq, materias, basicItem.ClassJob)
|
||||||
|
{
|
||||||
|
PrimaryStat = basicItem.Stats.Get(PrimaryStat)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Sort();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClearFromInventory()
|
||||||
|
{
|
||||||
|
Items.RemoveAll(x => x is InventoryItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class ItemComparer(IReadOnlyList<EBaseParam> substatPriorities) : IComparer<BaseItem>
|
||||||
|
{
|
||||||
|
public int Compare(BaseItem? a, BaseItem? b)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(a);
|
||||||
|
ArgumentNullException.ThrowIfNull(b);
|
||||||
|
|
||||||
|
// weapons: most damage wins
|
||||||
|
int damageA = a.Damage;
|
||||||
|
int damageB = b.Damage;
|
||||||
|
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),
|
||||||
|
// where they would otherwise get sorted as better-than-shire items (while that may be correct, it's also
|
||||||
|
// stupid)
|
||||||
|
int primaryStatA = Math.Max(1, a.PrimaryStat);
|
||||||
|
int primaryStatB = Math.Max(1, b.PrimaryStat);
|
||||||
|
if (primaryStatA != primaryStatB)
|
||||||
|
return primaryStatA.CompareTo(primaryStatB);
|
||||||
|
|
||||||
|
// gear: vitality wins
|
||||||
|
int vitalityA = a.Stats.Get(EBaseParam.Vitality);
|
||||||
|
int vitalityB = b.Stats.Get(EBaseParam.Vitality);
|
||||||
|
if (vitalityA != vitalityB)
|
||||||
|
return vitalityA.CompareTo(vitalityB);
|
||||||
|
|
||||||
|
// sum of relevant substats
|
||||||
|
int sumOfSubstatsA = substatPriorities.Sum(x => a.Stats.Get(x));
|
||||||
|
int sumOfSubstatsB = substatPriorities.Sum(x => b.Stats.Get(x));
|
||||||
|
|
||||||
|
// some relics have no substats in the sheets, since they can be allocated dynamically
|
||||||
|
// they are -generally- better/equal to any other weapon on that ilvl
|
||||||
|
if (sumOfSubstatsA == 0 && a.IsCombatRelicWithoutSubstats())
|
||||||
|
sumOfSubstatsA = int.MaxValue;
|
||||||
|
if (sumOfSubstatsB == 0 && b.IsCombatRelicWithoutSubstats())
|
||||||
|
sumOfSubstatsB = int.MaxValue;
|
||||||
|
|
||||||
|
if (sumOfSubstatsA != sumOfSubstatsB)
|
||||||
|
return sumOfSubstatsA.CompareTo(sumOfSubstatsB);
|
||||||
|
|
||||||
|
// level-based sorting
|
||||||
|
if (a.Level != b.Level)
|
||||||
|
return a.Level.CompareTo(b.Level);
|
||||||
|
if (a.ItemLevel != b.ItemLevel)
|
||||||
|
return a.ItemLevel.CompareTo(b.ItemLevel);
|
||||||
|
if (a.Rarity != b.Rarity)
|
||||||
|
{
|
||||||
|
// aetherial items aren't "special" enough to be sorted higher than normal gear
|
||||||
|
int rarityA = a.Rarity;
|
||||||
|
int rarityB = b.Rarity;
|
||||||
|
|
||||||
|
if (rarityA == 7)
|
||||||
|
rarityA = 1;
|
||||||
|
|
||||||
|
if (rarityB == 7)
|
||||||
|
rarityB = 1;
|
||||||
|
|
||||||
|
return rarityA.CompareTo(rarityB);
|
||||||
|
}
|
||||||
|
|
||||||
|
// individual substats
|
||||||
|
foreach (EBaseParam substat in substatPriorities)
|
||||||
|
{
|
||||||
|
int substatA = a.Stats.Get(substat);
|
||||||
|
int substatB = b.Stats.Get(substat);
|
||||||
|
if (substatA != substatB)
|
||||||
|
return substatA.CompareTo(substatB);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
11
Gearsetter/Model/MateriaStat.cs
Normal file
11
Gearsetter/Model/MateriaStat.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Gearsetter.GameData;
|
||||||
|
|
||||||
|
namespace Gearsetter.Model;
|
||||||
|
|
||||||
|
internal sealed class MateriaStat(EBaseParam baseParam, short[] values)
|
||||||
|
{
|
||||||
|
public EBaseParam BaseParam { get; } = baseParam;
|
||||||
|
public List<short> Values { get; } = values.ToList();
|
||||||
|
}
|
64
Gearsetter/Model/MateriaStats.cs
Normal file
64
Gearsetter/Model/MateriaStats.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Gearsetter.GameData;
|
||||||
|
|
||||||
|
namespace Gearsetter.Model;
|
||||||
|
|
||||||
|
internal sealed class MateriaStats : IEquatable<MateriaStats>
|
||||||
|
{
|
||||||
|
private readonly List<(EBaseParam, short)> _list;
|
||||||
|
|
||||||
|
public MateriaStats(IEnumerable<(MateriaStat Stat, byte Grade)> materias)
|
||||||
|
{
|
||||||
|
foreach (var materia in materias)
|
||||||
|
{
|
||||||
|
if (Values.TryGetValue(materia.Stat.BaseParam, out short value))
|
||||||
|
Values[materia.Stat.BaseParam] = (short)(value + materia.Stat.Values[materia.Grade]);
|
||||||
|
else
|
||||||
|
Values[materia.Stat.BaseParam] = materia.Stat.Values[materia.Grade];
|
||||||
|
|
||||||
|
++Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
_list = Enum.GetValues<EBaseParam>()
|
||||||
|
.Select(x => (x, Values.GetValueOrDefault(x, (short)0)))
|
||||||
|
.Where(x => x.Item2 > 0)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<EBaseParam, short> Values { get; } = new();
|
||||||
|
public byte Count { get; }
|
||||||
|
|
||||||
|
public override bool Equals(object? obj)
|
||||||
|
{
|
||||||
|
return ReferenceEquals(this, obj) || obj is MateriaStats other && Equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
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}"))}]";
|
||||||
|
}
|
||||||
|
}
|
12
Gearsetter/Model/RecommendedItemChange.cs
Normal file
12
Gearsetter/Model/RecommendedItemChange.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
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);
|
29
Gearsetter/Windows/ConfigWindow.cs
Normal file
29
Gearsetter/Windows/ConfigWindow.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using Dalamud.Plugin;
|
||||||
|
using ImGuiNET;
|
||||||
|
using LLib.ImGui;
|
||||||
|
|
||||||
|
namespace Gearsetter.Windows;
|
||||||
|
|
||||||
|
internal sealed class ConfigWindow : LWindow
|
||||||
|
{
|
||||||
|
private readonly IDalamudPluginInterface _pluginInterface;
|
||||||
|
private readonly Configuration _configuration;
|
||||||
|
|
||||||
|
public ConfigWindow(IDalamudPluginInterface pluginInterface, Configuration configuration)
|
||||||
|
: base("Gearsetter - Config###GearsetterConfig", ImGuiWindowFlags.AlwaysAutoResize)
|
||||||
|
{
|
||||||
|
_pluginInterface = pluginInterface;
|
||||||
|
_configuration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Draw()
|
||||||
|
{
|
||||||
|
bool showRecommendationsWhenEnteringGcArea = _configuration.ShowRecommendationsWhenEnteringGcArea;
|
||||||
|
if (ImGui.Checkbox("Show recommendations when entering Grand Company area",
|
||||||
|
ref showRecommendationsWhenEnteringGcArea))
|
||||||
|
{
|
||||||
|
_configuration.ShowRecommendationsWhenEnteringGcArea = showRecommendationsWhenEnteringGcArea;
|
||||||
|
_pluginInterface.SavePluginConfig(_configuration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,14 +6,16 @@ using System.Numerics;
|
|||||||
using Dalamud.Game.Text;
|
using Dalamud.Game.Text;
|
||||||
using Dalamud.Game.Text.SeStringHandling;
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Interface.Colors;
|
using Dalamud.Interface.Colors;
|
||||||
using Dalamud.Interface.Windowing;
|
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using Gearsetter.GameData;
|
using Gearsetter.GameData;
|
||||||
|
using Gearsetter.Model;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
using LLib.GameData;
|
||||||
|
using LLib.ImGui;
|
||||||
|
|
||||||
namespace Gearsetter.Windows;
|
namespace Gearsetter.Windows;
|
||||||
|
|
||||||
internal sealed class EquipmentBrowserWindow : Window
|
internal sealed class EquipmentBrowserWindow : LWindow
|
||||||
{
|
{
|
||||||
private readonly GearsetterPlugin _plugin;
|
private readonly GearsetterPlugin _plugin;
|
||||||
private readonly GameDataHolder _dataHolder;
|
private readonly GameDataHolder _dataHolder;
|
||||||
@ -33,16 +35,24 @@ internal sealed class EquipmentBrowserWindow : Window
|
|||||||
|
|
||||||
public EquipmentBrowserWindow(GearsetterPlugin plugin, GameDataHolder dataHolder, IClientState clientState,
|
public EquipmentBrowserWindow(GearsetterPlugin plugin, GameDataHolder dataHolder, IClientState clientState,
|
||||||
IChatGui chatGui)
|
IChatGui chatGui)
|
||||||
: base("Equipment Browser")
|
: base("Equipment Browser###GearsetterBrowser")
|
||||||
{
|
{
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
_dataHolder = dataHolder;
|
_dataHolder = dataHolder;
|
||||||
_clientState = clientState;
|
_clientState = clientState;
|
||||||
_chatGui = chatGui;
|
_chatGui = chatGui;
|
||||||
_classJobNames = dataHolder.ClassJobNames.Select(x => x.Name).ToArray();
|
_classJobNames = dataHolder.ClassJobNames
|
||||||
_classJobIds = dataHolder.ClassJobNames.Select(x => x.ClassJob).ToArray();
|
.Where(x => x.ClassJob.AsJob() == x.ClassJob)
|
||||||
|
.Select(x => x.Name)
|
||||||
|
.ToArray();
|
||||||
|
_classJobIds = dataHolder.ClassJobNames
|
||||||
|
.Where(x => x.ClassJob.AsJob() == x.ClassJob)
|
||||||
|
.Select(x => x.ClassJob)
|
||||||
|
.ToArray();
|
||||||
UpdateEquipmentCategories();
|
UpdateEquipmentCategories();
|
||||||
|
|
||||||
|
Size = new Vector2(800, 500);
|
||||||
|
SizeCondition = ImGuiCond.FirstUseEver;
|
||||||
SizeConstraints = new WindowSizeConstraints
|
SizeConstraints = new WindowSizeConstraints
|
||||||
{
|
{
|
||||||
MinimumSize = new Vector2(800, 500)
|
MinimumSize = new Vector2(800, 500)
|
||||||
@ -52,7 +62,7 @@ internal sealed class EquipmentBrowserWindow : Window
|
|||||||
public override void OnOpen()
|
public override void OnOpen()
|
||||||
{
|
{
|
||||||
if (_clientState.LocalPlayer != null)
|
if (_clientState.LocalPlayer != null)
|
||||||
_selectedClassJob = (EClassJob)_clientState.LocalPlayer.ClassJob.Id;
|
_selectedClassJob = ((EClassJob)_clientState.LocalPlayer.ClassJob.Id).AsJob();
|
||||||
|
|
||||||
UpdateEquipmentCategories();
|
UpdateEquipmentCategories();
|
||||||
}
|
}
|
||||||
@ -62,7 +72,7 @@ internal sealed class EquipmentBrowserWindow : Window
|
|||||||
return _clientState.IsLoggedIn;
|
return _clientState.IsLoggedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw()
|
public override unsafe void Draw()
|
||||||
{
|
{
|
||||||
int currentClassJob = Array.IndexOf(_classJobIds, _selectedClassJob);
|
int currentClassJob = Array.IndexOf(_classJobIds, _selectedClassJob);
|
||||||
if (currentClassJob == -1)
|
if (currentClassJob == -1)
|
||||||
@ -101,101 +111,128 @@ internal sealed class EquipmentBrowserWindow : Window
|
|||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
ImGui.Checkbox("Hide normal quality items", ref _hideNormalQualityItems);
|
ImGui.Checkbox("Hide normal quality items", ref _hideNormalQualityItems);
|
||||||
|
|
||||||
Dictionary<(uint, bool), int>? ownedItems = null;
|
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> ownedItems = _plugin.GetAllInventoryItems();
|
||||||
if (_onlyShowOwnedItems)
|
try
|
||||||
ownedItems = _plugin.GetAllInventoryItems();
|
|
||||||
|
|
||||||
byte maxLevel = byte.MaxValue;
|
|
||||||
if (_onlyShowEquippableItems)
|
|
||||||
maxLevel = _plugin.GetLevel(_selectedClassJob);
|
|
||||||
|
|
||||||
bool includeDamage = _selectedEquipmentCategory is EEquipSlotCategory.OneHandedMainHand
|
|
||||||
or EEquipSlotCategory.Shield
|
|
||||||
or EEquipSlotCategory.TwoHandedMainHand
|
|
||||||
&& !itemList.ClassJob.IsCrafter()
|
|
||||||
&& !itemList.ClassJob.IsGatherer();
|
|
||||||
if (ImGui.BeginTable("ItemList", 2 + (includeDamage ? 1 : 0) + itemList.SubstatPriorities.Count,
|
|
||||||
ImGuiTableFlags.Borders | ImGuiTableFlags.Resizable))
|
|
||||||
{
|
{
|
||||||
ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.None, 300);
|
itemList.ApplyFromInventory(ownedItems, _onlyShowOwnedItems);
|
||||||
ImGui.TableSetupColumn("Level", ImGuiTableColumnFlags.WidthFixed, 50);
|
|
||||||
if (includeDamage)
|
|
||||||
ImGui.TableSetupColumn("Damage", ImGuiTableColumnFlags.WidthFixed, 50);
|
|
||||||
foreach (var substat in itemList.SubstatPriorities)
|
|
||||||
ImGui.TableSetupColumn(_dataHolder.StatNames[substat], ImGuiTableColumnFlags.WidthFixed, 50);
|
|
||||||
|
|
||||||
ImGui.TableHeadersRow();
|
byte maxLevel = byte.MaxValue;
|
||||||
|
if (_onlyShowEquippableItems)
|
||||||
|
maxLevel = _plugin.GetLevel(_selectedClassJob);
|
||||||
|
|
||||||
foreach (var item in itemList.Items)
|
bool includeDamage = _selectedEquipmentCategory is EEquipSlotCategory.OneHandedMainHand
|
||||||
|
or EEquipSlotCategory.Shield
|
||||||
|
or EEquipSlotCategory.TwoHandedMainHand
|
||||||
|
&& !itemList.ClassJob.IsCrafter()
|
||||||
|
&& !itemList.ClassJob.IsGatherer();
|
||||||
|
|
||||||
|
var hoverColorPtr = ImGui.GetStyleColorVec4(ImGuiCol.HeaderHovered);
|
||||||
|
var hoverColor = new Vector4(hoverColorPtr->X, hoverColorPtr->Y, hoverColorPtr->Z, 0.3f);
|
||||||
|
|
||||||
|
if (ImGui.BeginTable("ItemList", 2 + (includeDamage ? 1 : 0) + itemList.SubstatPriorities.Count,
|
||||||
|
ImGuiTableFlags.Borders | ImGuiTableFlags.Resizable))
|
||||||
{
|
{
|
||||||
if (ownedItems != null && !ownedItems.ContainsKey((item.ItemId, item.Hq)))
|
ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.None, 300);
|
||||||
continue;
|
ImGui.TableSetupColumn("Level", ImGuiTableColumnFlags.WidthFixed, 50);
|
||||||
|
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);
|
||||||
|
|
||||||
if (item.Level > maxLevel)
|
ImGui.TableHeadersRow();
|
||||||
continue;
|
|
||||||
|
|
||||||
if (_hideNormalQualityItems && item.CanBeHq && !item.Hq)
|
ImGui.PushStyleColor(ImGuiCol.HeaderHovered, hoverColor);
|
||||||
continue;
|
foreach (var item in itemList.Items.DistinctBy(x => new
|
||||||
|
{ x.ItemId, x.Hq, Materia = x.MateriaStats?.GetHashCode() }))
|
||||||
ImGui.TableNextRow();
|
|
||||||
|
|
||||||
if (ImGui.TableNextColumn())
|
|
||||||
{
|
{
|
||||||
Vector4? color = item.Rarity switch
|
if (item is not InventoryItem)
|
||||||
{
|
{
|
||||||
2 => ImGuiColors.ParsedGreen,
|
if (_onlyShowOwnedItems)
|
||||||
3 => ImGuiColors.ParsedBlue,
|
continue;
|
||||||
4 => ImGuiColors.ParsedPurple,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
string name = item.Name;
|
|
||||||
if (item.Hq)
|
|
||||||
name += $" {SeIconChar.HighQuality.ToIconString()}";
|
|
||||||
|
|
||||||
if (color != null)
|
|
||||||
ImGui.TextColored(color.Value, name);
|
|
||||||
else
|
|
||||||
ImGui.Text(name);
|
|
||||||
|
|
||||||
if (ImGui.IsItemClicked())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_chatGui.Print(SeString.CreateItemLink(item.ItemId, item.Hq));
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// doesn't matter, just nice-to-have
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.TableNextColumn())
|
if (item.Level > maxLevel)
|
||||||
{
|
continue;
|
||||||
if (item.Level >= 50 && item.Level % 10 == 0)
|
|
||||||
ImGui.Text(string.Create(CultureInfo.InvariantCulture, $"{item.Level} ({item.ItemLevel})"));
|
|
||||||
else
|
|
||||||
ImGui.Text(item.Level.ToString(CultureInfo.InvariantCulture));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (includeDamage && ImGui.TableNextColumn())
|
if (_hideNormalQualityItems && item.CanBeHq && !item.Hq)
|
||||||
ImGui.Text(item.Damage.ToString(CultureInfo.CurrentCulture));
|
continue;
|
||||||
|
|
||||||
|
ImGui.TableNextRow();
|
||||||
|
|
||||||
foreach (EBaseParam substat in itemList.SubstatPriorities)
|
|
||||||
{
|
|
||||||
if (ImGui.TableNextColumn())
|
if (ImGui.TableNextColumn())
|
||||||
{
|
{
|
||||||
var stat = item.Stats.Get(substat);
|
Vector4? color = item.Rarity switch
|
||||||
if (stat == 0)
|
{
|
||||||
ImGui.Text("-");
|
2 => ImGuiColors.ParsedGreen,
|
||||||
|
3 => ImGuiColors.ParsedBlue,
|
||||||
|
4 => ImGuiColors.ParsedPurple,
|
||||||
|
7 => ImGuiColors.ParsedPink,
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
|
||||||
|
string name = item.Name;
|
||||||
|
if (item.Hq)
|
||||||
|
name += $" {SeIconChar.HighQuality.ToIconString()}";
|
||||||
|
if (item is InventoryItem { MateriaStats: not null } inventoryItem)
|
||||||
|
name +=
|
||||||
|
$" {string.Join("", Enumerable.Repeat(SeIconChar.Circle.ToIconString(), inventoryItem.MateriaStats!.Count))}";
|
||||||
|
|
||||||
|
if (color != null)
|
||||||
|
ImGui.PushStyleColor(ImGuiCol.Text, color.Value);
|
||||||
|
|
||||||
|
ImGui.Selectable(name, false, ImGuiSelectableFlags.SpanAllColumns);
|
||||||
|
|
||||||
|
if (color != null)
|
||||||
|
ImGui.PopStyleColor();
|
||||||
|
|
||||||
|
if (ImGui.IsItemClicked())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_chatGui.Print(SeString.CreateItemLink(item.ItemId, item.Hq));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// doesn't matter, just nice-to-have
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.TableNextColumn())
|
||||||
|
{
|
||||||
|
if (item.Level >= 50 && item.Level % 10 == 0)
|
||||||
|
ImGui.Text(string.Create(CultureInfo.InvariantCulture, $"{item.Level} ({item.ItemLevel})"));
|
||||||
else
|
else
|
||||||
ImGui.Text(stat.ToString(CultureInfo.CurrentCulture));
|
ImGui.Text(item.Level.ToString(CultureInfo.InvariantCulture));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeDamage && ImGui.TableNextColumn())
|
||||||
|
ImGui.Text(item.Damage.ToString(CultureInfo.CurrentCulture));
|
||||||
|
|
||||||
|
foreach (EBaseParam substat in itemList.SubstatPriorities)
|
||||||
|
{
|
||||||
|
if (ImGui.TableNextColumn())
|
||||||
|
{
|
||||||
|
var estat = item.Stats.GetEquipment(substat);
|
||||||
|
var mstat = item.Stats.GetMateria(substat);
|
||||||
|
if (estat == 0 && mstat == 0)
|
||||||
|
ImGui.Text("-");
|
||||||
|
else if (mstat == 0)
|
||||||
|
ImGui.Text(string.Create(CultureInfo.InvariantCulture, $"{estat}"));
|
||||||
|
else
|
||||||
|
ImGui.Text(string.Create(CultureInfo.InvariantCulture, $"{estat} +{mstat}"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.EndTable();
|
ImGui.PopStyleColor();
|
||||||
|
ImGui.EndTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
itemList.ClearFromInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,9 +4,83 @@
|
|||||||
"net8.0-windows7.0": {
|
"net8.0-windows7.0": {
|
||||||
"DalamudPackager": {
|
"DalamudPackager": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[2.1.12, )",
|
"requested": "[2.1.13, )",
|
||||||
"resolved": "2.1.12",
|
"resolved": "2.1.13",
|
||||||
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
|
"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, )"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
LLib
Submodule
1
LLib
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 9db9f95b8cd3f36262b5b4b14f12b7331d3c7279
|
Loading…
Reference in New Issue
Block a user