Skip to content

Commit

Permalink
update for dawntrail
Browse files Browse the repository at this point in the history
  • Loading branch information
lichie567 committed Jul 3, 2024
1 parent 114bf4a commit 83b0944
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 41 deletions.
10 changes: 5 additions & 5 deletions LMeter/ACT/IpcClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class IpcClient : LogClient

public IpcClient(ActConfig config) : base(config)
{
_subscriptionReceiver = Singletons.Get<DalamudPluginInterface>().GetIpcProvider<JObject, bool>(LMeterSubscriptionIpcEndpoint);
_subscriptionReceiver = Singletons.Get<IDalamudPluginInterface>().GetIpcProvider<JObject, bool>(LMeterSubscriptionIpcEndpoint);
_subscriptionReceiver.RegisterFunc(ReceiveIpcMessage);
}

Expand All @@ -46,7 +46,7 @@ public override void Start()
try
{
this.Status = ConnectionStatus.Connecting;
bool result = Singletons.Get<DalamudPluginInterface>()
bool result = Singletons.Get<IDalamudPluginInterface>()
.GetIpcSubscriber<bool>(IinactListeningIpcEndpoint).InvokeFunc();

Singletons.Get<IPluginLog>().Info("Check if IINACT installed and running: " + result);
Expand All @@ -66,7 +66,7 @@ public override void Start()
Singletons.Get<IPluginLog>().Info("Successfully discovered IINACT IPC endpoint");
try
{
bool result = Singletons.Get<DalamudPluginInterface>()
bool result = Singletons.Get<IDalamudPluginInterface>()
.GetIpcSubscriber<string, bool>(IinactSubscribeIpcEndpoint)
.InvokeFunc(LMeterSubscriptionIpcEndpoint);

Expand All @@ -85,7 +85,7 @@ public override void Start()

try
{
Singletons.Get<DalamudPluginInterface>()
Singletons.Get<IDalamudPluginInterface>()
.GetIpcSubscriber<JObject, bool>(IinactProviderEditEndpoint)
.InvokeAction(SubscriptionMessageObject);

Expand Down Expand Up @@ -126,7 +126,7 @@ public override void Shutdown()

try
{
bool result = Singletons.Get<DalamudPluginInterface>()
bool result = Singletons.Get<IDalamudPluginInterface>()
.GetIpcSubscriber<string, bool>(IinactUnsubscribeIpcEndpoint)
.InvokeFunc(LMeterSubscriptionIpcEndpoint);

Expand Down
2 changes: 1 addition & 1 deletion LMeter/Config/MeterListConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Interface.ImGuiNotification;
using ImGuiNET;
using LMeter.Helpers;
using LMeter.Meter;
Expand Down
2 changes: 1 addition & 1 deletion LMeter/Helpers/CharacterState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static bool IsInGoldenSaucer()

public static Job GetCharacterJob()
{
PlayerCharacter? player = Singletons.Get<IClientState>().LocalPlayer;
IPlayerCharacter? player = Singletons.Get<IClientState>().LocalPlayer;
if (player is null)
{
return Job.UKN;
Expand Down
7 changes: 3 additions & 4 deletions LMeter/Helpers/ClipRectsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
Expand Down Expand Up @@ -144,7 +143,7 @@ public unsafe void Update()
{
_clipRects.Clear();

AtkStage* stage = AtkStage.GetSingleton();
AtkStage* stage = AtkStage.Instance();
if (stage == null) { return; }

RaptureAtkUnitManager* manager = stage->RaptureAtkUnitManager;
Expand All @@ -157,13 +156,13 @@ public unsafe void Update()
{
try
{
AtkUnitBase* addon = *(AtkUnitBase**)Unsafe.AsPointer(ref loadedUnitsList->EntriesSpan[i]);
AtkUnitBase* addon = *(AtkUnitBase**)Unsafe.AsPointer(ref loadedUnitsList->Entries[i]);
if (addon == null || !addon->IsVisible || addon->WindowNode == null || addon->Scale == 0)
{
continue;
}

string? name = Marshal.PtrToStringAnsi(new IntPtr(addon->Name));
string? name = addon->NameString;
if (name == null || !AddonNames.Contains(name))
{
continue;
Expand Down
2 changes: 1 addition & 1 deletion LMeter/Helpers/ConfigHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.IO;
using System.IO.Compression;
using System.Text;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Interface.ImGuiNotification;
using Dalamud.Plugin.Services;
using ImGuiNET;
using LMeter.Config;
Expand Down
3 changes: 1 addition & 2 deletions LMeter/Helpers/DrawHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.ImGuiNotification;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Interface.Textures.TextureWraps;
using Dalamud.Plugin.Services;
using ImGuiNET;

Expand Down
4 changes: 2 additions & 2 deletions LMeter/Helpers/FontsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public class FontsManager : IDisposable
{
private readonly Dictionary<string, IFontHandle> _imGuiFonts = [];
private string[] _fontList;
private readonly UiBuilder _uiBuilder;
private readonly IUiBuilder _uiBuilder;

public const string DalamudFontKey = "Dalamud Font";
public static readonly List<string> DefaultFontKeys = ["Expressway_24", "Expressway_20", "Expressway_16"];
public static string DefaultBigFontKey => DefaultFontKeys[0];
public static string DefaultMediumFontKey => DefaultFontKeys[1];
public static string DefaultSmallFontKey => DefaultFontKeys[2];

public FontsManager(UiBuilder uiBuilder, IEnumerable<FontData> fonts)
public FontsManager(IUiBuilder uiBuilder, IEnumerable<FontData> fonts)
{
_uiBuilder = uiBuilder;
_fontList = [DalamudFontKey];
Expand Down
24 changes: 11 additions & 13 deletions LMeter/Helpers/TexturesCache.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
using Dalamud.Interface;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Textures;
using Dalamud.Interface.Textures.TextureWraps;
using Dalamud.Plugin.Services;
using Dalamud.Utility;
using Lumina.Data.Files;
using static Dalamud.Plugin.Services.ITextureProvider;

namespace LMeter.Helpers
{
Expand All @@ -24,19 +23,17 @@ public TexturesCache()
bool hdIcon = true,
bool greyScale = false)
{
IconFlags flags = hdIcon ? IconFlags.HiRes : IconFlags.None;

if (!greyScale)
{
return Singletons.Get<ITextureProvider>().GetIcon(iconId + stackCount, flags);
return Singletons.Get<ITextureProvider>().GetFromGameIcon(iconId + stackCount).GetWrapOrDefault();
}

if (_desaturatedCache.TryGetValue(iconId + stackCount, out IDalamudTextureWrap? t))
{
return t;
}

string? path = Singletons.Get<ITextureProvider>().GetIconPath(iconId + stackCount, flags);
string? path = Singletons.Get<ITextureProvider>().GetIconPath(new GameIconLookup(iconId: iconId, hiRes: hdIcon));
if (path != null)
{
path = Singletons.Get<ITextureSubstitutionProvider>().GetSubstitutedPath(path);
Expand All @@ -55,16 +52,17 @@ public TexturesCache()
private static IDalamudTextureWrap? GetDesaturatedTextureWrap(string path)
{
TexFile? file = Singletons.Get<IDataManager>().GetFile<TexFile>(path);
if (file == null) { return null; }
if (file is null)
{
return null;
}

UiBuilder uiBuilder = Singletons.Get<UiBuilder>();
byte[] bytes = file.GetRgbaImageData();
ConvertBytes(ref bytes);

return uiBuilder.LoadImageRaw(bytes, file.Header.Width, file.Header.Height, 4);
DesaturateBytes(ref bytes);
return Singletons.Get<ITextureProvider>().CreateFromRaw(RawImageSpecification.Rgba32(file.Header.Width, file.Header.Height), bytes);
}

private static void ConvertBytes(ref byte[] bytes)
private static void DesaturateBytes(ref byte[] bytes)
{
if (bytes.Length % 4 != 0)
{
Expand Down
6 changes: 3 additions & 3 deletions LMeter/Helpers/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static Vector2 GetAnchoredPosition(Vector2 position, Vector2 size, DrawAn
};
}

public static GameObject? FindTargetOfTarget(GameObject? player, GameObject? target)
public static IGameObject? FindTargetOfTarget(IGameObject? player, IGameObject? target)
{
if (target == null)
{
Expand All @@ -43,8 +43,8 @@ public static Vector2 GetAnchoredPosition(Vector2 position, Vector2 size, DrawAn
IObjectTable objectTable = Singletons.Get<IObjectTable>();
for (int i = 0; i < 200; i += 2)
{
GameObject? actor = objectTable[i];
if (actor?.ObjectId == target.TargetObjectId)
IGameObject? actor = objectTable[i];
if (actor?.GameObjectId == target.TargetObjectId)
{
return actor;
}
Expand Down
2 changes: 1 addition & 1 deletion LMeter/LMeter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

<!-- NuGet Packages -->
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.12" />
<PackageReference Include="DalamudPackager" Version="2.1.13" />
</ItemGroup>

<!-- Dalamud Packager Task-->
Expand Down
12 changes: 6 additions & 6 deletions LMeter/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
using System.Reflection;
using Dalamud.Game;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Interface;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Textures.TextureWraps;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using LMeter.Act;
Expand Down Expand Up @@ -36,7 +35,7 @@ public Plugin(
IClientState clientState,
ICommandManager commandManager,
ICondition condition,
DalamudPluginInterface pluginInterface,
IDalamudPluginInterface pluginInterface,
IDataManager dataManager,
IFramework framework,
IGameGui gameGui,
Expand Down Expand Up @@ -84,7 +83,7 @@ INotificationManager notificationManager
Singletons.Register(new TexturesCache());

// Load Icon Texure
Plugin.IconTexture = LoadIconTexture(pluginInterface.UiBuilder);
Plugin.IconTexture = LoadIconTexture(textureProvider);

// Load changelog
Plugin.Changelog = LoadChangelog();
Expand Down Expand Up @@ -126,7 +125,7 @@ INotificationManager notificationManager
Singletons.Register(new PluginManager(clientState, commandManager, pluginInterface, config));
}

private static IDalamudTextureWrap? LoadIconTexture(UiBuilder uiBuilder)
private static IDalamudTextureWrap? LoadIconTexture(ITextureProvider textureProvider)
{
if (string.IsNullOrEmpty(AssemblyFileDir))
{
Expand All @@ -142,7 +141,8 @@ INotificationManager notificationManager
IDalamudTextureWrap? texture = null;
try
{
texture = uiBuilder.LoadImage(iconPath);
texture = textureProvider.GetFromFile(iconPath).GetWrapOrDefault();

}
catch (Exception ex)
{
Expand Down
4 changes: 2 additions & 2 deletions LMeter/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class PluginManager : IPluginDisposable
private readonly Vector2 _configSize = new(550, 550);

private readonly IClientState _clientState;
private readonly DalamudPluginInterface _pluginInterface;
private readonly IDalamudPluginInterface _pluginInterface;
private readonly ICommandManager _commandManager;
private readonly WindowSystem _windowSystem;
private readonly ConfigWindow _configRoot;
Expand All @@ -38,7 +38,7 @@ public class PluginManager : IPluginDisposable
public PluginManager(
IClientState clientState,
ICommandManager commandManager,
DalamudPluginInterface pluginInterface,
IDalamudPluginInterface pluginInterface,
LMeterConfig config)
{
_clientState = clientState;
Expand Down
2 changes: 2 additions & 0 deletions LMeter/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Version 0.3.1.0
- Updated plugin for Dawntrail
- Added support for Viper and Pictomancer
- Window clipping logic was improved
- Improved the Visibility options for more complex configurations

Expand Down

0 comments on commit 83b0944

Please sign in to comment.