Skip to content

Commit

Permalink
remove waits from clicks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaksuhn committed Jul 29, 2024
1 parent 464b760 commit c1de306
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
11 changes: 3 additions & 8 deletions SomethingNeedDoing/Grammar/Commands/ClickCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class ClickCommand : MacroCommand
private string methodName;
private readonly string[] values = [];

private ClickCommand(string text, string addon, string method, string[] mParams, WaitModifier wait) : base(text, wait)
private ClickCommand(string text, string addon, string method, string[] mParams) : base(text)
{
addonName = addon;
methodName = method;
Expand All @@ -35,12 +35,7 @@ private ClickCommand(string text, string addon, string method, string[] mParams,

public static unsafe ClickCommand Parse(string text)
{
var mods = Regex.Match(text, @"<[^>]*>");
var modsText = mods.Success ? mods.Value : string.Empty;
_ = WaitModifier.TryParse(ref modsText, out var waitModifier);

text = !modsText.IsNullOrEmpty() ? text.Replace(modsText, string.Empty).Trim() : text.Trim();
var match = Regex.Match(text.Replace(modsText, string.Empty).Trim());
var match = Regex.Match(text);
if (!match.Success)
throw new MacroSyntaxError(text);

Expand All @@ -49,7 +44,7 @@ public static unsafe ClickCommand Parse(string text)
var methodName = clickValue[1];
var values = clickValue.Skip(2).ToArray();

return new ClickCommand(text, addonName, methodName, values, waitModifier);
return new ClickCommand(text, addonName, methodName, values);
}

public override async Task Execute(ActiveMacro macro, CancellationToken token)
Expand Down
1 change: 1 addition & 0 deletions SomethingNeedDoing/Grammar/Commands/MacroCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal abstract class MacroCommand
{
private static readonly Random Rand = new();

protected MacroCommand(string text) : this(text, 0, 0) { }
protected MacroCommand(string text, WaitModifier waitMod) : this(text, waitMod.Wait, waitMod.Until) { }

protected MacroCommand(string text, WaitModifier waitMod, IndexModifier indexMod) : this(text, waitMod.Wait, waitMod.Until, indexMod.ObjectId) { }
Expand Down

0 comments on commit c1de306

Please sign in to comment.