using Editor; using Sandbox; using System.Linq; namespace SFXR.Editor; [CustomEditor( typeof( SFXRControls ) )] public class SFXRSoundControlWidget : ControlWidget { SerializedObject Target; public SFXRSoundControlWidget( SerializedProperty property ) : base( property ) { if ( !property.TryGetAsObject( out Target ) ) return; var component = property.Parent.Targets.First() as SFXRComponent; // Randomize Button var btnRandomize = new Button( "Randomize All", "casino" ); btnRandomize.Clicked = () => { component.Randomize(); component.PlaySound(); }; btnRandomize.ToolTip = "Randomize all sound properties"; // Play Sound Button var btnPlaySound = new Button( "Play Sound", "play_arrow" ); btnPlaySound.Clicked = () => { component.PlaySound(); }; btnPlaySound.MinimumWidth = 200; btnPlaySound.ToolTip = "Play the current sound"; // Mutate Button var btnMutate = new Button( "Mutate", "shuffle" ); btnMutate.Clicked = () => { component.Mutate(); component.PlaySound(); }; btnMutate.ToolTip = "Mutate all sound properties"; // Randomize Pickup Button var btnRandomizePickup = new Button( "", "monetization_on" ); btnRandomizePickup.Clicked = () => { component.RandomizePickup(); component.PlaySound(); }; btnRandomizePickup.ToolTip = "Generate random pickup sound"; // Randomize Laser Button var btnRandomizeLaser = new Button( "", "bolt" ); btnRandomizeLaser.Clicked = () => { component.RandomizeLaser(); component.PlaySound(); }; btnRandomizeLaser.ToolTip = "Generate random laser sound"; // Randomize Explosion Button var btnRandomizeExplosion = new Button( "", "flare" ); btnRandomizeExplosion.Clicked = () => { component.RandomizeExplosion(); component.PlaySound(); }; btnRandomizeExplosion.ToolTip = "Generate random explosion sound"; // Randomize Powerup Button var btnRandomizePowerup = new Button( "", "star" ); btnRandomizePowerup.Clicked = () => { component.RandomizePowerup(); component.PlaySound(); }; btnRandomizePowerup.ToolTip = "Generate random powerup sound"; // Randomize Hit Hurt Button var btnRandomizeHit = new Button( "", "sentiment_very_dissatisfied" ); btnRandomizeHit.Clicked = () => { component.RandomizeHit(); component.PlaySound(); }; btnRandomizeHit.ToolTip = "Generate random hit/hurt sound"; // Randomize Jump Button var btnRandomizeJump = new Button( "", "settings_accessibility" ); btnRandomizeJump.Clicked = () => { component.RandomizeJump(); component.PlaySound(); }; btnRandomizeJump.ToolTip = "Generate random jump sound"; // Randomize Blip Select Button var btnRandomizeBlipSelect = new Button( "", "menu" ); btnRandomizeBlipSelect.Clicked = () => { component.RandomizeBlip(); component.PlaySound(); }; btnRandomizeBlipSelect.ToolTip = "Generate random blip/select sound"; Layout = Layout.Column(); Layout.Spacing = 2; Layout.Margin = new Sandbox.UI.Margin( 0, 4 ); MinimumHeight = 90; var grid = Layout.Grid(); grid.Spacing = 2; grid.AddCell( 0, 0, btnRandomizePickup ); grid.AddCell( 1, 0, btnRandomizeLaser ); grid.AddCell( 2, 0, btnRandomizeExplosion ); grid.AddCell( 3, 0, btnRandomizePowerup ); grid.AddCell( 4, 0, btnRandomizeHit ); grid.AddCell( 5, 0, btnRandomizeJump ); grid.AddCell( 6, 0, btnRandomizeBlipSelect ); var randomRow = Layout.Row(); randomRow.Spacing = 2; randomRow.Add( btnRandomize ); randomRow.Add( btnMutate ); Layout.Add( grid ); Layout.Add( randomRow ); Layout.Add( btnPlaySound ); } protected override void OnPaint() { } }