Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions ReAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ public override bool Initialise()

var stringData = File.ReadAllText(Path.Join(DirectoryFullName, "CustomAilments.json"));
CustomAilments = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(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)
Expand Down Expand Up @@ -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 && 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);
Expand Down Expand Up @@ -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";
Expand Down
5 changes: 4 additions & 1 deletion ReAgentSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using ExileCore.Shared.Attributes;
using ExileCore.Shared.Interfaces;
using ExileCore.Shared.Nodes;
Expand Down Expand Up @@ -78,4 +78,7 @@ public RangeNode<int> HistorySecondsToKeep

public RangeNode<int> 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);
}
1 change: 1 addition & 0 deletions State/RuleInternalState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class RuleInternalState
public RuleGroup CurrentGroup { get; private set; }
public Dictionary<int, (bool WasActive, DateTime DeactivationTime)> TinctureUsageTracker { get; } = [];

public bool InputElementActive { get; set; }
public bool ChatTitlePanelVisible { get; set; }

public bool LeftPanelVisible { get; set; }
Expand Down
11 changes: 7 additions & 4 deletions State/RuleState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public RuleState(ReAgent plugin, RuleInternalState internalState)
_effects = new Lazy<List<EntityInfo>>(() => controller.EntityListWrapper.ValidEntitiesByType[EntityType.Effect].Select(x => new EntityInfo(controller, x)).ToList(), LazyThreadSafetyMode.None);
_allPlayers = new Lazy<List<MonsterInfo>>(() => controller.EntityListWrapper.ValidEntitiesByType[EntityType.Player]
.Select(x => new MonsterInfo(controller, x)).ToList(), LazyThreadSafetyMode.None);
_leaderName = new Lazy<string>(() => controller.IngameState.ServerData.PartyMembers.FirstOrDefault(p=>p.Type is PartyPlayerInfoType.Leader)?.PlayerInfo.CharacterName, LazyThreadSafetyMode.None);
_leaderName = new Lazy<string>(() => controller.IngameState.ServerData.PartyMembers.FirstOrDefault(p => p.Type is PartyPlayerInfoType.Leader)?.PlayerInfo.CharacterName, LazyThreadSafetyMode.None);
_portals = new Lazy<List<EntityInfo>>(() => controller.EntityListWrapper.ValidEntitiesByType[EntityType.TownPortal]
.Select(x => new EntityInfo(controller, x)).ToList(), LazyThreadSafetyMode.None);
}
Expand Down Expand Up @@ -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);

Expand All @@ -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;

Expand Down