qstbak/Questionable/Questionable.Windows.JournalComponents/QuestRewardComponent.cs
2026-05-01 05:17:35 +10:00

123 lines
3.7 KiB
C#

using System;
using System.Linq;
using System.Numerics;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.Text;
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility.Raii;
using Questionable.Controller;
using Questionable.Data;
using Questionable.Model;
using Questionable.Windows.QuestComponents;
namespace Questionable.Windows.JournalComponents;
internal sealed class QuestRewardComponent
{
private readonly QuestRegistry _questRegistry;
private readonly QuestData _questData;
private readonly QuestTooltipComponent _questTooltipComponent;
private readonly UiUtils _uiUtils;
private bool _showEventRewards;
public QuestRewardComponent(QuestRegistry questRegistry, QuestData questData, QuestTooltipComponent questTooltipComponent, UiUtils uiUtils)
{
_questRegistry = questRegistry;
_questData = questData;
_questTooltipComponent = questTooltipComponent;
_uiUtils = uiUtils;
}
public void DrawItemRewards()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
TabItemDisposable val = ImRaii.TabItem((ImU8String)"Item Rewards");
try
{
if (!(!val))
{
ImGui.Checkbox("Show rewards from seasonal event quests", ref _showEventRewards);
ImGui.Spacing();
ImGui.BulletText("Only untradeable items are listed (e.g. the Wind-up Airship can be sold on the market board).");
DrawGroup("Mounts", EItemRewardType.Mount);
DrawGroup("Minions", EItemRewardType.Minion);
DrawGroup("Orchestrion Rolls", EItemRewardType.OrchestrionRoll);
DrawGroup("Triple Triad Cards", EItemRewardType.TripleTriadCard);
DrawGroup("Fashion Accessories", EItemRewardType.FashionAccessory);
}
}
finally
{
((TabItemDisposable)(ref val)).Dispose();
}
}
private void DrawGroup(string label, EItemRewardType type)
{
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
ImU8String label2 = new ImU8String(9, 2);
label2.AppendFormatted(label);
label2.AppendLiteral("###Reward");
label2.AppendFormatted(type);
if (!ImGui.CollapsingHeader(label2))
{
return;
}
foreach (ItemReward item in _questData.RedeemableItems.Where((ItemReward x) => x.Type == type).OrderBy<ItemReward, string>((ItemReward x) => x.Name, StringComparer.CurrentCultureIgnoreCase))
{
if (!_questData.TryGetQuestInfo(item.ElementId, out IQuestInfo questInfo))
{
continue;
}
bool flag = questInfo is QuestInfo questInfo2 && questInfo2.IsSeasonalEvent;
if (!_showEventRewards && flag)
{
continue;
}
string text = item.Name;
if (flag)
{
text = text + " " + SeIconChar.Clock.ToIconString();
}
bool flag2 = item.IsUnlocked();
Vector4 color = ((!_questRegistry.IsKnownQuest(item.ElementId)) ? ImGuiColors.DalamudGrey : (flag2 ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed));
FontAwesomeIcon icon = (flag2 ? FontAwesomeIcon.Check : FontAwesomeIcon.Times);
if (!_uiUtils.ChecklistItem(text, color, icon))
{
continue;
}
TooltipDisposable val = ImRaii.Tooltip();
try
{
if (((TooltipDisposable)(ref val)).Alive)
{
ImU8String text2 = new ImU8String(15, 1);
text2.AppendLiteral("Obtained from: ");
text2.AppendFormatted(questInfo.Name);
ImGui.Text(text2);
IndentDisposable val2 = ImRaii.PushIndent(1, true);
try
{
_questTooltipComponent.DrawInner(questInfo, showItemRewards: false);
}
finally
{
((IDisposable)val2)?.Dispose();
}
}
}
finally
{
((TooltipDisposable)(ref val)).Dispose();
}
}
}
}