Update to API 10 without the Kami touch

main
Liza 2024-07-09 23:01:17 +02:00
parent 2cf6ded1cd
commit 40bd0a0a2d
Signed by: liza
GPG Key ID: 7199F8D727D55F67
27 changed files with 92 additions and 101 deletions

View File

@ -51,7 +51,7 @@ public class Configuration : IPluginConfiguration
};
[NonSerialized]
private DalamudPluginInterface? pluginInterface;
public void Initialize(DalamudPluginInterface inputPluginInterface) => pluginInterface = inputPluginInterface;
private IDalamudPluginInterface? pluginInterface;
public void Initialize(IDalamudPluginInterface inputPluginInterface) => pluginInterface = inputPluginInterface;
public void Save() => pluginInterface!.SavePluginConfig(this);
}
}

View File

@ -8,7 +8,7 @@
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<Platforms>x64</Platforms>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
@ -27,7 +27,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.12" />
<PackageReference Include="DalamudPackager" Version="2.1.13" />
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private>

View File

@ -1,6 +1,8 @@
using System;
using System.Linq;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Textures;
using Dalamud.Interface.Textures.TextureWraps;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.Game;
using ImGuiScene;
@ -9,12 +11,12 @@ using Lumina.Excel.GeneratedSheets;
namespace CurrencyAlert.DataModels;
public class CurrencyInfo : IDisposable
public class CurrencyInfo
{
public uint ItemID { get; }
public string ItemName { get; } = string.Empty;
public uint IconID { get; }
public IDalamudTextureWrap? IconTexture { get; }
public ISharedImmediateTexture? IconTexture { get; }
public CurrencyInfo(CurrencyName currency)
{
@ -25,18 +27,9 @@ public class CurrencyInfo : IDisposable
{
ItemName = currencyItem.Name.ToDalamudString().TextValue;
IconID = currencyItem.Icon;
if (IconCache.Instance.GetIcon(IconID) is { } iconTexture)
{
IconTexture = iconTexture;
}
IconTexture = IconCache.Instance.GetIcon(IconID);
}
}
public void Dispose()
{
IconTexture?.Dispose();
}
public unsafe int GetCurrentQuantity() => InventoryManager.Instance()->GetInventoryItemCount(ItemID);
@ -70,8 +63,8 @@ public class CurrencyInfo : IDisposable
{
return LuminaCache<TomestonesItem>.Instance
.Where(tomestone => tomestone.Tomestones.Row is 3)
.First()
.Item.Row;
.FirstOrDefault()
?.Item?.Row ?? 0;
}
// This will always return the ItemID of whatever tomestone is not limited

View File

@ -1,4 +1,5 @@
using System.Numerics;
using Dalamud.Interface.Textures.TextureWraps;
using ImGuiNET;
using KamiLib.Configuration;
@ -15,9 +16,10 @@ public record TrackedCurrency(CurrencyName Name, Setting<int> Threshold, Setting
public void DrawIcon()
{
if (CurrencyInfo().IconTexture is { } icon)
var texture = CurrencyInfo().IconTexture;
if (texture != null && texture.TryGetWrap(out IDalamudTextureWrap? wrap, out _))
{
ImGui.Image(icon.ImGuiHandle, new Vector2(20.0f));
ImGui.Image(wrap.ImGuiHandle, new Vector2(20.0f));
}
}

View File

@ -30,12 +30,12 @@ internal class LocalizationManager : IDisposable
{
try
{
PluginLog.Information($"Loading Localization for {languageCode}");
//PluginLog.Information($"Loading Localization for {languageCode}");
Strings.Culture = new CultureInfo(languageCode);
}
catch (Exception ex)
{
PluginLog.Error(ex, "Unable to Load Localization");
//PluginLog.Error(ex, "Unable to Load Localization");
}
}
}
}

View File

@ -9,8 +9,8 @@ namespace CurrencyAlert;
public sealed class Plugin : IDalamudPlugin
{
public string Name => "CurrencyAlert";
public Plugin(DalamudPluginInterface pluginInterface)
public Plugin(IDalamudPluginInterface pluginInterface)
{
pluginInterface.Create<Service>();
@ -33,4 +33,4 @@ public sealed class Plugin : IDalamudPlugin
Service.CurrencyTracker.Dispose();
LocalizationManager.Cleanup();
}
}
}

View File

@ -9,7 +9,7 @@ namespace CurrencyAlert;
public class Service
{
[PluginService] public static DalamudPluginInterface PluginInterface { get; private set; } = null!;
[PluginService] public static IDalamudPluginInterface PluginInterface { get; private set; } = null!;
[PluginService] public static IFramework Framework { get; private set; } = null!;
[PluginService] public static IClientState ClientState { get; private set; } = null!;

View File

@ -59,7 +59,7 @@ public class CurrencyTracker : IDisposable
else
{
var lockoutRemaining = TimeSpan.FromMinutes(5) - timer.Elapsed;
PluginLog.Debug($"Zone Change Messages Suppressed, '{lockoutRemaining}' Remaining");
//PluginLog.Debug($"Zone Change Messages Suppressed, '{lockoutRemaining}' Remaining");
}
}

View File

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

View File

@ -8,6 +8,7 @@ namespace KamiLib.Atk;
public static class AtkValueHelper
{
/*
public static unsafe void PrintAtkValue(AtkValue value, int index)
{
switch (value.Type)
@ -44,6 +45,7 @@ public static class AtkValueHelper
break;
}
}
*/
}
public static class AtkValueExtensions
@ -52,4 +54,4 @@ public static class AtkValueExtensions
{
return Marshal.PtrToStringUTF8(new nint(value.String)) ?? "Unable to Allocate String";
}
}
}

View File

@ -96,11 +96,11 @@ public static unsafe class Node
foreach (var index in Enumerable.Range(0, uldManager.NodeListCount))
{
var currentNode = uldManager.NodeList[index];
if (currentNode->NodeID != nodeId) continue;
if (currentNode->NodeId != nodeId) continue;
return (T*) currentNode;
}
return null;
}
}
}

View File

@ -76,7 +76,7 @@ public static class BlacklistDraw
if (ImGui.InputTextWithHint("###TerritorySearch", Strings.Blacklist_Search, ref _searchString, 60, ImGuiInputTextFlags.AutoSelectAll))
{
_searchResults = Search(_searchString, 5);
PluginLog.Debug("Updating TerritorySearch Results");
//PluginLog.Debug("Updating TerritorySearch Results");
}
})
.AddAction(() => DisplayResults(_searchResults))

View File

@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Textures;
using Dalamud.Interface.Textures.TextureWraps;
using Dalamud.Logging;
using Dalamud.Utility;
using ImGuiScene;
@ -10,7 +12,7 @@ namespace KamiLib.Caching;
public class IconCache : IDisposable
{
private readonly Dictionary<uint, IDalamudTextureWrap?> iconTextures = new();
private readonly Dictionary<uint, ISharedImmediateTexture?> iconTextures = new();
private const string IconFilePath = "ui/icon/{0:D3}000/{1:D6}_hr1.tex";
@ -24,11 +26,6 @@ public class IconCache : IDisposable
public void Dispose()
{
foreach (var texture in iconTextures.Values)
{
texture?.Dispose();
}
iconTextures.Clear();
}
@ -39,25 +36,18 @@ public class IconCache : IDisposable
try
{
var path = IconFilePath.Format(iconId / 1000, iconId);
var tex = Service.TextureProvider.GetTextureFromGame(path);
var tex = Service.TextureProvider.GetFromGame(path);
if (tex is not null && tex.ImGuiHandle != nint.Zero)
{
iconTextures[iconId] = tex;
}
else
{
tex?.Dispose();
}
}
iconTextures[iconId] = tex;
}
catch (Exception ex)
{
PluginLog.LogError($"Failed loading texture for icon {iconId} - {ex.Message}");
//PluginLog.LogError($"Failed loading texture for icon {iconId} - {ex.Message}");
}
});
}
public IDalamudTextureWrap? GetIcon(uint iconId)
public ISharedImmediateTexture? GetIcon(uint iconId)
{
if (iconTextures.TryGetValue(iconId, out var value)) return value;

View File

@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using Dalamud;
using Dalamud.Game;
using Lumina.Excel;
namespace KamiLib.Caching;
@ -58,4 +59,4 @@ public class LuminaCache<T> : IEnumerable<T> where T : ExcelRow
public IEnumerator<T> GetEnumerator() => Service.DataManager.GetExcelSheet<T>()!.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}

