public void OpenInfos()
 {
     if (isActive)
     {
         OnPressed.Invoke(locationData.name, "Open" + locationData.opening_hours.open_now.ToString(), locationDetails);
     }
 }
Beispiel #2
0
            /// <summary>
            /// Handles watching the given key for
            /// </summary>
            /// <param name="myCurrentState"></param>
            /// <param name="myPrevState"></param>
            /// <param name="key"></param>
            public void Watch(KeyboardState myCurrentState, KeyboardState myPrevState)
            {
                bool wasPressed = myPrevState.IsKeyDown(myKey);
                bool isPressed  = myCurrentState.IsKeyDown(myKey);

                ButtonDelta deltaState =
                    isPressed != wasPressed ?
                    isPressed ? ButtonDelta.Pressed : ButtonDelta.Released :
                    isPressed ? ButtonDelta.Down : ButtonDelta.Up;

                if (deltaState == ButtonDelta.Pressed)
                {
                    OnPressed?.Invoke(this, new KeyPressEventArgs(myKey, deltaState));
                }

                if (deltaState == ButtonDelta.Released)
                {
                    OnReleased?.Invoke(this, new KeyPressEventArgs(myKey, deltaState));
                }

                if (deltaState == ButtonDelta.Down)
                {
                    OnDown?.Invoke(this, new KeyPressEventArgs(myKey, deltaState));
                }

                if (deltaState == ButtonDelta.Up)
                {
                    OnUp?.Invoke(this, new KeyPressEventArgs(myKey, deltaState));
                }

                OnEvent?.Invoke(this, new KeyPressEventArgs(myKey, deltaState));
            }
Beispiel #3
0
 private void KeyPressed()
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         OnPressed?.Invoke(keyValue);
     }
 }
        protected override Control MakeUI(object value)
        {
            if (value == null)
            {
                return(new Label {
                    Text = "null", Align = Label.AlignMode.Right
                });
            }

            // NOTE: value is NOT always the actual object.
            // Only thing we can really rely on is that ToString works out correctly.
            // This is because of reference tokens, but due to simplicity the object ref is still passed.

            var button = new Button
            {
                Text                = $"Reference: {value}",
                ClipText            = true,
                SizeFlagsHorizontal = Control.SizeFlags.FillExpand
            };

            button.OnPressed += _ =>
            {
                OnPressed?.Invoke();
            };
            return(button);
        }
Beispiel #5
0
 public void PressOption()
 {
     if (OnPressed != null)
     {
         OnPressed.Invoke();
     }
 }
Beispiel #6
0
 private void OnHotkeyTriggered(HotkeyTriggered e)
 {
     if (e.Hotkey == Hotkey)
     {
         OnPressed.Invoke();
     }
 }
Beispiel #7
0
        private void Press()
        {
            _startDragPosition = Touch.Position;

            SetPressStyle();

            ButtonState = ButtonClickState.Pressed;

            OnPressed?.Invoke(Touch);
        }
Beispiel #8
0
    public override void OnMouseReleased()
    {
        base.OnMouseReleased();

        if (Enabled)
        {
            OnPressed?.Invoke();
            pressed = false;
            Children.ForEach((child) => child.Offset = Vector2.Zero);
        }
    }
Beispiel #9
0
 internal void onMouseButtonPressed(object sender, MouseButtonEventArgs e)
 {
     if (e.X >= Position.X && e.Y >= Position.Y)
     {
         int xLimit = Position.X + Size.Width;
         int yLimit = Position.Y + Size.Height;
         if (e.X < xLimit && e.Y < yLimit)
         {
             OnPressed?.Invoke(this, EventArgs.Empty);
         }
     }
 }
