Exemplo n.º 1
0
        public async void UseInput()
        {
            await MessageService.ProcessAsync(Message <float> .Create(0.3F, DialoguePlugin.MessageIntegration.Mask,
                                                                      DialoguePlugin.MessageIntegration.HideDialogueBox));

            var title = new StringValue {
                Value = "输入姓和名(空格隔开)"
            };
            var defaultText = new StringValue {
                Value = "诹访部 翔平"
            };
            var confirmText = new StringValue {
                Value = "继续"
            };
            var context = PluginExecuteContext.Create(new ScriptRuntime("Utilities"));
            var message = await MessageService.ProcessAsync(ContextMessage <InputPlugin.MessageIntegration.Content> .Create(context,
                                                                                                                            new InputPlugin.MessageIntegration.Content {
                Title = title, Default = defaultText, ButtonText = confirmText
            },
                                                                                                                            InputPlugin.MessageIntegration.Mask,
                                                                                                                            InputPlugin.MessageIntegration.CreateInput));

            if (message is Message <string> stringMessage)
            {
                Debug.Log(stringMessage.Content);
            }
            await MessageService.ProcessAsync(Message <float> .Create(0.3F, DialoguePlugin.MessageIntegration.Mask,
                                                                      DialoguePlugin.MessageIntegration.ShowDialogueBox));
        }
Exemplo n.º 2
0
 /// <summary>
 /// 创建一条带插件执行上下文的有值消息
 /// </summary>
 /// <param name="context">插件执行上下文</param>
 /// <param name="content">消息内容</param>
 /// <param name="mask">消息掩码</param>
 /// <param name="tag">消息标记(如果有)</param>
 public static ContextMessage <T> Create(int mask, string tag, T content, PluginExecuteContext context)
 {
     return(new ContextMessage <T>(context)
     {
         Mask = mask, Tag = tag, Content = content
     });
 }
Exemplo n.º 3
0
 public async Task<SerializableValue> Execute(PluginExecuteContext context) {
     var parameters = new Dictionary<string, SerializableValue>();
     string effectName = null;
     var duration = 0.0F;
     var easingType = EasingType.Linear;
     foreach (var (key, value) in context.StringParameters) {
         var name = key.ConvertToString(context.Language);
         switch (name) {
             case "Type":
                 effectName = StringValue.TryParse(value, context.Language);
                 break;
             case "Duration":
                 duration = FloatValue.TryParse(value, context.Language);
                 break;
             case "Easing": {
                 var easingName = StringValue.TryParse(value, context.Language);
                 if (!Enum.TryParse<EasingType>(easingName, true, out var easing)) {
                     throw new NotSupportedException($"Unable to create effect: ease type {easingName} is not supported");
                 }
                 easingType = easing;
                 break;
             }
             default:
                 parameters.Add(name, value);
                 break;
         }
     }
     if (string.IsNullOrEmpty(effectName)) throw new NotSupportedException("Unable to create effect: missing effect type");
     if (duration.Equals(0.0F)) throw new NotSupportedException("Unable to create effect: missing duration or duration less than/equals to 0");
     var effect = Create(effectName, parameters, duration, easingType);
     if (effect == null) throw new KeyNotFoundException($"Unable to create effect: expected effect name {effectName} not existed");
     await effect.Initialize();
     var result = new EffectValue(effectName, effect);
     return result;
 }
Exemplo n.º 4
0
        public async Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            EffectValue effect = null;
            var         images = new List <string>();

            foreach (var(key, value) in context.Parameters)
            {
                switch (key)
                {
                case EffectValue effectValue:
                    effect = effectValue;
                    break;

                case IStringConverter stringConverter:
                    var target = stringConverter.ConvertToString(context.Language);
                    if (value != null && !(value is NullValue))
                    {
                        switch (target)
                        {
                        case "Image":
                            var name = StringValue.TryParse(value);
                            if (!images.Contains(name))
                            {
                                images.Add(name);
                            }
                            break;

                        case "Effect":
                            if (value is EffectValue effectValue)
                            {
                                effect = effectValue;
                            }
                            else
                            {
                                throw new ArgumentException($"Unable to set effect: {value} is not EffectValue", nameof(value));
                            }
                            break;
                        }
                    }
                    else
                    {
                        if (!images.Contains(target))
                        {
                            images.Add(target);
                        }
                    }
                    break;
                }
            }
            if (context.CommandName == "PlayEffect")
            {
                await PlayEffect(effect, images.ToArray());
            }
            else
            {
                await StopEffect(images.ToArray());
            }
            return(new NullValue());
        }
Exemplo n.º 5
0
        public override void SetText(PluginExecuteContext context, InputPlugin.MessageIntegration.Content content)
        {
            titleText.text = content.Title != null?content.Title.ConvertToString(context.Language) : "";

            inputField.text = content.Default != null?content.Default.ConvertToString(context.Language) : "";

            confirmText.text = content.ButtonText != null?content.ButtonText.ConvertToString(context.Language) : "OK";
        }
Exemplo n.º 6
0
        public override Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            var result = new ObjectValue();

            foreach (var(key, value) in context.Parameters)
            {
                result.Add(key, value);
            }
            return(Task.FromResult <SerializableValue>(result));
        }
