diff --git a/RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs b/RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs index dfa83b89a..49d5fe3c8 100644 --- a/RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs +++ b/RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs @@ -94,16 +94,16 @@ public partial class BaseAction : IBaseAction /// public bool IsEnabled { - get => !Service.Config.DisabledActions.Contains(ID); + get => !Service.Config.GlobalConfig.DisabledActions.Contains(ID); set { if (value) { - Service.Config.DisabledActions.Remove(ID); + Service.Config.GlobalConfig.DisabledActions.Remove(ID); } else { - Service.Config.DisabledActions.Add(ID); + Service.Config.GlobalConfig.DisabledActions.Add(ID); } } } @@ -113,16 +113,16 @@ public bool IsEnabled /// public bool IsInCooldown { - get => !Service.Config.NotInCoolDownActions.Contains(ID); + get => !Service.Config.GlobalConfig.NotInCoolDownActions.Contains(ID); set { if (value) { - Service.Config.NotInCoolDownActions.Remove(ID); + Service.Config.GlobalConfig.NotInCoolDownActions.Remove(ID); } else { - Service.Config.NotInCoolDownActions.Add(ID); + Service.Config.GlobalConfig.NotInCoolDownActions.Add(ID); } } } diff --git a/RotationSolver.Basic/Actions/BaseAction_Target.cs b/RotationSolver.Basic/Actions/BaseAction_Target.cs index 6595b1e81..a9c0576f2 100644 --- a/RotationSolver.Basic/Actions/BaseAction_Target.cs +++ b/RotationSolver.Basic/Actions/BaseAction_Target.cs @@ -6,6 +6,7 @@ using ECommons.GameHelpers; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Common.Component.BGCollision; +using RotationSolver.Basic.Configuration; namespace RotationSolver.Basic.Actions; @@ -154,7 +155,7 @@ private bool TargetAreaHostile(int aoeCount) private bool TargetAreaMove(float range, bool mustUse) { - if (Service.Config.MoveAreaActionFarthest) + if (Service.Config.GetValue(PluginConfigBool.MoveAreaActionFarthest)) { Vector3 pPosition = Player.Object.Position; float rotation = Player.Object.Rotation; @@ -174,9 +175,9 @@ private bool TargetAreaMove(float range, bool mustUse) private bool TargetAreaFriend(float range, bool mustUse, PlayerCharacter player) { - if (!Service.Config.GetValue(SettingsCommand.UseGroundBeneficialAbility)) return false; + if (!Service.Config.GetValue(PluginConfigBool.UseGroundBeneficialAbility)) return false; - if (Service.Config.BeneficialAreaOnTarget && Svc.Targets.Target != null) + if (Service.Config.GetValue(PluginConfigBool.BeneficialAreaOnTarget) && Svc.Targets.Target != null) { Position = Svc.Targets.Target.Position; } @@ -236,7 +237,7 @@ private bool TargetParty(float range, int aoeCount, bool mustUse, out BattleChar var availableCharas = DataCenter.PartyMembers.Where(player => player.CurrentHp != 0); - if (Service.Config.GetValue(SettingsCommand.TargetAllForFriendly) ? _action.CanTargetFriendly : (ActionID)ID == ActionID.AethericMimicry) + if (Service.Config.GetValue(PluginConfigBool.TargetAllForFriendly) ? _action.CanTargetFriendly : (ActionID)ID == ActionID.AethericMimicry) { availableCharas = availableCharas.Union(DataCenter.AllianceMembers); } @@ -256,7 +257,7 @@ private bool TargetParty(float range, int aoeCount, bool mustUse, out BattleChar } else { - if(Service.Config.OnlyHotOnTanks && IsEot) + if (Service.Config.GetValue(PluginConfigBool.OnlyHotOnTanks) && IsEot) { availableCharas = availableCharas.Where(b => b.IsJobCategory(JobRole.Tank)); } @@ -297,10 +298,10 @@ private bool TargetHostile(float range, bool mustUse, int aoeCount, out BattleCh return false; } - if (Service.Config.ChooseAttackMark) + if (Service.Config.GetValue(PluginConfigBool.ChooseAttackMark)) { var b = MarkingHelper.GetAttackMarkChara(DataCenter.HostileTargets); - if (b != null && ChoiceTarget(GetMostObjects(TargetFilterFuncEot(new BattleChara[] { b }, mustUse), Service.Config.CanAttackMarkAOE ? aoeCount : int.MaxValue), mustUse) != null) + if (b != null && ChoiceTarget(GetMostObjects(TargetFilterFuncEot(new BattleChara[] { b }, mustUse), Service.Config.GetValue(PluginConfigBool.CanAttackMarkAOE) ? aoeCount : int.MaxValue), mustUse) != null) { target = b; return true; @@ -332,8 +333,8 @@ private bool TargetHostileManual(BattleChara b, bool mustUse, int aoeCount, out return true; } - if (Service.Config.GetValue(SettingsCommand.UseAOEAction) - && Service.Config.GetValue(SettingsCommand.UseAOEWhenManual) || mustUse) + if (Service.Config.GetValue(PluginConfigBool.UseAOEAction) + && Service.Config.GetValue(PluginConfigBool.UseAOEWhenManual) || mustUse) { if (GetMostObjects(TargetFilterFuncEot(DataCenter.HostileTargets, mustUse), aoeCount).Contains(b)) { @@ -361,13 +362,13 @@ private bool TargetSelf(bool mustUse, int aoeCount) //not use when aoe. if (DataCenter.IsManual) { - if (!Service.Config.GetValue(SettingsCommand.UseAOEWhenManual) && !mustUse) return false; + if (!Service.Config.GetValue(PluginConfigBool.UseAOEWhenManual) && !mustUse) return false; } var tars = TargetFilter.GetObjectInRadius(TargetFilterFuncEot(DataCenter.HostileTargets, mustUse), EffectRange); if (tars.Count() < aoeCount) return false; - if (Service.Config.NoNewHostiles && TargetFilter.GetObjectInRadius(DataCenter.AllHostileTargets, EffectRange) + if (Service.Config.GetValue(PluginConfigBool.NoNewHostiles) && TargetFilter.GetObjectInRadius(DataCenter.AllHostileTargets, EffectRange) .Any(t => t.TargetObject == null)) return false; } @@ -418,7 +419,7 @@ private int CanGetTargetCount(BattleChara target, IEnumerable canAt count++; } } - if (Service.Config.NoNewHostiles) + if (Service.Config.GetValue(PluginConfigBool.NoNewHostiles)) { if (DataCenter.AllHostileTargets.Where(t => t.TargetObject == null) .Any(t => CanGetTarget(target, t))) return 0; @@ -506,7 +507,7 @@ bool CheckStatus(BattleChara tar) if (TargetStatus == null) return true; - return tar.WillStatusEndGCD(GetDotGcdCount?.Invoke() ?? (uint)Service.Config.AddDotGCDCount, + return tar.WillStatusEndGCD(GetDotGcdCount?.Invoke() ?? (uint)Service.Config.GetValue(DataCenter.Job, JobConfigInt.AddDotGCDCount), 0, true, TargetStatus); } @@ -537,10 +538,10 @@ private static bool NoAOE { get { - if (!Service.Config.GetValue(SettingsCommand.UseAOEAction)) return true; + if (!Service.Config.GetValue(PluginConfigBool.UseAOEAction)) return true; - return Service.Config.ChooseAttackMark - && !Service.Config.CanAttackMarkAOE + return Service.Config.GetValue(PluginConfigBool.ChooseAttackMark) + && !Service.Config.GetValue(PluginConfigBool.CanAttackMarkAOE) && MarkingHelper.HaveAttackChara(DataCenter.HostileTargets); } } diff --git a/RotationSolver.Basic/Actions/BaseItem.cs b/RotationSolver.Basic/Actions/BaseItem.cs index 72393edfd..d2b59e09a 100644 --- a/RotationSolver.Basic/Actions/BaseItem.cs +++ b/RotationSolver.Basic/Actions/BaseItem.cs @@ -44,16 +44,16 @@ public class BaseItem : IBaseItem /// public bool IsEnabled { - get => !Service.Config.DisabledItems.Contains(ID); + get => !Service.Config.GlobalConfig.DisabledItems.Contains(ID); set { if (value) { - Service.Config.DisabledItems.Remove(ID); + Service.Config.GlobalConfig.DisabledItems.Remove(ID); } else { - Service.Config.DisabledItems.Add(ID); + Service.Config.GlobalConfig.DisabledItems.Add(ID); } } } @@ -63,16 +63,16 @@ public bool IsEnabled /// public bool IsInCooldown { - get => !Service.Config.NotInCoolDownItems.Contains(ID); + get => !Service.Config.GlobalConfig.NotInCoolDownItems.Contains(ID); set { if (value) { - Service.Config.NotInCoolDownItems.Remove(ID); + Service.Config.GlobalConfig.NotInCoolDownItems.Remove(ID); } else { - Service.Config.NotInCoolDownItems.Add(ID); + Service.Config.GlobalConfig.NotInCoolDownItems.Add(ID); } } } diff --git a/RotationSolver.Basic/Actions/HealPotionItem.cs b/RotationSolver.Basic/Actions/HealPotionItem.cs index 58670e57c..7965083fa 100644 --- a/RotationSolver.Basic/Actions/HealPotionItem.cs +++ b/RotationSolver.Basic/Actions/HealPotionItem.cs @@ -18,7 +18,7 @@ public uint MaxHealHp } } - protected override bool CanUseThis => Service.Config.UseHealPotions; + protected override bool CanUseThis => Service.Config.GetValue(Configuration.PluginConfigBool.UseHealPotions); public HealPotionItem(Item item, uint a4 = 65535) : base(item, a4) { diff --git a/RotationSolver.Basic/Actions/MedicineItem.cs b/RotationSolver.Basic/Actions/MedicineItem.cs index 84a317f60..922b73eeb 100644 --- a/RotationSolver.Basic/Actions/MedicineItem.cs +++ b/RotationSolver.Basic/Actions/MedicineItem.cs @@ -30,7 +30,7 @@ internal class MedicineItem : BaseItem { private readonly MedicineType _type; - protected override bool CanUseThis => Service.Config.UseTinctures; + protected override bool CanUseThis => Service.Config.GetValue(Configuration.PluginConfigBool.UseTinctures); public MedicineItem(uint row, MedicineType type, uint a4 = 65535) : base(row, a4) { diff --git a/RotationSolver.Basic/Configuration/Configs.cs b/RotationSolver.Basic/Configuration/Configs.cs index 9a6d46f1f..e48582c25 100644 --- a/RotationSolver.Basic/Configuration/Configs.cs +++ b/RotationSolver.Basic/Configuration/Configs.cs @@ -190,6 +190,7 @@ public enum PluginConfigInt : byte [Default(0)] ActionSequencerIndex, [Default(0)] PoslockModifier, [Default(0, 0, 10000)] LessMPNoRaise, + [Default(2, 0, 5)] KeyBoardNoiseMin, [Default(3)] KeyBoardNoiseMax, @@ -299,6 +300,8 @@ public enum PluginConfigBool : byte [Default(false)] TargetAllForFriendly, [Default(false)] ShowCooldownWindow, + [Default(true)] RecordCastingArea, + [Default(true)] AutoOpenChest, [Default(true)] AutoCloseChestWindow, } diff --git a/RotationSolver.Basic/Configuration/PluginConfiguration.cs b/RotationSolver.Basic/Configuration/PluginConfiguration.cs deleted file mode 100644 index c47c32628..000000000 --- a/RotationSolver.Basic/Configuration/PluginConfiguration.cs +++ /dev/null @@ -1,235 +0,0 @@ -using Dalamud.Configuration; -using ECommons.DalamudServices; -using ECommons.ExcelServices; - -namespace RotationSolver.Basic.Configuration; -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -[Serializable] -public class PluginConfiguration : IPluginConfiguration -{ - public int Version { get; set; } = 6; - - public SortedSet DisabledCombos { get; private set; } = new SortedSet(); - public SortedSet DisabledActions { get; private set; } = new SortedSet(); - public SortedSet NotInCoolDownActions { get; private set; } = new SortedSet(); - public SortedSet DisabledItems { get; private set; } = new SortedSet(); - public SortedSet NotInCoolDownItems { get; private set; } = new SortedSet(); - - public List Events { get; private set; } = new List(); - public Dictionary>> RotationsConfigurations { get; private set; } - = new Dictionary>>(); - public Dictionary RotationChoices { get; private set; } = new Dictionary(); - public Dictionary TargetToHostileTypes { get; set; } = - new Dictionary(); - - [JsonProperty] - private Dictionary SettingsBools { get; set; } = new Dictionary(); - public bool GetValue(SettingsCommand command) => SettingsBools.TryGetValue(command, out var value) ? value : command.GetDefault(); - public void SetValue(SettingsCommand command, bool value) => SettingsBools[command] = value; - - public int AddDotGCDCount = 2; - - public int ActionSequencerIndex = 0; - - public bool AutoOffBetweenArea = true; - public bool AutoOffCutScene = true; - public float AutoOffAfterCombat = 8; - public bool AutoOffWhenDead = true; - public bool PreventActionsIfOutOfCombat = false; - public bool PreventActionsIfDutyRing = false; - public bool ChangeTargetForFate = true; - public bool MoveTowardsScreenCenter = true; - - public bool SayOutStateChanged = true; - - public bool ShowInfoOnDtr = true; - - public bool HealOutOfCombat = false; - public bool ShowInfoOnToast = true; - public bool RaiseAll = false; - public bool PoslockCasting = false; - public int PoslockModifier = 0; - public bool PosPassageOfArms = false; - public bool PosTenChiJin = true; - public bool PosFlameThrower = false; - public bool PosImprovisation = false; - - public bool RaisePlayerByCasting = true; - public bool RaiseBrinkOfDeath = true; - public int LessMPNoRaise = 0; - public bool AddEnemyListToHostile = true; - public bool UseTinctures = false; - public bool UseHealPotions = false; - public bool DrawMeleeOffset = true; - public bool ShowMoveTarget = true; - public bool ShowHealthRatio = false; - public bool ShowTarget = true; - public bool ChooseAttackMark = true; - public bool CanAttackMarkAOE = true; - public bool FilterStopMark = true; - public bool TeachingMode = true; - public Vector4 TeachingModeColor = new(0f, 1f, 0.8f, 1f); - public Vector4 MovingTargetColor = new(0f, 1f, 0.8f, 0.6f); - public Vector4 TargetColor = new(1f, 0.2f, 0f, 0.8f); - public Vector4 SubTargetColor = new(1f, 0.9f, 0f, 0.8f); - public bool UseOverlayWindow = true; - - public float DrawingHeight = 3; - public float SampleLength = 0.2f; - - public bool KeyBoardNoise = true; - public int KeyBoardNoiseMin = 2; - public int KeyBoardNoiseMax = 3; - public float KeyBoardNoiseTimeMin = 0.1f; - public float KeyBoardNoiseTimeMax = 0.2f; - public bool MoveAreaActionFarthest = true; - public bool StartOnCountdown = true; - public bool StartOnAttackedBySomeone = false; - public bool NoNewHostiles = false; - public bool UseHealWhenNotAHealer = true; - public float HealthDifference = 0.25f; - public float MeleeRangeOffset = 1; - public bool TargetFriendly = false; - public float MinLastAbilityAdvanced = 0.1f; - - public float HealWhenNothingTodoBelow = 0.8f; - public float TargetIconSize = 0.6f; - - public float MistakeRatio = 0; - public Dictionary HealthAreaAbilitiesHot { get; set; } = new Dictionary(); - public float HealthAreaAbilityHot = 0.55f; - - public Dictionary HealthAreaSpellsHot { get; set; } = new Dictionary(); - public float HealthAreaSpellHot = 0.55f; - - public Dictionary HealthAreaAbilities { get; set; } = new Dictionary(); - public float HealthAreaAbility = 0.75f; - - public Dictionary HealthAreaSpells { get; set; } = new Dictionary(); - public float HealthAreaSpell = 0.65f; - - public Dictionary HealthSingleAbilitiesHot { get; set; } = new Dictionary(); - public float HealthSingleAbilityHot = 0.6f; - - public Dictionary HealthSingleSpellsHot { get; set; } = new Dictionary(); - public float HealthSingleSpellHot = 0.45f; - - public Dictionary HealthSingleAbilities { get; set; } = new Dictionary(); - public float HealthSingleAbility = 0.7f; - - public Dictionary HealthSingleSpells { get; set; } = new Dictionary(); - public float HealthSingleSpell = 0.55f; - - public Dictionary HealthForDyingTanks { get; set; } = new Dictionary(); - - public float HealthTankRatio = 0.4f; - public float HealthHealerRatio = 0.4f; - - public bool InterruptibleMoreCheck = true; - public float SpecialDuration = 3; - - public float ActionAhead = 0.08f; - public float ActionAheadForLast0GCD = 0.06f; - - public float WeaponDelayMin = 0; - public float WeaponDelayMax = 0; - - public float DeathDelayMin = 1; - public float DeathDelayMax = 1.5f; - - public float WeakenDelayMin = 0.5f; - public float WeakenDelayMax = 1; - - public float HostileDelayMin = 0; - public float HostileDelayMax = 0; - - public float HealDelayMin = 0; - public float HealDelayMax = 0; - - public float StopCastingDelayMin = 0.5f; - public float StopCastingDelayMax = 1; - - public float InterruptDelayMin = 0.5f; - public float InterruptDelayMax = 1; - - public float NotInCombatDelayMin = 3; - public float NotInCombatDelayMax = 4; - - public float ClickingDelayMin = 0.1f; - public float ClickingDelayMax = 0.15f; - - public float CountdownDelayMin = 0.5f; - public float CountdownDelayMax = 1; - - public bool UseWorkTask = true; - - public bool UseStopCasting = false; - public bool EsunaAll = false; - public bool OnlyAttackInView = false; - public bool OnlyHotOnTanks = false; - public bool BeneficialAreaOnTarget = false; - - public float CountDownAhead = 0.6f; - - public int MoveTargetAngle = 24; - public float HealthRatioBoss = 1.85f; - public float HealthRatioDying = 0.8f; - public float HealthRatioDot = 1.2f; - - public bool InDebug = false; - public bool AutoUpdateLibs = true; - public string[] OtherLibs = Array.Empty(); - - public bool RecordCastingArea = true; - - public List TargetingTypes { get; set; } = new List(); - public int TargetingIndex { get; set; } = 0; - public MacroInfo DutyStart { get; set; } = new MacroInfo(); - public MacroInfo DutyEnd { get; set; } = new MacroInfo(); - - public bool DownloadRotations = true; - public bool AutoUpdateRotations = true; - - public bool ToggleManual = false; - public bool OnlyShowWithHostileOrInDuty = true; - public bool ShowControlWindow = false; - public bool IsControlWindowLock = false; - public bool ShowNextActionWindow = true; - public bool IsInfoWindowNoInputs = false; - public bool IsInfoWindowNoMove = false; - public bool ShowItemsCooldown = false; - public bool ShowGCDCooldown = false; - public bool UseOriginalCooldown = true; - public int CooldownActionOneLine = 15; - public float CooldownFontSize = 16; - - public Vector4 ControlWindowLockBg = new(0, 0, 0, 0.6f); - public Vector4 ControlWindowUnlockBg = new(0, 0, 0, 0.9f); - public Vector4 InfoWindowBg = new(0, 0, 0, 0.4f); - - public float ControlWindowGCDSize = 40; - public float ControlWindow0GCDSize = 30; - public float CooldownWindowIconSize = 30; - public float ControlWindowNextSizeRatio = 1.5f; - public float ControlProgressHeight = 8; - public bool ShowCooldownWindow = false; - public float DistanceForMoving = 1.2f; - public float MaxPing = 0.3f; - - public bool ShowTooltips = true; - - public bool AutoLoadCustomRotations = false; - - public bool TargetFatePriority = true; - public bool TargetHuntingRelicLevePriority = true; - public bool TargetQuestPriority = true; - - public bool ShowToastsAboutDoAction = true; - - public void Save() - { - Svc.PluginInterface.SavePluginConfig(this); - } -} -#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member diff --git a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigBase.cs b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigBase.cs index 98ce71479..1499a0e17 100644 --- a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigBase.cs +++ b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigBase.cs @@ -17,7 +17,7 @@ public RotationConfigBase(string name, string value, string displayName) public string GetValue(Job job, string rotationName) { - if (!Service.Config.RotationsConfigurations.TryGetValue((uint)job, out var jobDict)) return DefaultValue; + var jobDict = Service.Config.GetJobConfig(job).RotationsConfigurations; if (!jobDict.TryGetValue(rotationName, out var configDict)) return DefaultValue; if (!configDict.TryGetValue(Name, out var config)) return DefaultValue; return config; @@ -27,10 +27,7 @@ public string GetValue(Job job, string rotationName) public void SetValue(Job job, string rotationName, string value) { - if (!Service.Config.RotationsConfigurations.TryGetValue((uint)job, out var jobDict)) - { - jobDict = Service.Config.RotationsConfigurations[(uint)job] = new Dictionary>(); - } + var jobDict = Service.Config.GetJobConfig(job).RotationsConfigurations; if (!jobDict.TryGetValue(rotationName, out var configDict)) { diff --git a/RotationSolver.Basic/Data/Countdown.cs b/RotationSolver.Basic/Data/Countdown.cs index 6a0cf613c..35c238ebf 100644 --- a/RotationSolver.Basic/Data/Countdown.cs +++ b/RotationSolver.Basic/Data/Countdown.cs @@ -30,7 +30,9 @@ public unsafe struct Countdown /// public static unsafe Countdown* Instance => (Countdown*)Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.CountDownSettingDialog); - static RandomDelay _delay = new RandomDelay(()=>(Service.Config.CountdownDelayMin, Service.Config.CountdownDelayMax)); + static RandomDelay _delay = new RandomDelay( + ()=>(Service.Config.GetValue(Configuration.PluginConfigFloat.CountdownDelayMin), + Service.Config.GetValue(Configuration.PluginConfigFloat.CountdownDelayMax))); /// /// TimeRemaining. diff --git a/RotationSolver.Basic/DataCenter.cs b/RotationSolver.Basic/DataCenter.cs index a9e90ed7e..e744296f1 100644 --- a/RotationSolver.Basic/DataCenter.cs +++ b/RotationSolver.Basic/DataCenter.cs @@ -15,9 +15,9 @@ namespace RotationSolver.Basic; internal static class DataCenter { internal static bool NoPoslock => Svc.Condition[ConditionFlag.OccupiedInEvent] - || !Service.Config.PoslockCasting + || !Service.Config.GetValue(Configuration.PluginConfigBool.PoslockCasting) //Key cancel. - || Svc.KeyState[ConfigurationHelper.Keys[Service.Config.PoslockModifier]] + || Svc.KeyState[ConfigurationHelper.Keys[Service.Config.GetValue(Configuration.PluginConfigInt.PoslockModifier)]] //Gamepad cancel. || Svc.GamepadState.Raw(Dalamud.Game.ClientState.GamePad.GamepadButtons.L2) >= 0.5f; @@ -72,6 +72,7 @@ public static IAction CommandNextAction return next?.Act; } } + public static Job Job { get; set; } internal static void AddCommandAction(IAction act, double time) { @@ -89,24 +90,7 @@ internal static void AddCommandAction(IAction act, double time) } public static TargetHostileType RightNowTargetToHostileType - { - get - { - if (!Player.Available) return 0; - var id = Player.Object.ClassJob.Id; - return GetTargetHostileType(Service.GetSheet().GetRow(id)); - } - } - - public static TargetHostileType GetTargetHostileType(ClassJob classJob) - { - if (Service.Config.TargetToHostileTypes.TryGetValue(classJob.RowId, out var type)) - { - return (TargetHostileType)type; - } - - return classJob.GetJobRole() == JobRole.Tank ? TargetHostileType.AllTargetsCanAttack : TargetHostileType.TargetsHaveTarget; - } + => (TargetHostileType)Service.Config.GetValue(Job, Configuration.JobConfigInt.HostileType); public static unsafe ActionID LastComboAction => (ActionID)ActionManager.Instance()->Combo.Action; public static unsafe float ComboTime => ActionManager.Instance()->Combo.Timer; @@ -114,14 +98,14 @@ public static TargetingType TargetingType { get { - if (Service.Config.TargetingTypes.Count == 0) + if (Service.Config.GlobalConfig.TargetingTypes.Count == 0) { - Service.Config.TargetingTypes.Add(TargetingType.Big); - Service.Config.TargetingTypes.Add(TargetingType.Small); + Service.Config.GlobalConfig.TargetingTypes.Add(TargetingType.Big); + Service.Config.GlobalConfig.TargetingTypes.Add(TargetingType.Small); Service.Config.Save(); } - return Service.Config.TargetingTypes[Service.Config.TargetingIndex %= Service.Config.TargetingTypes.Count]; + return Service.Config.GlobalConfig.TargetingTypes[Service.Config.GetValue(Configuration.PluginConfigInt.TargetingIndex) %Service.Config.GlobalConfig.TargetingTypes.Count]; } } @@ -135,7 +119,7 @@ public static unsafe ushort FateId { try { - if (Service.Config.ChangeTargetForFate && (IntPtr)FateManager.Instance() != IntPtr.Zero + if (Service.Config.GetValue(Configuration.PluginConfigBool.ChangeTargetForFate) && (IntPtr)FateManager.Instance() != IntPtr.Zero && (IntPtr)FateManager.Instance()->CurrentFate != IntPtr.Zero && Player.Level <= FateManager.Instance()->CurrentFate->MaxLevel) { @@ -187,8 +171,8 @@ public static float AbilityRemain static DateTime _specialStateStartTime = DateTime.MinValue; private static double SpecialTimeElapsed => (DateTime.Now - _specialStateStartTime).TotalSeconds; - public static double SpecialTimeLeft => WeaponTotal == 0 || WeaponElapsed == 0 ? Service.Config.SpecialDuration - SpecialTimeElapsed : - Math.Ceiling((Service.Config.SpecialDuration + WeaponElapsed - SpecialTimeElapsed) / WeaponTotal) * WeaponTotal - WeaponElapsed; + public static double SpecialTimeLeft => WeaponTotal == 0 || WeaponElapsed == 0 ? Service.Config.GetValue(Configuration.PluginConfigFloat.SpecialDuration) - SpecialTimeElapsed : + Math.Ceiling((Service.Config.GetValue(Configuration.PluginConfigFloat.SpecialDuration) + WeaponElapsed - SpecialTimeElapsed) / WeaponTotal) * WeaponTotal - WeaponElapsed; static SpecialCommandType _specialType = SpecialCommandType.EndSpecial; public static SpecialCommandType SpecialType => @@ -216,27 +200,32 @@ public static void SetSpecialType(SpecialCommandType specialType) public static IEnumerable AllianceMembers { get; internal set; } = Array.Empty(); public static IEnumerable AllianceTanks { get; internal set; } = Array.Empty(); - + public static ObjectListDelay DeathPeopleAll { get; } = new( - () => (Service.Config.DeathDelayMin, Service.Config.DeathDelayMax)); + () => (Service.Config.GetValue(Configuration.PluginConfigFloat.DeathDelayMin), + Service.Config.GetValue(Configuration.PluginConfigFloat.DeathDelayMax))); public static ObjectListDelay DeathPeopleParty { get; } = new( - () => (Service.Config.DeathDelayMin, Service.Config.DeathDelayMax)); + () => (Service.Config.GetValue(Configuration.PluginConfigFloat.DeathDelayMin), + Service.Config.GetValue(Configuration.PluginConfigFloat.DeathDelayMax))); public static ObjectListDelay WeakenPeople { get; } = new( - () => (Service.Config.WeakenDelayMin, Service.Config.WeakenDelayMax)); + () => (Service.Config.GetValue(Configuration.PluginConfigFloat.WeakenDelayMin), + Service.Config.GetValue(Configuration.PluginConfigFloat.WeakenDelayMax))); public static IEnumerable DyingPeople { get; internal set; } = Array.Empty(); public static ObjectListDelay HostileTargets { get; } = new ObjectListDelay( - () => (Service.Config.HostileDelayMin, Service.Config.HostileDelayMax)); + () => (Service.Config.GetValue(Configuration.PluginConfigFloat.HostileDelayMin), + Service.Config.GetValue(Configuration.PluginConfigFloat.HostileDelayMax))); public static IEnumerable AllHostileTargets { get; internal set; } = Array.Empty(); public static IEnumerable TarOnMeTargets { get; internal set; } = Array.Empty(); public static ObjectListDelay CanInterruptTargets { get; } = new ObjectListDelay( - () => (Service.Config.InterruptDelayMin, Service.Config.InterruptDelayMax)); + () => (Service.Config.GetValue(Configuration.PluginConfigFloat.InterruptDelayMin), + Service.Config.GetValue(Configuration.PluginConfigFloat.InterruptDelayMax))); public static IEnumerable AllTargets { get; set; } @@ -349,7 +338,7 @@ public static float DPSTaken public static ActionID LastGCD { get; private set; } = 0; public static ActionID LastAbility { get; private set; } = 0; - public static float Ping => Math.Min(Math.Min(RTT, FetchTime), Service.Config.MaxPing); + public static float Ping => Math.Min(Math.Min(RTT, FetchTime), Service.Config.GetValue(Configuration.PluginConfigFloat.MaxPing)); public static float RTT { get; internal set; } = 0.1f; public static float FetchTime { get; private set; } = 0.1f; diff --git a/RotationSolver.Basic/Helpers/ConfigurationHelper.cs b/RotationSolver.Basic/Helpers/ConfigurationHelper.cs index 771ed7716..58d6f9e83 100644 --- a/RotationSolver.Basic/Helpers/ConfigurationHelper.cs +++ b/RotationSolver.Basic/Helpers/ConfigurationHelper.cs @@ -34,31 +34,29 @@ internal static class ConfigurationHelper public static readonly VirtualKey[] Keys = new VirtualKey[] { VirtualKey.CONTROL, VirtualKey.SHIFT, VirtualKey.MENU, VirtualKey.LBUTTON, VirtualKey.MBUTTON, VirtualKey.RBUTTON }; public static float GetHealthAreaAbility(this Job job) - => Service.Config.HealthAreaAbilities.TryGetValue(job, out var value) ? value : Service.Config.HealthAreaAbility; + => Service.Config.GetValue(job, Configuration.JobConfigFloat.HealthAreaAbility); public static float GetHealthAreaSpell(this Job job) - => Service.Config.HealthAreaSpells.TryGetValue(job, out var value) ? value : Service.Config.HealthAreaSpell; + => Service.Config.GetValue(job, Configuration.JobConfigFloat.HealthAreaSpell); public static float GetHealthAreaAbilityHot(this Job job) - => Service.Config.HealthAreaAbilitiesHot.TryGetValue(job, out var value) ? value : Service.Config.HealthAreaAbilityHot; + => Service.Config.GetValue(job, Configuration.JobConfigFloat.HealthAreaAbilityHot); public static float GetHealthAreaSpellHot(this Job job) - => Service.Config.HealthAreaSpellsHot.TryGetValue(job, out var value) ? value : Service.Config.HealthAreaSpellHot; + => Service.Config.GetValue(job, Configuration.JobConfigFloat.HealthAreaSpellHot); public static float GetHealthSingleAbility(this Job job) - => Service.Config.HealthSingleAbilities.TryGetValue(job, out var value) ? value : Service.Config.HealthSingleAbility; + => Service.Config.GetValue(job, Configuration.JobConfigFloat.HealthSingleAbility); public static float GetHealthSingleSpell(this Job job) - => Service.Config.HealthSingleSpells.TryGetValue(job, out var value) ? value : Service.Config.HealthSingleSpell; + => Service.Config.GetValue(job, Configuration.JobConfigFloat.HealthSingleSpell); public static float GetHealthSingleAbilityHot(this Job job) - => Service.Config.HealthSingleAbilitiesHot.TryGetValue(job, out var value) ? value : Service.Config.HealthSingleAbilityHot; + => Service.Config.GetValue(job, Configuration.JobConfigFloat.HealthSingleAbilityHot); public static float GetHealthSingleSpellHot(this Job job) - => Service.Config.HealthSingleSpellsHot.TryGetValue(job, out var value) ? value : Service.Config.HealthSingleSpellHot; + => Service.Config.GetValue(job, Configuration.JobConfigFloat.HealthSingleSpellHot); public static float GetHealthForDyingTank(this Job job) - => Service.Config.HealthForDyingTanks.TryGetValue(job, out var value) ? value : HealthForDyingTanksDefault; - - public const float HealthForDyingTanksDefault = 0.15f; + => Service.Config.GetValue(job, Configuration.JobConfigFloat.HealthForDyingTanks); } diff --git a/RotationSolver.Basic/Helpers/ObjectHelper.cs b/RotationSolver.Basic/Helpers/ObjectHelper.cs index 81ab3f384..fcfcfc837 100644 --- a/RotationSolver.Basic/Helpers/ObjectHelper.cs +++ b/RotationSolver.Basic/Helpers/ObjectHelper.cs @@ -80,20 +80,20 @@ internal static bool IsTopPriorityHostile(this GameObject obj) { var fateId = DataCenter.FateId; //Fate - if (Service.Config.TargetFatePriority && fateId != 0 && obj.FateId() == fateId) return true; + if (Service.Config.GetValue(Configuration.PluginConfigBool.TargetFatePriority) && fateId != 0 && obj.FateId() == fateId) return true; var icon = obj.GetNamePlateIcon(); //Hunting log and weapon. - if (Service.Config.TargetHuntingRelicLevePriority && icon + if (Service.Config.GetValue(Configuration.PluginConfigBool.TargetHuntingRelicLevePriority) && icon is 60092 //Hunting or 60096 //Weapon or 71244 //Leve ) return true; - if (Service.Config.TargetQuestPriority && (icon + if (Service.Config.GetValue(Configuration.PluginConfigBool.TargetQuestPriority) && (icon is 71204 //Main Quest or 71144 //Major Quest or 71224 //Other Quest @@ -122,7 +122,7 @@ internal static bool CanInterrupt(this BattleChara b) var baseCheck = b.IsCasting && b.IsCastInterruptible && b.TotalCastTime >= 2; if (!baseCheck) return false; - if (!Service.Config.InterruptibleMoreCheck) return true; + if (!Service.Config.GetValue(Configuration.PluginConfigBool.InterruptibleMoreCheck)) return true; var id = b.CastActionId; if (_effectRangeCheck.TryGetValue(id, out var check)) return check; @@ -149,8 +149,8 @@ internal static bool CanInterrupt(this BattleChara b) public static bool IsBoss(this BattleChara obj) { if (obj == null) return false; - if (obj.IsDummy() && !Service.Config.ShowHealthRatio) return true; - return obj.MaxHp >= GetHealthFromMulty(Service.Config.HealthRatioBoss) + if (obj.IsDummy() && !Service.Config.GetValue(Configuration.PluginConfigBool.ShowHealthRatio)) return true; + return obj.MaxHp >= GetHealthFromMulty(Service.Config.GetValue(Configuration.PluginConfigFloat.HealthRatioBoss)) || !(obj.GetObjectNPC()?.IsTargetLine ?? true); } @@ -162,8 +162,8 @@ public static bool IsBoss(this BattleChara obj) public static bool IsDying(this BattleChara b) { if (b == null) return false; - if (b.IsDummy() && !Service.Config.ShowHealthRatio) return false; - return b.CurrentHp <= GetHealthFromMulty(Service.Config.HealthRatioDying) || b.GetHealthRatio() < 0.02f; + if (b.IsDummy() && !Service.Config.GetValue(Configuration.PluginConfigBool.ShowHealthRatio)) return false; + return b.CurrentHp <= GetHealthFromMulty(Service.Config.GetValue(Configuration.PluginConfigFloat.HealthRatioDying)) || b.GetHealthRatio() < 0.02f; } /// @@ -186,8 +186,8 @@ public static float GetHealthRatio(this BattleChara b) public static bool CanDot(this BattleChara b) { if (b == null) return false; - if (b.IsDummy() && !Service.Config.ShowHealthRatio) return true; - return b.CurrentHp >= GetHealthFromMulty(Service.Config.HealthRatioDot); + if (b.IsDummy() && !Service.Config.GetValue(Configuration.PluginConfigBool.ShowHealthRatio)) return true; + return b.CurrentHp >= GetHealthFromMulty(Service.Config.GetValue(Configuration.PluginConfigFloat.HealthRatioDot)); } internal static EnemyPositional FindEnemyPositional(this GameObject enemy) diff --git a/RotationSolver.Basic/Helpers/TargetFilter.cs b/RotationSolver.Basic/Helpers/TargetFilter.cs index cbfb7de96..33047699e 100644 --- a/RotationSolver.Basic/Helpers/TargetFilter.cs +++ b/RotationSolver.Basic/Helpers/TargetFilter.cs @@ -13,7 +13,7 @@ public static class TargetFilter { #region Find one target internal static IEnumerable MeleeRangeTargetFilter(IEnumerable availableCharas) - => availableCharas.Where(t => t.DistanceToPlayer() >= 3 + Service.Config.MeleeRangeOffset); + => availableCharas.Where(t => t.DistanceToPlayer() >= 3 + Service.Config.GetValue(Configuration.PluginConfigFloat.MeleeRangeOffset)); internal static BattleChara DefaultChooseFriend(IEnumerable availableCharas, bool mustUse) { @@ -25,11 +25,11 @@ internal static BattleChara DefaultChooseFriend(IEnumerable availab var tankTars = availableCharas.GetJobCategory(JobRole.Tank); var healerTar = tankTars.OrderBy(ObjectHelper.GetHealthRatio).FirstOrDefault(); - if (healerTar != null && healerTar.GetHealthRatio() < Service.Config.HealthHealerRatio) + if (healerTar != null && healerTar.GetHealthRatio() < Service.Config.GetValue(Configuration.PluginConfigFloat.HealthHealerRatio)) return healerTar; var tankTar = tankTars.OrderBy(ObjectHelper.GetHealthRatio).FirstOrDefault(); - if (tankTar != null && tankTar.GetHealthRatio() < Service.Config.HealthTankRatio) + if (tankTar != null && tankTar.GetHealthRatio() < Service.Config.GetValue(Configuration.PluginConfigFloat.HealthTankRatio)) return tankTar; var tar = availableCharas.OrderBy(ObjectHelper.GetHealthRatio).FirstOrDefault(); @@ -43,7 +43,7 @@ internal static BattleChara DefaultFindHostile(IEnumerable availabl { if (availableCharas == null || !availableCharas.Any()) return null; - if (Service.Config.FilterStopMark) + if (Service.Config.GetValue(Configuration.PluginConfigBool.FilterStopMark)) { var charas = MarkingHelper.FilterStopCharaes(availableCharas); if (charas?.Any() ?? false) availableCharas = charas; @@ -77,11 +77,11 @@ internal static T FindTargetForMoving(this IEnumerable charas, bool mustUs { var tar = charas.OrderBy(ObjectHelper.DistanceToPlayer).FirstOrDefault(); if (tar == null) return null; - if (tar.DistanceToPlayer() < Service.Config.DistanceForMoving) return tar; + if (tar.DistanceToPlayer() < Service.Config.GetValue(Configuration.PluginConfigFloat.DistanceForMoving) )return tar; return null; } - if (Service.Config.MoveTowardsScreenCenter) + if (Service.Config.GetValue(Configuration.PluginConfigBool.MoveTowardsScreenCenter)) { return FindMoveTargetScreenCenter(charas); } @@ -105,7 +105,7 @@ private static T FindMoveTargetFaceDirection(IEnumerable charas) where T : Vector3 dir = t.Position - pPosition; Vector2 dirVec = new(dir.Z, dir.X); double angle = Math.Acos(Vector2.Dot(dirVec, faceVec) / dirVec.Length() / faceVec.Length()); - return angle <= Math.PI * Service.Config.MoveTargetAngle / 360; + return angle <= Math.PI * Service.Config.GetValue(Configuration.PluginConfigFloat.MoveTargetAngle) / 360; }).OrderByDescending(ObjectHelper.DistanceToPlayer); return tars.FirstOrDefault(); @@ -126,7 +126,7 @@ private static T FindMoveTargetScreenCenter(IEnumerable charas) where T : if (dir.Y > 0) return false; - return Math.Abs(dir.X / dir.Y) < Math.Tan(Math.PI * Service.Config.MoveTargetAngle / 360); + return Math.Abs(dir.X / dir.Y) < Math.Tan(Math.PI * Service.Config.GetValue(Configuration.PluginConfigFloat.MoveTargetAngle) / 360); }).OrderByDescending(ObjectHelper.DistanceToPlayer); return tars.FirstOrDefault(); @@ -251,7 +251,7 @@ public unsafe static IEnumerable GetDeath(this IEnumerable c.CastTargetObjectId == item.ObjectId)) return false; diff --git a/RotationSolver.Basic/Rotations/CustomRotation_Ability.cs b/RotationSolver.Basic/Rotations/CustomRotation_Ability.cs index ae49736b3..4b024fc4f 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_Ability.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_Ability.cs @@ -1,4 +1,6 @@ -namespace RotationSolver.Basic.Rotations; +using RotationSolver.Basic.Configuration; + +namespace RotationSolver.Basic.Rotations; public abstract partial class CustomRotation { @@ -13,7 +15,7 @@ private bool Ability(IAction nextGCD, out IAction act, bool helpDefenseAOE, bool if (act is IBaseItem i && i.CanUse(out _, true)) return true; - if (!Service.Config.GetValue(SettingsCommand.UseAbility) + if (!Service.Config.GetValue(PluginConfigBool.UseAbility) || Player.TotalCastTime > 0) { act = null; @@ -58,7 +60,7 @@ private bool Ability(IAction nextGCD, out IAction act, bool helpDefenseAOE, bool if (GeneralAbility(out act)) return true; //Run! - if (IsMoving && NotInCombatDelay && Service.Config.GetValue(SettingsCommand.AutoSpeedOutOfCombat) + if (IsMoving && NotInCombatDelay && Service.Config.GetValue(PluginConfigBool.AutoSpeedOutOfCombat) && SpeedAbility(out act)) return true; return false; @@ -107,7 +109,7 @@ private bool ShirkOrShield(JobRole role, SpecialCommandType specialType, out IAc break; } - if (DataCenter.SetAutoStatus(AutoStatus.TankStance, Service.Config.GetValue(SettingsCommand.AutoTankStance) + if (DataCenter.SetAutoStatus(AutoStatus.TankStance, Service.Config.GetValue(PluginConfigBool.AutoTankStance) && !DataCenter.AllianceTanks.Any(t => t.CurrentHp != 0 && t.HasStatus(false, StatusHelper.TankStanceStatus)) && !HasTankStance && TankStance.CanUse(out act, CanUseOption.IgnoreClippingCheck))) { @@ -186,7 +188,7 @@ private bool AutoDefense(JobRole role, bool helpDefenseAOE, bool helpDefenseSing //Auto Provoke if (DataCenter.SetAutoStatus(AutoStatus.Provoke, role == JobRole.Tank - && (Service.Config.GetValue(SettingsCommand.AutoProvokeForTank) || DataCenter.AllianceTanks.Count() < 2) + && (Service.Config.GetValue(PluginConfigBool.AutoProvokeForTank) || DataCenter.AllianceTanks.Count() < 2) && TargetFilter.ProvokeTarget(DataCenter.HostileTargets, true).Count() != DataCenter.HostileTargets.Count())) { if (!HasTankStance && TankStance.CanUse(out act)) return true; @@ -195,7 +197,7 @@ private bool AutoDefense(JobRole role, bool helpDefenseAOE, bool helpDefenseSing } //No using defense abilities. - if (!Service.Config.GetValue(SettingsCommand.UseDefenseAbility)) return false; + if (!Service.Config.GetValue(PluginConfigBool.UseDefenseAbility)) return false; if (helpDefenseAOE) { @@ -279,7 +281,7 @@ protected virtual bool EmergencyAbility(IAction nextGCD, out IAction act) if (ClassJob.GetJobRole() is JobRole.Healer or JobRole.RangedMagical && action.CastTime >= 5 && Swiftcast.CanUse(out act, CanUseOption.EmptyOrSkipCombo)) return true; - if (Service.Config.GetValue(SettingsCommand.AutoUseTrueNorth) + if (Service.Config.GetValue(PluginConfigBool.AutoUseTrueNorth) && action.EnemyPositional != EnemyPositional.None && action.Target != null) { if (action.EnemyPositional != action.Target.FindEnemyPositional() && action.Target.HasPositional()) diff --git a/RotationSolver.Basic/Rotations/CustomRotation_Actions.cs b/RotationSolver.Basic/Rotations/CustomRotation_Actions.cs index ef9b5ca84..5f355b2df 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_Actions.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_Actions.cs @@ -79,7 +79,7 @@ internal RoleAction(ActionID actionID, JobRole[] roles, ActionOption option = Ac public static IBaseAction SecondWind { get; } = new RoleAction(ActionID.SecondWind, new JobRole[] { JobRole.RangedPhysical, JobRole.Melee }, ActionOption.Heal) { - ActionCheck = (b, m) => Player?.GetHealthRatio() < Service.Config.HealthSingleAbility && InCombat, + ActionCheck = (b, m) => Player?.GetHealthRatio() < Service.Config.GetValue(DataCenter.Job, Configuration.JobConfigFloat.HealthSingleAbility) && InCombat, }; /// diff --git a/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs b/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs index 13142b552..24168d9e8 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs @@ -23,16 +23,16 @@ public abstract partial class CustomRotation : ICustomRotation public bool IsEnabled { - get => !Service.Config.DisabledCombos.Contains(Name); + get => !Service.Config.GlobalConfig.DisabledCombos.Contains(Name); set { if (value) { - Service.Config.DisabledCombos.Remove(Name); + Service.Config.GlobalConfig.DisabledCombos.Remove(Name); } else { - Service.Config.DisabledCombos.Add(Name); + Service.Config.GlobalConfig.DisabledCombos.Add(Name); } } } diff --git a/RotationSolver.Basic/Rotations/CustomRotation_GCD.cs b/RotationSolver.Basic/Rotations/CustomRotation_GCD.cs index d4b574bb1..bfdd3f0cd 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_GCD.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_GCD.cs @@ -1,4 +1,6 @@ -namespace RotationSolver.Basic.Rotations; +using RotationSolver.Basic.Configuration; + +namespace RotationSolver.Basic.Rotations; public abstract partial class CustomRotation { @@ -20,10 +22,10 @@ private IAction GCD(bool helpDefenseAOE, bool helpDefenseSingle) { if (act is IBaseAction b && ObjectHelper.DistanceToPlayer(b.Target) > 5) return act; } - + //General Heal if ((DataCenter.HPNotFull || ClassJob.GetJobRole() != JobRole.Healer) - && (DataCenter.InCombat || Service.Config.HealOutOfCombat)) + && (DataCenter.InCombat || Service.Config.GetValue(PluginConfigBool.HealOutOfCombat))) { if ((specialType == SpecialCommandType.HealArea || CanHealAreaSpell) && HealAreaGCD(out act)) return act; if ((specialType == SpecialCommandType.HealSingle || CanHealSingleSpell) && HealSingleGCD(out act)) return act; @@ -37,21 +39,20 @@ private IAction GCD(bool helpDefenseAOE, bool helpDefenseSingle) //Esuna if (DataCenter.SetAutoStatus(AutoStatus.Esuna, (specialType == SpecialCommandType.EsunaStanceNorth - || !HasHostilesInRange || Service.Config.EsunaAll) + || !HasHostilesInRange || Service.Config.GetValue(PluginConfigBool.EsunaAll)) && DataCenter.WeakenPeople.Any() || DataCenter.DyingPeople.Any())) { if (ClassJob.GetJobRole() == JobRole.Healer && Esuna.CanUse(out act, CanUseOption.MustUse)) return act; } if (GeneralGCD(out var action)) return action; - - if(DataCenter.PartyMembersMinHP < Service.Config.HealWhenNothingTodoBelow && DataCenter.InCombat) + if (DataCenter.PartyMembersMinHP < Service.Config.GetValue(PluginConfigFloat.HealWhenNothingTodoBelow) && DataCenter.InCombat) { if (DataCenter.PartyMembersDifferHP < DataCenter.PartyMembersDifferHP && HealAreaGCD(out act)) return act; if (HealSingleGCD(out act)) return act; } - - if (Service.Config.RaisePlayerByCasting && RaiseSpell(specialType, out act, true)) return act; + + if (Service.Config.GetValue(PluginConfigBool.RaisePlayerByCasting) && RaiseSpell(specialType, out act, true)) return act; return null; } @@ -64,7 +65,7 @@ private bool RaiseSpell(SpecialCommandType specialType, out IAction act, bool mu if (RaiseAction(out act)) return true; } - if ((Service.Config.RaiseAll ? DataCenter.DeathPeopleAll.Any() : DataCenter.DeathPeopleParty.Any()) + if ((Service.Config.GetValue(PluginConfigBool.RaiseAll) ? DataCenter.DeathPeopleAll.Any() : DataCenter.DeathPeopleParty.Any()) && RaiseAction(out act, CanUseOption.IgnoreCastCheck)) { if (HasSwift) @@ -84,7 +85,7 @@ private bool RaiseSpell(SpecialCommandType specialType, out IAction act, bool mu return DataCenter.SetAutoStatus(AutoStatus.Raise, true); } } - else if (Service.Config.GetValue(SettingsCommand.RaisePlayerBySwift) && !Swiftcast.IsCoolingDown + else if (Service.Config.GetValue(PluginConfigBool.RaisePlayerBySwift) && !Swiftcast.IsCoolingDown && DataCenter.NextAbilityToNextGCD > DataCenter.MinAnimationLock + DataCenter.Ping) { return DataCenter.SetAutoStatus(AutoStatus.Raise, true); @@ -96,7 +97,7 @@ private bool RaiseSpell(SpecialCommandType specialType, out IAction act, bool mu private bool RaiseAction(out IAction act, CanUseOption option = CanUseOption.None) { if (VariantRaise.CanUse(out act, option)) return true; - if (Player.CurrentMp > Service.Config.LessMPNoRaise && (Raise?.CanUse(out act, option) ?? false)) return true; + if (Player.CurrentMp > Service.Config.GetValue(PluginConfigInt.LessMPNoRaise) && (Raise?.CanUse(out act, option) ?? false)) return true; return false; } diff --git a/RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs b/RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs index 84c4a749f..464e63f93 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs @@ -151,7 +151,7 @@ private IAction Invoke(out IAction gcdAction) return CountDownAction(countDown); } - var helpDefenseAOE = Service.Config.GetValue(SettingsCommand.UseDefenseAbility) && DataCenter.IsHostileCastingAOE; + var helpDefenseAOE = Service.Config.GetValue(Configuration.PluginConfigBool.UseDefenseAbility) && DataCenter.IsHostileCastingAOE; bool helpDefenseSingle = false; if (ClassJob.GetJobRole() == JobRole.Healer || ClassJob.RowId == (uint)ECommons.ExcelServices.Job.PLD) diff --git a/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs b/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs index 2c4e67457..933b28f71 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs @@ -39,7 +39,8 @@ public abstract partial class CustomRotation protected static bool InCombat => DataCenter.InCombat; static RandomDelay _notInCombatDelay = new(() => - (Service.Config.NotInCombatDelayMin, Service.Config.NotInCombatDelayMax)); + (Service.Config.GetValue(Configuration.PluginConfigFloat.NotInCombatDelayMin), + Service.Config.GetValue(Configuration.PluginConfigFloat.NotInCombatDelayMax))); /// /// Is out of combat. @@ -170,9 +171,9 @@ public abstract partial class CustomRotation /// /// Is in burst right now? Usually it used with team support actions. /// - protected static bool InBurst => DataCenter.SpecialType == SpecialCommandType.Burst || Service.Config.GetValue(SettingsCommand.AutoBurst); + protected static bool InBurst => DataCenter.SpecialType == SpecialCommandType.Burst || Service.Config.GetValue(Configuration.PluginConfigBool.AutoBurst); - bool _canUseHealAction => (ClassJob.GetJobRole() == JobRole.Healer || Service.Config.UseHealWhenNotAHealer) && Service.Config.GetValue(SettingsCommand.AutoHeal); + bool _canUseHealAction => (ClassJob.GetJobRole() == JobRole.Healer || Service.Config.GetValue(Configuration.PluginConfigBool.UseHealWhenNotAHealer) && Service.Config.GetValue(Configuration.PluginConfigBool.AutoHeal)); /// /// @@ -412,7 +413,7 @@ protected static int NumberOfHostilesIn(float range) /// /// The countDond ahead. /// - protected static float CountDownAhead => Service.Config.CountDownAhead; + protected static float CountDownAhead => Service.Config.GetValue(Configuration.PluginConfigFloat.CountDownAhead); /// /// diff --git a/RotationSolver.Basic/Service.cs b/RotationSolver.Basic/Service.cs index ffb44e764..234dbc11e 100644 --- a/RotationSolver.Basic/Service.cs +++ b/RotationSolver.Basic/Service.cs @@ -38,10 +38,10 @@ internal static unsafe bool CanMove } public static float CountDownTime => Countdown.TimeRemaining; - public static PluginConfig ConfigNew { get; set; } = new PluginConfig(); + public static PluginConfig Config { get; set; } = new PluginConfig(); - public static PluginConfiguration Config { get; set; } - public static PluginConfiguration Default { get; } = new PluginConfiguration(); + //public static PluginConfiguration Config { get; set; } + //public static PluginConfiguration Default { get; } = new PluginConfiguration(); public Service() diff --git a/RotationSolver/Commands/RSCommands_Actions.cs b/RotationSolver/Commands/RSCommands_Actions.cs index 2a07a71a3..88c715d28 100644 --- a/RotationSolver/Commands/RSCommands_Actions.cs +++ b/RotationSolver/Commands/RSCommands_Actions.cs @@ -1,9 +1,7 @@ using Dalamud.Game.ClientState.Conditions; -using Dalamud.Game.ClientState.Objects.SubKinds; using Dalamud.Logging; using ECommons.DalamudServices; using ECommons.GameHelpers; -using RotationSolver.Helpers; using RotationSolver.Localization; using RotationSolver.UI; using RotationSolver.Updaters; @@ -28,7 +26,7 @@ internal static unsafe bool CanDoAnAction(bool isGCD) //Do not click the button in random time. if (DateTime.Now - _lastClickTime < TimeSpan.FromMilliseconds(new Random().Next( - (int)(Service.Config.ClickingDelayMin * 1000), (int)(Service.Config.ClickingDelayMax * 1000)))) return false; + (int)(Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.ClickingDelayMin) * 1000), (int)(Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.ClickingDelayMax) * 1000)))) return false; _lastClickTime = DateTime.Now; if (!isGCD && ActionUpdater.NextAction is IBaseAction act1 && act1.IsRealGCD) return false; @@ -39,7 +37,7 @@ internal static unsafe bool CanDoAnAction(bool isGCD) internal static uint _lastActionID; public static void DoAction() { - var wrong = new Random().NextDouble() < Service.Config.MistakeRatio && ActionUpdater.WrongAction != null; + var wrong = new Random().NextDouble() < Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.MistakeRatio) && ActionUpdater.WrongAction != null; var nextAction = wrong ? ActionUpdater.WrongAction : ActionUpdater.NextAction; if (nextAction == null) return; @@ -55,7 +53,7 @@ public static void DoAction() // Svc.Chat.Print($"Will Do {acti}"); #endif - if (Service.Config.KeyBoardNoise) + if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.KeyBoardNoise)) { PreviewUpdater.PulseActionBar(nextAction.AdjustedID); } @@ -67,7 +65,7 @@ public static void DoAction() if (nextAction is BaseAction act) { - if (Service.Config.KeyBoardNoise) + if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.KeyBoardNoise)) Task.Run(() => PulseSimulation(nextAction.AdjustedID)); if (act.ShouldEndSpecial) ResetSpecial(); @@ -75,7 +73,7 @@ public static void DoAction() //Svc.Chat.Print($"{act}, {act.Target.Name}, {ActionUpdater.AbilityRemainCount}, {ActionUpdater.WeaponElapsed}"); #endif //Change Target - if (act.Target != null && (Service.Config.TargetFriendly && !DataCenter.IsManual || ((Svc.Targets.Target?.IsNPCEnemy() ?? true) + if (act.Target != null && (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.SwitchTargetFriendly) && !DataCenter.IsManual || ((Svc.Targets.Target?.IsNPCEnemy() ?? true) || Svc.Targets.Target?.GetObjectKind() == Dalamud.Game.ClientState.Objects.Enums.ObjectKind.Treasure) && act.Target.IsNPCEnemy())) { @@ -92,12 +90,12 @@ static async void PulseSimulation(uint id) started = true; try { - for (int i = 0; i < new Random().Next(Service.Config.KeyBoardNoiseMin, - Service.Config.KeyBoardNoiseMax); i++) + for (int i = 0; i < new Random().Next(Service.Config.GetValue(Basic.Configuration.PluginConfigInt.KeyBoardNoiseMin), + Service.Config.GetValue(Basic.Configuration.PluginConfigInt.KeyBoardNoiseMax)); i++) { PreviewUpdater.PulseActionBar(id); - var time = Service.Config.ClickingDelayMin + - new Random().NextDouble() * (Service.Config.ClickingDelayMax - Service.Config.ClickingDelayMin); + var time = Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.ClickingDelayMin) + + new Random().NextDouble() * (Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.ClickingDelayMax) - Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.ClickingDelayMin)); await Task.Delay((int)(time * 1000)); } } @@ -133,18 +131,19 @@ internal static void UpdateRotationState() { CancelState(); } - else if (Service.Config.AutoOffWhenDead + else if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.AutoOffWhenDead) && Player.Available && Player.Object.CurrentHp == 0) { CancelState(); } - else if (Service.Config.AutoOffCutScene + else if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.AutoOffCutScene) && Svc.Condition[ConditionFlag.OccupiedInCutSceneEvent]) { CancelState(); } - else if (Service.Config.AutoOffBetweenArea && ( + else if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.AutoOffBetweenArea) + && ( Svc.Condition[ConditionFlag.BetweenAreas] || Svc.Condition[ConditionFlag.BetweenAreas51])) { @@ -157,7 +156,8 @@ internal static void UpdateRotationState() CancelState(); } //Auto manual on being attacked by someone. - else if (Service.Config.StartOnAttackedBySomeone && target != null + else if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.StartOnAttackedBySomeone) + && target != null && !target.IsDummy()) { if(!DataCenter.State) @@ -166,7 +166,8 @@ internal static void UpdateRotationState() } } //Auto start at count Down. - else if (Service.Config.StartOnCountdown && Service.CountDownTime > 0) + else if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.StartOnCountdown) + && Service.CountDownTime > 0) { _lastCountdownTime = Service.CountDownTime; if (!DataCenter.State) diff --git a/RotationSolver/Commands/RSCommands_BasicInfo.cs b/RotationSolver/Commands/RSCommands_BasicInfo.cs index 58b88c178..41f705c82 100644 --- a/RotationSolver/Commands/RSCommands_BasicInfo.cs +++ b/RotationSolver/Commands/RSCommands_BasicInfo.cs @@ -6,21 +6,6 @@ namespace RotationSolver.Commands; public static partial class RSCommands { - internal static TargetingType TargetingType - { - get - { - if (Service.Config.TargetingTypes.Count == 0) - { - Service.Config.TargetingTypes.Add(TargetingType.Big); - Service.Config.TargetingTypes.Add(TargetingType.Small); - Service.Config.Save(); - } - - return Service.Config.TargetingTypes[Service.Config.TargetingIndex %= Service.Config.TargetingTypes.Count]; - } - } - internal static void Enable() => Svc.Commands.AddHandler(Service.Command, new CommandInfo(OnCommand) { diff --git a/RotationSolver/Commands/RSCommands_OtherCommand.cs b/RotationSolver/Commands/RSCommands_OtherCommand.cs index 4d07c0dc0..2543c19d2 100644 --- a/RotationSolver/Commands/RSCommands_OtherCommand.cs +++ b/RotationSolver/Commands/RSCommands_OtherCommand.cs @@ -2,6 +2,7 @@ using RotationSolver.Basic.Configuration; using RotationSolver.Localization; using RotationSolver.Updaters; +using System.Configuration; namespace RotationSolver.Commands { @@ -38,36 +39,36 @@ private static void DoOtherCommand(OtherCommandType otherType, string str) private static void DoSettingCommand(string str) { - var job = RotationUpdater.Job; + var job = DataCenter.Job; var strs = str.Split(' '); var value = strs.LastOrDefault(); if(TryGetOneEnum(str, out var b)) { - var v = !Service.ConfigNew.GetValue(b); - Service.ConfigNew.SetValue(b, v); - value = Service.ConfigNew.GetValue(b).ToString(); + var v = !Service.Config.GetValue(b); + Service.Config.SetValue(b, v); + value = Service.Config.GetValue(b).ToString(); } else if (TryGetOneEnum(str, out var f) && float.TryParse(value, out var f1)) { - Service.ConfigNew.SetValue(f, f1); - value = Service.ConfigNew.GetValue(f).ToString(); + Service.Config.SetValue(f, f1); + value = Service.Config.GetValue(f).ToString(); } else if (TryGetOneEnum(str, out var i) && int.TryParse(value, out var i1)) { - Service.ConfigNew.SetValue(i, i1); - value = Service.ConfigNew.GetValue(i).ToString(); + Service.Config.SetValue(i, i1); + value = Service.Config.GetValue(i).ToString(); } else if (TryGetOneEnum(str, out var f2) && float.TryParse(value, out f1)) { - Service.ConfigNew.SetValue(job, f2, f1); - value = Service.ConfigNew.GetValue(job, f2).ToString(); + Service.Config.SetValue(job, f2, f1); + value = Service.Config.GetValue(job, f2).ToString(); } else if (TryGetOneEnum(str, out var i2) && int.TryParse(value, out i1)) { - Service.ConfigNew.SetValue(job, i2, i1); - value = Service.ConfigNew.GetValue(job, i2).ToString(); + Service.Config.SetValue(job, i2, i1); + value = Service.Config.GetValue(job, i2).ToString(); } else { @@ -113,7 +114,7 @@ private static void DoActionCommand(string str) { DataCenter.AddCommandAction(iAct, time); - if (Service.Config.ShowToastsAboutDoAction) + if (Service.Config.GetValue(PluginConfigBool.ShowToastsAboutDoAction)) { Svc.Toasts.ShowQuest(string.Format(LocalizationManager.RightLang.Commands_InsertAction, time), new Dalamud.Game.Gui.Toast.QuestToastOptions() diff --git a/RotationSolver/Commands/RSCommands_StateSpecialCommand.cs b/RotationSolver/Commands/RSCommands_StateSpecialCommand.cs index 450f8b0a4..59cebc47f 100644 --- a/RotationSolver/Commands/RSCommands_StateSpecialCommand.cs +++ b/RotationSolver/Commands/RSCommands_StateSpecialCommand.cs @@ -13,7 +13,7 @@ public static partial class RSCommands private static void UpdateToast() { - if (!Service.Config.ShowInfoOnToast) return; + if (!Service.Config.GetValue(Basic.Configuration.PluginConfigBool.ShowInfoOnToast)) return; Svc.Toasts.ShowQuest(" " + EntryString, new Dalamud.Game.Gui.Toast.QuestToastOptions() { @@ -26,12 +26,13 @@ private static unsafe void DoStateCommandType(StateCommandType stateType) => DoO if (DataCenter.State && !DataCenter.IsManual && stateType == StateCommandType.Auto) { - Service.Config.TargetingIndex += 1; - Service.Config.TargetingIndex %= Service.Config.TargetingTypes.Count; + var index = Service.Config.GetValue(Basic.Configuration.PluginConfigInt.TargetingIndex) + 1; + index %= Service.Config.GlobalConfig.TargetingTypes.Count; + Service.Config.SetValue(Basic.Configuration.PluginConfigInt.TargetingIndex, index); ActionUpdater._cancelTime = DateTime.MinValue; } - if (Service.Config.ToggleManual + if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.ToggleManual) && DataCenter.State && DataCenter.IsManual && stateType == StateCommandType.Manual) { @@ -77,6 +78,6 @@ private static void DoOneCommandType(Func sayout, Func config switch { JobConfigInt.AddDotGCDCount => LocalizationManager.RightLang.ConfigWindow_Param_AddDotGCDCount, + JobConfigInt.HostileType => LocalizationManager.RightLang.ConfigWindow_Param_RightNowTargetToHostileType, _ => string.Empty, }; public static string ToName(this JobConfigFloat config) => config switch { + JobConfigFloat.HealthForDyingTanks => LocalizationManager.RightLang.ConfigWindow_Param_HealthForDyingTank, _ => string.Empty, }; public static string ToName(this PluginConfigInt config) => config switch { PluginConfigInt.PoslockModifier => LocalizationManager.RightLang.ConfigWindow_Param_PoslockModifier, - + PluginConfigInt.MoveTargetAngle => LocalizationManager.RightLang.ConfigWindow_Param_MoveTargetAngle, // UI PluginConfigInt.KeyBoardNoiseMin => LocalizationManager.RightLang.ConfigWindow_Param_KeyBoardNoiseTimes, @@ -42,7 +44,7 @@ internal static class ConfigTranslation // UI PluginConfigBool.UseOverlayWindow => LocalizationManager.RightLang.ConfigWindow_Param_UseOverlayWindow, PluginConfigBool.TeachingMode => LocalizationManager.RightLang.ConfigWindow_Param_TeachingMode, - PluginConfigBool.ShowMoveTarget => LocalizationManager.RightLang.ConfigWindow_Param_MovingTargetColor, + PluginConfigBool.ShowMoveTarget => LocalizationManager.RightLang.ConfigWindow_Param_ShowMoveTarget, PluginConfigBool.ShowTarget => LocalizationManager.RightLang.ConfigWindow_Param_ShowTarget, PluginConfigBool.DrawMeleeOffset => LocalizationManager.RightLang.ConfigWindow_Param_DrawMeleeOffset, PluginConfigBool.KeyBoardNoise => LocalizationManager.RightLang.ConfigWindow_Param_KeyBoardNoise, @@ -85,7 +87,7 @@ internal static class ConfigTranslation PluginConfigBool.HealOutOfCombat => LocalizationManager.RightLang.ConfigWindow_Param_HealOutOfCombat, PluginConfigBool.OnlyHotOnTanks => LocalizationManager.RightLang.ConfigWindow_Param_OnlyHotOnTanks, PluginConfigBool.BeneficialAreaOnTarget => LocalizationManager.RightLang.ConfigWindow_Param_BeneficialAreaOnTarget, - + PluginConfigBool.RecordCastingArea => "Record AOE actions", // target PluginConfigBool.AddEnemyListToHostile => LocalizationManager.RightLang.ConfigWindow_Param_AddEnemyListToHostile, PluginConfigBool.ChooseAttackMark => LocalizationManager.RightLang.ConfigWindow_Param_ChooseAttackMark, @@ -94,6 +96,7 @@ internal static class ConfigTranslation PluginConfigBool.ChangeTargetForFate => LocalizationManager.RightLang.ConfigWindow_Param_ChangeTargetForFate, PluginConfigBool.OnlyAttackInView => LocalizationManager.RightLang.ConfigWindow_Param_OnlyAttackInView, PluginConfigBool.MoveTowardsScreenCenter => LocalizationManager.RightLang.ConfigWindow_Param_MoveTowardsScreen, + PluginConfigBool.MoveAreaActionFarthest => LocalizationManager.RightLang.ConfigWindow_Param_MoveAreaActionFarthest, PluginConfigBool.TargetAllForFriendly => LocalizationManager.RightLang.ConfigWindow_Param_ActionTargetFriendly, PluginConfigBool.RaiseAll => LocalizationManager.RightLang.ConfigWindow_Param_RaiseAll, PluginConfigBool.RaiseBrinkOfDeath => LocalizationManager.RightLang.ConfigWindow_Param_RaiseBrinkOfDeath, @@ -173,8 +176,8 @@ internal static class ConfigTranslation PluginConfigVector4.TargetColor => LocalizationManager.RightLang.ConfigWindow_Param_TargetColor, PluginConfigVector4.SubTargetColor => LocalizationManager.RightLang.ConfigWindow_Param_SubTargetColor, PluginConfigVector4.InfoWindowBg => LocalizationManager.RightLang.ConfigWindow_Control_InfoWindowBg, - PluginConfigVector4.ControlWindowLockBg => "锁定时控制面板背景颜色", - PluginConfigVector4.ControlWindowUnlockBg => "未锁定时控制面板背景颜色", + PluginConfigVector4.ControlWindowLockBg => LocalizationManager.RightLang.ConfigWindow_Control_LockBackgroundColor, + PluginConfigVector4.ControlWindowUnlockBg => LocalizationManager.RightLang.ConfigWindow_Control_UnlockBackgroundColor, _ => string.Empty, }; @@ -192,7 +195,7 @@ internal static class ConfigTranslation { PluginConfigInt.PoslockModifier => LocalizationManager.RightLang.ConfigWindow_Param_PoslockDescription, - PluginConfigInt.MoveTargetAngle => LocalizationManager.RightLang.ConfigWindow_Param_MoveAreaActionFarthestDesc, + PluginConfigInt.MoveTargetAngle => LocalizationManager.RightLang.ConfigWindow_Param_MoveTargetAngleDesc, _ => string.Empty, }; @@ -204,6 +207,7 @@ internal static class ConfigTranslation PluginConfigBool.AutoProvokeForTank => LocalizationManager.RightLang.ConfigWindow_Param_AutoProvokeForTankDesc, PluginConfigBool.CanAttackMarkAOE => LocalizationManager.RightLang.ConfigWindow_Param_AttackMarkAOEDesc, PluginConfigBool.MoveTowardsScreenCenter => LocalizationManager.RightLang.ConfigWindow_Param_MoveTowardsScreenDesc, + PluginConfigBool.MoveAreaActionFarthest => LocalizationManager.RightLang.ConfigWindow_Param_MoveAreaActionFarthestDesc, PluginConfigBool.AutoOpenChest => "Because of the feature in pandora, there is an issue the treasure chest cannot be opened in some cases, I find the code from roll for loot. Once Pandora fixed that, this feature will be deleted.", _ => string.Empty, diff --git a/RotationSolver/Localization/EnumTranslations.cs b/RotationSolver/Localization/EnumTranslations.cs index 8fa575aa4..4fb745857 100644 --- a/RotationSolver/Localization/EnumTranslations.cs +++ b/RotationSolver/Localization/EnumTranslations.cs @@ -143,7 +143,7 @@ internal static class EnumTranslations internal static string ToStateString(this StateCommandType type, JobRole role) => type switch { - StateCommandType.Auto => LocalizationManager.RightLang.SpecialCommandType_Smart + RSCommands.TargetingType.ToName(), + StateCommandType.Auto => LocalizationManager.RightLang.SpecialCommandType_Smart + DataCenter.TargetingType.ToName(), StateCommandType.Manual => LocalizationManager.RightLang.SpecialCommandType_Manual, StateCommandType.Cancel => LocalizationManager.RightLang.SpecialCommandType_Off, _ => string.Empty, diff --git a/RotationSolver/Localization/Strings.cs b/RotationSolver/Localization/Strings.cs index b8d46905a..4d0b1d350 100644 --- a/RotationSolver/Localization/Strings.cs +++ b/RotationSolver/Localization/Strings.cs @@ -19,18 +19,7 @@ internal partial class Strings #region ConfigWindow public string ConfigWindow_Header { get; set; } = "Rotation Solver Settings v"; - public string ConfigWindow_RotationItem { get; set; } = "Rotation"; - public string ConfigWindow_ParamItem { get; set; } = "Param"; - public string ConfigWindow_ListItem { get; set; } = "List"; public string ConfigWindow_EventItem { get; set; } = "Event"; - public string ConfigWindow_ActionItem { get; set; } = "Action Rules"; - public string ConfigWindow_ControlItem { get; set; } = "Control"; - public string ConfigWindow_HelpItem { get; set; } = "Help"; - public string ConfigWindow_ActionItem_Description { get; set; } - = "Modify the usage for each action."; - - public string ConfigWindow_HelpItem_Description { get; set; } - = "In this window, you can see all Rotation Solver built-in commands for combat. "; public string ConfigWindow_HelpItem_AttackAuto { get; set; } = "Start the addon in Auto mode (auto-targeting) when out of combat or when combat starts, otherwise switch the target according to the set condition."; @@ -79,12 +68,9 @@ internal partial class Strings = "To end this special duration before the set time."; public string ConfigWindow_Helper_SwitchRotation { get; set; } = "Click to switch authors"; public string ConfigWindow_Helper_GameVersion { get; set; } = "Game"; - public string ConfigWindow_Helper_OpenSource { get; set; } = "Open the source code URL"; public string ConfigWindow_Helper_RunCommand { get; set; } = "Click to execute the command"; public string ConfigWindow_Helper_CopyCommand { get; set; } = "Right-click to copy the command"; - public string ConfigWindow_Rotation_Description_Old { get; set; } = "You can enable the function for each job you want and configure the setting about how to use actions."; - public string ConfigWindow_Rotation_KeyName { get; set; } = "The key name is"; public string ConfigWindow_Events_AddEvent { get; set; } = "AddEvents"; public string ConfigWindow_Events_Description { get; set; } = "In this window, you can set what macro will be trigger after using an action."; public string ConfigWindow_Events_ActionName { get; set; } = "Action Name"; @@ -93,11 +79,9 @@ internal partial class Strings public string ConfigWindow_Events_RemoveEvent { get; set; } = "Delete Event"; public string ConfigWindow_Events_DutyStart { get; set; } = "Duty Start: "; public string ConfigWindow_Events_DutyEnd { get; set; } = "Duty End: "; - public string ConfigWindow_Params_Description { get; set; } = "In this window, you can set the parameters about the using way of actions."; public string ConfigWindow_Param_UseOverlayWindow { get; set; } = "Display Top Overlay"; public string ConfigWindow_Param_UseOverlayWindowDesc { get; set; } = "This top window is used to display some extra information on your game window, such as target's positional, target and sub-target, etc."; - public string ConfigWindow_Param_Basic { get; set; } = "Basic"; public string ConfigWindow_Param_ActionAhead { get; set; } = "Set the time advance of using actions"; public string ConfigWindow_Param_MinLastAbilityAdvanced { get; set; } = "Set min the time advance of using the last 0gcd."; @@ -117,7 +101,6 @@ internal partial class Strings public string ConfigWindow_Param_UseWorkTask { get; set; } = "Use work task for acceleration."; public string ConfigWindow_Param_ToggleManual { get; set; } = "Make Manual Command as toggle."; - public string ConfigWindow_Param_Delay { get; set; } = "Delay"; public string ConfigWindow_Param_WeaponDelay { get; set; } = "Set the range of random delay for GCD in second."; public string ConfigWindow_Param_DeathDelay { get; set; } = "Set the range of random delay for raising deaths in second."; @@ -133,8 +116,6 @@ internal partial class Strings public string ConfigWindow_Param_ClickingDelay { get; set; } = "Set the range of random delay for the interval of clicking actions."; public string ConfigWindow_Param_StopCastingDelay { get; set; } = "Set the range of random delay for stopping casting when target is no need to cast in second."; public string ConfigWindow_Param_ClickMistake { get; set; } = "How likely is it that RS will click the wrong action."; - public string ConfigWindow_Param_Display { get; set; } = "Display"; - public string ConfigWindow_Param_Advanced { get; set; } = "Advanced"; public string ConfigWindow_Param_PoslockCasting { get; set; } = "Lock the movement when casting or some actions."; public string ConfigWindow_Param_UseStopCasting { get; set; } = "Stops casting when hostile target is dead."; public string ConfigWindow_Param_ShowTooltips { get; set; } = "Show tooltips"; @@ -165,7 +146,6 @@ internal partial class Strings public string ConfigWindow_Param_ShowInfoOnDtr { get; set; } = "Display plugin state on server info"; public string ConfigWindow_Param_ShowInfoOnToast { get; set; } = "Display plugin state on toast"; public string ConfigWindow_Param_ShowToastsAboutDoAction { get; set; } = "Display do action feedback on toast"; - public string ConfigWindow_Param_Action { get; set; } = "Action"; public string ConfigWindow_Param_UseAOEAction { get; set; } = "Use AOE actions"; public string ConfigWindow_Param_UseAOEWhenManual { get; set; } = "Use AOE actions in manual mode"; @@ -189,7 +169,6 @@ internal partial class Strings public string ConfigWindow_Param_LessMPNoRaise { get; set; } = "Never raise player if MP is less than the set value"; public string ConfigWindow_Param_UseTinctures { get; set; } = "Use Tinctures"; public string ConfigWindow_Param_UseHealPotions { get; set; } = "Use Heal Potions"; - public string ConfigWindow_Param_Condition { get; set; } = "Condition"; public string ConfigWindow_Param_StartOnCountdown { get; set; } = "Auto turn smart on countdown"; public string ConfigWindow_Param_StartOnAttackedBySomeone { get; set; } = "Automatically turn on manual mode and target enemy when being attacked"; @@ -225,12 +204,10 @@ internal partial class Strings public string ConfigWindow_Param_HealthForDyingTank { get; set; } = "Set the HP%% for tank to use invincibility"; public string ConfigWindow_Param_MeleeRangeOffset { get; set; } = "Melee Range action using offset"; - public string ConfigWindow_Param_Target { get; set; } = "Target"; public string ConfigWindow_Param_RightNowTargetToHostileType { get; set; } = "Engage settings"; public string ConfigWindow_Param_TargetToHostileType1 { get; set; } = "All targets can attack"; public string ConfigWindow_Param_TargetToHostileType2 { get; set; } = "Targets have a target or all targets can attack"; public string ConfigWindow_Param_TargetToHostileType3 { get; set; } = "Targets have a target"; - public string ConfigWindow_Param_NoticeUnexpectedCombat { get; set; } = "NOTICE: You are not turn the auto off between area on. It may start a combat unexpectedly."; public string ConfigWindow_Param_AddEnemyListToHostile { get; set; } = "Add Enemies list to the hostile target."; public string ConfigWindow_Param_ChooseAttackMark { get; set; } = "Priority attack targets with attack markers"; public string ConfigWindow_Param_CanAttackMarkAOE { get; set; } = "Forced use of AOE"; @@ -255,11 +232,7 @@ internal partial class Strings public string ConfigWindow_Param_MoveAreaActionFarthestDesc { get; set; } = "Move to the furthest position from character's face direction."; public string ConfigWindow_Param_HostileDesc { get; set; } = "You can set the logic of hostile target selection to allow flexibility in switching the logic of selecting hostile in battle."; - public string ConfigWindow_Param_AddOne { get; set; } = "Add One"; public string ConfigWindow_Param_HostileCondition { get; set; } = "Hostile target selection condition"; - public string ConfigWindow_Param_ResetToDefault { get; set; } = "Click to reset this value."; - public string ConfigWindow_Param_ResetToDefaultWait { get; set; } = "Please wait for a second."; - public string ConfigWindow_Param_ResetToDefaultSure { get; set; } = "Are you sure to reset this value?"; public string ConfigWindow_Control_OnlyShowWithHostileOrInDuty { get; set; } = "Only shown if there are enemies in or in duty"; public string ConfigWindow_Control_ShowNextActionWindow { get; set; } = "Show Next Action Window"; @@ -274,7 +247,8 @@ internal partial class Strings public string ConfigWindow_Control_UseOriginalCooldown { get; set; } = "Show Original Cooldown"; public string ConfigWindow_Control_CooldownActionOneLine { get; set; } = "The count of cooldown actions in one line."; public string ConfigWindow_Control_CooldownFontSize { get; set; } = "Change the cooldown font size."; - public string ConfigWindow_Control_BackgroundColor { get; set; } = "Control Window's Background"; + public string ConfigWindow_Control_UnlockBackgroundColor { get; set; } = "Unlocked Control Window's Background"; + public string ConfigWindow_Control_LockBackgroundColor { get; set; } = "Locked Control Window's Background"; public string ConfigWindow_Control_InfoWindowBg { get; set; } = "Info Window's Background"; public string ConfigWindow_Control_ControlWindowGCDSize { get; set; } = "GCD icon size"; public string ConfigWindow_Control_ControlWindow0GCDSize { get; set; } = "0GCD icon size"; @@ -288,7 +262,6 @@ internal partial class Strings public string ConfigWindow_Rotation_AutoUpdateRotations { get; set; } = "Auto Update Rotations"; public string ConfigWindow_Rotation_InvalidRotation { get; set; } = "Invalid Rotation! \nPlease update to the latest version or contact to the {0}!"; - public string ConfigWindow_Rotation_ResetToDefault { get; set; } = "Click to reset the rotation configuration to default!"; public string ConfigWindow_List_Description { get; set; } = "In this window, you can set the parameters about some list things."; public string ConfigWindow_List_Hostile { get; set; } = "Hostile"; @@ -307,7 +280,6 @@ internal partial class Strings public string ConfigWindow_List_HostileCastingAreaDesc { get; set; } = "If the target is casting the action like this, it'll defense area."; - public string ConfigWindow_List_Rotations { get; set; } = "Rotations"; public string ConfigWindow_List_NoHostile { get; set; } = "No Hostile"; public string ConfigWindow_List_NoHostileDesc { get; set; } = "Add a name of target that never be the hostile for you."; @@ -639,8 +611,6 @@ internal partial class Strings public string ConfigWindow_Actions_DisabledConditionSet_Description { get; set; } = "Conditions when automatic use of action is disabled."; public string ConfigWindow_Actions_ShowOnCDWindow { get; set; } = "Show on CD window"; - public string ConfigWindow_Actions_InsertCommand { get; set; } = "Insert \"{0}\" first in {1}s"; - public string ConfigWindow_Configs_JobConfigTip { get; set; } = "This config is binding with the job, different job gets different value."; public string ConfigWindow_Rotations_Settings { get; set; } = "Settings"; @@ -687,5 +657,4 @@ internal partial class Strings public string ConfigWindow_Auto_ActionCondition { get; set; } = "Action Condition"; public string ConfigWindow_Auto_ActionCondition_Description { get; set; } = "This will change the strategy of Rotation Solver to use these actions."; public string ConfigWindow_Target_Config { get; set; } = "Configuration"; - -} +} \ No newline at end of file diff --git a/RotationSolver/RotationSolver.csproj b/RotationSolver/RotationSolver.csproj index defb6b235..d3da8bc19 100644 --- a/RotationSolver/RotationSolver.csproj +++ b/RotationSolver/RotationSolver.csproj @@ -16,6 +16,7 @@ + diff --git a/RotationSolver/RotationSolverPlugin.cs b/RotationSolver/RotationSolverPlugin.cs index 124c0902a..4a9e4de59 100644 --- a/RotationSolver/RotationSolverPlugin.cs +++ b/RotationSolver/RotationSolverPlugin.cs @@ -22,7 +22,6 @@ public sealed class RotationSolverPlugin : IDalamudPlugin, IDisposable { private readonly WindowSystem windowSystem; - static RotationConfigWindow _comboConfigWindow; static RotationConfigWindowNew _rotationConfigWindow; static ControlWindow _controlWindow; static NextActionWindow _nextActionWindow; @@ -44,23 +43,21 @@ public RotationSolverPlugin(DalamudPluginInterface pluginInterface) _dis.Add(new Service()); try { - Service.Config = JsonConvert.DeserializeObject( + Service.Config = JsonConvert.DeserializeObject( File.ReadAllText(Svc.PluginInterface.ConfigFile.FullName)) - ?? new PluginConfiguration(); + ?? new PluginConfig(); } catch { - Service.Config = new PluginConfiguration(); + Service.Config = new PluginConfig(); } - _comboConfigWindow = new(); _rotationConfigWindow = new(); _controlWindow = new(); _nextActionWindow = new(); _cooldownWindow = new(); windowSystem = new WindowSystem(Name); - windowSystem.AddWindow(_comboConfigWindow); windowSystem.AddWindow(_rotationConfigWindow); windowSystem.AddWindow(_controlWindow); windowSystem.AddWindow(_nextActionWindow); @@ -93,8 +90,8 @@ public RotationSolverPlugin(DalamudPluginInterface pluginInterface) internal static void ChangeUITranslation() { - _comboConfigWindow.WindowName = LocalizationManager.RightLang.ConfigWindow_Header - + typeof(RotationConfigWindow).Assembly.GetName().Version.ToString(); + _rotationConfigWindow.WindowName = LocalizationManager.RightLang.ConfigWindow_Header + + typeof(RotationConfigWindowNew).Assembly.GetName().Version.ToString(); RSCommands.Disable(); RSCommands.Enable(); @@ -123,15 +120,10 @@ public void Dispose() private void OnOpenConfigUi() { - _comboConfigWindow.IsOpen = true; + _rotationConfigWindow.IsOpen = true; } internal static void OpenConfigWindow() - { - _comboConfigWindow.Toggle(); - } - - internal static void ToggleConfigWindow() { _rotationConfigWindow.Toggle(); } @@ -148,14 +140,13 @@ internal static void UpdateDisplayWindow() && (!Svc.Condition[ConditionFlag.UsingParasol] || Player.Object.StatusFlags.HasFlag(Dalamud.Game.ClientState.Objects.Enums.StatusFlags.WeaponOut)) && !Svc.Condition[ConditionFlag.OccupiedInQuestEvent]); - _nextActionWindow.IsOpen = isValid && Service.Config.ShowNextActionWindow; + _nextActionWindow.IsOpen = isValid && Service.Config.GetValue(PluginConfigBool.ShowNextActionWindow); - isValid &= !Service.Config.OnlyShowWithHostileOrInDuty + isValid &= !Service.Config.GetValue(PluginConfigBool.OnlyShowWithHostileOrInDuty) || Svc.Condition[ConditionFlag.BoundByDuty] || DataCenter.AllHostileTargets.Any(o => o.DistanceToPlayer() <= 25); - _controlWindow.IsOpen = isValid && Service.Config.ShowControlWindow; - _cooldownWindow.IsOpen = isValid && Service.Config.ShowCooldownWindow; - + _controlWindow.IsOpen = isValid && Service.Config.GetValue(PluginConfigBool.ShowControlWindow); + _cooldownWindow.IsOpen = isValid && Service.Config.GetValue(PluginConfigBool.ShowCooldownWindow); } } diff --git a/RotationSolver/UI/ControlWindow.cs b/RotationSolver/UI/ControlWindow.cs index bd578c269..106cce250 100644 --- a/RotationSolver/UI/ControlWindow.cs +++ b/RotationSolver/UI/ControlWindow.cs @@ -1,5 +1,4 @@ using Dalamud.Interface.Colors; -using Dalamud.Interface.Style; using Dalamud.Interface.Windowing; using ECommons.DalamudServices; using ImGuiScene; @@ -7,6 +6,7 @@ using RotationSolver.Commands; using RotationSolver.Localization; using RotationSolver.Updaters; +using System.Drawing; namespace RotationSolver.UI; @@ -30,14 +30,15 @@ public ControlWindow() public override void PreDraw() { - Vector4 bgColor = Service.Config.IsControlWindowLock - ? Service.Config.ControlWindowLockBg - : Service.Config.ControlWindowUnlockBg; + + Vector4 bgColor = Service.Config.GetValue(PluginConfigBool.IsControlWindowLock) + ? Service.Config.GetValue(PluginConfigVector4.ControlWindowLockBg) + : Service.Config.GetValue(PluginConfigVector4.ControlWindowUnlockBg); ImGui.PushStyleColor(ImGuiCol.WindowBg, bgColor); Flags = BaseFlags; - if (Service.Config.IsControlWindowLock) + if (Service.Config.GetValue(PluginConfigBool.IsControlWindowLock)) { Flags |= ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove; } @@ -54,9 +55,12 @@ public override void PostDraw() public override void Draw() { + ImGui.Columns(3, "Control Bolder", false); - var gcd = Service.Config.ControlWindowGCDSize * Service.Config.ControlWindowNextSizeRatio; - var ability = Service.Config.ControlWindow0GCDSize * Service.Config.ControlWindowNextSizeRatio; + var gcd = Service.Config.GetValue(PluginConfigFloat.ControlWindowGCDSize) + * Service.Config.GetValue(PluginConfigFloat.ControlWindowNextSizeRatio); + var ability = Service.Config.GetValue(PluginConfigFloat.ControlWindow0GCDSize) + * Service.Config.GetValue(PluginConfigFloat.ControlWindowNextSizeRatio); var width = gcd + ability + ImGui.GetStyle().ItemSpacing.X; ImGui.SetColumnWidth(1, 8); @@ -86,8 +90,11 @@ public override void Draw() ImGui.TextColored(ImGuiColors.DPSRed, DataCenter.TargetingType.ToName()); - RotationConfigWindow.DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsInfoWindowNoMove, - ref Service.Config.IsControlWindowLock); + var value = Service.Config.GetValue(PluginConfigBool.IsControlWindowLock); + if(ImGui.Checkbox(LocalizationManager.RightLang.ConfigWindow_Control_IsInfoWindowNoMove, ref value)) + { + Service.Config.SetValue(PluginConfigBool.IsControlWindowLock, value); + } ImGui.EndGroup(); ImGui.SameLine(); @@ -169,7 +176,8 @@ private static void DrawSpecials() ImGui.Text("CMD:"); ImGui.SameLine(); - DrawIAction(DataCenter.CommandNextAction, Service.Config.ControlWindow0GCDSize, 1); + + DrawIAction(DataCenter.CommandNextAction, Service.Config.GetValue(PluginConfigFloat.ControlWindow0GCDSize), 1); ImGui.SameLine(); @@ -185,20 +193,21 @@ private static void DrawSpecials() ImGui.Text("Auto: " + DataCenter.AutoStatus.ToString()); ImGui.EndGroup(); - - if(Service.Config.MistakeRatio > 0) + if (Service.Config.GetValue(PluginConfigFloat.MistakeRatio) > 0) { ImGui.SameLine(); ImGui.TextColored(ImGuiColors.DPSRed, " | Mistake | \n | Mistake | "); ImGui.SameLine(); - DrawIAction(DateTime.Now - DidTime < TimeSpan.FromSeconds(5) ? Wrong : null, Service.Config.ControlWindowGCDSize, 1); + + DrawIAction(DateTime.Now - DidTime < TimeSpan.FromSeconds(5) ? Wrong : null, + Service.Config.GetValue(PluginConfigFloat.ControlWindowGCDSize), 1); } } static void DrawCommandAction(IAction gcd, IAction ability, SpecialCommandType command, Vector4 color) { - var gcdW = Service.Config.ControlWindowGCDSize; - var abilityW = Service.Config.ControlWindow0GCDSize; + var gcdW = Service.Config.GetValue(PluginConfigFloat.ControlWindowGCDSize); + var abilityW = Service.Config.GetValue(PluginConfigFloat.ControlWindow0GCDSize); var width = gcdW + abilityW + ImGui.GetStyle().ItemSpacing.X + ImGui.GetStyle().ItemInnerSpacing.X * 4; var str = command.ToString(); var strWidth = ImGui.CalcTextSize(str).X; @@ -214,12 +223,10 @@ static void DrawCommandAction(IAction gcd, IAction ability, SpecialCommandType c ImGui.SetCursorPosX(ImGui.GetCursorPosX() + Math.Max(0, strWidth / 2 - width / 2)); - var texture = IconSet.GetTexture(gcd); - if(texture != null) + if(IconSet.GetTexture(gcd, out var texture)) { DrawIAction(texture.ImGuiHandle, baseId + nameof(gcd), gcdW, command, help); - texture = IconSet.GetTexture(ability); - if (texture != null) + if (IconSet.GetTexture(ability, out texture)) { ImGui.SameLine(); DrawIAction(texture.ImGuiHandle, baseId + nameof(ability), abilityW, command, help); @@ -253,17 +260,17 @@ static void HighLight(Vector2 pt, Vector2 size, float thickness = 2f) static void DrawCommandAction(IAction ability, SpecialCommandType command, Vector4 color) { - DrawCommandAction(IconSet.GetTexture(ability), command, color); + if (IconSet.GetTexture(ability, out var texture)) DrawCommandAction(texture, command, color); } static void DrawCommandAction(uint iconId, SpecialCommandType command, Vector4 color) { - DrawCommandAction(IconSet.GetTexture(iconId), command, color); + if(IconSet.GetTexture(iconId, out var texture)) DrawCommandAction(texture, command, color); } static void DrawCommandAction(TextureWrap texture, SpecialCommandType command, Vector4 color) { - var abilityW = Service.Config.ControlWindow0GCDSize; + var abilityW = Service.Config.GetValue(PluginConfigFloat.ControlWindow0GCDSize); var width = abilityW + ImGui.GetStyle().ItemInnerSpacing.X * 2; var str = command.ToString(); var strWidth = ImGui.CalcTextSize(str).X; @@ -300,7 +307,7 @@ static void DrawCommandAction(TextureWrap texture, SpecialCommandType command, V static void DrawCommandAction(uint iconId, StateCommandType command, Vector4 color) { - var abilityW = Service.Config.ControlWindow0GCDSize; + var abilityW = Service.Config.GetValue(PluginConfigFloat.ControlWindow0GCDSize); var width = abilityW + ImGui.GetStyle().ItemInnerSpacing.X * 2; var str = command.ToString(); var strWidth = ImGui.CalcTextSize(str).X; @@ -313,8 +320,7 @@ static void DrawCommandAction(uint iconId, StateCommandType command, Vector4 col var help = GetHelp(command); string baseId = "ImgButton" + command.ToString(); - var texture = IconSet.GetTexture(iconId); - if(texture != null) + if(IconSet.GetTexture(iconId, out var texture)) { ImGui.SetCursorPosX(ImGui.GetCursorPosX() + Math.Max(0, strWidth / 2 - width / 2)); DrawIAction(texture.ImGuiHandle, baseId, abilityW, command, help); @@ -386,8 +392,7 @@ static void DrawIAction(nint handle, string id, float width, StateCommandType co internal static (Vector2, Vector2) DrawIAction(IAction action, float width, float percent, bool isAdjust = true) { - var texture = IconSet.GetTexture(action, isAdjust); - if (texture == null) return (default, default); + if (!IconSet.GetTexture(action, out var texture, isAdjust)) return (default, default); var result = DrawIAction(texture.ImGuiHandle, width, action == null ? -1 : percent); if (action != null) ImGuiHelper.HoveredString(action.Name, () => { @@ -426,9 +431,7 @@ internal static (Vector2, Vector2) DrawIAction(nint handle, float width, float p if (percent < 0) { - var cover = IconSet.GetTexture("ui/uld/icona_frame_hr1.tex"); - - if (cover != null) + if (IconSet.GetTexture("ui/uld/icona_frame_hr1.tex", out var cover)) { ImGui.SetCursorPos(cursor - new Vector2(pixPerUnit * 3, pixPerUnit * 4)); @@ -443,9 +446,7 @@ internal static (Vector2, Vector2) DrawIAction(nint handle, float width, float p } else if (percent < 1) { - var cover = IconSet.GetTexture("ui/uld/icona_recast_hr1.tex"); - - if (cover != null) + if (IconSet.GetTexture("ui/uld/icona_recast_hr1.tex", out var cover)) { ImGui.SetCursorPos(cursor - new Vector2(pixPerUnit * 3, pixPerUnit * 0)); @@ -463,9 +464,7 @@ internal static (Vector2, Vector2) DrawIAction(nint handle, float width, float p } else { - var cover = IconSet.GetTexture("ui/uld/icona_frame_hr1.tex"); - - if (cover != null) + if (IconSet.GetTexture("ui/uld/icona_frame_hr1.tex", out var cover)) { ImGui.SetCursorPos(cursor - new Vector2(pixPerUnit * 3, pixPerUnit * 4)); @@ -480,9 +479,7 @@ internal static (Vector2, Vector2) DrawIAction(nint handle, float width, float p if (percent > 1) { - var cover = IconSet.GetTexture("ui/uld/icona_recast2_hr1.tex"); - - if (cover != null) + if (IconSet.GetTexture("ui/uld/icona_recast2_hr1.tex", out var cover)) { ImGui.SetCursorPos(cursor - new Vector2(pixPerUnit * 3, pixPerUnit * 0)); diff --git a/RotationSolver/UI/CooldownWindow.cs b/RotationSolver/UI/CooldownWindow.cs index ca00dd082..b8d4df34a 100644 --- a/RotationSolver/UI/CooldownWindow.cs +++ b/RotationSolver/UI/CooldownWindow.cs @@ -18,17 +18,17 @@ public override void Draw() foreach (var pair in RotationUpdater.AllGroupedActions) { var showItems = pair.OrderBy(a => a.SortKey).Where(a => a.IsInCooldown); - if (!Service.Config.ShowGCDCooldown) showItems = showItems.Where(i => !(i is IBaseAction a && a.IsGeneralGCD)); + if (!Service.Config.GetValue(Basic.Configuration.PluginConfigBool.ShowGCDCooldown)) showItems = showItems.Where(i => !(i is IBaseAction a && a.IsGeneralGCD)); if (!showItems.Any()) continue; - if (!Service.Config.ShowItemsCooldown && showItems.Any(i => i is IBaseItem)) continue; + if (!Service.Config.GetValue(Basic.Configuration.PluginConfigBool.ShowItemsCooldown) && showItems.Any(i => i is IBaseItem)) continue; ImGui.Text(pair.Key); uint started = 0; foreach (var item in showItems) { - if (started % Math.Max(1, Service.Config.CooldownActionOneLine) != 0) + if (started % Math.Max(1, Service.Config.GetValue(Basic.Configuration.PluginConfigInt.CooldownActionOneLine)) != 0) { ImGui.SameLine(); } @@ -43,7 +43,7 @@ public override void Draw() private static void DrawActionCooldown(IAction act) { - var width = Service.Config.CooldownWindowIconSize; + var width = Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.CooldownWindowIconSize); var recast = act.RecastTimeOneChargeRaw; var elapsed = act.RecastTimeElapsedRaw; var shouldSkip = recast < 3 && act is IBaseAction a && !a.IsRealGCD; @@ -52,7 +52,7 @@ private static void DrawActionCooldown(IAction act) var winPos = ImGui.GetWindowPos(); var r = -1f; - if (Service.Config.UseOriginalCooldown) + if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.UseOriginalCooldown)) { r = !act.EnoughLevel ? 0: recast == 0 || !act.IsCoolingDown || shouldSkip ? 1 : elapsed / recast; } @@ -63,7 +63,7 @@ private static void DrawActionCooldown(IAction act) if (!act.EnoughLevel) { - if (!Service.Config.UseOriginalCooldown) + if (!Service.Config.GetValue(Basic.Configuration.PluginConfigBool.UseOriginalCooldown)) { ImGui.GetWindowDrawList().AddRectFilled(new Vector2(pos.X, pos.Y) + winPos, new Vector2(pos.X + size.X, pos.Y + size.Y) + winPos, progressCol); @@ -71,7 +71,7 @@ private static void DrawActionCooldown(IAction act) } else if (act.IsCoolingDown && !shouldSkip) { - if (!Service.Config.UseOriginalCooldown) + if (!Service.Config.GetValue(Basic.Configuration.PluginConfigBool.UseOriginalCooldown)) { var ratio = recast == 0 || !act.EnoughLevel ? 0 : elapsed % recast / recast; var startPos = new Vector2(pos.X + size.X * ratio, pos.Y) + winPos; @@ -81,7 +81,7 @@ private static void DrawActionCooldown(IAction act) ImGui.GetWindowDrawList().AddLine(startPos, startPos + new Vector2(0, size.Y), black); } - ImGui.PushFont(ImGuiHelper.GetFont(Service.Config.CooldownFontSize)); + ImGui.PushFont(ImGuiHelper.GetFont(Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.CooldownFontSize))); string time = recast == 0 ? "0" : ((int)(recast - elapsed % recast) + 1).ToString(); var strSize = ImGui.CalcTextSize(time); var fontPos = new Vector2(pos.X + size.X / 2 - strSize.X / 2, pos.Y + size.Y / 2 - strSize.Y / 2) + winPos; diff --git a/RotationSolver/UI/ImGuiHelper.cs b/RotationSolver/UI/ImGuiHelper.cs index 5ecfc8d52..19ac32193 100644 --- a/RotationSolver/UI/ImGuiHelper.cs +++ b/RotationSolver/UI/ImGuiHelper.cs @@ -1,12 +1,9 @@ using Dalamud.Interface.Colors; using Dalamud.Interface.Components; -using Dalamud.Utility; using ECommons.DalamudServices; using F23.StringSimilarity; -using FFXIVClientStructs.FFXIV.Client.Game; using RotationSolver.Basic.Configuration; using RotationSolver.Commands; -using RotationSolver.Helpers; using RotationSolver.Localization; using System.ComponentModel; @@ -14,76 +11,6 @@ namespace RotationSolver.UI; internal static class ImGuiHelper { - - public static void DrawEnableTexture(this T texture, bool isSelected, Action selected, - Action showToolTip = null, Action> additionalHeader = null, - Action otherThing = null) where T : class, ITexture - { - var t = texture.GetTexture(); - - if (t == null) return; - - showToolTip ??= text => - { - ShowTooltip(text.Description); - }; - - ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(3f, 3f)); - - ImGui.Columns(2, texture.Name, false); - - ImGui.SetColumnWidth(0, t.Width + 5); - - ImGui.Image(t.ImGuiHandle, new Vector2(t.Width, t.Height)); - - var desc = texture?.Description; - if (ImGui.IsItemHovered()) - { - showToolTip(texture); - if (ImGui.IsMouseClicked(ImGuiMouseButton.Left)) - { - selected?.Invoke(); - } - } - ImGui.NextColumn(); - - if (isSelected) ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); - var enable = texture.IsEnabled; - if (ImGui.Checkbox($"{texture.Name}##{texture.Name}Enabled", ref enable)) - { - texture.IsEnabled = enable; - Service.Config.Save(); - } - if (isSelected) ImGui.PopStyleColor(); - - if (ImGui.IsItemHovered()) - { - showToolTip(texture); - } - - if(texture is IAction) - { - ImGui.SameLine(); - Spacing(); - - OtherCommandType.ToggleActions.DisplayCommandHelp(texture.ToString()); - } - - additionalHeader?.Invoke(showToolTip); - - if (enable) - { - ImGui.Indent(20); - ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(1f, 1f)); - otherThing?.Invoke(); - ImGui.PopStyleVar(); - ImGui.Unindent(20); - } - ImGui.Columns(1); - - ImGui.PopStyleVar(); - } - public static bool IconButton(FontAwesomeIcon icon, string name, string description = null) { ImGui.PushFont(UiBuilder.IconFont); @@ -107,60 +34,6 @@ public static bool IconButton(FontAwesomeIcon icon, string name, string descript return result; } - static string _undoName; - static DateTime _lastTime; - public static void UndoValue(string name, ref T value, T @default, Action otherThing = null) - { - if (UndoValue(name)) - { - otherThing?.Invoke(); - value = @default; - Service.Config.Save(); - } - } - - public static void UndoValue(string name, ref T value1, T default1, ref T value2, T default2, Action otherThing = null) - { - if (UndoValue(name)) - { - otherThing?.Invoke(); - value1 = default1; - value2 = default2; - Service.Config.Save(); - } - } - - private static bool UndoValue(string name) - { - ImGui.SameLine(); - Spacing(); - - bool isLast = name == _undoName && DateTime.Now - _lastTime < TimeSpan.FromSeconds(2); - bool isTime = DateTime.Now - _lastTime > TimeSpan.FromSeconds(0.5); - - bool result = false; - - if (isLast) ImGui.PushStyleColor(ImGuiCol.Text, isTime ? ImGuiColors.HealerGreen : ImGuiColors.DPSRed); - if (IconButton(isLast ? FontAwesomeIcon.Check : FontAwesomeIcon.Undo, $"#{name}: Undo", - !isTime ? LocalizationManager.RightLang.ConfigWindow_Param_ResetToDefaultWait : - isLast ? LocalizationManager.RightLang.ConfigWindow_Param_ResetToDefaultSure - : LocalizationManager.RightLang.ConfigWindow_Param_ResetToDefault) - ) - { - if (isLast && isTime) - { - result = true; - _lastTime = DateTime.MinValue; - } - else - { - _lastTime = DateTime.Now; - _undoName = name; - } - } - if (isLast) ImGui.PopStyleColor(); - return result; - } public static void HoveredString(string text, Action selected = null) { @@ -427,295 +300,6 @@ internal static void DisplayCommandHelp(this T command, string extraCommand = } } - public unsafe static void Display(this ICustomRotation rotation, ICustomRotation[] rotations, bool canAddButton) - => rotation.DrawEnableTexture(canAddButton, null, - rotation => - { - ImguiTooltips.ShowTooltip(() => - { - var t = IconSet.GetTexture(IconSet.GetJobIcon(rotation, IconType.Framed)); - ImGui.Image(t.ImGuiHandle, new Vector2(t.Width, t.Height)); - - if (!string.IsNullOrEmpty(rotation.Description)) - { - ImGui.SameLine(); - ImGui.Text(" "); - ImGui.SameLine(); - ImGui.Text(rotation.Description); - } - - var type = rotation.GetType(); - - var attrs = new List { RotationDescAttribute.MergeToOne(type.GetCustomAttributes()) }; - - foreach (var m in type.GetAllMethodInfo()) - { - attrs.Add(RotationDescAttribute.MergeToOne(m.GetCustomAttributes())); - } - - try - { - foreach (var a in RotationDescAttribute.Merge(attrs)) - { - RotationDescAttribute.MergeToOne(a)?.Display(rotation); - } - } - catch (Exception ex) - { - var e = ex; - while(e != null) - { - ImGui.Text(e.Message); - e = e.InnerException; - } - ImGui.Text(ex.StackTrace); - } - }); - }, - showToolTip => - { - if (!string.IsNullOrEmpty(rotation.RotationName) && rotations != null) - { - ImGui.SameLine(); - ImGui.TextDisabled(" - "); - ImGui.SameLine(); - ImGui.SetNextItemWidth(ImGui.CalcTextSize(rotation.RotationName).X + 30); - if (ImGui.BeginCombo("##RotationName:" + rotation.Name, rotation.RotationName)) - { - foreach (var r in rotations) - { - ImGui.PushStyleColor(ImGuiCol.Text, r.GetColor()); - if (ImGui.Selectable(r.RotationName)) - { - Service.Config.RotationChoices[rotation.ClassJob.RowId] = r.GetType().FullName; - Service.Config.Save(); - } - if (ImGui.IsItemHovered()) - { - showToolTip?.Invoke(r); - } - ImGui.PopStyleColor(); - } - ImGui.EndCombo(); - } - HoveredString(LocalizationManager.RightLang.ConfigWindow_Helper_SwitchRotation); - } - - ImGui.SameLine(); - ImGui.TextDisabled(" - "); - ImGui.SameLine(); - - ImGui.PushStyleColor(ImGuiCol.Text, rotation.GetColor()); - ImGui.Text(rotation.GetType().Assembly.GetName().Name); - if(!rotation.IsValid) - { - HoveredString(string.Format(LocalizationManager.RightLang.ConfigWindow_Rotation_InvalidRotation, - rotation.GetType().Assembly.GetInfo().Author)); - } - else if (rotation.IsBeta()) - { - HoveredString(LocalizationManager.RightLang.ConfigWindow_Rotation_BetaRotation); - } - ImGui.PopStyleColor(); - - ImGui.SameLine(); - ImGui.TextDisabled(" - " + LocalizationManager.RightLang.ConfigWindow_Helper_GameVersion + ": "); - ImGui.SameLine(); - ImGui.Text(rotation.GameVersion); - - //if (rotation.Configs.Any()) - //{ - // ImGui.SameLine(); - // Spacing(); - // if (IconButton(FontAwesomeIcon.Undo, $"#{rotation.GetHashCode()}Undo", - // LocalizationManager.RightLang.ConfigWindow_Rotation_ResetToDefault)) - // { - // if (Service.Config.RotationsConfigurations.TryGetValue(rotation.ClassJob.RowId, out var jobDict) - // && jobDict.ContainsKey(rotation.GetType().FullName)) - // { - // jobDict.Remove(rotation.GetType().FullName); - // } - // } - //} - - var link = rotation.GetType().GetCustomAttribute(); - if (link != null) - { - ImGui.SameLine(); - Spacing(); - - if (IconButton(FontAwesomeIcon.Code, "Code" + rotation.GetHashCode().ToString())) - { - try - { - Util.OpenLink(link.Path); - } - catch - { - } - } - } - - HoveredString(LocalizationManager.RightLang.ConfigWindow_Helper_OpenSource); - - //var attrs = rotation.GetType().GetCustomAttributes(); - //if (attrs.Any()) - //{ - // var display = ImGui.GetIO().DisplaySize * 0.7f; - - // bool isFirst = true; - // foreach (var texture in attrs) - // { - // ImGui.SameLine(); - // if(isFirst) - // { - // isFirst = false; - // Spacing(); - // } - // //var hasTexture = texture.Texture != null; - - // //if (IconButton(hasTexture ? FontAwesomeIcon.Image : FontAwesomeIcon.Question, - // // "Button" + rotation.GetHashCode().ToString() + texture.GetHashCode().ToString())) - // //{ - // // try - // // { - // // Util.OpenLink(texture.Path); - // // } - // // catch - // // { - // // } - // //} - // //if (ImGui.IsItemHovered() && (hasTexture || !string.IsNullOrEmpty( texture.Description))) - // //{ - // // ImguiTooltips.ShowTooltip(() => - // // { - // // if(hasTexture) - // // { - // // var ratio = Math.Min(1, Math.Min(display.X / texture.Texture.Width, display.Y / texture.Texture.Height)); - // // var size = new Vector2(texture.Texture.Width * ratio, - // // texture.Texture.Height * ratio); - // // ImGui.Image(texture.Texture.ImGuiHandle, size); - // // } - // // if (!string.IsNullOrEmpty(texture.Description)) - // // { - // // ImGui.Text(texture.Description); - // // } - - // // }); - // //} - // } - //} - }, () => - { - RotationConfigWindow.DrawRotationRole(rotation, canAddButton); - }); - - #region IAction - public static void Display(this IAction action, bool IsActive) - { - if (action is IBaseAction act) - { - act.Display(IsActive); - } - else if (action is IBaseItem item) - { - item.Display(IsActive); - } - } - private unsafe static void Display(this IBaseAction action, bool IsActive) => action.DrawEnableTexture(IsActive, () => - { - RotationConfigWindow.ActiveAction = action; - }, showToolTip: a => - { - if(!string.IsNullOrEmpty(a.Description)) ImGui.SetTooltip(a.Description); - },otherThing: () => - { - var enable = action.IsInCooldown; - if (ImGui.Checkbox($"{LocalizationManager.RightLang.ConfigWindow_Actions_ShowOnCDWindow}##{action.Name}InCooldown", ref enable)) - { - action.IsInCooldown = enable; - Service.Config.Save(); - } - - ImGui.SameLine(); - Spacing(); - - OtherCommandType.DoActions.DisplayCommandHelp($"{action}-{5}", - type => string.Format(LocalizationManager.RightLang.ConfigWindow_Actions_InsertCommand, action, 5), false); - - if (Service.Config.InDebug) - { - try - { -#if DEBUG - ImGui.Text("Is Real GCD: " + action.IsRealGCD.ToString()); - ImGui.Text("Status: " + ActionManager.Instance()->GetActionStatus(ActionType.Spell, action.AdjustedID).ToString()); - ImGui.Text("Cast Time: " + action.CastTime.ToString()); - ImGui.Text("MP: " + action.MPNeed.ToString()); -#endif - ImGui.Text("AttackType: " + action.AttackType.ToString()); - ImGui.Text("Aspect: " + action.Aspect.ToString()); - ImGui.Text("Has One:" + action.HasOneCharge.ToString()); - ImGui.Text("Recast One: " + action.RecastTimeOneChargeRaw.ToString()); - ImGui.Text("Recast Elapsed: " + action.RecastTimeElapsedRaw.ToString()); - - var option = CanUseOption.IgnoreTarget | CanUseOption.IgnoreClippingCheck; - ImGui.Text($"Can Use: {action.CanUse(out _, option)} "); - ImGui.Text("Must Use:" + action.CanUse(out _, option | CanUseOption.MustUse).ToString()); - ImGui.Text("Empty Use:" + action.CanUse(out _, option | CanUseOption.EmptyOrSkipCombo).ToString()); - ImGui.Text("Must & Empty Use:" + action.CanUse(out _, option | CanUseOption.MustUseEmpty).ToString()); - if (action.Target != null) - { - ImGui.Text("Target Name: " + action.Target.Name); - } - } - catch - { - - } - } - }); - - public unsafe static void Display(this IBaseItem item, bool IsActive) - => item.DrawEnableTexture(IsActive, () => RotationConfigWindow.ActiveAction = item, - showToolTip: a => - { - if (!string.IsNullOrEmpty(a.Description)) ImGui.SetTooltip(a.Description); - }, otherThing: () => - { - if (Service.Config.ShowCooldownWindow) - { - var enable = item.IsInCooldown; - if (ImGui.Checkbox($"{LocalizationManager.RightLang.ConfigWindow_Actions_ShowOnCDWindow}##{item.Name}InCooldown", ref enable)) - { - item.IsInCooldown = enable; - Service.Config.Save(); - } - - ImGui.SameLine(); - Spacing(); - } - - OtherCommandType.DoActions.DisplayCommandHelp($"{item}-{5}", - type => string.Format(LocalizationManager.RightLang.ConfigWindow_Actions_InsertCommand, item, 5), false); - - - if (Service.Config.InDebug) - { - ImGui.Text("Status: " + ActionManager.Instance()->GetActionStatus(ActionType.Item, item.ID).ToString()); - ImGui.Text("Status HQ: " + ActionManager.Instance()->GetActionStatus(ActionType.Item, item.ID + 1000000).ToString()); - var remain = ActionManager.Instance()->GetRecastTime(ActionType.Item, item.ID) - ActionManager.Instance()->GetRecastTimeElapsed(ActionType.Item, item.ID); - ImGui.Text("remain: " + remain.ToString()); - ImGui.Text("CanUse: " + item.CanUse(out _, true).ToString()); - - if(item is HealPotionItem healPotionItem) - { - ImGui.Text("MaxHP:" + healPotionItem.MaxHealHp.ToString()); - } - } - }); - #endregion - public static void DisplayMacro(this MacroInfo info) { ImGui.SetNextItemWidth(50); @@ -746,159 +330,10 @@ public static void DisplayEvent(this ActionEventInfo info) info.DisplayMacro(); } - #region Rotation Config Display - internal static void Draw(this IRotationConfigSet set, bool canAddButton) - { - foreach (var config in set.Configs) - { - if (config is RotationConfigCombo c) c.Draw(set, canAddButton); - else if (config is RotationConfigBoolean b) b.Draw(set, canAddButton); - else if (config is RotationConfigFloat f) f.Draw(set, canAddButton); - else if (config is RotationConfigString s) s.Draw(set, canAddButton); - else if (config is RotationConfigInt i) i.Draw(set, canAddButton); - } - } - - static void Draw(this RotationConfigCombo config, IRotationConfigSet set, bool canAddButton) - { - var val = set.GetCombo(config.Name); - ImGui.SetNextItemWidth(ImGui.CalcTextSize(config.Items[val]).X + 50); - var name = $"{config.DisplayName}##{config.GetHashCode()}_{config.Name}"; - if (ImGui.BeginCombo(name, config.Items[val])) - { - for (int comboIndex = 0; comboIndex < config.Items.Length; comboIndex++) - { - if (ImGui.Selectable(config.Items[comboIndex])) - { - set.SetValue(config.Name, comboIndex.ToString()); - Service.Config.Save(); - } - if (canAddButton) - { - ImGui.SameLine(); - Spacing(); - OtherCommandType.Rotations.DisplayCommandHelp(config.Name + " " + comboIndex.ToString()); - - ImGui.SameLine(); - Spacing(); - OtherCommandType.Rotations.DisplayCommandHelp(config.Name + " " + config.Items[comboIndex]); - } - } - ImGui.EndCombo(); - } - HoveredString(LocalizationManager.RightLang.ConfigWindow_Rotation_KeyName + ": " + config.Name); - - var @default = int.TryParse(config.DefaultValue, out var f) ? f : 0; - if (val != @default) - { - UndoValue(name, ref val, @default); - } - - if (canAddButton) - { - ImGui.SameLine(); - Spacing(); - OtherCommandType.Rotations.DisplayCommandHelp(config.Name); - } - } - - static void Draw(this RotationConfigBoolean config, IRotationConfigSet set, bool canAddButton) - { - bool val = set.GetBool(config.Name); - - RotationConfigWindow.DrawCheckBox($"{config.DisplayName}##{config.GetHashCode()}_{config.DisplayName}", ref val, bool.TryParse(config.DefaultValue, out var f) ? f : false, LocalizationManager.RightLang.ConfigWindow_Rotation_KeyName + ": " + config.Name, () => - { - set.SetValue(config.Name, val.ToString()); - }); - - if (canAddButton) - { - ImGui.SameLine(); - Spacing(); - OtherCommandType.Rotations.DisplayCommandHelp(config.Name); - } - } - - static void Draw(this RotationConfigFloat config, IRotationConfigSet set, bool canAddButton) - { - float val = set.GetFloat(config.Name); - RotationConfigWindow.DrawFloatNumber($"{config.DisplayName}##{config.GetHashCode()}_{config.Name}", ref val, float.TryParse(config.DefaultValue, out var f) ? f : 0, config.Speed, config.Min, config.Max, otherThing: () => - { - set.SetValue(config.Name, val.ToString()); - }); - } - - static void Draw(this RotationConfigString config, IRotationConfigSet set, bool canAddButton) - { - string val = set.GetString(config.Name); - if (ImGui.InputText($"{config.DisplayName}##{config.GetHashCode()}_{config.Name}", ref val, 15)) - { - set.SetValue(config.Name, val); - Service.Config.Save(); - } - } - - static void Draw(this RotationConfigInt config, IRotationConfigSet set, bool canAddButton) - { - int val = set.GetInt(config.Name); - RotationConfigWindow.DrawIntNumber($"{config.DisplayName}##{config.GetHashCode()}_{config.Name}", ref val, int.TryParse(config.DefaultValue, out var f) ? f : 0, config.Speed, config.Min, config.Max, otherThing: () => - { - set.SetValue(config.Name, val.ToString()); - }); - } - #endregion - static readonly Vector2 PIC_SIZE = new(24, 24); const float ATTR_INDENT = 170; - public static void Display(this RotationDescAttribute attr, ICustomRotation rotation) - { - var acts = rotation.AllBaseActions; - - var allActions = attr.Actions.Select(i => acts.FirstOrDefault(a => a.ID == (uint)i)) - .Where(i => i != null); - - bool hasDesc = !string.IsNullOrEmpty(attr.Description); - - if (!hasDesc && !allActions.Any()) return; - ImGui.Separator(); - - ImGui.Image(IconSet.GetTexture(attr.IconID).ImGuiHandle, PIC_SIZE); - ImGui.SameLine(); - - var isOnCommand = attr.IsOnCommand; - if (isOnCommand) ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); - ImGui.Text(" " + attr.Type.ToName()); - if (isOnCommand) ImGui.PopStyleColor(); - - ImGui.SameLine(); - - ImGui.Indent(ATTR_INDENT); - - if (hasDesc) - { - ImGui.Text(attr.Description); - } - - bool notStart = false; - foreach (var item in allActions) - { - if (item == null) continue; - - if (notStart) - { - ImGui.SameLine(); - ImGui.Text(" "); - ImGui.SameLine(); - } - ControlWindow.DrawIAction(item.GetTexture().ImGuiHandle, 24, 1); - ImGuiHelper.HoveredString(item.Name); - - notStart = true; - } - ImGui.Unindent(ATTR_INDENT); - } public unsafe static ImFontPtr GetFont(float size) { diff --git a/RotationSolver/UI/ImguiTooltips.cs b/RotationSolver/UI/ImguiTooltips.cs index 35b2d1de9..0a09c1952 100644 --- a/RotationSolver/UI/ImguiTooltips.cs +++ b/RotationSolver/UI/ImguiTooltips.cs @@ -30,7 +30,7 @@ public static void ShowTooltip(string text) public static void ShowTooltip(Action act) { if (act == null) return; - if (!Service.Config.ShowTooltips) return; + if (!Service.Config.GetValue(Basic.Configuration.PluginConfigBool.ShowTooltips)) return; ImGui.SetNextWindowBgAlpha(1); ImGui.PushStyleColor(ImGuiCol.BorderShadow, ImGuiColors.DalamudWhite); diff --git a/RotationSolver/UI/InfoWindow.cs b/RotationSolver/UI/InfoWindow.cs index 1785a5e16..e19d13de4 100644 --- a/RotationSolver/UI/InfoWindow.cs +++ b/RotationSolver/UI/InfoWindow.cs @@ -1,4 +1,5 @@ using Dalamud.Interface.Windowing; +using RotationSolver.Basic.Configuration; namespace RotationSolver.UI; @@ -16,14 +17,14 @@ public InfoWindow(string name) public override void PreDraw() { - ImGui.PushStyleColor(ImGuiCol.WindowBg, Service.Config.InfoWindowBg); + ImGui.PushStyleColor(ImGuiCol.WindowBg, Service.Config.GetValue(PluginConfigVector4.InfoWindowBg)); Flags = BaseFlags; - if (Service.Config.IsInfoWindowNoInputs) + if (Service.Config.GetValue(PluginConfigBool.IsInfoWindowNoInputs)) { Flags |= ImGuiWindowFlags.NoInputs; } - if (Service.Config.IsInfoWindowNoMove) + if (Service.Config.GetValue(PluginConfigBool.IsInfoWindowNoMove)) { Flags |= ImGuiWindowFlags.NoMove; } diff --git a/RotationSolver/UI/NextActionWindow.cs b/RotationSolver/UI/NextActionWindow.cs index 1ca4871a7..c0a58118e 100644 --- a/RotationSolver/UI/NextActionWindow.cs +++ b/RotationSolver/UI/NextActionWindow.cs @@ -14,22 +14,23 @@ public NextActionWindow() public override void Draw() { - var width = Service.Config.ControlWindowGCDSize * Service.Config.ControlWindowNextSizeRatio; + var width = Service.Config.GetValue(PluginConfigFloat.ControlWindowGCDSize) + * Service.Config.GetValue(PluginConfigFloat.ControlWindowNextSizeRatio); DrawGcdCooldown(width, false); ControlWindow.DrawIAction(ActionUpdater.NextAction, width, 1); var strs = new List(3); - if(Service.Config.GetValue(SettingsCommand.UseAOEAction) + if(Service.Config.GetValue(PluginConfigBool.UseAOEAction) && (!DataCenter.IsManual - || Service.Config.GetValue(SettingsCommand.UseAOEWhenManual))) + || Service.Config.GetValue(PluginConfigBool.UseAOEWhenManual))) { strs.Add("AOE"); } - if (Service.Config.GetValue(SettingsCommand.PreventActions)) + if (Service.Config.GetValue(PluginConfigBool.PreventActions)) { strs.Add("Prevent"); } - if (Service.Config.GetValue(SettingsCommand.AutoBurst)) + if (Service.Config.GetValue(PluginConfigBool.AutoBurst)) { strs.Add("Burst"); } @@ -55,7 +56,7 @@ public static unsafe void DrawGcdCooldown(float width, bool drawTittle) } var cursor = ImGui.GetCursorPos() + ImGui.GetWindowPos(); - var height = Service.Config.ControlProgressHeight; + var height = Service.Config.GetValue(PluginConfigFloat.ControlProgressHeight); ImGui.ProgressBar(group->Elapsed / group->Total, new Vector2(width, height), string.Empty); diff --git a/RotationSolver/UI/PainterManager.cs b/RotationSolver/UI/PainterManager.cs index 5b1a08b12..9ea151c78 100644 --- a/RotationSolver/UI/PainterManager.cs +++ b/RotationSolver/UI/PainterManager.cs @@ -16,7 +16,7 @@ class TargetDrawing : Drawing3DPoly public TargetDrawing() { - var TColor = ImGui.GetColorU32(Service.Config.TargetColor); + var TColor = ImGui.GetColorU32(Service.Config.GetValue(Basic.Configuration.PluginConfigVector4.TargetColor)); _target = new Drawing3DCircularSector(default, 0, TColor, 3) { IsFill = false, @@ -32,7 +32,7 @@ public override void UpdateOnFrame(XIVPainter.XIVPainter painter) { SubItems = Array.Empty(); - if (!Service.Config.ShowTarget) return; + if (!Service.Config.GetValue(Basic.Configuration.PluginConfigBool.ShowTarget)) return; if (ActionUpdater.NextAction is not BaseAction act) return; @@ -42,15 +42,15 @@ public override void UpdateOnFrame(XIVPainter.XIVPainter painter) var ratio = (float)DrawingExtensions.EaseFuncRemap(EaseFuncType.None, EaseFuncType.Cubic)(d); List subItems = new List(); - if(Service.Config.TargetIconSize > 0) + if(Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.TargetIconSize) > 0) { _targetImage.Position = act.IsTargetArea ? act.Position : act.Target.Position; - _targetImage.SetTexture(act.GetTexture(true), Service.Config.TargetIconSize); + if(act.GetTexture(out var texture, true)) _targetImage.SetTexture(texture, Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.TargetIconSize)); subItems.Add(_targetImage); } else { - _target.Color = ImGui.GetColorU32(Service.Config.TargetColor); + _target.Color = ImGui.GetColorU32(Service.Config.GetValue(Basic.Configuration.PluginConfigVector4.TargetColor)); _target.Center = act.IsTargetArea ? act.Position : act.Target.Position; _target.Radius = targetRadius * ratio; subItems.Add(_target); @@ -58,7 +58,7 @@ public override void UpdateOnFrame(XIVPainter.XIVPainter painter) if (DataCenter.HostileTargets.Contains(act.Target) || act.Target == Player.Object && !act.IsFriendly) { - var SColor = ImGui.GetColorU32(Service.Config.SubTargetColor); + var SColor = ImGui.GetColorU32(Service.Config.GetValue(Basic.Configuration.PluginConfigVector4.SubTargetColor)); foreach (var t in DataCenter.HostileTargets) { @@ -100,7 +100,7 @@ public override void UpdateOnFrame(XIVPainter.XIVPainter painter) ((Drawing3DText)SubItems[i]).Text = string.Empty; } - if (!Service.Config.ShowHealthRatio) return; + if (!Service.Config.GetValue(Basic.Configuration.PluginConfigBool.ShowHealthRatio)) return; var calHealth = (double)ObjectHelper.GetHealthFromMulty(1); @@ -138,17 +138,17 @@ public static void Init() _highLight = new(); - _painter.DrawingHeight = Service.Config.DrawingHeight; - _painter.SampleLength = Service.Config.SampleLength; - _painter.Enable = Service.Config.UseOverlayWindow; - HighlightColor = Service.Config.TeachingModeColor; + _painter.DrawingHeight = Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.DrawingHeight); + _painter.SampleLength = Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.SampleLength); + _painter.Enable = Service.Config.GetValue(Basic.Configuration.PluginConfigBool.UseOverlayWindow); + HighlightColor = Service.Config.GetValue(Basic.Configuration.PluginConfigVector4.TeachingModeColor); - var annulus = new Drawing3DAnnulusO(Player.Object, 3, 3 + Service.Config.MeleeRangeOffset, 0, 2); + var annulus = new Drawing3DAnnulusO(Player.Object, 3, 3 + Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.MeleeRangeOffset), 0, 2); annulus.InsideColor = ImGui.ColorConvertFloat4ToU32(new Vector4(0.8f, 0.3f, 0.2f, 0.15f)); annulus.UpdateEveryFrame = () => { - if (Player.Available && (Player.Object.IsJobCategory(JobRole.Tank) || Player.Object.IsJobCategory(JobRole.Melee)) && (Svc.Targets.Target?.IsNPCEnemy() ?? false) && Service.Config.DrawMeleeOffset + if (Player.Available && (Player.Object.IsJobCategory(JobRole.Tank) || Player.Object.IsJobCategory(JobRole.Melee)) && (Svc.Targets.Target?.IsNPCEnemy() ?? false) && Service.Config.GetValue(Basic.Configuration.PluginConfigBool.DrawMeleeOffset) && ActionUpdater.NextGCDAction == null) { annulus.Target = Svc.Targets.Target; @@ -159,13 +159,13 @@ public static void Init() } }; - var color = ImGui.GetColorU32(Service.Config.MovingTargetColor); + var color = ImGui.GetColorU32(Service.Config.GetValue(Basic.Configuration.PluginConfigVector4.MovingTargetColor)); var movingTarget = new Drawing3DHighlightLine(default, default, 0, color, 3); movingTarget.UpdateEveryFrame = () => { var tar = CustomRotation.MoveTarget; - if (!Service.Config.ShowMoveTarget || !Player.Available || !tar.HasValue || Vector3.Distance(tar.Value, Player.Object.Position) < 0.01f) + if (!Service.Config.GetValue(Basic.Configuration.PluginConfigBool.ShowMoveTarget) || !Player.Available || !tar.HasValue || Vector3.Distance(tar.Value, Player.Object.Position) < 0.01f) { movingTarget.Radius = 0; return; @@ -173,7 +173,7 @@ public static void Init() movingTarget.Radius = 0.5f; - movingTarget.Color = ImGui.GetColorU32(Service.Config.MovingTargetColor); + movingTarget.Color = ImGui.GetColorU32(Service.Config.GetValue(Basic.Configuration.PluginConfigVector4.MovingTargetColor)); movingTarget.From = Player.Object.Position; movingTarget.To = tar.Value; diff --git a/RotationSolver/UI/RotationConfigWindowNew.cs b/RotationSolver/UI/RotationConfigWindowNew.cs index 834538c1c..8ffd0ce40 100644 --- a/RotationSolver/UI/RotationConfigWindowNew.cs +++ b/RotationSolver/UI/RotationConfigWindowNew.cs @@ -19,6 +19,7 @@ using RotationSolver.UI.SearchableSettings; using RotationSolver.Updaters; using System.Diagnostics; +using System.Windows.Forms; using GAction = Lumina.Excel.GeneratedSheets.Action; namespace RotationSolver.UI; @@ -26,7 +27,7 @@ namespace RotationSolver.UI; public partial class RotationConfigWindowNew : Window { private static float _scale => ImGuiHelpers.GlobalScale; - private static Job Job => RotationUpdater.Job; + private static Job Job => DataCenter.Job; private RotationConfigWindowTab _activeTab; @@ -213,7 +214,7 @@ private void DrawHeader(float wholeWidth) var size = MathF.Max(MathF.Min(wholeWidth, _scale * 120), _scale * MIN_COLUMN_WIDTH); int realFrame = FRAME_COUNT; - if (Service.ConfigNew.GetValue(PluginConfigBool.DrawIconAnimation)) + if (Service.Config.GetValue(PluginConfigBool.DrawIconAnimation)) { var frame = Environment.TickCount / 34; //30 realFrame = frame % FRAME_COUNT; @@ -320,7 +321,7 @@ private static void DrawRotationCombo(float comboSize, ICustomRotation[] rotatio ImGui.PushStyleColor(ImGuiCol.Text, r.GetColor()); if (ImGui.Selectable(r.RotationName)) { - Service.Config.RotationChoices[rotation.ClassJob.RowId] = r.GetType().FullName; + Service.Config.GetJobConfig(Job).RotationChoice = r.GetType().FullName; Service.Config.Save(); } ImguiTooltips.HoveredTooltip(r.Description); @@ -740,9 +741,9 @@ private static void DrawRotationStatus() RotationUpdater.RightNowRotation?.DisplayStatus(); } - private static string ToCommandStr(string str, string extra = "") + private static string ToCommandStr(OtherCommandType type, string str, string extra = "") { - var result = Service.Command + " " + OtherCommandType.Rotations.ToString() + " " + str; + var result = Service.Command + " " + type.ToString() + " " + str; if (!string.IsNullOrEmpty(extra)) result += " " + extra; return result; } @@ -756,7 +757,7 @@ private static void DrawRotationConfiguration() { var key = config.Name; var name = $"##{config.GetHashCode()}_{config.Name}"; - string command = ToCommandStr(config.Name, config.DefaultValue); + string command = ToCommandStr(OtherCommandType.Rotations,config.Name, config.DefaultValue); void Reset() => set.SetValue(config.Name, config.DefaultValue); Searchable.PrepareGroup(key, command, Reset); @@ -766,7 +767,7 @@ private static void DrawRotationConfiguration() var val = set.GetCombo(c.Name); ImGui.SetNextItemWidth(ImGui.CalcTextSize(c.Items[val]).X + 50 * _scale); var openCombo = ImGui.BeginCombo(name, c.Items[val]); - if (ImGui.IsItemHovered()) Searchable.ReactPopup(key, command, Reset); + Searchable.ReactPopup(key, command, Reset); if (openCombo) { for (int comboIndex = 0; comboIndex < c.Items.Length; comboIndex++) @@ -787,7 +788,7 @@ private static void DrawRotationConfiguration() { set.SetValue(config.Name, val.ToString()); } - if (ImGui.IsItemHovered()) Searchable.ReactPopup(key, command, Reset); + Searchable.ReactPopup(key, command, Reset); } else if (config is RotationConfigFloat f) { @@ -797,7 +798,7 @@ private static void DrawRotationConfiguration() { set.SetValue(config.Name, val.ToString()); } - if (ImGui.IsItemHovered()) Searchable.ReactPopup(key, command, Reset); + Searchable.ReactPopup(key, command, Reset); } else if (config is RotationConfigString s) { @@ -808,7 +809,7 @@ private static void DrawRotationConfiguration() { set.SetValue(config.Name, val.ToString()); } - if (ImGui.IsItemHovered()) Searchable.ReactPopup(key, command, Reset); + Searchable.ReactPopup(key, command, Reset); continue; } else if (config is RotationConfigInt i) @@ -819,13 +820,13 @@ private static void DrawRotationConfiguration() { set.SetValue(config.Name, val.ToString()); } - if (ImGui.IsItemHovered()) Searchable.ReactPopup(key, command, Reset); + Searchable.ReactPopup(key, command, Reset); } else continue; ImGui.SameLine(); ImGui.TextWrapped(config.DisplayName); - if (ImGui.IsItemHovered()) Searchable.ReactPopup(key, command, Reset, false); + Searchable.ReactPopup(key, command, Reset, false); } } @@ -904,7 +905,6 @@ private static unsafe void DrawActions() { _activeAction = item; } - ImguiTooltips.HoveredTooltip(item.Name); DrawActionOverlay(cursor, size, _activeAction == item ? 1 : 0); if(IconSet.GetTexture("ui/uld/readycheck_hr1.tex", out var texture)) @@ -916,6 +916,11 @@ private static unsafe void DrawActions() new Vector2(item.IsEnabled ? 0.5f : 1, 1) - offset); } ImGui.EndGroup(); + + string key = $"Action Macro Usage{item.Name} {item.ID}"; + var cmd = ToCommandStr(OtherCommandType.DoActions, $"{_activeAction}-{5}"); + Searchable.DrawHotKeysPopup(key, cmd); + Searchable.ExecuteHotKeysPopup(key, cmd, item.Name, false); } }); } @@ -927,7 +932,7 @@ private static unsafe void DrawActions() ImGui.TableNextColumn(); - if (Service.ConfigNew.GetValue(PluginConfigBool.InDebug)) + if (Service.Config.GetValue(PluginConfigBool.InDebug)) { if(_activeAction is IBaseAction action) { @@ -982,6 +987,8 @@ private static unsafe void DrawActions() } } + ActionSequencerUpdater.DrawHeader(30 * _scale); + if (_sequencerList != null && _activeAction != null && BeginChild("Rotation Solver Sequencer List")) { var enable = _activeAction.IsEnabled; @@ -990,8 +997,10 @@ private static unsafe void DrawActions() _activeAction.IsEnabled = enable; } - ImGui.SameLine(); - OtherCommandType.ToggleActions.DisplayCommandHelp(_activeAction.ToString()); + const string key = "Action Enable Popup"; + var cmd = ToCommandStr(OtherCommandType.ToggleActions, _activeAction.ToString()); + Searchable.DrawHotKeysPopup(key, cmd); + Searchable.ExecuteHotKeysPopup(key, cmd, string.Empty, false); enable = _activeAction.IsInCooldown; if (ImGui.Checkbox($"{LocalizationManager.RightLang.ConfigWindow_Actions_ShowOnCDWindow}##{_activeAction.Name}InCooldown", ref enable)) @@ -999,10 +1008,6 @@ private static unsafe void DrawActions() _activeAction.IsInCooldown = enable; } - ImGui.SameLine(); - OtherCommandType.DoActions.DisplayCommandHelp($"{_activeAction}-{5}", - type => string.Format(LocalizationManager.RightLang.ConfigWindow_Actions_InsertCommand, _activeAction, 5), false); - _sequencerList.Draw(); ImGui.EndChild(); } @@ -1083,8 +1088,8 @@ private static void DrawRotations() private static void DrawRotationsSettings() { - _updateRotation?.Draw(RotationUpdater.Job); - _autoLoadRotations?.Draw(RotationUpdater.Job); + _updateRotation?.Draw(Job); + _autoLoadRotations?.Draw(Job); } private static void DrawRotationsLoaded() @@ -1174,17 +1179,17 @@ private static void DrawGitHubBadge(string userName, string repository, string i private static void DrawRotationsGitHub() { - if (!Service.ConfigNew.GlobalConfig.GitHubLibs.Any(s => string.IsNullOrEmpty(s) || s == "||")) + if (!Service.Config.GlobalConfig.GitHubLibs.Any(s => string.IsNullOrEmpty(s) || s == "||")) { - Service.ConfigNew.GlobalConfig.GitHubLibs = Service.ConfigNew.GlobalConfig.GitHubLibs.Append("||").ToArray(); + Service.Config.GlobalConfig.GitHubLibs = Service.Config.GlobalConfig.GitHubLibs.Append("||").ToArray(); } ImGui.Spacing(); int removeIndex = -1; - for (int i = 0; i < Service.ConfigNew.GlobalConfig.GitHubLibs.Length; i++) + for (int i = 0; i < Service.Config.GlobalConfig.GitHubLibs.Length; i++) { - var strs = Service.ConfigNew.GlobalConfig.GitHubLibs[i].Split('|'); + var strs = Service.Config.GlobalConfig.GitHubLibs[i].Split('|'); var userName = strs.FirstOrDefault() ?? string.Empty; var repository = strs.Length > 1 ? strs[1] : string.Empty; var fileName = strs.LastOrDefault() ?? string.Empty; @@ -1210,7 +1215,7 @@ private static void DrawRotationsGitHub() if(changed) { - Service.ConfigNew.GlobalConfig.GitHubLibs[i] = $"{userName}|{repository}|{fileName}"; + Service.Config.GlobalConfig.GitHubLibs[i] = $"{userName}|{repository}|{fileName}"; } if (ImGuiHelper.IconButton(FontAwesomeIcon.Ban, $"##Rotation Solver Remove GitHubLibs{i}")) @@ -1220,17 +1225,17 @@ private static void DrawRotationsGitHub() } if (removeIndex > -1) { - var list = Service.ConfigNew.GlobalConfig.GitHubLibs.ToList(); + var list = Service.Config.GlobalConfig.GitHubLibs.ToList(); list.RemoveAt(removeIndex); - Service.ConfigNew.GlobalConfig.GitHubLibs = list.ToArray(); + Service.Config.GlobalConfig.GitHubLibs = list.ToArray(); } } private static void DrawRotationsLibraries() { - if (!Service.ConfigNew.GlobalConfig.OtherLibs.Any(string.IsNullOrEmpty)) + if (!Service.Config.GlobalConfig.OtherLibs.Any(string.IsNullOrEmpty)) { - Service.ConfigNew.GlobalConfig.OtherLibs = Service.ConfigNew.GlobalConfig.OtherLibs.Append(string.Empty).ToArray(); + Service.Config.GlobalConfig.OtherLibs = Service.Config.GlobalConfig.OtherLibs.Append(string.Empty).ToArray(); } ImGui.Spacing(); @@ -1238,10 +1243,10 @@ private static void DrawRotationsLibraries() var width = ImGui.GetWindowWidth() - ImGuiEx.CalcIconSize(FontAwesomeIcon.Ban).X - ImGui.GetStyle().ItemSpacing.X - 10 * _scale; int removeIndex = -1; - for (int i = 0; i < Service.ConfigNew.GlobalConfig.OtherLibs.Length; i++) + for (int i = 0; i < Service.Config.GlobalConfig.OtherLibs.Length; i++) { ImGui.SetNextItemWidth(width); - ImGui.InputTextWithHint($"##Rotation Solver OtherLib{i}", LocalizationManager.RightLang.ConfigWindow_Rotations_Library, ref Service.ConfigNew.GlobalConfig.OtherLibs[i], 1024); + ImGui.InputTextWithHint($"##Rotation Solver OtherLib{i}", LocalizationManager.RightLang.ConfigWindow_Rotations_Library, ref Service.Config.GlobalConfig.OtherLibs[i], 1024); ImGui.SameLine(); if (ImGuiHelper.IconButton(FontAwesomeIcon.Ban, $"##Rotation Solver Remove OtherLibs{i}")) @@ -1251,9 +1256,9 @@ private static void DrawRotationsLibraries() } if (removeIndex > -1) { - var list = Service.ConfigNew.GlobalConfig.OtherLibs.ToList(); + var list = Service.Config.GlobalConfig.OtherLibs.ToList(); list.RemoveAt(removeIndex); - Service.ConfigNew.GlobalConfig.OtherLibs = list.ToArray(); + Service.Config.GlobalConfig.OtherLibs = list.ToArray(); } } #endregion @@ -1320,7 +1325,7 @@ private static void DrawList() private static readonly CollapsingHeaderGroup _idsHeader = new(new() { { () => LocalizationManager.RightLang.ConfigWindow_List_Statuses, DrawActionsStatuses}, - { () => Service.ConfigNew.GetValue(PluginConfigBool.UseDefenseAbility) ? LocalizationManager.RightLang.ConfigWindow_List_Actions : string.Empty, DrawListActions}, + { () => Service.Config.GetValue(PluginConfigBool.UseDefenseAbility) ? LocalizationManager.RightLang.ConfigWindow_List_Actions : string.Empty, DrawListActions}, { () => LocalizationManager.RightLang.ConfigWindow_List_Territories, DrawListTerritories}, }); private static void DrawActionsStatuses() @@ -1342,9 +1347,14 @@ private static void DrawActionsStatuses() ImGui.TableNextRow(); ImGui.TableNextColumn(); + + ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_InvincibilityDesc); DrawStatusList(nameof(OtherConfiguration.InvincibleStatus), OtherConfiguration.InvincibleStatus, AllInvStatus); ImGui.TableNextColumn(); + + ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_DangerousStatusDesc); + DrawStatusList(nameof(OtherConfiguration.DangerousStatus), OtherConfiguration.DangerousStatus, AllDispelStatus); ImGui.EndTable(); @@ -1384,16 +1394,8 @@ private static void DrawStatusList(string name, HashSet statuses, Status[] var key = "Status" + status.RowId; - if (ImGui.BeginPopup(key)) - { - if (ImGui.BeginTable(key, 2, ImGuiTableFlags.BordersOuter)) - { - Searchable.DrawHotKeys(LocalizationManager.RightLang.ConfigWindow_List_Remove, Reset, "Delete"); - ImGui.EndTable(); - } + Searchable.DrawHotKeysPopup(key, string.Empty, (LocalizationManager.RightLang.ConfigWindow_List_Remove, Reset, new string[] { "Delete" })); - ImGui.EndPopup(); - } if (IconSet.GetTexture(status.Icon, out var texture, notLoadId)) { if (index++ % count != 0) @@ -1402,15 +1404,7 @@ private static void DrawStatusList(string name, HashSet statuses, Status[] } NoPaddingNoColorImageButton(texture.ImGuiHandle, new Vector2(24, 32) * _scale, "Status" + status.RowId.ToString()); - if (ImGui.IsItemHovered()) - { - ImguiTooltips.ShowTooltip($"{status.Name} ({status.RowId})"); - if (ImGui.IsMouseClicked(ImGuiMouseButton.Right) && !ImGui.IsPopupOpen(key)) - { - ImGui.OpenPopup(key); - } - Searchable.ExecuteHotKeys(Reset, Dalamud.Game.ClientState.Keys.VirtualKey.DELETE); - } + Searchable.ExecuteHotKeysPopup(key, string.Empty, $"{status.Name} ({status.RowId})", false, (Reset, new Dalamud.Game.ClientState.Keys.VirtualKey[] { Dalamud.Game.ClientState.Keys.VirtualKey.DELETE })); } } @@ -1458,6 +1452,10 @@ private static void DrawStatusList(string name, HashSet statuses, Status[] } } + private static readonly ISearchable[] _listSearchable = new ISearchable[] + { + new CheckBoxSearchPlugin(PluginConfigBool.RecordCastingArea), + }; private static void DrawListActions() { ImGui.SetNextItemWidth(ImGui.GetWindowWidth()); @@ -1477,9 +1475,16 @@ private static void DrawListActions() ImGui.TableNextRow(); ImGui.TableNextColumn(); + ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_HostileCastingTankDesc); DrawActionsList(nameof(OtherConfiguration.HostileCastingTank), OtherConfiguration.HostileCastingTank); ImGui.TableNextColumn(); + foreach (var searchable in _listSearchable) + { + searchable?.Draw(Job); + } + ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_HostileCastingAreaDesc); + DrawActionsList(nameof(OtherConfiguration.HostileCastingArea), OtherConfiguration.HostileCastingArea); ImGui.EndTable(); @@ -1510,26 +1515,11 @@ private static void DrawActionsList(string name, HashSet actions) var key = "Action" + action.RowId; - if (ImGui.BeginPopup(key)) - { - if (ImGui.BeginTable(key, 2, ImGuiTableFlags.BordersOuter)) - { - Searchable.DrawHotKeys(LocalizationManager.RightLang.ConfigWindow_List_Remove, Reset, "Delete"); - ImGui.EndTable(); - } - - ImGui.EndPopup(); - } + Searchable.DrawHotKeysPopup(key, string.Empty, (LocalizationManager.RightLang.ConfigWindow_List_Remove, Reset, new string[] { "Delete" })); ImGui.Selectable($"{action.Name} ({action.RowId})"); - if (ImGui.IsItemHovered()) - { - if (ImGui.IsMouseClicked(ImGuiMouseButton.Right) && !ImGui.IsPopupOpen(key)) - { - ImGui.OpenPopup(key); - } - Searchable.ExecuteHotKeys(Reset, Dalamud.Game.ClientState.Keys.VirtualKey.DELETE); - } + + Searchable.ExecuteHotKeysPopup(key, string.Empty, string.Empty, false, (Reset, new Dalamud.Game.ClientState.Keys.VirtualKey[] { Dalamud.Game.ClientState.Keys.VirtualKey.DELETE })); } @@ -1632,6 +1622,8 @@ private static void DrawListTerritories() ImGui.TableNextColumn(); + ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_NoHostileDesc); + var width = ImGui.GetColumnWidth() - ImGuiEx.CalcIconSize(FontAwesomeIcon.Ban).X - ImGui.GetStyle().ItemSpacing.X - 10 * _scale; if(!OtherConfiguration.NoHostileNames.TryGetValue(_territoryId, out var libs)) @@ -1686,7 +1678,8 @@ private static void DrawDebug() searchable?.Draw(Job); } - if (!Player.Available || !Service.ConfigNew.GetValue(PluginConfigBool.InDebug)) return; + if (!Player.Available || !Service.Config.GetValue(PluginConfigBool.InDebug)) return; + var str = SocialUpdater.EncryptString(Player.Object); ImGui.SetNextItemWidth(ImGui.CalcTextSize(str).X + 10); @@ -1821,8 +1814,6 @@ private static void DrawNextAction() ImGui.Text("Action Remain: " + DataCenter.ActionRemain.ToString()); ImGui.Text("Weapon Remain: " + DataCenter.WeaponRemain.ToString()); ImGui.Text("Time: " + (DataCenter.CombatTimeRaw + DataCenter.WeaponRemain).ToString()); - - ActionUpdater.NextAction?.Display(false); } private static void DrawLastAction() diff --git a/RotationSolver/UI/RotationConfigWindowNew_Config.cs b/RotationSolver/UI/RotationConfigWindowNew_Config.cs index 2e75171e9..5e1078617 100644 --- a/RotationSolver/UI/RotationConfigWindowNew_Config.cs +++ b/RotationSolver/UI/RotationConfigWindowNew_Config.cs @@ -314,6 +314,13 @@ private static void DrawAuto() JobRole.RangedPhysical, } }, + new DragFloatSearchJob(JobConfigFloat.HealthForDyingTanks, 0.02f) + { + JobRoles = new JobRole[] + { + JobRole.Tank, + } + }, new DragFloatSearchPlugin(PluginConfigFloat.HealthDifference, 0.02f)), new CheckBoxSearchPlugin(PluginConfigBool.InterruptibleMoreCheck) @@ -483,7 +490,12 @@ private static void DrawTarget() }); private static readonly ISearchable[] _targetSearchable = new ISearchable[] -{ + { + new DragIntSearchJob(JobConfigInt.HostileType, + LocalizationManager.RightLang.ConfigWindow_Param_TargetToHostileType1, + LocalizationManager.RightLang.ConfigWindow_Param_TargetToHostileType2, + LocalizationManager.RightLang.ConfigWindow_Param_TargetToHostileType3 ), + new CheckBoxSearchPlugin(PluginConfigBool.AddEnemyListToHostile), new CheckBoxSearchPlugin(PluginConfigBool.ChooseAttackMark, new ISearchable[] { @@ -495,6 +507,7 @@ private static void DrawTarget() new CheckBoxSearchPlugin(PluginConfigBool.OnlyAttackInView), new CheckBoxSearchPlugin(PluginConfigBool.MoveTowardsScreenCenter), + new CheckBoxSearchPlugin(PluginConfigBool.MoveAreaActionFarthest), new DragIntSearchPlugin(PluginConfigInt.MoveTargetAngle, 0.02f), new DragFloatSearchPlugin(PluginConfigFloat.DistanceForMoving, 1f), @@ -504,51 +517,51 @@ private static void DrawTarget() new CheckBoxSearchPlugin(PluginConfigBool.TargetQuestPriority), new CheckBoxSearchPlugin(PluginConfigBool.SwitchTargetFriendly), -}; + }; private static void DrawTargetHostile() { if (ImGuiEx.IconButton(FontAwesomeIcon.Plus, "Add Hostile")) { - Service.Config.TargetingTypes.Add(TargetingType.Big); + Service.Config.GlobalConfig.TargetingTypes.Add(TargetingType.Big); } ImGui.SameLine(); ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_Param_HostileDesc); ImGui.Separator(); - for (int i = 0; i < Service.Config.TargetingTypes.Count; i++) + for (int i = 0; i < Service.Config.GlobalConfig.TargetingTypes.Count; i++) { ImGui.Separator(); var names = Enum.GetNames(typeof(TargetingType)); - var targingType = (int)Service.Config.TargetingTypes[i]; + var targingType = (int)Service.Config.GlobalConfig.TargetingTypes[i]; ImGui.SetNextItemWidth(150); if (ImGui.Combo(LocalizationManager.RightLang.ConfigWindow_Param_HostileCondition + "##HostileCondition" + i.ToString(), ref targingType, names, names.Length)) { - Service.Config.TargetingTypes[i] = (TargetingType)targingType; + Service.Config.GlobalConfig.TargetingTypes[i] = (TargetingType)targingType; } if (ImGuiHelper.IconButton(FontAwesomeIcon.ArrowUp, $"##HostileUp{i}")) { if (i > 0) { - var value = Service.Config.TargetingTypes[i]; - Service.Config.TargetingTypes.RemoveAt(i); - Service.Config.TargetingTypes.Insert(i - 1, value); + var value = Service.Config.GlobalConfig.TargetingTypes[i]; + Service.Config.GlobalConfig.TargetingTypes.RemoveAt(i); + Service.Config.GlobalConfig.TargetingTypes.Insert(i - 1, value); } } ImGui.SameLine(); ImGuiHelper.Spacing(); if (ImGuiHelper.IconButton(FontAwesomeIcon.ArrowDown, $"##HostileDown{i}")) { - if (i < Service.Config.TargetingTypes.Count - 1) + if (i < Service.Config.GlobalConfig.TargetingTypes.Count - 1) { - var value = Service.Config.TargetingTypes[i]; - Service.Config.TargetingTypes.RemoveAt(i); - Service.Config.TargetingTypes.Insert(i + 1, value); + var value = Service.Config.GlobalConfig.TargetingTypes[i]; + Service.Config.GlobalConfig.TargetingTypes.RemoveAt(i); + Service.Config.GlobalConfig.TargetingTypes.Insert(i + 1, value); } } @@ -557,7 +570,7 @@ private static void DrawTargetHostile() if (ImGuiHelper.IconButton(FontAwesomeIcon.Ban, $"##HostileDelete{i}")) { - Service.Config.TargetingTypes.RemoveAt(i); + Service.Config.GlobalConfig.TargetingTypes.RemoveAt(i); } } } @@ -626,7 +639,7 @@ private static void DrawEventTab() { if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Events_AddEvent)) { - Service.Config.Events.Add(new ActionEventInfo()); + Service.Config.GlobalConfig.Events.Add(new ActionEventInfo()); Service.Config.Save(); } ImGui.SameLine(); @@ -637,17 +650,17 @@ private static void DrawEventTab() ImGui.Text(LocalizationManager.RightLang.ConfigWindow_Events_DutyStart); ImGui.SameLine(); ImGuiHelper.Spacing(); - Service.Config.DutyStart.DisplayMacro(); + Service.Config.GlobalConfig.DutyStart.DisplayMacro(); ImGui.Text(LocalizationManager.RightLang.ConfigWindow_Events_DutyEnd); ImGui.SameLine(); ImGuiHelper.Spacing(); - Service.Config.DutyEnd.DisplayMacro(); + Service.Config.GlobalConfig.DutyEnd.DisplayMacro(); ImGui.Separator(); ActionEventInfo remove = null; - foreach (var eve in Service.Config.Events) + foreach (var eve in Service.Config.GlobalConfig.Events) { eve.DisplayEvent(); @@ -662,7 +675,7 @@ private static void DrawEventTab() } if (remove != null) { - Service.Config.Events.Remove(remove); + Service.Config.GlobalConfig.Events.Remove(remove); Service.Config.Save(); } } diff --git a/RotationSolver/UI/RotationConfigWindow_Action.cs b/RotationSolver/UI/RotationConfigWindow_Action.cs deleted file mode 100644 index d7e959643..000000000 --- a/RotationSolver/UI/RotationConfigWindow_Action.cs +++ /dev/null @@ -1,86 +0,0 @@ -using Dalamud.Interface.Colors; -using RotationSolver.ActionSequencer; -using RotationSolver.Localization; -using RotationSolver.Updaters; - -namespace RotationSolver.UI; -internal partial class RotationConfigWindow -{ - internal static IAction ActiveAction { get; set; } - - private static void DrawActionTab() - { - ImGui.Columns(2); - - DrawActionList(); - - ImGui.NextColumn(); - - DrawActionSequencerCondition(); - - ImGui.Columns(1); - } - - private static void DrawActionList() - { - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_ActionItem_Description); - - ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f)); - - if (ImGui.BeginChild("Action List", new Vector2(0f, -1f), true)) - { - if (RotationUpdater.RightNowRotation != null) - foreach (var pair in RotationUpdater.AllGroupedActions) - { - if (ImGui.CollapsingHeader(pair.Key)) - { - foreach (var item in pair.OrderBy(t => t.ID)) - { - item.Display(ActiveAction == item); - ImGui.Separator(); - } - } - } - - ImGui.EndChild(); - } - ImGui.PopStyleVar(); - } - - private static void DrawActionSequencerCondition() - { - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_Actions_Description); - - var rotation = RotationUpdater.RightNowRotation; - if (rotation == null) return; - - ActionSequencerUpdater.DrawHeader(); - - if (ActiveAction == null) return; - if (!RotationUpdater.RightRotationActions.Any(a => a.ID == ActiveAction.ID)) return; - - var set = ActionSequencerUpdater.RightSet; - if (set == null) return; - - ImGui.SameLine(); - ImGui.TextColored(ImGuiColors.DalamudYellow, ActiveAction.Name); - - if (ImGui.CollapsingHeader(LocalizationManager.RightLang.ConfigWindow_Actions_ForcedConditionSet)) - { - if (!set.Conditions.TryGetValue(ActiveAction.ID, out var conditionSet)) - { - conditionSet = set.Conditions[ActiveAction.ID] = new ConditionSet(); - } - conditionSet?.Draw(rotation); - } - - if (ImGui.CollapsingHeader(LocalizationManager.RightLang.ConfigWindow_Actions_DisabledConditionSet)) - { - if (!set.DiabledConditions.TryGetValue(ActiveAction.ID, out var disableConditionSet)) - { - disableConditionSet = set.DiabledConditions[ActiveAction.ID] = new ConditionSet(); - } - disableConditionSet?.Draw(rotation); - } - } -} diff --git a/RotationSolver/UI/RotationConfigWindow_Control.cs b/RotationSolver/UI/RotationConfigWindow_Control.cs deleted file mode 100644 index 85af77ab2..000000000 --- a/RotationSolver/UI/RotationConfigWindow_Control.cs +++ /dev/null @@ -1,108 +0,0 @@ -using RotationSolver.Localization; - -namespace RotationSolver.UI; - -internal partial class RotationConfigWindow -{ - private static void DrawControlTab() - { - ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f)); - - if (ImGui.BeginChild("Action List", new Vector2(0f, -1f), true)) - { - //if (Service.Config.ShowNextActionWindow || Service.Config.ShowCooldownWindow || Service.Config.ShowControlWindow) - //{ - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_OnlyShowWithHostileOrInDuty, - // ref Service.Config.OnlyShowWithHostileOrInDuty, Service.Default.OnlyShowWithHostileOrInDuty); - //} - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowNextActionWindow, - // ref Service.Config.ShowNextActionWindow, Service.Default.ShowNextActionWindow); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowCooldownWindow, - // ref Service.Config.ShowCooldownWindow, Service.Default.ShowCooldownWindow); - - //if (Service.Config.ShowNextActionWindow || Service.Config.ShowCooldownWindow) - //{ - //DrawColor4(LocalizationManager.RightLang.ConfigWindow_Control_InfoWindowBg, - // ref Service.Config.InfoWindowBg, Service.Default.InfoWindowBg); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsInfoWindowNoInputs + "##Info", - // ref Service.Config.IsInfoWindowNoInputs, Service.Default.IsInfoWindowNoInputs); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsInfoWindowNoMove, - //ref Service.Config.IsInfoWindowNoMove, Service.Default.IsInfoWindowNoMove); - - //if (Service.Config.ShowCooldownWindow) - //{ - // //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowItemsCooldown, - // ref Service.Config.ShowItemsCooldown, Service.Default.ShowItemsCooldown); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowGCDCooldown, - // ref Service.Config.ShowGCDCooldown, Service.Default.ShowGCDCooldown); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_UseOriginalCooldown, - // ref Service.Config.UseOriginalCooldown, Service.Default.UseOriginalCooldown); - - //DrawIntNumber(LocalizationManager.RightLang.ConfigWindow_Control_CooldownActionOneLine, ref Service.Config.CooldownActionOneLine, Service.Default.CooldownActionOneLine, min: 1, max: 30); - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_CooldownFontSize, ref Service.Config.CooldownFontSize, Service.Default.CooldownFontSize, speed: 0.1f, min: 9.6f, max: 96); - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_CooldownWindowIconSize, - //ref Service.Config.CooldownWindowIconSize, Service.Default.CooldownWindowIconSize, speed: 0.2f, max: 80); - // } - //} - - //ImGui.Separator(); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowControlWindow, - // ref Service.Config.ShowControlWindow, Service.Default.ShowControlWindow); - - //if (Service.Config.ShowControlWindow) - //{ - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsInfoWindowNoMove + "##Control", - // ref Service.Config.IsControlWindowLock, Service.Default.IsControlWindowLock); - - // if (Service.Config.IsControlWindowLock) - // { - // DrawColor4(LocalizationManager.RightLang.ConfigWindow_Control_BackgroundColor, - // ref Service.Config.ControlWindowLockBg, Service.Default.ControlWindowLockBg); - // } - // else - // { - // DrawColor4(LocalizationManager.RightLang.ConfigWindow_Control_BackgroundColor, - // ref Service.Config.ControlWindowUnlockBg, Service.Default.ControlWindowUnlockBg); - // } - - // DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_ControlWindowGCDSize, - // ref Service.Config.ControlWindowGCDSize, Service.Default.ControlWindowGCDSize, speed: 0.2f, max: 80); - - // DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_ControlWindow0GCDSize, - // ref Service.Config.ControlWindow0GCDSize, Service.Default.ControlWindow0GCDSize, speed: 0.2f, max: 80); - - // DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_ControlWindowNextSizeRatio, - // ref Service.Config.ControlWindowNextSizeRatio, Service.Default.ControlWindowNextSizeRatio); - //} - - ImGui.EndChild(); - } - ImGui.PopStyleVar(); - } - - private static void DrawColor4(string name, ref Vector4 value, Vector4 @default, Action otherthing = null, string description = "") - { - ImGui.SetNextItemWidth(210); - if (ImGui.ColorEdit4(name, ref value)) - { - otherthing?.Invoke(); - Service.Config.Save(); - } - - ImGuiHelper.HoveredString(description); - - if (value != @default) - { - ImGuiHelper.UndoValue(name, ref value, @default); - } - } -} diff --git a/RotationSolver/UI/RotationConfigWindow_Debug.cs b/RotationSolver/UI/RotationConfigWindow_Debug.cs deleted file mode 100644 index 0c4f510ff..000000000 --- a/RotationSolver/UI/RotationConfigWindow_Debug.cs +++ /dev/null @@ -1,228 +0,0 @@ -using ECommons.DalamudServices; -using ECommons.GameFunctions; -using ECommons.GameHelpers; -using FFXIVClientStructs.FFXIV.Client.Game.Fate; -using RotationSolver.Updaters; - -namespace RotationSolver.UI; - -internal partial class RotationConfigWindow -{ - private void DrawDebugTab() - { - if (!Player.Available) return; - - var str = SocialUpdater.EncryptString(Player.Object); - ImGui.SetNextItemWidth(ImGui.CalcTextSize(str).X + 10); - ImGui.InputText("That is your HASH", ref str, 100); - - ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f)); - - if (ImGui.BeginTabBar("Debug Items")) - { - if(RotationUpdater.RightNowRotation != null) - { - DrawParamTabItem("Rotation", RotationUpdater.RightNowRotation.DisplayStatus); - } - DrawParamTabItem("Status", DrawStatus); - DrawParamTabItem("Party", DrawParty); - DrawParamTabItem("Target Data", DrawTargetData); - DrawParamTabItem("Next Action", DrawNextAction); - DrawParamTabItem("Last Action", DrawLastAction); - DrawParamTabItem("Icon", DrawIcon); - DrawParamTabItem("Effect", () => - { - ImGui.Text(Watcher.ShowStrSelf); - ImGui.Separator(); - ImGui.Text(Watcher.ShowStrEnemy); - }); - - ImGui.EndTabBar(); - } - ImGui.PopStyleVar(); - } - - private unsafe void DrawStatus() - { - if ((IntPtr)FateManager.Instance() != IntPtr.Zero) - { - ImGui.Text("Fate: " + DataCenter.FateId.ToString()); - } - ImGui.Text("Moving: " + DataCenter.IsMoving.ToString()); - ImGui.Text("Stop Moving: " + DataCenter.StopMovingRaw.ToString()); - - ImGui.Text("TerritoryType: " + DataCenter.TerritoryContentType.ToString()); - ImGui.Text("DPSTaken: " + DataCenter.DPSTaken.ToString()); - ImGui.Text("TimeToNext: " + DataCenter.NextAbilityToNextGCD.ToString()); - ImGui.Text("WeaponElapsed: " + DataCenter.WeaponElapsed.ToString()); - ImGui.Text("AnimationLock: " + DataCenter.ActionRemain.ToString()); - - ImGui.Text("Have pet: " + DataCenter.HasPet.ToString()); - ImGui.Text("Hostile Near Count: " + DataCenter.NumberOfHostilesInRange.ToString()); - ImGui.Text("Hostile Near Count Max Range: " + DataCenter.NumberOfHostilesInMaxRange.ToString()); - ImGui.Text("Have Companion: " + DataCenter.HasCompanion.ToString()); - ImGui.Text("Ping: " + DataCenter.Ping.ToString()); - ImGui.Text("MP: " + DataCenter.CurrentMp.ToString()); - ImGui.Text("Count Down: " + Service.CountDownTime.ToString()); - ImGui.Text("Fetch Time: " + DataCenter.FetchTime.ToString()); - - foreach (var status in Player.Object.StatusList) - { - var source = status.SourceId == Player.Object.ObjectId ? "You" : Svc.Objects.SearchById(status.SourceId) == null ? "None" : "Others"; - ImGui.Text($"{status.GameData.Name}: {status.StatusId} From: {source}"); - } - } - private unsafe void DrawParty() - { - ImGui.Text("Party Burst Ratio: " + DataCenter.RatioOfMembersIn2minsBurst.ToString()); - ImGui.Text("Party: " + DataCenter.PartyMembers.Count().ToString()); - ImGui.Text("CanHealSingleAbility: " + DataCenter.CanHealSingleAbility.ToString()); - ImGui.Text("CanHealSingleSpell: " + DataCenter.CanHealSingleSpell.ToString()); - ImGui.Text("CanHealAreaAbility: " + DataCenter.CanHealAreaAbility.ToString()); - ImGui.Text("CanHealAreaSpell: " + DataCenter.CanHealAreaSpell.ToString()); - ImGui.Text("CanHealAreaSpell: " + DataCenter.CanHealAreaSpell.ToString()); - ImGui.Text("PartyMembersAverHP: " + DataCenter.PartyMembersAverHP.ToString()); - } - - private unsafe void DrawTargetData() - { - if(Svc.Targets.Target != null) - { - ImGui.Text("Height: " + Svc.Targets.Target.Struct()->Height.ToString()); - ImGui.Text("Kind: " + Svc.Targets.Target.GetObjectKind().ToString()); - ImGui.Text("SubKind: " + Svc.Targets.Target.GetBattleNPCSubKind().ToString()); - var owner = Svc.Objects.SearchById(Svc.Targets.Target.OwnerId); - if(owner != null) - { - ImGui.Text("Owner: " + owner.Name.ToString()); - } - } - if (Svc.Targets.Target is BattleChara b) - { - ImGui.Text("HP: " + b.CurrentHp + " / " + b.MaxHp); - ImGui.Text("Is Boss: " + b.IsBoss().ToString()); - ImGui.Text("Has Positional: " + b.HasPositional().ToString()); - ImGui.Text("Is Dying: " + b.IsDying().ToString()); - ImGui.Text("EventType: " + b.GetEventType().ToString()); - ImGui.Text("NamePlate: " + b.GetNamePlateIcon().ToString()); - ImGui.Text("StatusFlags: " + b.StatusFlags.ToString()); - ImGui.Text("InView: " + Svc.GameGui.WorldToScreen(b.Position, out _).ToString()); - ImGui.Text("Name Id: " + b.NameId.ToString()); - ImGui.Text("Data Id: " + b.DataId.ToString()); - ImGui.Text("Targetable: " + b.Struct()->Character.GameObject.TargetableStatus.ToString()); - - var npc = b.GetObjectNPC(); - if(npc != null) - { - ImGui.Text("Unknown12: " + npc.Unknown12.ToString()); - - //ImGui.Text("Unknown15: " + npc.Unknown15.ToString()); - //ImGui.Text("Unknown18: " + npc.Unknown18.ToString()); - //ImGui.Text("Unknown19: " + npc.Unknown19.ToString()); - //ImGui.Text("Unknown20: " + npc.Unknown20.ToString()); - //ImGui.Text("Unknown21: " + npc.Unknown21.ToString()); - } - - foreach (var status in b.StatusList) - { - var source = status.SourceId == Player.Object.ObjectId ? "You" : Svc.Objects.SearchById(status.SourceId) == null ? "None" : "Others"; - ImGui.Text($"{status.GameData.Name}: {status.StatusId} From: {source}"); - } - } - - ImGui.Text("All: " + DataCenter.AllTargets.Count().ToString()); - ImGui.Text("Hostile: " + DataCenter.HostileTargets.Count().ToString()); - foreach (var item in DataCenter.HostileTargets) - { - ImGui.Text(item.Name.ToString()); - } - } - - private void DrawNextAction() - { - ImGui.Text(RotationUpdater.RightNowRotation.RotationName); - ImGui.Text(DataCenter.SpecialType.ToString()); - - ImGui.Text("Ability Remain: " + DataCenter.AbilityRemain.ToString()); - ImGui.Text("Action Remain: " + DataCenter.ActionRemain.ToString()); - ImGui.Text("Weapon Remain: " + DataCenter.WeaponRemain.ToString()); - ImGui.Text("Time: " + (DataCenter.CombatTimeRaw + DataCenter.WeaponRemain).ToString()); - - ActionUpdater.NextAction?.Display(false); - } - - private void DrawLastAction() - { - DrawAction(DataCenter.LastAction, nameof(DataCenter.LastAction)); - DrawAction(DataCenter.LastAbility, nameof(DataCenter.LastAbility)); - DrawAction(DataCenter.LastGCD, nameof(DataCenter.LastGCD)); - DrawAction(DataCenter.LastComboAction, nameof(DataCenter.LastComboAction)); - } - - private unsafe void DrawIcon() - { - //if(ImGui.BeginTable("BLUAction", 4, ImGuiTableFlags.Borders | ImGuiTableFlags.Resizable | ImGuiTableFlags.SizingFixedFit)) - //{ - // foreach (var item in Svc.Data.GetExcelSheet()) - // { - // if (item == null) continue; - // if (item.ClassJob?.Row != 36) continue; - // //if (item.RowId <= 20000) continue; - - // ImGui.TableNextRow(); - // ImGui.TableNextColumn(); - - // ImGui.Text($"{item.Name}"); - - // ImGui.TableNextColumn(); - - // try - // { - // var tex = IconSet.GetTexture(item.Icon); - // if (tex != null) - // { - // ImGui.Image(tex.ImGuiHandle, Vector2.One * 32); - // } - // } - // catch - // { - - // } - // ImGui.TableNextColumn(); - - // try - // { - // ImGui.Text($"{(Aspect)item.Aspect}"); - // ImGui.SameLine(); - // var desc = item.AttackType?.Value?.Name?.ToString(); - // if (!string.IsNullOrEmpty(desc)) ImGui.Text(desc); - // } - // catch - // { - - // } - // ImGui.TableNextColumn(); - - // //ImGui.TableNextColumn(); - - // //try - // //{ - // // var desc = Svc.Data.GetExcelSheet()?.GetRow(item.RowId)?.Description?.ToString(); - // // //ImGui.Text((!string.IsNullOrEmpty(desc)).ToString()); - // // //if (!string.IsNullOrEmpty(desc)) ImGui.Text(desc); - // //} - // //catch - // //{ - - // //} - // } - // ImGui.EndTable(); - //} - - } - - private static void DrawAction(ActionID id, string type) - { - ImGui.Text($"{type}: {id}"); - } -} diff --git a/RotationSolver/UI/RotationConfigWindow_Events.cs b/RotationSolver/UI/RotationConfigWindow_Events.cs deleted file mode 100644 index f9c4b9358..000000000 --- a/RotationSolver/UI/RotationConfigWindow_Events.cs +++ /dev/null @@ -1,57 +0,0 @@ -using RotationSolver.Basic.Configuration; -using RotationSolver.Localization; - -namespace RotationSolver.UI; -internal partial class RotationConfigWindow -{ - private static void DrawEventTab() - { - if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Events_AddEvent)) - { - Service.Config.Events.Add(new ActionEventInfo()); - Service.Config.Save(); - } - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_Events_Description); - - ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f)); - - ImGui.Text(LocalizationManager.RightLang.ConfigWindow_Events_DutyStart); - ImGui.SameLine(); - ImGuiHelper.Spacing(); - Service.Config.DutyStart.DisplayMacro(); - - ImGui.Text(LocalizationManager.RightLang.ConfigWindow_Events_DutyEnd); - ImGui.SameLine(); - ImGuiHelper.Spacing(); - Service.Config.DutyEnd.DisplayMacro(); - - if (ImGui.BeginChild("Events List", new Vector2(0f, -1f), true)) - { - ActionEventInfo remove = null; - foreach (var eve in Service.Config.Events) - { - eve.DisplayEvent(); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - if (ImGui.Button($"{LocalizationManager.RightLang.ConfigWindow_Events_RemoveEvent}##RemoveEvent{eve.GetHashCode()}")) - { - remove = eve; - } - ImGui.Separator(); - } - if(remove!= null) - { - Service.Config.Events.Remove(remove); - Service.Config.Save(); - } - - ImGui.EndChild(); - } - ImGui.PopStyleVar(); - } -} diff --git a/RotationSolver/UI/RotationConfigWindow_Help.cs b/RotationSolver/UI/RotationConfigWindow_Help.cs deleted file mode 100644 index ca32ca8ba..000000000 --- a/RotationSolver/UI/RotationConfigWindow_Help.cs +++ /dev/null @@ -1,99 +0,0 @@ -using Dalamud.Utility; -using RotationSolver.Localization; - -namespace RotationSolver.UI; -internal partial class RotationConfigWindow -{ - private static void DrawHelpTab() - { - if(ImGui.Button("New Config Window (Test)")) - { - RotationSolverPlugin.ToggleConfigWindow(); - } - - ImGui.SameLine(); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.Code, "GitHub")) - { - Util.OpenLink("https://GitHub.com/ArchiDog1998/RotationSolver"); - } - - ImGui.SameLine(); - - if(ImGuiHelper.IconButton(FontAwesomeIcon.HandPaper, "Discord")) - { - Util.OpenLink("https://discord.gg/4fECHunam9"); - } - - ImGui.SameLine(); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.Book, "Wiki")) - { - Util.OpenLink("https://archidog1998.GitHub.io/RotationSolver/"); - } - - ImGui.SameLine(); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.History, "ChangeLog")) - { - Util.OpenLink("https://GitHub.com/ArchiDog1998/RotationSolver/blob/release/CHANGELOG.md"); - } - - ImGui.SameLine(); - - ImGui.PushStyleColor(ImGuiCol.Button, 0xFF5E5BFF); - ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xDD5E5BFF); - ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xAA5E5BFF); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.Coffee, "Support")) - { - Util.OpenLink("https://ko-fi.com/archited"); - } - ImGui.PopStyleColor(3); - - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_HelpItem_Description); - - if (ImGui.BeginChild("Help Information", new Vector2(0f, -1f), true)) - { - ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f)); - - StateCommandType.Auto.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - StateCommandType.Manual.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - StateCommandType.Cancel.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - OtherCommandType.NextAction.DisplayCommandHelp(getHelp: i => LocalizationManager.RightLang.ConfigWindow_HelpItem_NextAction); - - ImGui.Separator(); - - SpecialCommandType.EndSpecial.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - SpecialCommandType.HealArea.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - SpecialCommandType.HealSingle.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - SpecialCommandType.DefenseArea.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - SpecialCommandType.DefenseSingle.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - SpecialCommandType.MoveForward.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - SpecialCommandType.MoveBack.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - SpecialCommandType.Speed.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - SpecialCommandType.EsunaStanceNorth.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - SpecialCommandType.RaiseShirk.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - SpecialCommandType.AntiKnockback.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - SpecialCommandType.Burst.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp); - - ImGui.PopStyleVar(); - - ImGui.EndChild(); - } - } -} diff --git a/RotationSolver/UI/RotationConfigWindow_List.cs b/RotationSolver/UI/RotationConfigWindow_List.cs deleted file mode 100644 index 06cc5c8fd..000000000 --- a/RotationSolver/UI/RotationConfigWindow_List.cs +++ /dev/null @@ -1,539 +0,0 @@ -using Dalamud.Utility; -using Lumina.Excel.GeneratedSheets; -using RotationSolver.Basic.Configuration; -using RotationSolver.Data; -using RotationSolver.Localization; -using RotationSolver.TextureItems; -using RotationSolver.Updaters; -using Action = Lumina.Excel.GeneratedSheets.Action; - -namespace RotationSolver.UI; - -internal partial class RotationConfigWindow -{ - private static uint _territoryId = 0; - private static TerritoryTypeTexture[] _allTerritories = null; - public static TerritoryTypeTexture[] AllTerritories - { - get - { - _allTerritories ??= Service.GetSheet() - .Where(t => t!= null - && t.ContentFinderCondition?.Value?.ContentType?.Value?.RowId != 0) - .OrderBy(t => t.ContentFinderCondition?.Value?.ContentType?.Value?.RowId) - .Select(t => new TerritoryTypeTexture(t)) - .ToArray(); - return _allTerritories; - } - } - - private static StatusTexture[] _allDispelStatus = null; - public static StatusTexture[] AllDispelStatus - { - get - { - _allDispelStatus ??= Service.GetSheet() - .Where(s => s.CanDispel) - .Select(s => new StatusTexture(s)) - .ToArray(); - return _allDispelStatus; - } - } - - private static StatusTexture[] _allInvStatus = null; - public static StatusTexture[] AllInvStatus - { - get - { - _allInvStatus ??= Service.GetSheet() - .Where(s => !s.CanDispel && !s.LockMovement && !s.IsGaze && !s.IsFcBuff && s.HitEffect.Row == 16 && s.ClassJobCategory.Row == 1 && s.StatusCategory == 1 - && !string.IsNullOrEmpty(s.Name.ToString()) && s.Icon != 0) - .Select(s => new StatusTexture(s)) - .ToArray(); - return _allInvStatus; - } - } - - private static ActionTexture[] _allActions = null; - public static ActionTexture[] AllActions - { - get - { - _allActions ??= Service.GetSheet() - .Where(a => !string.IsNullOrEmpty(a.Name) && !a.IsPvP && !a.IsPlayerAction - && a.ClassJob.Value == null && a.Cast100ms > 0) - .Select(a => new ActionTexture(a)) - .ToArray(); - return _allActions; - } - } - - private void DrawListTab() - { - if (ImGuiHelper.IconButton(FontAwesomeIcon.FileDownload, "##Load All")) - { - OtherConfiguration.Init(); - } - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_Description); - - ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f)); - - if (ImGui.BeginTabBar("List Items")) - { - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_List_Hostile, DrawParamHostile, () => - { - if (ImGuiHelper.IconButton(FontAwesomeIcon.Plus, "Add Hostile")) - { - Service.Config.TargetingTypes.Add(TargetingType.Big); - } - ImGui.SameLine(); - ImGuiHelper.Spacing(); - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_Param_HostileDesc); - }); - - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_List_NoHostile, DrawParamNoHostile, () => - { - ImGui.SetNextItemWidth(200); - - if (ImGui.BeginCombo("##AddNoHostileNames", - Service.GetSheet().GetRow(_territoryId)?.PlaceName?.Value?.Name.ToString() ?? "Everywhere", ImGuiComboFlags.HeightLargest)) - { - if (ImGui.Selectable("Everywhere")) - { - _territoryId = 0; - } - - ImGuiHelper.SearchItems(ref searchText, AllTerritories, s => - { - _territoryId = s.ID; - }); - - ImGui.EndCombo(); - } - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.Plus, "Add Territory")) - { - if (!OtherConfiguration.NoHostileNames.TryGetValue(_territoryId, out var hostileNames)) - hostileNames = Array.Empty(); - OtherConfiguration.NoHostileNames[_territoryId] = hostileNames.Append(string.Empty).ToArray(); - } - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_NoHostileDesc); - }); - - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_List_Invincibility, DrawInvincibility, () => - { - ImGui.SetNextItemWidth(200); - ImGuiHelper.SearchCombo("##AddInvincibleStatus", - LocalizationManager.RightLang.ConfigWindow_Param_AddOne, - ref searchText, AllInvStatus, s => - { - OtherConfiguration.InvincibleStatus.Add((uint)s.ID); - OtherConfiguration.SaveInvincibleStatus(); - - }); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_InvincibilityDesc); - }); - - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_List_DangerousStatus, DrawDangerousStatus, () => - { - ImGui.SetNextItemWidth(200); - ImGuiHelper.SearchCombo("##AddDangerousStatus", - LocalizationManager.RightLang.ConfigWindow_Param_AddOne, - ref searchText, AllDispelStatus, s => - { - OtherConfiguration.DangerousStatus.Add((uint)s.ID); - OtherConfiguration.SaveDangerousStatus(); - }); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_DangerousStatusDesc); - }); - - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_List_HostileCastingTank, DrawHostileCastingTank, () => - { - ImGui.SetNextItemWidth(200); - ImGuiHelper.SearchCombo("##AddCastingTank", - LocalizationManager.RightLang.ConfigWindow_Param_AddOne, - ref searchText, AllActions, a => - { - OtherConfiguration.HostileCastingTank.Add(a.ID); - OtherConfiguration.SaveHostileCastingTank(); - }); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_HostileCastingTankDesc); - }); - - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_List_HostileCastingArea, DrawHostileCastingArea, () => - { - DrawCheckBox("Record", ref Service.Config.RecordCastingArea, Service.Default.RecordCastingArea); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - ImGui.SetNextItemWidth(200); - ImGuiHelper.SearchCombo("##AddCastingArea", - LocalizationManager.RightLang.ConfigWindow_Param_AddOne, - ref searchText, AllActions, a => - { - OtherConfiguration.HostileCastingArea.Add(a.ID); - OtherConfiguration.SaveHostileCastingArea(); - }); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_HostileCastingAreaDesc); - }); - - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_List_Rotations, DrawRotationDevTab, () => - { - if (ImGuiHelper.IconButton(FontAwesomeIcon.Download, "DownloadRotationsButton")) - { - Task.Run(async () => - { - await RotationUpdater.GetAllCustomRotationsAsync(DownloadOption.MustDownload | DownloadOption.ShowList); - }); - } - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.FileDownload, "##LoadLocalRotations")) - { - Task.Run(async () => - { - await RotationUpdater.GetAllCustomRotationsAsync(DownloadOption.ShowList); - }); - } - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.Book, "##OpenWiki")) - { - Util.OpenLink("https://archidog1998.GitHub.io/RotationSolver/#/RotationDev/"); - } - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.Plus, "Add Rotation")) - { - Service.Config.OtherLibs = Service.Config.OtherLibs.Append(string.Empty).ToArray(); - } - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - ImGui.TextWrapped("Third-party Rotation Libraries"); - - ImGui.Checkbox("Auto load rotations", - ref Service.Config.AutoLoadCustomRotations); - }); - - ImGui.EndTabBar(); - } - ImGui.PopStyleVar(); - } - - private void DrawParamHostile() - { - for (int i = 0; i < Service.Config.TargetingTypes.Count; i++) - { - ImGui.Separator(); - - var names = Enum.GetNames(typeof(TargetingType)); - var targingType = (int)Service.Config.TargetingTypes[i]; - - ImGui.SetNextItemWidth(150); - - if (ImGui.Combo(LocalizationManager.RightLang.ConfigWindow_Param_HostileCondition + "##HostileCondition" + i.ToString(), ref targingType, names, names.Length)) - { - Service.Config.TargetingTypes[i] = (TargetingType)targingType; - Service.Config.Save(); - } - - if (ImGuiHelper.IconButton(FontAwesomeIcon.ArrowUp, $"##HostileUp{i}")) - { - if (i > 0) - { - var value = Service.Config.TargetingTypes[i]; - Service.Config.TargetingTypes.RemoveAt(i); - Service.Config.TargetingTypes.Insert(i - 1, value); - Service.Config.Save(); - } - } - ImGui.SameLine(); - ImGuiHelper.Spacing(); - if (ImGuiHelper.IconButton(FontAwesomeIcon.ArrowDown, $"##HostileDown{i}")) - { - if (i < Service.Config.TargetingTypes.Count - 1) - { - var value = Service.Config.TargetingTypes[i]; - Service.Config.TargetingTypes.RemoveAt(i); - Service.Config.TargetingTypes.Insert(i + 1, value); - Service.Config.Save(); - } - } - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.Ban, $"##HostileDelete{i}")) - { - Service.Config.TargetingTypes.RemoveAt(i); - Service.Config.Save(); - } - } - } - - string searchText = string.Empty; - private void DrawDangerousStatus() - { - uint removeId = 0; - uint addId = 0; - foreach (var statusId in OtherConfiguration.DangerousStatus) - { - var status = Service.GetSheet().GetRow(statusId); - ImGui.Image(IconSet.GetTexture(status.Icon).ImGuiHandle, new Vector2(24, 30)); - ImGuiHelper.HoveredString(status.Description?.ToString()); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - ImGui.SetNextItemWidth(150); - - ImGuiHelper.SearchCombo($"##DangerousStatus{statusId}", - $"{status.Name} ({status.RowId})", - ref searchText, AllDispelStatus, s => - { - removeId = statusId; - addId = (uint)s.ID; - }); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - - if (ImGuiHelper.IconButton(FontAwesomeIcon.Ban, $"##RemoveDangerous{statusId}")) - { - removeId = statusId; - } - } - - if(removeId != 0) - { - OtherConfiguration.DangerousStatus.Remove(removeId); - OtherConfiguration.SaveDangerousStatus(); - } - if (addId != 0) - { - OtherConfiguration.DangerousStatus.Add(addId); - OtherConfiguration.SaveDangerousStatus(); - } - } - - private void DrawInvincibility() - { - uint removeId = 0; - uint addId = 0; - foreach (var statusId in OtherConfiguration.InvincibleStatus) - { - var status = Service.GetSheet().GetRow(statusId); - ImGui.Image(IconSet.GetTexture(status.Icon).ImGuiHandle, new Vector2(24, 30)); - ImGuiHelper.HoveredString(status.Description?.ToString()); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - ImGui.SetNextItemWidth(150); - - ImGuiHelper.SearchCombo($"##InvincibleStatus{statusId}", - $"{status.Name} ({status.RowId})", - ref searchText, AllInvStatus, s => - { - removeId = statusId; - addId = (uint)s.ID; - }); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.Ban, $"##InvincibleStatus{statusId}")) - { - removeId = statusId; - } - } - - if (removeId != 0) - { - OtherConfiguration.InvincibleStatus.Remove(removeId); - OtherConfiguration.SaveInvincibleStatus(); - } - if (addId != 0) - { - OtherConfiguration.InvincibleStatus.Add(addId); - OtherConfiguration.SaveInvincibleStatus(); - } - } - - private void DrawRotationDevTab() - { - int removeIndex = -1; - for (int i = 0; i < Service.Config.OtherLibs.Length; i++) - { - if (ImGui.InputText($"##OtherLib{i}", ref Service.Config.OtherLibs[i], 1024)) - { - Service.Config.Save(); - } - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.Ban, $"##RemoveOtherLibs{i}")) - { - removeIndex = i; - } - } - if (removeIndex > -1) - { - var list = Service.Config.OtherLibs.ToList(); - list.RemoveAt(removeIndex); - Service.Config.OtherLibs = list.ToArray(); - Service.Config.Save(); - } - } - - private void DrawHostileCastingTank() - { - uint removeId = 0; - uint addId = 0; - foreach (var actionId in OtherConfiguration.HostileCastingTank) - { - var status = Service.GetSheet().GetRow(actionId); - ImGui.Image(IconSet.GetTexture(status.Icon).ImGuiHandle, new Vector2(24, 24)); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - ImGui.SetNextItemWidth(150); - - ImGuiHelper.SearchCombo($"##SaveHostileCastingTank{actionId}", - $"{status.Name} ({status.RowId})", - ref searchText, AllActions, s => - { - removeId = actionId; - addId = s.ID; - }); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.Ban, $"##SaveHostileCastingTank{actionId}")) - { - removeId = actionId; - } - } - - if (removeId != 0) - { - OtherConfiguration.HostileCastingTank.Remove(removeId); - OtherConfiguration.SaveHostileCastingTank(); - } - if (addId != 0) - { - OtherConfiguration.HostileCastingTank.Add(addId); - OtherConfiguration.SaveHostileCastingTank(); - } - } - - private void DrawHostileCastingArea() - { - uint removeId = 0; - uint addId = 0; - foreach (var actionId in OtherConfiguration.HostileCastingArea) - { - var status = Service.GetSheet().GetRow(actionId); - ImGui.Image(IconSet.GetTexture(status.Icon).ImGuiHandle, new Vector2(24, 24)); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - ImGui.SetNextItemWidth(150); - - ImGuiHelper.SearchCombo($"##SaveHostileCastingArea{actionId}", - $"{status.Name} ({status.RowId})", - ref searchText, AllActions, s => - { - removeId = actionId; - addId = s.ID; - }); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.Ban, $"##SaveHostileCastingArea{actionId}")) - { - removeId = actionId; - } - } - - if (removeId != 0) - { - OtherConfiguration.HostileCastingArea.Remove(removeId); - OtherConfiguration.SaveHostileCastingArea(); - } - if (addId != 0) - { - OtherConfiguration.HostileCastingArea.Add(addId); - OtherConfiguration.SaveHostileCastingArea(); - } - } - - private void DrawParamNoHostile() - { - int removeIndex = -1; - - if (!OtherConfiguration.NoHostileNames.TryGetValue(_territoryId, out var names)) names = Array.Empty(); - - for (int i = 0; i < names.Length; i++) - { - if (ImGui.InputText($"##NoHostileNames{i}", ref names[i], 1024)) - { - OtherConfiguration.NoHostileNames[_territoryId] = names; - OtherConfiguration.SaveNoHostileNames(); - } - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - if (ImGuiHelper.IconButton(FontAwesomeIcon.Ban, $"##RemoveNoHostileNames{i}")) - { - removeIndex = i; - } - } - if (removeIndex > -1) - { - var list = names.ToList(); - list.RemoveAt(removeIndex); - OtherConfiguration.NoHostileNames[_territoryId] = list.ToArray(); - OtherConfiguration.SaveNoHostileNames(); - } - } -} diff --git a/RotationSolver/UI/RotationConfigWindow_Major.cs b/RotationSolver/UI/RotationConfigWindow_Major.cs deleted file mode 100644 index 554631c81..000000000 --- a/RotationSolver/UI/RotationConfigWindow_Major.cs +++ /dev/null @@ -1,263 +0,0 @@ -using Dalamud.Interface.Windowing; -using Dalamud.Logging; -using RotationSolver.Localization; - -namespace RotationSolver.UI; -internal partial class RotationConfigWindow : Window -{ - public RotationConfigWindow() - : base(nameof(RotationConfigWindow), 0, false) - { - SizeCondition = ImGuiCond.FirstUseEver; - Size = new Vector2(740f, 490f); - RespectCloseHotkey = true; - } - - public override unsafe void Draw() - { - if (ImGui.BeginTabBar("RotationSolverSettings")) - { - if (ImGui.BeginTabItem(LocalizationManager.RightLang.ConfigWindow_RotationItem)) - { - DrawRotationTab(); - ImGui.EndTabItem(); - } - - if (ImGui.BeginTabItem(LocalizationManager.RightLang.ConfigWindow_ParamItem)) - { - DrawParamTab(); - ImGui.EndTabItem(); - } - - if (ImGui.BeginTabItem(LocalizationManager.RightLang.ConfigWindow_ListItem)) - { - DrawListTab(); - ImGui.EndTabItem(); - } - - if (ImGui.BeginTabItem(LocalizationManager.RightLang.ConfigWindow_ControlItem)) - { - DrawControlTab(); - ImGui.EndTabItem(); - } - - if (ImGui.BeginTabItem(LocalizationManager.RightLang.ConfigWindow_ActionItem)) - { - DrawActionTab(); - ImGui.EndTabItem(); - } - - if (ImGui.BeginTabItem(LocalizationManager.RightLang.ConfigWindow_EventItem)) - { - DrawEventTab(); - ImGui.EndTabItem(); - } - - if (ImGui.BeginTabItem(LocalizationManager.RightLang.ConfigWindow_HelpItem)) - { - DrawHelpTab(); - ImGui.EndTabItem(); - } - - if (Service.Config.InDebug && ImGui.BeginTabItem("Debug")) - { - DrawDebugTab(); - ImGui.EndTabItem(); - } - - ImGui.EndTabBar(); - } - ImGui.End(); - } - - internal static void DrawCheckBox(string name, SettingsCommand command, string description = "", Action otherThing = null) - { - var value = Service.Config.GetValue(command); - DrawCheckBox(name, ref value, command.GetDefault(), description, () => - { - Service.Config.SetValue(command, value); - otherThing?.Invoke(); - }); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - ImGuiHelper.DisplayCommandHelp(OtherCommandType.Settings, command.ToString()); - } - - internal static void DrawIconCheckBox(ActionID actionID, ref bool value, string description = "", Action otherThing = null) - { - var name = $"##{actionID}"; - description = actionID.ToString() + "\n" + description; - - ControlWindow.DrawIAction(IconSet.GetTexture(actionID).ImGuiHandle, 40, value ? 1 : - 1); - - ImGuiHelper.HoveredString(description); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - DrawCheckBox(name, ref value, description, otherThing); - } - - internal static void DrawCheckBox(string name, ref bool value, bool @default, string description = "", Action otherThing = null) - { - DrawCheckBox(name, ref value, description, otherThing); - - if (value != @default) - { - ImGuiHelper.UndoValue(name, ref value, @default, otherThing); - } - } - - internal static void DrawCheckBox(string name, ref bool value, string description = "", Action otherThing = null) - { - if (ImGui.Checkbox(name, ref value)) - { - otherThing?.Invoke(); - Service.Config.Save(); - } - - ImGuiHelper.HoveredString(description); - } - - private static void DrawRangedFloat(string name, ref float minValue, ref float maxValue, float defaultMin, float defaultMax, float speed = 0.01f, float min = 0, float max = 3, string description = "") - { - ImGui.SetNextItemWidth(100); - if (ImGui.DragFloatRange2(name, ref minValue, ref maxValue, speed, min, max)) - { - Service.Config.Save(); - } - - ImGuiHelper.HoveredString(description); - - if (minValue != defaultMin || maxValue != defaultMax) - { - ImGuiHelper.UndoValue(name, ref minValue, defaultMin, ref maxValue, defaultMax); - } - } - - private static void DrawRangedInt(string name, ref int minValue, ref int maxValue, int defaultMin, int defaultMax, float speed = 0.01f, int min = 0, int max = 3, string description = "", Action otherThing = null) - { - ImGui.SetNextItemWidth(100); - if (ImGui.DragIntRange2(name, ref minValue, ref maxValue, speed, min, max)) - { - otherThing?.Invoke(); - Service.Config.Save(); - } - - ImGuiHelper.HoveredString(description); - - if (minValue != defaultMin || maxValue != defaultMax) - { - ImGuiHelper.UndoValue(name, ref minValue, defaultMin, ref maxValue, defaultMax, otherThing); - } - } - - public static void DrawFloatNumber(string name, ref float value, float @default, float speed = 0.002f, float min = 0, float max = 1, string description = "", Action otherThing = null) - { - ImGui.SetNextItemWidth(100); - if (ImGui.DragFloat(name, ref value, speed, min, max)) - { - otherThing?.Invoke(); - Service.Config.Save(); - } - - ImGuiHelper.HoveredString(description); - - if (value != @default) - { - ImGuiHelper.UndoValue(name, ref value, @default, otherThing); - } - } - - public static void DrawIntNumber(string name, ref int value, int @default, float speed = 0.2f, int min = 0, int max = 1, string description = "", Action otherThing = null) - { - ImGui.SetNextItemWidth(100); - if (ImGui.DragInt(name, ref value, speed, min, max)) - { - Service.Config.Save(); - otherThing?.Invoke(); - } - - ImGuiHelper.HoveredString(description); - - if (value != @default) - { - ImGuiHelper.UndoValue(name, ref value, @default, otherThing); - } - } - - private static void DrawColor3(string name, ref Vector3 value, Vector3 @default, string description = "") - { - ImGui.SetNextItemWidth(210); - if (ImGui.ColorEdit3(name, ref value)) - { - Service.Config.Save(); - } - - ImGuiHelper.HoveredString(description); - - if (value != @default) - { - ImGuiHelper.UndoValue(name, ref value, @default); - } - } - - public static void DrawCombo(string name, ref int value, int @default, Func toString, T[] choices = null, string description = "") where T : struct, Enum - { - choices ??= Enum.GetValues(); - - ImGui.SetNextItemWidth(100); - if (ImGui.BeginCombo(name, toString(choices[value]))) - { - for (int i = 0; i < choices.Length; i++) - { - if (ImGui.Selectable(toString(choices[i]))) - { - value = i; - Service.Config.Save(); - } - } - ImGui.EndCombo(); - } - ImGuiHelper.HoveredString(description); - - if (value != @default) - { - ImGuiHelper.UndoValue(name, ref value, @default); - } - } - - private static void DrawInputText(string name, ref string value, uint maxLength, string description = "") - { - ImGui.SetNextItemWidth(210); - if (ImGui.InputText(name, ref value, maxLength)) - { - Service.Config.Save(); - } - ImGuiHelper.HoveredString(description); - } - - private static void DrawParamTabItem(string name, Action act, Action outsideChild = null) - { - if (act == null) return; - if (ImGui.BeginTabItem(name)) - { - try - { - outsideChild?.Invoke(); - if (ImGui.BeginChild("Param", new Vector2(0f, -1f), true)) - { - act(); - ImGui.EndChild(); - } - } - catch (Exception ex) - { - PluginLog.Warning(ex, $"{name} displays failed."); - } - - ImGui.EndTabItem(); - } - } -} diff --git a/RotationSolver/UI/RotationConfigWindow_Param.cs b/RotationSolver/UI/RotationConfigWindow_Param.cs deleted file mode 100644 index 3b67964c9..000000000 --- a/RotationSolver/UI/RotationConfigWindow_Param.cs +++ /dev/null @@ -1,550 +0,0 @@ -using RotationSolver.Commands; -using RotationSolver.Localization; - -namespace RotationSolver.UI; -internal partial class RotationConfigWindow -{ - private void DrawParamTab() - { - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_Params_Description); - - ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f)); - - if (ImGui.BeginTabBar("Param Items")) - { - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Basic, DrawParamBasic); - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Delay, DrawParamDelay); - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Display, DrawParamDisplay); - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Action, DrawParamAction); - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Condition, DrawParamCondition); - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Target, DrawParamTarget); - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Advanced, DrawParamAdvanced); - - ImGui.EndTabBar(); - } - ImGui.PopStyleVar(); - } - - private void DrawParamBasic() - { - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_ActionAhead, - // ref Service.Config.ActionAhead, Service.Default.ActionAhead, max: 0.5f); - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_MinLastAbilityAdvanced, - // ref Service.Config.MinLastAbilityAdvanced, Service.Default.MinLastAbilityAdvanced, max: 0.4f); - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_CountDownAhead, - // ref Service.Config.CountDownAhead, Service.Default.CountDownAhead, min: 0.5f, max: 0.7f); - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_SpecialDuration, - // ref Service.Config.SpecialDuration, Service.Default.SpecialDuration, speed: 0.02f, min: 1, max: 20); - - //DrawIntNumber(LocalizationManager.RightLang.ConfigWindow_Param_AddDotGCDCount, - // ref Service.Config.AddDotGCDCount, Service.Default.AddDotGCDCount, min: 0, max: 3); - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_MaxPing, - // ref Service.Config.MaxPing, Service.Default.MaxPing, min: 0.01f, max: 0.5f); - - ImGui.Spacing(); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoOffBetweenArea, - // ref Service.Config.AutoOffBetweenArea, Service.Default.AutoOffBetweenArea); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoOffCutScene, - // ref Service.Config.AutoOffCutScene, Service.Default.AutoOffCutScene); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoOffWhenDead, - // ref Service.Config.AutoOffWhenDead, Service.Default.AutoOffWhenDead); - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_AutoOffAfterCombat, - //ref Service.Config.AutoOffAfterCombat, Service.Default.AutoOffAfterCombat, min: 0, max: 10); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_StartOnCountdown, - // ref Service.Config.StartOnCountdown, Service.Default.StartOnCountdown); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_StartOnAttackedBySomeone, - // ref Service.Config.StartOnAttackedBySomeone, Service.Default.StartOnAttackedBySomeone); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseWorkTask, - // ref Service.Config.UseWorkTask, Service.Default.UseWorkTask); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ToggleManual, - // ref Service.Config.ToggleManual, Service.Default.ToggleManual); - } - - private void DrawParamDelay() - { - //DrawRangedFloat(LocalizationManager.RightLang.ConfigWindow_Param_WeaponDelay, - // ref Service.Config.WeaponDelayMin, ref Service.Config.WeaponDelayMax, - // Service.Default.WeaponDelayMin, Service.Default.WeaponDelayMax, - // speed: 0.002f, max: 1); - - //DrawRangedFloat(LocalizationManager.RightLang.ConfigWindow_Param_HostileDelay, - // ref Service.Config.HostileDelayMin, ref Service.Config.HostileDelayMax, - // Service.Default.HostileDelayMin, Service.Default.HostileDelayMax); - - //DrawRangedFloat(LocalizationManager.RightLang.ConfigWindow_Param_InterruptDelay, - // ref Service.Config.InterruptDelayMin, ref Service.Config.InterruptDelayMax, - // Service.Default.InterruptDelayMin, Service.Default.InterruptDelayMax); - - //DrawRangedFloat(LocalizationManager.RightLang.ConfigWindow_Param_DeathDelay, - // ref Service.Config.DeathDelayMin, ref Service.Config.DeathDelayMax, - // Service.Default.DeathDelayMin, Service.Default.DeathDelayMax); - - //DrawRangedFloat(LocalizationManager.RightLang.ConfigWindow_Param_WeakenDelay, - // ref Service.Config.WeakenDelayMin, ref Service.Config.WeakenDelayMax, - // Service.Default.WeakenDelayMin, Service.Default.WeakenDelayMax); - - //DrawRangedFloat(LocalizationManager.RightLang.ConfigWindow_Param_HealDelay, - // ref Service.Config.HealDelayMin, ref Service.Config.HealDelayMax, - // Service.Default.HealDelayMin, Service.Default.HealDelayMax); - - //DrawRangedFloat(LocalizationManager.RightLang.ConfigWindow_Param_CountdownDelay, - // ref Service.Config.CountdownDelayMin, ref Service.Config.CountdownDelayMax, - // Service.Default.CountdownDelayMin, Service.Default.CountdownDelayMax); - - //DrawRangedFloat(LocalizationManager.RightLang.ConfigWindow_Param_NotInCombatDelay, - // ref Service.Config.NotInCombatDelayMin, ref Service.Config.NotInCombatDelayMax, - // Service.Default.NotInCombatDelayMin, Service.Default.NotInCombatDelayMax); - - //DrawRangedFloat(LocalizationManager.RightLang.ConfigWindow_Param_ClickingDelay, - // ref Service.Config.ClickingDelayMin, ref Service.Config.ClickingDelayMax, - // Service.Default.ClickingDelayMin, Service.Default.ClickingDelayMax - // ,min : 0.05f, max: 0.25f); - - //if (Service.Config.UseStopCasting) - //{ - // DrawRangedFloat(LocalizationManager.RightLang.ConfigWindow_Param_StopCastingDelay, - // ref Service.Config.StopCastingDelayMin, ref Service.Config.StopCastingDelayMax, - // Service.Default.StopCastingDelayMin, Service.Default.StopCastingDelayMax); - //} - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_ClickMistake, ref Service.Config.MistakeRatio, Service.Default.MistakeRatio); - } - - private void DrawParamAdvanced() - { - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_SayOutStateChanged, - // ref Service.Config.SayOutStateChanged, Service.Default.SayOutStateChanged); - - ImGui.Separator(); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_PoslockCasting, - //ref Service.Config.PoslockCasting, Service.Default.PoslockCasting); - - //if (Service.Config.PoslockCasting) - //{ - // ImGui.Indent(); - - // DrawCombo(LocalizationManager.RightLang.ConfigWindow_Param_PoslockModifier, - // ref Service.Config.PoslockModifier, Service.Default.PoslockModifier, EnumTranslations.ToName, - // ConfigurationHelper.Keys, - // LocalizationManager.RightLang.ConfigWindow_Param_PoslockDescription); - - // DrawIconCheckBox(ActionID.PassageOfArms, ref Service.Config.PosPassageOfArms); - - // ImGui.SameLine(); - // ImGuiHelper.Spacing(); - - // DrawIconCheckBox(ActionID.TenChiJin, ref Service.Config.PosTenChiJin); - - // ImGui.SameLine(); - // ImGuiHelper.Spacing(); - - // DrawIconCheckBox(ActionID.FlameThrower, ref Service.Config.PosFlameThrower); - - // ImGui.SameLine(); - // ImGuiHelper.Spacing(); - - // DrawIconCheckBox(ActionID.Improvisation, ref Service.Config.PosImprovisation); - - // ImGui.Unindent(); - //} - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseStopCasting, - // ref Service.Config.UseStopCasting, Service.Default.UseStopCasting); - - ImGui.Separator(); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ShowHealthRatio, - // ref Service.Config.ShowHealthRatio, Service.Default.ShowHealthRatio); - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_HealthRatioBoss, - // ref Service.Config.HealthRatioBoss, Service.Default.HealthRatioBoss, - // speed: 0.02f, min: 0, max: 10); - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_HealthRatioDying, - // ref Service.Config.HealthRatioDying, Service.Default.HealthRatioDying, - // speed: 0.02f, min: 0, max: 10); - - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_HealthRatioDot, - // ref Service.Config.HealthRatioDot, Service.Default.HealthRatioDot, - // speed: 0.02f, min: 0, max: 10); - - ImGui.Separator(); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ShowTooltips, - // ref Service.Config.ShowTooltips, Service.Default.ShowTooltips); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_InDebug, - // ref Service.Config.InDebug, Service.Default.InDebug); - } - - private void DrawParamDisplay() - { - DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseOverlayWindow, - ref Service.Config.UseOverlayWindow, Service.Default.UseOverlayWindow, - LocalizationManager.RightLang.ConfigWindow_Param_UseOverlayWindowDesc, otherThing: () => - { - PainterManager._painter.Enable = Service.Config.UseOverlayWindow; - }); - - if (Service.Config.UseOverlayWindow) - { - DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_TeachingMode, - ref Service.Config.TeachingMode, Service.Default.TeachingMode); - - if (Service.Config.TeachingMode) - { - ImGuiHelper.Spacing(); - - DrawColor4(LocalizationManager.RightLang.ConfigWindow_Param_TeachingModeColor, - ref Service.Config.TeachingModeColor, Service.Default.TeachingModeColor, otherthing: () => - { - PainterManager.HighlightColor = Service.Config.TeachingModeColor; - }); - } - - DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ShowMoveTarget, - ref Service.Config.ShowMoveTarget, Service.Default.ShowMoveTarget); - - if (Service.Config.ShowMoveTarget) - { - ImGuiHelper.Spacing(); - - DrawColor4(LocalizationManager.RightLang.ConfigWindow_Param_MovingTargetColor, - ref Service.Config.MovingTargetColor, Service.Default.MovingTargetColor); - } - - DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ShowTarget, - ref Service.Config.ShowTarget, Service.Default.ShowTarget); - - if (Service.Config.ShowTarget) - { - DrawColor4(LocalizationManager.RightLang.ConfigWindow_Param_TargetColor, - ref Service.Config.TargetColor, Service.Default.TargetColor); - - DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_TargetIconSize, - ref Service.Config.TargetIconSize, Service.Default.TargetIconSize); - - ImGuiHelper.Spacing(); - - DrawColor4(LocalizationManager.RightLang.ConfigWindow_Param_SubTargetColor, - ref Service.Config.SubTargetColor, Service.Default.SubTargetColor); - } - - DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_DrawMeleeOffset, - ref Service.Config.DrawMeleeOffset, Service.Default.DrawMeleeOffset); - - DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_DrawingHeight, ref Service.Config.DrawingHeight, Service.Default.DrawingHeight, 0.02f, 0, 8, otherThing: () => - { - PainterManager._painter.DrawingHeight = Service.Config.DrawingHeight; - }); - - DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_SampleLength, ref Service.Config.SampleLength, Service.Default.SampleLength, 0.005f, 0.05f, 3, otherThing: () => - { - PainterManager._painter.SampleLength = Math.Max(0.05f, Service.Config.SampleLength); - }); - } - - ImGui.Separator(); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_KeyBoardNoise, - // ref Service.Config.KeyBoardNoise, Service.Default.KeyBoardNoise); - - //if (Service.Config.KeyBoardNoise) - //{ - // ImGui.Indent(); - - // DrawRangedInt(LocalizationManager.RightLang.ConfigWindow_Param_KeyBoardNoiseTimes, - // ref Service.Config.KeyBoardNoiseMin, ref Service.Config.KeyBoardNoiseMax, - // Service.Default.KeyBoardNoiseMin, Service.Default.KeyBoardNoiseMax); - - // ImGui.Unindent(); - //} - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ShowInfoOnDtr, - // ref Service.Config.ShowInfoOnDtr, Service.Default.ShowInfoOnDtr); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ShowInfoOnToast, - // ref Service.Config.ShowInfoOnToast, Service.Default.ShowInfoOnToast); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ShowToastsAboutDoAction, - // ref Service.Config.ShowToastsAboutDoAction, Service.Default.ShowToastsAboutDoAction); - - ImGui.Spacing(); - } - - private void DrawParamAction() - { - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseAOEAction, - // SettingsCommand.UseAOEAction); - - //if(Service.Config.GetValue(SettingsCommand.UseAOEAction)) - //{ - // ImGui.Indent(); - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseAOEWhenManual, - // SettingsCommand.UseAOEWhenManual); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_NoNewHostiles, - // ref Service.Config.NoNewHostiles, Service.Default.NoNewHostiles, - // LocalizationManager.RightLang.ConfigWindow_Params_NoNewHostilesDesc); - // ImGui.Unindent(); - //} - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_PreventActionsIfOutOfCombat, - // SettingsCommand.PreventActions); - - //if (Service.Config.GetValue(SettingsCommand.PreventActions)) - //{ - // ImGui.Indent(); - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_PreventActionsIfDutyRing, - // SettingsCommand.PreventActionsDuty); - // ImGui.Unindent(); - //} - - //ImGui.Separator(); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoBurst, SettingsCommand.AutoBurst); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoHeal, SettingsCommand.AutoHeal); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseTinctures, - // ref Service.Config.UseTinctures, Service.Default.UseTinctures); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseHealPotions, - // ref Service.Config.UseHealPotions, Service.Default.UseHealPotions); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseAbility, - // SettingsCommand.UseAbility); - - //if (Service.Config.GetValue(SettingsCommand.UseAbility)) - //{ - // ImGui.Indent(); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseDefenseAbility, - // SettingsCommand.UseDefenseAbility, - // LocalizationManager.RightLang.ConfigWindow_Param_UseDefenseAbilityDesc); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoShield, - // SettingsCommand.AutoTankStance); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoProvokeForTank, - // SettingsCommand.AutoProvokeForTank, - // LocalizationManager.RightLang.ConfigWindow_Param_AutoProvokeForTankDesc); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoUseTrueNorth, - // SettingsCommand.AutoUseTrueNorth); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_RaisePlayerBySwift, - // SettingsCommand.RaisePlayerBySwift); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoSpeedOutOfCombat, - // SettingsCommand.AutoSpeedOutOfCombat); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseGroundBeneficialAbility, - // SettingsCommand.UseGroundBeneficialAbility); - - // ImGui.Unindent(); - //} - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_RaisePlayerByCasting, - // ref Service.Config.RaisePlayerByCasting, Service.Default.RaisePlayerByCasting); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseHealWhenNotAHealer, - // ref Service.Config.UseHealWhenNotAHealer, Service.Default.UseHealWhenNotAHealer); - - //DrawIntNumber(LocalizationManager.RightLang.ConfigWindow_Param_LessMPNoRaise, - // ref Service.Config.LessMPNoRaise, Service.Default.LessMPNoRaise, 200, 0, 2000000); - } - - private void DrawParamCondition() - { - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_InterruptibleMoreCheck, - // ref Service.Config.InterruptibleMoreCheck, Service.Default.InterruptibleMoreCheck); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_EsunaAll, - // ref Service.Config.EsunaAll, Service.Default.EsunaAll); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_HealOutOfCombat, - // ref Service.Config.HealOutOfCombat, Service.Default.HealOutOfCombat); - - const float speed = 0.005f; - - // DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_HealWhenNothingTodoBelow, - //ref Service.Config.HealWhenNothingTodoBelow, Service.Default.HealWhenNothingTodoBelow, speed); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_OnlyHotOnTanks, - // ref Service.Config.OnlyHotOnTanks, Service.Default.OnlyHotOnTanks); - - //if (Service.Config.GetValue(SettingsCommand.UseGroundBeneficialAbility)) - //{ - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_BeneficialAreaOnTarget, - // ref Service.Config.BeneficialAreaOnTarget, Service.Default.BeneficialAreaOnTarget); - //} - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_DistanceForMoving, - // ref Service.Config.DistanceForMoving, Service.Default.DistanceForMoving, speed * 3); - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_MeleeRangeOffset, - // ref Service.Config.MeleeRangeOffset, Service.Default.MeleeRangeOffset, 5 * speed, max: 5); - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_HealthDifference, - // ref Service.Config.HealthDifference, Service.Default.HealthDifference, - //speed * 2, 0, 0.5f); - - //if (ImGui.BeginTable("Healing things", 3, ImGuiTableFlags.Borders - // | ImGuiTableFlags.Resizable - // | ImGuiTableFlags.SizingStretchProp)) - //{ - // ImGui.TableSetupScrollFreeze(0, 1); - // ImGui.TableNextRow(ImGuiTableRowFlags.Headers); - - // ImGui.TableNextColumn(); - // ImGui.TableHeader(""); - - // ImGui.TableNextColumn(); - // ImGui.TableHeader(LocalizationManager.RightLang.ConfigWindow_Param_Normal); - - // ImGui.TableNextColumn(); - // ImGui.TableHeader(LocalizationManager.RightLang.ConfigWindow_Param_HOT); - - // ImGui.TableNextRow(); - // ImGui.TableNextColumn(); - // ImGui.Text(LocalizationManager.RightLang.ConfigWindow_Param_HealthAreaAbility); - - // ImGui.TableNextColumn(); - - // DrawFloatNumber("##" + nameof(Service.Config.HealthAreaAbility), - // ref Service.Config.HealthAreaAbility, Service.Default.HealthAreaAbility, speed); - - // ImGui.TableNextColumn(); - - // DrawFloatNumber("##" + nameof(Service.Config.HealthAreaAbilityHot), - // ref Service.Config.HealthAreaAbilityHot, Service.Default.HealthAreaAbilityHot, speed); - - // ImGui.TableNextRow(); - // ImGui.TableNextColumn(); - // ImGui.Text(LocalizationManager.RightLang.ConfigWindow_Param_HealthAreaSpell); - - // ImGui.TableNextColumn(); - - // DrawFloatNumber("##" + nameof(Service.Config.HealthAreaSpell), - // ref Service.Config.HealthAreaSpell, Service.Default.HealthAreaSpell, speed); - - // ImGui.TableNextColumn(); - - // DrawFloatNumber("##" + nameof(Service.Config.HealthAreaSpellHot), - // ref Service.Config.HealthAreaSpellHot, Service.Default.HealthAreaSpellHot, speed); - - // ImGui.TableNextRow(); - // ImGui.TableNextColumn(); - // ImGui.Text(LocalizationManager.RightLang.ConfigWindow_Param_HealthSingleAbility); - - // ImGui.TableNextColumn(); - - // DrawFloatNumber("##" + nameof(Service.Config.HealthSingleAbility), - // ref Service.Config.HealthSingleAbility, Service.Default.HealthSingleAbility, speed); - - // ImGui.TableNextColumn(); - - // DrawFloatNumber("##" + nameof(Service.Config.HealthSingleAbilityHot), - // ref Service.Config.HealthSingleAbilityHot, Service.Default.HealthSingleAbilityHot, speed); - - // ImGui.TableNextRow(); - // ImGui.TableNextColumn(); - // ImGui.Text(LocalizationManager.RightLang.ConfigWindow_Param_HealthSingleSpell); - - // ImGui.TableNextColumn(); - - // DrawFloatNumber("##" + nameof(Service.Config.HealthSingleSpell), - // ref Service.Config.HealthSingleSpell, Service.Default.HealthSingleSpell, speed); - - // ImGui.TableNextColumn(); - - // DrawFloatNumber("##" + nameof(Service.Config.HealthSingleSpellHot), - // ref Service.Config.HealthSingleSpellHot, Service.Default.HealthSingleSpellHot, speed); - - // ImGui.EndTable(); - //} - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_HealthHealerRatio, - // ref Service.Config.HealthHealerRatio, Service.Default.HealthHealerRatio, speed); - - //DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_HealthTankRatio, - // ref Service.Config.HealthTankRatio, Service.Default.HealthTankRatio, speed); - } - - private void DrawParamTarget() - { - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AddEnemyListToHostile, - // ref Service.Config.AddEnemyListToHostile, Service.Default.AddEnemyListToHostile); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ChooseAttackMark, - // ref Service.Config.ChooseAttackMark, Service.Default.ChooseAttackMark); - - //if (Service.Config.ChooseAttackMark && Service.Config.GetValue(SettingsCommand.UseAOEAction)) - //{ - // ImGui.Indent(); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_CanAttackMarkAOE, - // ref Service.Config.CanAttackMarkAOE, Service.Default.CanAttackMarkAOE, - // LocalizationManager.RightLang.ConfigWindow_Param_AttackMarkAOEDesc); - - // ImGui.Unindent(); - //} - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_FilterStopMark, - // ref Service.Config.FilterStopMark, Service.Default.FilterStopMark); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ChangeTargetForFate, - // ref Service.Config.ChangeTargetForFate, Service.Default.ChangeTargetForFate); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_OnlyAttackInView, - // ref Service.Config.OnlyAttackInView, Service.Default.OnlyAttackInView); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_MoveTowardsScreen, - // ref Service.Config.MoveTowardsScreenCenter, Service.Default.MoveTowardsScreenCenter, - // LocalizationManager.RightLang.ConfigWindow_Param_MoveTowardsScreenDesc); - - //DrawIntNumber(LocalizationManager.RightLang.ConfigWindow_Param_MoveTargetAngle, - // ref Service.Config.MoveTargetAngle, Service.Default.MoveTargetAngle, 0.02f, 0, 100, - // LocalizationManager.RightLang.ConfigWindow_Param_MoveTargetAngleDesc); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_MoveAreaActionFarthest, - // ref Service.Config.MoveAreaActionFarthest, Service.Default.MoveAreaActionFarthest, - // LocalizationManager.RightLang.ConfigWindow_Param_MoveAreaActionFarthestDesc); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ActionTargetFriendly, - //SettingsCommand.TargetAllForFriendly); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_RaiseAll, - // ref Service.Config.RaiseAll, Service.Default.RaiseAll); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_RaiseBrinkOfDeath, - // ref Service.Config.RaiseBrinkOfDeath, Service.Default.RaiseBrinkOfDeath); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_TargetFriendly, - // ref Service.Config.TargetFriendly, Service.Default.TargetFriendly); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_TargetFatePriority, - // ref Service.Config.TargetFatePriority, Service.Default.TargetFatePriority); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_TargetHuntingRelicLevePriority, - // ref Service.Config.TargetHuntingRelicLevePriority, Service.Default.TargetHuntingRelicLevePriority); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_TargetQuestPriority, - // ref Service.Config.TargetQuestPriority, Service.Default.TargetQuestPriority); - } -} diff --git a/RotationSolver/UI/RotationConfigWindow_Rotation.cs b/RotationSolver/UI/RotationConfigWindow_Rotation.cs deleted file mode 100644 index d550b383a..000000000 --- a/RotationSolver/UI/RotationConfigWindow_Rotation.cs +++ /dev/null @@ -1,265 +0,0 @@ -using Dalamud.Interface.Colors; -using Dalamud.Utility; -using ECommons.ExcelServices; -using ECommons.GameHelpers; - -using RotationSolver.Data; -using RotationSolver.Helpers; -using RotationSolver.Localization; -using RotationSolver.Updaters; -using System.Diagnostics; - -namespace RotationSolver.UI; -internal partial class RotationConfigWindow -{ - private static void DrawRotationTab() - { - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_Rotation_Description_Old); - - ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f)); - - if (ImGui.BeginTabBar("Job Items")) - { - DrawRoleItems(); - - ImGui.EndTabBar(); - } - ImGui.PopStyleVar(); - } - - private static void DrawRoleItems() - { - foreach (var key in RotationUpdater.CustomRotationsDict.Keys) - { - var rotations = RotationUpdater.CustomRotationsDict[key]; - if (rotations == null || rotations.Length == 0) continue; - - if (ImGui.BeginTabItem(key.ToName())) - { - if (ImGui.BeginChild("Rotation Items", new Vector2(0f, -1f), true)) - { - DrawRotations(rotations); - ImGui.EndChild(); - } - ImGui.EndTabItem(); - } - } - - if (ImGui.BeginTabItem("Info")) - { - DrawInfos(); - ImGui.EndTabItem(); - } - } - - private static void DrawRotations(CustomRotationGroup[] rotations) - { - for (int i = 0; i < rotations.Length; i++) - { - if (i > 0) ImGui.Separator(); - - var group = rotations[i]; - var rotation = RotationUpdater.GetChosenRotation(group); - - var canAddButton = Player.Available - && rotation.Jobs.Contains((Job)Player.Object.ClassJob.Id); - - rotation.Display(group.Rotations, canAddButton); - } - } - - internal static void DrawRotationRole(ICustomRotation rotation, bool canAddButton) - { - DrawTargetHostileType(rotation); - - if (rotation.Configs.Configs.Count != 0) - { - if (ImGui.CollapsingHeader($"{rotation.Jobs[0]} rotation settings##Settings")) - { - ImGui.Indent(); - - DrawSpecialRoleSettings(rotation.ClassJob.GetJobRole(), rotation.Jobs[0]); - rotation.Configs.Draw(canAddButton); - - ImGui.Unindent(); - - ImGui.Spacing(); - } - } - else - { - DrawSpecialRoleSettings(rotation.ClassJob.GetJobRole(), rotation.Jobs[0]); - rotation.Configs.Draw(canAddButton); - } - } - - private static void DrawTargetHostileType(ICustomRotation rotation) - { - var isAllTargetAsHostile = (int)DataCenter.GetTargetHostileType(rotation.ClassJob); - ImGui.SetNextItemWidth(300); - if (ImGui.Combo(LocalizationManager.RightLang.ConfigWindow_Param_RightNowTargetToHostileType + $"##HostileType{rotation.GetHashCode()}", ref isAllTargetAsHostile, new string[] - { - LocalizationManager.RightLang.ConfigWindow_Param_TargetToHostileType1, - LocalizationManager.RightLang.ConfigWindow_Param_TargetToHostileType2, - LocalizationManager.RightLang.ConfigWindow_Param_TargetToHostileType3, - }, 3)) - { - Service.Config.TargetToHostileTypes[rotation.ClassJob.RowId] = (byte)isAllTargetAsHostile; - Service.Config.Save(); - } - - if (isAllTargetAsHostile != 2 && !Service.Config.AutoOffBetweenArea) - { - ImGui.TextColored(ImGuiColors.DPSRed, LocalizationManager.RightLang.ConfigWindow_Param_NoticeUnexpectedCombat); - } - } - - private static void DrawSpecialRoleSettings(JobRole role, Job job) - { - if (role == JobRole.Healer) - { - DrawHealerSettings(job); - } - else if (role == JobRole.Tank) - { - DrawDragFloat(job, LocalizationManager.RightLang.ConfigWindow_Param_HealthForDyingTank, - () => ConfigurationHelper.GetHealthForDyingTank(job), - (value) => Service.Config.HealthForDyingTanks[job] = value, - ConfigurationHelper.HealthForDyingTanksDefault); - } - } - - private static void DrawHealerSettings(Job job) - { - if (ImGui.BeginTable(job.ToString(), 3, ImGuiTableFlags.Borders - | ImGuiTableFlags.Resizable - | ImGuiTableFlags.SizingStretchProp)) - { - ImGui.TableSetupScrollFreeze(0, 1); - ImGui.TableNextRow(ImGuiTableRowFlags.Headers); - - ImGui.TableNextColumn(); - ImGui.TableHeader(""); - - ImGui.TableNextColumn(); - ImGui.TableHeader(LocalizationManager.RightLang.ConfigWindow_Param_Normal); - - ImGui.TableNextColumn(); - ImGui.TableHeader(LocalizationManager.RightLang.ConfigWindow_Param_HOT); - - ImGui.TableNextRow(); - ImGui.TableNextColumn(); - ImGui.Text(LocalizationManager.RightLang.ConfigWindow_Param_HealthAreaAbility); - - ImGui.TableNextColumn(); - - DrawDragFloat(job, nameof(Service.Config.HealthAreaAbilities), - () => ConfigurationHelper.GetHealthAreaAbility(job), - (value) => Service.Config.HealthAreaAbilities[job] = value, - Service.Config.HealthAreaAbility); - - ImGui.TableNextColumn(); - - DrawDragFloat(job, nameof(Service.Config.HealthAreaAbilitiesHot), - () => ConfigurationHelper.GetHealthAreaAbilityHot(job), - (value) => Service.Config.HealthAreaAbilitiesHot[job] = value, - Service.Config.HealthAreaAbilityHot); - - ImGui.TableNextRow(); - ImGui.TableNextColumn(); - ImGui.Text(LocalizationManager.RightLang.ConfigWindow_Param_HealthAreaSpell); - - ImGui.TableNextColumn(); - - DrawDragFloat(job, nameof(Service.Config.HealthAreaSpells), - () => ConfigurationHelper.GetHealthAreaSpell(job), - (value) => Service.Config.HealthAreaSpells[job] = value, - Service.Config.HealthAreaSpell); - - ImGui.TableNextColumn(); - - DrawDragFloat(job, nameof(Service.Config.HealthAreaSpellsHot), - () => ConfigurationHelper.GetHealthAreaSpellHot(job), - (value) => Service.Config.HealthAreaSpellsHot[job] = value, - Service.Config.HealthAreaSpellHot); - - ImGui.TableNextRow(); - ImGui.TableNextColumn(); - ImGui.Text(LocalizationManager.RightLang.ConfigWindow_Param_HealthSingleAbility); - - ImGui.TableNextColumn(); - - DrawDragFloat(job, nameof(Service.Config.HealthSingleAbilities), - () => ConfigurationHelper.GetHealthSingleAbility(job), - (value) => Service.Config.HealthSingleAbilities[job] = value, - Service.Config.HealthSingleAbility); - - ImGui.TableNextColumn(); - - DrawDragFloat(job, nameof(Service.Config.HealthSingleAbilitiesHot), - () => ConfigurationHelper.GetHealthSingleAbilityHot(job), - (value) => Service.Config.HealthSingleAbilitiesHot[job] = value, - Service.Config.HealthSingleAbilityHot); - - ImGui.TableNextRow(); - ImGui.TableNextColumn(); - ImGui.Text(LocalizationManager.RightLang.ConfigWindow_Param_HealthSingleSpell); - - ImGui.TableNextColumn(); - - DrawDragFloat(job, nameof(Service.Config.HealthSingleSpells), - () => ConfigurationHelper.GetHealthSingleSpell(job), - (value) => Service.Config.HealthSingleSpells[job] = value, - Service.Config.HealthSingleSpell); - - ImGui.TableNextColumn(); - - DrawDragFloat(job, nameof(Service.Config.HealthSingleSpellsHot), - () => ConfigurationHelper.GetHealthSingleSpellHot(job), - (value) => Service.Config.HealthSingleSpellsHot[job] = value, - Service.Config.HealthSingleSpellHot); - - ImGui.EndTable(); - } - } - - private static void DrawDragFloat(Job job, string desc, Func getValue, Action setValue, float @default) - { - if (getValue == null || setValue == null) return; - - var value = getValue(); - var last = value; - DrawFloatNumber($"##{job}{desc}", ref value, @default, speed: 0.005f, description: desc); - if(last != value) - { - setValue(value); - Service.Config.Save(); - } - } - - private static void DrawInfos() - { - //if (ImGuiHelper.IconButton(FontAwesomeIcon.Download, "DownloadRotationsButtonInfo")) - //{ - // Task.Run(async () => - // { - // await RotationUpdater.GetAllCustomRotationsAsync(DownloadOption.MustDownload | DownloadOption.ShowList); - // }); - //} - - //ImGui.SameLine(); - //ImGuiHelper.Spacing(); - - //DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Rotation_DownloadRotations, - // ref Service.Config.DownloadRotations, Service.Default.DownloadRotations); - - //if (Service.Config.DownloadRotations) - //{ - // ImGui.SameLine(); - // ImGuiHelper.Spacing(); - - // DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Rotation_AutoUpdateRotations, - // ref Service.Config.AutoUpdateRotations, Service.Default.AutoUpdateRotations); - //} - } -} diff --git a/RotationSolver/UI/SearchableConfigs/CheckBoxSearch.cs b/RotationSolver/UI/SearchableConfigs/CheckBoxSearch.cs index 21bc0288b..5991e8830 100644 --- a/RotationSolver/UI/SearchableConfigs/CheckBoxSearch.cs +++ b/RotationSolver/UI/SearchableConfigs/CheckBoxSearch.cs @@ -27,17 +27,17 @@ public CheckBoxSearchPlugin(PluginConfigBool config, params ISearchable[] childr protected override bool GetValue(Job job) { - return Service.ConfigNew.GetValue(_config); + return Service.Config.GetValue(_config); } protected override void SetValue(Job job, bool value) { - Service.ConfigNew.SetValue(_config, value); + Service.Config.SetValue(_config, value); } public override void ResetToDefault(Job job) { - Service.ConfigNew.SetValue(_config, Service.ConfigNew.GetDefault(_config)); + Service.Config.SetValue(_config, Service.Config.GetDefault(_config)); } } diff --git a/RotationSolver/UI/SearchableConfigs/ColorEditSearch.cs b/RotationSolver/UI/SearchableConfigs/ColorEditSearch.cs index 87c06748d..111bda197 100644 --- a/RotationSolver/UI/SearchableConfigs/ColorEditSearch.cs +++ b/RotationSolver/UI/SearchableConfigs/ColorEditSearch.cs @@ -25,17 +25,17 @@ public ColorEditSearchPlugin(PluginConfigVector4 config) public override void ResetToDefault(Job job) { - Service.ConfigNew.SetValue(_config, Service.ConfigNew.GetDefault(_config)); + Service.Config.SetValue(_config, Service.Config.GetDefault(_config)); } protected override Vector4 GetValue(Job job) { - return Service.ConfigNew.GetValue(_config); + return Service.Config.GetValue(_config); } protected override void SetValue(Job job, Vector4 value) { - Service.ConfigNew.SetValue(_config, value); + Service.Config.SetValue(_config, value); } } diff --git a/RotationSolver/UI/SearchableConfigs/DragFloatRangeSearch.cs b/RotationSolver/UI/SearchableConfigs/DragFloatRangeSearch.cs index c3acca1dc..ab7a6c74b 100644 --- a/RotationSolver/UI/SearchableConfigs/DragFloatRangeSearch.cs +++ b/RotationSolver/UI/SearchableConfigs/DragFloatRangeSearch.cs @@ -28,28 +28,28 @@ public DragFloatRangeSearchJob(JobConfigFloat configMin, JobConfigFloat configMa public override void ResetToDefault(Job job) { - Service.ConfigNew.SetValue(job, _configMin, Service.ConfigNew.GetDefault(job, _configMin)); - Service.ConfigNew.SetValue(job, _configMax, Service.ConfigNew.GetDefault(job, _configMax)); + Service.Config.SetValue(job, _configMin, Service.Config.GetDefault(job, _configMin)); + Service.Config.SetValue(job, _configMax, Service.Config.GetDefault(job, _configMax)); } protected override float GetMinValue(Job job) { - return Service.ConfigNew.GetValue(job, _configMin); + return Service.Config.GetValue(job, _configMin); } protected override void SetMinValue(Job job, float value) { - Service.ConfigNew.SetValue(job, _configMin, value); + Service.Config.SetValue(job, _configMin, value); } protected override float GetMaxValue(Job job) { - return Service.ConfigNew.GetValue(job, _configMax); + return Service.Config.GetValue(job, _configMax); } protected override void SetMaxValue(Job job, float value) { - Service.ConfigNew.SetValue(job, _configMax, value); + Service.Config.SetValue(job, _configMax, value); } } @@ -75,28 +75,28 @@ public DragFloatRangeSearchPlugin(PluginConfigFloat configMin, PluginConfigFloat public override void ResetToDefault(Job job) { - Service.ConfigNew.SetValue(_configMin, Service.ConfigNew.GetDefault(_configMin)); - Service.ConfigNew.SetValue(_configMax, Service.ConfigNew.GetDefault(_configMax)); + Service.Config.SetValue(_configMin, Service.Config.GetDefault(_configMin)); + Service.Config.SetValue(_configMax, Service.Config.GetDefault(_configMax)); } protected override float GetMinValue(Job job) { - return Service.ConfigNew.GetValue(_configMin); + return Service.Config.GetValue(_configMin); } protected override void SetMinValue(Job job, float value) { - Service.ConfigNew.SetValue(_configMin, value); + Service.Config.SetValue(_configMin, value); } protected override float GetMaxValue(Job job) { - return Service.ConfigNew.GetValue(_configMax); + return Service.Config.GetValue(_configMax); } protected override void SetMaxValue(Job job, float value) { - Service.ConfigNew.SetValue(_configMax, value); + Service.Config.SetValue(_configMax, value); } } diff --git a/RotationSolver/UI/SearchableConfigs/DragFloatSearch.cs b/RotationSolver/UI/SearchableConfigs/DragFloatSearch.cs index a6f26e496..ac94e7175 100644 --- a/RotationSolver/UI/SearchableConfigs/DragFloatSearch.cs +++ b/RotationSolver/UI/SearchableConfigs/DragFloatSearch.cs @@ -28,17 +28,17 @@ public DragFloatSearchJob(JobConfigFloat config, float speed) public override void ResetToDefault(Job job) { - Service.ConfigNew.SetValue(job, _config, Service.ConfigNew.GetDefault(job, _config)); + Service.Config.SetValue(job, _config, Service.Config.GetDefault(job, _config)); } protected override float GetValue(Job job) { - return Service.ConfigNew.GetValue(job, _config); + return Service.Config.GetValue(job, _config); } protected override void SetValue(Job job, float value) { - Service.ConfigNew.SetValue(job, _config, value); + Service.Config.SetValue(job, _config, value); } } @@ -65,17 +65,17 @@ public DragFloatSearchPlugin(PluginConfigFloat config, float speed) public override void ResetToDefault(Job job) { - Service.ConfigNew.SetValue(_config, Service.ConfigNew.GetDefault(_config)); + Service.Config.SetValue(_config, Service.Config.GetDefault(_config)); } protected override float GetValue(Job job) { - return Service.ConfigNew.GetValue(_config); + return Service.Config.GetValue(_config); } protected override void SetValue(Job job, float value) { - Service.ConfigNew.SetValue(_config, value); + Service.Config.SetValue(_config, value); } } diff --git a/RotationSolver/UI/SearchableConfigs/DragIntRangeSearch.cs b/RotationSolver/UI/SearchableConfigs/DragIntRangeSearch.cs index 513f2dcac..3c51a9af6 100644 --- a/RotationSolver/UI/SearchableConfigs/DragIntRangeSearch.cs +++ b/RotationSolver/UI/SearchableConfigs/DragIntRangeSearch.cs @@ -28,28 +28,28 @@ public DragIntRangeSearchJob(JobConfigInt configMin, JobConfigInt configMax, flo public override void ResetToDefault(Job job) { - Service.ConfigNew.SetValue(job, _configMin, Service.ConfigNew.GetDefault(job, _configMin)); - Service.ConfigNew.SetValue(job, _configMax, Service.ConfigNew.GetDefault(job, _configMax)); + Service.Config.SetValue(job, _configMin, Service.Config.GetDefault(job, _configMin)); + Service.Config.SetValue(job, _configMax, Service.Config.GetDefault(job, _configMax)); } protected override int GetMinValue(Job job) { - return Service.ConfigNew.GetValue(job, _configMin); + return Service.Config.GetValue(job, _configMin); } protected override void SetMinValue(Job job, int value) { - Service.ConfigNew.SetValue(job, _configMin, value); + Service.Config.SetValue(job, _configMin, value); } protected override int GetMaxValue(Job job) { - return Service.ConfigNew.GetValue(job, _configMax); + return Service.Config.GetValue(job, _configMax); } protected override void SetMaxValue(Job job, int value) { - Service.ConfigNew.SetValue(job, _configMax, value); + Service.Config.SetValue(job, _configMax, value); } } @@ -75,28 +75,28 @@ public DragIntRangeSearchPlugin(PluginConfigInt configMin, PluginConfigInt confi public override void ResetToDefault(Job job) { - Service.ConfigNew.SetValue(_configMin, Service.ConfigNew.GetDefault(_configMin)); - Service.ConfigNew.SetValue(_configMax, Service.ConfigNew.GetDefault(_configMax)); + Service.Config.SetValue(_configMin, Service.Config.GetDefault(_configMin)); + Service.Config.SetValue(_configMax, Service.Config.GetDefault(_configMax)); } protected override int GetMinValue(Job job) { - return Service.ConfigNew.GetValue(_configMin); + return Service.Config.GetValue(_configMin); } protected override void SetMinValue(Job job, int value) { - Service.ConfigNew.SetValue(_configMin, value); + Service.Config.SetValue(_configMin, value); } protected override int GetMaxValue(Job job) { - return Service.ConfigNew.GetValue(_configMax); + return Service.Config.GetValue(_configMax); } protected override void SetMaxValue(Job job, int value) { - Service.ConfigNew.SetValue(_configMax, value); + Service.Config.SetValue(_configMax, value); } } diff --git a/RotationSolver/UI/SearchableConfigs/DragIntSearch.cs b/RotationSolver/UI/SearchableConfigs/DragIntSearch.cs index ff8d1dc59..68bad7091 100644 --- a/RotationSolver/UI/SearchableConfigs/DragIntSearch.cs +++ b/RotationSolver/UI/SearchableConfigs/DragIntSearch.cs @@ -27,19 +27,24 @@ public DragIntSearchJob(JobConfigInt config, float speed) _config = config; } + public DragIntSearchJob(JobConfigInt config, params string[] names) + : base(names) + { + _config = config; + } public override void ResetToDefault(Job job) { - Service.ConfigNew.SetValue(job, _config, Service.ConfigNew.GetDefault(job, _config)); + Service.Config.SetValue(job, _config, Service.Config.GetDefault(job, _config)); } protected override int GetValue(Job job) { - return Service.ConfigNew.GetValue(job, _config); + return Service.Config.GetValue(job, _config); } protected override void SetValue(Job job, int value) { - Service.ConfigNew.SetValue(job, _config, value); + Service.Config.SetValue(job, _config, value); } } @@ -71,17 +76,17 @@ public DragIntSearchPlugin(PluginConfigInt config, params string[] names) public override void ResetToDefault(Job job) { - Service.ConfigNew.SetValue(_config, Service.ConfigNew.GetDefault(_config)); + Service.Config.SetValue(_config, Service.Config.GetDefault(_config)); } protected override int GetValue(Job job) { - return Service.ConfigNew.GetValue(_config); + return Service.Config.GetValue(_config); } protected override void SetValue(Job job, int value) { - Service.ConfigNew.SetValue(_config, value); + Service.Config.SetValue(_config, value); } } diff --git a/RotationSolver/UI/SearchableConfigs/Searchable.cs b/RotationSolver/UI/SearchableConfigs/Searchable.cs index c893f6bc7..0b81954d1 100644 --- a/RotationSolver/UI/SearchableConfigs/Searchable.cs +++ b/RotationSolver/UI/SearchableConfigs/Searchable.cs @@ -45,7 +45,7 @@ public void Draw(Job job, bool mustDraw = false) if (Jobs != null) { - canDraw |= Jobs.Contains(RotationUpdater.Job); + canDraw |= Jobs.Contains(DataCenter.Job); } if (!canDraw) return; @@ -56,26 +56,7 @@ public void Draw(Job job, bool mustDraw = false) PrepareGroup(Popup_Key, Command, () => ResetToDefault(job)); } - public static void PrepareGroup(string key, string command, Action reset) - { - if (ImGui.BeginPopup(key)) - { - if (ImGui.BeginTable(key, 2, ImGuiTableFlags.BordersOuter)) - { - if (reset != null) DrawHotKeys("Reset to Default Value.", reset, "Backspace"); - - if (!string.IsNullOrEmpty(command)) - { - DrawHotKeys($"Execute \"{command}\"", () => ExecuteCommand(command), "Alt"); - DrawHotKeys($"Copy \"{command}\"", () => CopyCommand(command), "Ctrl"); - } - ImGui.EndTable(); - } - - ImGui.EndPopup(); - } - } protected abstract void DrawMain(Job job); @@ -105,11 +86,45 @@ protected void ShowTooltip(Job job, bool showHand = true) }); } - ReactPopup(Popup_Key, Command, () => ResetToDefault(job)); + ReactPopup(Popup_Key, Command, () => ResetToDefault(job), showHand); } + public static void PrepareGroup(string key, string command, Action reset) + { + DrawHotKeysPopup(key, command, ("Reset to Default Value.", reset, new string[] { "Backspace" })); + } public static void ReactPopup(string key, string command, Action reset, bool showHand = true) { + ExecuteHotKeysPopup(key, command, string.Empty, showHand, (reset, new VirtualKey[] { VirtualKey.BACK })); + } + public static void DrawHotKeysPopup(string key, string command, params (string name, Action action, string[] keys)[] pairs) + { + if (ImGui.BeginPopup(key)) + { + if (ImGui.BeginTable(key, 2, ImGuiTableFlags.BordersOuter)) + { + foreach (var (name, action, keys) in pairs) + { + if (action == null) continue; + DrawHotKeys(name, action, keys); + } + if (!string.IsNullOrEmpty(command)) + { + DrawHotKeys($"Execute \"{command}\"", () => ExecuteCommand(command), "Alt"); + + DrawHotKeys($"Copy \"{command}\"", () => CopyCommand(command), "Ctrl"); + } + ImGui.EndTable(); + } + + ImGui.EndPopup(); + } + } + public static void ExecuteHotKeysPopup(string key, string command, string tooltip, bool showHand, params (Action action, VirtualKey[] keys)[] pairs) + { + if (!ImGui.IsItemHovered()) return; + if (!string.IsNullOrEmpty(tooltip)) ImguiTooltips.ShowTooltip(tooltip); + if (showHand) ImGui.SetMouseCursor(ImGuiMouseCursor.Hand); if (ImGui.IsMouseClicked(ImGuiMouseButton.Right)) @@ -119,9 +134,17 @@ public static void ReactPopup(string key, string command, Action reset, bool sho ImGui.OpenPopup(key); } } - if (reset != null) ExecuteHotKeys(reset, VirtualKey.BACK); - ExecuteHotKeys(() => ExecuteCommand(command), VirtualKey.MENU); - ExecuteHotKeys(() => CopyCommand(command), VirtualKey.CONTROL); + + foreach (var (action, keys) in pairs) + { + if (action == null) continue; + ExecuteHotKeys(action, keys); + } + if (!string.IsNullOrEmpty(command)) + { + ExecuteHotKeys(() => ExecuteCommand(command), VirtualKey.MENU); + ExecuteHotKeys(() => CopyCommand(command), VirtualKey.CONTROL); + } } private static void ExecuteCommand(string command) @@ -135,7 +158,20 @@ private static void CopyCommand(string command) Notify.Success($"\"{command}\" copied to clipboard."); } - public static void DrawHotKeys(string name, Action action, params string[] keys) + + private static void ExecuteHotKeys(Action action, params VirtualKey[] keys) + { + if (action == null) return; + var name = string.Join(' ', keys); + + if (!_lastChecked.TryGetValue(name, out var last)) last = false; + var now = keys.All(k => Svc.KeyState[k]); + _lastChecked[name] = now; + + if (!last && now) action(); + } + + private static void DrawHotKeys(string name, Action action, params string[] keys) { if (action == null) return; @@ -152,23 +188,13 @@ public static void DrawHotKeys(string name, Action action, params string[] keys) } private static readonly SortedList _lastChecked = new(); - public static void ExecuteHotKeys(Action action, params VirtualKey[] keys) - { - if (action == null) return; - var name = string.Join(' ', keys); - - if (!_lastChecked.TryGetValue(name, out var last)) last = false; - var now = keys.All(k => Svc.KeyState[k]); - _lastChecked[name] = now; - if (!last && now) action(); - } protected static void DrawJobIcon() { ImGui.SameLine(); - if (IconSet.GetTexture(IconSet.GetJobIcon(RotationUpdater.Job, IconType.Framed), out var texture)) + if (IconSet.GetTexture(IconSet.GetJobIcon(DataCenter.Job, IconType.Framed), out var texture)) { ImGui.Image(texture.ImGuiHandle, Vector2.One * 24 * ImGuiHelpers.GlobalScale); ImguiTooltips.HoveredTooltip(LocalizationManager.RightLang.ConfigWindow_Configs_JobConfigTip); diff --git a/RotationSolver/Updaters/ActionSequencerUpdater.cs b/RotationSolver/Updaters/ActionSequencerUpdater.cs index f71816c80..2c19e4f81 100644 --- a/RotationSolver/Updaters/ActionSequencerUpdater.cs +++ b/RotationSolver/Updaters/ActionSequencerUpdater.cs @@ -1,4 +1,6 @@ -using RotationSolver.ActionSequencer; +using ECommons.ImGuiMethods; +using RotationSolver.ActionSequencer; +using RotationSolver.Basic.Configuration; using RotationSolver.UI; using System.Diagnostics; @@ -10,7 +12,7 @@ internal class ActionSequencerUpdater static IEnumerable _conditionSet; public static MajorConditionSet RightSet => _conditionSet? - .ElementAtOrDefault(Service.Config.ActionSequencerIndex); + .ElementAtOrDefault(Service.Config.GetValue(PluginConfigInt.ActionSequencerIndex)); public static string[] ConditionSetsName => _conditionSet?.Select(s => s.Name).ToArray() ?? Array.Empty(); @@ -90,7 +92,7 @@ private static void Delete(string name) _conditionSet = _conditionSet.Where(c => c.Name != name); } - public static void DrawHeader() + public static void DrawHeader(float width) { var set = RightSet; bool hasSet = set != null; @@ -103,17 +105,22 @@ public static void DrawHeader() ImGui.SameLine(); } + var index = Service.Config.GetValue(PluginConfigInt.ActionSequencerIndex); + var combos = ConditionSetsName; - if (combos != null && combos.Length > Service.Config.ActionSequencerIndex) + if (combos != null && combos.Length > index) { - ImGui.SetNextItemWidth(ImGui.CalcTextSize(combos[Service.Config.ActionSequencerIndex]).X + 30); + ImGui.SetNextItemWidth(ImGui.CalcTextSize(combos[index]).X + width); } else { - ImGui.SetNextItemWidth(30); + ImGui.SetNextItemWidth(width); } - ImGui.Combo("##MajorConditionCombo", ref Service.Config.ActionSequencerIndex, combos, combos.Length); + if(ImGui.Combo("##MajorConditionCombo", ref index, combos, combos.Length)) + { + Service.Config.SetValue(PluginConfigInt.ActionSequencerIndex, index); + } if (hasSet) { @@ -128,25 +135,25 @@ public static void DrawHeader() ImGui.SameLine(); - if (ImGuiHelper.IconButton(FontAwesomeIcon.Plus, "##AddNewTimelineConditionSet")) + if (ImGuiEx.IconButton(FontAwesomeIcon.Plus, "##AddNewTimelineConditionSet")) { AddNew(); } ImGui.SameLine(); - if (ImGuiHelper.IconButton(FontAwesomeIcon.Folder, "##OpenDefinationFolder")) + if (ImGuiEx.IconButton(FontAwesomeIcon.Folder, "##OpenDefinationFolder")) { Process.Start("explorer.exe", _actionSequencerFolder); } ImGui.SameLine(); - if (ImGuiHelper.IconButton(FontAwesomeIcon.Save, "##SaveTheConditions")) + if (ImGuiEx.IconButton(FontAwesomeIcon.Save, "##SaveTheConditions")) { SaveFiles(); } ImGui.SameLine(); - if (ImGuiHelper.IconButton(FontAwesomeIcon.FileDownload, "##LoadTheConditions")) + if (ImGuiEx.IconButton(FontAwesomeIcon.FileDownload, "##LoadTheConditions")) { LoadFiles(); } diff --git a/RotationSolver/Updaters/ActionUpdater.cs b/RotationSolver/Updaters/ActionUpdater.cs index 8a4fe603e..2ab9a74ba 100644 --- a/RotationSolver/Updaters/ActionUpdater.cs +++ b/RotationSolver/Updaters/ActionUpdater.cs @@ -5,6 +5,7 @@ using ECommons.GameHelpers; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.UI.Agent; +using RotationSolver.Basic.Configuration; using RotationSolver.Commands; namespace RotationSolver.Updaters; @@ -13,7 +14,9 @@ internal static class ActionUpdater { internal static DateTime _cancelTime = DateTime.MinValue; - static RandomDelay _GCDDelay = new(() => (Service.Config.WeaponDelayMin, Service.Config.WeaponDelayMax)); + static RandomDelay _GCDDelay = new(() => + (Service.Config.GetValue(PluginConfigFloat.WeaponDelayMin), + Service.Config.GetValue(PluginConfigFloat.WeaponDelayMax))); internal static IAction NextAction { get; set; } internal static IBaseAction NextGCDAction { get; set; } @@ -36,7 +39,7 @@ internal static void UpdateNextAction() if (localPlayer != null && customRotation != null && customRotation.TryInvoke(out var newAction, out var gcdAction)) { - if (Service.Config.MistakeRatio > 0) + if (Service.Config.GetValue(PluginConfigFloat.MistakeRatio) > 0) { var actions = customRotation.AllActions.Where(a => { @@ -132,9 +135,9 @@ private static void UpdateCombatTime() else if (last && !DataCenter.InCombat) { _startCombatTime = DateTime.MinValue; - if (Service.Config.AutoOffAfterCombat > 0) + if (Service.Config.GetValue(PluginConfigFloat.AutoOffAfterCombat) > 0) { - _cancelTime = DateTime.Now.AddSeconds(Service.Config.AutoOffAfterCombat); + _cancelTime = DateTime.Now.AddSeconds(Service.Config.GetValue(PluginConfigFloat.AutoOffAfterCombat)); } } @@ -212,7 +215,7 @@ internal unsafe static bool CanDoAction() || Player.Object.CurrentHp == 0) return false; var maxAhead = Math.Max(DataCenter.MinAnimationLock - DataCenter.Ping, 0.08f); - var ahead = Math.Min(maxAhead, Service.Config.ActionAhead); + var ahead = Math.Min(maxAhead, Service.Config.GetValue(PluginConfigFloat.ActionAhead)); //GCD var canUseGCD = DataCenter.WeaponRemain <= ahead; @@ -238,7 +241,7 @@ internal unsafe static bool CanDoAction() if (timeToNext + nextAction.AnimationLockTime + DataCenter.Ping + DataCenter.MinAnimationLock > DataCenter.WeaponRemain) { if (DataCenter.WeaponRemain > nextAction.AnimationLockTime + ahead + - Math.Max(DataCenter.Ping, Service.Config.MinLastAbilityAdvanced)) return false; + Math.Max(DataCenter.Ping, Service.Config.GetValue(PluginConfigFloat.MinLastAbilityAdvanced))) return false; return RSCommands.CanDoAnAction(false); } diff --git a/RotationSolver/Updaters/MajorUpdater.cs b/RotationSolver/Updaters/MajorUpdater.cs index 74d2d18d7..e7d5f1a59 100644 --- a/RotationSolver/Updaters/MajorUpdater.cs +++ b/RotationSolver/Updaters/MajorUpdater.cs @@ -8,6 +8,7 @@ using FFXIVClientStructs.FFXIV.Client.Game.Control; using FFXIVClientStructs.FFXIV.Client.Game.UI; using FFXIVClientStructs.FFXIV.Component.GUI; +using RotationSolver.Basic.Configuration; using RotationSolver.Commands; using RotationSolver.UI; using System.Runtime.InteropServices; @@ -21,8 +22,8 @@ internal static class MajorUpdater && !Svc.Condition[ConditionFlag.BetweenAreas51] && Player.Available && !SocialUpdater.InPvp; - public static bool ShouldPreventActions => Service.Config.GetValue(SettingsCommand.PreventActions) - && (Service.Config.GetValue(SettingsCommand.PreventActionsDuty) + public static bool ShouldPreventActions => Service.Config.GetValue(PluginConfigBool.PreventActions) + && (Service.Config.GetValue(PluginConfigBool.PreventActionsDuty) && Svc.Condition[ConditionFlag.BoundByDuty] && !Svc.DutyState.IsDutyStarted || !DataCenter.HasHostilesInMaxRange); @@ -78,7 +79,8 @@ private unsafe static void FrameworkUpdate(Framework framework) { SocialUpdater.UpdateSocial(); PreviewUpdater.UpdatePreview(); - if (Service.Config.TeachingMode && ActionUpdater.NextAction!= null) + + if (Service.Config.GetValue(PluginConfigBool.TeachingMode) && ActionUpdater.NextAction!= null) { //Sprint action id is 3 however the id in hot bar is 4. var id = ActionUpdater.NextAction.AdjustedID; @@ -114,7 +116,7 @@ private unsafe static void FrameworkUpdate(Framework framework) try { - if (Service.Config.UseWorkTask) + if (Service.Config.GetValue(PluginConfigBool.UseWorkTask)) { Task.Run(UpdateWork); } @@ -153,8 +155,8 @@ private static void UpdateWork() try { TargetUpdater.UpdateTarget(); - - if (Service.Config.AutoLoadCustomRotations) + + if (Service.Config.GetValue(PluginConfigBool.AutoLoadCustomRotations)) { RotationUpdater.LocalRotationWatcher(); } @@ -211,7 +213,7 @@ private unsafe static void CloseWindow() static uint _lastChest = 0; private unsafe static void OpenChest() { - if (!Service.ConfigNew.GetValue(Basic.Configuration.PluginConfigBool.AutoOpenChest)) return; + if (!Service.Config.GetValue(Basic.Configuration.PluginConfigBool.AutoOpenChest)) return; var player = Player.Object; var treasure = Svc.Objects.FirstOrDefault(o => @@ -252,7 +254,7 @@ private unsafe static void OpenChest() PluginLog.Error(ex, "Failed to open the chest!"); } - if (!Service.ConfigNew.GetValue(Basic.Configuration.PluginConfigBool.AutoOpenChest)) return; + if (!Service.Config.GetValue(Basic.Configuration.PluginConfigBool.AutoOpenChest)) return; _closeWindowTime = DateTime.Now.AddSeconds(0.1); } diff --git a/RotationSolver/Updaters/MovingUpdater.cs b/RotationSolver/Updaters/MovingUpdater.cs index cb633ce20..566a1e41c 100644 --- a/RotationSolver/Updaters/MovingUpdater.cs +++ b/RotationSolver/Updaters/MovingUpdater.cs @@ -33,22 +33,22 @@ internal unsafe static void UpdateCanMove(bool doNextAction) var statusList = new List(4); var actionList = new List(4); - if (Service.Config.PosFlameThrower) + if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.PosFlameThrower)) { statusList.Add(StatusID.Flamethrower); actionList.Add(ActionID.FlameThrower); } - if (Service.Config.PosTenChiJin) + if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.PosTenChiJin)) { statusList.Add(StatusID.TenChiJin); actionList.Add(ActionID.TenChiJin); } - if (Service.Config.PosPassageOfArms) + if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.PosPassageOfArms)) { statusList.Add(StatusID.PassageOfArms); actionList.Add(ActionID.PassageOfArms); } - if (Service.Config.PosImprovisation) + if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.PosImprovisation)) { statusList.Add(StatusID.Improvisation); actionList.Add(ActionID.Improvisation); diff --git a/RotationSolver/Updaters/PreviewUpdater.cs b/RotationSolver/Updaters/PreviewUpdater.cs index 5f1e1910e..d2583c4a3 100644 --- a/RotationSolver/Updaters/PreviewUpdater.cs +++ b/RotationSolver/Updaters/PreviewUpdater.cs @@ -23,7 +23,8 @@ internal static void UpdatePreview() private static void UpdateEntry() { var showStr = RSCommands.EntryString; - if (Service.Config.ShowInfoOnDtr && !string.IsNullOrEmpty(showStr)) + if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.ShowInfoOnDtr) + && !string.IsNullOrEmpty(showStr)) { try { @@ -48,10 +49,11 @@ private static void UpdateEntry() } static RandomDelay _tarStopCastDelay = new(() => - (Service.Config.StopCastingDelayMin, Service.Config.StopCastingDelayMax)); + (Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.StopCastingDelayMin), + Service.Config.GetValue(Basic.Configuration.PluginConfigFloat.StopCastingDelayMax))); private static unsafe void UpdateCancelCast() { - var tarDead = Service.Config.UseStopCasting + var tarDead = Service.Config.GetValue(Basic.Configuration.PluginConfigBool.UseStopCasting) && Svc.Objects.SearchById(Player.Object.CastTargetObjectId) is BattleChara b && b.IsNPCEnemy() && b.CurrentHp == 0; diff --git a/RotationSolver/Updaters/RotationUpdater.cs b/RotationSolver/Updaters/RotationUpdater.cs index acdeba018..a990ee96e 100644 --- a/RotationSolver/Updaters/RotationUpdater.cs +++ b/RotationSolver/Updaters/RotationUpdater.cs @@ -2,6 +2,7 @@ using ECommons.DalamudServices; using ECommons.ExcelServices; using ECommons.GameHelpers; +using RotationSolver.Basic.Configuration; using RotationSolver.Data; using RotationSolver.Helpers; using RotationSolver.Localization; @@ -16,7 +17,6 @@ internal static class RotationUpdater internal static SortedList AuthorHashes { get; private set; } = new SortedList(); internal static CustomRotationGroup[] CustomRotations { get; set; } = Array.Empty(); - public static Job Job => RightNowRotation?.Jobs[0] ?? Job.ADV; public static ICustomRotation RightNowRotation { get; private set; } public static IAction[] RightRotationActions { get; private set; } = Array.Empty(); @@ -45,7 +45,7 @@ public static async Task GetAllCustomRotationsAsync(DownloadOption option) LoadRotationsFromLocal(relayFolder); } - if (option.HasFlag(DownloadOption.Download) && Service.Config.DownloadRotations) + if (option.HasFlag(DownloadOption.Download) && Service.Config.GetValue(PluginConfigBool.DownloadRotations)) await DownloadRotationsAsync(relayFolder, option.HasFlag(DownloadOption.MustDownload)); if (option.HasFlag(DownloadOption.ShowList)) @@ -77,7 +77,7 @@ public static async Task GetAllCustomRotationsAsync(DownloadOption option) /// private static void LoadRotationsFromLocal(string relayFolder) { - var directories = Service.Config.OtherLibs + var directories = Service.Config.GlobalConfig.OtherLibs .Append(relayFolder) .Where(Directory.Exists); @@ -196,11 +196,11 @@ private static async Task DownloadRotationsAsync(string relayFolder, bool mustDo // Code to download rotations from remote server bool hasDownload = false; - var GitHubLinks = Service.ConfigNew.GlobalConfig.GitHubLibs.Union(DownloadHelper.LinkLibraries ?? Array.Empty()); + var GitHubLinks = Service.Config.GlobalConfig.GitHubLibs.Union(DownloadHelper.LinkLibraries ?? Array.Empty()); using (var client = new HttpClient()) { - foreach (var url in Service.ConfigNew.GlobalConfig.OtherLibs.Union(GitHubLinks.Select(Convert))) + foreach (var url in Service.Config.GlobalConfig.OtherLibs.Union(GitHubLinks.Select(Convert))) { hasDownload |= await DownloadOneUrlAsync(url, relayFolder, client, mustDownload); var pdbUrl = Path.ChangeExtension(url, ".pdb"); @@ -239,7 +239,7 @@ private static async Task DownloadOneUrlAsync(string url, string relayFold if (string.IsNullOrEmpty(fileName)) return false; //if (Path.GetExtension(fileName) != ".dll") continue; var filePath = Path.Combine(relayFolder, fileName); - if (!Service.Config.AutoUpdateRotations && File.Exists(filePath)) return false; + if (!Service.Config.GetValue(PluginConfigBool.AutoUpdateRotations) && File.Exists(filePath)) return false; //Download using (HttpResponseMessage response = await client.GetAsync(url)) @@ -304,7 +304,7 @@ public static void LocalRotationWatcher() return; } - var dirs = Service.Config.OtherLibs; + var dirs = Service.Config.GlobalConfig.OtherLibs; foreach (var dir in dirs) { @@ -438,23 +438,21 @@ public static void UpdateRotation() } RightNowRotation = rotation; RightRotationActions = RightNowRotation.AllActions; + DataCenter.Job = RightNowRotation?.Jobs[0] ?? Job.ADV; return; } RightNowRotation = null; RightRotationActions = Array.Empty(); + DataCenter.Job = RightNowRotation?.Jobs[0] ?? Job.ADV; } internal static ICustomRotation GetChosenRotation(CustomRotationGroup group) { - var has = Service.Config.RotationChoices.TryGetValue((uint)group.JobId, out var name); + var name = Service.Config.GetJobConfig(group.JobId).RotationChoice; var rotation = group.Rotations.FirstOrDefault(r => r.GetType().FullName == name); rotation ??= group.Rotations.FirstOrDefault(); - if (!has && rotation != null) - { - Service.Config.RotationChoices[(uint)group.JobId] = rotation.GetType().FullName; - } return rotation; } } diff --git a/RotationSolver/Updaters/SocialUpdater.cs b/RotationSolver/Updaters/SocialUpdater.cs index 006555da2..e6ef1af64 100644 --- a/RotationSolver/Updaters/SocialUpdater.cs +++ b/RotationSolver/Updaters/SocialUpdater.cs @@ -75,7 +75,7 @@ static async void DutyState_DutyCompleted(object sender, ushort e) await Task.Delay(new Random().Next(4000, 6000)); - Service.Config.DutyEnd.AddMacro(); + Service.Config.GlobalConfig.DutyEnd.AddMacro(); } static void ClientState_TerritoryChanged(object sender, ushort e) @@ -138,7 +138,7 @@ internal static async void UpdateSocial() #if DEBUG Svc.Chat.Print("Macro now."); #endif - Service.Config.DutyStart.AddMacro(); + Service.Config.GlobalConfig.DutyStart.AddMacro(); await Task.Delay(new Random().Next(1000, 1500)); SayHelloToAuthor(); } diff --git a/RotationSolver/Updaters/TargetUpdater.cs b/RotationSolver/Updaters/TargetUpdater.cs index af5667d20..c94953e92 100644 --- a/RotationSolver/Updaters/TargetUpdater.cs +++ b/RotationSolver/Updaters/TargetUpdater.cs @@ -79,7 +79,7 @@ private unsafe static void UpdateHostileTargets(IEnumerable allTarg if (b.StatusList.Any(StatusHelper.IsInvincible)) return false; - if (Service.Config.OnlyAttackInView) + if (Service.Config.GetValue(PluginConfigBool.OnlyAttackInView)) { if (!Svc.GameGui.WorldToScreen(b.Position, out _)) return false; } @@ -163,7 +163,7 @@ private static IEnumerable GetHostileTargets(IEnumerable(); + if (!Service.Config.GetValue(PluginConfigBool.AddEnemyListToHostile)) return Array.Empty(); var addons = Service.GetAddons(); @@ -351,7 +351,7 @@ private static IEnumerable FilterForDeath(IEnumerable return loc == b.Position; }); - static (float min, float max) GetHealRange() => (Service.Config.HealDelayMin, Service.Config.HealDelayMax); + static (float min, float max) GetHealRange() => (Service.Config.GetValue(PluginConfigFloat.HealDelayMin), Service.Config.GetValue(PluginConfigFloat.HealDelayMax)); static RandomDelay _healDelay1 = new(GetHealRange); static RandomDelay _healDelay2 = new(GetHealRange); @@ -374,10 +374,10 @@ static void UpdateCanHeal(PlayerCharacter player) var ratio = GetHealingOfTimeRatio(player, StatusHelper.AreaHots); if (!DataCenter.CanHealAreaAbility) - DataCenter.CanHealAreaAbility = DataCenter.PartyMembersDifferHP < Service.Config.HealthDifference && DataCenter.PartyMembersAverHP < Lerp(job.GetHealthAreaAbility(), job.GetHealthAreaAbilityHot(), ratio); + DataCenter.CanHealAreaAbility = DataCenter.PartyMembersDifferHP < Service.Config.GetValue(PluginConfigFloat.HealthDifference) && DataCenter.PartyMembersAverHP < Lerp(job.GetHealthAreaAbility(), job.GetHealthAreaAbilityHot(), ratio); if (!DataCenter.CanHealAreaSpell) - DataCenter.CanHealAreaSpell = DataCenter.PartyMembersDifferHP < Service.Config.HealthDifference && DataCenter.PartyMembersAverHP < Lerp(job.GetHealthAreaSpell(), job.GetHealthAreaSpellHot(), ratio); + DataCenter.CanHealAreaSpell = DataCenter.PartyMembersDifferHP < Service.Config.GetValue(PluginConfigFloat.HealthDifference) && DataCenter.PartyMembersAverHP < Lerp(job.GetHealthAreaSpell(), job.GetHealthAreaSpellHot(), ratio); } //Delay diff --git a/RotationSolver/Watcher.cs b/RotationSolver/Watcher.cs index 0e17fa074..473c98780 100644 --- a/RotationSolver/Watcher.cs +++ b/RotationSolver/Watcher.cs @@ -92,7 +92,7 @@ private static void ActionFromEnemy(ActionEffectSet set) && (effect.value > 0 || (effect.param0 & 6) == 6)) == DataCenter.PartyMembers.Count()) { - if (Service.Config.RecordCastingArea) + if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.RecordCastingArea)) { OtherConfiguration.HostileCastingArea.Add(set.Action.RowId); OtherConfiguration.SaveHostileCastingArea(); @@ -133,7 +133,7 @@ private static void ActionFromSelf(ActionEffectSet set) DataCenter.EffectEndTime = DateTime.Now.AddSeconds(set.Header.AnimationLockTime + 1); //Macro - foreach (var item in Service.Config.Events) + foreach (var item in Service.Config.GlobalConfig.Events) { if (!new Regex(item.Name).Match(action.Name).Success) continue; if (item.AddMacro(tar)) break;