pi: add "updateable plugins" page, open kind, make auto-updates go there by default

This commit is contained in:
goat 2024-06-18 23:04:04 +02:00
parent c155be7db6
commit 3509a0bdca
4 changed files with 106 additions and 55 deletions

View file

@ -14,6 +14,11 @@ public enum PluginInstallerOpenKind
/// Open to the "Installed Plugins" page. /// Open to the "Installed Plugins" page.
/// </summary> /// </summary>
InstalledPlugins, InstalledPlugins,
/// <summary>
/// Open to the "Can be updated" page.
/// </summary>
UpdateablePlugins,
/// <summary> /// <summary>
/// Open to the "Changelogs" page. /// Open to the "Changelogs" page.

View file

@ -28,6 +28,7 @@ internal class PluginCategoryManager
new(12, "special.dalamud", () => Locs.Category_Dalamud), new(12, "special.dalamud", () => Locs.Category_Dalamud),
new(13, "special.plugins", () => Locs.Category_Plugins), new(13, "special.plugins", () => Locs.Category_Plugins),
new(14, "special.profiles", () => Locs.Category_PluginProfiles), new(14, "special.profiles", () => Locs.Category_PluginProfiles),
new(15, "special.updateable", () => Locs.Category_UpdateablePlugins),
new(FirstTagBasedCategoryId + 0, "other", () => Locs.Category_Other), new(FirstTagBasedCategoryId + 0, "other", () => Locs.Category_Other),
new(FirstTagBasedCategoryId + 1, "jobs", () => Locs.Category_Jobs), new(FirstTagBasedCategoryId + 1, "jobs", () => Locs.Category_Jobs),
new(FirstTagBasedCategoryId + 2, "ui", () => Locs.Category_UI), new(FirstTagBasedCategoryId + 2, "ui", () => Locs.Category_UI),
@ -43,7 +44,7 @@ internal class PluginCategoryManager
private GroupInfo[] groupList = private GroupInfo[] groupList =
{ {
new(GroupKind.DevTools, () => Locs.Group_DevTools, 10, 11), new(GroupKind.DevTools, () => Locs.Group_DevTools, 10, 11),
new(GroupKind.Installed, () => Locs.Group_Installed, 0, 1, 14), new(GroupKind.Installed, () => Locs.Group_Installed, 0, 1, 15, 14),
new(GroupKind.Available, () => Locs.Group_Available, 0), new(GroupKind.Available, () => Locs.Group_Available, 0),
new(GroupKind.Changelog, () => Locs.Group_Changelog, 0, 12, 13), new(GroupKind.Changelog, () => Locs.Group_Changelog, 0, 12, 13),
@ -432,6 +433,8 @@ internal class PluginCategoryManager
public static string Category_PluginProfiles => Loc.Localize("InstallerCategoryPluginProfiles", "Plugin Collections"); public static string Category_PluginProfiles => Loc.Localize("InstallerCategoryPluginProfiles", "Plugin Collections");
public static string Category_UpdateablePlugins => Loc.Localize("InstallerCategoryCanBeUpdated", "Can be updated");
public static string Category_Other => Loc.Localize("InstallerCategoryOther", "Other"); public static string Category_Other => Loc.Localize("InstallerCategoryOther", "Other");
public static string Category_Jobs => Loc.Localize("InstallerCategoryJobs", "Jobs"); public static string Category_Jobs => Loc.Localize("InstallerCategoryJobs", "Jobs");

View file

@ -221,6 +221,14 @@ internal class PluginInstallerWindow : Window, IDisposable
IsTesting = 1 << 6, IsTesting = 1 << 6,
} }
private enum InstalledPluginListFilter
{
None,
Testing,
Updateable,
Dev,
}
private bool AnyOperationInProgress => this.installStatus == OperationStatus.InProgress || private bool AnyOperationInProgress => this.installStatus == OperationStatus.InProgress ||
this.updateStatus == OperationStatus.InProgress || this.updateStatus == OperationStatus.InProgress ||
this.enableDisableStatus == OperationStatus.InProgress; this.enableDisableStatus == OperationStatus.InProgress;
@ -430,6 +438,12 @@ internal class PluginInstallerWindow : Window, IDisposable
// All category // All category
this.categoryManager.CurrentCategoryIdx = 0; this.categoryManager.CurrentCategoryIdx = 0;
break; break;
case PluginInstallerOpenKind.UpdateablePlugins:
// Installed group
this.categoryManager.CurrentGroupIdx = 1;
// Updateable category
this.categoryManager.CurrentCategoryIdx = 15;
break;
case PluginInstallerOpenKind.Changelogs: case PluginInstallerOpenKind.Changelogs:
// Changelog group // Changelog group
this.categoryManager.CurrentGroupIdx = 3; this.categoryManager.CurrentGroupIdx = 3;
@ -1215,7 +1229,8 @@ internal class PluginInstallerWindow : Window, IDisposable
if (proxy.LocalPlugin != null) if (proxy.LocalPlugin != null)
{ {
this.DrawInstalledPlugin(proxy.LocalPlugin, i++, proxy.RemoteManifest, true); var update = this.pluginListUpdatable.FirstOrDefault(up => up.InstalledPlugin == proxy.LocalPlugin);
this.DrawInstalledPlugin(proxy.LocalPlugin, i++, proxy.RemoteManifest, update);
} }
else if (proxy.RemoteManifest != null) else if (proxy.RemoteManifest != null)
{ {
@ -1225,8 +1240,8 @@ internal class PluginInstallerWindow : Window, IDisposable
ImGui.PopID(); ImGui.PopID();
} }
} }
private void DrawInstalledPluginList(bool filterTesting) private void DrawInstalledPluginList(InstalledPluginListFilter filter)
{ {
var pluginList = this.pluginListInstalled; var pluginList = this.pluginListInstalled;
var manager = Service<PluginManager>.Get(); var manager = Service<PluginManager>.Get();
@ -1247,47 +1262,57 @@ internal class PluginInstallerWindow : Window, IDisposable
return; return;
} }
var drewAny = false;
var i = 0; var i = 0;
foreach (var plugin in filteredList) foreach (var plugin in filteredList)
{ {
if (filterTesting && !manager.HasTestingOptIn(plugin.Manifest)) if (filter == InstalledPluginListFilter.Testing && !manager.HasTestingOptIn(plugin.Manifest))
continue; continue;
// Find applicable update and manifest, if we have them
AvailablePluginUpdate? update = null;
RemotePluginManifest? remoteManifest = null;
// Find the applicable remote manifest if (filter != InstalledPluginListFilter.Dev)
var remoteManifest = this.pluginListAvailable {
.FirstOrDefault(rm => rm.InternalName == plugin.Manifest.InternalName && update = this.pluginListUpdatable.FirstOrDefault(up => up.InstalledPlugin == plugin);
rm.RepoUrl == plugin.Manifest.RepoUrl); if (filter == InstalledPluginListFilter.Updateable && update == null)
continue;
this.DrawInstalledPlugin(plugin, i++, remoteManifest); // Find the applicable remote manifest
remoteManifest = this.pluginListAvailable
.FirstOrDefault(rm => rm.InternalName == plugin.Manifest.InternalName &&
rm.RepoUrl == plugin.Manifest.RepoUrl);
}
else if (!plugin.IsDev)
{
continue;
}
this.DrawInstalledPlugin(plugin, i++, remoteManifest, update);
drewAny = true;
} }
}
if (!drewAny)
private void DrawInstalledDevPluginList()
{
var pluginList = this.pluginListInstalled
.Where(plugin => plugin.IsDev)
.ToList();
if (pluginList.Count == 0)
{ {
ImGui.TextColored(ImGuiColors.DalamudGrey, Locs.TabBody_SearchNoInstalled); var text = filter switch
return; {
} InstalledPluginListFilter.None => Locs.TabBody_NoPluginsInstalled,
InstalledPluginListFilter.Testing => Locs.TabBody_NoPluginsTesting,
InstalledPluginListFilter.Updateable => Locs.TabBody_NoPluginsUpdateable,
InstalledPluginListFilter.Dev => Locs.TabBody_NoPluginsDev,
_ => throw new ArgumentException(null, nameof(filter)),
};
ImGuiHelpers.ScaledDummy(60);
var filteredList = pluginList using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudGrey))
.Where(plugin => !this.IsManifestFiltered(plugin.Manifest)) {
.ToList(); foreach (var line in text.Split('\n'))
{
if (filteredList.Count == 0) ImGuiHelpers.CenteredText(line);
{ }
ImGui.TextColored(ImGuiColors.DalamudGrey2, Locs.TabBody_SearchNoMatching); }
return;
}
var i = 0;
foreach (var plugin in filteredList)
{
this.DrawInstalledPlugin(plugin, i++, null);
} }
} }
@ -1462,7 +1487,7 @@ internal class PluginInstallerWindow : Window, IDisposable
switch (this.categoryManager.CurrentCategoryIdx) switch (this.categoryManager.CurrentCategoryIdx)
{ {
case 0: case 0:
this.DrawInstalledDevPluginList(); this.DrawInstalledPluginList(InstalledPluginListFilter.Dev);
break; break;
case 1: case 1:
@ -1470,7 +1495,7 @@ internal class PluginInstallerWindow : Window, IDisposable
break; break;
default: default:
// umm, there's nothing else, keep handled set and just skip drawing... ImGui.TextUnformatted("You found a mysterious category. Please keep it to yourself.");
break; break;
} }
@ -1479,16 +1504,24 @@ internal class PluginInstallerWindow : Window, IDisposable
switch (this.categoryManager.CurrentCategoryIdx) switch (this.categoryManager.CurrentCategoryIdx)
{ {
case 0: case 0:
this.DrawInstalledPluginList(false); this.DrawInstalledPluginList(InstalledPluginListFilter.None);
break; break;
case 1: case 1:
this.DrawInstalledPluginList(true); this.DrawInstalledPluginList(InstalledPluginListFilter.Testing);
break;
case 2:
this.DrawInstalledPluginList(InstalledPluginListFilter.Updateable);
break; break;
case 2: case 3:
this.profileManagerWidget.Draw(); this.profileManagerWidget.Draw();
break; break;
default:
ImGui.TextUnformatted("You found a secret category. Please feel a sense of pride and accomplishment.");
break;
} }
break; break;
@ -2325,7 +2358,7 @@ internal class PluginInstallerWindow : Window, IDisposable
} }
} }
private void DrawInstalledPlugin(LocalPlugin plugin, int index, RemotePluginManifest? remoteManifest, bool showInstalled = false) private void DrawInstalledPlugin(LocalPlugin plugin, int index, RemotePluginManifest? remoteManifest, AvailablePluginUpdate? availablePluginUpdate, bool showInstalled = false)
{ {
var configuration = Service<DalamudConfiguration>.Get(); var configuration = Service<DalamudConfiguration>.Get();
var commandManager = Service<CommandManager>.Get(); var commandManager = Service<CommandManager>.Get();
@ -2384,8 +2417,6 @@ internal class PluginInstallerWindow : Window, IDisposable
trouble = true; trouble = true;
} }
var availablePluginUpdate = this.pluginListUpdatable.FirstOrDefault(up => up.InstalledPlugin == plugin);
// Dev plugins can never update // Dev plugins can never update
if (plugin.IsDev) if (plugin.IsDev)
availablePluginUpdate = null; availablePluginUpdate = null;
@ -3684,7 +3715,16 @@ internal class PluginInstallerWindow : Window, IDisposable
public static string TabBody_DownloadFailed => Loc.Localize("InstallerDownloadFailed", "Download failed."); public static string TabBody_DownloadFailed => Loc.Localize("InstallerDownloadFailed", "Download failed.");
public static string TabBody_SafeMode => Loc.Localize("InstallerSafeMode", "Dalamud is running in Plugin Safe Mode, restart to activate plugins."); public static string TabBody_SafeMode => Loc.Localize("InstallerSafeMode", "Dalamud is running in Plugin Safe Mode, restart to activate plugins.");
public static string TabBody_NoPluginsTesting => Loc.Localize("InstallerNoPluginsTesting", "You aren't testing any plugins at the moment!\nYou can opt in to testing versions in the plugin context menu.");
public static string TabBody_NoPluginsInstalled =>
string.Format(Loc.Localize("InstallerNoPluginsInstalled", "You don't have any plugins installed yet!\nYou can install them from the \"{0}\" tab."), PluginCategoryManager.Locs.Category_All);
public static string TabBody_NoPluginsUpdateable => Loc.Localize("InstallerNoPluginsUpdate", "No plugins have updates available at the moment.");
public static string TabBody_NoPluginsDev => Loc.Localize("InstallerNoPluginsDev", "You don't have any dev plugins. Add them some the settings.");
#endregion #endregion
#region Search text #region Search text

