Skip to content

Commit

Permalink
make it easier to identify target painter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcitectus committed Jan 2, 2016
1 parent 30e2b92 commit 3884f6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
19 changes: 9 additions & 10 deletions src/Sanderling/Sanderling/Parse/ModuleButtonTooltip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public interface IModuleButtonTooltip : MemoryStruct.IContainer
int? RangeMax { get; }
int? RangeFalloff { get; }
int? RangeWithin { get; }
int? SignatureRadiusModifierMilli { get; }

MemoryStruct.IUIElementText ToggleKeyTextLabel { get; }

Expand Down Expand Up @@ -119,6 +120,8 @@ public class ModuleButtonTooltip : IModuleButtonTooltip

public int? RangeWithin { private set; get; }

public int? SignatureRadiusModifierMilli { private set; get; }

public MemoryStruct.IUIElementText ToggleKeyTextLabel { private set; get; }

public VirtualKeyCode[] ToggleKey { private set; get; }
Expand Down Expand Up @@ -152,22 +155,18 @@ public ModuleButtonTooltip(MemoryStruct.IContainer Raw)
IsMiner = LabelAnyRegexMatchSuccessIgnoreCase(IsMinerSetIndicatorLabelRegexPattern);
IsSurveyScanner = LabelRegexMatchSuccessIgnoreCase(@"Survey\s*Scan");

var DistanceMinFromLabelWithRegexPattern = new Func<string, int?>(prefixPattern =>
{
var pattern = prefixPattern + Distance.DistanceRegexPattern;

var Match = Raw?.LabelText?.Select(LabelText => LabelText?.Text?.RegexMatchIfSuccess(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))?.WhereNotDefault()?.FirstOrDefault();
var MatchFromLabelWithRegexPattern = new Func<string, System.Text.RegularExpressions.Match>(regexPattern =>
Raw?.LabelText?.Select(LabelText => LabelText?.Text?.RegexMatchIfSuccess(regexPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))?.WhereNotDefault()?.FirstOrDefault());

if (null == Match)
return null;

return (int?)Distance.DistanceParseMin(Match.Value.RegexMatchIfSuccess(Distance.DistanceRegexPattern)?.Value);
});
var DistanceMinFromLabelWithRegexPattern = new Func<string, int?>(prefixPattern =>
(int?)Distance.DistanceParseMin(MatchFromLabelWithRegexPattern(prefixPattern + Distance.DistanceRegexPattern)?.Value?.RegexMatchIfSuccess(Distance.DistanceRegexPattern)?.Value));

RangeWithin = DistanceMinFromLabelWithRegexPattern(@"^Range within\s*");
RangeOptimal = DistanceMinFromLabelWithRegexPattern(@"Optimal range within\s*");
RangeFalloff = DistanceMinFromLabelWithRegexPattern(@"Falloff range within\s*");

SignatureRadiusModifierMilli = (int?)MatchFromLabelWithRegexPattern(@"(" + Number.DefaultNumberFormatRegexPatternAllowLeadingAndTrailingChars + @")\s*%\s*Signature\s*Radius\s*(Modifier|Bonus)")?.Groups[1]?.Value?.NumberParseDecimalMilli() / 100;

ToggleKeyTextLabel = Raw?.LabelText?.OrderByNearestPointOnLine(new Vektor2DInt(-1, 1), label => label?.RegionCenter())?.FirstOrDefault();
ToggleKey = ToggleKeyTextLabel?.Text?.ListKeyCodeFromUIText()?.ToArray();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Sanderling/Sanderling/Parse/Number.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ static public class Number
const string InNumberRegexPatternDecimalSeparatorGroupName = "DecimalSeparator";
const string InNumberRegexPatternDigitGroupSeparatorGroupName = "DigitGroupSeparator";

static readonly string DefaultNumberFormatRegexPattern = DefaultNumberFormatRegexPatternConstruct();
static readonly string DefaultNumberFormatRegexPatternAllowLeadingAndTrailingChars = DefaultNumberFormatRegexPatternConstruct(AllowLeadingCharacters: true, AllowTrailingCharacters: true);
static readonly public string DefaultNumberFormatRegexPattern = DefaultNumberFormatRegexPatternConstruct();
static readonly public string DefaultNumberFormatRegexPatternAllowLeadingAndTrailingChars = DefaultNumberFormatRegexPatternConstruct(AllowLeadingCharacters: true, AllowTrailingCharacters: true);

static readonly public Regex DefaultNumberFormatRegex =
new Regex(DefaultNumberFormatRegexPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
Expand Down

0 comments on commit 3884f6b

Please sign in to comment.