Exemplo n.º 7
0
        public Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            var transformProperty = new TransformValue();

            foreach (var(key, value) in context.StringParameters)
            {
                AnalyzePropertyTo(key.ConvertToString(context.Language), value, transformProperty, context.Language);
            }
            return(Task.FromResult <SerializableValue>(transformProperty));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 加载
        /// </summary>
        private void LoadPluginDispatchServices()
        {
            PluginDefinition pluginDefinition;

            try
            {
                pluginDefinition = ReadPluginDefinitions();
            }
            catch (Exception ex)
            {
                ExceptionLog("LoadPluginDefinition Failed", ex);
                DebugLog("LoadPluginDefinition Failed,Create Empty Config");
                //如果发生异常,创建空的内容
                pluginDefinition = new PluginDefinition();
                File.WriteAllText(PathUtils.PluginDefinitionPath, SerializationUtils.XmlSerialize(pluginDefinition));
            }
            var esClientConfig = EsClientConfigUtils.ReadEsClientConfig();

            if (!esClientConfig.CustomerAgreementState.Registered)
            {
                DebugLog("Not Registered,Start None Plugin");
                return;
            }
            var serverRoles = esClientConfig.ServerRoles;
            //string customerCode = LicenseUtils.GetCustomerCode(esClientConfig.LicenseOperatorServiceAddress);
            var hostName = Dns.GetHostName();

            foreach (var pluginConfig in pluginDefinition.PluginConfigs)
            {
                //插件启用的服务器角色中 有当前服务器角色(之一) 启用
                if (!CheckEnableByServerRole(serverRoles, pluginConfig.EnableServerRoles))
                {
                    DebugLog(string.Format("Server Role Not Match:[{0}][{1}][{2}]",
                                           pluginConfig.TypeKey, string.Join(",", serverRoles.ToArray()),
                                           string.Join(",", pluginConfig.EnableServerRoles.ToArray())));
                    continue;
                }
                if (!CheckEnableByAgreement(esClientConfig.CustomerAgreementState, pluginConfig.PluginType))
                {
                    DebugLog(string.Format("Agreement Not Match:[{0}][{1}][{2}][{3}][{4}]",
                                           pluginConfig.TypeKey, esClientConfig.CustomerAgreementState.Registered,
                                           esClientConfig.CustomerAgreementState.AgreeToUxImproving,
                                           esClientConfig.CustomerAgreementState.AgreeToE10Examination,
                                           pluginConfig.PluginType));
                    continue;
                }
                var context = new PluginExecuteContext(pluginConfig, serverRoles, null,
                                                       hostName, esClientConfig.LicenseOperatorServiceAddress);
                var pluginDispatchService = new PluginDispatchService(context);
                //注入服务环境
                Connection(pluginDispatchService, ResourceServiceProvider, ServiceCallContext);
                DebugLog("Add Plugin:" + pluginConfig.TypeKey);
                _pluginDispatchServices.Add(pluginDispatchService);
            }
        }
Exemplo n.º 9
0
 public Task <SerializableValue> Execute(PluginExecuteContext context)
 {
     foreach (var(key, _) in context.Parameters)
     {
         return(Task.FromResult <SerializableValue>(new FloatValue {
             value = FloatValue.TryParse(key, context.Language)
         }));
     }
     return(Task.FromResult <SerializableValue>(new FloatValue {
         value = 0
     }));
 }
Exemplo n.º 10
0
        public async Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            var description = new MessageIntegration.Content();

            foreach (var(name, value) in context.StringParameters)
            {
                switch (name.ConvertToString(context.Language))
                {
                case "Title":
                    if (value is IStringConverter stringTitle)
                    {
                        description.Title = stringTitle;
                    }
                    else
                    {
                        throw new NotSupportedException($"Unable to create input: title {value} is not string value");
                    }
                    break;

                case "Default":
                    if (value is IStringConverter stringDefault)
                    {
                        description.Default = stringDefault;
                    }
                    else
                    {
                        throw new NotSupportedException($"Unable to create input: default {value} is not string value");
                    }
                    break;

                case "ButtonText":
                    if (value is IStringConverter stringButton)
                    {
                        description.ButtonText = stringButton;
                    }
                    else
                    {
                        throw new NotSupportedException($"Unable to create input: button text {value} is not string value");
                    }
                    break;

                default:
                    Debug.LogWarning($"Input plugin: unknown parameter {name}");
                    break;
                }
            }
            var message = await MessageService.ProcessAsync(ContextMessage <MessageIntegration.Content> .Create(MessageIntegration.Mask, MessageIntegration.CreateInput, description, context));

            return(message is Message <string> stringMessage ? new StringValue {
                value = stringMessage.Content
            } : null);
        }
Exemplo n.º 11
0
        public Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            var result = new Texture2DValue();

            foreach (var(key, value) in context.StringParameters)
            {
                var name = key.ConvertToString(context.Language);
                switch (name)
                {
                case "Source":
                    result.source = StringValue.TryParse(value, context.Language);
                    break;
                }
            }
            return(Task.FromResult <SerializableValue>(result));
        }
