DalamudPluginInterface functions for opening Settings and DevMenu (#1795)

* Add functions for plugins to open the Developer Menu and Dalamud Settings windows

* Do not break ABI by instead declaring a new method OpenPluginsInstallerTo
Replace OpenDalamudSettings with OpenDalamudSettingsTo
This commit is contained in:
meoiswa 2024-04-30 00:30:09 +02:00 committed by GitHub
parent 5dd627d18e
commit 00311b4dca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 335 additions and 112 deletions

View file

@ -6,6 +6,7 @@ using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Dalamud.Game.Text; using Dalamud.Game.Text;
using Dalamud.Interface;
using Dalamud.Interface.FontIdentifier; using Dalamud.Interface.FontIdentifier;
using Dalamud.Interface.Internal.Windows.PluginInstaller; using Dalamud.Interface.Internal.Windows.PluginInstaller;
using Dalamud.Interface.Style; using Dalamud.Interface.Style;
@ -452,7 +453,7 @@ internal sealed class DalamudConfiguration : IInternalDisposableService
/// <summary> /// <summary>
/// Gets or sets the page of the plugin installer that is shown by default when opened. /// Gets or sets the page of the plugin installer that is shown by default when opened.
/// </summary> /// </summary>
public PluginInstallerWindow.PluginInstallerOpenKind PluginInstallerOpen { get; set; } = PluginInstallerWindow.PluginInstallerOpenKind.AllPlugins; public PluginInstallerOpenKind PluginInstallerOpen { get; set; } = PluginInstallerOpenKind.AllPlugins;
/// <summary> /// <summary>
/// Load a configuration from the provided path. /// Load a configuration from the provided path.

View file

@ -12,6 +12,7 @@ using Dalamud.Game.Gui;
using Dalamud.Game.Text; using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface;
using Dalamud.Interface.ImGuiNotification.Internal; using Dalamud.Interface.ImGuiNotification.Internal;
using Dalamud.Interface.Internal; using Dalamud.Interface.Internal;
using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Internal.Notifications;
@ -125,7 +126,7 @@ internal class ChatHandlers : IServiceType
this.openInstallerWindowLink = chatGui.AddChatLinkHandler("Dalamud", 1001, (i, m) => this.openInstallerWindowLink = chatGui.AddChatLinkHandler("Dalamud", 1001, (i, m) =>
{ {
Service<DalamudInterface>.GetNullable()?.OpenPluginInstallerTo(PluginInstallerWindow.PluginInstallerOpenKind.InstalledPlugins); Service<DalamudInterface>.GetNullable()?.OpenPluginInstallerTo(PluginInstallerOpenKind.InstalledPlugins);
}); });
} }

View file

@ -0,0 +1,53 @@
namespace Dalamud.Interface;
/// <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,
}
/// <summary>
/// Enum describing tabs the settings window can be opened to.
/// </summary>
public enum SettingsOpenKind
{
/// <summary>
/// Open to the "General" page.
/// </summary>
General,
/// <summary>
/// Open to the "Look &#038; Feel" page.
/// </summary>
LookAndFeel,
/// <summary>
/// Open to the "Server Info Bar" page.
/// </summary>
ServerInfoBar,
/// <summary>
/// Open to the "Experimental" page.
/// </summary>
Experimental,
/// <summary>
/// Open to the "About" page.
/// </summary>
About,
}

View file

@ -290,10 +290,10 @@ internal class DalamudInterface : IInternalDisposableService
} }
/// <summary> /// <summary>
/// Opens the <see cref="PluginInstallerWindow"/> on the plugin installed. /// Opens the <see cref="PluginInstallerWindow"/> on the specified page.
/// </summary> /// </summary>
/// <param name="kind">The page of the installer to open.</param> /// <param name="kind">The page of the installer to open.</param>
public void OpenPluginInstallerTo(PluginInstallerWindow.PluginInstallerOpenKind kind) public void OpenPluginInstallerTo(PluginInstallerOpenKind kind)
{ {
this.pluginWindow.OpenTo(kind); this.pluginWindow.OpenTo(kind);
this.pluginWindow.BringToFront(); this.pluginWindow.BringToFront();
@ -308,6 +308,16 @@ internal class DalamudInterface : IInternalDisposableService
this.settingsWindow.BringToFront(); this.settingsWindow.BringToFront();
} }
/// <summary>
/// Opens the <see cref="SettingsWindow"/> on the specified tab.
/// </summary>
/// <param name="kind">The tab of the settings to open.</param>
public void OpenSettingsTo(SettingsOpenKind kind)
{
this.settingsWindow.OpenTo(kind);
this.settingsWindow.BringToFront();
}
/// <summary> /// <summary>
/// Opens the <see cref="SelfTestWindow"/>. /// Opens the <see cref="SelfTestWindow"/>.
/// </summary> /// </summary>
@ -418,7 +428,7 @@ internal class DalamudInterface : IInternalDisposableService
/// Toggles the <see cref="PluginInstallerWindow"/>. /// Toggles the <see cref="PluginInstallerWindow"/>.
/// </summary> /// </summary>
/// <param name="kind">The page of the installer to open.</param> /// <param name="kind">The page of the installer to open.</param>
public void TogglePluginInstallerWindowTo(PluginInstallerWindow.PluginInstallerOpenKind kind) => this.pluginWindow.ToggleTo(kind); public void TogglePluginInstallerWindowTo(PluginInstallerOpenKind kind) => this.pluginWindow.ToggleTo(kind);
/// <summary> /// <summary>
/// Toggles the <see cref="SettingsWindow"/>. /// Toggles the <see cref="SettingsWindow"/>.
@ -456,6 +466,15 @@ internal class DalamudInterface : IInternalDisposableService
this.pluginWindow.SetSearchText(text); this.pluginWindow.SetSearchText(text);
} }
/// <summary>
/// Sets the current search text for the settings window.
/// </summary>
/// <param name="text">The search term.</param>
public void SetSettingsSearchText(string text)
{
this.settingsWindow.SetSearchText(text);
}
/// <summary> /// <summary>
/// Toggle the screen darkening effect used for the credits. /// Toggle the screen darkening effect used for the credits.
/// </summary> /// </summary>

View file

