Change how removed quests are shown in journal
authorLiza Carvelli <liza@carvel.li>
Sat, 21 Dec 2024 23:43:58 +0000 (00:43 +0100)
committerLiza Carvelli <liza@carvel.li>
Sat, 21 Dec 2024 23:43:58 +0000 (00:43 +0100)
QuestPathGenerator/RoslynElements/AlliedSocietyDailyIdExtensions.cs [new file with mode: 0644]
QuestPathGenerator/RoslynShortcuts.cs
Questionable/Data/JournalData.cs
Questionable/Data/QuestData.cs
Questionable/Functions/QuestFunctions.cs
Questionable/Windows/JournalComponents/QuestJournalComponent.cs

diff --git a/QuestPathGenerator/RoslynElements/AlliedSocietyDailyIdExtensions.cs b/QuestPathGenerator/RoslynElements/AlliedSocietyDailyIdExtensions.cs
new file mode 100644 (file)
index 0000000..535b66b
--- /dev/null
@@ -0,0 +1,26 @@
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Questionable.Model.Questing;
+using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
+using static Questionable.QuestPathGenerator.RoslynShortcuts;
+
+namespace Questionable.QuestPathGenerator.RoslynElements;
+
+internal static class AlliedSocietyDailyIdExtensions
+{
+    public static ExpressionSyntax ToExpressionSyntax(this AlliedSocietyDailyId alliedSocietyDailyId)
+    {
+        return ObjectCreationExpression(
+                IdentifierName(nameof(AlliedSocietyDailyId)))
+            .WithArgumentList(
+                ArgumentList(
+                    SeparatedList<ArgumentSyntax>(
+                        new SyntaxNodeOrToken[]
+                        {
+                            Argument(LiteralValue(alliedSocietyDailyId.AlliedSociety)),
+                            Token(SyntaxKind.CommaToken),
+                            Argument(LiteralValue(alliedSocietyDailyId.Rank)),
+                        })));
+    }
+}
index 4147e47baaaee78b91daffb3430c8467f766e662..c5fb47f5b8f592fe47c18ace73a44a7fd0444364 100644 (file)
@@ -51,6 +51,7 @@ public static class RoslynShortcuts
                 QuestId questId => questId.ToExpressionSyntax(),
                 LeveId leveId => leveId.ToExpressionSyntax(),
                 SatisfactionSupplyNpcId satisfactionSupplyNpcId => satisfactionSupplyNpcId.ToExpressionSyntax(),
+                AlliedSocietyDailyId alliedSocietyDailyId => alliedSocietyDailyId.ToExpressionSyntax(),
                 Vector3 vector => vector.ToExpressionSyntax(),
                 AethernetShortcut aethernetShortcut => aethernetShortcut.ToExpressionSyntax(),
                 ChatMessage chatMessage => chatMessage.ToExpressionSyntax(),
index 56a12b6b1436cc8a72872af1c8d666cd0ea30e31..115d806e21eceed71c598af92df59720158abed8 100644 (file)
@@ -77,7 +77,6 @@ internal sealed class JournalData
         public string Name { get; }
         public uint CategoryId { get; }
         public List<IQuestInfo> Quests { get; }
-        public int QuestCount => Quests.Count;
     }
 
     internal sealed class Category(JournalCategory journalCategory, IReadOnlyList<Genre> genres)
@@ -86,7 +85,6 @@ internal sealed class JournalData
         public string Name { get; } = journalCategory.Name.ToString();
         public uint SectionId { get; } = journalCategory.JournalSection.RowId;
         public IReadOnlyList<Genre> Genres { get; } = genres;
-        public int QuestCount => Genres.Sum(x => x.QuestCount);
     }
 
     internal sealed class Section(JournalSection journalSection, IReadOnlyList<Category> categories)
@@ -94,6 +92,5 @@ internal sealed class JournalData
         public uint Id { get; } = journalSection.RowId;
         public string Name { get; } = journalSection.Name.ToString();
         public IReadOnlyList<Category> Categories { get; } = categories;
-        public int QuestCount => Categories.Sum(x => x.QuestCount);
     }
 }