Exemplo n.º 12
0
        private async Task CreateDialogue()
        {
            var plugin = PluginManager.Find("Dialogue");

            if (plugin == null)
            {
                throw new RuntimeException(_callStack, "Unable to create dialogue: no dialogue plugin registered");
            }
            MemoryStack.Push(await plugin.Execute(PluginExecuteContext.Create(this, "Dialogue", new List <KeyValuePair <SerializableValue, SerializableValue> > {
                new KeyValuePair <SerializableValue, SerializableValue>(new StringValue {
                    value = "Character"
                }, MemoryStack.Pop()),
                new KeyValuePair <SerializableValue, SerializableValue>(new StringValue {
                    value = "Content"
                }, MemoryStack.Pop())
            })) ?? new NullValue());
        }
Exemplo n.º 13
0
        private async Task CreatePluginCall()
        {
            var(plugin, name) = FindPlugin();
            var parameterCount = ((IIntegerConverter)MemoryStack.Pop()).ConvertToInteger(ActiveLanguage);
            var parameters     = new List <KeyValuePair <SerializableValue, SerializableValue> >();

            for (var i = -1; ++i < parameterCount;)
            {
                parameters.Add(new KeyValuePair <SerializableValue, SerializableValue>(
                                   MemoryStack.Pop() ?? new NullValue(), MemoryStack.Pop() ?? new NullValue()));
            }
            parameters.Reverse();
            var context = PluginExecuteContext.Create(this, name, parameters);

            try {
                MemoryStack.Push(await plugin.Execute(context) ?? new NullValue());
            } catch (Exception ex) {
                throw new RuntimeException(_callStack, ex);
            }
        }
Exemplo n.º 14
0
        public Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            float x = 0.0F, y = 0.0F;

            foreach (var(key, value) in context.StringParameters)
            {
                var name = key.ConvertToString(context.Language);
                switch (name)
                {
                case "X":
                    x = FloatValue.TryParse(value, context.Language);
                    break;

                case "Y":
                    y = FloatValue.TryParse(value, context.Language);
                    break;
                }
            }
            return(Task.FromResult <SerializableValue>(new Vector2Value(x, y)));
        }
Exemplo n.º 15
0
        public async Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            var dialogue = new MessageIntegration.Content();

            foreach (var(name, value) in context.StringParameters)
            {
                switch (name.ConvertToString(context.Language))
                {
                case "Show":
                    await ShowWindow(value, context.Language);

                    return(new NullValue());

                case "Hide":
                    await HideWindow(value, context.Language);

                    return(new NullValue());

                case "Character":
                    dialogue.Character = value;
                    break;

                case "Content":
                    if (value is IStringConverter stringContent)
                    {
                        dialogue.Text = stringContent;
                    }
                    else
                    {
                        throw new ArgumentException($"Unable to create dialogue: unsupported content type {value}");
                    }
                    break;
                }
            }
            await MessageService.ProcessAsync(ContextMessage <MessageIntegration.Content> .Create(MessageIntegration.Mask, MessageIntegration.NewDialogue, dialogue, context));

            return(new NullValue());
        }
Exemplo n.º 16
0
        public Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            var character = new CharacterValue();

            foreach (var(key, value) in context.StringParameters)
            {
                var stringValue = value as IStringConverter;
                switch (key.ConvertToString(context.Runtime.ActiveLanguage))
                {
                case "Name":
                    if (stringValue == null)
                    {
                        Debug.LogWarning($"Skip parameter Name when creating Character: {value} is not string value");
                    }
                    else
                    {
                        character.name = stringValue;
                    }
                    break;

                case "Avatar":
                    if (stringValue == null)
                    {
                        Debug.LogWarning($"Skip parameter Avatar when creating Character: {value} is not string value");
                    }
                    else
                    {
                        character.avatar = stringValue;
                    }
                    break;

                default:
                    continue;
                }
            }
            return(Task.FromResult <SerializableValue>(character));
        }
Exemplo n.º 17
0
        public Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            float x = 0.0F, y = 0.0F, width = 0.0F, height = 0.0F;

            foreach (var(key, value) in context.StringParameters)
            {
                switch (key.ConvertToString(context.Language))
                {
                case "X":
                    x = FloatValue.TryParse(value, context.Language);
                    break;

                case "Y":
                    y = FloatValue.TryParse(value, context.Language);
                    break;

                case "Width":
                case "W":
                    width = FloatValue.TryParse(value, context.Language);
                    break;

                case "Height":
                case "H":
                    height = FloatValue.TryParse(value, context.Language);
                    break;

                case "Position":
                    (x, y) = GetCoordinates(value, context.Language);
                    break;

                case "Size":
                    (width, height) = GetCoordinates(value, context.Language);
                    break;
                }
            }
            return(Task.FromResult <SerializableValue>(new RectValue(x, y, width, height)));
        }
Exemplo n.º 18
0
        public async Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            float?time = null;

            foreach (var(key, value) in context.Parameters)
            {
                switch (key)
                {
                case IFloatConverter floatConverter:
                    time = floatConverter.ConvertToFloat(context.Language);
                    break;

                case IStringConverter stringConverter when stringConverter.ConvertToString(context.Language) == "Duration":
                    time = FloatValue.TryParse(value, context.Language);

                    break;
                }
            }
            if (time != null)
            {
                await Dispatcher.WaitForSeconds(time.Value);
            }
            return(new NullValue());
        }
