86 lines
2.7 KiB
C#
86 lines
2.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Numerics;
|
|
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Interface.Utility.Raii;
|
|
using Questionable.Controller;
|
|
|
|
namespace Questionable.Windows.QuestComponents;
|
|
|
|
internal sealed class RemainingTasksComponent
|
|
{
|
|
private readonly QuestController _questController;
|
|
|
|
private readonly GatheringController _gatheringController;
|
|
|
|
private readonly FateController _fateController;
|
|
|
|
private readonly SeasonalDutyController _seasonalDutyController;
|
|
|
|
public RemainingTasksComponent(QuestController questController, GatheringController gatheringController, FateController fateController, SeasonalDutyController seasonalDutyController)
|
|
{
|
|
_questController = questController;
|
|
_gatheringController = gatheringController;
|
|
_fateController = fateController;
|
|
_seasonalDutyController = seasonalDutyController;
|
|
}
|
|
|
|
public bool Draw()
|
|
{
|
|
var (list, text) = GetRemainingTasks();
|
|
if (list.Count == 0)
|
|
{
|
|
return false;
|
|
}
|
|
(Vector2 ContentStartPos, float AvailableWidth, ImDrawListPtr DrawList) tuple2 = UiThemeUtils.BeginCard();
|
|
Vector2 item = tuple2.ContentStartPos;
|
|
float item2 = tuple2.AvailableWidth;
|
|
ImDrawListPtr item3 = tuple2.DrawList;
|
|
float cursorPosX = ImGui.GetCursorPosX();
|
|
float num = ImGui.GetContentRegionAvail().X - 12f;
|
|
float wrapLocalPosX = cursorPosX + num;
|
|
string text2 = $"{list.Count} {((list.Count == 1) ? "task" : "tasks")}";
|
|
Vector2 vector = ImGui.CalcTextSize(text2);
|
|
ImGui.SetNextItemOpen(isOpen: false, ImGuiCond.Once);
|
|
bool flag = ImGui.TreeNodeEx("Up Next", ImGuiTreeNodeFlags.NoTreePushOnOpen | ImGuiTreeNodeFlags.SpanAvailWidth);
|
|
ImGui.SameLine();
|
|
ImGui.SetCursorPosX(cursorPosX + num - vector.X);
|
|
using (ImRaii.PushColor(ImGuiCol.Text, UiThemeUtils.DimTextColor))
|
|
{
|
|
ImGui.TextUnformatted(text2);
|
|
}
|
|
if (flag)
|
|
{
|
|
ImGui.PushTextWrapPos(wrapLocalPosX);
|
|
using (ImRaii.Disabled())
|
|
{
|
|
foreach (string item4 in list)
|
|
{
|
|
ImGui.TextUnformatted((text != null) ? (text + item4) : item4);
|
|
}
|
|
ImGui.PopTextWrapPos();
|
|
}
|
|
}
|
|
UiThemeUtils.EndCard(item, item2, item3);
|
|
return true;
|
|
}
|
|
|
|
private (IList<string> Tasks, string? Prefix) GetRemainingTasks()
|
|
{
|
|
IList<string> remainingTaskNames = _seasonalDutyController.GetRemainingTaskNames();
|
|
if (remainingTaskNames.Count > 0)
|
|
{
|
|
return (Tasks: remainingTaskNames, Prefix: "D: ");
|
|
}
|
|
IList<string> remainingTaskNames2 = _fateController.GetRemainingTaskNames();
|
|
if (remainingTaskNames2.Count > 0)
|
|
{
|
|
return (Tasks: remainingTaskNames2, Prefix: "F: ");
|
|
}
|
|
IList<string> remainingTaskNames3 = _gatheringController.GetRemainingTaskNames();
|
|
if (remainingTaskNames3.Count > 0)
|
|
{
|
|
return (Tasks: remainingTaskNames3, Prefix: "G: ");
|
|
}
|
|
return (Tasks: _questController.GetRemainingTaskNames(), Prefix: null);
|
|
}
|
|
}
|