Check for GC for quest lock; minor UI adjustments
authorLiza Carvelli <liza@carvel.li>
Mon, 22 Jul 2024 13:27:06 +0000 (15:27 +0200)
committerLiza Carvelli <liza@carvel.li>
Mon, 22 Jul 2024 13:27:06 +0000 (15:27 +0200)
Questionable/GameFunctions.cs
Questionable/Model/QuestInfo.cs
Questionable/Windows/QuestComponents/ActiveQuestComponent.cs
Questionable/Windows/QuestSelectionWindow.cs

index ff74a7082af4f925901ac2f3239ecf0ebd0e7a5e..a95f15abc9cac238f969bea28f4fa5673dfc46a8 100644 (file)
@@ -291,6 +291,9 @@ internal sealed unsafe class GameFunctions
                 return true;
         }
 
+        if (questInfo.GrandCompany != GrandCompany.None && questInfo.GrandCompany != GetGrandCompany())
+            return true;
+
         return !HasCompletedPreviousQuests(questInfo, extraCompletedQuest) || !HasCompletedPreviousInstances(questInfo);
     }
 
@@ -728,4 +731,9 @@ internal sealed unsafe class GameFunctions
                LAddon.IsAddonReady(fade) &&
                fade->IsVisible;
     }
+
+    public GrandCompany GetGrandCompany()
+    {
+        return (GrandCompany)PlayerState.Instance()->GrandCompany;
+    }
 }
index d0d1913ba8f601dd9269e5071acbc559d7d53c97..db4ded12c94e4829d9363c907e43b7f4db94d75c 100644 (file)
@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Collections.Immutable;
 using System.Linq;
 using Dalamud.Game.Text;
+using FFXIVClientStructs.FFXIV.Client.UI.Agent;
 using JetBrains.Annotations;
 using ExcelQuest = Lumina.Excel.GeneratedSheets.Quest;
 
@@ -25,6 +26,7 @@ internal sealed class QuestInfo
         CompletesInstantly = quest.ToDoCompleteSeq[0] == 0;
         PreviousInstanceContent = quest.InstanceContent.Select(x => (ushort)x.Row).Where(x => x != 0).ToList();
         PreviousInstanceContentJoin = (QuestJoin)quest.InstanceContentJoin;
+        GrandCompany = (GrandCompany)quest.GrandCompany.Row;
     }
 
 
@@ -35,12 +37,13 @@ internal sealed class QuestInfo
     public bool IsRepeatable { get; }
     public ImmutableList<ushort> PreviousQuests { get; }
     public QuestJoin PreviousQuestJoin { get; }
-    public ImmutableList<ushort> QuestLocks { get; set; }
-    public QuestJoin QuestLockJoin { get; set; }
-    public List<ushort> PreviousInstanceContent { get; set; }
-    public QuestJoin PreviousInstanceContentJoin { get; set; }
+    public ImmutableList<ushort> QuestLocks { get; }
+    public QuestJoin QuestLockJoin { get; }
+    public List<ushort> PreviousInstanceContent { get; }
+    public QuestJoin PreviousInstanceContentJoin { get; }
     public bool IsMainScenarioQuest { get; }
-    public bool CompletesInstantly { get; set; }
+    public bool CompletesInstantly { get; }
+    public GrandCompany GrandCompany { get; }
 
     public string SimplifiedName => Name
         .TrimStart(SeIconChar.QuestSync.ToIconChar(), SeIconChar.QuestRepeatable.ToIconChar(), ' ');
index c18c7d72041194ffe8f5278517c487e7dffb8be6..7821bbc12d9c70541e9a00fa909d89f1e46bdf95 100644 (file)
@@ -116,7 +116,9 @@ internal sealed class ActiveQuestComponent
                 if (_configuration.Advanced.AdditionalStatusInformation && _questController.IsInterruptible())
                 {
                     ImGui.SameLine();
-                    ImGui.TextColored(ImGuiColors.DalamudYellow, "Interruptible");
+                    ImGui.PushFont(UiBuilder.IconFont);
+                    ImGui.TextColored(ImGuiColors.DalamudYellow, FontAwesomeIcon.CodeBranch.ToIconString());
+                    ImGui.PopFont();
                 }
             }
 
index 1594c497a7968fe252fac9f12874cc4f700bab10..7594fc4a9fb333b3777402eaca30dea6040652cb 100644 (file)
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
 using System.Globalization;
 using System.Linq;
 using System.Numerics;
@@ -11,6 +12,7 @@ using Dalamud.Plugin;
 using Dalamud.Plugin.Services;
 using FFXIVClientStructs.FFXIV.Client.Game.UI;
 using FFXIVClientStructs.FFXIV.Client.UI;
+using FFXIVClientStructs.FFXIV.Client.UI.Agent;
 using ImGuiNET;
 using LLib.GameUI;
 using LLib.ImGui;
@@ -187,10 +189,7 @@ internal sealed class QuestSelectionWindow : LWindow
                         }
 
                         if (quest.PreviousQuests.Count > 0)