View File

@ -60,7 +60,7 @@ public class CommandManager : IDisposable
{
var commandData = Command.GetCommandData(command.ToLower(), arguments.ToLower());
PluginLog.Debug($"[{KamiCommon.PluginName}] Received Command: {commandData}");
//PluginLog.Debug($"[{KamiCommon.PluginName}] Received Command: {commandData}");
Command.ProcessCommand(commandData, Commands);
}
}

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Numerics;
using Dalamud.Interface.Components;
using Dalamud.Interface.Textures.TextureWraps;
using Dalamud.Interface.Utility;
using ImGuiNET;
using KamiLib.Caching;
@ -41,11 +42,11 @@ public abstract class DrawList<T>
{
var icon = IconCache.Instance.GetIcon(iconID);
if (icon != null)
if (icon != null && icon.TryGetWrap(out IDalamudTextureWrap? wrap, out _))
{
DrawActions.Add(() =>
{
ImGui.Image(icon.ImGuiHandle, size, Vector2.Zero, Vector2.One, color);
ImGui.Image(wrap.ImGuiHandle, size, Vector2.Zero, Vector2.One, color);
});
}
@ -56,11 +57,11 @@ public abstract class DrawList<T>
{
var icon = IconCache.Instance.GetIcon(iconID);
if (icon != null)
if (icon != null && icon.TryGetWrap(out IDalamudTextureWrap? wrap, out _))
{
DrawActions.Add(() =>
{
ImGui.Image(icon.ImGuiHandle, size, Vector2.Zero, Vector2.One, Vector4.One with {W = transparency});
ImGui.Image(wrap.ImGuiHandle, size, Vector2.Zero, Vector2.One, Vector4.One with {W = transparency});
});
}

View File

@ -6,33 +6,33 @@ namespace KamiLib.Extensions;
public static class PartyListExtensions
{
public static IEnumerable<PartyMember> Alive(this IEnumerable<PartyMember> list)
public static IEnumerable<IPartyMember> Alive(this IEnumerable<IPartyMember> list)
{
return list.Where(member => member.GameObject != null && !member.GameObject.IsDead);
}
public static IEnumerable<PartyMember> WithRole(this IEnumerable<PartyMember> list, uint roleID)
public static IEnumerable<IPartyMember> WithRole(this IEnumerable<IPartyMember> list, uint roleID)
{
return list.Where(member => member.ClassJob.GameData?.Role == roleID);
}
public static IEnumerable<PartyMember> WithJob(this IEnumerable<PartyMember> list, uint jobID)
public static IEnumerable<IPartyMember> WithJob(this IEnumerable<IPartyMember> list, uint jobID)
{
return list.Where(member => member.ClassJob.Id == jobID);
}
public static IEnumerable<PartyMember> WithJob(this IEnumerable<PartyMember> list, List<uint> jobList)
public static IEnumerable<IPartyMember> WithJob(this IEnumerable<IPartyMember> list, List<uint> jobList)
{
return list.Where(member => jobList.Contains(member.ClassJob.Id));
}
public static IEnumerable<PartyMember> WithStatus(this IEnumerable<PartyMember> list, uint statusID)
public static IEnumerable<IPartyMember> WithStatus(this IEnumerable<IPartyMember> list, uint statusID)
{
return list.Where(member => member.HasStatus(statusID));
}
public static IEnumerable<PartyMember> WithStatus(this IEnumerable<PartyMember> list, List<uint> statusList)
public static IEnumerable<IPartyMember> WithStatus(this IEnumerable<IPartyMember> list, List<uint> statusList)
{
return list.Where(member => member.HasStatus(statusList));
}
}
}

View File

@ -6,13 +6,13 @@ namespace KamiLib.Extensions;
public static class PartyMemberExtensions
{
public static bool HasStatus(this PartyMember character, uint statusId)
public static bool HasStatus(this IPartyMember character, uint statusId)
{
return character.Statuses.Any(status => status.StatusId == statusId);
}
public static bool HasStatus(this PartyMember character, List<uint> statusList)
public static bool HasStatus(this IPartyMember character, List<uint> statusList)
{
return character.Statuses.Any(status => statusList.Contains(status.StatusId));
}
}
}

