Remove YA interaction for SinglePlayerDuty; remove data id being required for accept/complete quest + SinglePlayerDuty

This commit is contained in:
Liza 2024-08-14 01:49:02 +02:00
parent 263e0b9a24
commit fdb8eed7a4
Signed by: liza
GPG Key ID: 7199F8D727D55F67
5 changed files with 25 additions and 96 deletions

View File

@ -397,23 +397,6 @@
]
}
},
{
"if": {
"properties": {
"InteractionType": {
"const": "SinglePlayerDuty"
},
"Emote": {
"not": true
}
}
},
"then": {
"required": [
"DataId"
]
}
},
{
"if": {
"properties": {

View File

@ -20,10 +20,14 @@ internal static class Interact
public IEnumerable<ITask> CreateAllTasks(Quest quest, QuestSequence sequence, QuestStep step)
{
if (step.InteractionType is EInteractionType.AcceptQuest or EInteractionType.CompleteQuest
or EInteractionType.AcceptLeve or EInteractionType.CompleteLeve)
or EInteractionType.AcceptLeve or EInteractionType.CompleteLeve
or EInteractionType.SinglePlayerDuty)
{
if (step.Emote != null)
yield break;
if (step.DataId == null)
yield break;
}
else if (step.InteractionType != EInteractionType.Interact)
yield break;

View File

@ -1,63 +0,0 @@
using System;
using System.Collections.Generic;
using Dalamud.Plugin.Services;
using Microsoft.Extensions.DependencyInjection;
using Questionable.External;
using Questionable.Model;
using Questionable.Model.Questing;
namespace Questionable.Controller.Steps.Interactions;
internal static class SinglePlayerDuty
{
internal sealed class Factory(IServiceProvider serviceProvider) : ITaskFactory
{
public IEnumerable<ITask> CreateAllTasks(Quest quest, QuestSequence sequence, QuestStep step)
{
if (step.InteractionType != EInteractionType.SinglePlayerDuty)
return [];
ArgumentNullException.ThrowIfNull(step.DataId);
return
[
serviceProvider.GetRequiredService<DisableYesAlready>(),
serviceProvider.GetRequiredService<Interact.DoInteract>()
.With(step.DataId.Value, quest, EInteractionType.None, true),
serviceProvider.GetRequiredService<RestoreYesAlready>()
];
}
public ITask CreateTask(Quest quest, QuestSequence sequence, QuestStep step)
=> throw new InvalidOperationException();
}
internal sealed class DisableYesAlready(YesAlreadyIpc yesAlreadyIpc) : ITask
{
public bool Start()
{
yesAlreadyIpc.DisableYesAlready();
return true;
}
public ETaskResult Update() => ETaskResult.TaskComplete;
public override string ToString() => "DisableYA";
}
internal sealed class RestoreYesAlready(YesAlreadyIpc yesAlreadyIpc, IGameGui gameGui) : ITask
{
public bool Start() => true;
public ETaskResult Update()
{
if (gameGui.GetAddonByName("SelectYesno") != nint.Zero ||
gameGui.GetAddonByName("DifficultySelectYesNo") != nint.Zero)
return ETaskResult.StillRunning;
yesAlreadyIpc.RestoreYesAlready();
return ETaskResult.TaskComplete;
}
public override string ToString() => "Wait(DialogClosed) → RestoreYA";
}
}

View File

@ -154,9 +154,6 @@ public sealed class QuestionablePlugin : IDalamudPlugin
serviceCollection.AddTaskWithFactory<EquipItem.Factory, EquipItem.DoEquip>();
serviceCollection.AddTaskWithFactory<EquipRecommended.Factory, EquipRecommended.DoEquipRecommended>();
serviceCollection.AddTaskWithFactory<TurnInDelivery.Factory, TurnInDelivery.SatisfactionSupplyTurnIn>();
serviceCollection
.AddTaskWithFactory<SinglePlayerDuty.Factory, SinglePlayerDuty.DisableYesAlready,
SinglePlayerDuty.RestoreYesAlready>();
serviceCollection
.AddTaskWithFactory<InitiateLeve.Factory,
InitiateLeve.SkipInitiateIfActive,

View File

@ -1,6 +1,7 @@
using System;
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using ImGuiNET;
@ -119,6 +120,8 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig
}
public override void Draw()
{
try
{
_activeQuestComponent.Draw(IsMinimized);
if (!IsMinimized)
@ -138,6 +141,11 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig
_remainingTasksComponent.Draw();
}
}
catch (Exception e)
{
ImGui.TextColored(ImGuiColors.DalamudRed, e.ToString());
}
}
private void OnReload(object? sender, EventArgs e) => Reload();