From c50008d9e6ab121f4b1f42603106a8c41fc4d82b Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Wed, 10 Jul 2024 18:54:04 +0200 Subject: [PATCH] Hide quest window in all instanced duties by default --- Questionable/Configuration.cs | 1 + Questionable/Data/TerritoryData.cs | 12 ++++++++++-- Questionable/Windows/ConfigWindow.cs | 7 +++++++ Questionable/Windows/QuestWindow.cs | 3 +++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Questionable/Configuration.cs b/Questionable/Configuration.cs index eaef4936..15a07b8c 100644 --- a/Questionable/Configuration.cs +++ b/Questionable/Configuration.cs @@ -17,6 +17,7 @@ internal sealed class Configuration : IPluginConfiguration public bool AutoAcceptNextQuest { get; set; } public uint MountId { get; set; } = 71; public GrandCompany GrandCompany { get; set; } = GrandCompany.None; + public bool HideInAllInstances { get; set; } = true; } internal sealed class AdvancedConfiguration diff --git a/Questionable/Data/TerritoryData.cs b/Questionable/Data/TerritoryData.cs index 7d3fc59e..fc541e77 100644 --- a/Questionable/Data/TerritoryData.cs +++ b/Questionable/Data/TerritoryData.cs @@ -10,7 +10,8 @@ namespace Questionable.Data; internal sealed class TerritoryData { private readonly ImmutableDictionary _territoryNames; - private readonly ImmutableHashSet _territoriesWithMount; + private readonly ImmutableHashSet _territoriesWithMount; + private readonly ImmutableHashSet _dutyTerritories; public TerritoryData(IDataManager dataManager) { @@ -27,7 +28,12 @@ internal sealed class TerritoryData _territoriesWithMount = dataManager.GetExcelSheet()! .Where(x => x.RowId > 0 && x.Mount) - .Select(x => x.RowId) + .Select(x => (ushort)x.RowId) + .ToImmutableHashSet(); + + _dutyTerritories = dataManager.GetExcelSheet()! + .Where(x => x.RowId > 0 && x.ContentFinderCondition.Row != 0) + .Select(x => (ushort)x.RowId) .ToImmutableHashSet(); } @@ -43,4 +49,6 @@ internal sealed class TerritoryData } public bool CanUseMount(ushort territoryId) => _territoriesWithMount.Contains(territoryId); + + public bool IsDutyInstance(ushort territoryId) => _dutyTerritories.Contains(territoryId); } diff --git a/Questionable/Windows/ConfigWindow.cs b/Questionable/Windows/ConfigWindow.cs index 48ef339f..a24b6734 100644 --- a/Questionable/Windows/ConfigWindow.cs +++ b/Questionable/Windows/ConfigWindow.cs @@ -69,6 +69,13 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig Save(); } + bool hideInAllInstances = _configuration.General.HideInAllInstances; + if (ImGui.Checkbox("Hide quest window in all instanced duties", ref hideInAllInstances)) + { + _configuration.General.HideInAllInstances = hideInAllInstances; + Save(); + } + ImGui.EndTabItem(); } diff --git a/Questionable/Windows/QuestWindow.cs b/Questionable/Windows/QuestWindow.cs index aef55d0b..17f40084 100644 --- a/Questionable/Windows/QuestWindow.cs +++ b/Questionable/Windows/QuestWindow.cs @@ -95,6 +95,9 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig if (!_clientState.IsLoggedIn || _clientState.LocalPlayer == null) return false; + if (_configuration.General.HideInAllInstances && _territoryData.IsDutyInstance(_clientState.TerritoryType)) + return false; + var currentQuest = _questController.CurrentQuest; return currentQuest == null || !currentQuest.Quest.Data.TerritoryBlacklist.Contains(_clientState.TerritoryType); }