Skip to content

Commit

Permalink
Merge pull request #40 from Orphis/dawntrail
Browse files Browse the repository at this point in the history
Update for apiX and 7.0.0
  • Loading branch information
SheepGoMeh authored Jul 8, 2024
2 parents 3778ebc + 1dbdf8c commit bd9fdf4
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 45 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>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>
Expand Down Expand Up @@ -54,6 +54,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.12" />
<PackageReference Include="DalamudPackager" Version="2.1.13" />
</ItemGroup>
</Project>
125 changes: 125 additions & 0 deletions HuntBuddy/Location.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ public float Y {
{ 05728, new PositionInfo { X = 17.0f, Y = 08.0f } }, // Specter
{ 05726, new PositionInfo { X = 25.0f, Y = 29.0f } }, // Vepar
{ 05719, new PositionInfo { X = 20.0f, Y = 25.0f } }, // Yabby

// Shadowbringers
// Lakeland
{ 08498, new PositionInfo { X = 19.0f, Y = 09.0f } }, // Chiliad Cama
Expand Down Expand Up @@ -457,6 +458,130 @@ public float Y {
{ 10427, new PositionInfo { X = 10.0f, Y = 30.0f } }, // Stellar Amphiptere
{ 10430, new PositionInfo { X = 14.4f, Y = 28.2f } }, // Stellar Brobinyak
{ 10435, new PositionInfo { X = 16.3f, Y = 14.1f } }, // Other One

// Dawntrail
// Urqopacha
{ 13079, new PositionInfo { X = 32.0f, Y = 13.4f } }, // Alpaca
{ 13090, new PositionInfo { X = 22.5f, Y = 16.9f } }, // Bandercoeurl
{ 13083, new PositionInfo { X = 22.5f, Y = 11.8f } }, // Barbmole
{ 13081, new PositionInfo { X = 33.5f, Y = 34.2f } }, // Bloodsucker
{ 13087, new PositionInfo { X = 28.7f, Y = 09.1f } }, // Chaba Gedan
{ 13084, new PositionInfo { X = 22.4f, Y = 33.9f } }, // Chirwagur Sabreur
{ 13085, new PositionInfo { X = 16.6f, Y = 28.0f } }, // Flint
{ 13094, new PositionInfo { X = 15.9f, Y = 23.7f } }, // Huallepen
{ 13096, new PositionInfo { X = 25.3f, Y = 22.2f } }, // Longjaw
{ 13080, new PositionInfo { X = 19.5f, Y = 14.8f } }, // Megamaguey
{ 13095, new PositionInfo { X = 35.0f, Y = 27.5f } }, // Molten Phoebad
{ 13091, new PositionInfo { X = 19.3f, Y = 17.1f } }, // Mountain Bear
{ 13093, new PositionInfo { X = 24.2f, Y = 27.3f } }, // Naryordor
{ 13092, new PositionInfo { X = 15.2f, Y = 13.3f } }, // Notocactuar
{ 13097, new PositionInfo { X = 09.4f, Y = 22.9f } }, // Ridgetrap
{ 13088, new PositionInfo { X = 25.7f, Y = 17.0f } }, // Siehnam
{ 13082, new PositionInfo { X = 25.9f, Y = 14.0f } }, // Silver Lobo
{ 13086, new PositionInfo { X = 31.9f, Y = 18.5f } }, // Tulichu
{ 13098, new PositionInfo { X = 28.1f, Y = 28.4f } }, // Tulidile
{ 13089, new PositionInfo { X = 30.8f, Y = 15.4f } }, // Turali Ratel

// Kozama'uka
{ 12946, new PositionInfo { X = 19.5f, Y = 23.8f } }, // Bird of Ligaka
{ 12935, new PositionInfo { X = 14.0f, Y = 19.3f } }, // Glowfly
{ 12930, new PositionInfo { X = 10.2f, Y = 09.5f } }, // Hammerhead Crocodile
{ 12936, new PositionInfo { X = 21.1f, Y = 12.7f } }, // Heavy Matamata
{ 12952, new PositionInfo { X = 13.2f, Y = 29.6f } }, // Jungle Iguana
{ 12934, new PositionInfo { X = 14.2f, Y = 16.3f } }, // Jungle Orobon
{ 12938, new PositionInfo { X = 13.8f, Y = 11.2f } }, // Jungle Pelican
{ 12943, new PositionInfo { X = 11.2f, Y = 22.8f } }, // Lesser Apollyon
{ 12941, new PositionInfo { X = 33.0f, Y = 14.6f } }, // Ocelot
{ 12949, new PositionInfo { X = 36.9f, Y = 34.9f } }, // Paper Wasp
{ 12939, new PositionInfo { X = 29.9f, Y = 15.5f } }, // Poison Frog
{ 12933, new PositionInfo { X = 15.7f, Y = 14.4f } }, // Rhino Beetle
{ 12937, new PositionInfo { X = 26.8f, Y = 12.3f } }, // Stinkshell
{ 12944, new PositionInfo { X = 19.9f, Y = 28.4f } }, // Swampmonk
{ 12948, new PositionInfo { X = 34.2f, Y = 27.5f } }, // Tegu
{ 12947, new PositionInfo { X = 08.0f, Y = 32.5f } }, // Tomaton
{ 12932, new PositionInfo { X = 20.7f, Y = 15.8f } }, // Toucalibri
{ 12950, new PositionInfo { X = 17.9f, Y = 32.2f } }, // Turali Morbol
{ 12951, new PositionInfo { X = 08.7f, Y = 26.7f } }, // Turali Netzach
{ 12942, new PositionInfo { X = 31.5f, Y = 19.5f } }, // U'out
{ 12931, new PositionInfo { X = 14.8f, Y = 05.5f } }, // Uolon
{ 12945, new PositionInfo { X = 28.9f, Y = 25.3f } }, // Widowmaker
{ 12940, new PositionInfo { X = 33.6f, Y = 08.5f } }, // Woodsman

// Yak T'el
{ 12957, new PositionInfo { X = 21.1f, Y = 05.6f } }, // Balyaborr
{ 12966, new PositionInfo { X = 07.4f, Y = 24.4f } }, // Blue Leafkin
{ 12969, new PositionInfo { X = 16.4f, Y = 28.9f } }, // Blue Morpho
{ 12964, new PositionInfo { X = 17.8f, Y = 24.4f } }, // Branchbearer
{ 12971, new PositionInfo { X = 16.3f, Y = 37.7f } }, // Fly Agaric
{ 12970, new PositionInfo { X = 20.4f, Y = 18.1f } }, // Ja Tiika Moth
{ 12958, new PositionInfo { X = 24.3f, Y = 06.3f } }, // Killer Piranha
{ 12955, new PositionInfo { X = 09.5f, Y = 20.4f } }, // Leaf Mantis
{ 12965, new PositionInfo { X = 30.2f, Y = 28.3f } }, // Mourner
{ 12954, new PositionInfo { X = 17.0f, Y = 13.8f } }, // Necrosis
{ 12962, new PositionInfo { X = 35.3f, Y = 23.1f } }, // Pitcher Weed
{ 12967, new PositionInfo { X = 30.6f, Y = 35.7f } }, // Sarracenia
{ 12960, new PositionInfo { X = 28.0f, Y = 18.4f } }, // T'ohsoq
{ 12961, new PositionInfo { X = 32.8f, Y = 20.5f } }, // T'ohts'on
{ 12953, new PositionInfo { X = 24.0f, Y = 11.8f } }, // Ty'aitya
{ 12956, new PositionInfo { X = 12.4f, Y = 09.9f } }, // Vawtsaral Br'aax
{ 12959, new PositionInfo { X = 32.2f, Y = 12.7f } }, // Yak T'el Squib

// Shaaloani
{ 12990, new PositionInfo { X = 14.7f, Y = 09.4f } }, // Aspis
{ 12989, new PositionInfo { X = 27.6f, Y = 13.1f } }, // Ceratoraptor
{ 12975, new PositionInfo { X = 11.4f, Y = 17.1f } }, // Cerule Anala
{ 12977, new PositionInfo { X = 19.9f, Y = 21.5f } }, // Cerule Bomb
{ 12992, new PositionInfo { X = 31.8f, Y = 23.8f } }, // Flying Popoto
{ 12996, new PositionInfo { X = 28.8f, Y = 23.5f } }, // Grasslands Worm
{ 12995, new PositionInfo { X = 24.4f, Y = 15.6f } }, // Gritclaw
{ 12997, new PositionInfo { X = 12.3f, Y = 12.9f } }, // Horned Lizard
{ 12988, new PositionInfo { X = 21.4f, Y = 31.8f } }, // Lunyucaua'pya
{ 12987, new PositionInfo { X = 18.0f, Y = 31.6f } }, // Lunyuhiyshahe
{ 12991, new PositionInfo { X = 24.3f, Y = 11.3f } }, // Rroneek
{ 12976, new PositionInfo { X = 25.9f, Y = 29.0f } }, // Sunbeard
{ 12993, new PositionInfo { X = 35.1f, Y = 11.1f } }, // Toari Alligator
{ 12972, new PositionInfo { X = 30.3f, Y = 33.1f } }, // Tumbleclaw
{ 12994, new PositionInfo { X = 29.2f, Y = 07.9f } }, // Turali Hawksbill
{ 12978, new PositionInfo { X = 14.1f, Y = 23.3f } }, // Wild Dhara
{ 12986, new PositionInfo { X = 12.7f, Y = 30.2f } }, // Yeheheceyaa

// Heritage Found
{ 13115, new PositionInfo { X = 09.6f, Y = 19.5f } }, // Asterodia
{ 13101, new PositionInfo { X = 33.4f, Y = 27.7f } }, // Axe Beak
{ 13103, new PositionInfo { X = 22.5f, Y = 16.7f } }, // Bolt Hound
{ 13116, new PositionInfo { X = 28.2f, Y = 26.7f } }, // Cauahealoa
{ 13117, new PositionInfo { X = 32.6f, Y = 22.7f } }, // Cauahepya
{ 13108, new PositionInfo { X = 15.8f, Y = 22.2f } }, // Defective Aerostat
{ 13107, new PositionInfo { X = 15.8f, Y = 22.2f } }, // Defective Sentry R8
{ 13106, new PositionInfo { X = 10.6f, Y = 26.2f } }, // Defective Sentry S8
{ 13109, new PositionInfo { X = 11.3f, Y = 11.5f } }, // Defective Turret
{ 13105, new PositionInfo { X = 21.3f, Y = 27.6f } }, // Eyeclops
{ 13104, new PositionInfo { X = 14.8f, Y = 17.2f } }, // Gomphotherium
{ 13113, new PositionInfo { X = 35.2f, Y = 14.2f } }, // Katoblepas
{ 13112, new PositionInfo { X = 24.3f, Y = 20.9f } }, // Myrmeleon
{ 13114, new PositionInfo { X = 11.2f, Y = 33.2f } }, // Python
{ 13111, new PositionInfo { X = 30.8f, Y = 13.9f } }, // Thunder Spirit
{ 13110, new PositionInfo { X = 15.6f, Y = 32.4f } }, // Woolback
{ 13102, new PositionInfo { X = 24.8f, Y = 07.3f } }, // Yyenisheyni Bat

// Living Memory
{ 13121, new PositionInfo { X = 33.1f, Y = 34.4f } }, // Acrocat
{ 13137, new PositionInfo { X = 12.0f, Y = 18.7f } }, // Agavoides
{ 13133, new PositionInfo { X = 30.5f, Y = 17.1f } }, // Alexandrian Clipper
{ 13130, new PositionInfo { X = 26.9f, Y = 17.6f } }, // Blazing Soul
{ 13127, new PositionInfo { X = 35.9f, Y = 27.2f } }, // Brownie
{ 13136, new PositionInfo { X = 17.8f, Y = 21.9f } }, // Everlasting Yew
{ 13124, new PositionInfo { X = 09.9f, Y = 36.2f } }, // Fluid Soul
{ 13131, new PositionInfo { X = 36.5f, Y = 18.3f } }, // Gargantua
{ 13120, new PositionInfo { X = 32.3f, Y = 27.1f } }, // Gemkeeper
{ 13129, new PositionInfo { X = 26.6f, Y = 08.7f } }, // Matchlock Scorpion
{ 13118, new PositionInfo { X = 33.2f, Y = 16.3f } }, // Outrunner
{ 13132, new PositionInfo { X = 30.3f, Y = 12.5f } }, // Pineapple
{ 13125, new PositionInfo { X = 13.0f, Y = 34.5f } }, // Remembird
{ 13119, new PositionInfo { X = 28.4f, Y = 31.6f } }, // Seeker Bat
{ 13139, new PositionInfo { X = 18.0f, Y = 15.2f } }, // Timberman
{ 13122, new PositionInfo { X = 17.7f, Y = 30.5f } }, // Torbalan
{ 13138, new PositionInfo { X = 11.8f, Y = 12.9f } }, // Walking Tree
};

public enum OpenType {
Expand Down
12 changes: 3 additions & 9 deletions HuntBuddy/MobHuntEntry.cs
Original file line number Diff line number Diff line change
@@ -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; }
Expand All @@ -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; }
}
20 changes: 6 additions & 14 deletions HuntBuddy/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Numerics;
using System.Threading.Tasks;

