Example #1
0
 public void HandleMouseMove(MouseEventArgs e)
 {
     float dx = e.GetMovementX();
     float dy = e.GetMovementY();
     previousMouseX = e.GetX();
     previousMouseY = e.GetY();
     if (mousePressed)
     {
         //            ySpeed += dx / 10;
         //            xSpeed += dy / 10;
     }
     screen.OnMouseMove(e);
 }
Example #2
0
 void MouseMove(MouseEventArgs e)
 {
     if (e.GetEmulated())
     {
         return;
     }
     for (int i = 0; i < WidgetCount; i++)
     {
         MenuWidget w = widgets[i];
         if (w != null)
         {
             w.hover = pointInRect(e.GetX(), e.GetY(), w.x, w.y, w.sizex, w.sizey);
         }
     }
 }
Example #3
0
 public void HandleMouseDown(MouseEventArgs e)
 {
     mousePressed = true;
     previousMouseX = e.GetX();
     previousMouseY = e.GetY();
     screen.OnMouseDown(e);
 }
    public override void OnMouseDown(Game game_, MouseEventArgs args)
    {
        if (game.guistate != GuiState.Inventory)
        {
            return;
        }
        PointRef scaledMouse = PointRef.Create(args.GetX(), args.GetY());

        //material selector
        if (SelectedMaterialSelectorSlot(scaledMouse) != null)
        {
            //int oldActiveMaterial = ActiveMaterial.ActiveMaterial;
            game.ActiveMaterial = SelectedMaterialSelectorSlot(scaledMouse).value;
            //if (oldActiveMaterial == ActiveMaterial.ActiveMaterial)
            {
                Packet_InventoryPosition p = new Packet_InventoryPosition();
                p.Type = Packet_InventoryPositionTypeEnum.MaterialSelector;
                p.MaterialId = game.ActiveMaterial;
                controller.InventoryClick(p);
            }
            args.SetHandled(true);
            return;
        }

        if (game.guistate != GuiState.Inventory)
        {
            return;
        }

        //main inventory
        PointRef cellInPage = SelectedCell(scaledMouse);
        //grab from inventory
        if (cellInPage != null)
        {
            if (args.GetButton() == MouseButtonEnum.Left)
            {
                Packet_InventoryPosition p = new Packet_InventoryPosition();
                p.Type = Packet_InventoryPositionTypeEnum.MainArea;
                p.AreaX = cellInPage.X;
                p.AreaY = cellInPage.Y + ScrollLine;
                controller.InventoryClick(p);
                args.SetHandled(true);
                return;
            }
            else
            {
                {
                    Packet_InventoryPosition p = new Packet_InventoryPosition();
                    p.Type = Packet_InventoryPositionTypeEnum.MainArea;
                    p.AreaX = cellInPage.X;
                    p.AreaY = cellInPage.Y + ScrollLine;
                    controller.InventoryClick(p);
                }
                {
                    Packet_InventoryPosition p = new Packet_InventoryPosition();
                    p.Type = Packet_InventoryPositionTypeEnum.WearPlace;
                    p.WearPlace = WearPlace_.RightHand;
                    p.ActiveMaterial = game.ActiveMaterial;
                    controller.InventoryClick(p);
                }
                {
                    Packet_InventoryPosition p = new Packet_InventoryPosition();
                    p.Type = Packet_InventoryPositionTypeEnum.MainArea;
                    p.AreaX = cellInPage.X;
                    p.AreaY = cellInPage.Y + ScrollLine;
                    controller.InventoryClick(p);
                }
            }
            if (game.guistate == GuiState.Inventory)
            {
                args.SetHandled(true);
                return;
            }
        }
        // //drop items on ground
        //if (scaledMouse.X < CellsStartX() && scaledMouse.Y < MaterialSelectorStartY())
        //{
        //    int posx = game.SelectedBlockPositionX;
        //    int posy = game.SelectedBlockPositionY;
        //    int posz = game.SelectedBlockPositionZ;
        //    Packet_InventoryPosition p = new Packet_InventoryPosition();
        //    {
        //        p.Type = Packet_InventoryPositionTypeEnum.Ground;
        //        p.GroundPositionX = posx;
        //        p.GroundPositionY = posy;
        //        p.GroundPositionZ = posz;
        //    }
        //    controller.InventoryClick(p);
        //}
        if (SelectedWearPlace(scaledMouse) != null)
        {
            Packet_InventoryPosition p = new Packet_InventoryPosition();
            p.Type = Packet_InventoryPositionTypeEnum.WearPlace;
            p.WearPlace = (SelectedWearPlace(scaledMouse).value);
            p.ActiveMaterial = game.ActiveMaterial;
            controller.InventoryClick(p);
            args.SetHandled(true);
            return;
        }
        if (scaledMouse.X >= ScrollUpButtonX() && scaledMouse.X < ScrollUpButtonX() + ScrollButtonSize()
            && scaledMouse.Y >= ScrollUpButtonY() && scaledMouse.Y < ScrollUpButtonY() + ScrollButtonSize())
        {
            ScrollUp();
            ScrollingUpTimeMilliseconds = game.platform.TimeMillisecondsFromStart();
            args.SetHandled(true);
            return;
        }
        if (scaledMouse.X >= ScrollDownButtonX() && scaledMouse.X < ScrollDownButtonX() + ScrollButtonSize()
            && scaledMouse.Y >= ScrollDownButtonY() && scaledMouse.Y < ScrollDownButtonY() + ScrollButtonSize())
        {
            ScrollDown();
            ScrollingDownTimeMilliseconds = game.platform.TimeMillisecondsFromStart();
            args.SetHandled(true);
            return;
        }
        game.GuiStateBackToGame();
        return;
    }
