diff --git a/Dalamud/Game/ChatHandlers.cs b/Dalamud/Game/ChatHandlers.cs index 91467bfc9..3e489af82 100644 --- a/Dalamud/Game/ChatHandlers.cs +++ b/Dalamud/Game/ChatHandlers.cs @@ -305,7 +305,7 @@ namespace Dalamud.Game { if (this.configuration.AutoUpdatePlugins) { - PluginManager.PrintUpdatedPlugins(updatedPlugins, Loc.Localize("DalamudPluginAutoUpdate", "Auto-update:")); + Service.Get().PrintUpdatedPlugins(updatedPlugins, Loc.Localize("DalamudPluginAutoUpdate", "Auto-update:")); notifications.AddNotification(Loc.Localize("NotificationUpdatedPlugins", "{0} of your plugins were updated.").Format(updatedPlugins.Count), Loc.Localize("NotificationAutoUpdate", "Auto-Update"), NotificationType.Info); } else diff --git a/Dalamud/Interface/Internal/DalamudInterface.cs b/Dalamud/Interface/Internal/DalamudInterface.cs index fe81caf81..b985522a9 100644 --- a/Dalamud/Interface/Internal/DalamudInterface.cs +++ b/Dalamud/Interface/Internal/DalamudInterface.cs @@ -250,6 +250,11 @@ namespace Dalamud.Interface.Internal /// public void OpenPluginInstaller() => this.pluginWindow.IsOpen = true; + /// + /// Opens the on the plugin changelogs. + /// + public void OpenPluginInstallerPluginChangelogs() => this.pluginWindow.OpenPluginChangelogs(); + /// /// Opens the . /// diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index 0a5308054..c7d8a2790 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -217,6 +217,16 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller this.imageCache.ClearIconCache(); } + /// + /// Open the window on the plugin changelogs. + /// + public void OpenPluginChangelogs() + { + this.categoryManager.CurrentGroupIdx = 3; + this.categoryManager.CurrentCategoryIdx = 2; + this.IsOpen = true; + } + private void DrawProgressOverlay() { var pluginManager = Service.Get(); @@ -501,7 +511,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller if (this.updatePluginCount > 0) { - PluginManager.PrintUpdatedPlugins(this.updatedPlugins, Locs.PluginUpdateHeader_Chatbox); + Service.Get().PrintUpdatedPlugins(this.updatedPlugins, Locs.PluginUpdateHeader_Chatbox); notifications.AddNotification(Locs.Notifications_UpdatesInstalled(this.updatePluginCount), Locs.Notifications_UpdatesInstalledTitle, NotificationType.Success); var installedGroupIdx = this.categoryManager.GroupList.TakeWhile( diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs index 003636cff..1889cbd50 100644 --- a/Dalamud/Plugin/Internal/PluginManager.cs +++ b/Dalamud/Plugin/Internal/PluginManager.cs @@ -17,6 +17,8 @@ using Dalamud.Game; using Dalamud.Game.Gui; using Dalamud.Game.Gui.Dtr; using Dalamud.Game.Text; +using Dalamud.Game.Text.SeStringHandling; +using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Interface.Internal; using Dalamud.Logging.Internal; using Dalamud.Plugin.Internal.Exceptions; @@ -50,6 +52,8 @@ internal partial class PluginManager : IDisposable, IServiceType private readonly DirectoryInfo devPluginDirectory; private readonly BannedPlugin[]? bannedPlugins; + private readonly DalamudLinkPayload openInstallerWindowPluginChangelogsLink; + [ServiceManager.ServiceDependency] private readonly DalamudConfiguration configuration = Service.Get(); @@ -101,6 +105,11 @@ internal partial class PluginManager : IDisposable, IServiceType throw new InvalidDataException("Couldn't deserialize banned plugins manifest."); } + this.openInstallerWindowPluginChangelogsLink = Service.Get().AddChatLinkHandler("Dalamud", 1003, (i, m) => + { + Service.GetNullable()?.OpenPluginInstallerPluginChangelogs(); + }); + this.ApplyPatches(); } @@ -169,25 +178,38 @@ internal partial class PluginManager : IDisposable, IServiceType /// /// The list of updated plugin metadata. /// The header text to send to chat prior to any update info. - public static void PrintUpdatedPlugins(List? updateMetadata, string header) + public void PrintUpdatedPlugins(List? updateMetadata, string header) { var chatGui = Service.Get(); if (updateMetadata is { Count: > 0 }) { - chatGui.Print(header); + chatGui.PrintChat(new XivChatEntry + { + Message = new SeString(new List() + { + new TextPayload(header), + new TextPayload(" ["), + new UIForegroundPayload(500), + this.openInstallerWindowPluginChangelogsLink, + new TextPayload(Loc.Localize("DalamudInstallerPluginChangelogHelp", "Open plugin changelogs") + " "), + RawPayload.LinkTerminator, + new UIForegroundPayload(0), + new TextPayload("]"), + }), + }); foreach (var metadata in updateMetadata) { if (metadata.WasUpdated) { - chatGui.Print(Locs.DalamudPluginUpdateSuccessful(metadata.Name, metadata.Version)); + chatGui.Print(Locs.DalamudPluginUpdateSuccessful(metadata.Name, metadata.Version) + (metadata.HasChangelog ? " " : string.Empty)); } else { chatGui.PrintChat(new XivChatEntry { - Message = Locs.DalamudPluginUpdateFailed(metadata.Name, metadata.Version), + Message = Locs.DalamudPluginUpdateFailed(metadata.Name, metadata.Version) + (metadata.HasChangelog ? " " : string.Empty), Type = XivChatType.Urgent, }); } @@ -975,6 +997,7 @@ internal partial class PluginManager : IDisposable, IServiceType ? metadata.UpdateManifest.TestingAssemblyVersion : metadata.UpdateManifest.AssemblyVersion)!, WasUpdated = true, + HasChangelog = !metadata.UpdateManifest.Changelog.IsNullOrWhitespace(), }; if (!dryRun) diff --git a/Dalamud/Plugin/Internal/Types/PluginUpdateStatus.cs b/Dalamud/Plugin/Internal/Types/PluginUpdateStatus.cs index 02eba7ea7..24ca5fe0f 100644 --- a/Dalamud/Plugin/Internal/Types/PluginUpdateStatus.cs +++ b/Dalamud/Plugin/Internal/Types/PluginUpdateStatus.cs @@ -26,4 +26,9 @@ internal class PluginUpdateStatus /// Gets or sets a value indicating whether the plugin was updated. /// public bool WasUpdated { get; set; } + + /// + /// Gets a value indicating whether the plugin has a changelog if it was updated. + /// + public bool HasChangelog { get; init; } }