index 3cb2f295a482aa421a8cf078c529e73ed178316e..b875d700d7d17fc14d3d98e5ca3796174f9217d9 100644 (file)
@@ -58,8 +58,7 @@ internal sealed class QuestData
                 .Where(x => x.RowId > 0)
                 .Where(x => x.IssuerLocation.RowId > 0)
                 .Select(x => new QuestInfo(x, questChapters.GetValueOrDefault(x.RowId),
-                    startingCities.GetValueOrDefault(x.RowId)))
-                .Where(x => x.QuestId.Value != 1428),
+                    startingCities.GetValueOrDefault(x.RowId))),
             ..dataManager.GetExcelSheet<SatisfactionNpc>()
                 .Where(x => x is { RowId: > 0, Npc.RowId: > 0 })
                 .Select(x => new SatisfactionSupplyInfo(x)),
@@ -186,7 +185,7 @@ internal sealed class QuestData
         // initial city quests are side quests
         // unclear if 470 can be started as the required quest isn't available anymore
         ushort[] limsaSideQuests =
-            [107, 111, 112, 122, 663, 475, 472, 476, 470, 473, 474, 477, 486, 478, 479, 487, 59, 400, 401, 693, 405];
+            [107, 111, 112, 122, 663, 475, 472, 476, 470, 473, 474, 477, 486, 478, 479, 59, 400, 401, 693, 405];
         foreach (var questId in limsaSideQuests)
             ((QuestInfo)_quests[new QuestId(questId)]).StartingCity = 1;
 
@@ -196,7 +195,7 @@ internal sealed class QuestData
             ((QuestInfo)_quests[new QuestId(questId)]).StartingCity = 2;
 
         ushort[] uldahSideQuests =
-            [594, 389, 390, 321, 304, 322, 388, 308, 326, 1429, 58, 687, 341, 504, 531, 506, 530, 573, 342, 505];
+            [594, 389, 390, 321, 304, 322, 388, 308, 326, 58, 687, 341, 504, 531, 506, 530, 573, 342, 505];
         foreach (var questId in uldahSideQuests)
             ((QuestInfo)_quests[new QuestId(questId)]).StartingCity = 3;
 
index fc5d7935c1c8d43b76ed1955a6b191cb58eecc3c..8c937bcc991560efe641c7ffbb358c1b12093d52 100644 (file)
@@ -670,6 +670,9 @@ internal sealed unsafe class QuestFunctions
                 return true;
         }
 
+        if (IsQuestRemoved(questId))
+            return true;
+
         return false;
     }
 
@@ -682,6 +685,20 @@ internal sealed unsafe class QuestFunctions
         return false;
     }
 
