Make it search for the plugin and open the installed category

This commit is contained in:
Infi 2023-02-26 21:00:03 +01:00
parent 4acadd5c9e
commit 94538d1728
3 changed files with 52 additions and 3 deletions

View file

@ -263,6 +263,15 @@ internal class DalamudInterface : IDisposable, IServiceType
this.pluginWindow.BringToFront();
}
/// <summary>
/// Opens the <see cref="PluginInstallerWindow"/> on the plugin installed.
/// </summary>
public void OpenPluginInstallerPluginInstalled()
{
this.pluginWindow.OpenInstalledPlugins();
this.pluginWindow.BringToFront();
}
/// <summary>
/// Opens the <see cref="PluginInstallerWindow"/> on the plugin changelogs.
/// </summary>
@ -420,6 +429,15 @@ internal class DalamudInterface : IDisposable, IServiceType
#endregion
/// <summary>
/// Sets the current search text for the plugin installer.
/// </summary>
/// <param name="text">The search term.</param>
public void SetPluginInstallerSearchText(string text)
{
this.pluginWindow.SetSearchText(text);
}
/// <summary>
/// Toggle the screen darkening effect used for the credits.
/// </summary>

View file

@ -97,6 +97,7 @@ internal class PluginInstallerWindow : Window, IDisposable
private bool hasDevPlugins = false;
private string searchText = string.Empty;
private bool prefilledSearchTexted = false;
private PluginSortKind sortKind = PluginSortKind.Alphabetical;
private string filterText = Locs.SortBy_Alphabetical;
@ -202,7 +203,7 @@ internal class PluginInstallerWindow : Window, IDisposable
_ = pluginManager.ReloadPluginMastersAsync();
this.searchText = string.Empty;
if (!this.prefilledSearchTexted) this.searchText = string.Empty;
this.sortKind = PluginSortKind.Alphabetical;
this.filterText = Locs.SortBy_Alphabetical;
@ -218,6 +219,12 @@ internal class PluginInstallerWindow : Window, IDisposable
public override void OnClose()
{
Service<DalamudConfiguration>.Get().QueueSave();
if (this.prefilledSearchTexted)
{
this.prefilledSearchTexted = false;
this.searchText = string.Empty;
}
}
/// <inheritdoc/>
@ -244,6 +251,18 @@ internal class PluginInstallerWindow : Window, IDisposable
this.imageCache.ClearIconCache();
}
/// <summary>
/// Open the window on the plugin changelogs.
/// </summary>
public void OpenInstalledPlugins()
{
// Installed group
this.categoryManager.CurrentGroupIdx = 1;
// All category
this.categoryManager.CurrentCategoryIdx = 0;
this.IsOpen = true;
}
/// <summary>
/// Open the window on the plugin changelogs.
/// </summary>
@ -256,6 +275,16 @@ internal class PluginInstallerWindow : Window, IDisposable
this.IsOpen = true;
}
/// <summary>
/// Sets the current search text and marks it as prefilled.
/// </summary>
/// <param name="text">The search term.</param>
public void SetSearchText(string text)
{
this.prefilledSearchTexted = true;
this.searchText = text;
}
private void DrawProgressOverlay()
{
var pluginManager = Service<PluginManager>.Get();

View file

@ -196,7 +196,7 @@ public sealed class DalamudPluginInterface : IDisposable
public List<string> PluginInternalNames => Service<PluginManager>.Get().InstalledPlugins.Select(p => p.Manifest.InternalName).ToList();
/// <summary>
/// Opens the <see cref="PluginInstallerWindow"/>.
/// Opens the <see cref="PluginInstallerWindow"/> with the plugin name set as search target.
/// </summary>
/// <returns>Returns false if the DalamudInterface was null.</returns>
public bool OpenPluginInstaller()
@ -207,7 +207,9 @@ public sealed class DalamudPluginInterface : IDisposable
return false;
}
dalamudInterface.OpenPluginInstaller();
dalamudInterface.OpenPluginInstallerPluginInstalled();
dalamudInterface.SetPluginInstallerSearchText(this.pluginName);
return true;
}