mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-21 23:37:47 +01:00
Update IntegrationSettings to Luna, update Luna.
Some checks are pending
.NET Build / build (push) Waiting to run
Some checks are pending
.NET Build / build (push) Waiting to run
This commit is contained in:
parent
15b952ac22
commit
a113bd329d
2 changed files with 16 additions and 15 deletions
2
Luna
2
Luna
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4b346670840c3ae0ef33a3f94445ff9c2f55559e
|
Subproject commit 3d5e7105f2671d741416988be95a5dba773adaf5
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using OtterGui.Services;
|
using ImSharp;
|
||||||
using OtterGui.Text;
|
using Luna;
|
||||||
using Penumbra.Api.Enums;
|
using Penumbra.Api.Enums;
|
||||||
|
|
||||||
namespace Penumbra.UI.Integration;
|
namespace Penumbra.UI.Integration;
|
||||||
|
|
@ -8,24 +8,21 @@ namespace Penumbra.UI.Integration;
|
||||||
public sealed class IntegrationSettingsRegistry : IService, IDisposable
|
public sealed class IntegrationSettingsRegistry : IService, IDisposable
|
||||||
{
|
{
|
||||||
private readonly IDalamudPluginInterface _pluginInterface;
|
private readonly IDalamudPluginInterface _pluginInterface;
|
||||||
|
|
||||||
private readonly List<(string InternalName, string Name, Action Draw)> _sections = [];
|
|
||||||
|
|
||||||
private bool _disposed = false;
|
private record struct Section(string InternalName, string Name, Action Draw);
|
||||||
|
private readonly List<Section> _sections = [];
|
||||||
|
private bool _disposed;
|
||||||
|
|
||||||
public IntegrationSettingsRegistry(IDalamudPluginInterface pluginInterface)
|
public IntegrationSettingsRegistry(IDalamudPluginInterface pluginInterface)
|
||||||
{
|
{
|
||||||
_pluginInterface = pluginInterface;
|
_pluginInterface = pluginInterface;
|
||||||
|
|
||||||
_pluginInterface.ActivePluginsChanged += OnActivePluginsChanged;
|
_pluginInterface.ActivePluginsChanged += OnActivePluginsChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
|
|
||||||
_pluginInterface.ActivePluginsChanged -= OnActivePluginsChanged;
|
_pluginInterface.ActivePluginsChanged -= OnActivePluginsChanged;
|
||||||
|
|
||||||
_sections.Clear();
|
_sections.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,10 +30,10 @@ public sealed class IntegrationSettingsRegistry : IService, IDisposable
|
||||||
{
|
{
|
||||||
foreach (var (internalName, name, draw) in _sections)
|
foreach (var (internalName, name, draw) in _sections)
|
||||||
{
|
{
|
||||||
if (!ImUtf8.CollapsingHeader($"Integration with {name}###IntegrationSettingsHeader.{internalName}"))
|
if (!Im.Tree.Header($"Integration with {name}###ISH.{internalName}"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
using var id = ImUtf8.PushId($"IntegrationSettings.{internalName}");
|
using var id = Im.Id.Push($"IS.{internalName}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
draw();
|
draw();
|
||||||
|
|
@ -52,22 +49,26 @@ public sealed class IntegrationSettingsRegistry : IService, IDisposable
|
||||||
{
|
{
|
||||||
if (_disposed)
|
if (_disposed)
|
||||||
return PenumbraApiEc.SystemDisposed;
|
return PenumbraApiEc.SystemDisposed;
|
||||||
|
|
||||||
var plugin = GetPlugin(draw);
|
var plugin = GetPlugin(draw);
|
||||||
if (plugin is null)
|
if (plugin is null)
|
||||||
return PenumbraApiEc.InvalidArgument;
|
return PenumbraApiEc.InvalidArgument;
|
||||||
|
|
||||||
var section = (plugin.InternalName, plugin.Name, draw);
|
var section = new Section(plugin.InternalName, plugin.Name, draw);
|
||||||
|
|
||||||
var index = FindSectionIndex(plugin.InternalName);
|
var index = FindSectionIndex(plugin.InternalName);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
{
|
{
|
||||||
if (_sections[index] == section)
|
if (_sections[index] == section)
|
||||||
return PenumbraApiEc.NothingChanged;
|
return PenumbraApiEc.NothingChanged;
|
||||||
|
|
||||||
_sections[index] = section;
|
_sections[index] = section;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
_sections.Add(section);
|
_sections.Add(section);
|
||||||
|
}
|
||||||
|
|
||||||
_sections.Sort((lhs, rhs) => string.Compare(lhs.Name, rhs.Name, StringComparison.CurrentCultureIgnoreCase));
|
_sections.Sort((lhs, rhs) => string.Compare(lhs.Name, rhs.Name, StringComparison.CurrentCultureIgnoreCase));
|
||||||
|
|
||||||
return PenumbraApiEc.Success;
|
return PenumbraApiEc.Success;
|
||||||
|
|
@ -78,7 +79,7 @@ public sealed class IntegrationSettingsRegistry : IService, IDisposable
|
||||||
var index = FindSectionIndex(draw);
|
var index = FindSectionIndex(draw);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_sections.RemoveAt(index);
|
_sections.RemoveAt(index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue