forked from liza/Questionable
Merge pull request 'add StartQuest ipc' (#133) from croizat/Questionable:ipc into master
Reviewed-on: liza/Questionable#133
This commit is contained in:
commit
7a47992792
19
Questionable/External/QuestionableIpc.cs
vendored
19
Questionable/External/QuestionableIpc.cs
vendored
@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using Dalamud.Plugin.Ipc;
|
using Dalamud.Plugin.Ipc;
|
||||||
using Questionable.Controller;
|
using Questionable.Controller;
|
||||||
|
using Questionable.Model.Questing;
|
||||||
using Questionable.Windows.QuestComponents;
|
using Questionable.Windows.QuestComponents;
|
||||||
|
|
||||||
namespace Questionable.External;
|
namespace Questionable.External;
|
||||||
@ -13,14 +14,16 @@ internal sealed class QuestionableIpc : IDisposable
|
|||||||
private const string IpcIsRunning = "Questionable.IsRunning";
|
private const string IpcIsRunning = "Questionable.IsRunning";
|
||||||
private const string IpcGetCurrentQuestId = "Questionable.GetCurrentQuestId";
|
private const string IpcGetCurrentQuestId = "Questionable.GetCurrentQuestId";
|
||||||
private const string IpcGetCurrentlyActiveEventQuests = "Questionable.GetCurrentlyActiveEventQuests";
|
private const string IpcGetCurrentlyActiveEventQuests = "Questionable.GetCurrentlyActiveEventQuests";
|
||||||
|
private const string IpcStartQuest = "Questionable.StartQuest";
|
||||||
|
|
||||||
private readonly ICallGateProvider<bool> _isRunning;
|
private readonly ICallGateProvider<bool> _isRunning;
|
||||||
private readonly ICallGateProvider<string?> _getCurrentQuestId;
|
private readonly ICallGateProvider<string?> _getCurrentQuestId;
|
||||||
private readonly ICallGateProvider<List<string>> _getCurrentlyActiveEventQuests;
|
private readonly ICallGateProvider<List<string>> _getCurrentlyActiveEventQuests;
|
||||||
|
private readonly ICallGateProvider<string, bool> _startQuest;
|
||||||
|
|
||||||
public QuestionableIpc(
|
public QuestionableIpc(
|
||||||
QuestController questController,
|
QuestController questController,
|
||||||
EventInfoComponent eventInfoComponent,
|
EventInfoComponent eventInfoComponent, QuestRegistry questRegistry,
|
||||||
IDalamudPluginInterface pluginInterface)
|
IDalamudPluginInterface pluginInterface)
|
||||||
{
|
{
|
||||||
_isRunning = pluginInterface.GetIpcProvider<bool>(IpcIsRunning);
|
_isRunning = pluginInterface.GetIpcProvider<bool>(IpcIsRunning);
|
||||||
@ -34,11 +37,25 @@ internal sealed class QuestionableIpc : IDisposable
|
|||||||
pluginInterface.GetIpcProvider<List<string>>(IpcGetCurrentlyActiveEventQuests);
|
pluginInterface.GetIpcProvider<List<string>>(IpcGetCurrentlyActiveEventQuests);
|
||||||
_getCurrentlyActiveEventQuests.RegisterFunc(() =>
|
_getCurrentlyActiveEventQuests.RegisterFunc(() =>
|
||||||
eventInfoComponent.GetCurrentlyActiveEventQuests().Select(q => q.ToString()).ToList());
|
eventInfoComponent.GetCurrentlyActiveEventQuests().Select(q => q.ToString()).ToList());
|
||||||
|
|
||||||
|
_startQuest = pluginInterface.GetIpcProvider<string, bool>(IpcStartQuest);
|
||||||
|
_startQuest.RegisterFunc((string questId) => StartQuest(questController, questRegistry, questId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool StartQuest(QuestController qc, QuestRegistry qr, string questId)
|
||||||
|
{
|
||||||
|
if (ElementId.TryFromString(questId, out var elementId) && elementId != null && qr.TryGetQuest(elementId, out var quest))
|
||||||
|
{
|
||||||
|
qc.SetNextQuest(quest);
|
||||||
|
qc.Start("IPCQuestSelection");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
_startQuest.UnregisterFunc();
|
||||||
_getCurrentlyActiveEventQuests.UnregisterFunc();
|
_getCurrentlyActiveEventQuests.UnregisterFunc();
|
||||||
_getCurrentQuestId.UnregisterFunc();
|
_getCurrentQuestId.UnregisterFunc();
|
||||||
_isRunning.UnregisterFunc();
|
_isRunning.UnregisterFunc();
|
||||||
|
Loading…
Reference in New Issue
Block a user