Example #5
0
 public virtual void OnMouseUp(MouseEventArgs e)
 {
     MouseUp(e.GetX(), e.GetY());
 }
Example #6
0
 public override void OnMouseDown(Game game_, MouseEventArgs args)
 {
     for (int i = 0; i < chatlines2Count; i++)
     {
         float dx = 20;
         if (!game.platform.IsMousePointerLocked())
         {
             dx += 100;
         }
         float chatlineStartX = dx * game.Scale();
         float chatlineStartY = (90 + i * 25) * game.Scale();
         float chatlineSizeX = 500 * game.Scale();
         float chatlineSizeY = 20 * game.Scale();
         if (args.GetX() > chatlineStartX && args.GetX() < chatlineStartX + chatlineSizeX)
         {
             if (args.GetY() > chatlineStartY && args.GetY() < chatlineStartY + chatlineSizeY)
             {
                 //Mouse over chatline at position i
                 if (chatlines2[i].clickable)
                 {
                     game.platform.OpenLinkInBrowser(chatlines2[i].linkTarget);
                 }
             }
         }
     }
 }
Example #7
0
 public void MouseMove(MouseEventArgs e)
 {
     mouseCurrentX = e.GetX();
     mouseCurrentY = e.GetY();
     mouseDeltaX += e.GetMovementX();
     mouseDeltaY += e.GetMovementY();
     for (int i = 0; i < clientmodsCount; i++)
     {
         if (clientmods[i] == null) { continue; }
         clientmods[i].OnMouseMove(this, e);
     }
 }
Example #8
0
 public override void OnMouseUp(Game game_, MouseEventArgs args) { MouseUp(args.GetX(), args.GetY()); }
Example #9
0
 void MouseMove(MouseEventArgs e)
 {
     for (int i = 0; i < WidgetCount; i++)
     {
         MenuWidget w = widgets[i];
         if (w != null)
         {
             w.hover = pointInRect(e.GetX(), e.GetY(), screenx + w.x, screeny + w.y, w.sizex, w.sizey);
         }
     }
 }
Example #10
0
 public void MouseMove(MouseEventArgs e)
 {
     if (!e.GetEmulated())
     {
         // Set x and y only for real MouseMove events
         mouseCurrentX = e.GetX();
         mouseCurrentY = e.GetY();
     }
     else
     {
         // Get delta only from emulated events (actual events negate previous ones)
         mouseDeltaX += e.GetMovementX();
         mouseDeltaY += e.GetMovementY();
     }
     for (int i = 0; i < clientmodsCount; i++)
     {
         if (clientmods[i] == null) { continue; }
         clientmods[i].OnMouseMove(this, e);
     }
 }