Esempio n. 1
0
        public void Tick()
        {
            if (pressed)
            {
                if (Mouse.GetCursorState().LeftButton == ButtonState.Released)
                {
                    if (UpUI != null)
                    {
                        UpUI.ClickReleased();
                    }
                    pressed = false;
                }
            }
            else
            {
                if (Mouse.GetCursorState().LeftButton == ButtonState.Pressed)
                {
                    if (UpUI != null)
                    {
                        if (UpUI.IsHover)
                        {
                            if (FocusedUI != null)
                            {
                                FocusedUI.UnFocus();
                            }

                            UpUI.Click();
                            FocusedUI = UpUI;

                            FocusedUI.Focus();
                        }
                        else
                        {
                            if (FocusedUI != null)
                            {
                                FocusedUI.UnFocus();
                            }
                        }
                    }
                    pressed = true;
                }
            }

            if (Input.GetKeyDown(Key.Escape) || Input.GetKeyDown(Key.Enter) || Input.GetKeyDown(Key.KeypadEnter))
            {
                if (FocusedUI != null)
                {
                    FocusedUI.UnFocus();
                }
            }

            /*for (int i = 0; i < GuiBaseList.Count; i++)
             * {
             *  GuiBaseList[i].Tick();
             * }*/
        }
Esempio n. 2
0
        public void OnMouseMove(MouseMoveEventArgs e)
        {
            if (!EvllyEngine.MouseCursor.MouseLocked)
            {
                Point point = new Point(e.X, e.Y);

                foreach (var item in GuiBaseList)
                {
                    if (item.IsInteract)
                    {
                        if (item.IsEnabled)
                        {
                            if (item.GetRectangle.Contains(point))
                            {
                                UpUI = item;

                                item.UnHover();
                                //item.UnFocus();
                            }
                            else
                            {
                                item.UnHover();
                                //item.UnFocus();
                            }
                        }
                    }
                    else
                    {
                        item.UnHover();
                        item.UnFocus();
                    }
                }

                if (UpUI != null)
                {
                    if (UpUI.GetRectangle.Contains(point))
                    {
                        UpUI.Hover();
                    }
                    else
                    {
                        UpUI.UnHover();
                    }
                }
            }
        }
Esempio n. 3
0
 public static void RemoveGuiElement(GUIBase baseGui)
 {
     GUI.Instance.GuiBaseList.Remove(baseGui);
 }
Esempio n. 4
0
 public static void AddGuiElement(GUIBase baseGui)
 {
     GUI.Instance.GuiBaseList.Add(baseGui);
 }