mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 13:14:17 +01:00
Add new draw events.
This commit is contained in:
parent
8fded88813
commit
5ea140db98
8 changed files with 88 additions and 7 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit d2a1406bc32f715c0687613f02e3f74caf7ceea9
|
||||
Subproject commit a28a2537c0ff030cf09f740bff3b1a51ac0b41f6
|
||||
|
|
@ -33,12 +33,24 @@ namespace Penumbra.Api;
|
|||
public class PenumbraApi : IDisposable, IPenumbraApi
|
||||
{
|
||||
public (int, int) ApiVersion
|
||||
=> (4, 23);
|
||||
=> (4, 24);
|
||||
|
||||
public event Action<string, float, float>? PreSettingsTabBarDraw
|
||||
{
|
||||
add => _communicator.PreSettingsTabBarDraw.Subscribe(value!, Communication.PreSettingsTabBarDraw.Priority.Default);
|
||||
remove => _communicator.PreSettingsTabBarDraw.Unsubscribe(value!);
|
||||
}
|
||||
|
||||
public event Action<string>? PreSettingsPanelDraw
|
||||
{
|
||||
add => _communicator.PreSettingsPanelDraw.Subscribe(value!, Communication.PreSettingsPanelDraw.Priority.Default);
|
||||
remove => _communicator.PreSettingsPanelDraw.Unsubscribe(value!);
|
||||
}
|
||||
|
||||
public event Action<string>? PostEnabledDraw
|
||||
{
|
||||
add => _communicator.PostEnabledDraw.Subscribe(value!, Communication.PostEnabledDraw.Priority.Default);
|
||||
remove => _communicator.PostEnabledDraw.Unsubscribe(value!);
|
||||
}
|
||||
|
||||
public event Action<string>? PostSettingsPanelDraw
|
||||
|
|
|
|||
18
Penumbra/Communication/PostEnabledDraw.cs
Normal file
18
Penumbra/Communication/PostEnabledDraw.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using OtterGui.Classes;
|
||||
|
||||
namespace Penumbra.Communication;
|
||||
|
||||
/// <summary>
|
||||
/// Triggered after the Enabled Checkbox line in settings is drawn, but before options are drawn.
|
||||
/// <list type="number">
|
||||
/// <item>Parameter is the identifier (directory name) of the currently selected mod. </item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public sealed class PostEnabledDraw() : EventWrapper<string, PostEnabledDraw.Priority>(nameof(PostEnabledDraw))
|
||||
{
|
||||
public enum Priority
|
||||
{
|
||||
/// <seealso cref="Api.PenumbraApi.PostEnabledDraw"/>
|
||||
Default = 0,
|
||||
}
|
||||
}
|
||||
20
Penumbra/Communication/PreSettingsTabBarDraw.cs
Normal file
20
Penumbra/Communication/PreSettingsTabBarDraw.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using OtterGui.Classes;
|
||||
|
||||
namespace Penumbra.Communication;
|
||||
|
||||
/// <summary>
|
||||
/// Triggered before the settings tab bar for a mod is drawn, after the title group is drawn.
|
||||
/// <list type="number">
|
||||
/// <item>Parameter is the identifier (directory name) of the currently selected mod. </item>
|
||||
/// <item>is the total width of the header group. </item>
|
||||
/// <item>is the width of the title box. </item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public sealed class PreSettingsTabBarDraw() : EventWrapper<string, float, float, PreSettingsTabBarDraw.Priority>(nameof(PreSettingsTabBarDraw))
|
||||
{
|
||||
public enum Priority
|
||||
{
|
||||
/// <seealso cref="Api.PenumbraApi.PreSettingsTabBarDraw"/>
|
||||
Default = 0,
|
||||
}
|
||||
}
|
||||
|
|
@ -95,6 +95,17 @@ public class Penumbra : IDalamudPlugin
|
|||
|
||||
if (_characterUtility.Ready)
|
||||
_residentResources.Reload();
|
||||
|
||||
var api = _services.GetService<IPenumbraApi>();
|
||||
api.PostEnabledDraw += ImGui.TextUnformatted;
|
||||
api.PreSettingsTabBarDraw += (name, width, titleWidth) =>
|
||||
{
|
||||
ImGui.TextUnformatted(width.ToString());
|
||||
ImGui.TextUnformatted(titleWidth.ToString());
|
||||
ImGui.TextUnformatted(ImGui.GetContentRegionMax().X.ToString());
|
||||
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (width - titleWidth) / 2);
|
||||
ImGui.Button("Test", new Vector2(titleWidth, 0));
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,9 +57,15 @@ public class CommunicatorService : IDisposable, IService
|
|||
/// <inheritdoc cref="Communication.EnabledChanged"/>
|
||||
public readonly EnabledChanged EnabledChanged = new();
|
||||
|
||||
/// <inheritdoc cref="Communication.PreSettingsTabBarDraw"/>
|
||||
public readonly PreSettingsTabBarDraw PreSettingsTabBarDraw = new();
|
||||
|
||||
/// <inheritdoc cref="Communication.PreSettingsPanelDraw"/>
|
||||
public readonly PreSettingsPanelDraw PreSettingsPanelDraw = new();
|
||||
|
||||
/// <inheritdoc cref="Communication.PostEnabledDraw"/>
|
||||
public readonly PostEnabledDraw PostEnabledDraw = new();
|
||||
|
||||
/// <inheritdoc cref="Communication.PostSettingsPanelDraw"/>
|
||||
public readonly PostSettingsPanelDraw PostSettingsPanelDraw = new();
|
||||
|
||||
|
|
@ -91,7 +97,9 @@ public class CommunicatorService : IDisposable, IService
|
|||
ModSettingChanged.Dispose();
|
||||
CollectionInheritanceChanged.Dispose();
|
||||
EnabledChanged.Dispose();
|
||||
PreSettingsTabBarDraw.Dispose();
|
||||
PreSettingsPanelDraw.Dispose();
|
||||
PostEnabledDraw.Dispose();
|
||||
PostSettingsPanelDraw.Dispose();
|
||||
ChangedItemHover.Dispose();
|
||||
ChangedItemClick.Dispose();
|
||||
|
|
|
|||
|
|
@ -32,9 +32,14 @@ public class ModPanelHeader : IDisposable
|
|||
/// </summary>
|
||||
public void Draw()
|
||||
{
|
||||
var offset = DrawModName();
|
||||
DrawVersion(offset);
|
||||
DrawSecondRow(offset);
|
||||
using (ImRaii.Group())
|
||||
{
|
||||
var offset = DrawModName();
|
||||
DrawVersion(offset);
|
||||
DrawSecondRow(offset);
|
||||
}
|
||||
|
||||
_communicator.PreSettingsTabBarDraw.Invoke(_mod.Identifier, ImGui.GetItemRectSize().X, _nameWidth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -43,6 +48,7 @@ public class ModPanelHeader : IDisposable
|
|||
/// </summary>
|
||||
public void UpdateModData(Mod mod)
|
||||
{
|
||||
_mod = mod;
|
||||
// Name
|
||||
var name = $" {mod.Name} ";
|
||||
if (name != _modName)
|
||||
|
|
@ -90,6 +96,7 @@ public class ModPanelHeader : IDisposable
|
|||
}
|
||||
|
||||
// Header data.
|
||||
private Mod _mod = null!;
|
||||
private string _modName = string.Empty;
|
||||
private string _modAuthor = string.Empty;
|
||||
private string _modVersion = string.Empty;
|
||||
|
|
@ -103,6 +110,8 @@ public class ModPanelHeader : IDisposable
|
|||
private float _modWebsiteButtonWidth;
|
||||
private float _secondRowWidth;
|
||||
|
||||
private float _nameWidth;
|
||||
|
||||
/// <summary>
|
||||
/// Draw the mod name in the game font with a 2px border, centered,
|
||||
/// with at least the width of the version space to each side.
|
||||
|
|
@ -124,6 +133,7 @@ public class ModPanelHeader : IDisposable
|
|||
using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, 2 * UiHelpers.Scale);
|
||||
using var f = _nameFont.Push();
|
||||
ImGuiUtil.DrawTextButton(_modName, Vector2.Zero, 0);
|
||||
_nameWidth = ImGui.GetItemRectSize().X;
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class ModPanelSettingsTab : ITab
|
|||
|
||||
DrawInheritedWarning();
|
||||
UiHelpers.DefaultLineSpace();
|
||||
_communicator.PreSettingsPanelDraw.Invoke(_selector.Selected!.ModPath.Name);
|
||||
_communicator.PreSettingsPanelDraw.Invoke(_selector.Selected!.Identifier);
|
||||
DrawEnabledInput();
|
||||
_tutorial.OpenTutorial(BasicTutorialSteps.EnablingMods);
|
||||
ImGui.SameLine();
|
||||
|
|
@ -69,6 +69,8 @@ public class ModPanelSettingsTab : ITab
|
|||
_tutorial.OpenTutorial(BasicTutorialSteps.Priority);
|
||||
DrawRemoveSettings();
|
||||
|
||||
_communicator.PostEnabledDraw.Invoke(_selector.Selected!.Identifier);
|
||||
|
||||
if (_selector.Selected!.Groups.Count > 0)
|
||||
{
|
||||
var useDummy = true;
|
||||
|
|
@ -98,7 +100,7 @@ public class ModPanelSettingsTab : ITab
|
|||
}
|
||||
|
||||
UiHelpers.DefaultLineSpace();
|
||||
_communicator.PostSettingsPanelDraw.Invoke(_selector.Selected!.ModPath.Name);
|
||||
_communicator.PostSettingsPanelDraw.Invoke(_selector.Selected!.Identifier);
|
||||
}
|
||||
|
||||
/// <summary> Draw a big red bar if the current setting is inherited. </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue