Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Drawing;
  6. using Microsoft.DirectX.Direct3D;
  7. using MapleLib.WzLib.WzProperties;
  8. using Microsoft.DirectX.DirectInput;
  9. using System.Windows.Forms;
  10.  
  11. namespace WzExplorer.Mapping
  12. {
  13.     class MapLink
  14.     {
  15.         private string toolTip, linkMap;
  16.         private Bitmap linkImage;
  17.         private Texture texture;
  18.         private Point Spot = new Point(0, 0);
  19.         public Microsoft.DirectX.DirectInput.Device Mouse;
  20.         public bool canDraw = false;
  21.         private WzVectorProperty ori;
  22.         private Point _position = Point.Empty;
  23.  
  24.         public void Update()
  25.         {
  26.             //still invalid mouse pos
  27.             _position = Mapper.obj.pos;
  28.             Mapper.obj.Text = "Pos: " + _position.X + "/ " + _position.Y;  
  29.             byte[] buttons = Mouse.CurrentMouseState.GetMouseButtons();
  30.             if (0 != buttons[0])
  31.             {
  32.                 if (canDraw == true)
  33.                 {
  34.                     Mapper.obj.test.Text = linkMap;
  35.                     Mapper.obj.change = true;
  36.                 }
  37.             }
  38.             else
  39.             {
  40.             }
  41.             //checks the mouse pos agenst the bounding box
  42.             if (_position.X >= Spot.X && _position.X <= Spot.X + linkImage.Width)
  43.             {
  44.                 if (_position.Y >= Spot.Y && _position.Y <= Spot.Y + linkImage.Height)
  45.                 {
  46.                     canDraw = true;
  47.                     return;
  48.                 }
  49.             }
  50.             canDraw = false;
  51.         }
  52.  
  53.         public MapLink(Microsoft.DirectX.Direct3D.Device DxDevice, Microsoft.DirectX.DirectInput.Device mouse, string tooltip, string linkMap, Bitmap linkimg, WzVectorProperty baseOrigin, WzVectorProperty origin)
  54.         {
  55.             this.toolTip = tooltip;
  56.             this.linkMap = linkMap;
  57.             this.linkImage = linkimg;
  58.             this.texture = Texture.FromBitmap(DxDevice, linkImage, Usage.Dynamic, Pool.Default);
  59.             this.Spot = calPOS(baseOrigin,origin);
  60.             this.Mouse = mouse;
  61.             this.ori = origin;
  62.         }
  63.  
  64.         private Point calPOS(WzVectorProperty baseOrigin, WzVectorProperty imageOrigin)
  65.         {
  66.             Point fix = new Point(baseOrigin.X.ToInt() - imageOrigin.X.ToInt(), baseOrigin.Y.ToInt() - imageOrigin.Y.ToInt());
  67.             return fix;
  68.         }
  69.  
  70.         public void StaticDraw()
  71.         {
  72.             Mapper.sprite.Draw2D(texture, new Point(0, 0), 0f, new Point(Spot.X, Spot.Y), Color.White);
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement