using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using Dalamud.Bindings.ImGui; using Dalamud.Interface; using Dalamud.Interface.Components; using Dalamud.Interface.Utility.Raii; using Dalamud.Plugin; using Questionable.Controller; using Questionable.Functions; using Questionable.Model; using Questionable.Model.Questing; using Questionable.Windows.QuestComponents; using Questionable.Windows.Utils; namespace Questionable.Windows.ConfigComponents; internal sealed class BlacklistConfigComponent : ConfigComponent { private readonly IDalamudPluginInterface _pluginInterface; private readonly QuestSelector _questSelector; private readonly QuestRegistry _questRegistry; private readonly QuestFunctions _questFunctions; private readonly QuestTooltipComponent _questTooltipComponent; private readonly UiUtils _uiUtils; public BlacklistConfigComponent(IDalamudPluginInterface pluginInterface, QuestSelector questSelector, QuestFunctions questFunctions, QuestRegistry questRegistry, QuestTooltipComponent questTooltipComponent, UiUtils uiUtils, Configuration configuration) : base(pluginInterface, configuration) { BlacklistConfigComponent blacklistConfigComponent = this; _pluginInterface = pluginInterface; _questSelector = questSelector; _questRegistry = questRegistry; _questFunctions = questFunctions; _questTooltipComponent = questTooltipComponent; _uiUtils = uiUtils; _questSelector.SuggestionPredicate = (Quest quest) => !configuration.General.BlacklistedQuests.Contains(quest.Id); _questSelector.DefaultPredicate = (Quest quest) => !quest.Root.Disabled && questFunctions.IsQuestAccepted(quest.Id); _questSelector.QuestSelected = delegate(Quest quest) { configuration.General.BlacklistedQuests.Add(quest.Id); blacklistConfigComponent.Save(); }; } public override void DrawTab() { //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) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) TabItemDisposable val = ImRaii.TabItem((ImU8String)"Blacklist###QuestBlacklist"); try { if (!val) { return; } ImGui.TextWrapped("Blacklisted quests will never be automatically picked up or executed by Questionable."); ImGui.TextWrapped("Use this to permanently skip specific quests you don't want to do."); ImGui.Separator(); DrawCurrentlyAcceptedQuests(); HashSet blacklistedQuests = base.Configuration.General.BlacklistedQuests; ImU8String text = new ImU8String(22, 1); text.AppendLiteral("Blacklisted Quests ("); text.AppendFormatted(blacklistedQuests.Count); text.AppendLiteral("):"); ImGui.Text(text); ChildDisposable val2 = ImRaii.Child((ImU8String)"BlacklistedQuestsList", new Vector2(-1f, 200f), true); try { if (ChildDisposable.op_Implicit(val2)) { if (blacklistedQuests.Count > 0) { ElementId elementId = null; int num = 0; foreach (ElementId item in blacklistedQuests.OrderBy((ElementId x) => x.ToString())) { IdDisposable val3; if (!_questRegistry.TryGetQuest(item, out Quest quest)) { ImU8String imU8String = new ImU8String(5, 1); imU8String.AppendLiteral("Quest"); imU8String.AppendFormatted(item); val3 = ImRaii.PushId(imU8String, true); try { ImGui.AlignTextToFramePadding(); Vector4 col = new Vector4(0.7f, 0.7f, 0.7f, 1f); ImU8String text2 = new ImU8String(16, 1); text2.AppendLiteral("Unknown Quest ("); text2.AppendFormatted(item); text2.AppendLiteral(")"); ImGui.TextColored(in col, text2); ImGui.SameLine(ImGui.GetContentRegionAvail().X - ImGui.CalcTextSize(FontAwesomeIcon.Times.ToIconString()).X - ImGui.GetStyle().FramePadding.X * 2f); if (ImGuiComponents.IconButton($"##Remove{num}", FontAwesomeIcon.Times)) { elementId = item; } } finally { ((IDisposable)val3)?.Dispose(); } num++; continue; } ImU8String imU8String2 = new ImU8String(5, 1); imU8String2.AppendLiteral("Quest"); imU8String2.AppendFormatted(item); val3 = ImRaii.PushId(imU8String2, true); try { (Vector4, FontAwesomeIcon, string) questStyle = _uiUtils.GetQuestStyle(item); bool flag; using (_pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push()) { ImGui.AlignTextToFramePadding(); ImGui.TextColored(in questStyle.Item1, questStyle.Item2.ToIconString()); flag = ImGui.IsItemHovered(); } ImGui.SameLine(); ImGui.AlignTextToFramePadding(); ImGui.TextUnformatted(quest.Info.Name); flag |= ImGui.IsItemHovered(); if (flag) { _questTooltipComponent.Draw(quest.Info); } ImGui.SameLine(ImGui.GetContentRegionAvail().X - ImGui.CalcTextSize(FontAwesomeIcon.Times.ToIconString()).X - ImGui.GetStyle().FramePadding.X * 2f); if (ImGuiComponents.IconButton($"##Remove{num}", FontAwesomeIcon.Times)) { elementId = item; } if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Remove from blacklist"); } } finally { ((IDisposable)val3)?.Dispose(); } num++; } if (elementId != null) { base.Configuration.General.BlacklistedQuests.Remove(elementId); Save(); } } else { ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.7f, 0.7f, 0.7f, 1f)); ImGui.TextWrapped("No quests blacklisted. Use the dropdown above or add from currently accepted quests."); ImGui.PopStyleColor(); } } } finally { ((ChildDisposable)(ref val2)).Dispose(); } _questSelector.DrawSelection(); if (blacklistedQuests.Count <= 0) { return; } DisabledDisposable val4 = ImRaii.Disabled(!ImGui.IsKeyDown(ImGuiKey.ModCtrl)); try { if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Trash, "Clear All")) { base.Configuration.General.BlacklistedQuests.Clear(); Save(); } } finally { ((IDisposable)val4)?.Dispose(); } if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) { ImGui.SetTooltip("Hold CTRL to enable this button."); } } finally { ((TabItemDisposable)(ref val)).Dispose(); } } private void DrawCurrentlyAcceptedQuests() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) List currentlyAcceptedQuests = GetCurrentlyAcceptedQuests(); ImGui.Text("Currently Accepted Quests:"); ChildDisposable val = ImRaii.Child((ImU8String)"AcceptedQuestsList", new Vector2(-1f, 100f), true); try { if (ChildDisposable.op_Implicit(val)) { if (currentlyAcceptedQuests.Count > 0) { foreach (Quest item in currentlyAcceptedQuests) { ImU8String imU8String = new ImU8String(13, 1); imU8String.AppendLiteral("AcceptedQuest"); imU8String.AppendFormatted(item.Id); IdDisposable val2 = ImRaii.PushId(imU8String, true); try { (Vector4, FontAwesomeIcon, string) questStyle = _uiUtils.GetQuestStyle(item.Id); bool flag = false; bool flag2 = base.Configuration.General.BlacklistedQuests.Contains(item.Id); using (_pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push()) { ImGui.AlignTextToFramePadding(); ImGui.TextColored(flag2 ? new Vector4(0.5f, 0.5f, 0.5f, 1f) : questStyle.Item1, questStyle.Item2.ToIconString()); flag = ImGui.IsItemHovered(); } ImGui.SameLine(); ImGui.AlignTextToFramePadding(); ImGui.TextColored(flag2 ? new Vector4(0.7f, 0.7f, 0.7f, 1f) : new Vector4(1f, 1f, 1f, 1f), item.Info.Name); if (flag | ImGui.IsItemHovered()) { _questTooltipComponent.Draw(item.Info); } ImGui.SameLine(ImGui.GetContentRegionAvail().X - ImGui.CalcTextSize(FontAwesomeIcon.Ban.ToIconString()).X - ImGui.GetStyle().FramePadding.X * 2f); DisabledDisposable val3 = ImRaii.Disabled(flag2); try { if (ImGuiComponents.IconButton($"##Blacklist{item.Id}", FontAwesomeIcon.Ban)) { base.Configuration.General.BlacklistedQuests.Add(item.Id); Save(); } } finally { ((IDisposable)val3)?.Dispose(); } if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) { ImGui.SetTooltip(flag2 ? "Quest already blacklisted" : "Add this quest to blacklist"); } } finally { ((IDisposable)val2)?.Dispose(); } } } else { ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.7f, 0.7f, 0.7f, 1f)); ImGui.TextWrapped("No quests currently accepted"); ImGui.PopStyleColor(); } } } finally { ((ChildDisposable)(ref val)).Dispose(); } ImGui.Spacing(); } private List GetCurrentlyAcceptedQuests() { List list = new List(); try { foreach (Quest allQuest in _questRegistry.AllQuests) { if (_questFunctions.IsQuestAccepted(allQuest.Id)) { list.Add(allQuest); } } list.Sort((Quest a, Quest b) => string.Compare(a.Info.Name, b.Info.Name, StringComparison.OrdinalIgnoreCase)); } catch (Exception) { list.Clear(); } return list; } }