diff --git a/GoodMemory/DalamudPackager.targets b/GoodMemory/DalamudPackager.targets index bc40883..268d00d 100644 --- a/GoodMemory/DalamudPackager.targets +++ b/GoodMemory/DalamudPackager.targets @@ -7,6 +7,6 @@ AssemblyName="$(AssemblyName)" VersionComponents="3" ManifestType="yaml" - MakeZip="true" /> + MakeZip="true"/> diff --git a/GoodMemory/FodyWeavers.xml b/GoodMemory/FodyWeavers.xml deleted file mode 100755 index 2dfb1f4..0000000 --- a/GoodMemory/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/GoodMemory/GameFunctions.cs b/GoodMemory/GameFunctions.cs index 8ad43a4..15598ef 100644 --- a/GoodMemory/GameFunctions.cs +++ b/GoodMemory/GameFunctions.cs @@ -17,11 +17,11 @@ namespace GoodMemory { private readonly IntPtr _cardStaticAddr; public GameFunctions(Plugin plugin) { - this.Plugin = plugin ?? throw new ArgumentNullException(nameof(plugin), "Plugin cannot be null"); + this.Plugin = plugin; - var hasIaUnlockedPtr = plugin.Interface.TargetModuleScanner.ScanText("48 83 EC 28 E8 ?? ?? ?? ?? 48 85 C0 0F 84 ?? ?? ?? ??"); - var hasCardPtr = plugin.Interface.TargetModuleScanner.ScanText("40 53 48 83 EC 20 48 8B D9 66 85 D2 74 ??"); - this._cardStaticAddr = plugin.Interface.TargetModuleScanner.GetStaticAddressFromSig("41 0F B7 17 48 8D 0D ?? ?? ?? ??"); + var hasIaUnlockedPtr = this.Plugin.SigScanner.ScanText("48 83 EC 28 E8 ?? ?? ?? ?? 48 85 C0 0F 84 ?? ?? ?? ??"); + var hasCardPtr = this.Plugin.SigScanner.ScanText("40 53 48 83 EC 20 48 8B D9 66 85 D2 74 ??"); + this._cardStaticAddr = this.Plugin.SigScanner.GetStaticAddressFromSig("41 0F B7 17 48 8D 0D ?? ?? ?? ??"); if (hasIaUnlockedPtr == IntPtr.Zero || hasCardPtr == IntPtr.Zero || this._cardStaticAddr == IntPtr.Zero) { throw new ApplicationException("Could not get pointers for game functions"); @@ -45,7 +45,7 @@ namespace GoodMemory { } var cardId = item.AdditionalData; - var card = this.Plugin.Interface.Data.GetExcelSheet().GetRow(cardId); + var card = this.Plugin.DataManager.GetExcelSheet().GetRow(cardId); return card != null && this.HasCard((ushort) card.RowId); } diff --git a/GoodMemory/GoodMemory.csproj b/GoodMemory/GoodMemory.csproj index 101cfdb..3f6b0b4 100755 --- a/GoodMemory/GoodMemory.csproj +++ b/GoodMemory/GoodMemory.csproj @@ -4,8 +4,10 @@ latest enable 1.0.8 - net48 + net5-windows true + true + false @@ -22,9 +24,7 @@ - - - - + + diff --git a/GoodMemory/GoodMemory.yaml b/GoodMemory/GoodMemory.yaml index d4cd7c5..ec5508e 100644 --- a/GoodMemory/GoodMemory.yaml +++ b/GoodMemory/GoodMemory.yaml @@ -1,8 +1,14 @@ author: ascclemens name: Good Memory +punchline: Adds an indicator in item tooltips to show whether you have acquired that item. description: |- Adds an indicator in item tooltips to show whether you have acquired that item. This indicator is in the item's description near the bottom and only appears for items that are unlockable, such as orchestrion rolls, minions, etc. + + Square Enix say this plugin is impossible! + + Icon: Server by Vectorstall from the Noun Project repo_url: https://git.sr.ht/~jkcclemens/GoodMemory +icon_url: https://annaclemens.io/assets/plugins/icons/goodmemory.png diff --git a/GoodMemory/Plugin.cs b/GoodMemory/Plugin.cs index 9e39f07..87ab29e 100644 --- a/GoodMemory/Plugin.cs +++ b/GoodMemory/Plugin.cs @@ -1,26 +1,35 @@ using Dalamud.Plugin; using Lumina.Excel.GeneratedSheets; -using System; using System.Diagnostics; using System.Linq; +using Dalamud.Data; +using Dalamud.Game; +using Dalamud.Game.ClientState; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; using XivCommon; using XivCommon.Functions.Tooltips; namespace GoodMemory { + // ReSharper disable once ClassNeverInstantiated.Global public class Plugin : IDalamudPlugin { public string Name => "Good Memory"; - public DalamudPluginInterface Interface { get; private set; } = null!; - private GameFunctions Functions { get; set; } = null!; - private XivCommonBase Common { get; set; } = null!; + private ClientState ClientState { get; } + internal DataManager DataManager { get; } + internal SigScanner SigScanner { get; } + private GameFunctions Functions { get; } + private XivCommonBase Common { get; } - public void Initialize(DalamudPluginInterface pluginInterface) { - this.Interface = pluginInterface ?? throw new ArgumentNullException(nameof(pluginInterface), "DalamudPluginInterface cannot be null"); - this.Functions = new GameFunctions(this); - this.Common = new XivCommonBase(pluginInterface, Hooks.Tooltips); + public Plugin(ClientState clientState, DataManager dataManager, SigScanner sigScanner) { + this.ClientState = clientState; + this.DataManager = dataManager; + this.SigScanner = sigScanner; + + this.Common = new XivCommonBase(Hooks.Tooltips); this.Common.Functions.Tooltips.OnItemTooltip += this.OnItemTooltip; + + this.Functions = new GameFunctions(this); } public void Dispose() { @@ -41,7 +50,7 @@ namespace GoodMemory { itemId -= 1_000_000; } - var item = this.Interface.Data.GetExcelSheet().GetRow((uint) itemId); + var item = this.DataManager.GetExcelSheet().GetRow((uint) itemId); if (item == null) { return; } @@ -50,27 +59,27 @@ namespace GoodMemory { // Faded Copies if (item.FilterGroup == 12 && item.ItemUICategory.Value?.RowId == 94 && item.LevelItem.Value?.RowId == 1) { - var recipeResults = this.Interface.Data.GetExcelSheet() + var recipeResults = this.DataManager.GetExcelSheet() .Where(recipe => recipe.UnkStruct5.Any(ritem => ritem.ItemIngredient == item.RowId)) .Select(recipe => recipe.ItemResult.Value) .Where(result => result != null) .ToArray(); foreach (var result in recipeResults) { - var resultAction = result.ItemAction?.Value; + var resultAction = result?.ItemAction?.Value; if (!ActionTypeExt.IsValidAction(resultAction)) { continue; } Debug.Assert(resultAction != null, nameof(resultAction) + " != null"); - uint orchId = resultAction!.Data[0]; - var orch = this.Interface.Data.GetExcelSheet().GetRow(orchId); + uint orchId = resultAction.Data[0]; + var orch = this.DataManager.GetExcelSheet().GetRow(orchId); if (orch == null) { continue; } - this.AppendIfAcquired(description, result, orch.Name); + this.AppendIfAcquired(description, result!, orch.Name); } } else { var action = item.ItemAction?.Value; @@ -93,7 +102,7 @@ namespace GoodMemory { string colon; string parenL; string parenR; - switch (this.Interface.ClientState.ClientLanguage) { + switch (this.ClientState.ClientLanguage) { default: acquired = "Acquired"; colon = ": "; diff --git a/icon.svg b/icon.svg new file mode 100755 index 0000000..fc1339c --- /dev/null +++ b/icon.svg @@ -0,0 +1,46 @@ + +