View File

@ -8,55 +8,55 @@ namespace KamiLib.Extensions;
public static class PlayerCharacterExtensions
{
public static bool HasStatus(this PlayerCharacter character, uint statusId)
public static bool HasStatus(this IPlayerCharacter character, uint statusId)
{
return character.StatusList.Any(status => status.StatusId == statusId);
}
public static bool HasStatus(this PlayerCharacter character, List<uint> statusList)
public static bool HasStatus(this IPlayerCharacter character, List<uint> statusList)
{
return character.StatusList.Any(status => statusList.Contains(status.StatusId));
}
public static bool HasOnlineStatus(this PlayerCharacter character, uint statusId)
public static bool HasOnlineStatus(this IPlayerCharacter character, uint statusId)
{
return character.OnlineStatus.Id == statusId;
}
public static int StatusCount(this PlayerCharacter character, List<uint> statusList)
public static int StatusCount(this IPlayerCharacter character, List<uint> statusList)
{
return character.StatusList.Count(status => statusList.Contains(status.StatusId));
}
public static bool HasPet(this PlayerCharacter character)
public static bool HasPet(this IPlayerCharacter character)
{
var ownedObjects = Service.ObjectTable.Where(obj => obj.OwnerId == character.ObjectId);
var ownedObjects = Service.ObjectTable.Where(obj => obj.OwnerId == character.GameObjectId);
return ownedObjects.Any(obj => obj.ObjectKind == ObjectKind.BattleNpc && (obj as BattleNpc)?.SubKind == (byte) BattleNpcSubKind.Pet);
return ownedObjects.Any(obj => obj.ObjectKind == ObjectKind.BattleNpc && (obj as IBattleNpc)?.SubKind == (byte) BattleNpcSubKind.Pet);
}
public static IEnumerable<PlayerCharacter> Alive(this IEnumerable<PlayerCharacter> list)
public static IEnumerable<IPlayerCharacter> Alive(this IEnumerable<IPlayerCharacter> list)
{
return list.Where(member => member.CurrentHp > 0);
}
public static IEnumerable<PlayerCharacter> WithJob(this IEnumerable<PlayerCharacter> list, uint jobID)
public static IEnumerable<IPlayerCharacter> WithJob(this IEnumerable<IPlayerCharacter> list, uint jobID)
{
return list.Where(member => member.ClassJob.Id == jobID);
}
public static IEnumerable<PlayerCharacter> WithJob(this IEnumerable<PlayerCharacter> list, List<uint> jobList)
public static IEnumerable<IPlayerCharacter> WithJob(this IEnumerable<IPlayerCharacter> list, List<uint> jobList)
{
return list.Where(member => jobList.Contains(member.ClassJob.Id));
}
public static IEnumerable<PlayerCharacter> WithStatus(this IEnumerable<PlayerCharacter> list, uint statusID)
public static IEnumerable<IPlayerCharacter> WithStatus(this IEnumerable<IPlayerCharacter> list, uint statusID)
{
return list.Where(member => member.HasStatus(statusID));
}
public static IEnumerable<PlayerCharacter> WithStatus(this IEnumerable<PlayerCharacter> list, List<uint> statusList)
public static IEnumerable<IPlayerCharacter> WithStatus(this IEnumerable<IPlayerCharacter> list, List<uint> statusList)
{
return list.Where(member => member.HasStatus(statusList));
}
}
}

View File

@ -1,4 +1,5 @@
using FFXIVClientStructs.FFXIV.Component.GUI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Component.GUI;
namespace KamiLib.Hooking;

View File

