From 6dd918eaec8c6271d8d5abdcbfaf401d6de82453 Mon Sep 17 00:00:00 2001 From: Aireil <33433913+Aireil@users.noreply.github.com> Date: Fri, 4 Feb 2022 06:17:18 +0100 Subject: [PATCH] feat(PluginInstaller): add categories to Changelog tab --- .../Internal/PluginCategoryManager.cs | 8 +++- .../PluginInstaller/PluginInstallerWindow.cs | 44 +++++++++++++++---- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Dalamud/Interface/Internal/PluginCategoryManager.cs b/Dalamud/Interface/Internal/PluginCategoryManager.cs index 36693549a..cb7849c27 100644 --- a/Dalamud/Interface/Internal/PluginCategoryManager.cs +++ b/Dalamud/Interface/Internal/PluginCategoryManager.cs @@ -22,6 +22,8 @@ namespace Dalamud.Interface.Internal new(0, "special.all", () => Locs.Category_All), new(10, "special.devInstalled", () => Locs.Category_DevInstalled), new(11, "special.devIconTester", () => Locs.Category_IconTester), + new(12, "special.dalamud", () => Locs.Category_Dalamud), + new(13, "special.plugins", () => Locs.Category_Plugins), new(FirstTagBasedCategoryId + 0, "other", () => Locs.Category_Other), new(FirstTagBasedCategoryId + 1, "jobs", () => Locs.Category_Jobs), new(FirstTagBasedCategoryId + 2, "ui", () => Locs.Category_UI), @@ -39,7 +41,7 @@ namespace Dalamud.Interface.Internal new(GroupKind.DevTools, () => Locs.Group_DevTools, 10, 11), new(GroupKind.Installed, () => Locs.Group_Installed, 0), new(GroupKind.Available, () => Locs.Group_Available, 0), - new(GroupKind.Changelog, () => Locs.Group_Changelog, 0), + new(GroupKind.Changelog, () => Locs.Group_Changelog, 0, 12, 13), // order important, used for drawing, keep in sync with defaults for currentGroupIdx }; @@ -408,6 +410,10 @@ namespace Dalamud.Interface.Internal public static string Category_Utility => Loc.Localize("InstallerCategoryUtility", "Utility"); + public static string Category_Plugins => Loc.Localize("InstallerCategoryPlugins", "Plugins"); + + public static string Category_Dalamud => Loc.Localize("InstallerCategoryDalamud", "Dalamud"); + #endregion } } diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index 30e76fff2..12e88330e 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -513,7 +513,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller } */ - private void DrawChangelogList() + private void DrawChangelogList(bool displayDalamud, bool displayPlugins) { if (this.pluginListInstalled.Count == 0) { @@ -537,12 +537,26 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller return (IChangelogEntry)changelog; }); - var changelogs = (this.dalamudChangelogManager.Changelogs != null - ? pluginChangelogs - .Concat(this.dalamudChangelogManager.Changelogs.Select(x => new DalamudChangelogEntry(x, this.imageCache.CorePluginIcon))) - : pluginChangelogs).OrderByDescending(x => x.Date).ToList(); + IEnumerable changelogs = null; + if (displayDalamud && displayPlugins && this.dalamudChangelogManager.Changelogs != null) + { + changelogs = pluginChangelogs + .Concat(this.dalamudChangelogManager.Changelogs.Select( + x => new DalamudChangelogEntry(x, this.imageCache.CorePluginIcon))); + } + else if (displayDalamud && this.dalamudChangelogManager.Changelogs != null) + { + changelogs = this.dalamudChangelogManager.Changelogs.Select( + x => new DalamudChangelogEntry(x, this.imageCache.CorePluginIcon)); + } + else if (displayPlugins) + { + changelogs = pluginChangelogs; + } - if (!changelogs.Any()) + var sortedChangelogs = changelogs?.OrderByDescending(x => x.Date).ToList(); + + if (sortedChangelogs == null || !sortedChangelogs.Any()) { ImGui.TextColored( ImGuiColors.DalamudGrey2, @@ -553,7 +567,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller return; } - foreach (var logEntry in changelogs) + foreach (var logEntry in sortedChangelogs) { this.DrawChangelog(logEntry); } @@ -801,7 +815,21 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller this.DrawInstalledPluginList(); break; case PluginCategoryManager.GroupKind.Changelog: - this.DrawChangelogList(); + switch (this.categoryManager.CurrentCategoryIdx) + { + case 0: + this.DrawChangelogList(true, true); + break; + + case 1: + this.DrawChangelogList(true, false); + break; + + case 2: + this.DrawChangelogList(false, true); + break; + } + break; default: this.DrawAvailablePluginList();