muffin v7.4.10
This commit is contained in:
parent
2df81c5d15
commit
b8dd142c23
47 changed files with 3604 additions and 1058 deletions
|
|
@ -0,0 +1,369 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Plugin;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Questionable.Data;
|
||||
using Questionable.Functions;
|
||||
using Questionable.Model;
|
||||
using Questionable.Model.Questing;
|
||||
|
||||
namespace Questionable.Windows.JournalComponents;
|
||||
|
||||
internal sealed class DutyJournalComponent
|
||||
{
|
||||
private sealed record DutyCategory(string Name, List<DutyInfo> Duties);
|
||||
|
||||
private sealed record DutyCounts(int Unlocked, int Completed, int CompletionTrackable, int Total)
|
||||
{
|
||||
public DutyCounts()
|
||||
: this(0, 0, 0, 0)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private readonly DutyUnlockData _dutyUnlockData;
|
||||
|
||||
private readonly QuestData _questData;
|
||||
|
||||
private readonly QuestFunctions _questFunctions;
|
||||
|
||||
private readonly UiUtils _uiUtils;
|
||||
|
||||
private readonly IDalamudPluginInterface _pluginInterface;
|
||||
|
||||
private readonly ILogger<DutyJournalComponent> _logger;
|
||||
|
||||
private List<DutyCategory> _filteredCategories = new List<DutyCategory>();
|
||||
|
||||
private Dictionary<string, DutyCounts> _categoryCounts = new Dictionary<string, DutyCounts>();
|
||||
|
||||
private string _searchText = string.Empty;
|
||||
|
||||
private bool _showLockedOnly;
|
||||
|
||||
private bool _showUnlockedOnly;
|
||||
|
||||
public DutyJournalComponent(DutyUnlockData dutyUnlockData, QuestData questData, QuestFunctions questFunctions, UiUtils uiUtils, IDalamudPluginInterface pluginInterface, ILogger<DutyJournalComponent> logger)
|
||||
{
|
||||
_dutyUnlockData = dutyUnlockData;
|
||||
_questData = questData;
|
||||
_questFunctions = questFunctions;
|
||||
_uiUtils = uiUtils;
|
||||
_pluginInterface = pluginInterface;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void DrawDuties()
|
||||
{
|
||||
using ImRaii.IEndObject endObject = ImRaii.TabItem("Duties");
|
||||
if (!endObject)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ImGui.CollapsingHeader("Explanation", ImGuiTreeNodeFlags.DefaultOpen))
|
||||
{
|
||||
ImGui.Text("The list below shows all duties and their unlock status.");
|
||||
ImGui.BulletText("'Unlocked' shows duties you have access to.");
|
||||
ImGui.BulletText("'Completed' shows duties you have finished at least once.");
|
||||
ImGui.BulletText("Click on a duty to see which quest unlocks it.");
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
ImGui.Spacing();
|
||||
}
|
||||
DrawFilterControls();
|
||||
if (_filteredCategories.Count > 0)
|
||||
{
|
||||
using (ImRaii.IEndObject endObject2 = ImRaii.Table("Duties", 3, ImGuiTableFlags.NoSavedSettings))
|
||||
{
|
||||
if (!endObject2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.NoHide);
|
||||
ImGui.TableSetupColumn("Unlocked", ImGuiTableColumnFlags.WidthFixed, 120f * ImGui.GetIO().FontGlobalScale);
|
||||
ImGui.TableSetupColumn("Completed", ImGuiTableColumnFlags.WidthFixed, 120f * ImGui.GetIO().FontGlobalScale);
|
||||
ImGui.TableHeadersRow();
|
||||
foreach (DutyCategory filteredCategory in _filteredCategories)
|
||||
{
|
||||
DrawCategory(filteredCategory);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
ImGui.Text("No duties match your search.");
|
||||
}
|
||||
|
||||
private void DrawFilterControls()
|
||||
{
|
||||
if (ImGui.Checkbox("Locked Only", ref _showLockedOnly))
|
||||
{
|
||||
if (_showLockedOnly)
|
||||
{
|
||||
_showUnlockedOnly = false;
|
||||
}
|
||||
UpdateFilter();
|
||||
}
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Checkbox("Unlocked Only", ref _showUnlockedOnly))
|
||||
{
|
||||
if (_showUnlockedOnly)
|
||||
{
|
||||
_showLockedOnly = false;
|
||||
}
|
||||
UpdateFilter();
|
||||
}
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
|
||||
if (ImGui.InputTextWithHint(string.Empty, "Search duties...", ref _searchText, 256))
|
||||
{
|
||||
UpdateFilter();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCategory(DutyCategory category)
|
||||
{
|
||||
DutyCounts valueOrDefault = _categoryCounts.GetValueOrDefault(category.Name, new DutyCounts());
|
||||
if (valueOrDefault.Total == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
bool num = ImGui.TreeNodeEx(category.Name, ImGuiTreeNodeFlags.SpanFullWidth);
|
||||
ImGui.TableNextColumn();
|
||||
DrawCount(valueOrDefault.Unlocked, valueOrDefault.Total);
|
||||
ImGui.TableNextColumn();
|
||||
DrawCount(valueOrDefault.Completed, valueOrDefault.CompletionTrackable);
|
||||
if (!num)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (DutyInfo duty in category.Duties)
|
||||
{
|
||||
DrawDuty(duty);
|
||||
}
|
||||
ImGui.TreePop();
|
||||
}
|
||||
|
||||
private void DrawDuty(DutyInfo duty)
|
||||
{
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
string text = $"Lv{duty.Level} {duty.Name}";
|
||||
if (duty.ItemLevel > 0)
|
||||
{
|
||||
text += $" (i{duty.ItemLevel})";
|
||||
}
|
||||
ImGui.TreeNodeEx(text, ImGuiTreeNodeFlags.NoTreePushOnOpen | ImGuiTreeNodeFlags.Leaf | ImGuiTreeNodeFlags.SpanFullWidth);
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
DrawDutyTooltip(duty);
|
||||
}
|
||||
ImGui.TableNextColumn();
|
||||
DrawDutyStatus(duty.IsUnlocked);
|
||||
ImGui.TableNextColumn();
|
||||
DrawDutyStatus(duty.IsCompleted);
|
||||
}
|
||||
|
||||
private void DrawDutyTooltip(DutyInfo duty)
|
||||
{
|
||||
using ImRaii.IEndObject endObject = ImRaii.Tooltip();
|
||||
if (!endObject)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ImGui.TextColored(ImGuiColors.DalamudWhite, duty.Name);
|
||||
Vector4 col = ImGuiColors.DalamudGrey;
|
||||
ImU8String text = new ImU8String(12, 1);
|
||||
text.AppendLiteral("Content ID: ");
|
||||
text.AppendFormatted(duty.ContentFinderConditionId);
|
||||
ImGui.TextColored(in col, text);
|
||||
ImGui.Separator();
|
||||
ImU8String text2 = new ImU8String(16, 1);
|
||||
text2.AppendLiteral("Level Required: ");
|
||||
text2.AppendFormatted(duty.Level);
|
||||
ImGui.Text(text2);
|
||||
if (duty.ItemLevel > 0)
|
||||
{
|
||||
ImU8String text3 = new ImU8String(21, 1);
|
||||
text3.AppendLiteral("Item Level Required: ");
|
||||
text3.AppendFormatted(duty.ItemLevel);
|
||||
ImGui.Text(text3);
|
||||
}
|
||||
ImU8String text4 = new ImU8String(6, 1);
|
||||
text4.AppendLiteral("Type: ");
|
||||
text4.AppendFormatted(duty.ContentTypeName);
|
||||
ImGui.Text(text4);
|
||||
if (duty.IsHighEndDuty)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(ImGuiColors.DalamudOrange, "(High-End)");
|
||||
}
|
||||
ImGui.Separator();
|
||||
if (duty.IsUnlocked)
|
||||
{
|
||||
ImGui.TextColored(ImGuiColors.ParsedGreen, "Status: Unlocked");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextColored(ImGuiColors.DalamudRed, "Status: Locked");
|
||||
}
|
||||
if (duty.UnlockQuests.Count > 0)
|
||||
{
|
||||
ImGui.Separator();
|
||||
ImGui.Text("Unlock Quest(s):");
|
||||
{
|
||||
foreach (QuestId unlockQuest in duty.UnlockQuests)
|
||||
{
|
||||
if (_questData.TryGetQuestInfo(unlockQuest, out IQuestInfo questInfo))
|
||||
{
|
||||
var (color, icon, _) = _uiUtils.GetQuestStyle(unlockQuest);
|
||||
_uiUtils.ChecklistItem($"{questInfo.Name} ({unlockQuest})", color, icon);
|
||||
}
|
||||
else
|
||||
{
|
||||
_uiUtils.ChecklistItem($"Unknown Quest ({unlockQuest})", ImGuiColors.DalamudGrey, FontAwesomeIcon.Question);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
ImGui.Separator();
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, "No unlock quest data available.");
|
||||
}
|
||||
|
||||
private void DrawDutyStatus(bool? status)
|
||||
{
|
||||
float num;
|
||||
using (_pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push())
|
||||
{
|
||||
num = ImGui.GetColumnWidth() / 2f - ImGui.CalcTextSize(FontAwesomeIcon.Check.ToIconString()).X;
|
||||
}
|
||||
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + num);
|
||||
if (!status.HasValue)
|
||||
{
|
||||
_uiUtils.ChecklistItem(string.Empty, ImGuiColors.DalamudGrey, FontAwesomeIcon.Minus);
|
||||
}
|
||||
else if (status.Value)
|
||||
{
|
||||
_uiUtils.ChecklistItem(string.Empty, ImGuiColors.ParsedGreen, FontAwesomeIcon.Check);
|
||||
}
|
||||
else
|
||||
{
|
||||
_uiUtils.ChecklistItem(string.Empty, ImGuiColors.DalamudRed, FontAwesomeIcon.Times);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawCount(int count, int total)
|
||||
{
|
||||
string text = 9999.ToString(CultureInfo.CurrentCulture);
|
||||
ImGui.PushFont(UiBuilder.MonoFont);
|
||||
if (total == 0)
|
||||
{
|
||||
Vector4 col = ImGuiColors.DalamudGrey;
|
||||
ImU8String text2 = new ImU8String(3, 2);
|
||||
text2.AppendFormatted("-".PadLeft(text.Length));
|
||||
text2.AppendLiteral(" / ");
|
||||
text2.AppendFormatted("-".PadLeft(text.Length));
|
||||
ImGui.TextColored(in col, text2);
|
||||
}
|
||||
else
|
||||
{
|
||||
string text3 = count.ToString(CultureInfo.CurrentCulture).PadLeft(text.Length) + " / " + total.ToString(CultureInfo.CurrentCulture).PadLeft(text.Length);
|
||||
if (count == total)
|
||||
{
|
||||
ImGui.TextColored(ImGuiColors.ParsedGreen, text3);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextUnformatted(text3);
|
||||
}
|
||||
}
|
||||
ImGui.PopFont();
|
||||
}
|
||||
|
||||
public void UpdateFilter()
|
||||
{
|
||||
List<DutyCategory> list = new List<DutyCategory>();
|
||||
AddCategory(list, "Dungeons", _dutyUnlockData.GetDungeons());
|
||||
AddCategory(list, "Hard Dungeons", _dutyUnlockData.GetHardDungeons());
|
||||
AddCategory(list, "Guildhests", _dutyUnlockData.GetGuildhests());
|
||||
AddCategory(list, "Trials", _dutyUnlockData.GetTrials());
|
||||
AddCategory(list, "Hard Trials", _dutyUnlockData.GetHardTrials());
|
||||
AddCategory(list, "Extreme Trials", _dutyUnlockData.GetExtremeTrials());
|
||||
AddCategory(list, "Unreal Trials", _dutyUnlockData.GetUnrealTrials());
|
||||
AddCategory(list, "Normal Raids", _dutyUnlockData.GetNormalRaids());
|
||||
AddCategory(list, "Savage Raids", _dutyUnlockData.GetSavageRaids());
|
||||
AddCategory(list, "Alliance Raids", _dutyUnlockData.GetAllianceRaids());
|
||||
AddCategory(list, "Chaotic Alliance Raids", _dutyUnlockData.GetChaoticAllianceRaids());
|
||||
AddCategory(list, "Ultimate Raids", _dutyUnlockData.GetUltimateRaids());
|
||||
AddCategory(list, "Deep Dungeons", _dutyUnlockData.GetDeepDungeons());
|
||||
AddCategory(list, "Variant Dungeons", _dutyUnlockData.GetVariantDungeons());
|
||||
AddCategory(list, "Criterion Dungeons", _dutyUnlockData.GetCriterionDungeons());
|
||||
AddCategory(list, "Criterion Savage", _dutyUnlockData.GetCriterionSavageDungeons());
|
||||
_filteredCategories = list.Where((DutyCategory c) => c.Duties.Count > 0).ToList();
|
||||
RefreshCounts();
|
||||
}
|
||||
|
||||
private void AddCategory(List<DutyCategory> categories, string name, IEnumerable<DutyInfo> duties)
|
||||
{
|
||||
List<DutyInfo> list = (from d in duties
|
||||
where MatchesFilter(d)
|
||||
orderby d.Level, d.ItemLevel, d.ContentFinderConditionId
|
||||
select d).ToList();
|
||||
if (list.Count > 0)
|
||||
{
|
||||
categories.Add(new DutyCategory(name, list));
|
||||
}
|
||||
}
|
||||
|
||||
private bool MatchesFilter(DutyInfo duty)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_searchText) && !duty.Name.Contains(_searchText, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_showLockedOnly && duty.IsUnlocked)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_showUnlockedOnly && !duty.IsUnlocked)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void RefreshCounts()
|
||||
{
|
||||
_categoryCounts.Clear();
|
||||
foreach (DutyCategory filteredCategory in _filteredCategories)
|
||||
{
|
||||
int unlocked = filteredCategory.Duties.Count((DutyInfo d) => d.IsUnlocked);
|
||||
int completed = filteredCategory.Duties.Count((DutyInfo d) => d.IsCompleted == true);
|
||||
int completionTrackable = filteredCategory.Duties.Count((DutyInfo d) => d.IsCompleted.HasValue);
|
||||
int count = filteredCategory.Duties.Count;
|
||||
_categoryCounts[filteredCategory.Name] = new DutyCounts(unlocked, completed, completionTrackable, count);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearCounts(int type, int code)
|
||||
{
|
||||
foreach (string item in _categoryCounts.Keys.ToList())
|
||||
{
|
||||
_categoryCounts[item] = _categoryCounts[item]with
|
||||
{
|
||||
Unlocked = 0,
|
||||
Completed = 0,
|
||||
CompletionTrackable = 0
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -388,13 +388,18 @@ internal sealed class QuestJournalComponent
|
|||
{
|
||||
bool num = IsQuestExpired(questInfo);
|
||||
bool flag = _questFunctions.IsQuestUnobtainable(questInfo.QuestId);
|
||||
bool flag2 = _questFunctions.IsQuestLocked(questInfo.QuestId);
|
||||
bool flag3 = _questFunctions.IsReadyToAcceptQuest(questInfo.QuestId);
|
||||
bool flag2 = _questFunctions.IsQuestBlacklisted(questInfo.QuestId);
|
||||
bool flag3 = _questFunctions.IsQuestLocked(questInfo.QuestId);
|
||||
bool flag4 = _questFunctions.IsReadyToAcceptQuest(questInfo.QuestId);
|
||||
if (num || flag)
|
||||
{
|
||||
_uiUtils.ChecklistItem("Unobtainable", ImGuiColors.DalamudGrey, FontAwesomeIcon.Minus);
|
||||
}
|
||||
else if (flag2 || !flag3 || !_questRegistry.IsKnownQuest(questInfo.QuestId))
|
||||
else if (flag2)
|
||||
{
|
||||
_uiUtils.ChecklistItem("Blacklisted", ImGuiColors.DalamudGrey3, FontAwesomeIcon.Ban);
|
||||
}
|
||||
else if (flag3 || !flag4 || !_questRegistry.IsKnownQuest(questInfo.QuestId))
|
||||
{
|
||||
_uiUtils.ChecklistItem("Locked", ImGuiColors.DalamudRed, FontAwesomeIcon.Times);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue