Show outdated plugins when searched for (#995)

This commit is contained in:
goat 2022-09-03 23:36:23 +02:00 committed by GitHub
commit 13daece2c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 12 deletions

View file

@ -56,6 +56,7 @@ namespace Dalamud.Interface.Internal.Windows
private readonly Task<TextureWrap> emptyTextureTask;
private readonly Task<TextureWrap> disabledIconTask;
private readonly Task<TextureWrap> outdatedInstallableIconTask;
private readonly Task<TextureWrap> defaultIconTask;
private readonly Task<TextureWrap> troubleIconTask;
private readonly Task<TextureWrap> updateIconTask;
@ -74,6 +75,7 @@ namespace Dalamud.Interface.Internal.Windows
this.emptyTextureTask = imwst.ContinueWith(task => task.Result.Manager.LoadImageRaw(new byte[64], 8, 8, 4)!);
this.defaultIconTask = imwst.ContinueWith(task => TaskWrapIfNonNull(task.Result.Manager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "defaultIcon.png"))) ?? this.emptyTextureTask).Unwrap();
this.disabledIconTask = imwst.ContinueWith(task => TaskWrapIfNonNull(task.Result.Manager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "disabledIcon.png"))) ?? this.emptyTextureTask).Unwrap();
this.outdatedInstallableIconTask = imwst.ContinueWith(task => TaskWrapIfNonNull(task.Result.Manager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "outdatedInstallableIcon.png"))) ?? this.emptyTextureTask).Unwrap();
this.troubleIconTask = imwst.ContinueWith(task => TaskWrapIfNonNull(task.Result.Manager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "troubleIcon.png"))) ?? this.emptyTextureTask).Unwrap();
this.updateIconTask = imwst.ContinueWith(task => TaskWrapIfNonNull(task.Result.Manager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "updateIcon.png"))) ?? this.emptyTextureTask).Unwrap();
this.installedIconTask = imwst.ContinueWith(task => TaskWrapIfNonNull(task.Result.Manager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "installedIcon.png"))) ?? this.emptyTextureTask).Unwrap();
@ -95,12 +97,19 @@ namespace Dalamud.Interface.Internal.Windows
: this.emptyTextureTask.GetAwaiter().GetResult();
/// <summary>
/// Gets the default plugin icon.
/// Gets the disabled plugin icon.
/// </summary>
public TextureWrap DisabledIcon => this.disabledIconTask.IsCompleted
? this.disabledIconTask.Result
: this.disabledIconTask.GetAwaiter().GetResult();
/// <summary>
/// Gets the outdated installable plugin icon.
/// </summary>
public TextureWrap OutdatedInstallableIcon => this.outdatedInstallableIconTask.IsCompleted
? this.outdatedInstallableIconTask.Result
: this.outdatedInstallableIconTask.GetAwaiter().GetResult();
/// <summary>
/// Gets the default plugin icon.
/// </summary>

View file