Beispiel #10
0
 private void Update()
 {
     foreach (var command in _toRemove)
     {
         _commands.Remove(command);
         _isPressed.Remove(command);
         _wasPressed.Remove(command);
     }
     _toRemove.Clear();
     foreach (var command in _commands)
     {
         if (_toRemove.Contains(command))
         {
             continue;
         }
         var blockFlag = command.GetValue <bool>("_blockNextRelease");
         if (command.IsNewlyPressed())
         {
             OnNewlyPressed?.Invoke(command);
         }
         if (command.IsNewlyHeld(MinimalPressDuration))
         {
             OnNewlyHeld?.Invoke(command);
         }
         if (command.IsPressed())
         {
             OnPressed?.Invoke(command);
             _isPressed[command] = true;
         }
         else
         {
             _wasPressed[command] = _isPressed[command];
             _isPressed[command]  = false;
         }
         if (command.IsNewlyReleased())
         {
             OnNewlyReleased?.Invoke(command);
         }
         if (command.IsHeld(MinimalPressDuration))
         {
             OnHeld?.Invoke(command);
         }
         if (command.IsTapped(MaximalTapDuration))
         {
             OnTapped?.Invoke(command);
         }
         if (blockFlag)//damn you, Mobius Digital
         {
             var toReblock = _wasPressed[command] || _isPressed[command];
             command.SetValue("_blockNextRelease", toReblock);
         }
     }
 }
Beispiel #11
0
            public void Watch(DeltaMouseState change)
            {
                ButtonDelta deltaState = ButtonDelta.Invalid;

                switch (myButton)
                {
                case MouseButton.Left:
                    deltaState = change.LeftButton;
                    break;

                case MouseButton.Right:
                    deltaState = change.RightButton;
                    break;

                case MouseButton.Middle:
                    deltaState = change.MiddleButton;
                    break;

                case MouseButton.XButton1:
                    deltaState = change.XButton1;
                    break;

                case MouseButton.XButton2:
                    deltaState = change.XButton2;
                    break;
                }

                if (deltaState != ButtonDelta.Invalid)
                {
                    if (deltaState == ButtonDelta.Pressed)
                    {
                        OnPressed?.Invoke(this, change);
                    }

                    if (deltaState == ButtonDelta.Released)
                    {
                        OnReleased?.Invoke(this, change);
                    }

                    if (deltaState == ButtonDelta.Down)
                    {
                        OnDown?.Invoke(this, change);
                    }

                    if (deltaState == ButtonDelta.Up)
                    {
                        OnUp?.Invoke(this, change);
                    }

                    OnEvent?.Invoke(this, change);
                }
            }
Beispiel #12
0
 private void Input_DigitalValueChanged(object sender, DigitalInValueChangedEventArgs e)
 {
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Pressed"));
     if (e.NewValue ^ activeLow)
     {
         OnPressed?.Invoke(this, new ButtonPressedEventArgs {
             ButtonPressed = true
         });
     }
     else
     {
         OnReleased?.Invoke(this, new ButtonReleasedEventArgs {
             ButtonReleased = true
         });
     }
 }
Beispiel #13
0
 public void Compute()
 {
     output = Input.GetAxis(name);
     value  = Mathf.Abs(Input.GetAxisRaw(name));
     if (value > 0f && oldValue == 0f)
     {
         OnDown.Invoke(output);
     }
     if (value < 1f && oldValue == 1f)
     {
         OnUp.Invoke(output);
     }
     if (value > 0f && oldValue > 0f)
     {
         OnPressed.Invoke(output);
     }
     oldValue = value;
 }
Beispiel #14
0
    public void OnPointerDown(PointerEventData eventData)
    {
        buttonPressed           = true;
        PlayerScript.blockShoot = true;

        //switch(button_type)
        if (!(pointerDown || locked))
        {
            pointerDown = true;

            //Do stuff on press:
            //image.color = new Color(1, 1, 1, 0.75f);
            image.sprite = clickedSprite;
            OnPressed.Invoke();
            if (useHold)
            {
                StartCoroutine(HoldCounter());
            }
        }
    }
