Example #1
0
        /// <summary>
        /// Store subscribed buttons in batch, buttons not always need to be polled
        /// and can be unsubscribed from click at any point in users program.
        /// </summary>
        /// <returns>byte length batchcommand</returns>
        internal ushort BatchCommand(PayLoadBuilder payLoadBuilder, int index)
        {
            ushort byteLength = 0;

            _eventButtons = new List <ButtonType>();
            if (Clicked != null)
            {
                UIButtonMethods.BatchCommand(payLoadBuilder, ButtonType.Any, Mode, index);
                _eventButtons.Add(ButtonType.Any);
                byteLength++;
            }
            else
            {
                if (Up.OnClickSubscribed)
                {
                    Up.BatchCommand(payLoadBuilder, index);
                    index++;
                    byteLength++;
                    _eventButtons.Add(Up.Type);
                }
                if (Ok.OnClickSubscribed)
                {
                    Ok.BatchCommand(payLoadBuilder, index);
                    index++;
                    byteLength++;
                    _eventButtons.Add(Ok.Type);
                }
                if (Down.OnClickSubscribed)
                {
                    Down.BatchCommand(payLoadBuilder, index);
                    index++;
                    byteLength++;
                    _eventButtons.Add(Down.Type);
                }
                if (Left.OnClickSubscribed)
                {
                    Left.BatchCommand(payLoadBuilder, index);
                    index++;
                    byteLength++;
                    _eventButtons.Add(Left.Type);
                }
                if (Right.OnClickSubscribed)
                {
                    Right.BatchCommand(payLoadBuilder, index);
                    index++;
                    byteLength++;
                    _eventButtons.Add(Right.Type);
                }
                if (Back.OnClickSubscribed)
                {
                    Back.BatchCommand(payLoadBuilder, index);
                    index++;
                    byteLength++;
                    _eventButtons.Add(Back.Type);
                }
            }

            if (byteLength == 0)
            {
                _eventButtons = null;
            }
            return(byteLength);
        }