@ -1377,7 +1377,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
return ready;
}
private bool DrawPluginCollapsingHeader(string label, LocalPlugin? plugin, PluginManifest manifest, bool isThirdParty, bool trouble, bool updateAvailable, bool isNew, Action drawContextMenuAction, int index)
private bool DrawPluginCollapsingHeader(string label, LocalPlugin? plugin, PluginManifest manifest, bool isThirdParty, bool trouble, bool updateAvailable, bool isNew, bool installableOutdated, Action drawContextMenuAction, int index)
{
ImGui.Separator();
@ -1428,14 +1428,14 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
iconTex = cachedIconTex;
}
if (pluginDisabled)
if (pluginDisabled || installableOutdated)
{
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.5f);
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.4f);
}
ImGui.Image(iconTex.ImGuiHandle, iconSize);
if (pluginDisabled)
if (pluginDisabled || installableOutdated)
{
ImGui.PopStyleVar();
}
@ -1450,6 +1450,8 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
ImGui.Image(this.imageCache.UpdateIcon.ImGuiHandle, iconSize);
else if (trouble && !pluginDisabled)
ImGui.Image(this.imageCache.TroubleIcon.ImGuiHandle, iconSize);
else if (installableOutdated)
ImGui.Image(this.imageCache.OutdatedInstallableIcon.ImGuiHandle, iconSize);
else if (pluginDisabled)
ImGui.Image(this.imageCache.DisabledIcon.ImGuiHandle, iconSize);
else if (isLoaded && isThirdParty)
@ -1488,7 +1490,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
ImGui.SetCursorPos(cursor);
// Outdated warning
if (plugin is { IsOutdated: true, IsBanned: false })
if (plugin is { IsOutdated: true, IsBanned: false } || installableOutdated)
{
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
ImGui.TextWrapped(Locs.PluginBody_Outdated);
@ -1616,6 +1618,8 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
var useTesting = PluginManager.UseTesting(manifest);
var wasSeen = this.WasPluginSeen(manifest.InternalName);
var isOutdated = manifest.DalamudApiLevel < PluginManager.DalamudApiLevel;
// Check for valid versions
if ((useTesting && manifest.TestingAssemblyVersion == null) || manifest.AssemblyVersion == null)
{
@ -1635,7 +1639,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
ImGui.PushID($"available{index}{manifest.InternalName}");
var isThirdParty = manifest.SourceRepo.IsThirdParty;
if (this.DrawPluginCollapsingHeader(label, null, manifest, isThirdParty, false, false, !wasSeen, () => this.DrawAvailablePluginContextMenu(manifest), index))
if (this.DrawPluginCollapsingHeader(label, null, manifest, isThirdParty, false, false, !wasSeen, isOutdated, () => this.DrawAvailablePluginContextMenu(manifest), index))
{
if (!wasSeen)
configuration.SeenPluginInternalName.Add(manifest.InternalName);
@ -1662,7 +1666,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
ImGuiHelpers.ScaledDummy(5);
// Controls
var disabled = this.updateStatus == OperationStatus.InProgress || this.installStatus == OperationStatus.InProgress;
var disabled = this.updateStatus == OperationStatus.InProgress || this.installStatus == OperationStatus.InProgress || isOutdated;
var versionString = useTesting
? $"{manifest.TestingAssemblyVersion}"
@ -1878,7 +1882,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
ImGui.PushID($"installed{index}{plugin.Manifest.InternalName}");
var hasChangelog = !plugin.Manifest.Changelog.IsNullOrEmpty();
if (this.DrawPluginCollapsingHeader(label, plugin, plugin.Manifest, plugin.Manifest.IsThirdParty, trouble, availablePluginUpdate != default, false, () => this.DrawInstalledPluginContextMenu(plugin), index))
if (this.DrawPluginCollapsingHeader(label, plugin, plugin.Manifest, plugin.Manifest.IsThirdParty, trouble, availablePluginUpdate != default, false, false, () => this.DrawInstalledPluginContextMenu(plugin), index))
{
if (!this.WasPluginSeen(plugin.Manifest.InternalName))
configuration.SeenPluginInternalName.Add(plugin.Manifest.InternalName);
@ -2484,15 +2488,21 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
{
var searchString = this.searchText.ToLowerInvariant();
var hasSearchString = !string.IsNullOrWhiteSpace(searchString);
var oldApi = manifest.DalamudApiLevel < PluginManager.DalamudApiLevel;
var installed = this.IsManifestInstalled(manifest).IsInstalled;
if (oldApi && !hasSearchString && !installed)
return true;
return hasSearchString && !(
manifest.Name.ToLowerInvariant().Contains(searchString) ||
manifest.InternalName.ToLowerInvariant().Contains(searchString) ||
(!manifest.Author.IsNullOrEmpty() && manifest.Author.Equals(this.searchText, StringComparison.InvariantCultureIgnoreCase)) ||
(!manifest.Punchline.IsNullOrEmpty() && manifest.Punchline.ToLowerInvariant().Contains(searchString)) ||
(manifest.Tags != null && manifest.Tags.Contains(searchString, StringComparer.InvariantCultureIgnoreCase)));
}
private (bool IsInstalled, LocalPlugin Plugin) IsManifestInstalled(RemotePluginManifest? manifest)
private (bool IsInstalled, LocalPlugin Plugin) IsManifestInstalled(PluginManifest? manifest)
{
if (manifest == null) return (false, default);

View file

@ -1169,8 +1169,8 @@ internal partial class PluginManager : IDisposable, IServiceType
return false;
}
// API level
if (manifest.DalamudApiLevel < DalamudApiLevel && !this.LoadAllApiLevels)
// API level - we keep the API before this in the installer to show as "outdated"
if (manifest.DalamudApiLevel < DalamudApiLevel - 1 && !this.LoadAllApiLevels)
{
Log.Verbose($"API Level: {manifest.InternalName} - {manifest.AssemblyVersion} - {manifest.TestingAssemblyVersion}");
return false;
@ -1235,6 +1235,7 @@ internal partial class PluginManager : IDisposable, IServiceType
var updates = this.AvailablePlugins
.Where(remoteManifest => plugin.Manifest.InternalName == remoteManifest.InternalName)
.Where(remoteManifest => plugin.Manifest.InstalledFromUrl == remoteManifest.SourceRepo.PluginMasterUrl || !remoteManifest.SourceRepo.IsThirdParty)
.Where(remoteManifest => remoteManifest.DalamudApiLevel == DalamudApiLevel)
.Select(remoteManifest =>
{
var useTesting = UseTesting(remoteManifest);