Exemple #1
0
        public override void Destroy()
        {
            base.Destroy();

            if (Focused == this)
            {
                Focused = null;
            }
        }
Exemple #2
0
        public override void OnClick()
        {
            base.OnClick();

            if (Focused == this)
            {
                // Focused = null;
                // SetLabel();
            }
            else
            {
                firstFrame      = true;
                firstClickFrame = true;
                Focused         = this;
                Label           = $"{Locale.Get(Key)}: {Locale.Get("select")}";
                RelativeCenterX = cx;
            }
        }
Exemple #3
0
 public void Cancel()
 {
     Focused = null;
     SetLabel();
 }
Exemple #4
0
        public void DoCheck()
        {
            if (firstFrame)
            {
                return;
            }

            if (Focused == this)
            {
                if (Gamepad)
                {
                    if (GamepadComponent.Controller == null)
                    {
                        Log.Error("Null controller");
                        return;
                    }


                    foreach (var b in buttonsToCheck)
                    {
                        if (GamepadComponent.Controller.WasPressed(b))
                        {
                            Controls.Replace(Key, b);
                            Controls.Bind();
                            Controls.Save();

                            Focused = null;
                            SetLabel();

                            break;
                        }
                    }
                }
                else
                {
                    foreach (var k in keysToCheck)
                    {
                        if (Input.Keyboard.WasPressed(k))
                        {
                            Controls.Replace(Key, k);
                            Controls.Bind();
                            Controls.Save();

                            Focused = null;
                            SetLabel();

                            break;
                        }
                    }

                    if (firstClickFrame)
                    {
                        firstClickFrame = false;
                    }
                    else
                    {
                        foreach (var b in mouseToCheck)
                        {
                            if (Input.Mouse.Check(b, Input.CheckType.PRESSED))
                            {
                                Controls.Replace(Key, b);
                                Controls.Bind();
                                Controls.Save();

                                Focused = null;
                                SetLabel();

                                break;
                            }
                        }
                    }
                }
            }
        }