Skip to content

Commit

Permalink
[PR] API9
Browse files Browse the repository at this point in the history
- Updated HuntBuddy for API9
  • Loading branch information
SheepGoMeh committed Oct 4, 2023
1 parent 45804a5 commit af0b20f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 51 deletions.
4 changes: 2 additions & 2 deletions HuntBuddy/HuntBuddy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<AssemblyVersion>1.0.2.0</AssemblyVersion>
<AssemblyVersion>1.0.3.0</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RootNamespace>HuntBuddy</RootNamespace>
Expand Down Expand Up @@ -54,6 +54,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.11" />
<PackageReference Include="DalamudPackager" Version="2.1.12" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion HuntBuddy/Ipc/TeleportConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void Subscribe()
}
catch (Exception ex)
{
PluginLog.LogDebug($"Failed to subscribe to Teleporter\nReason: {ex}");
Plugin.PluginLog.Debug($"Failed to subscribe to Teleporter\nReason: {ex}");
}
}

Expand Down
4 changes: 2 additions & 2 deletions HuntBuddy/MobHuntEntry.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using ImGuiScene;
using Dalamud.Interface.Internal;

namespace HuntBuddy
{
Expand All @@ -25,7 +25,7 @@ public class MobHuntEntry : IDisposable

public uint NeededKills { get; set; }

public TextureWrap Icon { get; init; } = null!;
public IDalamudTextureWrap Icon { get; init; } = null!;

public void Dispose()
{
Expand Down
59 changes: 18 additions & 41 deletions HuntBuddy/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,43 @@
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Interface.Internal;
using Dalamud.IoC;
using Dalamud.Logging;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using Dalamud.Utility;
using Lumina.Excel.GeneratedSheets;
using HuntBuddy.Attributes;
using HuntBuddy.Ipc;
using HuntBuddy.Structs;
using ImGuiNET;
using ImGuiScene;
using Lumina.Data.Files;
using Lumina.Extensions;

namespace HuntBuddy
{
public class Plugin : IDalamudPlugin
{
public string Name => "Hunt Buddy";

[PluginService]
[RequiredVersion("1.0")]
public static DalamudPluginInterface PluginInterface { get; set; } = null!;
[PluginService] public static DalamudPluginInterface PluginInterface { get; set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static CommandManager Commands { get; set; } = null!;
[PluginService] public static ICommandManager Commands { get; set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static ChatGui Chat { get; set; } = null!;
[PluginService] public static IChatGui Chat { get; set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static DataManager DataManager { get; set; } = null!;
[PluginService] public static IDataManager DataManager { get; set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static SigScanner SigScanner { get; set; } = null!;
[PluginService] public static ISigScanner SigScanner { get; set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static GameGui GameGui { get; set; } = null!;
[PluginService] public static IGameGui GameGui { get; set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static ClientState ClientState { get; set; } = null!;
[PluginService] public static IClientState ClientState { get; set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static Framework Framework { get; set; } = null!;
[PluginService] public static IFramework Framework { get; set; } = null!;

[PluginService] public static IPluginLog PluginLog { get; set; } = null!;

private readonly PluginCommandManager<Plugin> commandManager;
private readonly Interface pluginInterface;
Expand Down Expand Up @@ -96,7 +79,7 @@ public Plugin()
Plugin.Framework.Update += this.FrameworkOnUpdate;
}

private unsafe void FrameworkOnUpdate(Framework framework)
private unsafe void FrameworkOnUpdate(IFramework framework)
{
if (this.lastState == this.MobHuntStruct->ObtainedBillEnumFlags)
{
Expand All @@ -107,7 +90,7 @@ private unsafe void FrameworkOnUpdate(Framework framework)
this.PluginCommand(string.Empty, "reload");
}

private void ClientStateOnTerritoryChanged(object? sender, ushort e)
private void ClientStateOnTerritoryChanged(ushort e)
{
this.CurrentAreaMobHuntEntries.Clear();

Expand Down Expand Up @@ -321,20 +304,14 @@ public unsafe void ReloadData()
this.MobHuntEntries[key][subKey].Add(entry);
}

this.ClientStateOnTerritoryChanged(null, 0);
this.ClientStateOnTerritoryChanged(0);

this.MobHuntEntriesReady = true;
}

private static TexFile? GetHdIcon(uint id)
{
var path = $"ui/icon/{id / 1000 * 1000:000000}/{id:000000}_hr1.tex";
return Plugin.DataManager.GetFile<TexFile>(path);
}

private static TextureWrap LoadIcon(uint id)
private static IDalamudTextureWrap LoadIcon(uint id)
{
var icon = Plugin.GetHdIcon(id) ?? Plugin.DataManager.GetIcon(id)!;
var icon = Plugin.DataManager.GameData.GetHqIcon(id) ?? Plugin.DataManager.GameData.GetIcon(id)!;
var iconData = icon.GetRgbaImageData();

return Plugin.PluginInterface.UiBuilder.LoadImageRaw(iconData, icon.Header.Width, icon.Header.Height, 4);
Expand Down
5 changes: 3 additions & 2 deletions HuntBuddy/PluginCommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
using System.Linq;
using System.Reflection;
using Dalamud.Game.Command;
using Dalamud.Plugin.Services;
using HuntBuddy.Attributes;

namespace HuntBuddy
{
public class PluginCommandManager<THost> : IDisposable
{
private readonly CommandManager commandManager;
private readonly ICommandManager commandManager;
private readonly (string, CommandInfo)[] pluginCommands;
private readonly THost host;

public PluginCommandManager(THost host, CommandManager commandManager)
public PluginCommandManager(THost host, ICommandManager commandManager)
{
this.commandManager = commandManager;
this.host = host;
Expand Down
6 changes: 3 additions & 3 deletions HuntBuddy/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"net7.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.11, )",
"resolved": "2.1.11",
"contentHash": "9qlAWoRRTiL/geAvuwR/g6Bcbrd/bJJgVnB/RurBiyKs6srsP0bvpoo8IK+Eg8EA6jWeM6/YJWs66w4FIAzqPw=="
"requested": "[2.1.12, )",
"resolved": "2.1.12",
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
}
}
}
Expand Down

0 comments on commit af0b20f

Please sign in to comment.