Exemplo n.º 19
0
 /// <summary>
 /// 创建一条带插件执行上下文的有值消息
 /// </summary>
 /// <param name="context">插件执行上下文</param>
 /// <param name="content">消息内容</param>
 /// <param name="mask">消息掩码</param>
 /// <param name="tag">消息标记(如果有)</param>
 public static ContextMessage <T> Create(PluginExecuteContext context, T content, int mask, string tag = null)
 {
     return(new ContextMessage <T>(context, content, mask, tag));
 }
Exemplo n.º 20
0
 public override Task <SerializableValue> Execute(PluginExecuteContext context)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 21
0
        public async Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            var(mode, layer, effect, images) = AnalyseParameters(context);
            if (!images.Any())
            {
                return(new NullValue());
            }
            if (_placeholder != null)
            {
                await _placeholder;
            }
            CreatePlaceholder();
            InitializeImage(images, layer);
            if (effect == null)
            {
                await PlaceNewImages(images);

                UpdateImageList(images);
                CompletePlaceholder();
                return(new NullValue());
            }
            var names = images.Select(e => e.Name).ToArray();

            if (mode == ImageBindMode.None)
            {
                var existedImages = await UpdateImageInfo(_images.Where(e => names.Contains(e.Key)).Select(e => e.Value).ToArray());

                images = await UpdateImageInfo(images);

                await Dispatcher.WaitAll(images.Select(e => e.Content.Texture.ReadTexture()));

                var targets = existedImages.Length == 0
                    ? images.Select(e => (Previous: (ImageDisplayInformation?)null, Target: e)).ToArray()
                    : (from image in images
                       join e in existedImages.AsNullable() on image.Name equals e?.Name into tempImages
                       from r in tempImages.DefaultIfEmpty()
                       select(Previous: r, Target: image)).ToArray();
                var finalImages = new List <ImageDisplayInformation>();
                for (var i = -1; ++i < targets.Length;)
                {
                    var(previous, target) = targets[i];
                    if (previous.HasValue && previous.Value.Content.Texture.texture != null && target.Content.Texture.texture != null)
                    {
                        var texture      = previous.Value.Content.Texture.texture;
                        var previousRect = previous.Value.displayMatrix.MultiplyRect(new Rect(0, 0, texture.width, texture.height));
                        texture = target.Content.Texture.texture;
                        var targetRect = target.displayMatrix.MultiplyRect(new Rect(0, 0, texture.width, texture.height));
                        var canvasSize = previousRect.MergeWith(targetRect).MaximizeToRectInt();
                        var shader     = await GetCombinerShader();

                        var combiner      = new Texture2DCombiner(canvasSize.width, canvasSize.height, shader);
                        var drawingMatrix = previous.Value.displayMatrix;
                        drawingMatrix.SetTranslation(previousRect.position - canvasSize.position);
                        combiner.DrawTexture(previous.Value.Content.Texture.texture, drawingMatrix);
                        var canvasTransform = new TransformValue()
                                              .Set(TransformValue.PropertyName.PositionX, canvasSize.xMin)
                                              .Set(TransformValue.PropertyName.PositionY, canvasSize.yMin);
                        await PlaceOverlayCanvas(previous.Value.Name, combiner.Combine(), canvasTransform, previous.Value.layer);

                        combiner      = new Texture2DCombiner(canvasSize.width, canvasSize.height, shader);
                        drawingMatrix = target.displayMatrix;
                        drawingMatrix.SetTranslation(targetRect.position - canvasSize.position);
                        combiner.DrawTexture(target.Content.Texture.texture, drawingMatrix);
                        finalImages.Add(new ImageDisplayInformation(target.Name, new ImageValue {
                            Uv      = target.Content.Uv,
                            Color   = target.Content.Color,
                            Texture = new Texture2DValue {
                                texture = combiner.Combine()
                            }
                        }, canvasTransform)
                        {
                            layer  = target.layer,
                            status = ImageStatus.PrepareToShow
                        });
                    }
                    else
                    {
                        finalImages.Add(target);
                    }
                }
                await PlaceNewImages(finalImages.ToArray(), effect.Effect as SingleGraphicEffect);
                await PlaceNewImages(images);

                UpdateImageList(images);
                CompletePlaceholder();
                return(new NullValue());
            }
            var overlayCanvas = await BindImages(FindPreBindImages(names));

            var targetCanvas = await BindImages(images);

            RectInt displayArea;

            (overlayCanvas, targetCanvas, displayArea) = CutDisplayArea(new RectInt(0, 0, targetCanvas.width, targetCanvas.height), overlayCanvas, targetCanvas, mode);
            var overlayName      = $"OVERLAY{{{Guid.NewGuid().ToString().ToUpper()}}}";
            var overlayTransform = CreateOverlayTransform(displayArea.position);

            await PlaceOverlayCanvas(overlayName, overlayCanvas, overlayTransform, layer);
            await RemoveHiddenSeparateImages(names);
            await PlayOverlayEffect(overlayName, targetCanvas, effect.Effect as SingleGraphicEffect, overlayTransform, layer);
            await PlaceNewImages(images);
            await RemoveOverlayImage(overlayName);

            UpdateImageList(images);
            CompletePlaceholder();
            return(new NullValue());
        }
