Beispiel #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);
        }
Beispiel #2
0
		public override void initialize( Table table, Skin skin )
		{
			var label = createNameLabel( table, skin );

			// gotta get ugly here
			_selectBox = new SelectBox<string>( skin );

			var enumValues = Enum.GetValues( _valueType );
			var enumStringValues = new List<string>();
			foreach( var e in enumValues )
				enumStringValues.Add( e.ToString() );
			_selectBox.setItems( enumStringValues );

			_selectBox.onChanged += selectedItem =>
			{
				setValue( Enum.Parse( _valueType, selectedItem ) );
			};

			table.add( label );
			table.add( _selectBox ).setFillX();
		}
Beispiel #3
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);
        }
        public override void initialize(Table table, Skin skin, float leftCellWidth)
        {
            var label = createNameLabel(table, skin, leftCellWidth);

            // gotta get ugly here
            _selectBox = new SelectBox <string>(skin);

            var enumValues       = Enum.GetValues(_valueType);
            var enumStringValues = new List <string>();

            foreach (var e in enumValues)
            {
                enumStringValues.Add(e.ToString());
            }
            _selectBox.setItems(enumStringValues);

            _selectBox.onChanged += selectedItem =>
            {
                setValue(Enum.Parse(_valueType, selectedItem));
            };

            table.add(label);
            table.add(_selectBox).setFillX();
        }