public ModuleButtonTooltip(MemoryStruct.IContainer raw) { this.Raw = raw; if (null == raw) { return; } var LabelRegexMatchSuccessIgnoreCase = new Func <string, bool>( pattern => raw?.LabelText?.Any(label => label?.Text?.RegexMatchSuccess(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase) ?? false) ?? false); var LabelAnyRegexMatchSuccessIgnoreCase = new Func <string[], bool>( setPattern => setPattern?.Any(LabelRegexMatchSuccessIgnoreCase) ?? false); IsWeapon = LabelAnyRegexMatchSuccessIgnoreCase(IsWeaponSetIndicatorLabelRegexPattern); IsTargetPainter = LabelAnyRegexMatchSuccessIgnoreCase(IsTargetPainterSetIndicatorLabelRegexPattern); IsHardener = LabelAnyRegexMatchSuccessIgnoreCase(IsHardenerSetIndicatorLabelRegexPattern); IsAfterburner = LabelRegexMatchSuccessIgnoreCase("Afterburner"); IsMicroWarpDrive = LabelRegexMatchSuccessIgnoreCase("Microwarpdrive"); IsShieldBooster = LabelAnyRegexMatchSuccessIgnoreCase(IsShieldBoosterSetIndicatorLabelRegexPattern); IsArmorRepairer = LabelAnyRegexMatchSuccessIgnoreCase(IsArmorRepairerSetIndicatorLabelRegexPattern); IsMiner = LabelAnyRegexMatchSuccessIgnoreCase(IsMinerSetIndicatorLabelRegexPattern); IsSurveyScanner = LabelRegexMatchSuccessIgnoreCase(@"Survey\s*Scan"); IsIceHarvester = LabelRegexMatchSuccessIgnoreCase(@"Ice\s*Harvester"); 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()); 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(); }
static public IModuleButtonTooltip ParseAsModuleButtonTooltip(this MemoryStruct.IContainer container) => null == container ? null : new ModuleButtonTooltip(container);
public ModuleButtonTooltip(MemoryStruct.IContainer Raw) { this.Raw = Raw; if (null == Raw) { return; } var LabelRegexMatchSuccessIgnoreCase = new Func<string, bool>( Pattern => Raw?.LabelText?.Any(Label => Label?.Text?.RegexMatchSuccess(Pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase) ?? false) ?? false); var LabelAnyRegexMatchSuccessIgnoreCase = new Func<string[], bool>( SetPattern => SetPattern?.Any(LabelRegexMatchSuccessIgnoreCase) ?? false); IsWeapon = LabelAnyRegexMatchSuccessIgnoreCase(IsWeaponSetIndicatorLabelRegexPattern); IsTargetPainter = LabelAnyRegexMatchSuccessIgnoreCase(IsTargetPainterSetIndicatorLabelRegexPattern); IsHardener = LabelAnyRegexMatchSuccessIgnoreCase(IsHardenerSetIndicatorLabelRegexPattern); IsShieldBooster = LabelAnyRegexMatchSuccessIgnoreCase(IsShieldBoosterSetIndicatorLabelRegexPattern); IsArmorRepairer = LabelAnyRegexMatchSuccessIgnoreCase(IsArmorRepairerSetIndicatorLabelRegexPattern); IsMiner = LabelAnyRegexMatchSuccessIgnoreCase(IsMinerSetIndicatorLabelRegexPattern); IsSurveyScanner = LabelRegexMatchSuccessIgnoreCase(@"Survey\s*Scan"); 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()); 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(); }