Exemplo n.º 22
0
        public Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            byte?r = null, g = null, b = null, a = null;

            foreach (var(key, value) in context.StringParameters)
            {
                var name = key.ConvertToString(context.Language);
                if (name.StartsWith("#"))
                {
                    return(Task.FromResult <SerializableValue>(ParseHex(name)));
                }
                switch (name)
                {
                case "Hex":
                    return(Task.FromResult <SerializableValue>(ParseHex(StringValue.TryParse(value))));

                case "R":
                    r = GetColorNumber(value, context.Language);
                    break;

                case "G":
                    g = GetColorNumber(value, context.Language);
                    break;

                case "B":
                    b = GetColorNumber(value, context.Language);
                    break;

                case "A":
                case "Alpha":
                    a = GetColorNumber(value, context.Language);
                    break;

                case "AliceBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(240, 248, 255, 255)));

                case "AntiqueWhite":
                    return(Task.FromResult <SerializableValue>(new ColorValue(250, 235, 215, 255)));

                case "Aqua":
                case "Cyan":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 255, 255, 255)));

                case "Aquamarine":
                    return(Task.FromResult <SerializableValue>(new ColorValue(127, 255, 212, 255)));

                case "Azure":
                    return(Task.FromResult <SerializableValue>(new ColorValue(240, 255, 255, 255)));

                case "Beige":
                    return(Task.FromResult <SerializableValue>(new ColorValue(245, 245, 220, 255)));

                case "Bisque":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 228, 196, 255)));

                case "Black":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 0, 0, 255)));

                case "BlanchedAlmond":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 235, 205, 255)));

                case "Blue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 0, 255, 255)));

                case "BlueViolet":
                    return(Task.FromResult <SerializableValue>(new ColorValue(138, 43, 226, 255)));

                case "Brown":
                    return(Task.FromResult <SerializableValue>(new ColorValue(165, 42, 42, 255)));

                case "Burlywood":
                    return(Task.FromResult <SerializableValue>(new ColorValue(222, 184, 135, 255)));

                case "CadetBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(95, 158, 160, 255)));

                case "Chartreuse":
                    return(Task.FromResult <SerializableValue>(new ColorValue(127, 255, 0, 255)));

                case "Chocolate":
                    return(Task.FromResult <SerializableValue>(new ColorValue(210, 105, 30, 255)));

                case "Coral":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 127, 80, 255)));

                case "CornflowerBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(100, 149, 237, 255)));

                case "Cornsilk":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 248, 220, 255)));

                case "Crimson":
                    return(Task.FromResult <SerializableValue>(new ColorValue(220, 20, 60, 255)));

                case "DarkBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 0, 139, 255)));

                case "DarkCyan":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 139, 139, 255)));

                case "DarkGoldenrod":
                    return(Task.FromResult <SerializableValue>(new ColorValue(184, 134, 11, 255)));

                case "DarkGray":
                case "DarkGrey":
                    return(Task.FromResult <SerializableValue>(new ColorValue(169, 169, 169, 255)));

                case "DarkGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 100, 0, 255)));

                case "DarkKhaki":
                    return(Task.FromResult <SerializableValue>(new ColorValue(189, 183, 107, 255)));

                case "DarkMagenta":
                    return(Task.FromResult <SerializableValue>(new ColorValue(139, 0, 139, 255)));

                case "DarkOliveGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(85, 107, 47, 255)));

                case "DarkOrange":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 140, 0, 255)));

                case "DarkOrchid":
                    return(Task.FromResult <SerializableValue>(new ColorValue(153, 50, 204, 255)));

                case "DarkRed":
                    return(Task.FromResult <SerializableValue>(new ColorValue(139, 0, 0, 255)));

                case "DarkSalmon":
                    return(Task.FromResult <SerializableValue>(new ColorValue(233, 150, 122, 255)));

                case "DarkSeaGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(143, 188, 143, 255)));

                case "DarkSlateBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(72, 61, 139, 255)));

                case "DarkSlateGray":
                case "DarkSlateGrey":
                    return(Task.FromResult <SerializableValue>(new ColorValue(47, 79, 79, 255)));

                case "DarkTurquoise":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 206, 209, 255)));

                case "DarkViolet":
                    return(Task.FromResult <SerializableValue>(new ColorValue(148, 0, 211, 255)));

                case "DeepPink":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 20, 147, 255)));

                case "DeepSkyBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 191, 255, 255)));

                case "DimGray":
                case "DimGrey":
                    return(Task.FromResult <SerializableValue>(new ColorValue(105, 105, 105, 255)));

                case "DodgerBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(30, 144, 255, 255)));

                case "Firebrick":
                    return(Task.FromResult <SerializableValue>(new ColorValue(178, 34, 34, 255)));

                case "FloralWhite":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 250, 240, 255)));

                case "ForestGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(34, 139, 34, 255)));

                case "Fuchsia":
                case "Magenta":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 0, 255, 255)));

                case "Gainsboro":
                    return(Task.FromResult <SerializableValue>(new ColorValue(220, 220, 220, 255)));

                case "GhostWhite":
                    return(Task.FromResult <SerializableValue>(new ColorValue(248, 248, 255, 255)));

                case "Gold":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 215, 0, 255)));

                case "Goldenrod":
                    return(Task.FromResult <SerializableValue>(new ColorValue(218, 165, 32, 255)));

                case "Gray":
                case "Grey":
                case "X11Gray":
                case "X11Grey":
                    return(Task.FromResult <SerializableValue>(new ColorValue(190, 190, 190, 255)));

                case "WebGray":
                case "WebGrey":
                    return(Task.FromResult <SerializableValue>(new ColorValue(128, 128, 128, 255)));

                case "Green":
                case "X11Green":
                case "Lime":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 255, 0, 255)));

                case "WebGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 128, 0, 255)));

                case "GreenYellow":
                    return(Task.FromResult <SerializableValue>(new ColorValue(173, 255, 47, 255)));

                case "Honeydew":
                    return(Task.FromResult <SerializableValue>(new ColorValue(240, 255, 240, 255)));

                case "HotPink":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 105, 180, 255)));

                case "IndianRed":
                    return(Task.FromResult <SerializableValue>(new ColorValue(205, 92, 92, 255)));

                case "Indigo":
                    return(Task.FromResult <SerializableValue>(new ColorValue(75, 0, 130, 255)));

                case "Ivory":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 255, 240, 255)));

                case "Khaki":
                    return(Task.FromResult <SerializableValue>(new ColorValue(240, 230, 140, 255)));

                case "Lavender":
                    return(Task.FromResult <SerializableValue>(new ColorValue(230, 230, 250, 255)));

                case "LavenderBlush":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 240, 245, 255)));

                case "LawnGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(124, 252, 0, 255)));

                case "LemonChiffon":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 250, 205, 255)));

                case "LightBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(173, 216, 230, 255)));

                case "LightCoral":
                    return(Task.FromResult <SerializableValue>(new ColorValue(240, 128, 128, 255)));

                case "LightCyan":
                    return(Task.FromResult <SerializableValue>(new ColorValue(224, 255, 255, 255)));

                case "LightGoldenrod":
                    return(Task.FromResult <SerializableValue>(new ColorValue(250, 250, 210, 255)));

                case "LightGray":
                case "LightGrey":
                    return(Task.FromResult <SerializableValue>(new ColorValue(211, 211, 211, 255)));

                case "LightGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(144, 238, 144, 255)));

                case "LightPink":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 182, 193, 255)));

                case "LightSalmon":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 160, 122, 255)));

                case "LightSeaGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(32, 178, 170, 255)));

                case "LightSkyBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(135, 206, 250, 255)));

                case "LightSlateGray":
                case "LightSlateGrey":
                    return(Task.FromResult <SerializableValue>(new ColorValue(119, 136, 153, 255)));

                case "LightSteelBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(176, 196, 222, 255)));

                case "LightYellow":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 255, 224, 255)));

                case "LimeGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(50, 205, 50, 255)));

                case "Linen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(250, 240, 230, 255)));

                case "Maroon":
                case "X11Maroon":
                    return(Task.FromResult <SerializableValue>(new ColorValue(176, 48, 96, 255)));

                case "WebMaroon":
                    return(Task.FromResult <SerializableValue>(new ColorValue(128, 0, 0, 255)));

                case "MediumAquamarine":
                    return(Task.FromResult <SerializableValue>(new ColorValue(102, 205, 170, 255)));

                case "MediumBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 0, 205, 255)));

                case "MediumOrchid":
                    return(Task.FromResult <SerializableValue>(new ColorValue(186, 85, 211, 255)));

                case "MediumPurple":
                    return(Task.FromResult <SerializableValue>(new ColorValue(147, 112, 219, 255)));

                case "MediumSeaGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(60, 179, 113, 255)));

                case "MediumSlateBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(123, 104, 238, 255)));

                case "MediumSpringGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 250, 154, 255)));

                case "MediumTurquoise":
                    return(Task.FromResult <SerializableValue>(new ColorValue(72, 209, 204, 255)));

                case "MediumVioletRed":
                    return(Task.FromResult <SerializableValue>(new ColorValue(199, 21, 133, 255)));

                case "MidnightBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(25, 25, 112, 255)));

                case "MintCream":
                    return(Task.FromResult <SerializableValue>(new ColorValue(245, 255, 250, 255)));

                case "MistyRose":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 228, 225, 255)));

                case "Moccasin":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 228, 181, 255)));

                case "NavajoWhite":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 222, 173, 255)));

                case "NavyBlue":
                case "Navy":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 0, 128, 255)));

                case "OldLace":
                    return(Task.FromResult <SerializableValue>(new ColorValue(253, 245, 230, 255)));

                case "Olive":
                    return(Task.FromResult <SerializableValue>(new ColorValue(128, 128, 0, 255)));

                case "OliveDrab":
                    return(Task.FromResult <SerializableValue>(new ColorValue(107, 142, 35, 255)));

                case "Orange":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 165, 0, 255)));

                case "OrangeRed":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 69, 0, 255)));

                case "Orchid":
                    return(Task.FromResult <SerializableValue>(new ColorValue(218, 112, 214, 255)));

                case "PaleGoldenrod":
                    return(Task.FromResult <SerializableValue>(new ColorValue(238, 232, 170, 255)));

                case "PaleGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(152, 251, 152, 255)));

                case "PaleTurquoise":
                    return(Task.FromResult <SerializableValue>(new ColorValue(175, 238, 238, 255)));

                case "PaleVioletRed":
                    return(Task.FromResult <SerializableValue>(new ColorValue(219, 112, 147, 255)));

                case "PapayaWhip":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 239, 213, 255)));

                case "PeachPuff":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 218, 185, 255)));

                case "Peru":
                    return(Task.FromResult <SerializableValue>(new ColorValue(205, 133, 63, 255)));

                case "Pink":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 192, 203, 255)));

                case "Plum":
                    return(Task.FromResult <SerializableValue>(new ColorValue(221, 160, 221, 255)));

                case "PowderBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(176, 224, 230, 255)));

                case "X11Purple":
                    return(Task.FromResult <SerializableValue>(new ColorValue(160, 32, 240, 255)));

                case "WebPurple":
                    return(Task.FromResult <SerializableValue>(new ColorValue(128, 0, 128, 255)));

                case "RebeccaPurple":
                    return(Task.FromResult <SerializableValue>(new ColorValue(102, 51, 153, 255)));

                case "Red":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 0, 0, 255)));

                case "RosyBrown":
                    return(Task.FromResult <SerializableValue>(new ColorValue(188, 143, 143, 255)));

                case "RoyalBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(65, 105, 225, 255)));

                case "SaddleBrown":
                    return(Task.FromResult <SerializableValue>(new ColorValue(139, 69, 19, 255)));

                case "Salmon":
                    return(Task.FromResult <SerializableValue>(new ColorValue(250, 128, 114, 255)));

                case "SandyBrown":
                    return(Task.FromResult <SerializableValue>(new ColorValue(244, 164, 96, 255)));

                case "SeaGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(46, 139, 87, 255)));

                case "Seashell":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 245, 238, 255)));

                case "Sienna":
                    return(Task.FromResult <SerializableValue>(new ColorValue(160, 82, 45, 255)));

                case "Silver":
                    return(Task.FromResult <SerializableValue>(new ColorValue(192, 192, 192, 255)));

                case "SkyBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(135, 206, 235, 255)));

                case "SlateBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(106, 90, 205, 255)));

                case "SlateGray":
                case "SlateGrey":
                    return(Task.FromResult <SerializableValue>(new ColorValue(112, 128, 144, 255)));

                case "Snow":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 250, 250, 255)));

                case "SpringGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 255, 127, 255)));

                case "SteelBlue":
                    return(Task.FromResult <SerializableValue>(new ColorValue(70, 130, 180, 255)));

                case "Tan":
                    return(Task.FromResult <SerializableValue>(new ColorValue(210, 180, 140, 255)));

                case "Teal":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 128, 128, 255)));

                case "Thistle":
                    return(Task.FromResult <SerializableValue>(new ColorValue(216, 191, 216, 255)));

                case "Tomato":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 99, 71, 255)));

                case "Transparent":
                    return(Task.FromResult <SerializableValue>(new ColorValue(0, 0, 0, 0)));

                case "Turquoise":
                    return(Task.FromResult <SerializableValue>(new ColorValue(64, 224, 208, 255)));

                case "Violet":
                    return(Task.FromResult <SerializableValue>(new ColorValue(238, 130, 238, 255)));

                case "Wheat":
                    return(Task.FromResult <SerializableValue>(new ColorValue(245, 222, 179, 255)));

                case "White":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 255, 255, 255)));

                case "WhiteSmoke":
                    return(Task.FromResult <SerializableValue>(new ColorValue(245, 245, 245, 255)));

                case "Yellow":
                    return(Task.FromResult <SerializableValue>(new ColorValue(255, 255, 0, 255)));

                case "YellowGreen":
                    return(Task.FromResult <SerializableValue>(new ColorValue(154, 205, 50, 255)));
                }
            }
            r = r ?? 0;
            g = g ?? 0;
            b = b ?? 0;
            a = a ?? 255;
            return(Task.FromResult <SerializableValue>(new ColorValue(r.Value, g.Value, b.Value, a.Value)));
        }
 /// <summary>
 /// 创建一个插件消息模板
 /// </summary>
 /// <param name="context">执行上下文</param>
 public ContextMessageTemplate(PluginExecuteContext context)
 {
     Context = context;
 }
