浏览代码

Update for apiX and 7.0.0

Florent Castelli 1 年之前
父节点
当前提交
740d3f4519

+ 2 - 2
HuntBuddy/HuntBuddy.csproj

@@ -3,7 +3,7 @@
     <PropertyGroup>
         <TargetFramework>net8-windows</TargetFramework>
         <Nullable>enable</Nullable>
-        <AssemblyVersion>1.1.0.1</AssemblyVersion>
+        <AssemblyVersion>1.2.0.0</AssemblyVersion>
         <FileVersion>$(AssemblyVersion)</FileVersion>
         <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
         <RootNamespace>HuntBuddy</RootNamespace>
@@ -54,6 +54,6 @@
         </Reference>
     </ItemGroup>
     <ItemGroup>
-        <PackageReference Include="DalamudPackager" Version="2.1.12" />
+        <PackageReference Include="DalamudPackager" Version="2.1.13" />
     </ItemGroup>
 </Project>

+ 3 - 9
HuntBuddy/MobHuntEntry.cs

@@ -1,10 +1,6 @@
-using System;
+namespace HuntBuddy;
 
-using Dalamud.Interface.Internal;
-
-namespace HuntBuddy;
-
-public class MobHuntEntry: IDisposable {
+public class MobHuntEntry {
 	public string? Name { get; init; }
 
 	public string? TerritoryName { get; init; }
@@ -25,7 +21,5 @@ public class MobHuntEntry: IDisposable {
 
 	public uint NeededKills { get; set; }
 
-	public IDalamudTextureWrap Icon { get; init; } = null!;
-
-	public void Dispose() => this.Icon.Dispose();
+	public uint Icon { get; init; }
 }

+ 6 - 14
HuntBuddy/Plugin.cs

@@ -6,7 +6,6 @@ using System.Linq;
 using System.Numerics;
 using System.Threading.Tasks;
 
-using Dalamud.Interface.Internal;
 using Dalamud.Interface.Windowing;
 using Dalamud.Plugin;
 using Dalamud.Plugin.Services;
@@ -19,10 +18,8 @@ using HuntBuddy.Windows;
 
 using ImGuiNET;
 
-using Lumina.Data.Files;
 using Lumina.Excel;
 using Lumina.Excel.GeneratedSheets;
-using Lumina.Extensions;
 using Lumina.Text;
 
 namespace HuntBuddy;
@@ -60,7 +57,7 @@ public class Plugin: IDalamudPlugin {
 		internal set;
 	} = null!;
 
-	public Plugin(DalamudPluginInterface pluginInterface) {
+	public Plugin(IDalamudPluginInterface pluginInterface) {
 		Instance = this;
 
 		pluginInterface.Create<Service>();
@@ -91,6 +88,7 @@ public class Plugin: IDalamudPlugin {
 		Service.ClientState.TerritoryChanged += this.ClientStateOnTerritoryChanged;
 		Service.PluginInterface.UiBuilder.Draw += this.WindowSystem.Draw;
 		Service.PluginInterface.UiBuilder.OpenConfigUi += this.OpenConfigUi;
+		Service.PluginInterface.UiBuilder.OpenMainUi += this.OpenMainUi;
 		Service.Framework.Update += this.FrameworkOnUpdate;
 	}
 
@@ -117,6 +115,7 @@ public class Plugin: IDalamudPlugin {
 	private void DrawInterface() => this.MainWindow.Toggle();
 
 	public void OpenConfigUi() => this.ConfigurationWindow.Toggle();
+	public void OpenMainUi() => this.MainWindow.Toggle();
 
 	private void Dispose(bool disposing) {
 		if (!disposing) {
@@ -128,6 +127,7 @@ public class Plugin: IDalamudPlugin {
 		Service.Framework.Update -= this.FrameworkOnUpdate;
 		Service.PluginInterface.UiBuilder.Draw -= this.WindowSystem.Draw;
 		Service.PluginInterface.UiBuilder.OpenConfigUi -= this.OpenConfigUi;
+		Service.PluginInterface.UiBuilder.OpenMainUi -= this.OpenMainUi;
 
 		this.WindowSystem.RemoveAllWindows();
 
@@ -298,11 +298,10 @@ public class Plugin: IDalamudPlugin {
 							MapId = mobHuntOrderRow.Target.Value!.TerritoryType.Row,
 							TerritoryType = mobHuntOrderRow.Target.Value!.TerritoryType.Value.TerritoryType.Row,
 							MobHuntId = mobHuntOrderRow.Target.Value!.Name.Row,
-							IsEliteMark = billNumber is BillEnum.ArrElite or BillEnum.HwElite or BillEnum.SbElite
-								or BillEnum.ShbElite or BillEnum.EwElite,
+							IsEliteMark = mobHuntOrderTypeRow.Type == 2,
 							CurrentKillsOffset = (5 * (uint)billNumber) + mobHuntOrderRow.SubRowId,
 							NeededKills = mobHuntOrderRow.NeededKills,
-							Icon = Plugin.LoadIcon(mobHuntOrderRow.Target.Value.Icon)
+							Icon = mobHuntOrderRow.Target.Value.Icon,
 						});
 				}
 				else {
@@ -334,13 +333,6 @@ public class Plugin: IDalamudPlugin {
 		this.MobHuntEntriesReady = true;
 	}
 
-	private static IDalamudTextureWrap LoadIcon(uint id) {
-		TexFile icon = Service.DataManager.GameData.GetHqIcon(id) ?? Service.DataManager.GameData.GetIcon(id)!;
-		byte[] iconData = icon.GetRgbaImageData();
-
-		return Service.PluginInterface.UiBuilder.LoadImageRaw(iconData, icon.Header.Width, icon.Header.Height, 4);
-	}
-
 	public void Dispose() {
 		this.Dispose(true);
 		GC.SuppressFinalize(this);

+ 2 - 2
HuntBuddy/PluginCommandManager.cs

@@ -48,8 +48,8 @@ public class PluginCommandManager<THost>: IDisposable {
 	}
 
 	private IEnumerable<(string, CommandInfo)> GetCommandInfoTuple(MethodInfo method) {
-		CommandInfo.HandlerDelegate handlerDelegate = (CommandInfo.HandlerDelegate)Delegate.CreateDelegate(
-			typeof(CommandInfo.HandlerDelegate),
+		IReadOnlyCommandInfo.HandlerDelegate handlerDelegate = (IReadOnlyCommandInfo.HandlerDelegate)Delegate.CreateDelegate(
+			typeof(IReadOnlyCommandInfo.HandlerDelegate),
 			this.host,
 			method);
 

+ 7 - 1
HuntBuddy/Service.cs

@@ -7,7 +7,7 @@ namespace HuntBuddy;
 
 public class Service {
 	[PluginService]
-	public static DalamudPluginInterface PluginInterface {
+	public static IDalamudPluginInterface PluginInterface {
 		get;
 		set;
 	} = null!;
@@ -59,4 +59,10 @@ public class Service {
 		get;
 		set;
 	} = null!;
+
+	[PluginService]
+	public static ITextureProvider TextureProvider {
+		get;
+		set;
+	} = null!;
 }

+ 11 - 3
HuntBuddy/Structs/MobHuntStruct.cs

@@ -22,6 +22,10 @@ public enum BillEnum: uint {
 	EwRank2,
 	EwRank3,
 	EwElite,
+	DtRank1,
+	DtRank2,
+	DtRank3,
+	DtElite,
 }
 
 [Flags]
@@ -44,13 +48,17 @@ public enum ObtainedBillEnum: uint {
 	EwRank2 = 1 << 15,
 	EwRank3 = 1 << 16,
 	EwElite = 1 << 17,
+	DtRank1 = 1 << 18,
+	DtRank2 = 1 << 19,
+	DtRank3 = 1 << 20,
+	DtElite = 1 << 21,
 }
 
 // Signature to get struct address
 // D1 48 8D 0D ? ? ? ? 48 83 C4 20 5F E9 ? ? ? ?
 [StructLayout(LayoutKind.Explicit, Size = 0x198)]
 public unsafe struct MobHuntStruct {
-	[FieldOffset(0x1A)] public fixed byte BillOffset[18];
-	[FieldOffset(0x2C)] public fixed int CurrentKills[5 * 18];
-	[FieldOffset(0x194)] public readonly ObtainedBillEnum ObtainedBillEnumFlags;
+	[FieldOffset(0x1E)] public fixed byte BillOffset[22];
+	[FieldOffset(0x34)] public fixed int CurrentKills[5 * 22];
+	[FieldOffset(0x1EC)] public readonly ObtainedBillEnum ObtainedBillEnumFlags;
 }

+ 27 - 2
HuntBuddy/Utils/InterfaceUtil.cs

@@ -1,9 +1,15 @@
 using System.Numerics;
 
 using Dalamud.Interface;
-
+using Dalamud.Interface.Textures.TextureWraps;
+using Dalamud.Plugin.Services;
+using Dalamud.Interface.Textures;
 using ImGuiNET;
 
+using Lumina.Data.Files;
+
+using Lumina.Extensions;
+
 namespace HuntBuddy.Utils;
 
 /// <summary>
@@ -36,7 +42,26 @@ public static class InterfaceUtil {
 				Plugin.Instance.Configuration.IconBackgroundColourU32);
 		}
 
-		drawList.AddImage(mobHuntEntry.Icon.ImGuiHandle, cursorPos, cursorPos + imageSize);
+		drawList.AddImage(LoadIcon(mobHuntEntry.Icon).ImGuiHandle, cursorPos, cursorPos + imageSize);
+	}
+
+	/// <summary>
+	/// Returns a IDalamudTextureWrap for an icon.
+	/// Will request a Hi-Res version and fallback to normal resolution otherwise.
+	/// </summary>
+	/// <param name="id">Icon ID</param>
+	/// <returns>IDalamudTextureWrap for the icon, or an empty wrap if the icon is not found.</returns>
+	private static IDalamudTextureWrap LoadIcon(uint id) {
+		if (Service.TextureProvider.TryGetFromGameIcon(new GameIconLookup {
+			IconId = id,
+			HiRes = true,
+		}, out var texture)) {
+			return texture.GetWrapOrEmpty();
+		}
+		return Service.TextureProvider.GetFromGameIcon(new GameIconLookup {
+			IconId = id,
+			HiRes = false,
+		}).GetWrapOrEmpty();
 	}
 
 	/// <summary>

+ 12 - 12
HuntBuddy/packages.lock.json

@@ -1,13 +1,13 @@
 {
-  "version": 1,
-  "dependencies": {
-    "net7.0-windows7.0": {
-      "DalamudPackager": {
-        "type": "Direct",
-        "requested": "[2.1.12, )",
-        "resolved": "2.1.12",
-        "contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
-      }
-    }
-  }
-}
+	"version": 1,
+	"dependencies": {
+		"net8.0-windows7.0": {
+			"DalamudPackager": {
+				"type": "Direct",
+				"requested": "[2.1.13, )",
+				"resolved": "2.1.13",
+				"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
+			}
+		}
+	}
+}