Change how removed quests are shown in journal
This commit is contained in:
parent
f1b6614f52
commit
d59476f7f8
@ -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)),
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
}
|
@ -51,6 +51,7 @@ public static class RoslynShortcuts
|
|||||||
QuestId questId => questId.ToExpressionSyntax(),
|
QuestId questId => questId.ToExpressionSyntax(),
|
||||||
LeveId leveId => leveId.ToExpressionSyntax(),
|
LeveId leveId => leveId.ToExpressionSyntax(),
|
||||||
SatisfactionSupplyNpcId satisfactionSupplyNpcId => satisfactionSupplyNpcId.ToExpressionSyntax(),
|
SatisfactionSupplyNpcId satisfactionSupplyNpcId => satisfactionSupplyNpcId.ToExpressionSyntax(),
|
||||||
|
AlliedSocietyDailyId alliedSocietyDailyId => alliedSocietyDailyId.ToExpressionSyntax(),
|
||||||
Vector3 vector => vector.ToExpressionSyntax(),
|
Vector3 vector => vector.ToExpressionSyntax(),
|
||||||
AethernetShortcut aethernetShortcut => aethernetShortcut.ToExpressionSyntax(),
|
AethernetShortcut aethernetShortcut => aethernetShortcut.ToExpressionSyntax(),
|
||||||
ChatMessage chatMessage => chatMessage.ToExpressionSyntax(),
|
ChatMessage chatMessage => chatMessage.ToExpressionSyntax(),
|
||||||
|
@ -77,7 +77,6 @@ internal sealed class JournalData
|
|||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
public uint CategoryId { get; }
|
public uint CategoryId { get; }
|
||||||
public List<IQuestInfo> Quests { get; }
|
public List<IQuestInfo> Quests { get; }
|
||||||
public int QuestCount => Quests.Count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal sealed class Category(JournalCategory journalCategory, IReadOnlyList<Genre> genres)
|
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 string Name { get; } = journalCategory.Name.ToString();
|
||||||
public uint SectionId { get; } = journalCategory.JournalSection.RowId;
|
public uint SectionId { get; } = journalCategory.JournalSection.RowId;
|
||||||
public IReadOnlyList<Genre> Genres { get; } = genres;
|
public IReadOnlyList<Genre> Genres { get; } = genres;
|
||||||
public int QuestCount => Genres.Sum(x => x.QuestCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal sealed class Section(JournalSection journalSection, IReadOnlyList<Category> categories)
|
internal sealed class Section(JournalSection journalSection, IReadOnlyList<Category> categories)
|
||||||
@ -94,6 +92,5 @@ internal sealed class JournalData
|
|||||||
public uint Id { get; } = journalSection.RowId;
|
public uint Id { get; } = journalSection.RowId;
|
||||||
public string Name { get; } = journalSection.Name.ToString();
|
public string Name { get; } = journalSection.Name.ToString();
|
||||||
public IReadOnlyList<Category> Categories { get; } = categories;
|
public IReadOnlyList<Category> Categories { get; } = categories;
|
||||||
public int QuestCount => Categories.Sum(x => x.QuestCount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,7 @@ internal sealed class QuestData
|
|||||||
.Where(x => x.RowId > 0)
|
.Where(x => x.RowId > 0)
|
||||||
.Where(x => x.IssuerLocation.RowId > 0)
|
.Where(x => x.IssuerLocation.RowId > 0)
|
||||||
.Select(x => new QuestInfo(x, questChapters.GetValueOrDefault(x.RowId),
|
.Select(x => new QuestInfo(x, questChapters.GetValueOrDefault(x.RowId),
|
||||||
startingCities.GetValueOrDefault(x.RowId)))
|
startingCities.GetValueOrDefault(x.RowId))),
|
||||||
.Where(x => x.QuestId.Value != 1428),
|
|
||||||
..dataManager.GetExcelSheet<SatisfactionNpc>()
|
..dataManager.GetExcelSheet<SatisfactionNpc>()
|
||||||
.Where(x => x is { RowId: > 0, Npc.RowId: > 0 })
|
.Where(x => x is { RowId: > 0, Npc.RowId: > 0 })
|
||||||
.Select(x => new SatisfactionSupplyInfo(x)),
|
.Select(x => new SatisfactionSupplyInfo(x)),
|
||||||
@ -186,7 +185,7 @@ internal sealed class QuestData
|
|||||||
// initial city quests are side quests
|
// initial city quests are side quests
|
||||||
// unclear if 470 can be started as the required quest isn't available anymore
|
// unclear if 470 can be started as the required quest isn't available anymore
|
||||||
ushort[] limsaSideQuests =
|
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)
|
foreach (var questId in limsaSideQuests)
|
||||||
((QuestInfo)_quests[new QuestId(questId)]).StartingCity = 1;
|
((QuestInfo)_quests[new QuestId(questId)]).StartingCity = 1;
|
||||||
|
|
||||||
@ -196,7 +195,7 @@ internal sealed class QuestData
|
|||||||
((QuestInfo)_quests[new QuestId(questId)]).StartingCity = 2;
|
((QuestInfo)_quests[new QuestId(questId)]).StartingCity = 2;
|
||||||
|
|
||||||
ushort[] uldahSideQuests =
|
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)
|
foreach (var questId in uldahSideQuests)
|
||||||
((QuestInfo)_quests[new QuestId(questId)]).StartingCity = 3;
|
((QuestInfo)_quests[new QuestId(questId)]).StartingCity = 3;
|
||||||
|
|
||||||
|
@ -670,6 +670,9 @@ internal sealed unsafe class QuestFunctions
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsQuestRemoved(questId))
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,6 +685,20 @@ internal sealed unsafe class QuestFunctions
|
|||||||
return false;
|
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)
|
private bool HasCompletedPreviousQuests(IQuestInfo questInfo, ElementId? extraCompletedQuest)
|
||||||
{
|
{
|
||||||
if (questInfo.PreviousQuests.Count == 0)
|
if (questInfo.PreviousQuests.Count == 0)
|
||||||
|
@ -93,18 +93,18 @@ internal sealed class QuestJournalComponent
|
|||||||
|
|
||||||
private void DrawSection(FilteredSection filter)
|
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;
|
return;
|
||||||
|
|
||||||
(int available, int obtainable, int completed) = _sectionCounts.GetValueOrDefault(filter.Section, new());
|
|
||||||
|
|
||||||
ImGui.TableNextRow();
|
ImGui.TableNextRow();
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
|
|
||||||
bool open = ImGui.TreeNodeEx(filter.Section.Name, ImGuiTreeNodeFlags.SpanFullWidth);
|
bool open = ImGui.TreeNodeEx(filter.Section.Name, ImGuiTreeNodeFlags.SpanFullWidth);
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
DrawCount(available, filter.Section.QuestCount);
|
DrawCount(available, total);
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
DrawCount(completed, obtainable);
|
DrawCount(completed, obtainable);
|
||||||
|
|
||||||
@ -119,18 +119,18 @@ internal sealed class QuestJournalComponent
|
|||||||
|
|
||||||
private void DrawCategory(FilteredCategory filter)
|
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;
|
return;
|
||||||
|
|
||||||
(int available, int obtainable, int completed) = _categoryCounts.GetValueOrDefault(filter.Category, new());
|
|
||||||
|
|
||||||
ImGui.TableNextRow();
|
ImGui.TableNextRow();
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
|
|
||||||
bool open = ImGui.TreeNodeEx(filter.Category.Name, ImGuiTreeNodeFlags.SpanFullWidth);
|
bool open = ImGui.TreeNodeEx(filter.Category.Name, ImGuiTreeNodeFlags.SpanFullWidth);
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
DrawCount(available, filter.Category.QuestCount);
|
DrawCount(available, total);
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
DrawCount(completed, obtainable);
|
DrawCount(completed, obtainable);
|
||||||
|
|
||||||
@ -145,18 +145,17 @@ internal sealed class QuestJournalComponent
|
|||||||
|
|
||||||
private void DrawGenre(FilteredGenre filter)
|
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;
|
return;
|
||||||
|
|
||||||
(int supported, int obtainable, int completed) = _genreCounts.GetValueOrDefault(filter.Genre, new());
|
|
||||||
|
|
||||||
ImGui.TableNextRow();
|
ImGui.TableNextRow();
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
|
|
||||||
bool open = ImGui.TreeNodeEx(filter.Genre.Name, ImGuiTreeNodeFlags.SpanFullWidth);
|
bool open = ImGui.TreeNodeEx(filter.Genre.Name, ImGuiTreeNodeFlags.SpanFullWidth);
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
DrawCount(supported, filter.Genre.QuestCount);
|
DrawCount(supported, total);
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
DrawCount(completed, obtainable);
|
DrawCount(completed, obtainable);
|
||||||
|
|
||||||
@ -194,7 +193,9 @@ internal sealed class QuestJournalComponent
|
|||||||
|
|
||||||
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + spacing);
|
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);
|
List<ValidationIssue> issues = _questValidator.GetIssues(quest.Id);
|
||||||
if (issues.Any(x => x.Severity == EIssueSeverity.Error))
|
if (issues.Any(x => x.Severity == EIssueSeverity.Error))
|
||||||
@ -319,10 +320,13 @@ internal sealed class QuestJournalComponent
|
|||||||
foreach (var genre in _journalData.Genres)
|
foreach (var genre in _journalData.Genres)
|
||||||
{
|
{
|
||||||
int available = genre.Quests.Count(x =>
|
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 obtainable = genre.Quests.Count(x => !_questFunctions.IsQuestUnobtainable(x.QuestId));
|
||||||
int completed = genre.Quests.Count(x => _questFunctions.IsQuestComplete(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)
|
foreach (var category in _journalData.Categories)
|
||||||
@ -332,9 +336,10 @@ internal sealed class QuestJournalComponent
|
|||||||
.Select(x => x.Value)
|
.Select(x => x.Value)
|
||||||
.ToList();
|
.ToList();
|
||||||
int available = counts.Sum(x => x.Available);
|
int available = counts.Sum(x => x.Available);
|
||||||
|
int total = counts.Sum(x => x.Total);
|
||||||
int obtainable = counts.Sum(x => x.Obtainable);
|
int obtainable = counts.Sum(x => x.Obtainable);
|
||||||
int completed = counts.Sum(x => x.Completed);
|
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)
|
foreach (var section in _journalData.Sections)
|
||||||
@ -344,9 +349,10 @@ internal sealed class QuestJournalComponent
|
|||||||
.Select(x => x.Value)
|
.Select(x => x.Value)
|
||||||
.ToList();
|
.ToList();
|
||||||
int available = counts.Sum(x => x.Available);
|
int available = counts.Sum(x => x.Available);
|
||||||
|
int total = counts.Sum(x => x.Total);
|
||||||
int obtainable = counts.Sum(x => x.Obtainable);
|
int obtainable = counts.Sum(x => x.Obtainable);
|
||||||
int completed = counts.Sum(x => x.Completed);
|
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 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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user