예제 #1
0
        /**
         * De-registers an existing listener from receiving button events.
         *
         * @param listener to be removed.
         * @since v2.0
         */
        public void RemoveButtonListener(IButtonListener listener)
        {
            // Start logging elapsed time.
            long     tIn    = TimerUtil.CurrentTimeMillis();
            ILogging logger = AppRegistryBridge.GetInstance().GetLoggingBridge();

            if (logger != null)
            {
                logger.Log(ILoggingLogLevel.Debug, this.apiGroup.ToString(), "DeviceBridge executing removeButtonListener...");
            }

            if (this._delegate != null)
            {
                this._delegate.RemoveButtonListener(listener);
                if (logger != null)
                {
                    logger.Log(ILoggingLogLevel.Debug, this.apiGroup.ToString(), "DeviceBridge executed 'removeButtonListener' in " + (TimerUtil.CurrentTimeMillis() - tIn) + "ms.");
                }
            }
            else
            {
                if (logger != null)
                {
                    logger.Log(ILoggingLogLevel.Error, this.apiGroup.ToString(), "DeviceBridge no delegate for 'removeButtonListener'.");
                }
            }
        }
예제 #2
0
    /// <summary>
    /// Unsubscribe a given listener
    /// from the collection that it
    /// was assigned to
    /// </summary>
    /// <param name="listener">The listener to be removed</param>
    public void Unsubscribe(IButtonListener listener)
    {
        // Get the button(s) that the VRDControllerButtonListener
        // was getting input from
        OVRInput.Button targetButton = listener.TargetButton;

        // Check to see if each of our
        // buttons were being listened to.
        // When one is found, remove the
        // listener from the appropriate
        // collection
        if (targetButton.HasFlag(OVRInput.Button.One))
        {
            Unsubscribe(listener, ref buttonOneListeners);
        }
        if (targetButton.HasFlag(OVRInput.Button.Two))
        {
            Unsubscribe(listener, ref buttonTwoListeners);
        }
        if (targetButton.HasFlag(OVRInput.Button.PrimaryThumbstick))
        {
            Unsubscribe(listener, ref thumbstickListeners);
        }
        if (targetButton.HasFlag(OVRInput.Button.PrimaryIndexTrigger))
        {
            Unsubscribe(listener, ref indexTriggerListeners);
        }
        if (targetButton.HasFlag(OVRInput.Button.PrimaryHandTrigger))
        {
            Unsubscribe(listener, ref gripTriggerListeners);
        }
    }
예제 #3
0
    public void ReplaceButtonListener(IButtonListener newListener)
    {
        var index     = GameComponentsLookup.ButtonListener;
        var component = CreateComponent <ButtonListenerComponent>(index);

        component.listener = newListener;
        ReplaceComponent(index, component);
    }
예제 #4
0
        protected override void Awake()
        {
            base.Awake();

            sellerViewController = viewContext.SellerViewController;
            playerLookController = modelContext.PlayerLookController;
            modelController      = modelContext.ModelController;
            backListener         = viewContext.BackButtonListener;
        }
예제 #5
0
 /// <summary>
 /// This method is used to subscribe a
 /// VRDControllerButtonListener to an
 /// appropriate collection
 /// </summary>
 /// <param name="listener">The VRDControllerButtonListener
 /// will be receiving input feedback</param>
 /// <param name="targetList">The list of VRDControllerButtonListener
 /// components that this component should be assigned to</param>
 private void Subscribe(IButtonListener listener, ref List <IButtonListener> targetList)
 {
     // Check to see if the listener
     // is already in the list before adding
     if (!targetList.Contains(listener))
     {
         // Add the listener to the
         // collection
         targetList.Add(listener);
     }
 }
예제 #6
0
        /// <summary>
        /// Poistaa focuksen kontrollilta ja sen mahdollisilta listenereitlä
        /// ja childeiltä.
        /// </summary>
        public virtual void Defocus()
        {
            IButtonListener buttonListener = this as IButtonListener;

            if (buttonListener != null)
            {
                buttonListener.ButtonEventListener.Trigger.CurrentState = PressedState.None;
            }

            hasFocus = false;
        }
        // --- Interface methods ---
        public void AddButtonListener(IButtonListener buttonListener, int buttonID)
        {
            List <IButtonListener> value = null;

            if (Buttons.TryGetValue(buttonID, out value))
            {
                value.Add(buttonListener);
            }
            else
            {
                List <IButtonListener> listenList = new List <IButtonListener>();
                listenList.Add(buttonListener);
                Buttons.Add(buttonID, listenList);
            }
        }
