예제 #1
0
 public void refreshScripts()
 {
     ScriptProperties.ForEach((s) => { WhiskeyPropertyListGrid.removeOtherProperty(s); });
     ScriptProperties.Clear();
     Descriptor.getScriptNames().ForEach((s) =>
     {
         GeneralPropertyDescriptor gpd = WhiskeyPropertyListGrid.addOtherProperty(s, "Scripts", 1);
         gpd.PropIsReadOnly            = true;
         ScriptProperties.Add(gpd);
     });
 }
        public void refreshScripts()
        {
            ScriptProperties.ForEach((s) => { PropertyGrid.removeOtherProperty(s); });
            ScriptProperties.Clear();
            Descriptor.getScriptNames().ForEach((s) =>
            {
                InstanceScriptRhapper dumb    = new InstanceScriptRhapper();
                dumb.Descriptor               = Descriptor;
                dumb.ScriptName               = s;
                GeneralPropertyDescriptor gpd = PropertyGrid.addOtherProperty(s, "Scripts", dumb);
                gpd.CustomTypeEditor          = WhiskeyTypeEditors.lookUp("InstanceScriptRhapper");

                //gpd.PropIsReadOnly = true;
                ScriptProperties.Add(gpd);
            });
        }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value.GetType() == typeof(string))
            {
                PropertyAdapter           adapter     = (PropertyAdapter)context.Instance;
                string                    name        = context.PropertyDescriptor.Name;
                GeneralPropertyDescriptor gpd         = (GeneralPropertyDescriptor)context.PropertyDescriptor;
                WhiskeyProperty           whiskeyProp = adapter.WhiskeyPropertys.Where((w) => { return(w.Name.Equals(name)); }).ToList()[0];

                Type toType = whiskeyProp.TypeVal.Value.GetType();

                TypeConverter converter = WhiskeyTypeConverters.lookUp(toType.Name);
                if (converter != null && value != null && converter.CanConvertFrom(value.GetType()))
                {
                    object converted = converter.ConvertFrom(context, culture, value);
                    whiskeyProp.TypeVal.Value = converted;
                }


                if (ConverterManager.Instance.hasConverter(toType))
                {
                    whiskeyProp.TypeVal.Value = ConverterManager.Instance.convertFromString(toType, (string)value);
                }
                else
                {
                    try
                    {
                        whiskeyProp.TypeVal.Value = Convert.ChangeType(value, toType);
                    }
                    catch (Exception e)
                    {
                        //???
                    }
                }
                return(gpd.PropValue);
            }


            return(base.ConvertFrom(context, culture, value));
        }
