Beispiel #1
0
        void ItemsetViewer_Click(object sender, SdlDotNet.Widgets.MouseButtonEventArgs e)
        {
            Point location = this.Location;
            Point relPoint = new Point(e.Position.X - location.X, e.Position.Y - location.Y);

            if (!DrawingSupport.PointInBounds(relPoint, vScroll.Bounds) && !DrawingSupport.PointInBounds(relPoint, hScroll.Bounds))
            {
                if (relPoint.X + (hScroll.Value * Constants.TILE_WIDTH) > activeItemSurf.Size.Width)
                {
                    selectedTile.X = (activeItemSurf.Size.Width / 32) - 1;
                }
                else
                {
                    selectedTile.X = (relPoint.X / 32) + hScroll.Value;
                }
                if (relPoint.Y + (vScroll.Value * Constants.TILE_HEIGHT) > activeItemSurf.Size.Height)
                {
                    selectedTile.Y = (activeItemSurf.Size.Height / 32) - 1;
                }
                else
                {
                    selectedTile.Y = (relPoint.Y / 32) + vScroll.Value;
                }
            }
            RequestRedraw();
        }
Beispiel #2
0
 void TilesetViewer_Click(object sender, SdlDotNet.Widgets.MouseButtonEventArgs e)
 {
     //Point location = this.ScreenLocation;
     //Point relPoint = new Point(e.Position.X - location.X, e.Position.Y - location.Y);
     if (e.MouseEventArgs.Button == SdlDotNet.Input.MouseButton.PrimaryButton)
     {
         if (!DrawingSupport.PointInBounds(e.RelativePosition, vScroll.Bounds) && !DrawingSupport.PointInBounds(e.RelativePosition, hScroll.Bounds))
         {
             if (e.RelativePosition.X + (hScroll.Value * Constants.TILE_WIDTH) > activeTilesetSurf.Size.Width)
             {
                 selectedTile.X = (activeTilesetSurf.Size.Width / 32) - 1;
                 endTile.X      = selectedTile.X;
             }
             else
             {
                 selectedTile.X = (e.RelativePosition.X / 32) + hScroll.Value;
                 endTile.X      = selectedTile.X;
             }
             if (e.RelativePosition.Y + (vScroll.Value * Constants.TILE_HEIGHT) > activeTilesetSurf.Size.Height)
             {
                 selectedTile.Y = (activeTilesetSurf.Size.Height / 32) - 1;
                 endTile.Y      = selectedTile.Y;
             }
             else
             {
                 selectedTile.Y = (e.RelativePosition.Y / 32) + vScroll.Value;
                 endTile.Y      = selectedTile.Y;
             }
         }
         RequestRedraw();
     }
     else if (e.MouseEventArgs.Button == SdlDotNet.Input.MouseButton.SecondaryButton)
     {
         if (!DrawingSupport.PointInBounds(e.RelativePosition, vScroll.Bounds) && !DrawingSupport.PointInBounds(e.RelativePosition, hScroll.Bounds))
         {
             if (e.RelativePosition.X + (hScroll.Value * Constants.TILE_WIDTH) > activeTilesetSurf.Size.Width)
             {
                 endTile.X = (activeTilesetSurf.Size.Width / 32) - 1;
             }
             else
             {
                 endTile.X = (e.RelativePosition.X / 32) + hScroll.Value;
             }
             if (e.RelativePosition.Y + (vScroll.Value * Constants.TILE_HEIGHT) > activeTilesetSurf.Size.Height)
             {
                 endTile.Y = (activeTilesetSurf.Size.Height / 32) - 1;
             }
             else
             {
                 endTile.Y = (e.RelativePosition.Y / 32) + vScroll.Value;
             }
             if (DetermineTileNumber(endTile.X, endTile.Y) < DetermineTileNumber(selectedTile.X, selectedTile.Y))
             {
                 endTile = selectedTile;
             }
         }
         RequestRedraw();
     }
 }
Beispiel #3
0
 public override void OnMouseUp(MouseButtonEventArgs e)
 {
     base.OnMouseUp(e);
     //rwLock.EnterUpgradeableReadLock();
     try {
         foreach (IMenu menu in openMenus)
         {
             if (DrawingSupport.PointInBounds(e.ScreenPosition, menu.MenuPanel.Bounds))
             {
                 menu.MenuPanel.OnMouseUp(new MouseButtonEventArgs(e.MouseEventArgs, new Point(e.Position.X + this.X, e.Position.Y + this.Y)));
                 break;
             }
         }
     } finally {
         //rwLock.ExitUpgradeableReadLock();
     }
 }
Beispiel #4
0
 public override void OnMouseMotion(SdlDotNet.Input.MouseMotionEventArgs e)
 {
     base.OnMouseMotion(e);
     //rwLock.EnterUpgradeableReadLock();
     try {
         foreach (IMenu menu in openMenus)
         {
             if (DrawingSupport.PointInBounds(e.Position, menu.MenuPanel.Bounds))
             {
                 menu.MenuPanel.OnMouseMotion(e);
                 break;
             }
         }
     } finally {
         //rwLock.ExitUpgradeableReadLock();
     }
 }