refactor: update to net5

This commit is contained in:
Anna 2021-08-22 22:42:27 -04:00
parent d8c6f2ea56
commit fc0d1f15ea
7 changed files with 87 additions and 29 deletions

View File

@ -7,6 +7,6 @@
AssemblyName="$(AssemblyName)"
VersionComponents="3"
ManifestType="yaml"
MakeZip="true" />
MakeZip="true"/>
</Target>
</Project>

View File

@ -1,3 +0,0 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ILMerge/>
</Weavers>

View File

@ -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<TripleTriadCard>().GetRow(cardId);
var card = this.Plugin.DataManager.GetExcelSheet<TripleTriadCard>().GetRow(cardId);
return card != null && this.HasCard((ushort) card.RowId);
}

View File

@ -4,8 +4,10 @@
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<Version>1.0.8</Version>
<TargetFramework>net48</TargetFramework>
<TargetFramework>net5-windows</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dalamud">
@ -22,9 +24,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="1.2.1"/>
<PackageReference Include="Fody" Version="6.5.1" PrivateAssets="all"/>
<PackageReference Include="ILMerge.Fody" Version="1.16.0" PrivateAssets="all"/>
<PackageReference Include="XivCommon" Version="1.6.0"/>
<PackageReference Include="DalamudPackager" Version="2.0.0"/>
<PackageReference Include="XivCommon" Version="3.0.1"/>
</ItemGroup>
</Project>

View File

@ -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

View File

@ -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<Item>().GetRow((uint) itemId);
var item = this.DataManager.GetExcelSheet<Item>().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<Recipe>()
var recipeResults = this.DataManager.GetExcelSheet<Recipe>()
.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<Orchestrion>().GetRow(orchId);
uint orchId = resultAction.Data[0];
var orch = this.DataManager.GetExcelSheet<Orchestrion>().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 = ": ";

46
icon.svg Executable file
View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
version="1.1"
x="0px"
y="0px"
viewBox="0 0 48 48"
xml:space="preserve"
id="svg12"
sodipodi:docname="icon.svg"
width="48"
height="48"
inkscape:export-filename="C:\Users\Anna\Desktop\goodmemory.png"
inkscape:export-xdpi="1023.6888"
inkscape:export-ydpi="1023.6888"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs16" /><sodipodi:namedview
id="namedview14"
pagecolor="#505050"
bordercolor="#ffffff"
borderopacity="1"
inkscape:pageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="1"
showgrid="false"
inkscape:zoom="11.093333"
inkscape:cx="23.933293"
inkscape:cy="24.023438"
inkscape:window-width="1920"
inkscape:window-height="1017"
inkscape:window-x="1592"
inkscape:window-y="32"
inkscape:window-maximized="1"
inkscape:current-layer="svg12" /><path
d="m 20.13,19.015959 c 0.14,1.06 0.5,2.19 1.26,3.23 1.06,1.46 2.07,2.84 2.28,4.56 0.06,0.48 0.47,0.85 0.96,0.87 0.1,0.01 0.21,0.01 0.32,0.01 3.48,0 6.93,-2.26 8.47,-5.59 1.42,-3.09 1.36,-6.51 -0.15,-8.13 -0.24,-0.26 -0.61,-0.36 -0.96,-0.28 -0.35,0.09 -0.64,0.37 -0.74,0.71 -0.02,0.08 -0.05,0.25 -0.06,0.33 -0.04,1.11 -0.54,1.83 -1.46,2.14 -0.67,0.22 -1.62,-0.1 -2.08,-0.7 -0.21,-0.27 -0.83,-1.08 0.08,-2.53 l 0.16,-0.26 c 0.22,-0.33 0.47,-0.72 0.65,-1.15 1.22,-2.9399999 0.81,-5.8999999 -1.23,-8.8099999 -1,-1.42 -2.3,-2.44999996 -3.88,-3.06999996 -0.37,-0.15 -0.79,-0.06 -1.07,0.22 -0.28,0.28 -0.37,0.70999996 -0.22,1.07999996 0.46,1.14 0.57,2.19 0.35,3.23 -0.34,1.55 -1.18,2.9 -2.73,4.4 -0.33,0.32 -0.67,0.63 -1.01,0.9399999 -0.52,0.47 -1.05,0.96 -1.56,1.48 -2.7,2.8 -3.31,6.2 -1.79,10.11 0.67,1.72 1.7,3.03 3.15,4.02 0.36,0.25 0.84,0.23 1.18,-0.04 0.35,-0.27 0.47,-0.73 0.32,-1.14 -0.66,-1.73 -0.84,-3.1 -0.58,-4.44 0.08,-0.41 0.19,-0.81 0.34,-1.19 z"
id="path2"
style="fill:#ff4a00;fill-opacity:1" /><path
d="m 8.03,34.975959 c -0.84,0 -1.53,0.69 -1.53,1.53 0,0.84 0.68,1.53 1.53,1.53 0.84,0 1.53,-0.68 1.53,-1.53 0,-0.84 -0.69,-1.53 -1.53,-1.53 z"
id="path4"
style="fill:#cccccc" /><path
d="m 36.45,47.725959 h 6.4 c 0.55,0 1,-0.45 1,-1 v -3.02 H 47 c 0.55,0 1,-0.44 1,-1 v -12.4 c 0,-0.55 -0.45,-1 -1,-1 H 1 c -0.55,0 -1,0.45 -1,1 v 12.4 c 0,0.56 0.45,1 1,1 h 3.15 v 3.02 c 0,0.55 0.45,1 1,1 h 6.4 c 0.56,0 1,-0.45 1,-1 v -3.02 h 22.9 v 3.02 c 0,0.55 0.44,1 1,1 z m 5.53,-14.29 h 0.51 c 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 h -0.51 c -0.55,0 -1,-0.45 -1,-1 0,-0.56 0.45,-1 1,-1 z m 0,4.14 h 0.51 c 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 h -0.51 c -0.55,0 -1,-0.45 -1,-1 0,-0.55 0.45,-1 1,-1 z m -4.01,-4.14 h 0.51 c 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 h -0.51 c -0.55,0 -1,-0.45 -1,-1 0,-0.56 0.44,-1 1,-1 z m 0,4.14 h 0.51 c 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 h -0.51 c -0.55,0 -1,-0.45 -1,-1 0,-0.55 0.44,-1 1,-1 z m -4.02,-4.14 h 0.51 c 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 h -0.51 c -0.55,0 -1,-0.45 -1,-1 0,-0.56 0.44,-1 1,-1 z m -11.09,4.07 H 11.4 c -0.43,1.46 -1.77,2.53 -3.36,2.53 -1.95,0 -3.53,-1.58 -3.53,-3.53 0,-1.95 1.58,-3.53 3.53,-3.53 1.59,0 2.93,1.07 3.36,2.53 h 11.46 c 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 z m 7.57,2.07 h -0.51 c -0.55,0 -1,-0.45 -1,-1 0,-0.55 0.45,-1 1,-1 h 0.51 c 0.55,0 1,0.45 1,1 0,0.55 -0.44,1 -1,1 z m 0,-4.14 h -0.51 c -0.55,0 -1,-0.45 -1,-1 0,-0.55 0.45,-1 1,-1 h 0.51 c 0.55,0 1,0.45 1,1 0,0.55 -0.44,1 -1,1 z m 4.03,4.14 h -0.51 c -0.55,0 -1,-0.45 -1,-1 0,-0.55 0.45,-1 1,-1 h 0.51 c 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 z"
id="path6"
style="fill:#cccccc" /></svg>

After

Width:  |  Height:  |  Size: 3.8 KiB