feat: allow configuring the default page the installer opens to

This commit is contained in:
goat 2023-10-25 17:32:42 +02:00
parent 9850ac3f15
commit 9875a7ea31
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
11 changed files with 98 additions and 43 deletions

View file

@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using Dalamud.Game.Text;
using Dalamud.Interface.Internal.Windows.PluginInstaller;
using Dalamud.Interface.Style;
using Dalamud.IoC.Internal;
using Dalamud.Plugin.Internal.Profiles;
@ -424,6 +425,11 @@ internal sealed class DalamudConfiguration : IServiceType, IDisposable
/// </summary>
public double UiBuilderHitch { get; set; } = 100;
/// <summary>
/// Gets or sets the page of the plugin installer that is shown by default when opened.
/// </summary>
public PluginInstallerWindow.PluginInstallerOpenKind PluginInstallerOpen { get; set; } = PluginInstallerWindow.PluginInstallerOpenKind.AllPlugins;
/// <summary>
/// Load a configuration from the provided path.
/// </summary>

View file

@ -13,6 +13,7 @@ using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Interface.Internal.Windows;
using Dalamud.Interface.Internal.Windows.PluginInstaller;
using Dalamud.Plugin.Internal;
using Dalamud.Utility;
using Serilog;
@ -118,7 +119,7 @@ internal class ChatHandlers : IServiceType
this.openInstallerWindowLink = chatGui.AddChatLinkHandler("Dalamud", 1001, (i, m) =>
{
Service<DalamudInterface>.GetNullable()?.OpenPluginInstaller();
Service<DalamudInterface>.GetNullable()?.OpenPluginInstallerTo(PluginInstallerWindow.PluginInstallerOpenKind.InstalledPlugins);
});
}

View file

@ -222,7 +222,7 @@ internal sealed unsafe partial class DalamudAtkTweaks : IServiceType
switch (commandId)
{
case 69420:
dalamudInterface?.TogglePluginInstallerWindow();
dalamudInterface?.TogglePluginInstallerWindowTo(this.configuration.PluginInstallerOpen);
break;
case 69421:
dalamudInterface?.ToggleSettingsWindow();

View file

@ -351,7 +351,8 @@ internal class DalamudCommands : IServiceType
private void OnOpenInstallerCommand(string command, string arguments)
{
Service<DalamudInterface>.Get().TogglePluginInstallerWindow();
var configuration = Service<DalamudConfiguration>.Get();
Service<DalamudInterface>.Get().TogglePluginInstallerWindowTo(configuration.PluginInstallerOpen);
}
private void OnSetLanguageCommand(string command, string arguments)

View file

@ -254,18 +254,10 @@ internal class DalamudInterface : IDisposable, IServiceType
/// <summary>
/// Opens the <see cref="PluginInstallerWindow"/> on the plugin installed.
/// </summary>
public void OpenPluginInstallerPluginInstalled()
/// <param name="kind">The page of the installer to open.</param>
public void OpenPluginInstallerTo(PluginInstallerWindow.PluginInstallerOpenKind kind)
{
this.pluginWindow.OpenInstalledPlugins();
this.pluginWindow.BringToFront();
}
/// <summary>
/// Opens the <see cref="PluginInstallerWindow"/> on the plugin changelogs.
/// </summary>
public void OpenPluginInstallerPluginChangelogs()
{
this.pluginWindow.OpenPluginChangelogs();
this.pluginWindow.OpenTo(kind);
this.pluginWindow.BringToFront();
}
@ -397,7 +389,7 @@ internal class DalamudInterface : IDisposable, IServiceType
/// <summary>
/// Toggles the <see cref="PluginInstallerWindow"/>.
/// </summary>
public void TogglePluginInstallerWindow() => this.pluginWindow.Toggle();
public void TogglePluginInstallerWindowTo(PluginInstallerWindow.PluginInstallerOpenKind kind) => this.pluginWindow.ToggleTo(kind);
/// <summary>
/// Toggles the <see cref="SettingsWindow"/>.

View file

@ -1242,7 +1242,8 @@ internal class InterfaceManager : IDisposable, IServiceType
if (gamepadState.Pressed(GamepadButtons.R3) > 0)
{
dalamudInterface.TogglePluginInstallerWindow();
var configuration = Service<DalamudConfiguration>.Get();
dalamudInterface.TogglePluginInstallerWindowTo(configuration.PluginInstallerOpen);
}
}
}

View file

@ -129,7 +129,7 @@ internal class PluginCategoryManager
/// <summary>
/// Gets a value indicating whether current group + category selection changed recently.
/// Changes in Available group should be followed with <see cref="GetCurrentCategoryContent"/>, everythine else can use <see cref="ResetContentDirty"/>.
/// Changes in Available group should be followed with <see cref="GetCurrentCategoryContent"/>, everything else can use <see cref="ResetContentDirty"/>.
/// </summary>
public bool IsContentDirty => this.isContentDirty;

View file