Exemplo n.º 24
0
        private int _runningCount; // 正在运行的操作数 解决多线程问题

        /// <summary>
        ///     插件调度服务
        /// </summary>
        /// <param name="pluginExecuteContext">插件执行的上下文参数</param>
        public TaskDispatcherService(PluginExecuteContext pluginExecuteContext)
        {
            _pluginExecuteContext = pluginExecuteContext;
            _pluginConfig         = pluginExecuteContext.PluginConfig;
        }
Exemplo n.º 25
0
 public abstract void SetText(PluginExecuteContext context, InputPlugin.MessageIntegration.Content content);
Exemplo n.º 26
0
 private ContextMessage(PluginExecuteContext context)
 {
     Context = context;
 }
Exemplo n.º 27
0
 /// <inheritdoc />
 /// <summary>
 /// 创建一条带插件执行上下文的有值消息
 /// </summary>
 /// <param name="context">插件执行上下文</param>
 /// <param name="content">消息内容</param>
 public ContextMessage(PluginExecuteContext context, T content) : base(content)
 {
     Context = context;
 }
Exemplo n.º 28
0
 /// <inheritdoc />
 /// <summary>
 /// 创建一条带插件执行上下文的有值消息
 /// </summary>
 /// <param name="context">插件执行上下文</param>
 /// <param name="content">消息内容</param>
 /// <param name="mask">消息掩码</param>
 /// <param name="tag">消息标记(如果有)</param>
 public ContextMessage(PluginExecuteContext context, T content, int mask, string tag = null) : base(content, mask, tag)
 {
     Context = context;
 }
