diff --git a/Dalamud.CorePlugin/PluginImpl.cs b/Dalamud.CorePlugin/PluginImpl.cs index 9026ea0dd..b858e9a0c 100644 --- a/Dalamud.CorePlugin/PluginImpl.cs +++ b/Dalamud.CorePlugin/PluginImpl.cs @@ -7,6 +7,7 @@ using Dalamud.Interface.Windowing; using Dalamud.Logging; using Dalamud.Plugin; using Dalamud.Utility; +using Serilog; namespace Dalamud.CorePlugin { @@ -66,6 +67,7 @@ namespace Dalamud.CorePlugin this.Interface.UiBuilder.Draw += this.OnDraw; this.Interface.UiBuilder.OpenConfigUi += this.OnOpenConfigUi; + this.Interface.UiBuilder.OpenMainUi += this.OnOpenMainUi; Service.Get().AddHandler("/coreplug", new(this.OnCommand) { HelpMessage = $"Access the {this.Name} plugin." }); @@ -143,6 +145,11 @@ namespace Dalamud.CorePlugin // this.window.IsOpen = true; } + private void OnOpenMainUi() + { + Log.Verbose("Opened main UI"); + } + #endif } } diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index 6f7496c72..ad9d77754 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -2227,6 +2227,8 @@ internal class PluginInstallerWindow : Window, IDisposable { ImGuiHelpers.SafeTextWrapped($"{command.Key} → {command.Value.HelpMessage}"); } + + ImGuiHelpers.ScaledDummy(3); } } @@ -2573,6 +2575,9 @@ internal class PluginInstallerWindow : Window, IDisposable { // Only if the plugin isn't broken. this.DrawOpenPluginSettingsButton(plugin); + + ImGui.SameLine(); + ImGuiHelpers.ScaledDummy(5, 0); } if (applicableForProfiles && config.ProfilesEnabled) @@ -2637,10 +2642,39 @@ internal class PluginInstallerWindow : Window, IDisposable private void DrawOpenPluginSettingsButton(LocalPlugin plugin) { - if (plugin.DalamudInterface?.UiBuilder?.HasConfigUi ?? false) + var hasMainUi = plugin.DalamudInterface?.UiBuilder.HasMainUi ?? false; + var hasConfig = plugin.DalamudInterface?.UiBuilder.HasConfigUi ?? false; + if (hasMainUi) { ImGui.SameLine(); - if (ImGuiComponents.IconButton(FontAwesomeIcon.Cog)) + if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.ArrowUpRightFromSquare, Locs.PluginButton_OpenUi)) + { + try + { + plugin.DalamudInterface.UiBuilder.OpenMain(); + } + catch (Exception ex) + { + Log.Error(ex, $"Error during OpenMain(): {plugin.Name}"); + } + } + + if (ImGui.IsItemHovered()) + { + ImGui.SetTooltip(Locs.PluginButtonToolTip_OpenUi); + } + } + + if (hasConfig) + { + if (hasMainUi) + { + ImGui.SameLine(); + ImGuiHelpers.ScaledDummy(5, 0); + } + + ImGui.SameLine(); + if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Cog, Locs.PluginButton_OpenSettings)) { try { @@ -2648,7 +2682,7 @@ internal class PluginInstallerWindow : Window, IDisposable } catch (Exception ex) { - Log.Error(ex, $"Error during OpenConfigUi: {plugin.Name}"); + Log.Error(ex, $"Error during OpenConfig: {plugin.Name}"); } } @@ -3236,12 +3270,18 @@ internal class PluginInstallerWindow : Window, IDisposable 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_OpenUi => Loc.Localize("InstallerOpenPluginUi", "Open"); + + public static string PluginButton_OpenSettings => Loc.Localize("InstallerOpenPluginSettings", "Settings"); #endregion #region Plugin button tooltips + + public static string PluginButtonToolTip_OpenUi => Loc.Localize("InstallerTooltipOpenUi", "Open this plugin's interface"); - public static string PluginButtonToolTip_OpenConfiguration => Loc.Localize("InstallerOpenConfig", "Open Configuration"); + public static string PluginButtonToolTip_OpenConfiguration => Loc.Localize("InstallerTooltipOpenConfig", "Open this plugin's settings"); public static string PluginButtonToolTip_PickProfiles => Loc.Localize("InstallerPickProfiles", "Pick collections for this plugin"); diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs index eca0f64a0..b440a0705 100644 --- a/Dalamud/Interface/UiBuilder.cs +++ b/Dalamud/Interface/UiBuilder.cs @@ -69,6 +69,11 @@ public sealed class UiBuilder : IDisposable /// Event that is fired when the plugin should open its configuration interface. /// public event Action OpenConfigUi; + + /// + /// Event that is fired when the plugin should open its main interface. + /// + public event Action OpenMainUi; /// /// Gets or sets an action that is called any time ImGui fonts need to be rebuilt.
@@ -212,6 +217,11 @@ public sealed class UiBuilder : IDisposable ///
internal bool HasConfigUi => this.OpenConfigUi != null; + /// + /// Gets a value indicating whether this UiBuilder has a configuration UI registered. + /// + internal bool HasMainUi => this.OpenMainUi != null; + /// /// Gets or sets the time this plugin took to draw on the last frame. /// @@ -409,6 +419,14 @@ public sealed class UiBuilder : IDisposable { this.OpenConfigUi?.InvokeSafely(); } + + /// + /// Open the registered configuration UI, if it exists. + /// + internal void OpenMain() + { + this.OpenMainUi?.InvokeSafely(); + } /// /// Notify this UiBuilder about plugin UI being hidden.