@ -23,10 +23,10 @@ public static class Safety
var callingClass = trace.GetMethod()?.DeclaringType;
var callingName = trace.GetMethod()?.Name;
PluginLog.Error($"Exception Source: {callingAssembly} :: {callingClass} :: {callingName}");
//PluginLog.Error($"Exception Source: {callingAssembly} :: {callingClass} :: {callingName}");
}
PluginLog.Error(exception, message ?? "Caught Exception Safely");
//PluginLog.Error(exception, message ?? "Caught Exception Safely");
}
}
}
}

View File

@ -19,7 +19,7 @@ public static class KamiCommon
private static Action _saveConfigFunction = null!;
public static void Initialize(DalamudPluginInterface pluginInterface, string pluginName, Action saveConfig)
public static void Initialize(IDalamudPluginInterface pluginInterface, string pluginName, Action saveConfig)
{
pluginInterface.Create<Service>();
@ -48,4 +48,4 @@ public static class KamiCommon
}
public static void SaveConfiguration() => _saveConfigFunction();
}
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<Platforms>x64</Platforms>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>

View File

@ -30,12 +30,12 @@ internal class LocalizationManager : IDisposable
{
try
{
PluginLog.Information($"Loading Localization for {languageCode}");
//PluginLog.Information($"Loading Localization for {languageCode}");
Strings.Culture = new CultureInfo(languageCode);
}
catch (Exception ex)
{
PluginLog.Error(ex, "Unable to Load Localization");
//PluginLog.Error(ex, "Unable to Load Localization");
}
}
}
}

View File

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Dalamud;
using Dalamud.Game;
using KamiLib.Caching;
using Lumina.Excel.GeneratedSheets;
@ -73,4 +74,4 @@ public class DutyLists
public bool IsType(uint dutyId, DutyType type) => GetDutyType(dutyId) == type;
public bool IsType(uint dutyId, IEnumerable<DutyType> types) => types.Any(type => IsType(dutyId, type));
}
}

View File

@ -6,7 +6,7 @@ namespace KamiLib;
internal class Service
{
[PluginService] public static DalamudPluginInterface PluginInterface { get; private set; } = null!;
[PluginService] public static IDalamudPluginInterface PluginInterface { get; private set; } = null!;
[PluginService] public static ICommandManager Commands { get; private set; } = null!;
[PluginService] public static IClientState ClientState { get; private set; } = null!;
[PluginService] public static IChatGui Chat { get; private set; } = null!;

View File

@ -88,7 +88,7 @@ public class TeleportManager : IDisposable
}
else
{
PluginLog.Error("User attempted to teleport to an aetheryte that is not unlocked");
//PluginLog.Error("User attempted to teleport to an aetheryte that is not unlocked");
UserError(Strings.Teleport_NotUnlocked);
}
}
@ -98,7 +98,7 @@ public class TeleportManager : IDisposable
return ChatLinkPayloads.First(payload => Equals(payload.Location, targetLocation)).Payload;
}
private void Teleport(AetheryteEntry aetheryte)
private void Teleport(IAetheryteEntry aetheryte)
{
try
{
@ -116,7 +116,7 @@ public class TeleportManager : IDisposable
}
catch (IpcNotReadyError)
{
PluginLog.Error("Teleport IPC not found");
//PluginLog.Error("Teleport IPC not found");
UserError(Strings.Teleport_InstallTeleporter);
}
}
@ -127,7 +127,7 @@ public class TeleportManager : IDisposable
Service.Toast.ShowError(error);
}
private string GetAetheryteName(AetheryteEntry aetheryte)
private string GetAetheryteName(IAetheryteEntry aetheryte)
{
var gameData = aetheryte.AetheryteData.GameData;
var placeName = gameData?.PlaceName.Value;
@ -135,7 +135,7 @@ public class TeleportManager : IDisposable
return placeName == null ? "[Name Lookup Failed]" : placeName.Name;
}
private bool AetheryteUnlocked(ExcelRow aetheryte, out AetheryteEntry? entry)
private bool AetheryteUnlocked(ExcelRow aetheryte, out IAetheryteEntry? entry)
{
if (Service.AetheryteList.Any(entry => entry.AetheryteId == aetheryte.RowId))
{