Exemplo n.º 29
0
        private (ImageBindMode Mode, int Layer, EffectValue Effect, ImageDisplayInformation[] Images) AnalyseParameters(PluginExecuteContext context)
        {
            EffectValue    effect           = null;
            var            bind             = ImageBindMode.None;
            int?           layer            = null;
            var            images           = new List <ImageDisplayInformation>();
            ImageValue     currentImage     = null;
            string         currentName      = null;
            TransformValue currentTransform = null;

            foreach (var(key, value) in context.Parameters)
            {
                switch (key)
                {
                case EffectValue effectValue:
                    effect = effectValue;
                    break;

                case ImageValue imageValue:
                    if (currentImage != null)
                    {
                        AddImage(ref currentImage, ref currentName, ref currentTransform, images, context);
                    }
                    currentImage     = imageValue;
                    currentTransform = new TransformValue();
                    break;

                case IStringConverter stringConverter:
                    var name = stringConverter.ConvertToString(context.Language);
                    switch (name)
                    {
                    case "Layer":
                        layer = IntegerValue.TryParse(value);
                        break;

                    case "Name":
                        currentName = StringValue.TryParse(value);
                        break;

                    case "Effect":
                        effect = value is EffectValue effectValue ? effectValue : throw new ArgumentException($"Unable to create show command: effect {value} is not EffectValue");
                        break;

                    case "Transform":
                        currentTransform = (TransformValue)currentTransform.AddWith(value);
                        break;

                    case "Bind":
                        if (value is NullValue)
                        {
                            bind = ImageBindMode.Canvas;
                        }
                        else
                        {
                            switch (StringValue.TryParse(value))
                            {
                            case "Canvas":
                            case "Maximal":
                            case "Max":
                                bind = ImageBindMode.Canvas;
                                break;

                            case "Minimal":
                            case "Min":
                                bind = ImageBindMode.Minimal;
                                break;
                            }
                        }
                        break;

                    case "DefaultTransform":
                        _defaultTransform = value is TransformValue transformValue ? transformValue : throw new ArgumentException($"Unable to set show command default transform: target {value} is not TransformValue");
                        break;

                    case "DefaultLayer":
                        _defaultLayer = IntegerValue.TryParse(value);
                        break;

                    default:
                        TransformPlugin.AnalyzePropertyTo(name, value, currentTransform, context.Language);
                        break;
                    }
                    break;
                }
            }
            if (currentImage != null)
            {
                AddImage(ref currentImage, ref currentName, ref currentTransform, images, context);
            }
            layer = layer ?? _defaultLayer;
            var list = images.ToArray();

            for (var i = -1; ++i < list.Length;)
            {
                list[i].layer  = layer.Value;
                list[i].status = ImageStatus.PrepareToShow;
            }
            return(bind, layer.Value, effect, list);
        }
