Add IPC Questionable.GetCurrentStepData
This commit is contained in:
parent
70173d5ec9
commit
bb9dd90878
1
Questionable.IpcTest/.gitignore
vendored
Normal file
1
Questionable.IpcTest/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/dist
|
11
Questionable.IpcTest/DalamudPackager.targets
Normal file
11
Questionable.IpcTest/DalamudPackager.targets
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project>
|
||||||
|
<Target Name="PackagePlugin" AfterTargets="Build">
|
||||||
|
<DalamudPackager
|
||||||
|
ProjectDir="$(ProjectDir)"
|
||||||
|
OutputPath="$(OutputPath)"
|
||||||
|
AssemblyName="$(AssemblyName)"
|
||||||
|
MakeZip="false"
|
||||||
|
VersionComponents="2"/>
|
||||||
|
</Target>
|
||||||
|
</Project>
|
59
Questionable.IpcTest/IpcTestPlugin.cs
Normal file
59
Questionable.IpcTest/IpcTestPlugin.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
using System.Numerics;
|
||||||
|
using Dalamud.Game.Command;
|
||||||
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
|
using Dalamud.Plugin;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
|
|
||||||
|
namespace Questionable.IpcTest;
|
||||||
|
|
||||||
|
public sealed class IpcTestPlugin : IDalamudPlugin
|
||||||
|
{
|
||||||
|
//private readonly WindowSystem _windowSystem = new("Questionable/" + nameof(IpcTestPlugin));
|
||||||
|
private readonly IDalamudPluginInterface _pluginInterface;
|
||||||
|
private readonly ICommandManager _commandManager;
|
||||||
|
private readonly IChatGui _chatGui;
|
||||||
|
|
||||||
|
public IpcTestPlugin(
|
||||||
|
IDalamudPluginInterface pluginInterface,
|
||||||
|
ICommandManager commandManager,
|
||||||
|
IChatGui chatGui)
|
||||||
|
{
|
||||||
|
_pluginInterface = pluginInterface;
|
||||||
|
_commandManager = commandManager;
|
||||||
|
_chatGui = chatGui;
|
||||||
|
|
||||||
|
commandManager.AddHandler("/qipc", new CommandInfo(ProcessCommand));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessCommand(string command, string arguments)
|
||||||
|
{
|
||||||
|
if (arguments == "stepdata")
|
||||||
|
{
|
||||||
|
var stepData = _pluginInterface.GetIpcSubscriber<IpcStepData?>("Questionable.GetCurrentStepData").InvokeFunc();
|
||||||
|
_chatGui.Print(new SeStringBuilder()
|
||||||
|
.AddUiForeground("[IPC]", 576)
|
||||||
|
.AddText(": Type: ")
|
||||||
|
.AddUiForeground(stepData?.InteractionType ?? "?", 61)
|
||||||
|
.AddText(" - Pos: ")
|
||||||
|
.AddUiForeground(stepData?.Position?.ToString("G", CultureInfo.InvariantCulture) ?? "?", 61)
|
||||||
|
.AddText(" - Territory: ")
|
||||||
|
.AddUiForeground(stepData?.TerritoryId.ToString() ?? "?", 61)
|
||||||
|
.Build());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_chatGui.PrintError("Unknown subcommand");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_commandManager.RemoveHandler("/qipc");
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class IpcStepData
|
||||||
|
{
|
||||||
|
public required string InteractionType { get; set; }
|
||||||
|
public required Vector3? Position { get; set; }
|
||||||
|
public required ushort TerritoryId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
13
Questionable.IpcTest/Questionable.IpcTest.csproj
Normal file
13
Questionable.IpcTest/Questionable.IpcTest.csproj
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Dalamud.NET.Sdk/11.0.0">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputPath>dist</OutputPath>
|
||||||
|
<PathMap Condition="$(SolutionDir) != ''">$(SolutionDir)=X:\</PathMap>
|
||||||
|
<Platforms>x64</Platforms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\LLib\LLib.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Import Project="..\LLib\LLib.targets"/>
|
||||||
|
</Project>
|
7
Questionable.IpcTest/Questionable.IpcTest.json
Normal file
7
Questionable.IpcTest/Questionable.IpcTest.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"Name": "Questionable IPC Test",
|
||||||
|
"Author": "Liza Carvelli",
|
||||||
|
"Punchline": "[Questionable dev plugin]: IPC Tester.",
|
||||||
|
"Description": "[Questionable dev plugin]: IPC Tester",
|
||||||
|
"RepoUrl": "https://git.carvel.li/liza/Questionable/src/branch/master/Questionable.IpcTest"
|
||||||
|
}
|
1050
Questionable.IpcTest/packages.lock.json
Normal file
1050
Questionable.IpcTest/packages.lock.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -30,6 +30,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationMasterAPI", "ve
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pictomancy", "vendor\pictomancy\Pictomancy\Pictomancy.csproj", "{D1AE2F8C-BDE7-457F-A369-973101044A25}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pictomancy", "vendor\pictomancy\Pictomancy\Pictomancy.csproj", "{D1AE2F8C-BDE7-457F-A369-973101044A25}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Questionable.IpcTest", "Questionable.IpcTest\Questionable.IpcTest.csproj", "{8572A8B2-2F31-4D17-B207-6A7A2E0579EF}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
@ -76,6 +78,10 @@ Global
|
|||||||
{D1AE2F8C-BDE7-457F-A369-973101044A25}.Debug|x64.Build.0 = Debug|x64
|
{D1AE2F8C-BDE7-457F-A369-973101044A25}.Debug|x64.Build.0 = Debug|x64
|
||||||
{D1AE2F8C-BDE7-457F-A369-973101044A25}.Release|x64.ActiveCfg = Release|x64
|
{D1AE2F8C-BDE7-457F-A369-973101044A25}.Release|x64.ActiveCfg = Release|x64
|
||||||
{D1AE2F8C-BDE7-457F-A369-973101044A25}.Release|x64.Build.0 = Release|x64
|
{D1AE2F8C-BDE7-457F-A369-973101044A25}.Release|x64.Build.0 = Release|x64
|
||||||
|
{8572A8B2-2F31-4D17-B207-6A7A2E0579EF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{8572A8B2-2F31-4D17-B207-6A7A2E0579EF}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{8572A8B2-2F31-4D17-B207-6A7A2E0579EF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{8572A8B2-2F31-4D17-B207-6A7A2E0579EF}.Release|x64.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
69
Questionable/External/QuestionableIpc.cs
vendored
69
Questionable/External/QuestionableIpc.cs
vendored
@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using Dalamud.Plugin.Ipc;
|
using Dalamud.Plugin.Ipc;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using Questionable.Controller;
|
using Questionable.Controller;
|
||||||
using Questionable.Model.Questing;
|
using Questionable.Model.Questing;
|
||||||
using Questionable.Windows.QuestComponents;
|
using Questionable.Windows.QuestComponents;
|
||||||
@ -13,21 +15,30 @@ 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 IpcGetCurrentStepData = "Questionable.GetCurrentStepData";
|
||||||
private const string IpcGetCurrentlyActiveEventQuests = "Questionable.GetCurrentlyActiveEventQuests";
|
private const string IpcGetCurrentlyActiveEventQuests = "Questionable.GetCurrentlyActiveEventQuests";
|
||||||
private const string IpcStartQuest = "Questionable.StartQuest";
|
private const string IpcStartQuest = "Questionable.StartQuest";
|
||||||
private const string IpcStartSingleQuest = "Questionable.StartSingleQuest";
|
private const string IpcStartSingleQuest = "Questionable.StartSingleQuest";
|
||||||
|
|
||||||
|
private readonly QuestController _questController;
|
||||||
|
private readonly QuestRegistry _questRegistry;
|
||||||
|
|
||||||
private readonly ICallGateProvider<bool> _isRunning;
|
private readonly ICallGateProvider<bool> _isRunning;
|
||||||
private readonly ICallGateProvider<string?> _getCurrentQuestId;
|
private readonly ICallGateProvider<string?> _getCurrentQuestId;
|
||||||
|
private readonly ICallGateProvider<StepData?> _getCurrentStepData;
|
||||||
private readonly ICallGateProvider<List<string>> _getCurrentlyActiveEventQuests;
|
private readonly ICallGateProvider<List<string>> _getCurrentlyActiveEventQuests;
|
||||||
private readonly ICallGateProvider<string, bool> _startQuest;
|
private readonly ICallGateProvider<string, bool> _startQuest;
|
||||||
private readonly ICallGateProvider<string, bool> _startSingleQuest;
|
private readonly ICallGateProvider<string, bool> _startSingleQuest;
|
||||||
|
|
||||||
public QuestionableIpc(
|
public QuestionableIpc(
|
||||||
QuestController questController,
|
QuestController questController,
|
||||||
EventInfoComponent eventInfoComponent, QuestRegistry questRegistry,
|
EventInfoComponent eventInfoComponent,
|
||||||
|
QuestRegistry questRegistry,
|
||||||
IDalamudPluginInterface pluginInterface)
|
IDalamudPluginInterface pluginInterface)
|
||||||
{
|
{
|
||||||
|
_questController = questController;
|
||||||
|
_questRegistry = questRegistry;
|
||||||
|
|
||||||
_isRunning = pluginInterface.GetIpcProvider<bool>(IpcIsRunning);
|
_isRunning = pluginInterface.GetIpcProvider<bool>(IpcIsRunning);
|
||||||
_isRunning.RegisterFunc(() =>
|
_isRunning.RegisterFunc(() =>
|
||||||
questController.AutomationType != QuestController.EAutomationType.Manual || questController.IsRunning);
|
questController.AutomationType != QuestController.EAutomationType.Manual || questController.IsRunning);
|
||||||
@ -35,38 +46,80 @@ internal sealed class QuestionableIpc : IDisposable
|
|||||||
_getCurrentQuestId = pluginInterface.GetIpcProvider<string?>(IpcGetCurrentQuestId);
|
_getCurrentQuestId = pluginInterface.GetIpcProvider<string?>(IpcGetCurrentQuestId);
|
||||||
_getCurrentQuestId.RegisterFunc(() => questController.CurrentQuest?.Quest.Id.ToString());
|
_getCurrentQuestId.RegisterFunc(() => questController.CurrentQuest?.Quest.Id.ToString());
|
||||||
|
|
||||||
|
_getCurrentStepData = pluginInterface.GetIpcProvider<StepData?>(IpcGetCurrentStepData);
|
||||||
|
_getCurrentStepData.RegisterFunc(GetStepData);
|
||||||
|
|
||||||
_getCurrentlyActiveEventQuests =
|
_getCurrentlyActiveEventQuests =
|
||||||
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 = pluginInterface.GetIpcProvider<string, bool>(IpcStartQuest);
|
||||||
_startQuest.RegisterFunc((questId) => StartQuest(questController, questRegistry, questId, false));
|
_startQuest.RegisterFunc(questId => StartQuest(questId, false));
|
||||||
|
|
||||||
_startSingleQuest = pluginInterface.GetIpcProvider<string, bool>(IpcStartSingleQuest);
|
_startSingleQuest = pluginInterface.GetIpcProvider<string, bool>(IpcStartSingleQuest);
|
||||||
_startSingleQuest.RegisterFunc((questId) => StartQuest(questController, questRegistry, questId, true));
|
_startSingleQuest.RegisterFunc(questId => StartQuest(questId, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool StartQuest(QuestController qc, QuestRegistry qr, string questId, bool single)
|
private bool StartQuest(string questId, bool single)
|
||||||
{
|
{
|
||||||
if (ElementId.TryFromString(questId, out var elementId) && elementId != null && qr.TryGetQuest(elementId, out var quest))
|
if (ElementId.TryFromString(questId, out var elementId) && elementId != null &&
|
||||||
|
_questRegistry.TryGetQuest(elementId, out var quest))
|
||||||
{
|
{
|
||||||
qc.SetNextQuest(quest);
|
_questController.SetNextQuest(quest);
|
||||||
if (single)
|
if (single)
|
||||||
qc.StartSingleQuest("IPCQuestSelection");
|
_questController.StartSingleQuest("IPCQuestSelection");
|
||||||
else
|
else
|
||||||
qc.Start("IPCQuestSelection");
|
_questController.Start("IPCQuestSelection");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StepData? GetStepData()
|
||||||
|
{
|
||||||
|
var progress = _questController.CurrentQuest;
|
||||||
|
if (progress == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
string? questId = progress.Quest.Id.ToString();
|
||||||
|
if (questId == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
QuestStep? step = progress.Quest.FindSequence(progress.Sequence)?.FindStep(progress.Step);
|
||||||
|
if (step == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new StepData
|
||||||
|
{
|
||||||
|
QuestId = questId,
|
||||||
|
Sequence = progress.Sequence,
|
||||||
|
Step = progress.Step,
|
||||||
|
InteractionType = step.InteractionType.ToString(),
|
||||||
|
Position = step.Position,
|
||||||
|
TerritoryId = step.TerritoryId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_startSingleQuest.UnregisterFunc();
|
_startSingleQuest.UnregisterFunc();
|
||||||
_startQuest.UnregisterFunc();
|
_startQuest.UnregisterFunc();
|
||||||
_getCurrentlyActiveEventQuests.UnregisterFunc();
|
_getCurrentlyActiveEventQuests.UnregisterFunc();
|
||||||
|
_getCurrentStepData.UnregisterFunc();
|
||||||
_getCurrentQuestId.UnregisterFunc();
|
_getCurrentQuestId.UnregisterFunc();
|
||||||
_isRunning.UnregisterFunc();
|
_isRunning.UnregisterFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[UsedImplicitly(ImplicitUseKindFlags.Access, ImplicitUseTargetFlags.WithMembers)]
|
||||||
|
public sealed class StepData
|
||||||
|
{
|
||||||
|
public required string QuestId { get; init; }
|
||||||
|
public required byte Sequence { get; init; }
|
||||||
|
public required int Step { get; init; }
|
||||||
|
public required string InteractionType { get; init; }
|
||||||
|
public required Vector3? Position { get; init; }
|
||||||
|
public required ushort TerritoryId { get; init; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user