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 class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
{
|
{
|
||||||
public (int, int) ApiVersion
|
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
|
public event Action<string>? PreSettingsPanelDraw
|
||||||
{
|
{
|
||||||
add => _communicator.PreSettingsPanelDraw.Subscribe(value!, Communication.PreSettingsPanelDraw.Priority.Default);
|
add => _communicator.PreSettingsPanelDraw.Subscribe(value!, Communication.PreSettingsPanelDraw.Priority.Default);
|
||||||
remove => _communicator.PreSettingsPanelDraw.Unsubscribe(value!);
|
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
|
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)
|
if (_characterUtility.Ready)
|
||||||
_residentResources.Reload();
|
_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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,15 @@ public class CommunicatorService : IDisposable, IService
|
||||||
/// <inheritdoc cref="Communication.EnabledChanged"/>
|
/// <inheritdoc cref="Communication.EnabledChanged"/>
|
||||||
public readonly EnabledChanged EnabledChanged = new();
|
public readonly EnabledChanged EnabledChanged = new();
|
||||||
|
|
||||||
|
/// <inheritdoc cref="Communication.PreSettingsTabBarDraw"/>
|
||||||
|
public readonly PreSettingsTabBarDraw PreSettingsTabBarDraw = new();
|
||||||
|
|
||||||
/// <inheritdoc cref="Communication.PreSettingsPanelDraw"/>
|
/// <inheritdoc cref="Communication.PreSettingsPanelDraw"/>
|
||||||
public readonly PreSettingsPanelDraw PreSettingsPanelDraw = new();
|
public readonly PreSettingsPanelDraw PreSettingsPanelDraw = new();
|
||||||
|
|
||||||
|
/// <inheritdoc cref="Communication.PostEnabledDraw"/>
|
||||||
|
public readonly PostEnabledDraw PostEnabledDraw = new();
|
||||||
|
|
||||||
/// <inheritdoc cref="Communication.PostSettingsPanelDraw"/>
|
/// <inheritdoc cref="Communication.PostSettingsPanelDraw"/>
|
||||||
public readonly PostSettingsPanelDraw PostSettingsPanelDraw = new();
|
public readonly PostSettingsPanelDraw PostSettingsPanelDraw = new();
|
||||||
|
|
||||||
|
|
@ -91,7 +97,9 @@ public class CommunicatorService : IDisposable, IService
|
||||||
ModSettingChanged.Dispose();
|
ModSettingChanged.Dispose();
|
||||||
CollectionInheritanceChanged.Dispose();
|
CollectionInheritanceChanged.Dispose();
|
||||||
EnabledChanged.Dispose();
|
EnabledChanged.Dispose();
|
||||||
|
PreSettingsTabBarDraw.Dispose();
|
||||||
PreSettingsPanelDraw.Dispose();
|
PreSettingsPanelDraw.Dispose();
|
||||||
|
PostEnabledDraw.Dispose();
|
||||||
PostSettingsPanelDraw.Dispose();
|
PostSettingsPanelDraw.Dispose();
|
||||||
ChangedItemHover.Dispose();
|
ChangedItemHover.Dispose();
|
||||||
ChangedItemClick.Dispose();
|
ChangedItemClick.Dispose();
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,14 @@ public class ModPanelHeader : IDisposable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Draw()
|
public void Draw()
|
||||||
{
|
{
|
||||||
var offset = DrawModName();
|
using (ImRaii.Group())
|
||||||
DrawVersion(offset);
|
{
|
||||||
DrawSecondRow(offset);
|
var offset = DrawModName();
|
||||||
|
DrawVersion(offset);
|
||||||
|
DrawSecondRow(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
_communicator.PreSettingsTabBarDraw.Invoke(_mod.Identifier, ImGui.GetItemRectSize().X, _nameWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -43,6 +48,7 @@ public class ModPanelHeader : IDisposable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void UpdateModData(Mod mod)
|
public void UpdateModData(Mod mod)
|
||||||
{
|
{
|
||||||
|
_mod = mod;
|
||||||
// Name
|
// Name
|
||||||
var name = $" {mod.Name} ";
|
var name = $" {mod.Name} ";
|
||||||
if (name != _modName)
|
if (name != _modName)
|
||||||
|
|
@ -90,6 +96,7 @@ public class ModPanelHeader : IDisposable
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header data.
|
// Header data.
|
||||||
|
private Mod _mod = null!;
|
||||||
private string _modName = string.Empty;
|
private string _modName = string.Empty;
|
||||||
private string _modAuthor = string.Empty;
|
private string _modAuthor = string.Empty;
|
||||||
private string _modVersion = string.Empty;
|
private string _modVersion = string.Empty;
|
||||||
|
|
@ -103,6 +110,8 @@ public class ModPanelHeader : IDisposable
|
||||||
private float _modWebsiteButtonWidth;
|
private float _modWebsiteButtonWidth;
|
||||||
private float _secondRowWidth;
|
private float _secondRowWidth;
|
||||||
|
|
||||||
|
private float _nameWidth;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Draw the mod name in the game font with a 2px border, centered,
|
/// 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.
|
/// 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 style = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, 2 * UiHelpers.Scale);
|
||||||
using var f = _nameFont.Push();
|
using var f = _nameFont.Push();
|
||||||
ImGuiUtil.DrawTextButton(_modName, Vector2.Zero, 0);
|
ImGuiUtil.DrawTextButton(_modName, Vector2.Zero, 0);
|
||||||
|
_nameWidth = ImGui.GetItemRectSize().X;
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public class ModPanelSettingsTab : ITab
|
||||||
|
|
||||||
DrawInheritedWarning();
|
DrawInheritedWarning();
|
||||||
UiHelpers.DefaultLineSpace();
|
UiHelpers.DefaultLineSpace();
|
||||||
_communicator.PreSettingsPanelDraw.Invoke(_selector.Selected!.ModPath.Name);
|
_communicator.PreSettingsPanelDraw.Invoke(_selector.Selected!.Identifier);
|
||||||
DrawEnabledInput();
|
DrawEnabledInput();
|
||||||
_tutorial.OpenTutorial(BasicTutorialSteps.EnablingMods);
|
_tutorial.OpenTutorial(BasicTutorialSteps.EnablingMods);
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
@ -69,6 +69,8 @@ public class ModPanelSettingsTab : ITab
|
||||||
_tutorial.OpenTutorial(BasicTutorialSteps.Priority);
|
_tutorial.OpenTutorial(BasicTutorialSteps.Priority);
|
||||||
DrawRemoveSettings();
|
DrawRemoveSettings();
|
||||||
|
|
||||||
|
_communicator.PostEnabledDraw.Invoke(_selector.Selected!.Identifier);
|
||||||
|
|
||||||
if (_selector.Selected!.Groups.Count > 0)
|
if (_selector.Selected!.Groups.Count > 0)
|
||||||
{
|
{
|
||||||
var useDummy = true;
|
var useDummy = true;
|
||||||
|
|
@ -98,7 +100,7 @@ public class ModPanelSettingsTab : ITab
|
||||||
}
|
}
|
||||||
|
|
||||||
UiHelpers.DefaultLineSpace();
|
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>
|
/// <summary> Draw a big red bar if the current setting is inherited. </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue