diff --git a/AutoHook/AutoHook.csproj b/AutoHook/AutoHook.csproj index 2be7e5d..b2beff7 100644 --- a/AutoHook/AutoHook.csproj +++ b/AutoHook/AutoHook.csproj @@ -2,7 +2,7 @@ Det - 3.0.0.2 + 3.0.0.3 Auto hooks for you https://github.com/InitialDet/AutoHook Release;Debug diff --git a/AutoHook/Classes/AutoCasts/AutoCastLine.cs b/AutoHook/Classes/AutoCasts/AutoCastLine.cs index 6fbfbd9..17ade37 100644 --- a/AutoHook/Classes/AutoCasts/AutoCastLine.cs +++ b/AutoHook/Classes/AutoCasts/AutoCastLine.cs @@ -4,19 +4,16 @@ namespace AutoHook.Classes.AutoCasts; public class AutoCastLine : BaseActionCast { - public AutoCastLine() : base(UIStrings.AutoCastLine_Auto_Cast_Line, Data.IDs.Actions.Cast) { GpThreshold = 1; } - + public override bool CastCondition() { return true; } - - /*protected override DrawOptionsDelegate DrawOptions => () => - { - - };*/ + + public override string GetName() + => Name = UIStrings.AutoCastLine_Auto_Cast_Line; } \ No newline at end of file diff --git a/AutoHook/Classes/AutoCasts/AutoChum.cs b/AutoHook/Classes/AutoCasts/AutoChum.cs index cdb0572..018fdd2 100644 --- a/AutoHook/Classes/AutoCasts/AutoChum.cs +++ b/AutoHook/Classes/AutoCasts/AutoChum.cs @@ -7,19 +7,22 @@ namespace AutoHook.Classes.AutoCasts; public class AutoChum : BaseActionCast { private bool _onlyUseWithIntuition; - + public AutoChum() : base(UIStrings.Chum, IDs.Actions.Chum) { DoesCancelMooch = true; HelpText = UIStrings.CancelsCurrentMooch; } + public override string GetName() + => Name = UIStrings.Chum; + public override bool CastCondition() { if (!PlayerResources.HasStatus(IDs.Status.FishersIntuition) && _onlyUseWithIntuition) return false; - return true; + return true; } protected override DrawOptionsDelegate DrawOptions => () => diff --git a/AutoHook/Classes/AutoCasts/AutoCordial.cs b/AutoHook/Classes/AutoCasts/AutoCordial.cs index 19edc56..a1190c3 100644 --- a/AutoHook/Classes/AutoCasts/AutoCordial.cs +++ b/AutoHook/Classes/AutoCasts/AutoCordial.cs @@ -15,12 +15,12 @@ public class AutoCordial : BaseActionCast private const uint CordialWateredRecovery = 150; private bool _invertCordialPriority; - + public AutoCordial() : base(UIStrings.Cordial, IDs.Item.Cordial, ActionType.Item) { GpThreshold = 1; } - + public override bool CastCondition() { var cordialList = new List<(uint, bool, uint)> @@ -31,20 +31,21 @@ public override bool CastCondition() (IDs.Item.WateredCordial, true, CordialHqWateredRecovery), // Hq (IDs.Item.WateredCordial, false, CordialWateredRecovery) }; - + if (_invertCordialPriority) cordialList.Reverse(); - + foreach (var (id, hq, recovery) in cordialList) { if (!PlayerResources.HaveItemInInventory(id, hq)) continue; - + Id = id; - + var notOvercaped = PlayerResources.GetCurrentGp() + recovery < PlayerResources.GetMaxGp(); return notOvercaped && PlayerResources.IsPotOffCooldown(); } + return false; } @@ -55,7 +56,7 @@ public override void SetThreshold(int newCost) else GpThreshold = newCost; } - + protected override DrawOptionsDelegate DrawOptions => () => { if (DrawUtil.Checkbox(UIStrings.AutoCastCordialPriority, ref _invertCordialPriority)) diff --git a/AutoHook/Classes/AutoCasts/AutoDoubleHook.cs b/AutoHook/Classes/AutoCasts/AutoDoubleHook.cs index ef044e0..ee53915 100644 --- a/AutoHook/Classes/AutoCasts/AutoDoubleHook.cs +++ b/AutoHook/Classes/AutoCasts/AutoDoubleHook.cs @@ -7,15 +7,18 @@ public class AutoDoubleHook : BaseActionCast { public AutoDoubleHook() : base(UIStrings.Double_Hook, Data.IDs.Actions.DoubleHook, ActionType.Action) { - } + + public override string GetName() + => Name = UIStrings.Double_Hook; + public override bool CastCondition() { return true; } - + /*protected override DrawOptionsDelegate DrawOptions => () => { - + };*/ } \ No newline at end of file diff --git a/AutoHook/Classes/AutoCasts/AutoFishEyes.cs b/AutoHook/Classes/AutoCasts/AutoFishEyes.cs index f3407da..7afc553 100644 --- a/AutoHook/Classes/AutoCasts/AutoFishEyes.cs +++ b/AutoHook/Classes/AutoCasts/AutoFishEyes.cs @@ -12,13 +12,16 @@ public AutoFishEyes() : base(UIStrings.Fish_Eyes, IDs.Actions.FishEyes, ActionTy HelpText = UIStrings.CancelsCurrentMooch; } + public override string GetName() + => Name = UIStrings.Fish_Eyes; + public override bool CastCondition() { return true; } - + /*protected override DrawOptionsDelegate DrawOptions => () => { - + };*/ } \ No newline at end of file diff --git a/AutoHook/Classes/AutoCasts/AutoFood.cs b/AutoHook/Classes/AutoCasts/AutoFood.cs index 8d0c7a2..29c4dbd 100644 --- a/AutoHook/Classes/AutoCasts/AutoFood.cs +++ b/AutoHook/Classes/AutoCasts/AutoFood.cs @@ -7,25 +7,26 @@ namespace AutoHook.Classes.AutoCasts; public class AutoFood : BaseActionCast { private float _secondsRemaining = 0; - + public AutoFood() : base(UIStrings.Food_Buff, 0, ActionType.Item) { - } - + + public override string GetName() + => Name = UIStrings.Food_Buff; + public override bool CastCondition() { - if (PlayerResources.CheckFoodBuff() > _secondsRemaining) { return false; } - + return true; } - + /*protected override DrawOptionsDelegate DrawOptions => () => { - + };*/ } \ No newline at end of file diff --git a/AutoHook/Classes/AutoCasts/AutoIdenticalCast.cs b/AutoHook/Classes/AutoCasts/AutoIdenticalCast.cs index 3be6e68..93baa61 100644 --- a/AutoHook/Classes/AutoCasts/AutoIdenticalCast.cs +++ b/AutoHook/Classes/AutoCasts/AutoIdenticalCast.cs @@ -8,32 +8,34 @@ namespace AutoHook.Classes.AutoCasts; public class AutoIdenticalCast : BaseActionCast { public bool OnlyUseUnderPatience = false; - - public AutoIdenticalCast(string name = "") : base(UIStrings.Identical_Cast, IDs.Actions.IdenticalCast, ActionType.Action) + + public AutoIdenticalCast() : base(UIStrings.Identical_Cast, IDs.Actions.IdenticalCast, ActionType.Action) { - Name = name == "" ? UIStrings.Identical_Cast : name; DoesCancelMooch = true; HelpText = UIStrings.OverridesSurfaceSlap; } + public override string GetName() + => Name = UIStrings.UseIdenticalCast; + public override bool CastCondition() { if (PlayerResources.HasStatus(IDs.Status.IdenticalCast) || PlayerResources.HasStatus(IDs.Status.SurfaceSlap)) return false; - + if (OnlyUseUnderPatience && !PlayerResources.HasStatus(IDs.Status.AnglersFortune)) return false; - + return true; } - + protected override DrawOptionsDelegate DrawOptions => () => { if (DrawUtil.Checkbox(UIStrings.Only_When_Patience_Active, ref OnlyUseUnderPatience)) { Service.Save(); } - + if (DrawUtil.Checkbox(UIStrings.Dont_Cancel_Mooch, ref DontCancelMooch, UIStrings.IdenticalCast_HelpText, true)) { diff --git a/AutoHook/Classes/AutoCasts/AutoMakeShiftBait.cs b/AutoHook/Classes/AutoCasts/AutoMakeShiftBait.cs index 9b3b759..10d2547 100644 --- a/AutoHook/Classes/AutoCasts/AutoMakeShiftBait.cs +++ b/AutoHook/Classes/AutoCasts/AutoMakeShiftBait.cs @@ -14,6 +14,10 @@ public AutoMakeShiftBait() : base(UIStrings.MakeShift_Bait, IDs.Actions.Makeshif { HelpText = UIStrings.TabAutoCasts_DrawMakeShiftBait_HelpText; } + + public override string GetName() + => Name = UIStrings.MakeShift_Bait; + public override bool CastCondition() { if (!Enabled) @@ -34,7 +38,7 @@ public override bool CastCondition() return hasStacks && available; } - + protected override DrawOptionsDelegate DrawOptions => () => { var stack = MakeshiftBaitStacks; @@ -45,5 +49,4 @@ public override bool CastCondition() Service.Save(); } }; -} - +} \ No newline at end of file diff --git a/AutoHook/Classes/AutoCasts/AutoMooch.cs b/AutoHook/Classes/AutoCasts/AutoMooch.cs index 709bbfd..a86f54b 100644 --- a/AutoHook/Classes/AutoCasts/AutoMooch.cs +++ b/AutoHook/Classes/AutoCasts/AutoMooch.cs @@ -10,17 +10,20 @@ public class AutoMooch : BaseActionCast public AutoMooch2 Mooch2 = new(); public bool OnlyMoochIntuition = false; - + public AutoMooch() : base(UIStrings.AutoMooch, Data.IDs.Actions.Mooch, ActionType.Action) { DoesCancelMooch = false; } - + + public override string GetName() + => Name = UIStrings.AutoMooch; + public override bool CastCondition() { if (OnlyMoochIntuition && !PlayerResources.HasStatus(IDs.Status.IdenticalCast)) return false; - + if (Mooch2.IsAvailableToCast()) { Service.PrintDebug(@$"Mooch2 Available, casting mooch2"); @@ -37,11 +40,12 @@ public override bool CastCondition() return true; } - + protected override DrawOptionsDelegate DrawOptions => () => - { + { Mooch2.DrawConfig(); - if (DrawUtil.Checkbox(UIStrings.TabAutoCasts_DrawExtraOptionsAutoMooch_Extra_Only_Active, ref OnlyMoochIntuition)) + if (DrawUtil.Checkbox(UIStrings.TabAutoCasts_DrawExtraOptionsAutoMooch_Extra_Only_Active, + ref OnlyMoochIntuition)) { Service.Save(); } diff --git a/AutoHook/Classes/AutoCasts/AutoMooch2.cs b/AutoHook/Classes/AutoCasts/AutoMooch2.cs index c08d80f..656ae9d 100644 --- a/AutoHook/Classes/AutoCasts/AutoMooch2.cs +++ b/AutoHook/Classes/AutoCasts/AutoMooch2.cs @@ -7,18 +7,18 @@ public class AutoMooch2 : BaseActionCast { public AutoMooch2() : base(UIStrings.UseMoochII, Data.IDs.Actions.Mooch2, ActionType.Action) { - } - + + public override string GetName() + => Name = UIStrings.UseMoochII; + public override bool CastCondition() { return true; } - + /*protected override DrawOptionsDelegate DrawOptions => () => { - + };*/ - - } \ No newline at end of file diff --git a/AutoHook/Classes/AutoCasts/AutoPatience.cs b/AutoHook/Classes/AutoCasts/AutoPatience.cs index d99b27e..fc5f204 100644 --- a/AutoHook/Classes/AutoCasts/AutoPatience.cs +++ b/AutoHook/Classes/AutoCasts/AutoPatience.cs @@ -9,16 +9,18 @@ namespace AutoHook.Classes.AutoCasts; public class AutoPatience : BaseActionCast { public bool EnableMakeshiftPatience; - + public AutoPatience() : base(UIStrings.AutoPatience_Patience, Data.IDs.Actions.Patience2, ActionType.Action) { DoesCancelMooch = true; HelpText = UIStrings.CancelsCurrentMooch; } + public override string GetName() + => Name = UIStrings.AutoPatience_Patience; + public override bool CastCondition() { - if (PlayerResources.HasStatus(IDs.Status.AnglersFortune)) return false; @@ -30,7 +32,7 @@ public override bool CastCondition() return true; } - + protected override DrawOptionsDelegate DrawOptions => () => { if (DrawUtil.Checkbox(UIStrings.TabAutoCasts_DrawExtraOptionsPatience, ref EnableMakeshiftPatience)) diff --git a/AutoHook/Classes/AutoCasts/AutoPrizeCatch.cs b/AutoHook/Classes/AutoCasts/AutoPrizeCatch.cs index c5f1e65..dec6459 100644 --- a/AutoHook/Classes/AutoCasts/AutoPrizeCatch.cs +++ b/AutoHook/Classes/AutoCasts/AutoPrizeCatch.cs @@ -7,17 +7,19 @@ namespace AutoHook.Classes.AutoCasts; public class AutoPrizeCatch : BaseActionCast { - public bool UseWhenMoochIIOnCD = false; public bool UseOnlyWithIdenticalCast = false; - + public AutoPrizeCatch() : base(UIStrings.Prize_Catch, Data.IDs.Actions.PrizeCatch, ActionType.Action) { DoesCancelMooch = true; HelpText = UIStrings.Use_Prize_Catch_HelpText; } + public override string GetName() + => Name = UIStrings.Prize_Catch; + public override bool CastCondition() { if (!Enabled) @@ -40,7 +42,7 @@ public override bool CastCondition() return PlayerResources.ActionAvailable(IDs.Actions.PrizeCatch); } - + protected override DrawOptionsDelegate DrawOptions => () => { if (DrawUtil.Checkbox(UIStrings.AutoCastExtraOptionPrizeCatch, diff --git a/AutoHook/Classes/AutoCasts/AutoSurfaceSlap.cs b/AutoHook/Classes/AutoCasts/AutoSurfaceSlap.cs index d195d4b..a48e054 100644 --- a/AutoHook/Classes/AutoCasts/AutoSurfaceSlap.cs +++ b/AutoHook/Classes/AutoCasts/AutoSurfaceSlap.cs @@ -7,22 +7,23 @@ namespace AutoHook.Classes.AutoCasts; public class AutoSurfaceSlap : BaseActionCast { - - public AutoSurfaceSlap(string name = "") : base(UIStrings.Surface_Slap, Data.IDs.Actions.SurfaceSlap, ActionType.Action) + public AutoSurfaceSlap() : base(UIStrings.Surface_Slap, Data.IDs.Actions.SurfaceSlap, ActionType.Action) { - Name = name == "" ? UIStrings.Identical_Cast : name; DoesCancelMooch = true; HelpText = UIStrings.OverridesIdenticalCast; } - + + public override string GetName() + => Name = UIStrings.UseSurfaceSlap; + public override bool CastCondition() { if (PlayerResources.HasStatus(IDs.Status.IdenticalCast) || PlayerResources.HasStatus(IDs.Status.SurfaceSlap)) return false; - + return true; } - + protected override DrawOptionsDelegate DrawOptions => () => { if (DrawUtil.Checkbox(UIStrings.Dont_Cancel_Mooch, ref DontCancelMooch, diff --git a/AutoHook/Classes/AutoCasts/AutoThaliaksFavor.cs b/AutoHook/Classes/AutoCasts/AutoThaliaksFavor.cs index 5948359..5a188ea 100644 --- a/AutoHook/Classes/AutoCasts/AutoThaliaksFavor.cs +++ b/AutoHook/Classes/AutoCasts/AutoThaliaksFavor.cs @@ -15,6 +15,9 @@ public AutoThaliaksFavor() : base(UIStrings.Thaliaks_Favor, IDs.Actions.Thaliaks { HelpText = UIStrings.TabAutoCasts_DrawThaliaksFavor_HelpText; } + + public override string GetName() + => Name = UIStrings.Thaliaks_Favor; public override bool CastCondition() { diff --git a/AutoHook/Classes/AutoCasts/AutoTripleHook.cs b/AutoHook/Classes/AutoCasts/AutoTripleHook.cs index fed6523..926d663 100644 --- a/AutoHook/Classes/AutoCasts/AutoTripleHook.cs +++ b/AutoHook/Classes/AutoCasts/AutoTripleHook.cs @@ -7,15 +7,18 @@ public class AutoTripleHook : BaseActionCast { public AutoTripleHook() : base(UIStrings.Triple_Hook, Data.IDs.Actions.TripleHook, ActionType.Action) { - } + + public override string GetName() + => Name = UIStrings.Triple_Hook; + public override bool CastCondition() { return true; } - + /*protected override DrawOptionsDelegate DrawOptions => () => { - + };*/ } \ No newline at end of file diff --git a/AutoHook/Classes/BaseActionCast.cs b/AutoHook/Classes/BaseActionCast.cs index 5dce52d..291f212 100644 --- a/AutoHook/Classes/BaseActionCast.cs +++ b/AutoHook/Classes/BaseActionCast.cs @@ -76,13 +76,15 @@ public bool IsAvailableToCast() public abstract bool CastCondition(); + public virtual string GetName() => ""; + protected delegate void DrawOptionsDelegate(); protected virtual DrawOptionsDelegate? DrawOptions => null; public virtual void DrawConfig() { - ImGui.PushID($"{Name}_cfg"); + ImGui.PushID($"{GetName()}_cfg"); if (DrawOptions != null) { @@ -91,7 +93,7 @@ public virtual void DrawConfig() ImGui.SameLine(); - if (ImGui.TreeNodeEx($"{Name}", ImGuiTreeNodeFlags.FramePadding)) + if (ImGui.TreeNodeEx($"{GetName()}", ImGuiTreeNodeFlags.FramePadding)) { ImGui.SameLine(); DrawGpThreshold(); @@ -107,7 +109,7 @@ public virtual void DrawConfig() } else { - if (DrawUtil.Checkbox(Name, ref Enabled, HelpText, true)) + if (DrawUtil.Checkbox(GetName(), ref Enabled, HelpText, true)) Service.Save(); ImGui.SameLine(); @@ -118,7 +120,7 @@ public virtual void DrawConfig() public virtual void DrawGpThreshold() { - ImGui.PushID($"{Name}_gp"); + ImGui.PushID($"{GetName()}_gp"); if (ImGui.Button("GP")) { ImGui.OpenPopup(str_id: @"gp_cfg"); @@ -131,11 +133,11 @@ public virtual void DrawGpThreshold() if (ImGui.Button(" X ")) ImGui.CloseCurrentPopup(); ImGui.SameLine(); - ImGui.TextColored(ImGuiColors.DalamudYellow, $"GP - {Name}"); + ImGui.TextColored(ImGuiColors.DalamudYellow, $"GP - {GetName()}"); if (ImGui.IsItemHovered()) ImGui.SetTooltip( - @$"{Name} {UIStrings.WillBeUsedWhenYourGPIsEqualOr} {(GpThresholdAbove ? UIStrings.Above : UIStrings.Below)} {GpThreshold}"); + @$"{GetName()} {UIStrings.WillBeUsedWhenYourGPIsEqualOr} {(GpThresholdAbove ? UIStrings.Above : UIStrings.Below)} {GpThreshold}"); ImGui.Separator(); if (ImGui.RadioButton(UIStrings.Above, GpThresholdAbove)) diff --git a/AutoHook/Configurations/FishConfig.cs b/AutoHook/Configurations/FishConfig.cs index a4e1c38..07e68d2 100644 --- a/AutoHook/Configurations/FishConfig.cs +++ b/AutoHook/Configurations/FishConfig.cs @@ -14,8 +14,8 @@ public class FishConfig public bool StopAfterCaught = false; public int StopAfterCaughtLimit = 1; - public AutoIdenticalCast IdenticalCast = new(UIStrings.UseIdenticalCast); - public AutoSurfaceSlap SurfaceSlap = new(UIStrings.UseSurfaceSlap); + public AutoIdenticalCast IdenticalCast = new(); + public AutoSurfaceSlap SurfaceSlap = new(); public AutoMooch Mooch = new(); public bool SwapBait = false;