Hide quest window in all instanced duties by default

This commit is contained in:
Liza 2024-07-10 18:54:04 +02:00
parent 917ae4f4b8
commit c50008d9e6
Signed by: liza
GPG Key ID: 7199F8D727D55F67
4 changed files with 21 additions and 2 deletions

View File

@ -17,6 +17,7 @@ internal sealed class Configuration : IPluginConfiguration
public bool AutoAcceptNextQuest { get; set; } public bool AutoAcceptNextQuest { get; set; }
public uint MountId { get; set; } = 71; public uint MountId { get; set; } = 71;
public GrandCompany GrandCompany { get; set; } = GrandCompany.None; public GrandCompany GrandCompany { get; set; } = GrandCompany.None;
public bool HideInAllInstances { get; set; } = true;
} }
internal sealed class AdvancedConfiguration internal sealed class AdvancedConfiguration

View File

@ -10,7 +10,8 @@ namespace Questionable.Data;
internal sealed class TerritoryData internal sealed class TerritoryData
{ {
private readonly ImmutableDictionary<uint, string> _territoryNames; private readonly ImmutableDictionary<uint, string> _territoryNames;
private readonly ImmutableHashSet<uint> _territoriesWithMount; private readonly ImmutableHashSet<ushort> _territoriesWithMount;
private readonly ImmutableHashSet<ushort> _dutyTerritories;
public TerritoryData(IDataManager dataManager) public TerritoryData(IDataManager dataManager)
{ {
@ -27,7 +28,12 @@ internal sealed class TerritoryData
_territoriesWithMount = dataManager.GetExcelSheet<TerritoryType>()! _territoriesWithMount = dataManager.GetExcelSheet<TerritoryType>()!
.Where(x => x.RowId > 0 && x.Mount) .Where(x => x.RowId > 0 && x.Mount)
.Select(x => x.RowId) .Select(x => (ushort)x.RowId)
.ToImmutableHashSet();
_dutyTerritories = dataManager.GetExcelSheet<TerritoryType>()!
.Where(x => x.RowId > 0 && x.ContentFinderCondition.Row != 0)
.Select(x => (ushort)x.RowId)
.ToImmutableHashSet(); .ToImmutableHashSet();
} }
@ -43,4 +49,6 @@ internal sealed class TerritoryData
} }
public bool CanUseMount(ushort territoryId) => _territoriesWithMount.Contains(territoryId); public bool CanUseMount(ushort territoryId) => _territoriesWithMount.Contains(territoryId);
public bool IsDutyInstance(ushort territoryId) => _dutyTerritories.Contains(territoryId);
} }

View File

@ -69,6 +69,13 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
Save(); 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(); ImGui.EndTabItem();
} }

View File

@ -95,6 +95,9 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig
if (!_clientState.IsLoggedIn || _clientState.LocalPlayer == null) if (!_clientState.IsLoggedIn || _clientState.LocalPlayer == null)
return false; return false;
if (_configuration.General.HideInAllInstances && _territoryData.IsDutyInstance(_clientState.TerritoryType))
return false;
var currentQuest = _questController.CurrentQuest; var currentQuest = _questController.CurrentQuest;
return currentQuest == null || !currentQuest.Quest.Data.TerritoryBlacklist.Contains(_clientState.TerritoryType); return currentQuest == null || !currentQuest.Quest.Data.TerritoryBlacklist.Contains(_clientState.TerritoryType);
} }