Esempio 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(label).left().width(140);
            table.add("").width(1);                 // This table has 3 columns
            table.add(dropdown);
        }
Esempio 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);
        }