using Dalamud.Interface.Internal;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
Expand All @@ -19,10 +18,8 @@

using ImGuiNET;

using Lumina.Data.Files;
using Lumina.Excel;
using Lumina.Excel.GeneratedSheets;
using Lumina.Extensions;
using Lumina.Text;

namespace HuntBuddy;
Expand Down Expand Up @@ -60,7 +57,7 @@ public static Plugin Instance {
internal set;
} = null!;

public Plugin(DalamudPluginInterface pluginInterface) {
public Plugin(IDalamudPluginInterface pluginInterface) {
Instance = this;

pluginInterface.Create<Service>();
Expand Down Expand Up @@ -91,6 +88,7 @@ public Plugin(DalamudPluginInterface pluginInterface) {
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;
}

Expand All @@ -117,6 +115,7 @@ private void ClientStateOnTerritoryChanged(ushort e) {
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) {
Expand All @@ -128,6 +127,7 @@ private void Dispose(bool disposing) {
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();

Expand Down Expand Up @@ -298,11 +298,10 @@ public unsafe void ReloadData() {
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 {
Expand Down Expand Up @@ -334,13 +333,6 @@ public unsafe void ReloadData() {
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);
Expand Down
4 changes: 2 additions & 2 deletions HuntBuddy/PluginCommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ private void RemoveCommandHandlers() {
}

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);

Expand Down
8 changes: 7 additions & 1 deletion HuntBuddy/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace HuntBuddy;

public class Service {
[PluginService]
public static DalamudPluginInterface PluginInterface {
public static IDalamudPluginInterface PluginInterface {
get;
set;
} = null!;
Expand Down Expand Up @@ -59,4 +59,10 @@ public static IPluginLog PluginLog {
get;
set;
} = null!;

[PluginService]
public static ITextureProvider TextureProvider {
get;
set;
} = null!;
}
14 changes: 11 additions & 3 deletions HuntBuddy/Structs/MobHuntStruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public enum BillEnum: uint {
EwRank2,
EwRank3,
EwElite,
DtRank1,
DtRank2,
DtRank3,
DtElite,
}

[Flags]
Expand All @@ -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;
}
29 changes: 27 additions & 2 deletions HuntBuddy/Utils/InterfaceUtil.cs
Original file line number Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -36,7 +42,26 @@ public static void DrawHuntIcon(MobHuntEntry mobHuntEntry) {
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>
Expand Down
24 changes: 12 additions & 12 deletions HuntBuddy/packages.lock.json
Original file line number Diff line number Diff line change
@@ -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=="
}
}
}
}

0 comments on commit bd9fdf4

Please sign in to comment.