196 lines
7.2 KiB
C#
196 lines
7.2 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Numerics;
|
|
using Dalamud.Interface;
|
|
using Dalamud.Interface.Utility;
|
|
using Dalamud.Interface.Utility.Raii;
|
|
using Dalamud.Interface.Windowing;
|
|
using Dalamud.Plugin;
|
|
using Dalamud.Plugin.Services;
|
|
using Questionable.Controller;
|
|
using Questionable.Windows.JournalComponents;
|
|
|
|
namespace Questionable.Windows;
|
|
|
|
internal sealed class JournalProgressWindow : ThemedWindow, IDisposable
|
|
{
|
|
private static readonly SidebarNav.Group[] NavGroups = new SidebarNav.Group[3]
|
|
{
|
|
new SidebarNav.Group("Progress", new SidebarNav.Item[5]
|
|
{
|
|
new SidebarNav.Item(FontAwesomeIcon.Book, "Quests"),
|
|
new SidebarNav.Item(FontAwesomeIcon.Dungeon, "Duties"),
|
|
new SidebarNav.Item(FontAwesomeIcon.Wifi, "Attunement"),
|
|
new SidebarNav.Item(FontAwesomeIcon.Leaf, "Gathering Points"),
|
|
new SidebarNav.Item(FontAwesomeIcon.Gift, "Item Rewards")
|
|
}),
|
|
new SidebarNav.Group("Explore", new SidebarNav.Item[2]
|
|
{
|
|
new SidebarNav.Item(FontAwesomeIcon.Map, "Quest Map"),
|
|
new SidebarNav.Item(FontAwesomeIcon.ProjectDiagram, "Quest Chain")
|
|
}),
|
|
new SidebarNav.Group("Societies", new SidebarNav.Item[2]
|
|
{
|
|
new SidebarNav.Item(FontAwesomeIcon.Handshake, "Allied Societies"),
|
|
new SidebarNav.Item(FontAwesomeIcon.BoxOpen, "Custom Deliveries")
|
|
})
|
|
};
|
|
|
|
private static readonly string[] FlatLabels = (from i in NavGroups.SelectMany((SidebarNav.Group g) => g.Items)
|
|
select i.Label).ToArray();
|
|
|
|
private readonly QuestJournalComponent _questJournalComponent;
|
|
|
|
private readonly AlliedSocietyJournalComponent _alliedSocietyJournalComponent;
|
|
|
|
private readonly CustomDeliveryJournalComponent _customDeliveryJournalComponent;
|
|
|
|
private readonly QuestRewardComponent _questRewardComponent;
|
|
|
|
private readonly GatheringJournalComponent _gatheringJournalComponent;
|
|
|
|
private readonly DutyJournalComponent _dutyJournalComponent;
|
|
|
|
private readonly QuestMapComponent _questMapComponent;
|
|
|
|
private readonly QuestChainComponent _questChainComponent;
|
|
|
|
private readonly AttunementJournalComponent _attunementJournalComponent;
|
|
|
|
private readonly QuestRegistry _questRegistry;
|
|
|
|
private readonly IClientState _clientState;
|
|
|
|
private readonly IFramework _framework;
|
|
|
|
private readonly IDalamudPluginInterface _pluginInterface;
|
|
|
|
private readonly Configuration _configuration;
|
|
|
|
private readonly Action[] _pages;
|
|
|
|
private int _selectedTab;
|
|
|
|
private int _selectTabNextFrame = -1;
|
|
|
|
public JournalProgressWindow(QuestJournalComponent questJournalComponent, QuestRewardComponent questRewardComponent, AlliedSocietyJournalComponent alliedSocietyJournalComponent, CustomDeliveryJournalComponent customDeliveryJournalComponent, GatheringJournalComponent gatheringJournalComponent, DutyJournalComponent dutyJournalComponent, QuestMapComponent questMapComponent, QuestChainComponent questChainComponent, AttunementJournalComponent attunementJournalComponent, QuestJournalUtils questJournalUtils, QuestRegistry questRegistry, IClientState clientState, IFramework framework, IDalamudPluginInterface pluginInterface, Configuration configuration)
|
|
: base("Journal Progress###QuestionableJournalProgress")
|
|
{
|
|
_questJournalComponent = questJournalComponent;
|
|
_alliedSocietyJournalComponent = alliedSocietyJournalComponent;
|
|
_customDeliveryJournalComponent = customDeliveryJournalComponent;
|
|
_questRewardComponent = questRewardComponent;
|
|
_gatheringJournalComponent = gatheringJournalComponent;
|
|
_dutyJournalComponent = dutyJournalComponent;
|
|
_questMapComponent = questMapComponent;
|
|
_questChainComponent = questChainComponent;
|
|
_attunementJournalComponent = attunementJournalComponent;
|
|
_questRegistry = questRegistry;
|
|
_clientState = clientState;
|
|
_framework = framework;
|
|
_pluginInterface = pluginInterface;
|
|
_configuration = configuration;
|
|
_pages = new Action[9] { _questJournalComponent.DrawQuests, _dutyJournalComponent.DrawDuties, _attunementJournalComponent.DrawAttunement, _gatheringJournalComponent.DrawGatheringItems, _questRewardComponent.DrawItemRewards, _questMapComponent.DrawQuestMap, _questChainComponent.DrawQuestChain, _alliedSocietyJournalComponent.DrawAlliedSocietyQuests, _customDeliveryJournalComponent.DrawCustomDeliveries };
|
|
questJournalUtils.OpenJournal = delegate
|
|
{
|
|
base.IsOpen = true;
|
|
};
|
|
_questChainComponent.SelectTabAction = SelectTab;
|
|
_questChainComponent.QuestJournalUtils = questJournalUtils;
|
|
_questMapComponent.SelectTabAction = SelectTab;
|
|
_questMapComponent.QuestChainComponent = _questChainComponent;
|
|
_questMapComponent.QuestJournalUtils = questJournalUtils;
|
|
_clientState.Login += _questJournalComponent.RefreshCounts;
|
|
_clientState.Logout += _dutyJournalComponent.ClearCounts;
|
|
_clientState.Login += _gatheringJournalComponent.RefreshCounts;
|
|
_clientState.Login += _dutyJournalComponent.RefreshCounts;
|
|
_clientState.Logout += _questJournalComponent.ClearCounts;
|
|
_clientState.Logout += _gatheringJournalComponent.ClearCounts;
|
|
_clientState.Login += _attunementJournalComponent.RefreshCounts;
|
|
_clientState.Logout += _attunementJournalComponent.ClearCounts;
|
|
_questRegistry.Reloaded += OnQuestsReloaded;
|
|
base.SizeConstraints = new WindowSizeConstraints
|
|
{
|
|
MinimumSize = new Vector2(700f, 500f)
|
|
};
|
|
}
|
|
|
|
public void SelectTab(string tabName)
|
|
{
|
|
int num = Array.IndexOf(FlatLabels, tabName);
|
|
if (num >= 0)
|
|
{
|
|
_selectTabNextFrame = num;
|
|
}
|
|
}
|
|
|
|
private void OnQuestsReloaded(object? sender, EventArgs e)
|
|
{
|
|
_framework.RunOnFrameworkThread(delegate
|
|
{
|
|
_questJournalComponent.RefreshCounts();
|
|
_dutyJournalComponent.RefreshCounts();
|
|
_gatheringJournalComponent.RefreshCounts();
|
|
_attunementJournalComponent.RefreshCounts();
|
|
_questChainComponent.MarkDirty();
|
|
_questMapComponent.MarkDirty();
|
|
});
|
|
}
|
|
|
|
public override void OnOpen()
|
|
{
|
|
int num = Array.IndexOf<string>(FlatLabels, _configuration.JournalLastPage);
|
|
if (num >= 0)
|
|
{
|
|
_selectedTab = num;
|
|
}
|
|
_questJournalComponent.UpdateFilter();
|
|
_dutyJournalComponent.UpdateFilter();
|
|
_gatheringJournalComponent.UpdateFilter();
|
|
_attunementJournalComponent.UpdateFilter();
|
|
_questMapComponent.MarkDirty();
|
|
_questChainComponent.MarkDirty();
|
|
}
|
|
|
|
public override void DrawContent()
|
|
{
|
|
if (_selectTabNextFrame >= 0)
|
|
{
|
|
SetSelectedTab(_selectTabNextFrame);
|
|
_selectTabNextFrame = -1;
|
|
}
|
|
SetSelectedTab(SidebarNav.Draw(NavGroups, _selectedTab));
|
|
using ImRaii.ChildDisposable childDisposable = ImRaii.Child("##qstJournalContent", Vector2.Zero);
|
|
if ((bool)childDisposable)
|
|
{
|
|
using (ImRaii.PushIndent(8f * ImGuiHelpers.GlobalScale))
|
|
{
|
|
_pages[_selectedTab]();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void SetSelectedTab(int index)
|
|
{
|
|
if (index != _selectedTab)
|
|
{
|
|
_selectedTab = index;
|
|
_configuration.JournalLastPage = FlatLabels[index];
|
|
_pluginInterface.SavePluginConfig(_configuration);
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_questRegistry.Reloaded -= OnQuestsReloaded;
|
|
_clientState.Logout -= _attunementJournalComponent.ClearCounts;
|
|
_clientState.Login -= _attunementJournalComponent.RefreshCounts;
|
|
_clientState.Logout -= _gatheringJournalComponent.ClearCounts;
|
|
_clientState.Logout -= _questJournalComponent.ClearCounts;
|
|
_clientState.Login -= _dutyJournalComponent.RefreshCounts;
|
|
_clientState.Login -= _gatheringJournalComponent.RefreshCounts;
|
|
_clientState.Logout -= _dutyJournalComponent.ClearCounts;
|
|
_clientState.Login -= _questJournalComponent.RefreshCounts;
|
|
}
|
|
}
|