@ -173,6 +173,27 @@ internal class PluginInstallerWindow : Window, IDisposable
this.profileManagerWidget = new(this);
}
/// <summary>
/// Enum describing pages the plugin installer can be opened to.
/// </summary>
public enum PluginInstallerOpenKind
{
/// <summary>
/// Open to the "All Plugins" page.
/// </summary>
AllPlugins,
/// <summary>
/// Open to the "Installed Plugins" page.
/// </summary>
InstalledPlugins,
/// <summary>
/// Open to the "Changelogs" page.
/// </summary>
Changelogs,
}
private enum OperationStatus
{
Idle,
@ -220,6 +241,28 @@ internal class PluginInstallerWindow : Window, IDisposable
}
}
/// <summary>
/// Open to the installer to the page specified by <paramref name="kind"/>.
/// </summary>
/// <param name="kind">The page of the installer to open.</param>
public void OpenTo(PluginInstallerOpenKind kind)
{
this.IsOpen = true;
this.SetOpenPage(kind);
}
/// <summary>
/// Toggle to the installer to the page specified by <paramref name="kind"/>.
/// </summary>
/// <param name="kind">The page of the installer to open.</param>
public void ToggleTo(PluginInstallerOpenKind kind)
{
this.Toggle();
if (this.IsOpen)
this.SetOpenPage(kind);
}
/// <inheritdoc/>
public override void OnOpen()
{
@ -278,30 +321,6 @@ 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>
public void OpenPluginChangelogs()
{
// Changelog group
this.categoryManager.CurrentGroupIdx = 3;
// Plugins category
this.categoryManager.CurrentCategoryIdx = 2;
this.IsOpen = true;
}
/// <summary>
/// Sets the current search text and marks it as prefilled.
/// </summary>
@ -386,6 +405,33 @@ internal class PluginInstallerWindow : Window, IDisposable
return true;
}
private void SetOpenPage(PluginInstallerOpenKind kind)
{
switch (kind)
{
case PluginInstallerOpenKind.AllPlugins:
// Plugins group
this.categoryManager.CurrentGroupIdx = 0;
// All category
this.categoryManager.CurrentCategoryIdx = 0;
break;
case PluginInstallerOpenKind.InstalledPlugins:
// Installed group
this.categoryManager.CurrentGroupIdx = 2;
// All category
this.categoryManager.CurrentCategoryIdx = 0;
break;
case PluginInstallerOpenKind.Changelogs:
// Changelog group
this.categoryManager.CurrentGroupIdx = 3;
// Plugins category
this.categoryManager.CurrentCategoryIdx = 2;
break;
default:
throw new ArgumentOutOfRangeException(nameof(kind), kind, null);
}
}
private void DrawProgressOverlay()
{
var pluginManager = Service<PluginManager>.Get();

View file

@ -4,6 +4,7 @@ using System.Diagnostics.CodeAnalysis;
using CheapLoc;
using Dalamud.Configuration.Internal;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Internal.Windows.PluginInstaller;
using Dalamud.Interface.Internal.Windows.Settings.Widgets;
using Dalamud.Interface.Utility;
using Dalamud.Utility;
@ -120,6 +121,12 @@ public class SettingsTabLook : SettingsTab
Loc.Localize("DalamudSettingToggleTsmHint", "This will allow you to access certain Dalamud and Plugin functionality from the title screen."),
c => c.ShowTsm,
(v, c) => c.ShowTsm = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingInstallerOpenDefault", "Open the Plugin Installer to the \"Installed Plugins\" tab by default"),
Loc.Localize("DalamudSettingInstallerOpenDefaultHint", "This will allow you to open the Plugin Installer to the \"Installed Plugins\" tab by default, instead of the \"Available Plugins\" tab."),
c => c.PluginInstallerOpen == PluginInstallerWindow.PluginInstallerOpenKind.InstalledPlugins,
(v, c) => c.PluginInstallerOpen = v ? PluginInstallerWindow.PluginInstallerOpenKind.InstalledPlugins : PluginInstallerWindow.PluginInstallerOpenKind.AllPlugins),
};
public override string Title => Loc.Localize("DalamudSettingsVisual", "Look & Feel");

View file

@ -223,7 +223,7 @@ public sealed class DalamudPluginInterface : IDisposable
return false;
}
dalamudInterface.OpenPluginInstallerPluginInstalled();
dalamudInterface.OpenPluginInstallerTo(PluginInstallerWindow.PluginInstallerOpenKind.InstalledPlugins);
dalamudInterface.SetPluginInstallerSearchText(this.plugin.InternalName);
return true;

View file

@ -19,6 +19,7 @@ using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Internal.Windows.PluginInstaller;
using Dalamud.IoC.Internal;
using Dalamud.Logging.Internal;
using Dalamud.Networking.Http;
@ -130,7 +131,7 @@ internal partial class PluginManager : IDisposable, IServiceType
this.openInstallerWindowPluginChangelogsLink = Service<ChatGui>.Get().AddChatLinkHandler("Dalamud", 1003, (_, _) =>
{
Service<DalamudInterface>.GetNullable()?.OpenPluginInstallerPluginChangelogs();
Service<DalamudInterface>.GetNullable()?.OpenPluginInstallerTo(PluginInstallerWindow.PluginInstallerOpenKind.Changelogs);
});
this.configuration.PluginTestingOptIns ??= new List<PluginTestingOptIn>();