コード例 #1
0
        public static DefineableCondition Parse(string s)
        {
            s = Strip(s);

            int depth = 0;

            for (int i = 0; i < s.Length - 1; i++)
            {
                char c  = s[i];
                char cc = s[i + 1];
                if (c == '(')
                {
                    depth++;
                }
                else if (c == ')')
                {
                    depth--;
                }

                if (depth == 0)
                {
                    if (c == '&' && cc == '&')
                    {
                        DefineableCondition con = new DefineableCondition();
                        con.type       = DefineableConditionType.AND;
                        con.condition1 = Parse(s.Substring(0, i));
                        con.condition2 = Parse(s.Substring(i + 2, s.Length - i - 2));
                        return(con);
                    }
                    if (c == '|' && cc == '|')
                    {
                        DefineableCondition con = new DefineableCondition();
                        con.type       = DefineableConditionType.OR;
                        con.condition1 = Parse(s.Substring(0, i));
                        con.condition2 = Parse(s.Substring(i + 2, s.Length - i - 2));
                        return(con);
                    }
                }
            }
            for (int i = 0; i < s.Length - 1; i++)
            {
                char c  = s[i];
                char cc = s[i + 1];
                if (c == '(')
                {
                    depth++;
                }
                else if (c == ')')
                {
                    depth--;
                }

                if (depth == 0)
                {
                    if (c == '>' || c == '<' || c == '=' || c == '!')
                    {
                        DefineableCondition con = new DefineableCondition();
                        con.data = s;
                        con.type = DefineableConditionType.PROPERTY_BOOL;
                        if (s.StartsWith("VRCSDK"))
                        {
                            con.type = DefineableConditionType.VRC_SDK_VERSION;
                            con.data = s.Replace("VRCSDK", "");
                        }
                        else if (s.StartsWith("ThryEditor"))
                        {
                            con.type = DefineableConditionType.VRC_SDK_VERSION;
                            con.data = s.Replace("ThryEditor", "");
                        }
                        return(con);
                    }
                }
            }
            return(new DefineableCondition());
        }
コード例 #2
0
        public static DefineableCondition Parse(string s, Material useThisMaterialInsteadOfOpenEditor = null)
        {
            DefineableCondition con = new DefineableCondition();

            con._materialInsteadOfEditor = useThisMaterialInsteadOfOpenEditor;

            s = Strip(s);

            int depth = 0;

            for (int i = 0; i < s.Length - 1; i++)
            {
                char c  = s[i];
                char cc = s[i + 1];
                if (c == '(')
                {
                    depth++;
                }
                else if (c == ')')
                {
                    depth--;
                }

                if (depth == 0)
                {
                    if (c == '&' && cc == '&')
                    {
                        con.type       = DefineableConditionType.AND;
                        con.condition1 = Parse(s.Substring(0, i), useThisMaterialInsteadOfOpenEditor);
                        con.condition2 = Parse(s.Substring(i + 2, s.Length - i - 2), useThisMaterialInsteadOfOpenEditor);
                        return(con);
                    }
                    if (c == '|' && cc == '|')
                    {
                        con.type       = DefineableConditionType.OR;
                        con.condition1 = Parse(s.Substring(0, i), useThisMaterialInsteadOfOpenEditor);
                        con.condition2 = Parse(s.Substring(i + 2, s.Length - i - 2), useThisMaterialInsteadOfOpenEditor);
                        return(con);
                    }
                }
            }
            if (s.IndexOfAny(ComparissionLiteralsToCheckFor) != -1)
            {
                //is a comparission
                con.data = s;
                con.type = DefineableConditionType.PROPERTY_BOOL;
                if (s.StartsWith("VRCSDK", StringComparison.Ordinal))
                {
                    con.type = DefineableConditionType.VRC_SDK_VERSION;
                    con.data = s.Replace("VRCSDK", "");
                }
                else if (s.StartsWith("ThryEditor", StringComparison.Ordinal))
                {
                    con.type = DefineableConditionType.EDITOR_VERSION;
                    con.data = s.Replace("ThryEditor", "");
                }
                return(con);
            }
            if (s.StartsWith("isNotAnimated(", StringComparison.Ordinal))
            {
                con.type = DefineableConditionType.PROPERTY_IS_NOT_ANIMATED;
                con.data = s.Replace("isNotAnimated(", "").TrimEnd(')');
                return(con);
            }
            if (s.StartsWith("isAnimated(", StringComparison.Ordinal))
            {
                con.type = DefineableConditionType.PROPERTY_IS_ANIMATED;
                con.data = s.Replace("isAnimated(", "").TrimEnd(')');
                return(con);
            }
            return(con);
        }