예제 #8
0
    /// <summary>
    /// This method is used to remove a
    /// VRDControllerButtonListener from an
    /// appropriate collection
    /// </summary>
    /// <param name="listener">The VRDControllerButtonListener
    /// will was receiving input feedback</param>
    /// <param name="targetList">The list of VRDControllerButtonListener
    /// components that this component should be removed from</param>
    public void Unsubscribe(IButtonListener listener, ref List <IButtonListener> targetList)
    {
        // Note that the method signature
        // above uses the ref keyword which
        // will allow us to manipulate the List
        // that is being used directly.
        // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/ref

        // Make sure the listener
        // is in the collection before
        // trying to remove it
        if (targetList.Contains(listener))
        {
            // Remove the listener that was
            // found
            targetList.Remove(listener);
        }
    }
예제 #9
0
 public void GenerateTextButtons(IButtonListener target, string[] buttonText, int[] buttonCodes)
 {
     GameManager.getInstance().TogglePlayerMovement(false);
     if (buttonText.Length == buttonCodes.Length)
     {
         textButtons = new List <Button>();
         for (int i = 0; i < Mathf.Min(buttonText.Length, textButtonPositions.Length); i++)
         {
             /*IButton btn = textButtons[i];
              * btn.gameObject.SetActive(true);
              * TextButton txt = btn.gameObject.GetComponent<TextButton>();
              * txt.SetListener(target);
              * txt.SetText(buttonText[i]);
              * txt.SetButtonCode(buttonCodes[i]);*/
             Button btn = textButtons[i];
             btn.gameObject.SetActive(true);
         }
     }
 }
예제 #10
0
        /// <summary>
        /// Tries to attach the given command input listener to the appropriate command button slot if the given listener is a command button
        /// listener, and the state of the given listener is not CommandButtonStateEnum.Invisible.
        /// </summary>
        /// <param name="listener">The command input listener to attach.</param>
        /// <remarks>
        /// If the given command input listener is not a command button listener, or its state is CommandButtonStateEnum.Invisible then this
        /// function has no effect.
        /// </remarks>
        private void TryAttachAsButtonListener(CommandInputListener listener)
        {
            IButtonListener buttonListener = listener as IButtonListener;

            if (buttonListener == null)
            {
                return;
            }

            AvailabilityEnum buttonAvailability = buttonListener.ButtonAvailability;

            if (buttonAvailability == AvailabilityEnum.Unavailable)
            {
                return;
            }

            RCIntVector slotPosition = buttonListener.CommandPanelSlot;

            if (this.commandPanelSlots[slotPosition.X, slotPosition.Y] != null)
            {
                if (this.commandPanelSlots[slotPosition.X, slotPosition.Y].ButtonListener.Priority > buttonListener.Priority)
                {
                    /// Another IButtonListener with higher priority has already been attached to the command panel slot.
                    return;
                }
                else if (this.commandPanelSlots[slotPosition.X, slotPosition.Y].ButtonListener.Priority == buttonListener.Priority)
                {
                    throw new InvalidOperationException(string.Format("Another IButtonListener with the same priority has already been attached to command panel slot {0}!", slotPosition));
                }
            }

            this.commandPanelSlots[slotPosition.X, slotPosition.Y] = new CommandPanelSlot
            {
                ButtonState    = buttonAvailability == AvailabilityEnum.Disabled ? CommandButtonStateEnum.Disabled : CommandButtonStateEnum.Enabled,
                ButtonSprite   = buttonListener.ButtonSprite,
                ButtonListener = buttonListener,
                Listener       = listener
            };
        }
예제 #11
0
 public void SetListener(IButtonListener l)
 {
     listener = l;
 }
예제 #12
0
 public void AddButtonListener(IButtonListener listener)
 {
     listeners.Add(listener);
 }
 public void SetButtonListener(IButtonListener listener)
 {
 }
예제 #14
0
 public void RemoveListener(IButtonListener buttonListener)
 {
     buttonListeners.Remove(buttonListener);
 }
예제 #15
0
 public void RegisterListener(IButtonListener buttonListener)
 {
     buttonListeners.Add(buttonListener);
 }
예제 #16
0
 public void RemoveListener(IButtonListener listener)
 {
     btn.onClick.RemoveListener(() => listener.ClickCallback());
 }
예제 #17
0
 /// <summary>
 /// Метод вызывает событие нажатие на нужную кнопку.
 /// </summary>
 /// <param name="btn"></param>
 public void ButtonPress(IButtonListener btn)
 {
     btn.ButtonPressed();
 }
예제 #18
0
 public void AddListener(IButtonListener listener)
 {
     _buttonListeners.Add(listener);
 }
예제 #19
0
 protected override void Awake()
 {
     base.Awake();
     modelController = modelContext.ModelController;
     backListener    = viewContext.BackButtonListener;
 }
예제 #20
0
 protected override void Awake()
 {
     base.Awake();
     backListener = viewContext.BackButtonListener;
 }
예제 #21
0
 public void SetButtonListener(IButtonListener listener) => _listener = listener;
예제 #22
0
 public void AddListener(IButtonListener listener)
 {
     btn.onClick.AddListener(() => listener.ClickCallback());
 }