qstbak/Questionable/Questionable.Windows/JournalProgressWindow.cs
2025-10-09 07:47:19 +10:00

80 lines
2.7 KiB
C#

using System;
using System.Numerics;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin.Services;
using LLib.ImGui;
using Questionable.Controller;
using Questionable.Windows.JournalComponents;
namespace Questionable.Windows;
internal sealed class JournalProgressWindow : LWindow, IDisposable
{
private readonly QuestJournalComponent _questJournalComponent;
private readonly AlliedSocietyJournalComponent _alliedSocietyJournalComponent;
private readonly QuestRewardComponent _questRewardComponent;
private readonly GatheringJournalComponent _gatheringJournalComponent;
private readonly QuestRegistry _questRegistry;
private readonly IClientState _clientState;
public JournalProgressWindow(QuestJournalComponent questJournalComponent, QuestRewardComponent questRewardComponent, AlliedSocietyJournalComponent alliedSocietyJournalComponent, GatheringJournalComponent gatheringJournalComponent, QuestRegistry questRegistry, IClientState clientState)
: base("Journal Progress###QuestionableJournalProgress")
{
_questJournalComponent = questJournalComponent;
_alliedSocietyJournalComponent = alliedSocietyJournalComponent;
_questRewardComponent = questRewardComponent;
_gatheringJournalComponent = gatheringJournalComponent;
_questRegistry = questRegistry;
_clientState = clientState;
_clientState.Login += _questJournalComponent.RefreshCounts;
_clientState.Login += _gatheringJournalComponent.RefreshCounts;
_clientState.Logout += _questJournalComponent.ClearCounts;
_clientState.Logout += _gatheringJournalComponent.ClearCounts;
_questRegistry.Reloaded += OnQuestsReloaded;
base.SizeConstraints = new WindowSizeConstraints
{
MinimumSize = new Vector2(700f, 500f)
};
}
private void OnQuestsReloaded(object? sender, EventArgs e)
{
_questJournalComponent.RefreshCounts();
_gatheringJournalComponent.RefreshCounts();
}
public override void OnOpen()
{
_questJournalComponent.UpdateFilter();
_questJournalComponent.RefreshCounts();
_gatheringJournalComponent.UpdateFilter();
_gatheringJournalComponent.RefreshCounts();
}
public override void DrawContent()
{
using ImRaii.IEndObject endObject = ImRaii.TabBar("Journal");
if (!(!endObject))
{
_questJournalComponent.DrawQuests();
_alliedSocietyJournalComponent.DrawAlliedSocietyQuests();
_questRewardComponent.DrawItemRewards();
_gatheringJournalComponent.DrawGatheringItems();
}
}
public void Dispose()
{
_questRegistry.Reloaded -= OnQuestsReloaded;
_clientState.Logout -= _gatheringJournalComponent.ClearCounts;
_clientState.Logout -= _questJournalComponent.ClearCounts;
_clientState.Login -= _gatheringJournalComponent.RefreshCounts;
_clientState.Login -= _questJournalComponent.RefreshCounts;
}
}