Exemplo n.º 30
0
        public Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            var  result = new ImageValue();
            bool flipX = false, flipY = false;

            foreach (var(key, value) in context.StringParameters)
            {
                var name = key.ConvertToString(context.Language);
                switch (name)
                {
                case "Texture":
                    result.Texture = value is Texture2DValue texture2DValue ? texture2DValue : throw new ArgumentException($"Unable to create image: texture {value} is not Texture2DValue");
                    break;

                case "Color":
                    result.Color = value is ColorValue colorValue ? colorValue : throw new ArgumentException($"Unable to create image: color {value} is not ColorValue");
                    break;

                case "Source":
                    result.Texture.source  = StringValue.TryParse(value, context.Language);
                    result.Texture.texture = null;
                    break;

                case "FlipX":
                    if (value == null || value is NullValue || BooleanValue.TryParse(value, context.Language))
                    {
                        flipX = true;
                    }
                    break;

                case "FlipY":
                    if (value == null || value is NullValue || BooleanValue.TryParse(value, context.Language))
                    {
                        flipY = true;
                    }
                    break;

                case "FlipXy":
                case "FlipXY":
                case "FlipYx":
                case "FlipYX":
                    if (value == null || value is NullValue || BooleanValue.TryParse(value, context.Language))
                    {
                        flipX = flipY = true;
                    }
                    break;

                case "Uv":
                case "UV":
                    if (!(value is RectValue rectValue))
                    {
                        throw new NotSupportedException($"Unable to create image: uv {value} is not RectValue");
                    }
                    result.Uv = rectValue;
                    break;
                }
            }
            if (flipX || flipY)
            {
                result.Uv = new RectValue(result.Uv.value.x + (flipX ? 1 : 0),
                                          result.Uv.value.y + (flipY ? 1 : 0),
                                          result.Uv.value.width * (flipX ? -1 : 1),
                                          result.Uv.value.height * (flipY ? -1 : 1));
            }
            return(Task.FromResult <SerializableValue>(result));
        }