Beispiel #15
0
        private static void OnSceneRender(SceneView scene)
        {
            Event e = Event.current;

            HandleFilthyShiftInput(e);
            if (e.keyCode == KeyCode.None)
            {
                return;     //Sometimes returns none for some reason, might be unity input lag.
            }
            switch (e.type)
            {
            case EventType.KeyDown:
            {
                s_HeldDown.Add(e.keyCode);
                OnPressed?.Invoke(e.keyCode);
                break;
            }

            case EventType.KeyUp:
            {
                s_HeldDown.Remove(e.keyCode);
                OnRelease?.Invoke(e.keyCode);
                break;
            }

            case EventType.MouseDown:
            {
                s_HeldDown.Add(e.keyCode);
                OnPressed?.Invoke(e.keyCode);
                break;
            }

            case EventType.MouseUp:
            {
                s_HeldDown.Remove(e.keyCode);
                OnRelease?.Invoke(e.keyCode);
                break;
            }
            }
        }
Beispiel #16
0
        internal override void Update(GuiMouseState mouseState)
        {
            if (this.ContainsPoint(mouseState.MouseX, mouseState.MouseY))
            {
                if (!this.Hovered)
                {
                    this.Hovered = true;
                    Gui.InvalidateVisual();
                }

                if (mouseState.MouseLeftDown && !this.Active)
                {
                    this.Active = true;
                    OnPressed?.Invoke(this, EventArgs.Empty);
                    Gui.InvalidateVisual();
                }
                else if (!mouseState.MouseLeftDown && this.Active)
                {
                    this.Active = false;
                    OnReleased?.Invoke(this, EventArgs.Empty);
                    OnClick?.Invoke(this, EventArgs.Empty);
                    Gui.InvalidateVisual();
                }
            }
            else
            {
                if (this.Hovered)
                {
                    if (this.Active)
                    {
                        this.Active = false;
                    }

                    this.Hovered = false;

                    Gui.InvalidateVisual();
                }
            }
        }
Beispiel #17
0
    void Update()
    {
        if (animator != null)
        {
            animator.SetBool(ANIM_PARAM_ON, On);
            animator.SetBool(ANIM_PARAM_DOWN, Down);
            animator.SetBool(ANIM_PARAM_HOVER, Hover);
        }

        if (!_percent.HasValue)
        {
            _percent = lever.OpenPercent;
        }
        else
        {
            _percent = Mathf.Lerp(_percent.Value, lever.OpenPercent, Mathf.Clamp(Time.deltaTime * lerp, 0f, 1f));
        }
        transform.localEulerAngles = axis.normalized * CosLerp(start, end, _percent.Value);

        if (On && _percent >= activateThreshold)
        {
            if (OnPressed != null)
            {
                OnPressed.Invoke();
            }
            _timePressed      = Time.time;
            lever.OpenPercent = 1f;
            On = false;
        }

        //if we've released, set the position to zero
        if ((!On || !Down) && (Time.time - _timePressed >= timeStuckAtEnd))
        {
            lever.OpenPercent = 0f;
        }
    }
    public override void ButtonPressAction()
    {
        base.ButtonPressAction();

        OnPressed?.Invoke();
    }
Beispiel #19
0
 public void OnButtonPressed()
 {
     OnPressed?.Invoke(m_mapIdx);
 }
Beispiel #20
0
 public override void OnPointerDown(PointerEventData eventData)
 {
     base.OnPointerDown(eventData);
     OnPressed?.Invoke();
 }
Beispiel #21
0
 void Press()
 {
     OnPressed.Invoke();
     Audio.Play();
     Anim.Play("ButtonPressing");
 }
Beispiel #22
0
 public void Press()
 {
     OnPressed?.Invoke(this, EventArgs.Empty);
 }
Beispiel #23
0
 public void Pressed()
 {
     OnPressed?.Invoke(BaseProduct);
 }
Beispiel #24
0
 public virtual void FireOnPressed()
 {
     OnPressed?.Invoke();
     NotifyChanged();
 }
Beispiel #25
0
 private void onClick()
 {
     OnPressed?.Invoke(this, EventArgs.Empty);
 }
Beispiel #26
0
 void IBeginDragHandler.OnBeginDrag(PointerEventData eventData)
 {
     pressed = true;
     OnPressed?.Invoke();
 }