forked from liza/Deliveroo
Add IPC
This commit is contained in:
parent
d1fcceb946
commit
afd7cab940
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0-windows</TargetFramework>
|
<TargetFramework>net7.0-windows</TargetFramework>
|
||||||
<Version>2.10</Version>
|
<Version>2.11</Version>
|
||||||
<LangVersion>11.0</LangVersion>
|
<LangVersion>11.0</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
46
Deliveroo/External/DeliverooIpc.cs
vendored
Normal file
46
Deliveroo/External/DeliverooIpc.cs
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
using Dalamud.Plugin;
|
||||||
|
using Dalamud.Plugin.Ipc;
|
||||||
|
|
||||||
|
namespace Deliveroo.External;
|
||||||
|
|
||||||
|
internal sealed class DeliverooIpc : IDisposable
|
||||||
|
{
|
||||||
|
private const string TurnInStarted = "Deliveroo.TurnInStarted";
|
||||||
|
private const string TurnInStopped = "Deliveroo.TurnInStopped";
|
||||||
|
private const string IsTurnInRunning = "Deliveroo.IsTurnInRunning";
|
||||||
|
|
||||||
|
private readonly ICallGateProvider<bool> _isTurnInRunning;
|
||||||
|
private readonly ICallGateProvider<object> _turnInStarted;
|
||||||
|
private readonly ICallGateProvider<object> _turnInStopped;
|
||||||
|
|
||||||
|
private bool _running;
|
||||||
|
|
||||||
|
public DeliverooIpc(DalamudPluginInterface pluginInterface)
|
||||||
|
{
|
||||||
|
_isTurnInRunning = pluginInterface.GetIpcProvider<bool>(IsTurnInRunning);
|
||||||
|
_turnInStarted = pluginInterface.GetIpcProvider<object>(TurnInStarted);
|
||||||
|
_turnInStopped = pluginInterface.GetIpcProvider<object>(TurnInStopped);
|
||||||
|
|
||||||
|
_isTurnInRunning.RegisterFunc(CheckIsTurnInRunning);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartTurnIn()
|
||||||
|
{
|
||||||
|
_running = true;
|
||||||
|
_turnInStarted.SendMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StopTurnIn()
|
||||||
|
{
|
||||||
|
_running = false;
|
||||||
|
_turnInStopped.SendMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool CheckIsTurnInRunning() => _running;
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_isTurnInRunning.UnregisterFunc();
|
||||||
|
}
|
||||||
|
}
|
4
Deliveroo/External/ExternalPluginHandler.cs
vendored
4
Deliveroo/External/ExternalPluginHandler.cs
vendored
@ -7,6 +7,7 @@ namespace Deliveroo.External;
|
|||||||
internal sealed class ExternalPluginHandler
|
internal sealed class ExternalPluginHandler
|
||||||
{
|
{
|
||||||
private readonly IPluginLog _pluginLog;
|
private readonly IPluginLog _pluginLog;
|
||||||
|
private readonly DeliverooIpc _deliverooIpc;
|
||||||
private readonly YesAlreadyIpc _yesAlreadyIpc;
|
private readonly YesAlreadyIpc _yesAlreadyIpc;
|
||||||
private readonly PandoraIpc _pandoraIpc;
|
private readonly PandoraIpc _pandoraIpc;
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ internal sealed class ExternalPluginHandler
|
|||||||
public ExternalPluginHandler(DalamudPluginInterface pluginInterface, IFramework framework, IPluginLog pluginLog)
|
public ExternalPluginHandler(DalamudPluginInterface pluginInterface, IFramework framework, IPluginLog pluginLog)
|
||||||
{
|
{
|
||||||
_pluginLog = pluginLog;
|
_pluginLog = pluginLog;
|
||||||
|
_deliverooIpc = new DeliverooIpc(pluginInterface);
|
||||||
|
|
||||||
var dalamudReflector = new DalamudReflector(pluginInterface, framework, pluginLog);
|
var dalamudReflector = new DalamudReflector(pluginInterface, framework, pluginLog);
|
||||||
_yesAlreadyIpc = new YesAlreadyIpc(dalamudReflector);
|
_yesAlreadyIpc = new YesAlreadyIpc(dalamudReflector);
|
||||||
@ -33,6 +35,7 @@ internal sealed class ExternalPluginHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
_pluginLog.Information("Saving external plugin state...");
|
_pluginLog.Information("Saving external plugin state...");
|
||||||
|
_deliverooIpc.StartTurnIn();
|
||||||
SaveYesAlreadyState();
|
SaveYesAlreadyState();
|
||||||
SavePandoraState();
|
SavePandoraState();
|
||||||
Saved = true;
|
Saved = true;
|
||||||
@ -61,6 +64,7 @@ internal sealed class ExternalPluginHandler
|
|||||||
Saved = false;
|
Saved = false;
|
||||||
_yesAlreadyState = null;
|
_yesAlreadyState = null;
|
||||||
_pandoraState = null;
|
_pandoraState = null;
|
||||||
|
_deliverooIpc.StopTurnIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RestoreYesAlready()
|
private void RestoreYesAlready()
|
||||||
|
2
LLib
2
LLib
@ -1 +1 @@
|
|||||||
Subproject commit e59d291f04473eae0b76712397733e2e25349953
|
Subproject commit 2f6ef354c401a9f1bb9b807327acad7e98662a2e
|
Loading…
Reference in New Issue
Block a user