From 9a13c43aa7268512a068e6c7cb5ddffc76f7ab7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Sun, 30 Jul 2023 00:47:51 +0800 Subject: [PATCH] fix: add friend target self aoe count checking. --- Resources/AnimationLockTime.json | 3 ++ Resources/HostileCastingArea.json | 7 +++- .../Actions/BaseAction_Target.cs | 15 ++++--- RotationSolver/UI/RotationConfigWindowNew.cs | 39 ++++++++++++++----- RotationSolver/UI/RotationConfigWindowTab.cs | 8 +++- RotationSolver/Updaters/SocialUpdater.cs | 2 +- 6 files changed, 57 insertions(+), 17 deletions(-) diff --git a/Resources/AnimationLockTime.json b/Resources/AnimationLockTime.json index 0d1a7d235..40dda0bb4 100644 --- a/Resources/AnimationLockTime.json +++ b/Resources/AnimationLockTime.json @@ -553,6 +553,8 @@ "25840": 0.6, "25859": 0.1, "25860": 0.1, + "25861": 0.6, + "25862": 0.6, "25865": 0.1, "25870": 0.6, "25871": 0.1, @@ -587,6 +589,7 @@ "29400": 0.6, "29401": 2.5, "29709": 0.1, + "30800": 0.1, "31323": 2.1, "31338": 2.1, "33041": 2.1, diff --git a/Resources/HostileCastingArea.json b/Resources/HostileCastingArea.json index 867a6362e..f0b1ca2ea 100644 --- a/Resources/HostileCastingArea.json +++ b/Resources/HostileCastingArea.json @@ -331,5 +331,10 @@ 25672, 25685, 25690, - 25701 + 25701, + 30421, + 30450, + 30955, + 30447, + 30798 ] \ No newline at end of file diff --git a/RotationSolver.Basic/Actions/BaseAction_Target.cs b/RotationSolver.Basic/Actions/BaseAction_Target.cs index ec86b6e79..98a246f9e 100644 --- a/RotationSolver.Basic/Actions/BaseAction_Target.cs +++ b/RotationSolver.Basic/Actions/BaseAction_Target.cs @@ -347,12 +347,16 @@ private bool TargetHostileManual(BattleChara b, bool mustUse, int aoeCount, out private bool TargetSelf(bool mustUse, int aoeCount) { - if (EffectRange > 0 && !IsFriendly) + if (EffectRange <= 0) return true; + + if (IsFriendly) { - if (NoAOE) - { - return false; - } + var tars = TargetFilter.GetObjectInRadius(TargetFilterFuncEot(DataCenter.PartyMembers, mustUse), EffectRange); + if (tars.Count() < aoeCount) return false; + } + else + { + if (NoAOE) return false; //not use when aoe. if (DataCenter.IsManual) @@ -366,6 +370,7 @@ private bool TargetSelf(bool mustUse, int aoeCount) if (Service.Config.NoNewHostiles && TargetFilter.GetObjectInRadius(DataCenter.AllHostileTargets, EffectRange) .Any(t => t.TargetObject == null)) return false; } + return true; } diff --git a/RotationSolver/UI/RotationConfigWindowNew.cs b/RotationSolver/UI/RotationConfigWindowNew.cs index 9a1dd3cf2..a335af4a4 100644 --- a/RotationSolver/UI/RotationConfigWindowNew.cs +++ b/RotationSolver/UI/RotationConfigWindowNew.cs @@ -14,7 +14,7 @@ public class RotationConfigWindowNew : Window private RotationConfigWindowTab _activeTab; - private const float MIN_COLUMN_WIDTH = 30; + private const float MIN_COLUMN_WIDTH = 24; private const float JOB_ICON_WIDTH = 50; public RotationConfigWindowNew() @@ -55,9 +55,27 @@ private void DrawSideBar() { if (item.GetAttribute() != null) continue; - if(ImGui.Selectable(item.ToString(), _activeTab == item, ImGuiSelectableFlags.None, new Vector2(0, 20))) + var icon = IconSet.GetTexture(item.GetAttribute()?.Icon ?? 0); + + if(icon != null && wholeWidth <= JOB_ICON_WIDTH * _scale) { - _activeTab = item; + var size = Math.Max(_scale * MIN_COLUMN_WIDTH, Math.Min(wholeWidth, _scale * JOB_ICON_WIDTH)) * 0.6f; + DrawItemMiddle(() => + { + if (SilenceImageButton(icon.ImGuiHandle, Vector2.One * size, _activeTab == item)) + { + _activeTab = item; + } + }, Math.Max(_scale * MIN_COLUMN_WIDTH, wholeWidth), size); + + ImguiTooltips.HoveredTooltip(item.ToString()); + } + else + { + if (ImGui.Selectable(item.ToString(), _activeTab == item, ImGuiSelectableFlags.None, new Vector2(0, 20))) + { + _activeTab = item; + } } } ImGui.PopStyleVar(); @@ -67,7 +85,7 @@ private void DrawSideBar() private void DrawHeader(float wholeWidth) { - var size = MathF.Max(_scale * MathF.Min(wholeWidth, _scale * 120), _scale * MIN_COLUMN_WIDTH); + var size = MathF.Max(MathF.Min(wholeWidth, _scale * 120), _scale * MIN_COLUMN_WIDTH); var logo = IconSet.GetTexture("https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/docs/RotationSolverIcon_128.png"); @@ -92,7 +110,12 @@ private void DrawHeader(float wholeWidth) var iconSize = Math.Max(_scale * MIN_COLUMN_WIDTH, Math.Min(wholeWidth, _scale * JOB_ICON_WIDTH)); var comboSize = ImGui.CalcTextSize(rotation.RotationName).X + _scale * 30; - size = comboSize + iconSize + ImGui.GetStyle().ItemSpacing.X; + + const string slash = " - "; + var gameVersionSize = ImGui.CalcTextSize(slash + rotation.GameVersion).X + ImGui.GetStyle().ItemSpacing.X; + var gameVersion = LocalizationManager.RightLang.ConfigWindow_Helper_GameVersion + ": "; + var drawCenter = ImGui.CalcTextSize(slash + gameVersion + rotation.GameVersion).X + iconSize + ImGui.GetStyle().ItemSpacing.X * 3 < wholeWidth; + if(drawCenter) gameVersionSize += ImGui.CalcTextSize(gameVersion).X + ImGui.GetStyle().ItemSpacing.X; DrawItemMiddle(() => { @@ -140,12 +163,10 @@ private void DrawHeader(float wholeWidth) : warning + "\n \n" + LocalizationManager.RightLang.ConfigWindow_Helper_SwitchRotation; ImguiTooltips.HoveredTooltip(warning); - var slash = " - "; ImGui.TextDisabled(slash); ImGui.SameLine(); - var gameVersion = LocalizationManager.RightLang.ConfigWindow_Helper_GameVersion + ": "; - if (ImGui.CalcTextSize(slash + gameVersion + rotation.GameVersion).X + ImGui.GetCursorPosX() - ImGui.GetStyle().ItemSpacing.X < wholeWidth) + if (drawCenter) { ImGui.TextDisabled(gameVersion); ImGui.SameLine(); @@ -153,7 +174,7 @@ private void DrawHeader(float wholeWidth) ImGui.Text(rotation.GameVersion); ImGui.EndGroup(); } - }, wholeWidth, size); + }, wholeWidth, Math.Max(comboSize, gameVersionSize) + iconSize + ImGui.GetStyle().ItemSpacing.X); } } diff --git a/RotationSolver/UI/RotationConfigWindowTab.cs b/RotationSolver/UI/RotationConfigWindowTab.cs index e2de46d52..ff58fd1cb 100644 --- a/RotationSolver/UI/RotationConfigWindowTab.cs +++ b/RotationSolver/UI/RotationConfigWindowTab.cs @@ -6,9 +6,15 @@ internal class TabSkipAttribute : Attribute } +[AttributeUsage(AttributeTargets.Field)] +internal class TabIconAttribute : Attribute +{ + public uint Icon { get; set; } +} + internal enum RotationConfigWindowTab : byte { [TabSkip] About, [TabSkip] Rotation, - Actions, + [TabIcon(Icon = 4)] Actions, } diff --git a/RotationSolver/Updaters/SocialUpdater.cs b/RotationSolver/Updaters/SocialUpdater.cs index ef1665466..b2c374e23 100644 --- a/RotationSolver/Updaters/SocialUpdater.cs +++ b/RotationSolver/Updaters/SocialUpdater.cs @@ -151,7 +151,7 @@ internal static async void UpdateSocial() #if DEBUG Svc.Chat.Print("Macro now."); #endif - //Service.Config.DutyStart.AddMacro(); + Service.Config.DutyStart.AddMacro(); await Task.Delay(new Random().Next(1000, 1500)); SayHelloToAuthor(); }