Example #1
0
        public static PedalOption AddRadialPedalToSubMenu(Action <float> onUpdate, string text = "Button Text", float startingValue = 0, Texture2D icon = null)
        {
            ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener();

            if (actionMenuOpener == null)
            {
                return(null);
            }
            PedalOption pedalOption = actionMenuOpener.GetActionMenu().AddOption();

            pedalOption.setText(text);
            pedalOption.setIcon(icon);
            pedalOption.field_Public_ActionButton_0.prop_String_1             = $"{Math.Round(startingValue)}%";
            pedalOption.field_Public_ActionButton_0.prop_Texture2D_2          = Utilities.GetExpressionsIcons().typeRadial;
            pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate <PedalOptionTriggerEvent>(new Action(delegate
            {
                Action <float> combinedAction = (System.Action <float>) Delegate.Combine(new Action <float>(delegate(float f)
                {
                    startingValue = f;

                    pedalOption.field_Public_ActionButton_0.prop_String_1 = $"{Math.Round(startingValue)}%";
                }), onUpdate);
                RadialPuppetManager.OpenRadialMenu(startingValue, combinedAction, text);
            }));
            return(pedalOption);
        }
Example #2
0
        /// <summary>
        ///     Add a lockable radial puppet button pedal to a custom submenu
        /// </summary>
        /// <param name="text">Button text</param>
        /// <param name="onUpdate">Calls action with a float between 0 - 1 depending on the current value of the radial puppet</param>
        /// <param name="startingValue">(optional) Starting value for radial puppet 0-1</param>
        /// <param name="icon">(optional) The Button Icon</param>
        /// <param name="locked">(optional)The starting state for the lockable pedal, true = locked, false = unlocked</param>
        /// <returns>
        ///     PedalOption Instance (Note: the gameobject that it is attached to is destroyed when you change page on the
        ///     action menu
        /// </returns>
        public static PedalOption AddRadialPuppet(string text, Action <float> onUpdate, float startingValue = 0,
                                                  Texture2D icon = null, bool locked = false)
        {
            var actionMenuOpener = Utilities.GetActionMenuOpener();

            if (actionMenuOpener == null)
            {
                return(null);
            }
            var pedalOption = actionMenuOpener.GetActionMenu().AddOption();

            pedalOption.SetText(text);
            pedalOption.SetBackgroundIcon(icon);
            pedalOption.SetButtonPercentText($"{Math.Round(startingValue * 100)}%");
            pedalOption.SetPedalTypeIcon(Utilities.GetExpressionsIcons().typeRadial);
            if (!locked)
            {
                pedalOption.SetPedalAction(
                    delegate
                {
                    var combinedAction = (Action <float>) Delegate.Combine(new Action <float>(delegate(float f)
                    {
                        startingValue = f;
                        pedalOption.SetButtonPercentText($"{Math.Round(startingValue * 100)}%");
                    }), onUpdate);
                    RadialPuppetManager.OpenRadialMenu(startingValue, combinedAction, text, pedalOption);
                }
                    );
            }
            else
            {
                pedalOption.Lock();
            }
            return(pedalOption);
        }
Example #3
0
 public PedalRadial(string text, float startingValue, Texture2D icon, Action <float> onUpdate)
 {
     this.text         = text;
     this.currentValue = startingValue;
     this.icon         = icon;
     this.onUpdate     = onUpdate;
     this.onClose      = delegate(float f)
     {
         currentValue = f;
         pedal.field_Public_ActionButton_0.prop_String_1 = $"{Math.Round(currentValue)}%";
     };
     this.triggerEvent = delegate {
         RadialPuppetManager.OpenRadialMenu(currentValue, onClose, text);
     };
     this.Type = PedalType.RadialPuppet;
 }
Example #4
0
 public PedalRadial(string text, float startingValue, Texture2D icon, Action <float> onUpdate,
                    bool locked = false, bool restricted = false)
 {
     this.text    = text;
     currentValue = startingValue;
     this.icon    = icon;
     triggerEvent = delegate
     {
         var combinedAction = (Action <float>) Delegate.Combine(new Action <float>(delegate(float f)
         {
             startingValue = f;
             pedal.SetButtonPercentText($"{Math.Round(startingValue * 100)}%");
         }), onUpdate);
         RadialPuppetManager.OpenRadialMenu(startingValue, combinedAction, text, pedal, restricted);
     };
     Type            = PedalType.RadialPuppet;
     this.locked     = locked;
     this.restricted = restricted;
 }