mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-31 21:03:48 +01:00
Test subscription like before but without primary constructor.
This commit is contained in:
parent
d9bd05c9ec
commit
6b5321dad8
1 changed files with 11 additions and 17 deletions
|
|
@ -5,7 +5,7 @@ using Penumbra.Services;
|
||||||
|
|
||||||
namespace Penumbra.Api.Api;
|
namespace Penumbra.Api.Api;
|
||||||
|
|
||||||
public sealed class PluginStateApi : IPenumbraApiPluginState, IApiService, IDisposable
|
public class PluginStateApi : IPenumbraApiPluginState, IApiService
|
||||||
{
|
{
|
||||||
private readonly Configuration _config;
|
private readonly Configuration _config;
|
||||||
private readonly CommunicatorService _communicator;
|
private readonly CommunicatorService _communicator;
|
||||||
|
|
@ -14,14 +14,6 @@ public sealed class PluginStateApi : IPenumbraApiPluginState, IApiService, IDisp
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_communicator = communicator;
|
_communicator = communicator;
|
||||||
_communicator.ModDirectoryChanged.Subscribe(OnModDirectoryChanged, Communication.ModDirectoryChanged.Priority.Api);
|
|
||||||
_communicator.EnabledChanged.Subscribe(OnEnabledChanged, EnabledChanged.Priority.Api);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
_communicator.ModDirectoryChanged.Unsubscribe(OnModDirectoryChanged);
|
|
||||||
_communicator.EnabledChanged.Unsubscribe(OnEnabledChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetModDirectory()
|
public string GetModDirectory()
|
||||||
|
|
@ -30,16 +22,18 @@ public sealed class PluginStateApi : IPenumbraApiPluginState, IApiService, IDisp
|
||||||
public string GetConfiguration()
|
public string GetConfiguration()
|
||||||
=> JsonConvert.SerializeObject(_config, Formatting.Indented);
|
=> JsonConvert.SerializeObject(_config, Formatting.Indented);
|
||||||
|
|
||||||
public event Action<string, bool>? ModDirectoryChanged;
|
public event Action<string, bool>? ModDirectoryChanged
|
||||||
|
{
|
||||||
|
add => _communicator.ModDirectoryChanged.Subscribe(value!, Communication.ModDirectoryChanged.Priority.Api);
|
||||||
|
remove => _communicator.ModDirectoryChanged.Unsubscribe(value!);
|
||||||
|
}
|
||||||
|
|
||||||
public bool GetEnabledState()
|
public bool GetEnabledState()
|
||||||
=> _config.EnableMods;
|
=> _config.EnableMods;
|
||||||
|
|
||||||
public event Action<bool>? EnabledChange;
|
public event Action<bool>? EnabledChange
|
||||||
|
{
|
||||||
private void OnModDirectoryChanged(string modDirectory, bool valid)
|
add => _communicator.EnabledChanged.Subscribe(value!, EnabledChanged.Priority.Api);
|
||||||
=> ModDirectoryChanged?.Invoke(modDirectory, valid);
|
remove => _communicator.EnabledChanged.Unsubscribe(value!);
|
||||||
|
}
|
||||||
private void OnEnabledChanged(bool value)
|
|
||||||
=> EnabledChange?.Invoke(value);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue