From 6c73d17f48f46fa515abf4b1ab4274cebaf731da Mon Sep 17 00:00:00 2001 From: sTafnio Date: Sun, 22 Mar 2026 12:39:45 +0100 Subject: [PATCH 1/2] Add InputElementActive, replace ChatTitlePanelVisible with it --- ReAgent.cs | 20 ++++++++++++-------- State/RuleInternalState.cs | 1 + State/RuleState.cs | 11 +++++++---- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/ReAgent.cs b/ReAgent.cs index a6b78a8..ac15ce9 100644 --- a/ReAgent.cs +++ b/ReAgent.cs @@ -38,14 +38,17 @@ public override bool Initialise() var stringData = File.ReadAllText(Path.Join(DirectoryFullName, "CustomAilments.json")); CustomAilments = JsonConvert.DeserializeObject>>(stringData); - Settings.DumpState.OnPressed = () => { ImGui.SetClipboardText(JsonConvert.SerializeObject(new RuleState(this, _internalState), new JsonSerializerSettings + Settings.DumpState.OnPressed = () => { - Error = (sender, args) => + ImGui.SetClipboardText(JsonConvert.SerializeObject(new RuleState(this, _internalState), new JsonSerializerSettings { - DebugWindow.LogError($"Error during state dump {args.ErrorContext.Error}"); - args.ErrorContext.Handled = true; - } - })); }; + Error = (sender, args) => + { + DebugWindow.LogError($"Error during state dump {args.ErrorContext.Error}"); + args.ErrorContext.Handled = true; + } + })); + }; Settings.ImageDirectory.OnValueChanged = () => { foreach (var loadedTexture in _loadedTextures) @@ -324,8 +327,9 @@ public override void Render() _internalState.GraphicToDisplay.Clear(); _internalState.PluginBridgeMethodsToCall.Clear(); _internalState.ProgressBarsToDisplay.Clear(); + _internalState.InputElementActive = GameController.IngameState.FocusedInputElement != null; _internalState.ChatTitlePanelVisible = GameController.IngameState.IngameUi.ChatTitlePanel.IsVisible; - _internalState.CanPressKey = _sinceLastKeyPress.ElapsedMilliseconds >= Settings.GlobalKeyPressCooldown && !_internalState.ChatTitlePanelVisible; + _internalState.CanPressKey = _sinceLastKeyPress.ElapsedMilliseconds >= Settings.GlobalKeyPressCooldown && !_internalState.InputElementActive; _internalState.LeftPanelVisible = GameController.IngameState.IngameUi.OpenLeftPanel.IsVisible; _internalState.RightPanelVisible = GameController.IngameState.IngameUi.OpenRightPanel.IsVisible; _internalState.LargePanelVisible = GameController.IngameState.IngameUi.LargePanels.Any(p => p.IsVisible); @@ -473,7 +477,7 @@ private bool ShouldExecute(out string state) return false; } - if (!Settings.PluginSettings.EnableInEscapeState && + if (!Settings.PluginSettings.EnableInEscapeState && GameController.Game.IsEscapeState) { state = "Escape state is active"; diff --git a/State/RuleInternalState.cs b/State/RuleInternalState.cs index a1f9f36..b7de3d5 100644 --- a/State/RuleInternalState.cs +++ b/State/RuleInternalState.cs @@ -21,6 +21,7 @@ public class RuleInternalState public RuleGroup CurrentGroup { get; private set; } public Dictionary TinctureUsageTracker { get; } = []; + public bool InputElementActive { get; set; } public bool ChatTitlePanelVisible { get; set; } public bool LeftPanelVisible { get; set; } diff --git a/State/RuleState.cs b/State/RuleState.cs index c9ca0b4..ee1d5d3 100644 --- a/State/RuleState.cs +++ b/State/RuleState.cs @@ -108,7 +108,7 @@ public RuleState(ReAgent plugin, RuleInternalState internalState) _effects = new Lazy>(() => controller.EntityListWrapper.ValidEntitiesByType[EntityType.Effect].Select(x => new EntityInfo(controller, x)).ToList(), LazyThreadSafetyMode.None); _allPlayers = new Lazy>(() => controller.EntityListWrapper.ValidEntitiesByType[EntityType.Player] .Select(x => new MonsterInfo(controller, x)).ToList(), LazyThreadSafetyMode.None); - _leaderName = new Lazy(() => controller.IngameState.ServerData.PartyMembers.FirstOrDefault(p=>p.Type is PartyPlayerInfoType.Leader)?.PlayerInfo.CharacterName, LazyThreadSafetyMode.None); + _leaderName = new Lazy(() => controller.IngameState.ServerData.PartyMembers.FirstOrDefault(p => p.Type is PartyPlayerInfoType.Leader)?.PlayerInfo.CharacterName, LazyThreadSafetyMode.None); _portals = new Lazy>(() => controller.EntityListWrapper.ValidEntitiesByType[EntityType.TownPortal] .Select(x => new EntityInfo(controller, x)).ToList(), LazyThreadSafetyMode.None); } @@ -216,10 +216,10 @@ public RuleState(ReAgent plugin, RuleInternalState internalState) [Api] public MonsterInfo PlayerByName(string name) => _allPlayers.Value.FirstOrDefault(p => p.PlayerName.Equals(name)); - + [Api] public MonsterInfo PartyLeader => _allPlayers.Value.FirstOrDefault(p => p.PlayerName.Equals(_leaderName.Value)); - + [Api] public bool PortalExists(int distance) => _portals.Value.Any(p => p.Distance < distance); @@ -245,10 +245,13 @@ public bool SinceLastActivation(double minTime) => [Api] public bool IsTimerRunning(string name) => _internalState.CurrentGroupState.Timers.GetValueOrDefault(name)?.IsRunning ?? false; - + [Api] public float Random(int min, int max) => System.Random.Shared.Next(min, max); + [Api] + public bool IsInputElementActive => _internalState.InputElementActive; + [Api] public bool IsChatOpen => _internalState.ChatTitlePanelVisible; From c20bc3cd4f31c397db654453cfe1fb29a6fab6b2 Mon Sep 17 00:00:00 2001 From: sTafnio Date: Sun, 22 Mar 2026 13:18:17 +0100 Subject: [PATCH 2/2] Add settings option --- ReAgent.cs | 2 +- ReAgentSettings.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ReAgent.cs b/ReAgent.cs index ac15ce9..44eb02c 100644 --- a/ReAgent.cs +++ b/ReAgent.cs @@ -329,7 +329,7 @@ public override void Render() _internalState.ProgressBarsToDisplay.Clear(); _internalState.InputElementActive = GameController.IngameState.FocusedInputElement != null; _internalState.ChatTitlePanelVisible = GameController.IngameState.IngameUi.ChatTitlePanel.IsVisible; - _internalState.CanPressKey = _sinceLastKeyPress.ElapsedMilliseconds >= Settings.GlobalKeyPressCooldown && !_internalState.InputElementActive; + _internalState.CanPressKey = _sinceLastKeyPress.ElapsedMilliseconds >= Settings.GlobalKeyPressCooldown && Settings.PluginSettings.UseFocusedInputElement ? !_internalState.InputElementActive : !_internalState.ChatTitlePanelVisible; _internalState.LeftPanelVisible = GameController.IngameState.IngameUi.OpenLeftPanel.IsVisible; _internalState.RightPanelVisible = GameController.IngameState.IngameUi.OpenRightPanel.IsVisible; _internalState.LargePanelVisible = GameController.IngameState.IngameUi.LargePanels.Any(p => p.IsVisible); diff --git a/ReAgentSettings.cs b/ReAgentSettings.cs index 61e779b..64e45cb 100644 --- a/ReAgentSettings.cs +++ b/ReAgentSettings.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using ExileCore.Shared.Attributes; using ExileCore.Shared.Interfaces; using ExileCore.Shared.Nodes; @@ -78,4 +78,7 @@ public RangeNode HistorySecondsToKeep public RangeNode VerticalTabContainerWidth { get; set; } = new(150, 0, 1000); public ToggleNode IgnoreGracePeriod { get; set; } = new ToggleNode(false); + + [Menu(null, "Check for any active text input (Chat, Search bars, etc.) instead of just the chat panel.")] + public ToggleNode UseFocusedInputElement { get; set; } = new ToggleNode(true); } \ No newline at end of file