Always show validation issues (for quests you can edit)

This commit is contained in:
Liza 2024-07-16 10:52:54 +02:00
parent 9960f971db
commit 985fb7f4c1
Signed by: liza
GPG Key ID: 7199F8D727D55F67
4 changed files with 7 additions and 14 deletions

View File

@ -3,15 +3,11 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.IO; using System.IO;
using System.Numerics; using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Threading.Tasks;
using Dalamud.Plugin; using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Questionable.Controller.Utils;
using Questionable.Data; using Questionable.Data;
using Questionable.Model; using Questionable.Model;
using Questionable.Model.V1; using Questionable.Model.V1;
@ -23,18 +19,16 @@ internal sealed class QuestRegistry
{ {
private readonly IDalamudPluginInterface _pluginInterface; private readonly IDalamudPluginInterface _pluginInterface;
private readonly QuestData _questData; private readonly QuestData _questData;
private readonly IChatGui _chatGui;
private readonly QuestValidator _questValidator; private readonly QuestValidator _questValidator;
private readonly ILogger<QuestRegistry> _logger; private readonly ILogger<QuestRegistry> _logger;
private readonly Dictionary<ushort, Quest> _quests = new(); private readonly Dictionary<ushort, Quest> _quests = new();
public QuestRegistry(IDalamudPluginInterface pluginInterface, QuestData questData, IChatGui chatGui, public QuestRegistry(IDalamudPluginInterface pluginInterface, QuestData questData,
QuestValidator questValidator, ILogger<QuestRegistry> logger) QuestValidator questValidator, ILogger<QuestRegistry> logger)
{ {
_pluginInterface = pluginInterface; _pluginInterface = pluginInterface;
_questData = questData; _questData = questData;
_chatGui = chatGui;
_questValidator = questValidator; _questValidator = questValidator;
_logger = logger; _logger = logger;
} }
@ -76,6 +70,7 @@ internal sealed class QuestRegistry
QuestId = questId, QuestId = questId,
Root = questRoot, Root = questRoot,
Info = _questData.GetQuestInfo(questId), Info = _questData.GetQuestInfo(questId),
ReadOnly = true,
}; };
_quests[questId] = quest; _quests[questId] = quest;
} }
@ -111,14 +106,12 @@ internal sealed class QuestRegistry
} }
} }
[Conditional("DEBUG")]
private void ValidateQuests() private void ValidateQuests()
{ {
_questValidator.ClearIssues(); _questValidator.ClearIssues();
_questValidator.Validate(_quests.Values); _questValidator.Validate(_quests.Values.Where(x => !x.ReadOnly));
} }
private void LoadQuestFromStream(string fileName, Stream stream) private void LoadQuestFromStream(string fileName, Stream stream)
{ {
_logger.LogTrace("Loading quest from '{FileName}'", fileName); _logger.LogTrace("Loading quest from '{FileName}'", fileName);
@ -131,6 +124,7 @@ internal sealed class QuestRegistry
QuestId = questId.Value, QuestId = questId.Value,
Root = JsonSerializer.Deserialize<QuestRoot>(stream)!, Root = JsonSerializer.Deserialize<QuestRoot>(stream)!,
Info = _questData.GetQuestInfo(questId.Value), Info = _questData.GetQuestInfo(questId.Value),
ReadOnly = false,
}; };
_quests[questId.Value] = quest; _quests[questId.Value] = quest;
} }

View File

@ -8,6 +8,7 @@ internal sealed class Quest
public required ushort QuestId { get; init; } public required ushort QuestId { get; init; }
public required QuestRoot Root { get; init; } public required QuestRoot Root { get; init; }
public required QuestInfo Info { get; init; } public required QuestInfo Info { get; init; }
public required bool ReadOnly { get; init; }
public QuestSequence? FindSequence(byte currentSequence) public QuestSequence? FindSequence(byte currentSequence)
=> Root.QuestSequence.SingleOrDefault(seq => seq.Sequence == currentSequence); => Root.QuestSequence.SingleOrDefault(seq => seq.Sequence == currentSequence);

View File

@ -27,7 +27,7 @@ internal sealed class QuestValidator
public void ClearIssues() => _validationIssues.Clear(); public void ClearIssues() => _validationIssues.Clear();
public void Validate(IReadOnlyCollection<Quest> quests) public void Validate(IEnumerable<Quest> quests)
{ {
Task.Run(() => Task.Run(() =>
{ {

View File

@ -577,7 +577,6 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig
TimeSpan.FromMilliseconds(200)); TimeSpan.FromMilliseconds(200));
} }
#if DEBUG
if (_questRegistry.ValidationIssueCount > 0) if (_questRegistry.ValidationIssueCount > 0)
{ {
ImGui.SameLine(); ImGui.SameLine();
@ -587,7 +586,6 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig
$"{_questRegistry.ValidationIssueCount}")) $"{_questRegistry.ValidationIssueCount}"))
_questValidationWindow.IsOpen = true; _questValidationWindow.IsOpen = true;
} }
#endif
} }
private void DrawRemainingTasks() private void DrawRemainingTasks()