示例#1
0
        protected virtual void OnMouseLeftClick(float x, float y)
        {
            if (Contains(x, y))
            {
                MenuVisible = MenuVisible != true;
                Color       = MenuVisible == true ? parent.SelectionColor : parent.HoverColor;

                if (MenuVisible)
                {
                    ConnectMenu();
                }
                else
                {
                    DisconnectMenu();
                    parent.objectHandler.EnableInput();
                }
            }
            else if (MenuContains(x, y) && MenuVisible)
            {
                parent.objectHandler.EnableInput();
                MouseLeftPressed?.Invoke(x, y);
                MenuVisible = false;
                Color       = parent.BaseColor;
                DisconnectMenu();
            }

            /*else
             * {
             *  Debug.WriteLine("Here");
             *  MenuVisible = false;
             *  Color = parent.BaseColor;
             *  DisconnectMenu();
             * }*/
        }
示例#2
0
 private void OnMouseLeftClick(float x, float y)
 {
     if (ViewPortContains(x, y))
     {
         if (CurrentOperation == ObjectOperation.Placing && newObject != null)
         {
             newObject.Pos = new Vector2(x, y) - parent.camera.CurrentOffset;
             WorldObjects.Add(newObject);
             newObject = new WorldObject(newObject, newObject.Pos);
         }
         if (CurrentOperation == ObjectOperation.None && !parent.grid.EditModeEnabled)
         {
             currentSelection = null;
             MouseLeftPressed?.Invoke(x, y);
             ObjectSelection?.Invoke(ref currentSelection);
             if (currentSelection != null)
             {
                 InputStateChanged?.Invoke(false);
             }
             else
             {
                 InputStateChanged?.Invoke(true);
             }
         }
         if (CurrentOperation == ObjectOperation.Placing && currentSelection != null)
         {
             currentSelection.Pos = new Vector2(x, y) + mousePadding - parent.camera.CurrentOffset;
             parent.inputHandler.MouseMovedEvent -= OnMousePosChanged;
             CurrentOperation = ObjectOperation.None;
             InputStateChanged?.Invoke(true);
         }
     }
 }
示例#3
0
 public void OnMouseLeftPressed(float x, float y)
 {
     if (Contains(x, y))
     {
         MouseLeftPressed?.Invoke(x, y);
     }
 }