From b8cf9c4c46154627fc86c48916d62a9c20a6e2d6 Mon Sep 17 00:00:00 2001
From: Aireil <33433913+Aireil@users.noreply.github.com>
Date: Thu, 3 Feb 2022 17:17:42 +0100
Subject: [PATCH] feat(PluginInstaller): add Changelog tab
---
.../Internal/PluginCategoryManager.cs | 8 ++
.../Internal/Windows/PluginInstallerWindow.cs | 127 +++++++++++++++---
2 files changed, 113 insertions(+), 22 deletions(-)
diff --git a/Dalamud/Interface/Internal/PluginCategoryManager.cs b/Dalamud/Interface/Internal/PluginCategoryManager.cs
index 752580e45..36693549a 100644
--- a/Dalamud/Interface/Internal/PluginCategoryManager.cs
+++ b/Dalamud/Interface/Internal/PluginCategoryManager.cs
@@ -39,6 +39,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),
// order important, used for drawing, keep in sync with defaults for currentGroupIdx
};
@@ -69,6 +70,11 @@ namespace Dalamud.Interface.Internal
/// UI group: plugins that can be installed.
///
Available,
+
+ ///
+ /// UI group: changelog of plugins.
+ ///
+ Changelog,
}
///
@@ -374,6 +380,8 @@ namespace Dalamud.Interface.Internal
public static string Group_Available => Loc.Localize("InstallerAllPlugins", "All Plugins");
+ public static string Group_Changelog => Loc.Localize("InstallerChangelog", "Changelog");
+
#endregion
#region Categories
diff --git a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs
index 5ef811f8c..57f984016 100644
--- a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs
@@ -510,6 +510,37 @@ namespace Dalamud.Interface.Internal.Windows
}
*/
+ private void DrawChangelogList()
+ {
+ if (this.pluginListInstalled.Count == 0)
+ {
+ ImGui.TextColored(ImGuiColors.DalamudGrey, Locs.TabBody_SearchNoInstalled);
+ return;
+ }
+
+ var filteredList = this.pluginListInstalled
+ .Where(plugin => !this.IsManifestFiltered(plugin.Manifest)
+ && !plugin.Manifest.Changelog.IsNullOrEmpty())
+ .OrderByDescending(plugin => plugin.Manifest.LastUpdate)
+ .ToList();
+
+ if (!filteredList.Any())
+ {
+ ImGui.TextColored(
+ ImGuiColors.DalamudGrey2,
+ this.pluginListInstalled.Any(plugin => !plugin.Manifest.Changelog.IsNullOrEmpty())
+ ? Locs.TabBody_SearchNoMatching
+ : Locs.TabBody_ChangelogNone);
+
+ return;
+ }
+
+ foreach (var plugin in filteredList)
+ {
+ this.DrawChangelog(plugin);
+ }
+ }
+
private void DrawAvailablePluginList()
{
var pluginList = this.pluginListAvailable;
@@ -728,31 +759,35 @@ namespace Dalamud.Interface.Internal.Windows
}
}
- if (groupInfo.GroupKind == PluginCategoryManager.GroupKind.DevTools)
+ switch (groupInfo.GroupKind)
{
- // this one is never sorted and remains in hardcoded order from group ctor
- switch (this.categoryManager.CurrentCategoryIdx)
- {
- case 0:
- this.DrawInstalledDevPluginList();
- break;
+ case PluginCategoryManager.GroupKind.DevTools:
+ // this one is never sorted and remains in hardcoded order from group ctor
+ switch (this.categoryManager.CurrentCategoryIdx)
+ {
+ case 0:
+ this.DrawInstalledDevPluginList();
+ break;
- case 1:
- this.DrawImageTester();
- break;
+ case 1:
+ this.DrawImageTester();
+ break;
- default:
- // umm, there's nothing else, keep handled set and just skip drawing...
- break;
- }
- }
- else if (groupInfo.GroupKind == PluginCategoryManager.GroupKind.Installed)
- {
- this.DrawInstalledPluginList();
- }
- else
- {
- this.DrawAvailablePluginList();
+ default:
+ // umm, there's nothing else, keep handled set and just skip drawing...
+ break;
+ }
+
+ break;
+ case PluginCategoryManager.GroupKind.Installed:
+ this.DrawInstalledPluginList();
+ break;
+ case PluginCategoryManager.GroupKind.Changelog:
+ this.DrawChangelogList();
+ break;
+ default:
+ this.DrawAvailablePluginList();
+ break;
}
ImGui.PopStyleVar();
@@ -1167,6 +1202,52 @@ namespace Dalamud.Interface.Internal.Windows
return isOpen;
}
+ private void DrawChangelog(LocalPlugin plugin)
+ {
+ ImGui.Separator();
+
+ var startCursor = ImGui.GetCursorPos();
+
+ var iconTex = this.imageCache.DefaultIcon;
+ var hasIcon = this.imageCache.TryGetIcon(plugin, plugin.Manifest, plugin.Manifest.IsThirdParty, out var cachedIconTex);
+ if (hasIcon && cachedIconTex != null)
+ {
+ iconTex = cachedIconTex;
+ }
+
+ var iconSize = ImGuiHelpers.ScaledVector2(64, 64);
+
+ ImGui.Image(iconTex.ImGuiHandle, iconSize);
+ ImGui.SameLine();
+
+ ImGuiHelpers.ScaledDummy(5);
+
+ ImGui.SameLine();
+ var cursor = ImGui.GetCursorPos();
+ ImGui.Text(plugin.Name);
+
+ ImGui.SameLine();
+ var version = plugin.AssemblyName?.Version;
+ version ??= plugin.Manifest.Testing
+ ? plugin.Manifest.TestingAssemblyVersion
+ : plugin.Manifest.AssemblyVersion;
+ ImGui.TextColored(ImGuiColors.DalamudGrey3, $" v{version}");
+
+ cursor.Y += ImGui.GetTextLineHeightWithSpacing();
+ ImGui.SetCursorPos(cursor);
+
+ ImGui.TextWrapped(plugin.Manifest.Changelog);
+
+ var endCursor = ImGui.GetCursorPos();
+
+ var sectionSize = Math.Max(
+ 66 * ImGuiHelpers.GlobalScale, // min size due to icons
+ endCursor.Y - startCursor.Y);
+
+ startCursor.Y += sectionSize;
+ ImGui.SetCursorPos(startCursor);
+ }
+
private void DrawAvailablePlugin(RemotePluginManifest manifest, int index)
{
var configuration = Service.Get();
@@ -2126,6 +2207,8 @@ namespace Dalamud.Interface.Internal.Windows
public static string TabBody_SearchNoInstalled => Loc.Localize("InstallerNoInstalled", "No plugins are currently installed. You can install them from the \"All Plugins\" tab.");
+ public static string TabBody_ChangelogNone => Loc.Localize("InstallerNoChangelog", "None of your installed plugins have a changelog.");
+
#endregion
#region Plugin title text