Ejemplo n.º 1
0
        void MakeBlendDropdown(Table table, Skin skin, string label, string propertyName)
        {
            FieldInfo fieldInfo = typeof(ParticleEmitterConfig).GetField(propertyName);
            Blend     value     = (Blend)fieldInfo.GetValue(_particleEmitterConfig);

            var dropdown     = new SelectBox <string>(skin);
            var dropdownList = new List <string>()
            {
                "Zero",
                "One",
                "SourceColor",
                "InverseSourceColor",
                "SourceAlpha",
                "InverseSourceAlpha",
                "DestinationAlpha",
                "InverseDestinationAlpha",
                "DestinationColor",
                "InverseDestinationColor",
                "SourceAlphaSaturation"
            };

            dropdown.SetItems(dropdownList);

            // Make a lookup table from string to blend function
            var nameLookup = new Dictionary <string, Blend>()
            {
                { "Zero", Blend.Zero },
                { "One", Blend.One },
                { "SourceColor", Blend.SourceColor },
                { "InverseSourceColor", Blend.InverseSourceColor },
                { "SourceAlpha", Blend.SourceAlpha },
                { "InverseSourceAlpha", Blend.InverseSourceAlpha },
                { "DestinationAlpha", Blend.DestinationAlpha },
                { "InverseDestinationAlpha", Blend.InverseDestinationAlpha },
                { "DestinationColor", Blend.DestinationColor },
                { "InverseDestinationColor", Blend.InverseDestinationColor },
                { "SourceAlphaSaturation", Blend.SourceAlphaSaturation }
            };

            // Make a lookup table from blend function to string
            var functionLookup = new Dictionary <Blend, string>();

            foreach (var str in nameLookup.Keys)
            {
                functionLookup.Add(nameLookup[str], str);
            }

            ;

            dropdown.SetSelectedIndex(dropdownList.IndexOf(functionLookup[value]));
            dropdown.OnChanged += (str) =>
            {
                Blend newValue = nameLookup[str];
                fieldInfo.SetValue(_particleEmitterConfig, newValue);
                ResetEmitter();
            };

            table.Add(dropdown);
        }
Ejemplo n.º 2
0
        void MakeEmitterDropdown(Table table, Skin skin, string label)
        {
            ParticleEmitterType value = _particleEmitterConfig.EmitterType;

            var dropdown     = new SelectBox <string>(skin);
            var dropdownList = new List <string>()
            {
                "Gravity",
                "Radial"
            };

            dropdown.SetItems(dropdownList);

            if (_particleEmitterConfig.EmitterType == ParticleEmitterType.Gravity)
            {
                dropdown.SetSelectedIndex(0);
            }
            else
            {
                dropdown.SetSelectedIndex(1);
            }

            dropdown.OnChanged += (str) =>
            {
                if (str == "Gravity")
                {
                    _particleEmitterConfig.EmitterType = ParticleEmitterType.Gravity;
                }
                else
                {
                    _particleEmitterConfig.EmitterType = ParticleEmitterType.Radial;
                }
                ResetEmitter();
                ResetUi();
            };

            table.Add(label).Left().Width(140);
            table.Add("").Width(1);             // This is a 3 column table
            table.Add(dropdown);
        }