diff --git a/DownloadTask.cs b/DownloadTask.cs index 6811e7f..cfab201 100644 --- a/DownloadTask.cs +++ b/DownloadTask.cs @@ -2,7 +2,6 @@ using System.Text; using Blake3; using Dalamud.Interface.Internal.Notifications; -using Dalamud.Logging; using gfoidl.Base64; using Heliosphere.Exceptions; using Heliosphere.Model; @@ -196,7 +195,7 @@ private async Task DownloadFiles(IDownloadTask_GetVersion info) { Directory.Move(oldName, this.PenumbraModPath); } } else if (directories.Length > 1) { - PluginLog.Warning($"multiple heliosphere mod directories found for {info.Variant.Package.Name} - not attempting a rename"); + Plugin.Log.Warning($"multiple heliosphere mod directories found for {info.Variant.Package.Name} - not attempting a rename"); } var filesPath = Path.Join(this.PenumbraModPath, "files"); @@ -371,7 +370,7 @@ private IEnumerable DownloadBatchedFiles(IDownloadTask_GetVersion_NeededFi foreach (var path in toDuplicate) { if (!File.Exists(path)) { - PluginLog.Warning($"{path} was supposed to be duplicated but no longer exists"); + Plugin.Log.Warning($"{path} was supposed to be duplicated but no longer exists"); continue; } @@ -521,7 +520,7 @@ private static void GetExtensionsAndDiscriminators(IReadOnlyCollection {newPath}"); + Plugin.Log.Debug($" {oldPath} -> {newPath}"); Directory.Move(oldPath, newPath); if (!await PathHelper.WaitToExist(newPath)) { throw new DirectoryNotFoundException($"Directory '{newPath}' could not be found after waiting"); @@ -307,7 +306,7 @@ await this.Plugin.Framework.RunOnFrameworkThread(() => { } private async Task<(string, string[])> MigrateOldDirectory(HeliosphereMeta meta, string penumbraPath, string directory) { - PluginLog.Debug($"Migrating old folder name layout for {directory}"); + Plugin.Log.Debug($"Migrating old folder name layout for {directory}"); var variant = await Plugin.GraphQl.GetVariant.ExecuteAsync(meta.VersionId); if (variant.Data?.GetVersion == null) { throw new Exception($"no variant for version id {meta.VersionId}"); @@ -322,14 +321,14 @@ await this.Plugin.Framework.RunOnFrameworkThread(() => { var parts = newName.Split('-'); - PluginLog.Debug($" {oldPath} -> {newPath}"); + Plugin.Log.Debug($" {oldPath} -> {newPath}"); Directory.Move(oldPath, newPath); await this.Plugin.Framework.RunOnFrameworkThread(() => { this.Plugin.Penumbra.AddMod(newName); this.Plugin.Penumbra.ReloadMod(directory); }); - PluginLog.Debug(" writing new meta"); + Plugin.Log.Debug(" writing new meta"); var json = JsonConvert.SerializeObject(meta, Formatting.Indented); var path = Path.Join(penumbraPath, newName, "heliosphere.json"); await using var file = File.Create(path); @@ -356,7 +355,7 @@ internal class InstalledPackage : IDisposable { internal string Author { get; } internal string CoverImagePath { get; } - internal TextureWrap? CoverImage { get; private set; } + internal IDalamudTextureWrap? CoverImage { get; private set; } internal List InternalVariants { get; } internal IReadOnlyList Variants => this.InternalVariants.ToImmutableList(); diff --git a/Plugin.cs b/Plugin.cs index 7785e07..b0f541a 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -2,19 +2,15 @@ using System.Net.Http.Headers; using System.Text.Json; using System.Text.RegularExpressions; -using Dalamud.Game; -using Dalamud.Game.ClientState; -using Dalamud.Game.Command; -using Dalamud.Game.Gui; +using Dalamud.Interface.Internal; using Dalamud.Interface.Internal.Notifications; using Dalamud.IoC; -using Dalamud.Logging; using Dalamud.Plugin; +using Dalamud.Plugin.Services; using Heliosphere.Exceptions; using Heliosphere.Model.Generated; using Heliosphere.Ui; using Heliosphere.Util; -using ImGuiScene; using Microsoft.Extensions.DependencyInjection; using Sentry; using Sentry.Extensibility; @@ -34,21 +30,25 @@ public class Plugin : IDalamudPlugin { internal static GameFont GameFont { get; private set; } internal static DalamudPluginInterface PluginInterface { get; private set; } + internal static IPluginLog Log { get; private set; } [PluginService] internal DalamudPluginInterface Interface { get; init; } [PluginService] - internal ChatGui ChatGui { get; init; } + internal IChatGui ChatGui { get; init; } [PluginService] - internal ClientState ClientState { get; init; } + internal IClientState ClientState { get; init; } [PluginService] - internal CommandManager CommandManager { get; init; } + internal ICommandManager CommandManager { get; init; } [PluginService] - internal Framework Framework { get; init; } + internal IFramework Framework { get; init; } + + [PluginService] + private IPluginLog PluginLog { get; init; } internal Configuration Config { get; } internal DownloadCodes DownloadCodes { get; } @@ -62,7 +62,7 @@ public class Plugin : IDalamudPlugin { private IDisposable Sentry { get; } internal bool IntegrityFailed { get; private set; } - internal Guard> CoverImages { get; } = new(new Dictionary()); + internal Guard> CoverImages { get; } = new(new Dictionary()); public Plugin() { var checkTask = Task.Run(async () => { @@ -78,6 +78,7 @@ public Plugin() { Instance = this; GameFont = new GameFont(this); PluginInterface = this.Interface!; + Log = this.PluginLog!; this.Sentry = SentrySdk.Init(o => { o.Dsn = "https://540decab4a5941f1ba826cd50b4b6efd@sentry.heliosphere.app/4"; @@ -107,7 +108,7 @@ public Plugin() { try { DependencyLoader.Load(); } catch (Exception ex) { - PluginLog.Error(ex, "Failed to initialise native libraries (probably AV)"); + Log.Error(ex, "Failed to initialise native libraries (probably AV)"); startWithAvWarning = true; this.IntegrityFailed = true; } @@ -281,6 +282,7 @@ public class FileList { public Dictionary>> Files { get; init; } } +// ReSharper disable once ClassNeverInstantiated.Global public class FileListSerializer : ScalarSerializer { public FileListSerializer(string typeName = "FileList") : base(typeName) { } @@ -296,6 +298,7 @@ protected override JsonElement Format(FileList runtimeValue) { } } +// ReSharper disable once ClassNeverInstantiated.Global public class OptionsSerializer : ScalarSerializer>> { public OptionsSerializer(string typeName = "Options") : base(typeName) { } @@ -314,6 +317,7 @@ public class InstallerImageList { public Dictionary> Images { get; init; } } +// ReSharper disable once ClassNeverInstantiated.Global public class InstallerImageListSerializer : ScalarSerializer { public InstallerImageListSerializer(string typeName = "InstallerImageList") : base(typeName) { } @@ -346,6 +350,7 @@ public class BatchedFile { public ulong SizeUncompressed => this.size_uncompressed; } +// ReSharper disable once ClassNeverInstantiated.Global public class BatchListSerializer : ScalarSerializer { public BatchListSerializer(string typeName = "BatchList") : base(typeName) { } @@ -366,6 +371,7 @@ public class FileSwaps { public Dictionary Swaps { get; init; } } +// ReSharper disable once ClassNeverInstantiated.Global public class FileSwapsSerializer : ScalarSerializer { public FileSwapsSerializer(string typeName = "FileSwaps") : base(typeName) { } @@ -381,6 +387,7 @@ protected override JsonElement Format(FileSwaps runtimeValue) { } } +// ReSharper disable once ClassNeverInstantiated.Global public class GraphqlJsonSerializer : ScalarSerializer { public GraphqlJsonSerializer(string typeName = "JSON") : base(typeName) { } diff --git a/Server.cs b/Server.cs index 8d997cb..d3708c2 100644 --- a/Server.cs +++ b/Server.cs @@ -4,7 +4,6 @@ using System.Security.Cryptography; using System.Text; using Dalamud.Interface.Internal.Notifications; -using Dalamud.Logging; using gfoidl.Base64; using Heliosphere.Ui; using Heliosphere.Util; @@ -419,7 +418,7 @@ private bool OneClickPassed(string? providedPassword, bool holdingShift) { Base64.Default.Decode(this.Plugin.Config.OneClickHash) ); } catch (Exception ex) { - PluginLog.LogWarning(ex, "Failed to decode one-click password"); + Plugin.Log.Warning(ex, "Failed to decode one-click password"); } return false; diff --git a/Ui/DownloadStatusWindow.cs b/Ui/DownloadStatusWindow.cs index db00f8c..05a4ce2 100644 --- a/Ui/DownloadStatusWindow.cs +++ b/Ui/DownloadStatusWindow.cs @@ -1,6 +1,6 @@ using System.Diagnostics; using System.Numerics; -using Dalamud.Interface; +using Dalamud.Interface.Utility; using Heliosphere.Util; using ImGuiNET; diff --git a/Ui/InstallerWindow.cs b/Ui/InstallerWindow.cs index 826fd94..ea5c017 100644 --- a/Ui/InstallerWindow.cs +++ b/Ui/InstallerWindow.cs @@ -1,11 +1,11 @@ using System.Numerics; -using Dalamud.Interface; +using Dalamud.Interface.Internal; using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.Utility; using Heliosphere.Exceptions; using Heliosphere.Model.Generated; using Heliosphere.Util; using ImGuiNET; -using ImGuiScene; using StrawberryShake; namespace Heliosphere.Ui; @@ -22,7 +22,7 @@ internal class InstallerWindow : IDrawable { private string? DownloadKey { get; } private class ImageCache { - internal Dictionary HashImages { get; } = new(); + internal Dictionary HashImages { get; } = new(); internal Dictionary PathHashes { get; } = new(); } @@ -314,7 +314,7 @@ private void DrawTableColumn2(IReadOnlyList variants, TextureWrap? cover, string? downloadKey) { + private MultiVariantPromptWindow(Plugin plugin, Guid packageId, IMultiVariantInstall_Package package, Dictionary variants, IDalamudTextureWrap? cover, string? downloadKey) { this.Plugin = plugin; this.PackageId = packageId; this.Package = package; @@ -132,7 +132,7 @@ internal static async Task Open(Plugin plugin, Guid pa throw new Exception("Variants with no versions specified."); } - TextureWrap? cover = null; + IDalamudTextureWrap? cover = null; if (pkg.Images.Count > 0) { try { using var imgResp = await DownloadTask.GetImage(packageId, pkg.Images[0].Id); diff --git a/Ui/PromptWindow.cs b/Ui/PromptWindow.cs index c20fa85..1830cf5 100644 --- a/Ui/PromptWindow.cs +++ b/Ui/PromptWindow.cs @@ -1,9 +1,9 @@ +using Dalamud.Interface.Internal; using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Style; using Heliosphere.Model.Generated; using Heliosphere.Util; using ImGuiNET; -using ImGuiScene; namespace Heliosphere.Ui; @@ -19,9 +19,9 @@ internal class PromptWindow : IDrawable { private bool _openInPenumbra; private string? _collection; private readonly string? _downloadKey; - private readonly TextureWrap? _coverImage; + private readonly IDalamudTextureWrap? _coverImage; - private PromptWindow(Plugin plugin, Guid packageId, IInstallerWindow_GetVersion info, Guid versionId, string version, TextureWrap? coverImage, string? downloadKey) { + private PromptWindow(Plugin plugin, Guid packageId, IInstallerWindow_GetVersion info, Guid versionId, string version, IDalamudTextureWrap? coverImage, string? downloadKey) { this.Plugin = plugin; this.PackageId = packageId; this.Info = info; @@ -44,7 +44,7 @@ internal static async Task Open(Plugin plugin, Guid packageId, Gui throw new Exception("Invalid package install URI."); } - TextureWrap? cover = null; + IDalamudTextureWrap? cover = null; if (info.Variant.Package.Images.Count > 0) { var coverImage = info.Variant.Package.Images[0]; diff --git a/Ui/Tabs/Manager.cs b/Ui/Tabs/Manager.cs index 78760fd..a70bb7f 100644 --- a/Ui/Tabs/Manager.cs +++ b/Ui/Tabs/Manager.cs @@ -4,7 +4,7 @@ using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Interface; using Dalamud.Interface.Internal.Notifications; -using Dalamud.Logging; +using Dalamud.Interface.Utility; using Dalamud.Plugin; using Heliosphere.Model; using Heliosphere.Model.Api; @@ -464,7 +464,7 @@ void DrawRefreshButton(HeliosphereMeta pkg, bool forceRefresh, Guard { - PluginLog.Debug($"refreshing info and versions for {pkg.Id}"); + Plugin.Log.Debug($"refreshing info and versions for {pkg.Id}"); // get normal info await this.GetInfo(pkg.VariantId); @@ -731,7 +731,7 @@ private async Task DownloadUpdatesInner(bool useConfig) { this.Plugin.ChatGui.Print(moreInfo); } - private async void Login(object? sender, EventArgs eventArgs) { + private async void Login() { if (this.Plugin.Interface.IsAutoUpdateComplete) { await this.DownloadUpdates(true); } else { diff --git a/Util/DependencyHelper.cs b/Util/DependencyHelper.cs index 9f547d9..a4dddd3 100644 --- a/Util/DependencyHelper.cs +++ b/Util/DependencyHelper.cs @@ -1,4 +1,3 @@ -using Dalamud.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; @@ -38,7 +37,7 @@ internal static async Task CheckDependencies(Plugin plugin) { continue; } - PluginLog.Warning($"Missing dependency {name} with file name {dep}"); + Plugin.Log.Warning($"Missing dependency {name} with file name {dep}"); showWarning = true; } diff --git a/Util/ErrorHelper.cs b/Util/ErrorHelper.cs index e9fbcd5..75dff2c 100644 --- a/Util/ErrorHelper.cs +++ b/Util/ErrorHelper.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using System.Text; -using Dalamud.Logging; using Heliosphere.Exceptions; using Newtonsoft.Json; using Sentry; @@ -59,7 +58,7 @@ internal static void Handle(Exception ex, string message) { }; }); - PluginLog.LogError(ex, $"[{errorId}] {message}"); + Plugin.Log.Error(ex, $"[{errorId}] {message}"); } internal static bool IsAntiVirus(this Exception ex) { @@ -86,7 +85,7 @@ internal static bool IsAntiVirus(this Exception ex) { return new DriveInfo(dirInfo.Root.FullName); } } catch (Exception ex) { - PluginLog.LogError(ex, "Could not get drive info for error reporting"); + Plugin.Log.Error(ex, "Could not get drive info for error reporting"); } return null; diff --git a/Util/ImGuiHelper.cs b/Util/ImGuiHelper.cs index 5f596f6..ff6c388 100644 --- a/Util/ImGuiHelper.cs +++ b/Util/ImGuiHelper.cs @@ -5,10 +5,11 @@ using System.Text; using Dalamud.Interface; using Dalamud.Interface.Colors; +using Dalamud.Interface.Internal; using Dalamud.Interface.Style; +using Dalamud.Interface.Utility; using Heliosphere.Ui; using ImGuiNET; -using ImGuiScene; using Markdig; using Markdig.Renderers; using Markdig.Syntax; @@ -117,7 +118,7 @@ internal static OnDispose TextWrap(float? pos = null) { return new OnDispose(ImGui.PopStyleColor); } - internal static void ImageFullWidth(TextureWrap wrap, float maxHeight = 0f, bool centred = false) { + internal static void ImageFullWidth(IDalamudTextureWrap wrap, float maxHeight = 0f, bool centred = false) { // get the available area var contentAvail = ImGui.GetContentRegionAvail(); @@ -612,7 +613,7 @@ private class LinkInlineRenderer : MarkdownObjectRenderer LoadImageAsync(UiBuilder builder, byte[] buffer) { + internal static async Task LoadImageAsync(UiBuilder builder, byte[] buffer) { if (buffer.Length >= 12 && buffer.AsSpan()[..4].SequenceEqual("RIFF"u8) && buffer.AsSpan()[8..12].SequenceEqual("WEBP"u8)) { return await WebPHelper.LoadAsync(builder, buffer); } diff --git a/Util/WebPHelper.cs b/Util/WebPHelper.cs index ad69dab..3d91a28 100644 --- a/Util/WebPHelper.cs +++ b/Util/WebPHelper.cs @@ -1,18 +1,17 @@ using Dalamud.Interface; -using Dalamud.Logging; +using Dalamud.Interface.Internal; using Dalamud.Memory; -using ImGuiScene; using WebPDotNet; namespace Heliosphere.Util; internal static class WebPHelper { - internal static async Task LoadAsync(UiBuilder builder, byte[] imageBytes) { + internal static async Task LoadAsync(UiBuilder builder, byte[] imageBytes) { const int bytesPerPixel = 4; using var image = WebP.WebPDecodeRGBA(imageBytes); if (image.NativePtr == nint.Zero) { - PluginLog.LogWarning("webp image had a null data pointer"); + Plugin.Log.Warning("webp image had a null data pointer"); return null; } diff --git a/packages.lock.json b/packages.lock.json index f031065..1cf9e8e 100644 --- a/packages.lock.json +++ b/packages.lock.json @@ -10,9 +10,9 @@ }, "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==" }, "gfoidl.Base64": { "type": "Direct", @@ -77,9 +77,9 @@ }, "Penumbra.Api": { "type": "Direct", - "requested": "[1.0.9, )", - "resolved": "1.0.9", - "contentHash": "UKFJNy9dg3VZ5ztsu8rAIaGWCXloLDtTCYHV5Tjvr2xRgo+pTJkYBY3DRLQFIR0iF5S+0cnYlgIRj+vp4mTCLg==" + "requested": "[1.0.10, )", + "resolved": "1.0.10", + "contentHash": "wUEhhmqAYzP8caAxgx0e5r2nxVdpPGwGOUW9oL7yyfWb6CY/LA3DL3L/nuUs1cFIxlUMmYPMn9nDXPup7Ir/zw==" }, "Semver": { "type": "Direct",