+    public bool IsQuestRemoved(ElementId elementId)
+    {
+        if (elementId is QuestId questId)
+            return IsQuestRemoved(questId);
+        else
+            return false;
+    }
+
+    [SuppressMessage("Performance", "CA1822")]
+    private bool IsQuestRemoved(QuestId questId)
+    {
+        return questId.Value is 487 or 1428 or 1429;
+    }
+
     private bool HasCompletedPreviousQuests(IQuestInfo questInfo, ElementId? extraCompletedQuest)
     {
         if (questInfo.PreviousQuests.Count == 0)
index b68f9dd3aba23c6b732859471c4ecc21393fc185..04dc9bca8fb7c031bc521cccce8446fbefb925b9 100644 (file)
@@ -93,18 +93,18 @@ internal sealed class QuestJournalComponent
 
     private void DrawSection(FilteredSection filter)
     {
-        if (filter.Section.QuestCount == 0)
+        (int available, int total, int obtainable, int completed) =
+            _sectionCounts.GetValueOrDefault(filter.Section, new());
+        if (total == 0)
             return;
 
-        (int available, int obtainable, int completed) = _sectionCounts.GetValueOrDefault(filter.Section, new());
-
         ImGui.TableNextRow();
         ImGui.TableNextColumn();
 
         bool open = ImGui.TreeNodeEx(filter.Section.Name, ImGuiTreeNodeFlags.SpanFullWidth);
 
         ImGui.TableNextColumn();
-        DrawCount(available, filter.Section.QuestCount);
+        DrawCount(available, total);
         ImGui.TableNextColumn();
         DrawCount(completed, obtainable);
 
@@ -119,18 +119,18 @@ internal sealed class QuestJournalComponent
 
     private void DrawCategory(FilteredCategory filter)
     {
-        if (filter.Category.QuestCount == 0)
+        (int available, int total, int obtainable, int completed) =
+            _categoryCounts.GetValueOrDefault(filter.Category, new());
+        if (total == 0)
             return;
 
-        (int available, int obtainable, int completed) = _categoryCounts.GetValueOrDefault(filter.Category, new());
-
         ImGui.TableNextRow();
         ImGui.TableNextColumn();
 
         bool open = ImGui.TreeNodeEx(filter.Category.Name, ImGuiTreeNodeFlags.SpanFullWidth);
 
         ImGui.TableNextColumn();
-        DrawCount(available, filter.Category.QuestCount);
+        DrawCount(available, total);
         ImGui.TableNextColumn();
         DrawCount(completed, obtainable);
 
@@ -145,18 +145,17 @@ internal sealed class QuestJournalComponent
 
     private void DrawGenre(FilteredGenre filter)
     {
-        if (filter.Genre.QuestCount == 0)
+        (int supported, int total, int obtainable, int completed) = _genreCounts.GetValueOrDefault(filter.Genre, new());
+        if (total == 0)
             return;
 
-        (int supported, int obtainable, int completed) = _genreCounts.GetValueOrDefault(filter.Genre, new());
-
         ImGui.TableNextRow();
         ImGui.TableNextColumn();
 
         bool open = ImGui.TreeNodeEx(filter.Genre.Name, ImGuiTreeNodeFlags.SpanFullWidth);
 
         ImGui.TableNextColumn();
-        DrawCount(supported, filter.Genre.QuestCount);
+        DrawCount(supported, total);
         ImGui.TableNextColumn();
         DrawCount(completed, obtainable);
 
@@ -194,7 +193,9 @@ internal sealed class QuestJournalComponent
 
         ImGui.SetCursorPosX(ImGui.GetCursorPosX() + spacing);
 
-        if (quest is { Root.Disabled: false })
+        if (_questFunctions.IsQuestRemoved(questInfo.QuestId))
+            _uiUtils.ChecklistItem(string.Empty, ImGuiColors.DalamudGrey, FontAwesomeIcon.Minus);
+        else if (quest is { Root.Disabled: false })
         {
             List<ValidationIssue> issues = _questValidator.GetIssues(quest.Id);
             if (issues.Any(x => x.Severity == EIssueSeverity.Error))
@@ -319,10 +320,13 @@ internal sealed class QuestJournalComponent
         foreach (var genre in _journalData.Genres)
         {
             int available = genre.Quests.Count(x =>
-                _questRegistry.TryGetQuest(x.QuestId, out var quest) && !quest.Root.Disabled);
+                _questRegistry.TryGetQuest(x.QuestId, out var quest) &&
+                !quest.Root.Disabled &&
+                !_questFunctions.IsQuestRemoved(x.QuestId));
+            int total = genre.Quests.Count(x => !_questFunctions.IsQuestRemoved(x.QuestId));
             int obtainable = genre.Quests.Count(x => !_questFunctions.IsQuestUnobtainable(x.QuestId));
             int completed = genre.Quests.Count(x => _questFunctions.IsQuestComplete(x.QuestId));
-            _genreCounts[genre] = new(available, obtainable, completed);
+            _genreCounts[genre] = new(available, total, obtainable, completed);
         }
 
         foreach (var category in _journalData.Categories)
@@ -332,9 +336,10 @@ internal sealed class QuestJournalComponent
                 .Select(x => x.Value)
                 .ToList();
             int available = counts.Sum(x => x.Available);
+            int total = counts.Sum(x => x.Total);
             int obtainable = counts.Sum(x => x.Obtainable);
             int completed = counts.Sum(x => x.Completed);
-            _categoryCounts[category] = new(available, obtainable, completed);
+            _categoryCounts[category] = new(available, total, obtainable, completed);
         }
 
         foreach (var section in _journalData.Sections)
@@ -344,9 +349,10 @@ internal sealed class QuestJournalComponent
                 .Select(x => x.Value)
                 .ToList();
             int available = counts.Sum(x => x.Available);
+            int total = counts.Sum(x => x.Total);
             int obtainable = counts.Sum(x => x.Obtainable);
             int completed = counts.Sum(x => x.Completed);
-            _sectionCounts[section] = new(available, obtainable, completed);
+            _sectionCounts[section] = new(available, total, obtainable, completed);
         }
     }
 
@@ -368,5 +374,11 @@ internal sealed class QuestJournalComponent
 
     private sealed record FilteredGenre(JournalData.Genre Genre, List<IQuestInfo> Quests);
 
-    private sealed record JournalCounts(int Available = 0, int Obtainable = 0, int Completed = 0);
+    private sealed record JournalCounts(int Available, int Total, int Obtainable, int Completed)
+    {
+        public JournalCounts()
+            : this(0, 0, 0, 0)
+        {
+        }
+    }
 }