86 lines
2.3 KiB
C#
86 lines
2.3 KiB
C#
using System.Collections.Generic;
|
||
using System.Globalization;
|
||
using Dalamud.Bindings.ImGui;
|
||
using Dalamud.Plugin.Services;
|
||
using Questionable.Data;
|
||
using Questionable.Model.Questing;
|
||
|
||
namespace Questionable.Windows.QuestComponents;
|
||
|
||
internal sealed class GameSequenceChainComponent
|
||
{
|
||
private readonly IDataManager _dataManager;
|
||
|
||
private readonly Dictionary<uint, List<int>> _cache = new Dictionary<uint, List<int>>();
|
||
|
||
public GameSequenceChainComponent(IDataManager dataManager)
|
||
{
|
||
_dataManager = dataManager;
|
||
}
|
||
|
||
public List<int> GetSequences(QuestId questId)
|
||
{
|
||
if (!_cache.TryGetValue(questId.Value, out List<int> value))
|
||
{
|
||
value = GameQuestSequences.GetCompletionSequences(_dataManager, questId);
|
||
_cache[questId.Value] = value;
|
||
}
|
||
return value;
|
||
}
|
||
|
||
public void Draw(QuestId questId, byte currentSequence)
|
||
{
|
||
List<int> sequences = GetSequences(questId);
|
||
if (sequences.Count == 0)
|
||
{
|
||
ImGui.TextColored(in UiThemeUtils.MutedTextColor, "No sequence data");
|
||
return;
|
||
}
|
||
for (int i = 0; i < sequences.Count; i++)
|
||
{
|
||
if (i > 0)
|
||
{
|
||
ImGui.SameLine(0f, 4f);
|
||
ImGui.TextColored(in UiThemeUtils.MutedTextColor, "›");
|
||
ImGui.SameLine(0f, 4f);
|
||
}
|
||
int num = sequences[i];
|
||
if (num == currentSequence)
|
||
{
|
||
ImU8String text = new ImU8String(2, 1);
|
||
text.AppendLiteral("[");
|
||
text.AppendFormatted(num);
|
||
text.AppendLiteral("]");
|
||
ImGui.TextColored(in UiThemeUtils.StatusActive, text);
|
||
}
|
||
else
|
||
{
|
||
ImGui.TextColored(in UiThemeUtils.DimTextColor, num.ToString(CultureInfo.InvariantCulture));
|
||
}
|
||
}
|
||
int num2 = sequences.IndexOf(currentSequence);
|
||
ImGui.SameLine(0f, 8f);
|
||
if (currentSequence == byte.MaxValue)
|
||
{
|
||
ImGui.TextColored(in UiThemeUtils.StatusComplete, "(ready to turn in)");
|
||
}
|
||
else if (num2 >= 0)
|
||
{
|
||
ImU8String text2 = new ImU8String(3, 2);
|
||
text2.AppendLiteral("(");
|
||
text2.AppendFormatted(num2 + 1);
|
||
text2.AppendLiteral("/");
|
||
text2.AppendFormatted(sequences.Count);
|
||
text2.AppendLiteral(")");
|
||
ImGui.TextColored(in UiThemeUtils.MutedTextColor, text2);
|
||
}
|
||
else
|
||
{
|
||
ImU8String text3 = new ImU8String(19, 1);
|
||
text3.AppendLiteral("(at ");
|
||
text3.AppendFormatted(currentSequence);
|
||
text3.AppendLiteral(", not in chain)");
|
||
ImGui.TextColored(in UiThemeUtils.StatusUnobtainable, text3);
|
||
}
|
||
}
|
||
}
|