// protected override void OnAttach() { base.OnAttach(); instance = this; viewport = RendererWorld.Instance.DefaultViewport; window = ControlDeclarationManager.Instance.CreateControl( "Gui\\PostEffectsWindow.gui" ); Controls.Add( window ); for( int n = 0; n < scrollBarFloatParameters.Length; n++ ) { scrollBarFloatParameters[ n ] = (EScrollBar)window.Controls[ "FloatParameter" + n.ToString() ]; scrollBarFloatParameters[ n ].ValueChange += floatParameter_ValueChange; } for( int n = 0; n < checkBoxBoolParameters.Length; n++ ) { checkBoxBoolParameters[ n ] = (ECheckBox)window.Controls[ "BoolParameter" + n.ToString() ]; checkBoxBoolParameters[ n ].CheckedChange += boolParameter_CheckedChange; } listBox = (EListBox)window.Controls[ "List" ]; listBox.Items.Add( "HDR" ); listBox.Items.Add( "LDRBloom" ); listBox.Items.Add( "Glass" ); listBox.Items.Add( "OldTV" ); listBox.Items.Add( "HeatVision" ); listBox.Items.Add( "MotionBlur" ); listBox.Items.Add( "RadialBlur" ); listBox.Items.Add( "Blur" ); listBox.Items.Add( "Grayscale" ); listBox.Items.Add( "Invert" ); listBox.Items.Add( "Tiling" ); listBox.SelectedIndexChange += listBox_SelectedIndexChange; checkBoxEnabled = (ECheckBox)window.Controls[ "Enabled" ]; checkBoxEnabled.Click += checkBoxEnabled_Click; for( int n = 0; n < listBox.Items.Count; n++ ) { EButton itemButton = listBox.ItemButtons[ n ]; ECheckBox checkBox = (ECheckBox)itemButton.Controls[ "CheckBox" ]; string name = GetListCompositorItemName( (string)listBox.Items[ n ] ); CompositorInstance compositorInstance = viewport.GetCompositorInstance( name ); if( compositorInstance != null && compositorInstance.Enabled ) checkBox.Checked = true; if( itemButton.Text == "HDR" ) checkBox.Enable = false; checkBox.Click += listBoxCheckBox_Click; } listBox.SelectedIndex = 0; ( (EButton)window.Controls[ "Close" ] ).Click += delegate( EButton sender ) { SetShouldDetach(); }; //ApplyToTheScreenGUI { ECheckBox checkBox = (ECheckBox)window.Controls[ "ApplyToTheScreenGUI" ]; checkBox.Checked = EngineApp.Instance.ScreenGuiRenderer.ApplyPostEffectsToScreenRenderer; checkBox.Click += delegate( ECheckBox sender ) { EngineApp.Instance.ScreenGuiRenderer.ApplyPostEffectsToScreenRenderer = sender.Checked; }; } }
void UpdateCurrentPostEffect() { string name = GetListCompositorItemName( listBox.SelectedItem.ToString() ); bool enabled = checkBoxEnabled.Checked; CompositorInstance instance = viewport.GetCompositorInstance( name ); if( enabled ) { //Enable instance = viewport.AddCompositor( name ); if( instance != null ) instance.Enabled = true; } else { //Disable if( name == "MotionBlur" ) { //MotionBlur game specific. No remove compositor. only disable. if( instance != null ) instance.Enabled = false; } else viewport.RemoveCompositor( name ); } if( enabled ) { //MotionBlur specific if( name == "MotionBlur" ) { //Update post effect parameters MotionBlurCompositorInstance.Blur = scrollBarFloatParameters[ 0 ].Value; } //Blur specific if( name == "Blur" ) { //Update post effect parameters BlurCompositorInstance.Fuzziness = scrollBarFloatParameters[ 0 ].Value; } //HDR specific if( name == "HDR" ) { //Update post effect parameters HDRCompositorInstance.Adaptation = checkBoxBoolParameters[ 0 ].Checked; HDRCompositorInstance.AdaptationVelocity = scrollBarFloatParameters[ 1 ].Value; HDRCompositorInstance.AdaptationMiddleBrightness = scrollBarFloatParameters[ 2 ].Value; HDRCompositorInstance.AdaptationMinimum = scrollBarFloatParameters[ 3 ].Value; HDRCompositorInstance.AdaptationMaximum = scrollBarFloatParameters[ 4 ].Value; HDRCompositorInstance.BloomBrightThreshold = scrollBarFloatParameters[ 5 ].Value; HDRCompositorInstance.BloomScale = scrollBarFloatParameters[ 6 ].Value; //Update controls for( int n = 1; n <= 4; n++ ) scrollBarFloatParameters[ n ].Enable = HDRCompositorInstance.Adaptation; } //LDRBloom specific if( name == "LDRBloom" ) { //Update post effect parameters LDRBloomCompositorInstance.BloomBrightThreshold = scrollBarFloatParameters[ 0 ].Value; LDRBloomCompositorInstance.BloomScale = scrollBarFloatParameters[ 1 ].Value; } } }
protected override void OnDetach() { base.OnDetach(); instance = null; }
void UpdateCurrentPostEffect() { string name = GetListCompositorItemName(listBox.SelectedItem.ToString()); bool enabled = checkBoxEnabled.Checked; CompositorInstance instance = viewport.GetCompositorInstance(name); if (enabled) { //Enable instance = viewport.AddCompositor(name); if (instance != null) { instance.Enabled = true; } } else { //Disable if (name == "MotionBlur") { //MotionBlur game specific. No remove compositor. only disable. if (instance != null) { instance.Enabled = false; } } else { viewport.RemoveCompositor(name); } } if (enabled) { //MotionBlur specific if (name == "MotionBlur") { //Update post effect parameters MotionBlurCompositorInstance.Blur = scrollBarFloatParameters[0].Value; } //Blur specific if (name == "Blur") { //Update post effect parameters BlurCompositorInstance.Fuzziness = scrollBarFloatParameters[0].Value; } //RadialBlur specific if (name == "RadialBlur") { //Update post effect parameters RadialBlurCompositorInstance.BlurFactor = scrollBarFloatParameters[0].Value; } //HDR specific if (name == "HDR") { //Update post effect parameters HDRCompositorInstance.Adaptation = checkBoxBoolParameters[0].Checked; HDRCompositorInstance.AdaptationVelocity = scrollBarFloatParameters[1].Value; HDRCompositorInstance.AdaptationMiddleBrightness = scrollBarFloatParameters[2].Value; HDRCompositorInstance.AdaptationMinimum = scrollBarFloatParameters[3].Value; HDRCompositorInstance.AdaptationMaximum = scrollBarFloatParameters[4].Value; HDRCompositorInstance.BloomBrightThreshold = scrollBarFloatParameters[5].Value; HDRCompositorInstance.BloomScale = scrollBarFloatParameters[6].Value; //Update controls for (int n = 1; n <= 4; n++) { scrollBarFloatParameters[n].Enable = HDRCompositorInstance.Adaptation; } } //LDRBloom specific if (name == "LDRBloom") { //Update post effect parameters LDRBloomCompositorInstance.BloomBrightThreshold = scrollBarFloatParameters[0].Value; LDRBloomCompositorInstance.BloomScale = scrollBarFloatParameters[1].Value; } } }
// protected override void OnAttach() { base.OnAttach(); instance = this; viewport = RendererWorld.Instance.DefaultViewport; window = ControlDeclarationManager.Instance.CreateControl( "Gui\\PostEffectsWindow.gui"); Controls.Add(window); for (int n = 0; n < scrollBarFloatParameters.Length; n++) { scrollBarFloatParameters[n] = (EScrollBar)window.Controls[ "FloatParameter" + n.ToString()]; scrollBarFloatParameters[n].ValueChange += floatParameter_ValueChange; } for (int n = 0; n < checkBoxBoolParameters.Length; n++) { checkBoxBoolParameters[n] = (ECheckBox)window.Controls["BoolParameter" + n.ToString()]; checkBoxBoolParameters[n].CheckedChange += boolParameter_CheckedChange; } listBox = (EListBox)window.Controls["List"]; listBox.Items.Add("HDR"); listBox.Items.Add("LDRBloom"); listBox.Items.Add("Glass"); listBox.Items.Add("OldTV"); listBox.Items.Add("HeatVision"); listBox.Items.Add("MotionBlur"); listBox.Items.Add("RadialBlur"); listBox.Items.Add("Blur"); listBox.Items.Add("Grayscale"); listBox.Items.Add("Invert"); listBox.Items.Add("Tiling"); listBox.SelectedIndexChange += listBox_SelectedIndexChange; checkBoxEnabled = (ECheckBox)window.Controls["Enabled"]; checkBoxEnabled.Click += checkBoxEnabled_Click; for (int n = 0; n < listBox.Items.Count; n++) { EButton itemButton = listBox.ItemButtons[n]; ECheckBox checkBox = (ECheckBox)itemButton.Controls["CheckBox"]; string name = GetListCompositorItemName((string)listBox.Items[n]); CompositorInstance compositorInstance = viewport.GetCompositorInstance(name); if (compositorInstance != null && compositorInstance.Enabled) { checkBox.Checked = true; } if (itemButton.Text == "HDR") { checkBox.Enable = false; } checkBox.Click += listBoxCheckBox_Click; } listBox.SelectedIndex = 0; ((EButton)window.Controls["Close"]).Click += delegate(EButton sender) { SetShouldDetach(); }; //ApplyToTheScreenGUI { ECheckBox checkBox = (ECheckBox)window.Controls["ApplyToTheScreenGUI"]; checkBox.Checked = EngineApp.Instance.ScreenGuiRenderer.ApplyPostEffectsToScreenRenderer; checkBox.Click += delegate(ECheckBox sender) { EngineApp.Instance.ScreenGuiRenderer.ApplyPostEffectsToScreenRenderer = sender.Checked; }; } }