From d59476f7f88b0d5c497da4aeba91572fbd0be982 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sun, 22 Dec 2024 00:43:58 +0100 Subject: [PATCH] Change how removed quests are shown in journal --- .../AlliedSocietyDailyIdExtensions.cs | 26 ++++++++++ QuestPathGenerator/RoslynShortcuts.cs | 1 + Questionable/Data/JournalData.cs | 3 -- Questionable/Data/QuestData.cs | 7 ++- Questionable/Functions/QuestFunctions.cs | 17 +++++++ .../QuestJournalComponent.cs | 48 ++++++++++++------- 6 files changed, 77 insertions(+), 25 deletions(-) create mode 100644 QuestPathGenerator/RoslynElements/AlliedSocietyDailyIdExtensions.cs diff --git a/QuestPathGenerator/RoslynElements/AlliedSocietyDailyIdExtensions.cs b/QuestPathGenerator/RoslynElements/AlliedSocietyDailyIdExtensions.cs new file mode 100644 index 00000000..535b66b3 --- /dev/null +++ b/QuestPathGenerator/RoslynElements/AlliedSocietyDailyIdExtensions.cs @@ -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( + new SyntaxNodeOrToken[] + { + Argument(LiteralValue(alliedSocietyDailyId.AlliedSociety)), + Token(SyntaxKind.CommaToken), + Argument(LiteralValue(alliedSocietyDailyId.Rank)), + }))); + } +} diff --git a/QuestPathGenerator/RoslynShortcuts.cs b/QuestPathGenerator/RoslynShortcuts.cs index 4147e47b..c5fb47f5 100644 --- a/QuestPathGenerator/RoslynShortcuts.cs +++ b/QuestPathGenerator/RoslynShortcuts.cs @@ -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(), diff --git a/Questionable/Data/JournalData.cs b/Questionable/Data/JournalData.cs index 56a12b6b..115d806e 100644 --- a/Questionable/Data/JournalData.cs +++ b/Questionable/Data/JournalData.cs @@ -77,7 +77,6 @@ internal sealed class JournalData public string Name { get; } public uint CategoryId { get; } public List Quests { get; } - public int QuestCount => Quests.Count; } internal sealed class Category(JournalCategory journalCategory, IReadOnlyList 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 Genres { get; } = genres; - public int QuestCount => Genres.Sum(x => x.QuestCount); } internal sealed class Section(JournalSection journalSection, IReadOnlyList categories) @@ -94,6 +92,5 @@ internal sealed class JournalData public uint Id { get; } = journalSection.RowId; public string Name { get; } = journalSection.Name.ToString(); public IReadOnlyList Categories { get; } = categories; - public int QuestCount => Categories.Sum(x => x.QuestCount); } } diff --git a/Questionable/Data/QuestData.cs b/Questionable/Data/QuestData.cs index 3cb2f295..b875d700 100644 --- a/Questionable/Data/QuestData.cs +++ b/Questionable/Data/QuestData.cs @@ -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() .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; diff --git a/Questionable/Functions/QuestFunctions.cs b/Questionable/Functions/QuestFunctions.cs index fc5d7935..8c937bcc 100644 --- a/Questionable/Functions/QuestFunctions.cs +++ b/Questionable/Functions/QuestFunctions.cs @@ -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) diff --git a/Questionable/Windows/JournalComponents/QuestJournalComponent.cs b/Questionable/Windows/JournalComponents/QuestJournalComponent.cs index b68f9dd3..04dc9bca 100644 --- a/Questionable/Windows/JournalComponents/QuestJournalComponent.cs +++ b/Questionable/Windows/JournalComponents/QuestJournalComponent.cs @@ -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 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 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) + { + } + } }