private bool MatchesSearchCriteria(BaseActionPrototype action, string standardizedSearch, IReadOnlyList <string> selectedFilterTags) { // check filter tag match first - each action must contain all filter tags currently selected. // if no tags selected, don't check tags if (selectedFilterTags.Count > 0 && selectedFilterTags.Any(filterTag => !ActionMatchesFilterTag(action, filterTag))) { return(false); } // check search tag match against the search query if (action.Keywords.Any(standardizedSearch.Contains)) { return(true); } if (Standardize(ActionTypeString(action)).Contains(standardizedSearch)) { return(true); } // allows matching by typing spaces between the enum case changes, like "xeno spit" if the // actiontype is "XenoSpit" if (Standardize(ActionTypeString(action), true).Contains(standardizedSearch)) { return(true); } if (Standardize(action.Name.ToString()).Contains(standardizedSearch)) { return(true); } return(false); }
private string ActionTypeString(BaseActionPrototype baseActionPrototype) { if (baseActionPrototype is ActionPrototype actionPrototype) { return(actionPrototype.ActionType.ToString()); } if (baseActionPrototype is ItemActionPrototype itemActionPrototype) { return(itemActionPrototype.ActionType.ToString()); } throw new InvalidOperationException(); }
private bool ActionMatchesFilterTag(BaseActionPrototype action, string tag) { return(tag switch { AllActionsTag => true, GrantedActionsTag => _actionsComponent.IsGranted(action), ItemTag => action is ItemActionPrototype, NotItemTag => action is ActionPrototype, InstantActionTag => action.BehaviorType == BehaviorType.Instant, TargetActionTag => action.IsTargetAction, ToggleActionTag => action.BehaviorType == BehaviorType.Toggle, _ => action.Filters.Contains(tag) });
public ActionMenuItem(BaseActionPrototype action) { Action = action; CustomMinimumSize = (64, 64); SizeFlagsVertical = SizeFlags.None; AddChild(new TextureRect { SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand, Stretch = TextureRect.StretchMode.Scale, Texture = action.Icon.Frame0() }); TooltipDelay = CustomTooltipDelay; TooltipSupplier = SupplyTooltip; }
public ActionMenuItem(BaseActionPrototype action, Action <ActionMenuItem> onControlFocusExited) { _onControlFocusExited = onControlFocusExited; Action = action; MinSize = (64, 64); VerticalAlignment = VAlignment.Top; AddChild(new TextureRect { HorizontalExpand = true, VerticalExpand = true, Stretch = TextureRect.StretchMode.Scale, Texture = action.Icon.Frame0() }); TooltipDelay = CustomTooltipDelay; TooltipSupplier = SupplyTooltip; }