From faef1becc7ab1a9e836b175b05b3c26f0b4da681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Sun, 2 Apr 2023 10:57:33 +0800 Subject: [PATCH] fix: add an option to click simulation intense! --- .../Configuration/PluginConfiguration.cs | 6 ++- RotationSolver/Commands/RSCommands_Actions.cs | 23 +++++++- RotationSolver/Localization/Strings.cs | 4 +- .../UI/RotationConfigWindow_Param.cs | 54 ++++++++++--------- 4 files changed, 58 insertions(+), 29 deletions(-) diff --git a/RotationSolver.Basic/Configuration/PluginConfiguration.cs b/RotationSolver.Basic/Configuration/PluginConfiguration.cs index 927205ea4..d39d8126d 100644 --- a/RotationSolver.Basic/Configuration/PluginConfiguration.cs +++ b/RotationSolver.Basic/Configuration/PluginConfiguration.cs @@ -74,7 +74,11 @@ public class PluginConfiguration : IPluginConfiguration public Vector3 MovingTargetColor = new(0f, 1f, 0.8f); public Vector3 TargetColor = new(1f, 0.2f, 0f); public Vector3 SubTargetColor = new(1f, 0.9f, 0f); - public bool KeyBoardNoise = false; + public bool KeyBoardNoise = true; + public int KeyBoardNoiseMin = 2; + public int KeyBoardNoiseMax = 3; + public float KeyBoardNoiseTimeMin = 0.1f; + public float KeyBoardNoiseTimeMax = 0.2f; public bool UseGroundBeneficialAbility = true; public bool MoveAreaActionFarthest = true; public bool StartOnCountdown = true; diff --git a/RotationSolver/Commands/RSCommands_Actions.cs b/RotationSolver/Commands/RSCommands_Actions.cs index fcc53d865..fcd48762a 100644 --- a/RotationSolver/Commands/RSCommands_Actions.cs +++ b/RotationSolver/Commands/RSCommands_Actions.cs @@ -1,4 +1,5 @@ using Dalamud.Game.ClientState.Conditions; +using Lumina.Excel.GeneratedSheets; using RotationSolver.Actions.BaseAction; using RotationSolver.Basic; using RotationSolver.Basic.Data; @@ -47,7 +48,7 @@ internal static unsafe void DoAnAction(bool isGCD) if (nextAction.Use()) { if (nextAction is BaseAction a && a.ShouldEndSpecial) ResetSpecial(); - if (Service.Config.KeyBoardNoise) PreviewUpdater.PulseActionBar(nextAction.AdjustedID); + if (Service.Config.KeyBoardNoise) Task.Run(() => PulseSimulation(nextAction.AdjustedID)); if (nextAction is BaseAction act) { #if DEBUG @@ -64,6 +65,26 @@ internal static unsafe void DoAnAction(bool isGCD) return; } + static bool started = false; + static async void PulseSimulation(uint id) + { + if (started) return; + started = true; + try + { + for (int i = 0; i < new Random().Next(Service.Config.KeyBoardNoiseMin, + Service.Config.KeyBoardNoiseMax); i++) + { + PreviewUpdater.PulseActionBar(id); + var time = Service.Config.KeyBoardNoiseTimeMin + + new Random().NextDouble() * (Service.Config.KeyBoardNoiseTimeMax - Service.Config.KeyBoardNoiseTimeMin); + await Task.Delay((int)(time * 1000)); + } + } + finally { started = false; } + started = false; + } + internal static void ResetSpecial() => DoSpecialCommandType(SpecialCommandType.EndSpecial, false); private static void CancelState() { diff --git a/RotationSolver/Localization/Strings.cs b/RotationSolver/Localization/Strings.cs index ab70868b0..9bd9ef186 100644 --- a/RotationSolver/Localization/Strings.cs +++ b/RotationSolver/Localization/Strings.cs @@ -122,7 +122,7 @@ internal partial class Strings public string ConfigWindow_Param_HealDelay { get; set; } = "Set the range of random delay for healing people in second."; public string ConfigWindow_Param_NotInCombatDelay { get; set; } = "Set the range of random delay for Not In Combat in second."; - public string ConfigWindow_Param_StopCastingDelay { get; set; } = "Set the range of random delay for stoping casting when target is no need to cast in second."; + 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_Display { get; set; } = "Display"; public string ConfigWindow_Param_Advanced { get; set; } = "Advanced"; public string ConfigWindow_Param_PoslockCasting { get; set; } = "Lock the movement when casting."; @@ -144,6 +144,8 @@ internal partial class Strings public string ConfigWindow_Param_TargetColor { get; set; } = "Target color"; public string ConfigWindow_Param_SubTargetColor { get; set; } = "Sub-target color"; public string ConfigWindow_Param_KeyBoardNoise { get; set; } = "Simulate the effect of pressing"; + public string ConfigWindow_Param_KeyBoardNoiseTimes { get; set; } = "Effect times"; + public string ConfigWindow_Param_KeyBoardNoiseTime { get; set; } = "Effect interval"; public string ConfigWindow_Param_VoiceVolume { get; set; } = "Voice volume"; public string ConfigWindow_Param_VoiceName { get; set; } = "Voice Name"; public string ConfigWindow_Param_FlytextPositional { get; set; } = "Hint positional anticipation by flytext"; diff --git a/RotationSolver/UI/RotationConfigWindow_Param.cs b/RotationSolver/UI/RotationConfigWindow_Param.cs index f7f7ecdec..5227bb6e5 100644 --- a/RotationSolver/UI/RotationConfigWindow_Param.cs +++ b/RotationSolver/UI/RotationConfigWindow_Param.cs @@ -235,6 +235,19 @@ private void DrawParamDisplay() DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_KeyBoardNoise, ref Service.Config.KeyBoardNoise); + if (Service.Config.KeyBoardNoise) + { + ImGui.Indent(); + + DrawRangedInt(LocalizationManager.RightLang.ConfigWindow_Param_KeyBoardNoiseTimes, + ref Service.Config.KeyBoardNoiseMin, ref Service.Config.KeyBoardNoiseMax); + + DrawRangedFloat(LocalizationManager.RightLang.ConfigWindow_Param_KeyBoardNoiseTime, + ref Service.Config.KeyBoardNoiseTimeMin, ref Service.Config.KeyBoardNoiseTimeMax); + + ImGui.Unindent(); + } + DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ShowInfoOnDtr, ref Service.Config.ShowInfoOnDtr); @@ -480,10 +493,7 @@ internal static void DrawCheckBox(string name, ref bool value, string descriptio Service.Config.Save(); otherThing?.Invoke(); } - if (!string.IsNullOrEmpty(description) && ImGui.IsItemHovered()) - { - ImGui.SetTooltip(description); - } + ImGuiHelper.HoveredString(description); } private static void DrawRangedFloat(string name, ref float minValue, ref float maxValue, float speed = 0.01f, float min = 0, float max = 3, string description = "") @@ -493,10 +503,17 @@ private static void DrawRangedFloat(string name, ref float minValue, ref float m { Service.Config.Save(); } - if (!string.IsNullOrEmpty(description) && ImGui.IsItemHovered()) + ImGuiHelper.HoveredString(description); + } + + private static void DrawRangedInt(string name, ref int minValue, ref int maxValue, float speed = 0.01f, int min = 0, int max = 3, string description = "") + { + ImGui.SetNextItemWidth(100); + if (ImGui.DragIntRange2(name, ref minValue, ref maxValue, speed, min, max)) { - ImGui.SetTooltip(description); + Service.Config.Save(); } + ImGuiHelper.HoveredString(description); } private static void DrawFloatNumber(string name, ref float value, float speed = 0.002f, float min = 0, float max = 1, string description = "") @@ -506,10 +523,7 @@ private static void DrawFloatNumber(string name, ref float value, float speed = { Service.Config.Save(); } - if (!string.IsNullOrEmpty(description) && ImGui.IsItemHovered()) - { - ImGui.SetTooltip(description); - } + ImGuiHelper.HoveredString(description); } private static void DrawIntNumber(string name, ref int value, float speed = 0.2f, int min = 0, int max = 1, string description = "", Action otherThing = null) @@ -520,10 +534,7 @@ private static void DrawIntNumber(string name, ref int value, float speed = 0.2f Service.Config.Save(); otherThing?.Invoke(); } - if (!string.IsNullOrEmpty(description) && ImGui.IsItemHovered()) - { - ImGui.SetTooltip(description); - } + ImGuiHelper.HoveredString(description); } private static void DrawColor3(string name, ref Vector3 value, string description = "") @@ -533,10 +544,7 @@ private static void DrawColor3(string name, ref Vector3 value, string descriptio { Service.Config.Save(); } - if (!string.IsNullOrEmpty(description) && ImGui.IsItemHovered()) - { - ImGui.SetTooltip(description); - } + ImGuiHelper.HoveredString(description); } private static void DrawCombo(string name, ref int value, Func toString, T[] choices = null, string description = "") where T : struct, Enum @@ -556,10 +564,7 @@ private static void DrawCombo(string name, ref int value, Func toS } ImGui.EndCombo(); } - if (!string.IsNullOrEmpty(description) && ImGui.IsItemHovered()) - { - ImGui.SetTooltip(description); - } + ImGuiHelper.HoveredString(description); } private static void DrawInputText(string name, ref string value, uint maxLength, string description = "") @@ -569,9 +574,6 @@ private static void DrawInputText(string name, ref string value, uint maxLength, { Service.Config.Save(); } - if (!string.IsNullOrEmpty(description) && ImGui.IsItemHovered()) - { - ImGui.SetTooltip(description); - } + ImGuiHelper.HoveredString(description); } }