예제 #4
0
        private void initControls()
        {
            Stopwatch timer             = Stopwatch.StartNew();
            TimeSpan  TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 16);



            //PropertyGrid.PropertyList = Descriptor.getPropertySet();
            Application.Idle += (s, a) =>
            {
                if (timer.ElapsedMilliseconds >= TargetElapsedTime.Milliseconds)
                {
                    refreshPropertyContent();

                    timer.Restart();
                }
            };

            ColorDesc   = WhiskeyPropertyListGrid.addOtherProperty("Color", "Details", Descriptor.Color);
            AmbientDesc = WhiskeyPropertyListGrid.addOtherProperty("Ambient Light", "Details", Descriptor.Level.AmbientLight);

            CameraZoomDesc    = WhiskeyPropertyListGrid.addOtherProperty("Zoom", "Camera", Descriptor.Level.Camera.Zoom);
            CameraTruePosDesc = WhiskeyPropertyListGrid.addOtherProperty("Position", "Camera", Descriptor.Level.Camera.TruePosition);

            ShaderBloomThresholdDesc = WhiskeyPropertyListGrid.addOtherProperty("Bloom Threshold", "Effects", Descriptor.Level.BloomSettings.BloomThreshold);
            ShaderBlurdDesc          = WhiskeyPropertyListGrid.addOtherProperty("Blur Amount", "Effects", Descriptor.Level.BloomSettings.BlurAmount);
            ShaderBloomDesc          = WhiskeyPropertyListGrid.addOtherProperty("Bloom Intensity", "Effects", Descriptor.Level.BloomSettings.BloomIntensity);
            ShaderBaseDesc           = WhiskeyPropertyListGrid.addOtherProperty("Base Intensity", "Effects", Descriptor.Level.BloomSettings.BaseIntensity);
            ShaderBloomSatDesc       = WhiskeyPropertyListGrid.addOtherProperty("Bloom Saturation", "Effects", Descriptor.Level.BloomSettings.BloomSaturation);
            ShaderBaseSatDesc        = WhiskeyPropertyListGrid.addOtherProperty("Base Saturation", "Effects", Descriptor.Level.BloomSettings.BaseSaturation);

            ShaderBloomThresholdDesc.CustomTypeEditor = new UI.Properties.RestrictedFloatPicker(ShaderBloomThresholdDesc, 0, 1, .05f);
            ShaderBlurdDesc.CustomTypeEditor          = new UI.Properties.RestrictedFloatPicker(ShaderBlurdDesc, 0, 4, .1f);
            ShaderBloomDesc.CustomTypeEditor          = new UI.Properties.RestrictedFloatPicker(ShaderBloomDesc, 0, 2, .1f);
            ShaderBaseDesc.CustomTypeEditor           = new UI.Properties.RestrictedFloatPicker(ShaderBaseDesc, 0, 2, .1f);
            ShaderBloomSatDesc.CustomTypeEditor       = new UI.Properties.RestrictedFloatPicker(ShaderBloomSatDesc, 0, 1, .05f);
            ShaderBaseSatDesc.CustomTypeEditor        = new UI.Properties.RestrictedFloatPicker(ShaderBaseSatDesc, 0, 1, .05f);


            ShaderLightBloomThresholdDesc = WhiskeyPropertyListGrid.addOtherProperty("lBloom Threshold", "Light Effects", Descriptor.Level.LightBloomSettings.BloomThreshold);
            ShaderLightBlurdDesc          = WhiskeyPropertyListGrid.addOtherProperty("lBlur Amount", "Light Effects", Descriptor.Level.LightBloomSettings.BlurAmount);
            ShaderLightBloomDesc          = WhiskeyPropertyListGrid.addOtherProperty("lBloom Intensity", "Light Effects", Descriptor.Level.LightBloomSettings.BloomIntensity);
            ShaderLightBaseDesc           = WhiskeyPropertyListGrid.addOtherProperty("lBase Intensity", "Light Effects", Descriptor.Level.LightBloomSettings.BaseIntensity);
            ShaderLightBloomSatDesc       = WhiskeyPropertyListGrid.addOtherProperty("lBloom Saturation", "Light Effects", Descriptor.Level.LightBloomSettings.BloomSaturation);
            ShaderLightBaseSatDesc        = WhiskeyPropertyListGrid.addOtherProperty("lBase Saturation", "Light Effects", Descriptor.Level.LightBloomSettings.BaseSaturation);

            ShaderLightBloomThresholdDesc.CustomTypeEditor = new UI.Properties.RestrictedFloatPicker(ShaderLightBloomThresholdDesc, 0, 1, .05f);
            ShaderLightBlurdDesc.CustomTypeEditor          = new UI.Properties.RestrictedFloatPicker(ShaderLightBlurdDesc, 0, 12, .1f);
            ShaderLightBloomDesc.CustomTypeEditor          = new UI.Properties.RestrictedFloatPicker(ShaderLightBloomDesc, 0, 2, .1f);
            ShaderLightBaseDesc.CustomTypeEditor           = new UI.Properties.RestrictedFloatPicker(ShaderLightBaseDesc, 0, 2, .1f);
            ShaderLightBloomSatDesc.CustomTypeEditor       = new UI.Properties.RestrictedFloatPicker(ShaderLightBloomSatDesc, 0, 1, .05f);
            ShaderLightBaseSatDesc.CustomTypeEditor        = new UI.Properties.RestrictedFloatPicker(ShaderLightBaseSatDesc, 0, 1, .05f);


            ColorDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Color = (Whiskey2D.Core.Color)ColorDesc.PropValue;
            };
            AmbientDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.AmbientLight = (Whiskey2D.Core.Color)AmbientDesc.PropValue;
            };

            CameraTruePosDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.Camera.TruePosition = (Whiskey2D.Core.Vector)CameraTruePosDesc.PropValue;
            };
            CameraZoomDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.Camera.Zoom = (float)CameraZoomDesc.PropValue;
            };

            ShaderBloomThresholdDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.BloomSettings.BloomThreshold = (float)ShaderBloomThresholdDesc.PropValue;
                WhiskeyEditor.MonoHelp.WhiskeyControl.forceRedraw();
            };
            ShaderBlurdDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.BloomSettings.BlurAmount = (float)ShaderBlurdDesc.PropValue;
                WhiskeyEditor.MonoHelp.WhiskeyControl.forceRedraw();
            };
            ShaderBloomDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.BloomSettings.BloomIntensity = (float)ShaderBloomDesc.PropValue;
                WhiskeyEditor.MonoHelp.WhiskeyControl.forceRedraw();
            };
            ShaderBaseDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.BloomSettings.BaseIntensity = (float)ShaderBaseDesc.PropValue;
                WhiskeyEditor.MonoHelp.WhiskeyControl.forceRedraw();
            };
            ShaderBloomSatDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.BloomSettings.BloomSaturation = (float)ShaderBloomSatDesc.PropValue;
                WhiskeyEditor.MonoHelp.WhiskeyControl.forceRedraw();
            };
            ShaderBaseSatDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.BloomSettings.BaseSaturation = (float)ShaderBaseSatDesc.PropValue;
                WhiskeyEditor.MonoHelp.WhiskeyControl.forceRedraw();
            };


            ShaderLightBloomThresholdDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.LightBloomSettings.BloomThreshold = (float)ShaderLightBloomThresholdDesc.PropValue;
                WhiskeyEditor.MonoHelp.WhiskeyControl.forceRedraw();
            };
            ShaderLightBlurdDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.LightBloomSettings.BlurAmount = (float)ShaderLightBlurdDesc.PropValue;
                WhiskeyEditor.MonoHelp.WhiskeyControl.forceRedraw();
            };
            ShaderLightBloomDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.LightBloomSettings.BloomIntensity = (float)ShaderLightBloomDesc.PropValue;
                WhiskeyEditor.MonoHelp.WhiskeyControl.forceRedraw();
            };
            ShaderLightBaseDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.LightBloomSettings.BaseIntensity = (float)ShaderLightBaseDesc.PropValue;
                WhiskeyEditor.MonoHelp.WhiskeyControl.forceRedraw();
            };
            ShaderLightBloomSatDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.LightBloomSettings.BloomSaturation = (float)ShaderLightBloomSatDesc.PropValue;
                WhiskeyEditor.MonoHelp.WhiskeyControl.forceRedraw();
            };
            ShaderLightBaseSatDesc.ValueChanged += (s, a) =>
            {
                Descriptor.Level.LightBloomSettings.BaseSaturation = (float)ShaderLightBaseSatDesc.PropValue;
                WhiskeyEditor.MonoHelp.WhiskeyControl.forceRedraw();
            };



            WhiskeyPropertyListGrid.PropertyGrid.PropertyValueChanged += (s, a) =>
            {
                // Descriptor.ensureFileExists();
            };
        }