@ -10,6 +10,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using CheapLoc; using CheapLoc;
using Dalamud.Configuration.Internal; using Dalamud.Configuration.Internal;
using Dalamud.Game.Command; using Dalamud.Game.Command;
using Dalamud.Interface.Animation.EasingFunctions; using Dalamud.Interface.Animation.EasingFunctions;
@ -29,6 +30,7 @@ using Dalamud.Plugin.Internal.Types;
using Dalamud.Plugin.Internal.Types.Manifest; using Dalamud.Plugin.Internal.Types.Manifest;
using Dalamud.Support; using Dalamud.Support;
using Dalamud.Utility; using Dalamud.Utility;
using ImGuiNET; using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.PluginInstaller; namespace Dalamud.Interface.Internal.Windows.PluginInstaller;
@ -175,27 +177,6 @@ internal class PluginInstallerWindow : Window, IDisposable
this.profileManagerWidget = new(this); 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 private enum OperationStatus
{ {
Idle, Idle,
@ -329,8 +310,16 @@ internal class PluginInstallerWindow : Window, IDisposable
/// <param name="text">The search term.</param> /// <param name="text">The search term.</param>
public void SetSearchText(string text) public void SetSearchText(string text)
{ {
this.isSearchTextPrefilled = true; if (string.IsNullOrEmpty(text))
this.searchText = text; {
this.isSearchTextPrefilled = false;
this.searchText = string.Empty;
}
else
{
this.isSearchTextPrefilled = true;
this.searchText = text;
}
} }
/// <summary> /// <summary>
@ -591,7 +580,7 @@ internal class PluginInstallerWindow : Window, IDisposable
var isProfileManager = var isProfileManager =
this.categoryManager.CurrentGroupIdx == 1 && this.categoryManager.CurrentCategoryIdx == 2; this.categoryManager.CurrentGroupIdx == 1 && this.categoryManager.CurrentCategoryIdx == 2;
// Disable search if profile editor // Disable search if profile editor
using (ImRaii.Disabled(isProfileManager)) using (ImRaii.Disabled(isProfileManager))
{ {
@ -637,7 +626,7 @@ internal class PluginInstallerWindow : Window, IDisposable
lock (this.listLock) lock (this.listLock)
{ {
this.ResortPlugins(); this.ResortPlugins();
// Positions of plugins within the list is likely to change // Positions of plugins within the list is likely to change
this.openPluginCollapsibles.Clear(); this.openPluginCollapsibles.Clear();
} }
@ -742,7 +731,7 @@ internal class PluginInstallerWindow : Window, IDisposable
var errorMessage = this.updatePluginCount > 0 var errorMessage = this.updatePluginCount > 0
? Locs.ErrorModal_UpdaterFailPartial(this.updatePluginCount, errorPluginCount) ? Locs.ErrorModal_UpdaterFailPartial(this.updatePluginCount, errorPluginCount)
: Locs.ErrorModal_UpdaterFail(errorPluginCount); : Locs.ErrorModal_UpdaterFail(errorPluginCount);
var hintInsert = errorPlugins var hintInsert = errorPlugins
.Aggregate(string.Empty, (current, pluginUpdateStatus) => $"{current}* {pluginUpdateStatus.InternalName} ({PluginUpdateStatus.LocalizeUpdateStatusKind(pluginUpdateStatus.Status)})\n") .Aggregate(string.Empty, (current, pluginUpdateStatus) => $"{current}* {pluginUpdateStatus.InternalName} ({PluginUpdateStatus.LocalizeUpdateStatusKind(pluginUpdateStatus.Status)})\n")
.TrimEnd(); .TrimEnd();
@ -887,7 +876,7 @@ internal class PluginInstallerWindow : Window, IDisposable
this.deletePluginConfigWarningModalTaskCompletionSource = new TaskCompletionSource<bool>(); this.deletePluginConfigWarningModalTaskCompletionSource = new TaskCompletionSource<bool>();
return this.deletePluginConfigWarningModalTaskCompletionSource.Task; return this.deletePluginConfigWarningModalTaskCompletionSource.Task;
} }
private void DrawDeletePluginConfigWarningModal() private void DrawDeletePluginConfigWarningModal()
{ {
var modalTitle = Locs.DeletePluginConfigWarningModal_Title; var modalTitle = Locs.DeletePluginConfigWarningModal_Title;
@ -913,7 +902,7 @@ internal class PluginInstallerWindow : Window, IDisposable
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
this.deletePluginConfigWarningModalTaskCompletionSource?.SetResult(false); this.deletePluginConfigWarningModalTaskCompletionSource?.SetResult(false);
} }
ImGui.EndPopup(); ImGui.EndPopup();
} }
@ -1135,7 +1124,7 @@ internal class PluginInstallerWindow : Window, IDisposable
private IEnumerable<PluginInstallerAvailablePluginProxy> GatherProxies() private IEnumerable<PluginInstallerAvailablePluginProxy> GatherProxies()
{ {
var proxies = new List<PluginInstallerAvailablePluginProxy>(); var proxies = new List<PluginInstallerAvailablePluginProxy>();
var availableManifests = this.pluginListAvailable; var availableManifests = this.pluginListAvailable;
var installedPlugins = this.pluginListInstalled.ToList(); // Copy intended var installedPlugins = this.pluginListInstalled.ToList(); // Copy intended
@ -1162,27 +1151,27 @@ internal class PluginInstallerWindow : Window, IDisposable
.FirstOrDefault(plugin => plugin.Manifest.InternalName == availableManifest.InternalName && .FirstOrDefault(plugin => plugin.Manifest.InternalName == availableManifest.InternalName &&
plugin.Manifest.RepoUrl == availableManifest.RepoUrl && plugin.Manifest.RepoUrl == availableManifest.RepoUrl &&
!plugin.IsDev); !plugin.IsDev);
// We "consumed" this plugin from the pile and remove it. // We "consumed" this plugin from the pile and remove it.
if (plugin != null) if (plugin != null)
{ {
installedPlugins.Remove(plugin); installedPlugins.Remove(plugin);
proxies.Add(new PluginInstallerAvailablePluginProxy(availableManifest, plugin)); proxies.Add(new PluginInstallerAvailablePluginProxy(availableManifest, plugin));
continue; continue;
} }
proxies.Add(new PluginInstallerAvailablePluginProxy(availableManifest, null)); proxies.Add(new PluginInstallerAvailablePluginProxy(availableManifest, null));
} }
// Now, add all applicable local plugins that haven't been "used up", in most cases either dev or orphaned plugins. // Now, add all applicable local plugins that haven't been "used up", in most cases either dev or orphaned plugins.
foreach (var installedPlugin in installedPlugins) foreach (var installedPlugin in installedPlugins)
{ {
if (this.IsManifestFiltered(installedPlugin.Manifest)) if (this.IsManifestFiltered(installedPlugin.Manifest))
continue; continue;
// TODO: We should also check categories here, for good measure // TODO: We should also check categories here, for good measure
proxies.Add(new PluginInstallerAvailablePluginProxy(null, installedPlugin)); proxies.Add(new PluginInstallerAvailablePluginProxy(null, installedPlugin));
} }
@ -1199,7 +1188,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (applicableManifest == null) if (applicableManifest == null)
throw new Exception("Could not determine manifest for available plugin"); throw new Exception("Could not determine manifest for available plugin");
ImGui.PushID($"{applicableManifest.InternalName}{applicableManifest.AssemblyVersion}"); ImGui.PushID($"{applicableManifest.InternalName}{applicableManifest.AssemblyVersion}");
if (proxy.LocalPlugin != null) if (proxy.LocalPlugin != null)
@ -1246,7 +1235,7 @@ internal class PluginInstallerWindow : Window, IDisposable
var remoteManifest = this.pluginListAvailable var remoteManifest = this.pluginListAvailable
.FirstOrDefault(rm => rm.InternalName == plugin.Manifest.InternalName && .FirstOrDefault(rm => rm.InternalName == plugin.Manifest.InternalName &&
rm.RepoUrl == plugin.Manifest.RepoUrl); rm.RepoUrl == plugin.Manifest.RepoUrl);
this.DrawInstalledPlugin(plugin, i++, remoteManifest); this.DrawInstalledPlugin(plugin, i++, remoteManifest);
} }
} }
@ -1291,7 +1280,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (installerMainChild) if (installerMainChild)
{ {
using var style = ImRaii.PushStyle(ImGuiStyleVar.CellPadding, ImGuiHelpers.ScaledVector2(5, 0)); using var style = ImRaii.PushStyle(ImGuiStyleVar.CellPadding, ImGuiHelpers.ScaledVector2(5, 0));
try try
{ {
using (var categoriesChild = ImRaii.Child("InstallerCategoriesSelector", new Vector2(useMenuWidth * ImGuiHelpers.GlobalScale, -1), false)) using (var categoriesChild = ImRaii.Child("InstallerCategoriesSelector", new Vector2(useMenuWidth * ImGuiHelpers.GlobalScale, -1), false))
@ -1832,17 +1821,17 @@ internal class PluginInstallerWindow : Window, IDisposable
{ {
iconTex = cachedIconTex; iconTex = cachedIconTex;
} }
const float fadeTime = 0.3f; const float fadeTime = 0.3f;
var iconAlpha = 1f; var iconAlpha = 1f;
if (loadedSince.HasValue) if (loadedSince.HasValue)
{ {
float EaseOutCubic(float t) => 1 - MathF.Pow(1 - t, 3); float EaseOutCubic(float t) => 1 - MathF.Pow(1 - t, 3);
var secondsSinceLoad = (float)DateTime.Now.Subtract(loadedSince.Value).TotalSeconds; var secondsSinceLoad = (float)DateTime.Now.Subtract(loadedSince.Value).TotalSeconds;
var fadeTo = pluginDisabled || installableOutdated ? 0.4f : 1f; var fadeTo = pluginDisabled || installableOutdated ? 0.4f : 1f;
float Interp(float to) => Math.Clamp(EaseOutCubic(Math.Min(secondsSinceLoad, fadeTime) / fadeTime) * to, 0, 1); float Interp(float to) => Math.Clamp(EaseOutCubic(Math.Min(secondsSinceLoad, fadeTime) / fadeTime) * to, 0, 1);
iconAlpha = Interp(fadeTo); iconAlpha = Interp(fadeTo);
overlayAlpha = Interp(1f); overlayAlpha = Interp(1f);
@ -1878,7 +1867,7 @@ internal class PluginInstallerWindow : Window, IDisposable
else else
ImGui.Dummy(iconSize); ImGui.Dummy(iconSize);
ImGui.PopStyleVar(); ImGui.PopStyleVar();
ImGui.SameLine(); ImGui.SameLine();
ImGuiHelpers.ScaledDummy(5); ImGuiHelpers.ScaledDummy(5);
@ -1888,7 +1877,7 @@ internal class PluginInstallerWindow : Window, IDisposable
// Name // Name
ImGui.TextUnformatted(label); ImGui.TextUnformatted(label);
// Verified Checkmark or dev plugin wrench // Verified Checkmark or dev plugin wrench
{ {
ImGui.SameLine(); ImGui.SameLine();
@ -1946,7 +1935,7 @@ internal class PluginInstallerWindow : Window, IDisposable
bodyText += Locs.PluginBody_Outdated_CanNowUpdate; bodyText += Locs.PluginBody_Outdated_CanNowUpdate;
else else
bodyText += Locs.PluginBody_Outdated_WaitForUpdate; bodyText += Locs.PluginBody_Outdated_WaitForUpdate;
ImGui.TextWrapped(bodyText); ImGui.TextWrapped(bodyText);
ImGui.PopStyleColor(); ImGui.PopStyleColor();
} }
@ -1954,17 +1943,17 @@ internal class PluginInstallerWindow : Window, IDisposable
{ {
// Banned warning // Banned warning
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed); ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
var bodyText = plugin.BanReason.IsNullOrEmpty() var bodyText = plugin.BanReason.IsNullOrEmpty()
? Locs.PluginBody_Banned ? Locs.PluginBody_Banned
: Locs.PluginBody_BannedReason(plugin.BanReason); : Locs.PluginBody_BannedReason(plugin.BanReason);
bodyText += " "; bodyText += " ";
if (updateAvailable) if (updateAvailable)
bodyText += Locs.PluginBody_Outdated_CanNowUpdate; bodyText += Locs.PluginBody_Outdated_CanNowUpdate;
else else
bodyText += Locs.PluginBody_Outdated_WaitForUpdate; bodyText += Locs.PluginBody_Outdated_WaitForUpdate;
ImGuiHelpers.SafeTextWrapped(bodyText); ImGuiHelpers.SafeTextWrapped(bodyText);
ImGui.PopStyleColor(); ImGui.PopStyleColor();
@ -2189,13 +2178,13 @@ internal class PluginInstallerWindow : Window, IDisposable
ImGui.SameLine(); ImGui.SameLine();
ImGuiHelpers.ScaledDummy(3); ImGuiHelpers.ScaledDummy(3);
} }
if (!manifest.SourceRepo.IsThirdParty && manifest.AcceptsFeedback) if (!manifest.SourceRepo.IsThirdParty && manifest.AcceptsFeedback)
{ {
ImGui.SameLine(); ImGui.SameLine();
this.DrawSendFeedbackButton(manifest, false, true); this.DrawSendFeedbackButton(manifest, false, true);
} }
ImGuiHelpers.ScaledDummy(5); ImGuiHelpers.ScaledDummy(5);
if (this.DrawPluginImages(null, manifest, isThirdParty, index)) if (this.DrawPluginImages(null, manifest, isThirdParty, index))
@ -2323,11 +2312,11 @@ internal class PluginInstallerWindow : Window, IDisposable
} }
var availablePluginUpdate = this.pluginListUpdatable.FirstOrDefault(up => up.InstalledPlugin == plugin); 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;
// Update available // Update available
if (availablePluginUpdate != default) if (availablePluginUpdate != default)
{ {
@ -2388,7 +2377,7 @@ internal class PluginInstallerWindow : Window, IDisposable
} }
ImGui.PushID($"installed{index}{plugin.Manifest.InternalName}"); ImGui.PushID($"installed{index}{plugin.Manifest.InternalName}");
var applicableChangelog = plugin.IsTesting ? remoteManifest?.Changelog : remoteManifest?.TestingChangelog; var applicableChangelog = plugin.IsTesting ? remoteManifest?.Changelog : remoteManifest?.TestingChangelog;
var hasChangelog = !applicableChangelog.IsNullOrWhitespace(); var hasChangelog = !applicableChangelog.IsNullOrWhitespace();
var didDrawChangelogInsideCollapsible = false; var didDrawChangelogInsideCollapsible = false;
@ -2457,7 +2446,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (plugin.IsLoaded) if (plugin.IsLoaded)
{ {
var commands = commandManager.Commands var commands = commandManager.Commands
.Where(cInfo => .Where(cInfo =>
cInfo.Value is { ShowInHelp: true } && cInfo.Value is { ShowInHelp: true } &&
cInfo.Value.LoaderAssemblyName == plugin.Manifest.InternalName) cInfo.Value.LoaderAssemblyName == plugin.Manifest.InternalName)
.ToArray(); .ToArray();
@ -2469,7 +2458,7 @@ internal class PluginInstallerWindow : Window, IDisposable
{ {
ImGuiHelpers.SafeTextWrapped($"{command.Key} → {command.Value.HelpMessage}"); ImGuiHelpers.SafeTextWrapped($"{command.Key} → {command.Value.HelpMessage}");
} }
ImGuiHelpers.ScaledDummy(3); ImGuiHelpers.ScaledDummy(3);
} }
} }
@ -2749,7 +2738,7 @@ internal class PluginInstallerWindow : Window, IDisposable
var applicableProfile = profilesThatWantThisPlugin.First(); var applicableProfile = profilesThatWantThisPlugin.First();
Log.Verbose("Switching {InternalName} in {Profile} to {State}", Log.Verbose("Switching {InternalName} in {Profile} to {State}",
plugin.InternalName, applicableProfile, isLoadedAndUnloadable); plugin.InternalName, applicableProfile, isLoadedAndUnloadable);
try try
{ {
// Reload the devPlugin manifest if it's a dev plugin // Reload the devPlugin manifest if it's a dev plugin
@ -2763,7 +2752,7 @@ internal class PluginInstallerWindow : Window, IDisposable
{ {
Log.Error(ex, "Could not reload DevPlugin manifest"); Log.Error(ex, "Could not reload DevPlugin manifest");
} }
// NOTE: We don't use the profile manager to actually handle loading/unloading here, // NOTE: We don't use the profile manager to actually handle loading/unloading here,
// because that might cause us to show an error if a plugin we don't actually care about // because that might cause us to show an error if a plugin we don't actually care about
// fails to load/unload. Instead, we just do it ourselves and then update the profile. // fails to load/unload. Instead, we just do it ourselves and then update the profile.
@ -2842,7 +2831,7 @@ internal class PluginInstallerWindow : Window, IDisposable
{ {
// Only if the plugin isn't broken. // Only if the plugin isn't broken.
this.DrawOpenPluginSettingsButton(plugin); this.DrawOpenPluginSettingsButton(plugin);
ImGui.SameLine(); ImGui.SameLine();
ImGuiHelpers.ScaledDummy(5, 0); ImGuiHelpers.ScaledDummy(5, 0);
} }
@ -2891,7 +2880,7 @@ internal class PluginInstallerWindow : Window, IDisposable
Locs.ErrorModal_SingleUpdateFail(update.UpdateManifest.Name, PluginUpdateStatus.LocalizeUpdateStatusKind(task.Result.Status))); Locs.ErrorModal_SingleUpdateFail(update.UpdateManifest.Name, PluginUpdateStatus.LocalizeUpdateStatusKind(task.Result.Status)));
return false; return false;
} }
return this.DisplayErrorContinuation(task, Locs.ErrorModal_SingleUpdateFail(update.UpdateManifest.Name, "Exception")); return this.DisplayErrorContinuation(task, Locs.ErrorModal_SingleUpdateFail(update.UpdateManifest.Name, "Exception"));
}); });
} }
@ -2944,7 +2933,7 @@ internal class PluginInstallerWindow : Window, IDisposable
ImGui.SameLine(); ImGui.SameLine();
ImGuiHelpers.ScaledDummy(5, 0); ImGuiHelpers.ScaledDummy(5, 0);
} }
ImGui.SameLine(); ImGui.SameLine();
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Cog, Locs.PluginButton_OpenSettings)) if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Cog, Locs.PluginButton_OpenSettings))
{ {
@ -2967,10 +2956,10 @@ internal class PluginInstallerWindow : Window, IDisposable
private void DrawSendFeedbackButton(IPluginManifest manifest, bool isTesting, bool big) private void DrawSendFeedbackButton(IPluginManifest manifest, bool isTesting, bool big)
{ {
var clicked = big ? var clicked = big ?
ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Comment, Locs.FeedbackModal_Title) : ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Comment, Locs.FeedbackModal_Title) :
ImGuiComponents.IconButton(FontAwesomeIcon.Comment); ImGuiComponents.IconButton(FontAwesomeIcon.Comment);
if (clicked) if (clicked)
{ {
this.feedbackPlugin = manifest; this.feedbackPlugin = manifest;
@ -3009,7 +2998,7 @@ internal class PluginInstallerWindow : Window, IDisposable
var validationIssuesText = shouldBother ? var validationIssuesText = shouldBother ?
$"Found {problems.Count} validation issue{(problems.Count > 1 ? "s" : string.Empty)} in this plugin!" : $"Found {problems.Count} validation issue{(problems.Count > 1 ? "s" : string.Empty)} in this plugin!" :
$"{problems.Count} dismissed validation issue{(problems.Count > 1 ? "s" : string.Empty)} in this plugin."; $"{problems.Count} dismissed validation issue{(problems.Count > 1 ? "s" : string.Empty)} in this plugin.";
using var col = ImRaii.PushColor(ImGuiCol.Text, shouldBother ? ImGuiColors.DalamudOrange : ImGuiColors.DalamudGrey); using var col = ImRaii.PushColor(ImGuiCol.Text, shouldBother ? ImGuiColors.DalamudOrange : ImGuiColors.DalamudGrey);
using var tree = ImRaii.TreeNode($"{validationIssuesText}###validationIssueCollapsible"); using var tree = ImRaii.TreeNode($"{validationIssuesText}###validationIssueCollapsible");
if (tree.Success) if (tree.Success)
@ -3029,7 +3018,7 @@ internal class PluginInstallerWindow : Window, IDisposable
devPlugin.DismissedValidationProblems.Add(problem.GetType().Name); devPlugin.DismissedValidationProblems.Add(problem.GetType().Name);
Service<DalamudConfiguration>.Get().QueueSave(); Service<DalamudConfiguration>.Get().QueueSave();
} }
if (ImGui.IsItemHovered()) if (ImGui.IsItemHovered())
{ {
ImGui.SetTooltip("Dismiss this issue"); ImGui.SetTooltip("Dismiss this issue");
@ -3065,7 +3054,7 @@ internal class PluginInstallerWindow : Window, IDisposable
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
} }
ImGui.SameLine(); ImGui.SameLine();
using (ImRaii.PushColor(ImGuiCol.Text, thisProblemIsDismissed ? ImGuiColors.DalamudGrey : ImGuiColors.DalamudWhite)) using (ImRaii.PushColor(ImGuiCol.Text, thisProblemIsDismissed ? ImGuiColors.DalamudGrey : ImGuiColors.DalamudWhite))
@ -3216,7 +3205,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (!string.IsNullOrEmpty(repoUrl) && repoUrl.StartsWith("https://")) if (!string.IsNullOrEmpty(repoUrl) && repoUrl.StartsWith("https://"))
{ {
ImGui.SameLine(); ImGui.SameLine();
var clicked = big ? var clicked = big ?
ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Globe, "Open website") : ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Globe, "Open website") :
ImGuiComponents.IconButton(FontAwesomeIcon.Globe); ImGuiComponents.IconButton(FontAwesomeIcon.Globe);
@ -3403,7 +3392,7 @@ internal class PluginInstallerWindow : Window, IDisposable
// not the actual time of the last update, as the plugin may be pending an update // not the actual time of the last update, as the plugin may be pending an update
IPluginManifest? p2Considered = this.pluginListAvailable.FirstOrDefault(x => x.InternalName == p2.InternalName); IPluginManifest? p2Considered = this.pluginListAvailable.FirstOrDefault(x => x.InternalName == p2.InternalName);
p2Considered ??= p2.Manifest; p2Considered ??= p2.Manifest;
IPluginManifest? p1Considered = this.pluginListAvailable.FirstOrDefault(x => x.InternalName == p1.InternalName); IPluginManifest? p1Considered = this.pluginListAvailable.FirstOrDefault(x => x.InternalName == p1.InternalName);
p1Considered ??= p1.Manifest; p1Considered ??= p1.Manifest;
@ -3435,7 +3424,7 @@ internal class PluginInstallerWindow : Window, IDisposable
break; break;
case PluginSortKind.ProfileOrNot: case PluginSortKind.ProfileOrNot:
this.pluginListAvailable.Sort((p1, p2) => p1.Name.CompareTo(p2.Name)); this.pluginListAvailable.Sort((p1, p2) => p1.Name.CompareTo(p2.Name));
var profman = Service<ProfileManager>.Get(); var profman = Service<ProfileManager>.Get();
this.pluginListInstalled.Sort((p1, p2) => profman.IsInDefaultProfile(p1.Manifest.WorkingPluginId).CompareTo(profman.IsInDefaultProfile(p2.Manifest.WorkingPluginId))); this.pluginListInstalled.Sort((p1, p2) => profman.IsInDefaultProfile(p1.Manifest.WorkingPluginId).CompareTo(profman.IsInDefaultProfile(p2.Manifest.WorkingPluginId)));
break; break;
@ -3469,14 +3458,14 @@ internal class PluginInstallerWindow : Window, IDisposable
if (string.IsNullOrEmpty(this.searchText)) if (string.IsNullOrEmpty(this.searchText))
{ {
this.categoryManager.SetCategoryHighlightsForPlugins(null); this.categoryManager.SetCategoryHighlightsForPlugins(null);
// Reset here for good measure, as we're returning from a search // Reset here for good measure, as we're returning from a search
this.openPluginCollapsibles.Clear(); this.openPluginCollapsibles.Clear();
} }
else else
{ {
var pluginsMatchingSearch = this.pluginListAvailable.Where(rm => !this.IsManifestFiltered(rm)).ToArray(); var pluginsMatchingSearch = this.pluginListAvailable.Where(rm => !this.IsManifestFiltered(rm)).ToArray();
// Check if the search results are different, and clear the open collapsibles if they are // Check if the search results are different, and clear the open collapsibles if they are
if (previousSearchText != null) if (previousSearchText != null)
{ {
@ -3484,7 +3473,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (!previousSearchResults.SequenceEqual(pluginsMatchingSearch)) if (!previousSearchResults.SequenceEqual(pluginsMatchingSearch))
this.openPluginCollapsibles.Clear(); this.openPluginCollapsibles.Clear();
} }
this.categoryManager.SetCategoryHighlightsForPlugins(pluginsMatchingSearch); this.categoryManager.SetCategoryHighlightsForPlugins(pluginsMatchingSearch);
} }
} }
@ -3507,38 +3496,38 @@ internal class PluginInstallerWindow : Window, IDisposable
foreach (var y in Enumerable.Range(-1, 3)) foreach (var y in Enumerable.Range(-1, 3))
{ {
if (x is 0 && y is 0) continue; if (x is 0 && y is 0) continue;
ImGui.SetCursorPos(cursorStart + new Vector2(x, y)); ImGui.SetCursorPos(cursorStart + new Vector2(x, y));
ImGui.Text(icon.ToIconString()); ImGui.Text(icon.ToIconString());
} }
} }
ImGui.PopStyleColor(); ImGui.PopStyleColor();
ImGui.PushStyleColor(ImGuiCol.Text, iconColor); ImGui.PushStyleColor(ImGuiCol.Text, iconColor);
ImGui.SetCursorPos(cursorStart); ImGui.SetCursorPos(cursorStart);
ImGui.Text(icon.ToIconString()); ImGui.Text(icon.ToIconString());
ImGui.PopStyleColor(); ImGui.PopStyleColor();
ImGui.PopFont(); ImGui.PopFont();
ImGui.SetCursorPos(ImGui.GetCursorPos() - positionOffset); ImGui.SetCursorPos(ImGui.GetCursorPos() - positionOffset);
} }
// Animates a tooltip when hovering over the ImGui Item before this call. // Animates a tooltip when hovering over the ImGui Item before this call.
private void VerifiedCheckmarkFadeTooltip(string source, string tooltip) private void VerifiedCheckmarkFadeTooltip(string source, string tooltip)
{ {
const float fadeInStartDelay = 250.0f; const float fadeInStartDelay = 250.0f;
var isHoveringSameItem = this.verifiedCheckmarkHoveredPlugin == source; var isHoveringSameItem = this.verifiedCheckmarkHoveredPlugin == source;
// If we just started a hover, start the timer // If we just started a hover, start the timer
if (ImGui.IsItemHovered() && !this.tooltipFadeInStopwatch.IsRunning) if (ImGui.IsItemHovered() && !this.tooltipFadeInStopwatch.IsRunning)
{ {
this.verifiedCheckmarkHoveredPlugin = source; this.verifiedCheckmarkHoveredPlugin = source;
this.tooltipFadeInStopwatch.Restart(); this.tooltipFadeInStopwatch.Restart();
} }
// If we were last hovering this plugins item and are no longer hovered over that item, reset the timer // If we were last hovering this plugins item and are no longer hovered over that item, reset the timer
if (!ImGui.IsItemHovered() && isHoveringSameItem) if (!ImGui.IsItemHovered() && isHoveringSameItem)
{ {
@ -3546,13 +3535,13 @@ internal class PluginInstallerWindow : Window, IDisposable
this.tooltipFadeInStopwatch.Stop(); this.tooltipFadeInStopwatch.Stop();
this.tooltipFadeEasing.Reset(); this.tooltipFadeEasing.Reset();
} }
// If we have been hovering this item for > fadeInStartDelay milliseconds, fade in tooltip over fadeInTime milliseconds // If we have been hovering this item for > fadeInStartDelay milliseconds, fade in tooltip over fadeInTime milliseconds
if (ImGui.IsItemHovered() && isHoveringSameItem && this.tooltipFadeInStopwatch.ElapsedMilliseconds >= fadeInStartDelay) if (ImGui.IsItemHovered() && isHoveringSameItem && this.tooltipFadeInStopwatch.ElapsedMilliseconds >= fadeInStartDelay)
{ {
if (!this.tooltipFadeEasing.IsRunning) if (!this.tooltipFadeEasing.IsRunning)
this.tooltipFadeEasing.Start(); this.tooltipFadeEasing.Start();
this.tooltipFadeEasing.Update(); this.tooltipFadeEasing.Update();
var fadePercent = this.tooltipFadeEasing.EasedPoint.X; var fadePercent = this.tooltipFadeEasing.EasedPoint.X;
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetStyle().Colors[(int)ImGuiCol.Text] with { W = fadePercent }); ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetStyle().Colors[(int)ImGuiCol.Text] with { W = fadePercent });
@ -3697,9 +3686,9 @@ internal class PluginInstallerWindow : Window, IDisposable
public static string PluginBody_Plugin3rdPartyRepo(string url) => Loc.Localize("InstallerPlugin3rdPartyRepo", "From custom plugin repository {0}").Format(url); public static string PluginBody_Plugin3rdPartyRepo(string url) => Loc.Localize("InstallerPlugin3rdPartyRepo", "From custom plugin repository {0}").Format(url);
public static string PluginBody_Outdated => Loc.Localize("InstallerOutdatedPluginBody ", "This plugin is outdated and incompatible."); public static string PluginBody_Outdated => Loc.Localize("InstallerOutdatedPluginBody ", "This plugin is outdated and incompatible.");
public static string PluginBody_Outdated_WaitForUpdate => Loc.Localize("InstallerOutdatedWaitForUpdate", "Please wait for it to be updated by its author."); public static string PluginBody_Outdated_WaitForUpdate => Loc.Localize("InstallerOutdatedWaitForUpdate", "Please wait for it to be updated by its author.");
public static string PluginBody_Outdated_CanNowUpdate => Loc.Localize("InstallerOutdatedCanNowUpdate", "An update is available for installation."); public static string PluginBody_Outdated_CanNowUpdate => Loc.Localize("InstallerOutdatedCanNowUpdate", "An update is available for installation.");
public static string PluginBody_Orphaned => Loc.Localize("InstallerOrphanedPluginBody ", "This plugin's source repository is no longer available. You may need to reinstall it from its repository, or re-add the repository."); public static string PluginBody_Orphaned => Loc.Localize("InstallerOrphanedPluginBody ", "This plugin's source repository is no longer available. You may need to reinstall it from its repository, or re-add the repository.");
@ -3732,15 +3721,15 @@ internal class PluginInstallerWindow : Window, IDisposable
public static string PluginButton_Unload => Loc.Localize("InstallerUnload", "Unload"); public static string PluginButton_Unload => Loc.Localize("InstallerUnload", "Unload");
public static string PluginButton_SafeMode => Loc.Localize("InstallerSafeModeButton", "Can't change in safe mode"); public static string PluginButton_SafeMode => Loc.Localize("InstallerSafeModeButton", "Can't change in safe mode");
public static string PluginButton_OpenUi => Loc.Localize("InstallerOpenPluginUi", "Open"); public static string PluginButton_OpenUi => Loc.Localize("InstallerOpenPluginUi", "Open");
public static string PluginButton_OpenSettings => Loc.Localize("InstallerOpenPluginSettings", "Settings"); public static string PluginButton_OpenSettings => Loc.Localize("InstallerOpenPluginSettings", "Settings");
#endregion #endregion
#region Plugin button tooltips #region Plugin button tooltips
public static string PluginButtonToolTip_OpenUi => Loc.Localize("InstallerTooltipOpenUi", "Open this plugin's interface"); public static string PluginButtonToolTip_OpenUi => Loc.Localize("InstallerTooltipOpenUi", "Open this plugin's interface");
public static string PluginButtonToolTip_OpenConfiguration => Loc.Localize("InstallerTooltipOpenConfig", "Open this plugin's settings"); public static string PluginButtonToolTip_OpenConfiguration => Loc.Localize("InstallerTooltipOpenConfig", "Open this plugin's settings");
@ -3770,9 +3759,9 @@ internal class PluginInstallerWindow : Window, IDisposable
public static string PluginButtonToolTip_UnloadFailed => Loc.Localize("InstallerLoadUnloadFailedTooltip", "Plugin load/unload failed, please restart your game and try again."); public static string PluginButtonToolTip_UnloadFailed => Loc.Localize("InstallerLoadUnloadFailedTooltip", "Plugin load/unload failed, please restart your game and try again.");
public static string PluginButtonToolTip_NeedsToBeInDefault => Loc.Localize("InstallerUnloadNeedsToBeInDefault", "This plugin is in one or more collections. If you want to enable or disable it, please do so by enabling or disabling the collections it is in.\nIf you want to manage it manually, remove it from all collections."); public static string PluginButtonToolTip_NeedsToBeInDefault => Loc.Localize("InstallerUnloadNeedsToBeInDefault", "This plugin is in one or more collections. If you want to enable or disable it, please do so by enabling or disabling the collections it is in.\nIf you want to manage it manually, remove it from all collections.");
public static string PluginButtonToolTip_NeedsToBeInSingleProfile => Loc.Localize("InstallerUnloadNeedsToBeInSingleProfile", "This plugin is in more than one collection. If you want to enable or disable it, please do so by enabling or disabling the collections it is in.\nIf you want to manage it here, make sure it is only in a single collection."); public static string PluginButtonToolTip_NeedsToBeInSingleProfile => Loc.Localize("InstallerUnloadNeedsToBeInSingleProfile", "This plugin is in more than one collection. If you want to enable or disable it, please do so by enabling or disabling the collections it is in.\nIf you want to manage it here, make sure it is only in a single collection.");
public static string PluginButtonToolTip_SingleProfileDisabled(string name) => Loc.Localize("InstallerSingleProfileDisabled", "The collection '{0}' which contains this plugin is disabled.\nPlease enable it in the collections manager to toggle the plugin individually.").Format(name); public static string PluginButtonToolTip_SingleProfileDisabled(string name) => Loc.Localize("InstallerSingleProfileDisabled", "The collection '{0}' which contains this plugin is disabled.\nPlease enable it in the collections manager to toggle the plugin individually.").Format(name);
#endregion #endregion
@ -3930,7 +3919,7 @@ internal class PluginInstallerWindow : Window, IDisposable
public static string DeletePluginConfirmWarningModal_No => Loc.Localize("InstallerDeletePluginConfigWarningNo", "No"); public static string DeletePluginConfirmWarningModal_No => Loc.Localize("InstallerDeletePluginConfigWarningNo", "No");
#endregion #endregion
#region Plugin Update chatbox #region Plugin Update chatbox
public static string PluginUpdateHeader_Chatbox => Loc.Localize("DalamudPluginUpdates", "Updates:"); public static string PluginUpdateHeader_Chatbox => Loc.Localize("DalamudPluginUpdates", "Updates:");
@ -3963,7 +3952,7 @@ internal class PluginInstallerWindow : Window, IDisposable
Loc.Localize("InstallerProfilesRemoveFromAll", "Remove from all collections"); Loc.Localize("InstallerProfilesRemoveFromAll", "Remove from all collections");
#endregion #endregion
#region VerifiedCheckmark #region VerifiedCheckmark
public static string VerifiedCheckmark_VerifiedTooltip => public static string VerifiedCheckmark_VerifiedTooltip =>

View file

@ -2,6 +2,7 @@ using System.Linq;
using System.Numerics; using System.Numerics;
using CheapLoc; using CheapLoc;
using Dalamud.Configuration.Internal; using Dalamud.Configuration.Internal;
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.Interface.Internal.Windows.Settings.Tabs; using Dalamud.Interface.Internal.Windows.Settings.Tabs;
@ -10,6 +11,7 @@ using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.Utility; using Dalamud.Utility;
using ImGuiNET; using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.Settings; namespace Dalamud.Interface.Internal.Windows.Settings;
@ -22,6 +24,9 @@ internal class SettingsWindow : Window
private SettingsTab[]? tabs; private SettingsTab[]? tabs;
private string searchInput = string.Empty; private string searchInput = string.Empty;
private bool isSearchInputPrefilled = false;
private SettingsTab setActiveTab = null!;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SettingsWindow"/> class. /// Initializes a new instance of the <see cref="SettingsWindow"/> class.
@ -39,6 +44,34 @@ internal class SettingsWindow : Window
this.SizeCondition = ImGuiCond.FirstUseEver; this.SizeCondition = ImGuiCond.FirstUseEver;
} }
/// <summary>
/// Open the settings window to the tab specified by <paramref name="kind"/>.
/// </summary>
/// <param name="kind">The tab of the settings window to open.</param>
public void OpenTo(SettingsOpenKind kind)
{
this.IsOpen = true;
this.SetOpenTab(kind);
}
/// <summary>
/// Sets the current search text and marks it as prefilled.
/// </summary>
/// <param name="text">The search term.</param>
public void SetSearchText(string text)
{
if (string.IsNullOrEmpty(text))
{
this.isSearchInputPrefilled = false;
this.searchInput = string.Empty;
}
else
{
this.isSearchInputPrefilled = true;
this.searchInput = text;
}
}
/// <inheritdoc/> /// <inheritdoc/>
public override void OnOpen() public override void OnOpen()
{ {
@ -56,7 +89,7 @@ internal class SettingsWindow : Window
settingsTab.Load(); settingsTab.Load();
} }
this.searchInput = string.Empty; if (!this.isSearchInputPrefilled) this.searchInput = string.Empty;
base.OnOpen(); base.OnOpen();
} }
@ -84,6 +117,12 @@ internal class SettingsWindow : Window
settingsTab.IsOpen = false; settingsTab.IsOpen = false;
} }
if (this.isSearchInputPrefilled)
{
this.isSearchInputPrefilled = false;
this.searchInput = string.Empty;
}
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -97,7 +136,15 @@ internal class SettingsWindow : Window
{ {
foreach (var settingsTab in this.tabs.Where(x => x.IsVisible)) foreach (var settingsTab in this.tabs.Where(x => x.IsVisible))
{ {
if (ImGui.BeginTabItem(settingsTab.Title)) var flags = ImGuiTabItemFlags.NoCloseWithMiddleMouseButton;
if (this.setActiveTab == settingsTab)
{
flags |= ImGuiTabItemFlags.SetSelected;
this.setActiveTab = null;
}
using var tab = ImRaii.TabItem(settingsTab.Title, flags);
if (tab)
{ {
if (!settingsTab.IsOpen) if (!settingsTab.IsOpen)
{ {
@ -231,4 +278,28 @@ internal class SettingsWindow : Window
Service<InterfaceManager>.Get().RebuildFonts(); Service<InterfaceManager>.Get().RebuildFonts();
} }
private void SetOpenTab(SettingsOpenKind kind)
{
switch (kind)
{
case SettingsOpenKind.General:
this.setActiveTab = this.tabs[0];
break;
case SettingsOpenKind.LookAndFeel:
this.setActiveTab = this.tabs[1];
break;
case SettingsOpenKind.ServerInfoBar:
this.setActiveTab = this.tabs[2];
break;
case SettingsOpenKind.Experimental:
this.setActiveTab = this.tabs[3];
break;
case SettingsOpenKind.About:
this.setActiveTab = this.tabs[4];
break;
default:
throw new ArgumentOutOfRangeException(nameof(kind), kind, null);
}
}
} }

View file

@ -128,8 +128,8 @@ public class SettingsTabLook : SettingsTab
new SettingsEntry<bool>( new SettingsEntry<bool>(
Loc.Localize("DalamudSettingInstallerOpenDefault", "Open the Plugin Installer to the \"Installed Plugins\" tab by default"), 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."), 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, c => c.PluginInstallerOpen == PluginInstallerOpenKind.InstalledPlugins,
(v, c) => c.PluginInstallerOpen = v ? PluginInstallerWindow.PluginInstallerOpenKind.InstalledPlugins : PluginInstallerWindow.PluginInstallerOpenKind.AllPlugins), (v, c) => c.PluginInstallerOpen = v ? PluginInstallerOpenKind.InstalledPlugins : PluginInstallerOpenKind.AllPlugins),
new SettingsEntry<bool>( new SettingsEntry<bool>(
Loc.Localize("DalamudSettingReducedMotion", "Reduce motions"), Loc.Localize("DalamudSettingReducedMotion", "Reduce motions"),

View file

@ -1,4 +1,5 @@
using System.Numerics; using System.Numerics;
using System.Text;
using ImGuiNET; using ImGuiNET;
@ -36,7 +37,7 @@ public static partial class ImRaii
public static IEndObject Popup(string id, ImGuiWindowFlags flags) public static IEndObject Popup(string id, ImGuiWindowFlags flags)
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopup(id, flags)); => new EndConditionally(ImGui.EndPopup, ImGui.BeginPopup(id, flags));
public static IEndObject PopupModal(string id) public static IEndObject PopupModal(string id)
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id)); => new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id));
@ -103,8 +104,43 @@ public static partial class ImRaii
public static IEndObject TabItem(string label) public static IEndObject TabItem(string label)
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label)); => new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label));
public static unsafe IEndObject TabItem(byte* label, ImGuiTabItemFlags flags) public static unsafe IEndObject TabItem(string label, ImGuiTabItemFlags flags)
=> new EndConditionally(ImGuiNative.igEndTabItem, ImGuiNative.igBeginTabItem(label, null, flags) != 0); {
// I am so sorry for this.
const int ImGuiNET_Util_StackAllocationSizeLimit = 2048;
byte* native_label;
int label_byteCount = 0;
if (label != null)
{
label_byteCount = Encoding.UTF8.GetByteCount(label);
if (label_byteCount > ImGuiNET_Util_StackAllocationSizeLimit)
{
throw new ArgumentOutOfRangeException("label", "Label is too long. (Longer than 2048 bytes)");
}
byte* native_label_stackBytes = stackalloc byte[label_byteCount + 1];
native_label = native_label_stackBytes;
int native_label_offset;
fixed (char* utf16Ptr = label)
{
native_label_offset = Encoding.UTF8.GetBytes(utf16Ptr, label.Length, native_label, label_byteCount);
}
native_label[native_label_offset] = 0;
}
else
{
native_label = null;
}
byte* p_open = null;
byte ret = ImGuiNative.igBeginTabItem(native_label, p_open, flags);
return new EndUnconditionally(ImGuiNative.igEndTabItem, ret != 0);
}
public static IEndObject TabItem(string label, ref bool open) public static IEndObject TabItem(string label, ref bool open)
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, ref open)); => new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, ref open));
@ -174,7 +210,7 @@ public static partial class ImRaii
return new EndUnconditionally(Widget.EndFramedGroup, true); return new EndUnconditionally(Widget.EndFramedGroup, true);
} }
*/ */
// Used to avoid tree pops when flag for no push is set. // Used to avoid tree pops when flag for no push is set.
private static void Nop() private static void Nop()
{ {
@ -210,15 +246,15 @@ public static partial class ImRaii
{ {
private Action EndAction { get; } private Action EndAction { get; }
public bool Success { get; } public bool Success { get; }
public bool Disposed { get; private set; } public bool Disposed { get; private set; }
public EndUnconditionally(Action endAction, bool success) public EndUnconditionally(Action endAction, bool success)
{ {
this.EndAction = endAction; this.EndAction = endAction;
this.Success = success; this.Success = success;
this.Disposed = false; this.Disposed = false;
} }
public void Dispose() public void Dispose()
@ -240,11 +276,11 @@ public static partial class ImRaii
this.Success = success; this.Success = success;
this.Disposed = false; this.Disposed = false;
} }
public bool Success { get; } public bool Success { get; }
public bool Disposed { get; private set; } public bool Disposed { get; private set; }
private Action EndAction { get; } private Action EndAction { get; }
public void Dispose() public void Dispose()

View file

@ -18,12 +18,16 @@ using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Internal; using Dalamud.Interface.Internal;
using Dalamud.Interface.Internal.Windows.PluginInstaller; using Dalamud.Interface.Internal.Windows.PluginInstaller;
using Dalamud.Interface.Internal.Windows.Settings;
using Dalamud.Plugin.Internal; using Dalamud.Plugin.Internal;
using Dalamud.Plugin.Internal.Types; using Dalamud.Plugin.Internal.Types;
using Dalamud.Plugin.Internal.Types.Manifest; using Dalamud.Plugin.Internal.Types.Manifest;
using Dalamud.Plugin.Ipc; using Dalamud.Plugin.Ipc;
using Dalamud.Plugin.Ipc.Exceptions; using Dalamud.Plugin.Ipc.Exceptions;
using Dalamud.Plugin.Ipc.Internal; using Dalamud.Plugin.Ipc.Internal;
using Dalamud.Utility;
using static Dalamud.Interface.Internal.Windows.PluginInstaller.PluginInstallerWindow;
namespace Dalamud.Plugin; namespace Dalamud.Plugin;
@ -218,7 +222,19 @@ public sealed class DalamudPluginInterface : IDisposable
/// Opens the <see cref="PluginInstallerWindow"/> with the plugin name set as search target. /// Opens the <see cref="PluginInstallerWindow"/> with the plugin name set as search target.
/// </summary> /// </summary>
/// <returns>Returns false if the DalamudInterface was null.</returns> /// <returns>Returns false if the DalamudInterface was null.</returns>
[Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)]
public bool OpenPluginInstaller() public bool OpenPluginInstaller()
{
return this.OpenPluginInstallerTo(PluginInstallerOpenKind.InstalledPlugins, this.plugin.InternalName);
}
/// <summary>
/// Opens the <see cref="PluginInstallerWindow"/>, with an optional search term.
/// </summary>
/// <param name="openTo">The page to open the installer to. Defaults to the "All Plugins" page.</param>
/// <param name="searchText">An optional search text to input in the search box.</param>
/// <returns>Returns false if the DalamudInterface was null.</returns>
public bool OpenPluginInstallerTo(PluginInstallerOpenKind openTo = PluginInstallerOpenKind.AllPlugins, string searchText = null)
{ {
var dalamudInterface = Service<DalamudInterface>.GetNullable(); // Can be null during boot var dalamudInterface = Service<DalamudInterface>.GetNullable(); // Can be null during boot
if (dalamudInterface == null) if (dalamudInterface == null)
@ -226,12 +242,48 @@ public sealed class DalamudPluginInterface : IDisposable
return false; return false;
} }
dalamudInterface.OpenPluginInstallerTo(PluginInstallerWindow.PluginInstallerOpenKind.InstalledPlugins); dalamudInterface.OpenPluginInstallerTo(openTo);
dalamudInterface.SetPluginInstallerSearchText(this.plugin.InternalName); dalamudInterface.SetPluginInstallerSearchText(searchText);
return true; return true;
} }
/// <summary>
/// Opens the <see cref="SettingsWindow"/>, with an optional search term.
/// </summary>
/// <param name="openTo">The tab to open the settings to. Defaults to the "General" tab.</param>
/// <param name="searchText">An optional search text to input in the search box.</param>
/// <returns>Returns false if the DalamudInterface was null.</returns>
public bool OpenDalamudSettingsTo(SettingsOpenKind openTo = SettingsOpenKind.General, string searchText = null)
{
var dalamudInterface = Service<DalamudInterface>.GetNullable(); // Can be null during boot
if (dalamudInterface == null)
{
return false;
}
dalamudInterface.OpenSettingsTo(openTo);
dalamudInterface.SetSettingsSearchText(searchText);
return true;
}
/// <summary>
/// Opens the dev menu bar.
/// </summary>
/// <returns>Returns false if the DalamudInterface was null.</returns>
public bool OpenDeveloperMenu()
{
var dalamudInterface = Service<DalamudInterface>.GetNullable(); // Can be null during boot
if (dalamudInterface == null)
{
return false;
}
dalamudInterface.OpenDevMenu();
return true;
}
#region IPC #region IPC
/// <inheritdoc cref="DataShare.GetOrCreateData{T}"/> /// <inheritdoc cref="DataShare.GetOrCreateData{T}"/>

View file

@ -19,6 +19,7 @@ using Dalamud.Game.Gui.Dtr;
using Dalamud.Game.Text; using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface;
using Dalamud.Interface.Internal; using Dalamud.Interface.Internal;
using Dalamud.Interface.Internal.Windows.PluginInstaller; using Dalamud.Interface.Internal.Windows.PluginInstaller;
using Dalamud.IoC; using Dalamud.IoC;
@ -129,7 +130,7 @@ internal class PluginManager : IInternalDisposableService
(_, _) => (_, _) =>
{ {
Service<DalamudInterface>.GetNullable()?.OpenPluginInstallerTo( Service<DalamudInterface>.GetNullable()?.OpenPluginInstallerTo(
PluginInstallerWindow.PluginInstallerOpenKind.Changelogs); PluginInstallerOpenKind.Changelogs);
})); }));
this.configuration.PluginTestingOptIns ??= new(); this.configuration.PluginTestingOptIns ??= new();