forked from liza/Questionable
Show an icon if a quest is loaded from user directory
This commit is contained in:
parent
b8dc5fa8e3
commit
7de9ed38df
@ -61,7 +61,8 @@ internal sealed class QuestRegistry
|
||||
|
||||
try
|
||||
{
|
||||
LoadFromDirectory(new DirectoryInfo(Path.Combine(_pluginInterface.ConfigDirectory.FullName, "Quests")));
|
||||
LoadFromDirectory(new DirectoryInfo(Path.Combine(_pluginInterface.ConfigDirectory.FullName, "Quests")),
|
||||
Quest.ESource.UserDirectory);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -99,7 +100,7 @@ internal sealed class QuestRegistry
|
||||
Id = questId,
|
||||
Root = questRoot,
|
||||
Info = questInfo,
|
||||
ReadOnly = true,
|
||||
Source = Quest.ESource.Assembly,
|
||||
};
|
||||
_quests[quest.Id] = quest;
|
||||
}
|
||||
@ -122,6 +123,7 @@ internal sealed class QuestRegistry
|
||||
foreach (var expansionFolder in ExpansionData.ExpansionFolders.Values)
|
||||
LoadFromDirectory(
|
||||
new DirectoryInfo(Path.Combine(pathProjectDirectory.FullName, expansionFolder)),
|
||||
Quest.ESource.ProjectDirectory,
|
||||
LogLevel.Trace);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -135,10 +137,10 @@ internal sealed class QuestRegistry
|
||||
|
||||
private void ValidateQuests()
|
||||
{
|
||||
_questValidator.Validate(_quests.Values.Where(x => !x.ReadOnly));
|
||||
_questValidator.Validate(_quests.Values.Where(x => x.Source != Quest.ESource.Assembly));
|
||||
}
|
||||
|
||||
private void LoadQuestFromStream(string fileName, Stream stream)
|
||||
private void LoadQuestFromStream(string fileName, Stream stream, Quest.ESource source)
|
||||
{
|
||||
_logger.LogTrace("Loading quest from '{FileName}'", fileName);
|
||||
ElementId? questId = ExtractQuestIdFromName(fileName);
|
||||
@ -157,12 +159,13 @@ internal sealed class QuestRegistry
|
||||
Id = questId,
|
||||
Root = questRoot,
|
||||
Info = questInfo,
|
||||
ReadOnly = false,
|
||||
Source = source,
|
||||
};
|
||||
_quests[quest.Id] = quest;
|
||||
}
|
||||
|
||||
private void LoadFromDirectory(DirectoryInfo directory, LogLevel logLevel = LogLevel.Information)
|
||||
private void LoadFromDirectory(DirectoryInfo directory, Quest.ESource source,
|
||||
LogLevel logLevel = LogLevel.Information)
|
||||
{
|
||||
if (!directory.Exists)
|
||||
{
|
||||
@ -176,7 +179,7 @@ internal sealed class QuestRegistry
|
||||
try
|
||||
{
|
||||
using FileStream stream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read);
|
||||
LoadQuestFromStream(fileInfo.Name, stream);
|
||||
LoadQuestFromStream(fileInfo.Name, stream, source);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -185,7 +188,7 @@ internal sealed class QuestRegistry
|
||||
}
|
||||
|
||||
foreach (DirectoryInfo childDirectory in directory.GetDirectories())
|
||||
LoadFromDirectory(childDirectory, logLevel);
|
||||
LoadFromDirectory(childDirectory, source, logLevel);
|
||||
}
|
||||
|
||||
private static ElementId? ExtractQuestIdFromName(string resourceName)
|
||||
|
@ -9,7 +9,7 @@ internal sealed class Quest
|
||||
public required ElementId Id { get; init; }
|
||||
public required QuestRoot Root { get; init; }
|
||||
public required IQuestInfo Info { get; init; }
|
||||
public required bool ReadOnly { get; init; }
|
||||
public required ESource Source { get; init; }
|
||||
|
||||
public QuestSequence? FindSequence(byte currentSequence)
|
||||
=> Root.QuestSequence.SingleOrDefault(seq => seq.Sequence == currentSequence);
|
||||
@ -27,4 +27,11 @@ internal sealed class Quest
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ESource
|
||||
{
|
||||
Assembly,
|
||||
ProjectDirectory,
|
||||
UserDirectory,
|
||||
}
|
||||
}
|
||||
|
@ -134,6 +134,17 @@ internal sealed partial class ActiveQuestComponent
|
||||
var startedQuest = _questController.StartedQuest;
|
||||
if (startedQuest != null)
|
||||
{
|
||||
if (startedQuest.Quest.Source == Quest.ESource.UserDirectory)
|
||||
{
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
ImGui.TextColored(ImGuiColors.DalamudOrange, FontAwesomeIcon.FilePen.ToIconString());
|
||||
ImGui.PopFont();
|
||||
ImGui.SameLine(0);
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("This quest is loaded from your 'pluginConfigs\\Questionable\\Quests' directory.\nThis gets loaded even if Questionable ships with a newer/different version of the quest.");
|
||||
}
|
||||
|
||||
ImGui.TextUnformatted(
|
||||
$"Quest: {Shorten(startedQuest.Quest.Info.Name)} / {startedQuest.Sequence} / {startedQuest.Step}");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user