private static Condition CombineWithOr(IReadOnlyCollection <Condition> operations)
        {
            if (operations.Count < 0)
            {
                throw new InvalidOperationException();
            }

            var conditions = new CompoundCondition(Operator.Or);

            foreach (Condition condition in operations)
            {
                conditions.Or(condition);
            }

            return(conditions);
        }
Exemple #2
0
        /// <summary>
        /// Combines all definitions of the <paramref name="scope"/> with and
        /// </summary>
        /// <param name="scope">The scope where the definitions should be combined</param>
        /// <returns>A with and combined filter definition of all definitions of the scope</returns>
        protected static Condition CombineOperationsOfScope(Neo4JFilterScope scope)
        {
            Queue <Condition> level = scope.Level.Peek();

            if (level.Count == 1)
            {
                return(level.Peek());
            }

            var conditions = new CompoundCondition(Operator.And);

            foreach (Condition condition in level)
            {
                conditions.And(condition);
            }

            return(conditions);
        }
Exemple #3
0
        public static bool TryCreateQuery(
            this Neo4JFilterScope scope,
            [NotNullWhen(true)] out CompoundCondition query)
        {
            query = null;

            if (scope.Level.Peek().Count == 0)
            {
                return(false);
            }

            var conditions = new CompoundCondition(Operator.And);

            foreach (Condition condition in scope.Level.Peek().ToArray())
            {
                conditions.And(condition);
            }

            query = conditions;

            return(true);
        }
Exemple #4
0
 /// <summary>
 /// Tries to build the query based on the items that are stored on the scope
 /// </summary>
 /// <param name="context">The context</param>
 /// <param name="query">The query that was build</param>
 /// <returns>True in case the query has been build successfully, otherwise false</returns>
 public static bool TryCreateQuery(
     this Neo4JFilterVisitorContext context,
     [NotNullWhen(true)] out CompoundCondition query)
 {
     return(context.GetNeo4JFilterScope().TryCreateQuery(out query));
 }
 /// <inheritdoc />
 public INeo4JExecutable WithFiltering(CompoundCondition filters)
 {
     _filters = filters;
     return(this);
 }
Exemple #6
0
 public Condition And(IRelationshipPattern pattern) =>
 CompoundCondition.Create(this, Operator.And, new RelationshipPatternCondition(pattern));
Exemple #7
0
 public Condition And(Condition condition) =>
 CompoundCondition.Create(this, Operator.And, condition);
Exemple #8
0
 public static Condition Or(Condition condition1, Condition condition2) =>
 CompoundCondition.Create(condition1, Operator.Or, condition2);
Exemple #9
0
 public static Condition And(Condition condition1, Condition condition2) =>
 CompoundCondition.Create(condition1, Operator.And, condition2);
Exemple #10
0
 public Condition XOr(Condition condition) =>
 CompoundCondition.Create(this, Operator.XOr, condition);
        public ClientSettingsInterface(
            ModSettings modSettings,
            Game.Settings.GameSettings clientGameSettings,
            ComponentGroup settingsGroup,
            ComponentGroup connectGroup,
            PingInterface pingInterface
            )
        {
            settingsGroup.SetActive(false);

            _clientGameSettings = clientGameSettings;

            var x = 1920f - 210f;
            var y = 1080f - 100f;

            new TextComponent(
                settingsGroup,
                new Vector2(x, y),
                new Vector2(240f, ButtonComponent.DefaultHeight),
                "Settings",
                UiManager.HeaderFontSize,
                alignment: TextAnchor.MiddleLeft
                );

            var closeButton = new ButtonComponent(
                settingsGroup,
                new Vector2(x + 240f / 2f - ButtonComponent.DefaultHeight / 2f, y),
                new Vector2(ButtonComponent.DefaultHeight, ButtonComponent.DefaultHeight),
                "",
                TextureManager.CloseButtonBg,
                FontManager.UIFontRegular,
                UiManager.NormalFontSize
                );

            closeButton.SetOnPress(() => {
                settingsGroup.SetActive(false);
                connectGroup.SetActive(true);
            });

            y -= ButtonComponent.DefaultHeight + 30f;

            var skinSetting = new SettingsEntryInterface(
                settingsGroup,
                new Vector2(x, y),
                "Player skin ID",
                typeof(byte),
                0,
                0,
                o => {
                OnSkinIdChange?.Invoke((byte)o);
            },
                true
                );

            skinSetting.SetInteractable(false);
            _skinCondition = new CompoundCondition(
                () => skinSetting.SetInteractable(true),
                () => skinSetting.SetInteractable(false),
                false, true
                );

            y -= InputComponent.DefaultHeight + 8f;

            new SettingsEntryInterface(
                settingsGroup,
                new Vector2(x, y),
                "Display ping",
                typeof(bool),
                false,
                modSettings.DisplayPing,
                o => {
                var newValue            = (bool)o;
                modSettings.DisplayPing = newValue;

                pingInterface.SetEnabled(newValue);
            },
                true
                );

            y -= SettingsEntryInterface.CheckboxSize + 8f;

            var teamRadioButton = new RadioButtonBoxComponent(
                settingsGroup,
                new Vector2(x, y),
                "Team selection",
                new[] {
                "None",
                "Moss",
                "Hive",
                "Grimm",
                "Lifeblood",
            },
                0
                );

            // Make it non-interactable by default
            teamRadioButton.SetInteractable(false);
            _teamCondition = new CompoundCondition(
                () => teamRadioButton.SetInteractable(true),
                () => {
                teamRadioButton.SetInteractable(false);
                teamRadioButton.Reset();
            },
                false, false, true
                );

            teamRadioButton.SetOnChange(value => {
                if (!_clientGameSettings.TeamsEnabled)
                {
                    return;
                }

                OnTeamRadioButtonChange?.Invoke((Team)value);
            });
        }