-                        {
-                            ImGui.Separator();
                             DrawQuestUnlocks(quest, 0);
-                        }
                     }
                 }
             }
@@ -266,6 +265,9 @@ internal sealed class QuestSelectionWindow : LWindow
 
         if (quest.PreviousQuests.Count > 0)
         {
+            if (counter == 0)
+                ImGui.Separator();
+
             if (quest.PreviousQuests.Count > 1)
             {
                 if (quest.PreviousQuestJoin == QuestInfo.QuestJoin.All)
@@ -278,17 +280,10 @@ internal sealed class QuestSelectionWindow : LWindow
             {
                 var qInfo = _questData.GetQuestInfo(q);
                 var (iconColor, icon, _) = _uiUtils.GetQuestStyle(q);
-                // ReSharper disable once UnusedVariable
-                using (var font = _pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push())
-                {
-                    if (_questRegistry.IsKnownQuest(qInfo.QuestId))
-                        ImGui.TextColored(iconColor, icon.ToIconString());
-                    else
-                        ImGui.TextColored(ImGuiColors.DalamudGrey, icon.ToIconString());
-                }
+                if (!_questRegistry.IsKnownQuest(qInfo.QuestId))
+                    iconColor = ImGuiColors.DalamudGrey;
 
-                ImGui.SameLine();
-                ImGui.TextUnformatted(FormatQuestUnlockName(qInfo));
+                _uiUtils.ChecklistItem(FormatQuestUnlockName(qInfo), iconColor, icon);
 
                 DrawQuestUnlocks(qInfo, counter + 1);
             }
@@ -296,12 +291,13 @@ internal sealed class QuestSelectionWindow : LWindow
 
         if (counter == 0 && quest.QuestLocks.Count > 0)
         {
+            ImGui.Separator();
             if (quest.QuestLocks.Count > 1)
             {
                 if (quest.QuestLockJoin == QuestInfo.QuestJoin.All)
-                    ImGui.Text("Blocked if all completed:");
+                    ImGui.Text("Blocked by (if all completed):");
                 else if (quest.QuestLockJoin == QuestInfo.QuestJoin.AtLeastOne)
-                    ImGui.Text("Blocked if at least completed:");
+                    ImGui.Text("Blocked by (if at least completed):");
             }
             else
                 ImGui.Text("Blocked by (if completed):");
@@ -310,22 +306,16 @@ internal sealed class QuestSelectionWindow : LWindow
             {
                 var qInfo = _questData.GetQuestInfo(q);
                 var (iconColor, icon, _) = _uiUtils.GetQuestStyle(q);
-                // ReSharper disable once UnusedVariable
-                using (var font = _pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push())
-                {
-                    if (_questRegistry.IsKnownQuest(qInfo.QuestId))
-                        ImGui.TextColored(iconColor, icon.ToIconString());
-                    else
-                        ImGui.TextColored(ImGuiColors.DalamudGrey, icon.ToIconString());
-                }
+                if (!_questRegistry.IsKnownQuest(qInfo.QuestId))
+                    iconColor = ImGuiColors.DalamudGrey;
 
-                ImGui.SameLine();
-                ImGui.TextUnformatted(FormatQuestUnlockName(qInfo));
+                _uiUtils.ChecklistItem(FormatQuestUnlockName(qInfo), iconColor, icon);
             }
         }
 
         if (counter == 0 && quest.PreviousInstanceContent.Count > 0)
         {
+            ImGui.Separator();
             if (quest.PreviousInstanceContent.Count > 1)
             {
                 if (quest.PreviousQuestJoin == QuestInfo.QuestJoin.All)
@@ -340,18 +330,25 @@ internal sealed class QuestSelectionWindow : LWindow
             {
                 string instanceName = _territoryData.GetInstanceName(instanceId) ?? "?";
                 var (iconColor, icon) = UiUtils.GetInstanceStyle(instanceId);
-
-                // ReSharper disable once UnusedVariable
-                using (var font = _pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push())
-                {
-                    ImGui.TextColored(iconColor, icon.ToIconString());
-                }
-
-                ImGui.SameLine();
-                ImGui.TextUnformatted(instanceName);
+                _uiUtils.ChecklistItem(instanceName, iconColor, icon);
             }
         }
 
+        if (counter == 0 && quest.GrandCompany != GrandCompany.None)
+        {
+            ImGui.Separator();
+            string gcName = quest.GrandCompany switch
+            {
+                GrandCompany.Maelstrom => "Maelstrom",
+                GrandCompany.TwinAdder => "Twin Adder",
+                GrandCompany.ImmortalFlames => "Immortal Flames",
+                _ => "None",
+            };
+
+            GrandCompany currentGrandCompany = _gameFunctions.GetGrandCompany();
+            _uiUtils.ChecklistItem($"Grand Company: {gcName}", quest.GrandCompany == currentGrandCompany);
+        }
+
         if (counter > 0)
             ImGui.Unindent();
     }