Add tab to view available daily quests only

This commit is contained in:
Liza 2024-12-08 19:03:52 +01:00
parent 70c47e20fb
commit 8462b86544
Signed by: liza
GPG Key ID: 8DD6D21C03BB0848
4 changed files with 103 additions and 1 deletions

View File

@ -552,7 +552,7 @@ internal sealed unsafe class QuestFunctions
if (questInfo.GrandCompany != GrandCompany.None && questInfo.GrandCompany != GetGrandCompany())
return true;
if (questInfo.AlliedSociety != EAlliedSociety.None)
if (questInfo.AlliedSociety != EAlliedSociety.None && questInfo.IsRepeatable)
return !IsDailyAlliedSocietyQuestAndAvailableToday(questId);
return !HasCompletedPreviousQuests(questInfo, extraCompletedQuest) || !HasCompletedPreviousInstances(questInfo);

View File

@ -264,6 +264,7 @@ public sealed class QuestionablePlugin : IDalamudPlugin
serviceCollection.AddSingleton<QuestJournalComponent>();
serviceCollection.AddSingleton<GatheringJournalComponent>();
serviceCollection.AddSingleton<AlliedSocietyJournalComponent>();
serviceCollection.AddSingleton<OneTimeSetupWindow>();
serviceCollection.AddSingleton<QuestWindow>();

View File

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using Questionable.Controller;
using Questionable.Data;
using Questionable.Functions;
using Questionable.Model;
using Questionable.Windows.QuestComponents;
namespace Questionable.Windows.JournalComponents;
internal sealed class AlliedSocietyJournalComponent
{
private static readonly string[] RankNames =
["Neutral", "Recognized", "Friendly", "Trusted", "Respected", "Honored", "Sworn", "Allied"];
private readonly QuestFunctions _questFunctions;
private readonly AlliedSocietyQuestFunctions _alliedSocietyQuestFunctions;
private readonly QuestData _questData;
private readonly QuestRegistry _questRegistry;
private readonly QuestTooltipComponent _questTooltipComponent;
private readonly UiUtils _uiUtils;
public AlliedSocietyJournalComponent(
QuestFunctions questFunctions,
AlliedSocietyQuestFunctions alliedSocietyQuestFunctions,
QuestData questData,
QuestRegistry questRegistry,
QuestTooltipComponent questTooltipComponent,
UiUtils uiUtils)
{
_questFunctions = questFunctions;
_alliedSocietyQuestFunctions = alliedSocietyQuestFunctions;
_questData = questData;
_questRegistry = questRegistry;
_questTooltipComponent = questTooltipComponent;
_uiUtils = uiUtils;
}
public void DrawAlliedSocietyQuests()
{
using var tab = ImRaii.TabItem("Allied Societies");
if (!tab)
return;
foreach (EAlliedSociety alliedSociety in Enum.GetValues<EAlliedSociety>().Where(x => x != EAlliedSociety.None))
{
List<QuestInfo> quests = _alliedSocietyQuestFunctions.GetAvailableAlliedSocietyQuests(alliedSociety)
.Select(x => (QuestInfo)_questData.GetQuestInfo(x))
.ToList();
if (quests.Count == 0)
continue;
bool containsNewQuests = quests.Any(x => !_questFunctions.IsQuestComplete(x.QuestId));
if (containsNewQuests)
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
if (!ImGui.CollapsingHeader($"{alliedSociety}###AlliedSociety{(int)alliedSociety}"))
continue;
if (containsNewQuests)
ImGui.PopStyleColor();
if (alliedSociety <= EAlliedSociety.Ixal)
{
for (byte i = 1; i <= 8; ++i)
{
var questsByRank = quests.Where(x => x.AlliedSocietyRank == i).ToList();
if (questsByRank.Count == 0)
continue;
ImGui.Text(RankNames[i - 1]);
foreach (var quest in questsByRank)
DrawQuest(quest);
}
}
else
{
foreach (var quest in quests)
DrawQuest(quest);
}
}
}
private void DrawQuest(QuestInfo quest)
{
var (color, icon, tooltipText) = _uiUtils.GetQuestStyle(quest.QuestId);
if (!_questRegistry.IsKnownQuest(quest.QuestId))
color = ImGuiColors.DalamudGrey;
if (_uiUtils.ChecklistItem($"{quest.Name} ({tooltipText})", color, icon))
_questTooltipComponent.Draw(quest);
}
}

View File

@ -11,18 +11,21 @@ namespace Questionable.Windows;
internal sealed class JournalProgressWindow : LWindow, IDisposable
{
private readonly QuestJournalComponent _questJournalComponent;
private readonly AlliedSocietyJournalComponent _alliedSocietyJournalComponent;
private readonly GatheringJournalComponent _gatheringJournalComponent;
private readonly QuestRegistry _questRegistry;
private readonly IClientState _clientState;
public JournalProgressWindow(
QuestJournalComponent questJournalComponent,
AlliedSocietyJournalComponent alliedSocietyJournalComponent,
GatheringJournalComponent gatheringJournalComponent,
QuestRegistry questRegistry,
IClientState clientState)
: base("Journal Progress###QuestionableJournalProgress")
{
_questJournalComponent = questJournalComponent;
_alliedSocietyJournalComponent = alliedSocietyJournalComponent;
_gatheringJournalComponent = gatheringJournalComponent;
_questRegistry = questRegistry;
_clientState = clientState;
@ -60,6 +63,7 @@ internal sealed class JournalProgressWindow : LWindow, IDisposable
return;
_questJournalComponent.DrawQuests();
_alliedSocietyJournalComponent.DrawAlliedSocietyQuests();
_gatheringJournalComponent.DrawGatheringItems();
}