Add config to enable/disable recommendations when entering GC area
This commit is contained in:
parent
21e3f7c0a9
commit
6dd5148599
@ -8,6 +8,7 @@ internal sealed class Configuration : IPluginConfiguration
|
||||
{
|
||||
public int Version { get; set; } = 1;
|
||||
|
||||
public bool ShowRecommendationsWhenEnteringGcArea { get; set; } = true;
|
||||
public List<EBaseParam> StatPriorityTanks { get; set; } = new();
|
||||
public List<EBaseParam> StatPriorityHealer { get; set; } = new();
|
||||
public List<EBaseParam> StatPriorityMelee { get; set; } = new();
|
||||
|
@ -16,6 +16,7 @@ using Gearsetter.GameData;
|
||||
using Gearsetter.Model;
|
||||
using Gearsetter.Windows;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using GrandCompany = FFXIVClientStructs.FFXIV.Client.UI.Agent.GrandCompany;
|
||||
|
||||
namespace Gearsetter;
|
||||
|
||||
@ -32,6 +33,7 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
private readonly Configuration _configuration;
|
||||
private readonly GameDataHolder _gameDataHolder;
|
||||
private readonly EquipmentBrowserWindow _equipmentBrowserWindow;
|
||||
private readonly ConfigWindow _configWindow;
|
||||
|
||||
private readonly IReadOnlyDictionary<byte, DalamudLinkPayload> _linkPayloads;
|
||||
private readonly Dictionary<EClassJob, byte> _classJobToArrayIndex;
|
||||
@ -59,6 +61,8 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
_gameDataHolder = new GameDataHolder(dataManager, _configuration);
|
||||
_equipmentBrowserWindow = new EquipmentBrowserWindow(this, _gameDataHolder, _clientState, _chatGui);
|
||||
_windowSystem.AddWindow(_equipmentBrowserWindow);
|
||||
_configWindow = new ConfigWindow(_pluginInterface, _configuration);
|
||||
_windowSystem.AddWindow(_configWindow);
|
||||
|
||||
_commandManager.AddHandler("/gup", new CommandInfo(ShowUpgrades)
|
||||
{
|
||||
@ -72,16 +76,32 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
.ToDictionary(x => (byte)x, x => _pluginInterface.AddChatLinkHandler((byte)x, ChangeGearset)).AsReadOnly();
|
||||
_clientState.TerritoryChanged += TerritoryChanged;
|
||||
_pluginInterface.UiBuilder.Draw += _windowSystem.Draw;
|
||||
_pluginInterface.UiBuilder.OpenMainUi += _equipmentBrowserWindow.Toggle;
|
||||
_pluginInterface.UiBuilder.OpenConfigUi += _configWindow.Toggle;
|
||||
|
||||
_classJobToArrayIndex = dataManager.GetExcelSheet<ClassJob>()!
|
||||
.Where(x => x.RowId > 0 && Enum.IsDefined(typeof(EClassJob), x.RowId))
|
||||
.ToDictionary(x => (EClassJob)x.RowId, x => (byte)x.ExpArrayIndex);
|
||||
}
|
||||
|
||||
private void TerritoryChanged(ushort territory)
|
||||
private unsafe void TerritoryChanged(ushort territory)
|
||||
{
|
||||
if (territory == 128)
|
||||
ShowUpgrades();
|
||||
try
|
||||
{
|
||||
var playerState = PlayerState.Instance();
|
||||
if (playerState == null)
|
||||
return;
|
||||
|
||||
var grandCompany = (GrandCompany)playerState->GrandCompany;
|
||||
if ((grandCompany == GrandCompany.Maelstrom && territory == 128) ||
|
||||
(grandCompany == GrandCompany.TwinAdder && territory == 132) ||
|
||||
(grandCompany == GrandCompany.ImmortalFlames && territory == 130))
|
||||
ShowUpgrades();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_pluginLog.Warning(e, "Could not show upgrades when entering Grand Company area.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -312,6 +332,8 @@ public sealed class GearsetterPlugin : IDalamudPlugin
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_pluginInterface.UiBuilder.OpenConfigUi -= _configWindow.Toggle;
|
||||
_pluginInterface.UiBuilder.OpenMainUi -= _equipmentBrowserWindow.Toggle;
|
||||
_pluginInterface.UiBuilder.Draw -= _windowSystem.Draw;
|
||||
_clientState.TerritoryChanged -= TerritoryChanged;
|
||||
_pluginInterface.RemoveChatLinkHandler();
|
||||
|
@ -20,9 +20,18 @@ internal sealed record EquipmentItem(Item Item, bool Hq)
|
||||
|
||||
public int PrimaryStat { get; init; } = -1;
|
||||
|
||||
public int Damage => ClassJob.DealsMagicDamage()
|
||||
? Item.DamageMag + Stats.Get(EBaseParam.DamageMag)
|
||||
: Item.DamagePhys + Stats.Get(EBaseParam.DamagePhys);
|
||||
public int Damage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ClassJob.DealsMagicDamage())
|
||||
return Item.DamageMag + Stats.Get(EBaseParam.DamageMag);
|
||||
else if (ClassJob.DealsPhysicalDamage())
|
||||
return Item.DamagePhys + Stats.Get(EBaseParam.DamagePhys);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasAnyStat(params EBaseParam[] substats)
|
||||
{
|
||||
|
29
Gearsetter/Windows/ConfigWindow.cs
Normal file
29
Gearsetter/Windows/ConfigWindow.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Plugin;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Gearsetter.Windows;
|
||||
|
||||
internal sealed class ConfigWindow : Window
|
||||
{
|
||||
private readonly DalamudPluginInterface _pluginInterface;
|
||||
private readonly Configuration _configuration;
|
||||
|
||||
public ConfigWindow(DalamudPluginInterface pluginInterface, Configuration configuration)
|
||||
: base("Gearsetter - Config###GearsetterConfig", ImGuiWindowFlags.AlwaysAutoResize)
|
||||
{
|
||||
_pluginInterface = pluginInterface;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
bool showRecommendationsWhenEnteringGcArea = _configuration.ShowRecommendationsWhenEnteringGcArea;
|
||||
if (ImGui.Checkbox("Show recommendations when entering Grand Company area",
|
||||
ref showRecommendationsWhenEnteringGcArea))
|
||||
{
|
||||
_configuration.ShowRecommendationsWhenEnteringGcArea = showRecommendationsWhenEnteringGcArea;
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user