View file

@ -128,6 +128,17 @@ internal class AutoUpdateManager : IServiceType
_ => throw new ArgumentOutOfRangeException(nameof(behavior), behavior, null), _ => throw new ArgumentOutOfRangeException(nameof(behavior), behavior, null),
}; };
} }
private static void DrawOpenInstallerNotificationButton(bool primary, IActiveNotification notification)
{
if (primary ?
DalamudComponents.PrimaryButton(Locs.NotificationButtonOpenPluginInstaller) :
DalamudComponents.SecondaryButton(Locs.NotificationButtonOpenPluginInstaller))
{
Service<DalamudInterface>.Get().OpenPluginInstallerTo(PluginInstallerOpenKind.UpdateablePlugins);
notification.DismissNow();
}
}
private void OnUpdate(IFramework framework) private void OnUpdate(IFramework framework)
{ {
@ -293,11 +304,7 @@ internal class AutoUpdateManager : IServiceType
notification.DrawActions += _ => notification.DrawActions += _ =>
{ {
ImGuiHelpers.ScaledDummy(2); ImGuiHelpers.ScaledDummy(2);
if (DalamudComponents.PrimaryButton(Locs.NotificationButtonOpenPluginInstaller)) DrawOpenInstallerNotificationButton(true, notification);
{
Service<DalamudInterface>.Get().OpenPluginInstaller();
notification.DismissNow();
}
}; };
// Update the notification to show the final state // Update the notification to show the final state
@ -356,11 +363,7 @@ internal class AutoUpdateManager : IServiceType
} }
ImGui.SameLine(); ImGui.SameLine();
if (DalamudComponents.SecondaryButton(Locs.NotificationButtonOpenPluginInstaller)) DrawOpenInstallerNotificationButton(false, notification);
{
Service<DalamudInterface>.Get().OpenPluginInstaller();
notification.DismissNow();
}
}; };
} }