コード例 #1
0
        public override bool BuildMacro(RichPresenceDisplayFunction.RichPresenceDisplayContext context, InterpreterScope scope, out ExpressionBase result)
        {
            var macro = GetStringParameter(scope, "macro", out result);

            if (macro == null)
            {
                return(false);
            }

            var expression = GetParameter(scope, "expression", out result);

            if (expression == null)
            {
                return(false);
            }

            var value = TriggerBuilderContext.GetValueString(expression, scope, out result);

            if (value == null)
            {
                return(false);
            }

            var functionCall = scope.GetContext <FunctionCallExpression>();
            var valueFormat  = GetValueFormat(macro.Value);

            context.RichPresence.AddValueField(functionCall, macro.Value, valueFormat);

            result = new StringConstantExpression(String.Format("@{0}({1})", macro.Value, value));
            return(true);
        }
コード例 #2
0
        public override bool BuildMacro(RichPresenceDisplayFunction.RichPresenceDisplayContext context, InterpreterScope scope, out ExpressionBase result)
        {
            var name = GetStringParameter(scope, "name", out result);

            if (name == null)
            {
                return(false);
            }

            var expression = GetParameter(scope, "expression", out result);

            if (expression == null)
            {
                return(false);
            }

            var dictionary = GetDictionaryParameter(scope, "dictionary", out result);

            if (dictionary == null)
            {
                return(false);
            }

            var fallback = GetStringParameter(scope, "fallback", out result);

            if (fallback == null)
            {
                return(false);
            }

            var value = TriggerBuilderContext.GetValueString(expression, scope, out result);

            if (value == null)
            {
                return(false);
            }

            var functionCall = scope.GetContext <FunctionCallExpression>();

            var error = context.RichPresence.AddLookupField(functionCall, name.Value, dictionary, fallback);

            if (error != null)
            {
                result = error;
                return(false);
            }

            result = new StringConstantExpression(String.Format("@{0}({1})", name.Value, value));
            return(true);
        }
コード例 #3
0
        public override ParseErrorExpression BuildMacro(RichPresenceDisplayFunction.RichPresenceDisplayContext context, InterpreterScope scope, FunctionCallExpression functionCall)
        {
            var name       = (StringConstantExpression)functionCall.Parameters.First();
            var expression = functionCall.Parameters.ElementAt(1);
            var dictionary = (DictionaryExpression)functionCall.Parameters.ElementAt(2);

            ExpressionBase result;
            var            value = TriggerBuilderContext.GetValueString(expression, scope, out result);

            if (value == null)
            {
                return((ParseErrorExpression)result);
            }

            context.RichPresence.AddLookupField(name.Value, dictionary);

            context.DisplayString.Append('@');
            context.DisplayString.Append(name.Value);
            context.DisplayString.Append('(');
            context.DisplayString.Append(value);
            context.DisplayString.Append(')');
            return(null);
        }