muffin v6.12

This commit is contained in:
alydev 2025-10-09 07:53:51 +10:00
parent e786325cda
commit 0950798597
64 changed files with 40100 additions and 58121 deletions

View file

@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Plugin.Services;
using Lumina.Excel.Sheets;
using Microsoft.Extensions.Logging;
using Questionable.Model;
using Questionable.Model.Questing;
@ -19,12 +21,15 @@ internal sealed class JournalData
public List<IQuestInfo> Quests { get; }
public bool IsUnderOtherQuests { get; set; }
public Genre(JournalGenre journalGenre, List<IQuestInfo> quests)
{
Id = journalGenre.RowId;
Name = journalGenre.Name.ToString();
CategoryId = journalGenre.JournalCategory.RowId;
Quests = quests;
IsUnderOtherQuests = false;
}
public Genre(uint id, string name, uint categoryId, List<IQuestInfo> quests)
@ -33,6 +38,16 @@ internal sealed class JournalData
Name = name;
CategoryId = categoryId;
Quests = quests;
IsUnderOtherQuests = false;
}
public Genre(uint id, string name, uint categoryId, List<IQuestInfo> quests, bool isUnderOtherQuests = false)
{
Id = id;
Name = name;
CategoryId = categoryId;
Quests = quests;
IsUnderOtherQuests = isUnderOtherQuests;
}
}
@ -68,15 +83,20 @@ internal sealed class JournalData
}
}
private readonly ILogger<JournalData> _logger;
public List<Genre> Genres { get; }
public List<Category> Categories { get; }
public List<Section> Sections { get; }
public JournalData(IDataManager dataManager, QuestData questData)
public int? OtherQuestsSectionRowId { get; private set; }
public JournalData(IDataManager dataManager, QuestData questData, ILogger<JournalData> logger)
{
JournalData journalData = this;
_logger = logger;
List<Genre> list = (from x in dataManager.GetExcelSheet<JournalGenre>()
where x.RowId != 0 && x.Icon > 0
select new Genre(x, questData.GetAllByJournalGenre(x.RowId))).ToList();
@ -92,7 +112,7 @@ internal sealed class JournalData
Genre genreUldah = new Genre(4294967294u, "Starting in Ul'dah", 1u, (from x in new uint[3] { 568u, 569u, 570u }.Concat(row3.QuestRedoParam.Select((QuestRedo.QuestRedoParamStruct x) => x.Quest.RowId))
where x != 0
select questData.GetQuestInfo(QuestId.FromRowId(x))).ToList());
list.InsertRange(0, new global::_003C_003Ez__ReadOnlyArray<Genre>(new Genre[3] { genreLimsa, genreGridania, genreUldah }));
list.InsertRange(0, new Genre[3] { genreLimsa, genreGridania, genreUldah });
list.Single((Genre x) => x.Id == 1).Quests.RemoveAll((IQuestInfo x) => genreLimsa.Quests.Contains(x) || genreGridania.Quests.Contains(x) || genreUldah.Quests.Contains(x));
Genres = list.ToList();
Categories = (from x in dataManager.GetExcelSheet<JournalCategory>()
@ -100,5 +120,51 @@ internal sealed class JournalData
select new Category(x, journalData.Genres.Where((Genre y) => y.CategoryId == x.RowId).ToList())).ToList();
Sections = (from x in dataManager.GetExcelSheet<JournalSection>()
select new Section(x, journalData.Categories.Where((Category y) => y.SectionId == x.RowId).ToList())).ToList();
_logger.LogDebug("Resolving OtherQuests section id...");
OtherQuestsSectionRowId = GetOtherQuestsSectionRowId(dataManager);
_logger.LogDebug("Resolved OtherQuestsSectionRowId = {Id}", OtherQuestsSectionRowId);
int? otherQuestsSectionRowId = OtherQuestsSectionRowId;
if (otherQuestsSectionRowId.HasValue)
{
int valueOrDefault = otherQuestsSectionRowId.GetValueOrDefault();
uint otherIdU = (uint)valueOrDefault;
Section section = Sections.FirstOrDefault((Section s) => s.Id == otherIdU);
if (section != null)
{
int num = 0;
foreach (Category category in section.Categories)
{
foreach (Genre genre in category.Genres)
{
genre.IsUnderOtherQuests = true;
num++;
}
}
_logger.LogInformation("Marked {Count} genres as under 'Other Quests' (section id {Id})", num, valueOrDefault);
}
else
{
_logger.LogWarning("OtherQuestsSectionRowId {Id} found but matching Section not present in constructed Sections", valueOrDefault);
}
}
else
{
_logger.LogDebug("OtherQuestsSectionRowId not found - falling back to localized name lookup when necessary");
}
}
private int? GetOtherQuestsSectionRowId(IDataManager dataManager)
{
JournalSection journalSection = dataManager.GetExcelSheet<JournalSection>().FirstOrDefault((JournalSection s) => s.Name.ToString() == "Other Quests");
int? result = ((journalSection.RowId != 0) ? new int?((int)journalSection.RowId) : ((int?)null));
if (!result.HasValue)
{
Section section = Sections.FirstOrDefault((Section s) => s.Name.Equals("Other Quests", StringComparison.OrdinalIgnoreCase));
if (section != null)
{
result = (int)section.Id;
}
}
return result;
}
}