예제 #1
0
        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);
        }
예제 #2
0
 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();
 }
예제 #3
0
 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)
     });
예제 #4
0
        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;
        }
예제 #5
0
        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;
        }