punish v6.8.18.0
This commit is contained in:
commit
e786325cda
322 changed files with 554232 additions and 0 deletions
|
@ -0,0 +1,182 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Humanizer;
|
||||
using Humanizer.Localisation;
|
||||
using Questionable.Controller;
|
||||
using Questionable.Data;
|
||||
using Questionable.Functions;
|
||||
using Questionable.Model;
|
||||
using Questionable.Model.Questing;
|
||||
|
||||
namespace Questionable.Windows.QuestComponents;
|
||||
|
||||
internal sealed class EventInfoComponent
|
||||
{
|
||||
private sealed record EventQuest(string Name, List<ElementId> QuestIds, DateTime EndsAtUtc);
|
||||
|
||||
private readonly List<EventQuest> _eventQuests;
|
||||
|
||||
private readonly QuestData _questData;
|
||||
|
||||
private readonly QuestRegistry _questRegistry;
|
||||
|
||||
private readonly QuestFunctions _questFunctions;
|
||||
|
||||
private readonly UiUtils _uiUtils;
|
||||
|
||||
private readonly QuestController _questController;
|
||||
|
||||
private readonly QuestTooltipComponent _questTooltipComponent;
|
||||
|
||||
private readonly Configuration _configuration;
|
||||
|
||||
public bool ShouldDraw
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_configuration.General.ShowIncompleteSeasonalEvents)
|
||||
{
|
||||
return _eventQuests.Any(IsIncomplete);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public EventInfoComponent(QuestData questData, QuestRegistry questRegistry, QuestFunctions questFunctions, UiUtils uiUtils, QuestController questController, QuestTooltipComponent questTooltipComponent, Configuration configuration)
|
||||
{
|
||||
int num = 2;
|
||||
List<EventQuest> list = new List<EventQuest>(num);
|
||||
CollectionsMarshal.SetCount(list, num);
|
||||
Span<EventQuest> span = CollectionsMarshal.AsSpan(list);
|
||||
int num2 = 0;
|
||||
ref EventQuest reference = ref span[num2];
|
||||
int num3 = 1;
|
||||
List<ElementId> list2 = new List<ElementId>(num3);
|
||||
CollectionsMarshal.SetCount(list2, num3);
|
||||
CollectionsMarshal.AsSpan(list2)[0] = new UnlockLinkId(568);
|
||||
reference = new EventQuest("Limited Time Items", list2, DateTime.MaxValue);
|
||||
ref EventQuest reference2 = ref span[num2 + 1];
|
||||
int num4 = 2;
|
||||
List<ElementId> list3 = new List<ElementId>(num4);
|
||||
CollectionsMarshal.SetCount(list3, num4);
|
||||
Span<ElementId> span2 = CollectionsMarshal.AsSpan(list3);
|
||||
num3 = 0;
|
||||
span2[num3] = new QuestId(5297);
|
||||
span2[num3 + 1] = new QuestId(5298);
|
||||
reference2 = new EventQuest("The Rising 2025", list3, AtDailyReset(new DateOnly(2025, 9, 11)));
|
||||
_eventQuests = list;
|
||||
base._002Ector();
|
||||
_questData = questData;
|
||||
_questRegistry = questRegistry;
|
||||
_questFunctions = questFunctions;
|
||||
_uiUtils = uiUtils;
|
||||
_questController = questController;
|
||||
_questTooltipComponent = questTooltipComponent;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
private static DateTime AtDailyReset(DateOnly date)
|
||||
{
|
||||
return new DateTime(date, new TimeOnly(14, 59), DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
foreach (EventQuest eventQuest in _eventQuests)
|
||||
{
|
||||
if (IsIncomplete(eventQuest))
|
||||
{
|
||||
DrawEventQuest(eventQuest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawEventQuest(EventQuest eventQuest)
|
||||
{
|
||||
if (eventQuest.EndsAtUtc != DateTime.MaxValue)
|
||||
{
|
||||
string value = (eventQuest.EndsAtUtc - DateTime.UtcNow).Humanize(1, CultureInfo.InvariantCulture, TimeUnit.Day, TimeUnit.Minute);
|
||||
ImU8String text = new ImU8String(3, 2);
|
||||
text.AppendFormatted(eventQuest.Name);
|
||||
text.AppendLiteral(" (");
|
||||
text.AppendFormatted(value);
|
||||
text.AppendLiteral(")");
|
||||
ImGui.Text(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Text(eventQuest.Name);
|
||||
}
|
||||
List<ElementId> list = eventQuest.QuestIds.Where((ElementId x) => _questRegistry.IsKnownQuest(x) && _questFunctions.IsReadyToAcceptQuest(x) && x != _questController.StartedQuest?.Quest.Id && x != _questController.NextQuest?.Quest.Id).ToList();
|
||||
foreach (ElementId questId in eventQuest.QuestIds)
|
||||
{
|
||||
if (_questFunctions.IsQuestComplete(questId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ImU8String text = new ImU8String(21, 1);
|
||||
text.AppendLiteral("##EventQuestSelection");
|
||||
text.AppendFormatted(questId);
|
||||
using (ImRaii.PushId(text))
|
||||
{
|
||||
string name = _questData.GetQuestInfo(questId).Name;
|
||||
if (list.Contains(questId) && _questRegistry.TryGetQuest(questId, out Quest quest))
|
||||
{
|
||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.Play))
|
||||
{
|
||||
_questController.SetNextQuest(quest);
|
||||
_questController.Start("SeasonalEventSelection");
|
||||
}
|
||||
bool num = ImGui.IsItemHovered();
|
||||
ImGui.SameLine();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.Text(name);
|
||||
if (num | ImGui.IsItemHovered())
|
||||
{
|
||||
_questTooltipComponent.Draw(quest.Info);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.SetCursorPosX(ImGui.GetCursorPosX());
|
||||
(Vector4, FontAwesomeIcon, string) questStyle = _uiUtils.GetQuestStyle(questId);
|
||||
if (_uiUtils.ChecklistItem(name, questStyle.Item1, questStyle.Item2, ImGui.GetStyle().FramePadding.X))
|
||||
{
|
||||
_questTooltipComponent.Draw(_questData.GetQuestInfo(questId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsIncomplete(EventQuest eventQuest)
|
||||
{
|
||||
if (eventQuest.EndsAtUtc <= DateTime.UtcNow)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return eventQuest.QuestIds.Any(ShouldShowQuest);
|
||||
}
|
||||
|
||||
public IEnumerable<ElementId> GetCurrentlyActiveEventQuests()
|
||||
{
|
||||
return _eventQuests.Where((EventQuest x) => x.EndsAtUtc >= DateTime.UtcNow).SelectMany((EventQuest x) => x.QuestIds).Where(ShouldShowQuest);
|
||||
}
|
||||
|
||||
private bool ShouldShowQuest(ElementId elementId)
|
||||
{
|
||||
if (!_questFunctions.IsQuestComplete(elementId))
|
||||
{
|
||||
return !_questFunctions.IsQuestUnobtainable(elementId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue