public void Update() { if (Globals.Bank[mMySlot].ItemId != mCurrentItemId) { mCurrentItemId = Globals.Bank[mMySlot].ItemId; var item = ItemBase.Get(Globals.Bank[mMySlot].ItemId); if (item != null) { var itemTex = Globals.ContentManager.GetTexture(GameContentManager.TextureType.Item, item.Icon); if (itemTex != null) { Pnl.Texture = itemTex; Pnl.RenderColor = item.Color; } else { if (Pnl.Texture != null) { Pnl.Texture = null; } } } else { if (Pnl.Texture != null) { Pnl.Texture = null; } } } if (!IsDragging) { if (mMouseOver) { if (!Globals.InputManager.MouseButtonDown(GameInput.MouseButtons.Left)) { mCanDrag = true; mMouseX = -1; mMouseY = -1; if (Globals.System.GetTimeMs() < mClickTime) { //Globals.Me.TryUseItem(_mySlot); mClickTime = 0; } } else { if (mCanDrag && Draggable.Active == null) { if (mMouseX == -1 || mMouseY == -1) { mMouseX = InputHandler.MousePosition.X - Pnl.LocalPosToCanvas(new Point(0, 0)).X; mMouseY = InputHandler.MousePosition.Y - Pnl.LocalPosToCanvas(new Point(0, 0)).Y; } else { var xdiff = mMouseX - (InputHandler.MousePosition.X - Pnl.LocalPosToCanvas(new Point(0, 0)).X); var ydiff = mMouseY - (InputHandler.MousePosition.Y - Pnl.LocalPosToCanvas(new Point(0, 0)).Y); if (Math.Sqrt(Math.Pow(xdiff, 2) + Math.Pow(ydiff, 2)) > 5) { IsDragging = true; mDragIcon = new Draggable( Pnl.LocalPosToCanvas(new Point(0, 0)).X + mMouseX, Pnl.LocalPosToCanvas(new Point(0, 0)).X + mMouseY, Pnl.Texture ); } } } } } } else { if (mDragIcon.Update()) { //Drug the item and now we stopped IsDragging = false; var dragRect = new FloatRect( mDragIcon.X - sItemXPadding / 2, mDragIcon.Y - sItemYPadding / 2, sItemXPadding / 2 + 32, sItemYPadding / 2 + 32 ); float bestIntersect = 0; var bestIntersectIndex = -1; //So we picked up an item and then dropped it. Lets see where we dropped it to. //Check inventory first. if (mBankWindow.RenderBounds().IntersectsWith(dragRect)) { for (var i = 0; i < Globals.BankSlots; i++) { if (mBankWindow.Items[i].RenderBounds().IntersectsWith(dragRect)) { if (FloatRect.Intersect(mBankWindow.Items[i].RenderBounds(), dragRect).Width * FloatRect.Intersect(mBankWindow.Items[i].RenderBounds(), dragRect).Height > bestIntersect) { bestIntersect = FloatRect.Intersect(mBankWindow.Items[i].RenderBounds(), dragRect).Width * FloatRect.Intersect(mBankWindow.Items[i].RenderBounds(), dragRect).Height; bestIntersectIndex = i; } } } if (bestIntersectIndex > -1) { if (mMySlot != bestIntersectIndex) { var allowed = true; //Permission Check if (Globals.GuildBank) { var rank = Globals.Me.GuildRank; if (string.IsNullOrWhiteSpace(Globals.Me.Guild) || (!rank.Permissions.BankDeposit && Globals.Me.Rank != 0)) { ChatboxMsg.AddMessage(new ChatboxMsg(Strings.Guilds.NotAllowedSwap.ToString(Globals.Me.Guild), CustomColors.Alerts.Error, ChatMessageType.Bank)); allowed = false; } } if (allowed) { PacketSender.SendMoveBankItems(bestIntersectIndex, mMySlot); } //Globals.Me.SwapItems(bestIntersectIndex, _mySlot); } } } mDragIcon.Dispose(); } } }
public void Update() { if (Globals.Bag[mMySlot].ItemId != mCurrentItemId) { mCurrentItemId = Globals.Bag[mMySlot].ItemId; var item = ItemBase.Get(Globals.Bag[mMySlot].ItemId); if (item != null) { var itemTex = Globals.ContentManager.GetTexture(GameContentManager.TextureType.Item, item.Icon); if (itemTex != null) { Pnl.Texture = itemTex; } else { if (Pnl.Texture != null) { Pnl.Texture = null; } } } else { if (Pnl.Texture != null) { Pnl.Texture = null; } } } if (!IsDragging) { if (mMouseOver) { if (!Globals.InputManager.MouseButtonDown(GameInput.MouseButtons.Left)) { mCanDrag = true; mMouseX = -1; mMouseY = -1; if (Globals.System.GetTimeMs() < mClickTime) { //Globals.Me.TryUseItem(_mySlot); mClickTime = 0; } } else { if (mCanDrag && Draggable.Active == null) { if (mMouseX == -1 || mMouseY == -1) { mMouseX = InputHandler.MousePosition.X - Pnl.LocalPosToCanvas(new Point(0, 0)).X; mMouseY = InputHandler.MousePosition.Y - Pnl.LocalPosToCanvas(new Point(0, 0)).Y; } else { var xdiff = mMouseX - (InputHandler.MousePosition.X - Pnl.LocalPosToCanvas(new Point(0, 0)).X); var ydiff = mMouseY - (InputHandler.MousePosition.Y - Pnl.LocalPosToCanvas(new Point(0, 0)).Y); if (Math.Sqrt(Math.Pow(xdiff, 2) + Math.Pow(ydiff, 2)) > 5) { IsDragging = true; mDragIcon = new Draggable( Pnl.LocalPosToCanvas(new Point(0, 0)).X + mMouseX, Pnl.LocalPosToCanvas(new Point(0, 0)).X + mMouseY, Pnl.Texture ); } } } } } } else { if (mDragIcon.Update()) { //Drug the item and now we stopped IsDragging = false; var dragRect = new FloatRect( mDragIcon.X - sItemXPadding / 2, mDragIcon.Y - sItemYPadding / 2, sItemXPadding / 2 + 32, sItemYPadding / 2 + 32 ); float bestIntersect = 0; var bestIntersectIndex = -1; //So we picked up an item and then dropped it. Lets see where we dropped it to. //Check inventory first. if (mBagWindow.RenderBounds().IntersectsWith(dragRect)) { for (var i = 0; i < Globals.Bag.Length; i++) { if (mBagWindow.Items[i].RenderBounds().IntersectsWith(dragRect)) { if (FloatRect.Intersect(mBagWindow.Items[i].RenderBounds(), dragRect).Width * FloatRect.Intersect(mBagWindow.Items[i].RenderBounds(), dragRect).Height > bestIntersect) { bestIntersect = FloatRect.Intersect(mBagWindow.Items[i].RenderBounds(), dragRect).Width * FloatRect.Intersect(mBagWindow.Items[i].RenderBounds(), dragRect).Height; bestIntersectIndex = i; } } } if (bestIntersectIndex > -1) { if (mMySlot != bestIntersectIndex) { //Try to swap.... PacketSender.SendMoveBagItems(bestIntersectIndex, mMySlot); } } } mDragIcon.Dispose(); } } }
public void Update() { var equipped = false; for (var i = 0; i < Options.EquipmentSlots.Count; i++) { if (Globals.Me.MyEquipment[i] == mMySlot) { equipped = true; break; } } var item = ItemBase.Get(Globals.Me.Inventory[mMySlot].ItemId); if (Globals.Me.Inventory[mMySlot].ItemId != mCurrentItemId || Globals.Me.Inventory[mMySlot].Quantity != mCurrentAmt || equipped != mIsEquipped || item == null && mTexLoaded != "" || item != null && mTexLoaded != item.Icon || mIconCd != Globals.Me.ItemOnCd(mMySlot) || Globals.Me.ItemOnCd(mMySlot)) { mCurrentItemId = Globals.Me.Inventory[mMySlot].ItemId; mCurrentAmt = Globals.Me.Inventory[mMySlot].Quantity; mIsEquipped = equipped; EquipPanel.IsHidden = !mIsEquipped; EquipLabel.IsHidden = !mIsEquipped; mCooldownLabel.IsHidden = true; if (item != null) { var itemTex = Globals.ContentManager.GetTexture(GameContentManager.TextureType.Item, item.Icon); if (itemTex != null) { Pnl.Texture = itemTex; if (Globals.Me.ItemOnCd(mMySlot)) { Pnl.RenderColor = new Color(100, item.Color.R, item.Color.G, item.Color.B); } else { Pnl.RenderColor = item.Color; } } else { if (Pnl.Texture != null) { Pnl.Texture = null; } } mTexLoaded = item.Icon; mIconCd = Globals.Me.ItemOnCd(mMySlot); if (mIconCd) { mCooldownLabel.IsHidden = false; var secondsRemaining = (float)Globals.Me.ItemCdRemainder(mMySlot) / 1000f; if (secondsRemaining > 10f) { mCooldownLabel.Text = Strings.Inventory.cooldown.ToString(secondsRemaining.ToString("N0")); } else { mCooldownLabel.Text = Strings.Inventory.cooldown.ToString( secondsRemaining.ToString("N1").Replace(".", Strings.Numbers.dec) ); } } } else { if (Pnl.Texture != null) { Pnl.Texture = null; } mTexLoaded = ""; } if (mDescWindow != null) { mDescWindow.Dispose(); mDescWindow = null; pnl_HoverEnter(null, null); } } if (!IsDragging) { if (mMouseOver) { if (!Globals.InputManager.MouseButtonDown(GameInput.MouseButtons.Left)) { mCanDrag = true; mMouseX = -1; mMouseY = -1; if (Globals.System.GetTimeMs() < mClickTime) { Globals.Me.TryUseItem(mMySlot); mClickTime = 0; } } else { if (mCanDrag && Draggable.Active == null) { if (mMouseX == -1 || mMouseY == -1) { mMouseX = InputHandler.MousePosition.X - Pnl.LocalPosToCanvas(new Point(0, 0)).X; mMouseY = InputHandler.MousePosition.Y - Pnl.LocalPosToCanvas(new Point(0, 0)).Y; } else { var xdiff = mMouseX - (InputHandler.MousePosition.X - Pnl.LocalPosToCanvas(new Point(0, 0)).X); var ydiff = mMouseY - (InputHandler.MousePosition.Y - Pnl.LocalPosToCanvas(new Point(0, 0)).Y); if (Math.Sqrt(Math.Pow(xdiff, 2) + Math.Pow(ydiff, 2)) > 5) { IsDragging = true; mDragIcon = new Draggable( Pnl.LocalPosToCanvas(new Point(0, 0)).X + mMouseX, Pnl.LocalPosToCanvas(new Point(0, 0)).X + mMouseY, Pnl.Texture ); } } } } } } else { if (mDragIcon.Update()) { //Drug the item and now we stopped IsDragging = false; var dragRect = new FloatRect( mDragIcon.X - (Container.Padding.Left + Container.Padding.Right) / 2, mDragIcon.Y - (Container.Padding.Top + Container.Padding.Bottom) / 2, (Container.Padding.Left + Container.Padding.Right) / 2 + Pnl.Width, (Container.Padding.Top + Container.Padding.Bottom) / 2 + Pnl.Height ); float bestIntersect = 0; var bestIntersectIndex = -1; //So we picked up an item and then dropped it. Lets see where we dropped it to. //Check inventory first. if (mInventoryWindow.RenderBounds().IntersectsWith(dragRect)) { for (var i = 0; i < Options.MaxInvItems; i++) { if (mInventoryWindow.Items[i].RenderBounds().IntersectsWith(dragRect)) { if (FloatRect.Intersect(mInventoryWindow.Items[i].RenderBounds(), dragRect).Width * FloatRect.Intersect(mInventoryWindow.Items[i].RenderBounds(), dragRect).Height > bestIntersect) { bestIntersect = FloatRect.Intersect(mInventoryWindow.Items[i].RenderBounds(), dragRect).Width * FloatRect.Intersect(mInventoryWindow.Items[i].RenderBounds(), dragRect).Height; bestIntersectIndex = i; } } } if (bestIntersectIndex > -1) { if (mMySlot != bestIntersectIndex) { //Try to swap.... PacketSender.SendSwapInvItems(bestIntersectIndex, mMySlot); Globals.Me.SwapItems(bestIntersectIndex, mMySlot); } } } else if (Interface.GameUi.Hotbar.RenderBounds().IntersectsWith(dragRect)) { for (var i = 0; i < Options.MaxHotbar; i++) { if (Interface.GameUi.Hotbar.Items[i].RenderBounds().IntersectsWith(dragRect)) { if (FloatRect.Intersect( Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect ) .Width * FloatRect.Intersect(Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect) .Height > bestIntersect) { bestIntersect = FloatRect.Intersect(Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect) .Width * FloatRect.Intersect(Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect) .Height; bestIntersectIndex = i; } } } if (bestIntersectIndex > -1) { Globals.Me.AddToHotbar((byte)bestIntersectIndex, 0, mMySlot); } } else if (Globals.InBag) { var bagWindow = Interface.GameUi.GetBag(); if (bagWindow.RenderBounds().IntersectsWith(dragRect)) { for (var i = 0; i < Globals.Bag.Length; i++) { if (bagWindow.Items[i].RenderBounds().IntersectsWith(dragRect)) { if (FloatRect.Intersect(bagWindow.Items[i].RenderBounds(), dragRect).Width * FloatRect.Intersect(bagWindow.Items[i].RenderBounds(), dragRect).Height > bestIntersect) { bestIntersect = FloatRect.Intersect(bagWindow.Items[i].RenderBounds(), dragRect).Width * FloatRect.Intersect(bagWindow.Items[i].RenderBounds(), dragRect).Height; bestIntersectIndex = i; } } } if (bestIntersectIndex > -1) { Globals.Me.TryStoreBagItem(mMySlot, bestIntersectIndex); } } } mDragIcon.Dispose(); } } }
public void Update() { if (Globals.Me == null) { return; } //See if Label Should be changed if (mHotKey != Controls.ActiveControls.ControlMapping[Control.Hotkey1 + mYindex].Key1) { KeyLabel.SetText( Strings.Keys.keydict[ Enum.GetName( typeof(Keys), Controls.ActiveControls.ControlMapping[Control.Hotkey1 + mYindex].Key1 ) .ToLower()] ); mHotKey = Controls.ActiveControls.ControlMapping[Control.Hotkey1 + mYindex].Key1; } var slot = Globals.Me.Hotbar[mYindex]; var updateDisplay = mCurrentId != slot.ItemOrSpellId || mTexLoaded == false; //Update display if the hotbar item changes or we dont have a texture for the current item if (mCurrentId != slot.ItemOrSpellId) { mCurrentItem = null; mCurrentSpell = null; var itm = ItemBase.Get(slot.ItemOrSpellId); var spl = SpellBase.Get(slot.ItemOrSpellId); if (itm != null) { mCurrentItem = itm; } if (spl != null) { mCurrentSpell = spl; } mCurrentId = slot.ItemOrSpellId; } mSpellBookItem = null; mInventoryItem = null; mInventoryItemIndex = -1; if (mCurrentItem != null) { var itmIndex = Globals.Me.FindHotbarItem(slot); if (itmIndex > -1) { mInventoryItemIndex = itmIndex; mInventoryItem = Globals.Me.Inventory[itmIndex]; } } else if (mCurrentSpell != null) { var splIndex = Globals.Me.FindHotbarSpell(slot); if (splIndex > -1) { mSpellBookItem = Globals.Me.Spells[splIndex]; } } if (mCurrentItem != null) //When it's an item { //We don't have it, and the icon isn't faded if (mInventoryItem == null && !mIsFaded) { updateDisplay = true; } //We have it, and the equip icon doesn't match equipped status if (mInventoryItem != null && Globals.Me.IsEquipped(mInventoryItemIndex) != mIsEquipped) { updateDisplay = true; } //We have it, and it's on cd if (mInventoryItem != null && Globals.Me.ItemOnCd(mInventoryItemIndex)) { updateDisplay = true; } //We have it, and it's on cd, and the fade is incorrect if (mInventoryItem != null && Globals.Me.ItemOnCd(mInventoryItemIndex) != mIsFaded) { updateDisplay = true; } } if (mCurrentSpell != null) //When it's a spell { //We don't know it, and the icon isn't faded! if (mSpellBookItem == null && !mIsFaded) { updateDisplay = true; } //Spell on cd if (mSpellBookItem != null && Globals.Me.GetSpellCooldown(mSpellBookItem.SpellId) > Globals.System.GetTimeMs()) { updateDisplay = true; } //Spell on cd and the fade is incorrect if (mSpellBookItem != null && Globals.Me.GetSpellCooldown(mSpellBookItem.SpellId) > Globals.System.GetTimeMs() != mIsFaded) { updateDisplay = true; } } if (updateDisplay) //Item on cd and fade is incorrect { if (mCurrentItem != null) { mCooldownLabel.IsHidden = true; mContentPanel.Show(); mContentPanel.Texture = Globals.ContentManager.GetTexture( GameContentManager.TextureType.Item, mCurrentItem.Icon ); if (mInventoryItemIndex > -1) { EquipPanel.IsHidden = !Globals.Me.IsEquipped(mInventoryItemIndex); EquipLabel.IsHidden = !Globals.Me.IsEquipped(mInventoryItemIndex); mIsFaded = Globals.Me.ItemOnCd(mInventoryItemIndex); if (mIsFaded) { mCooldownLabel.IsHidden = false; var secondsRemaining = (float)Globals.Me.ItemCdRemainder(mInventoryItemIndex) / 1000f; if (secondsRemaining > 10f) { mCooldownLabel.Text = Strings.Inventory.cooldown.ToString(secondsRemaining.ToString("N0")); } else { mCooldownLabel.Text = Strings.Inventory.cooldown.ToString( secondsRemaining.ToString("N1").Replace(".", Strings.Numbers.dec) ); } } mIsEquipped = Globals.Me.IsEquipped(mInventoryItemIndex); } else { EquipPanel.IsHidden = true; EquipLabel.IsHidden = true; mIsEquipped = false; mIsFaded = true; } mTexLoaded = true; } else if (mCurrentSpell != null) { mContentPanel.Show(); mContentPanel.Texture = Globals.ContentManager.GetTexture( GameContentManager.TextureType.Spell, mCurrentSpell.Icon ); EquipPanel.IsHidden = true; EquipLabel.IsHidden = true; mCooldownLabel.IsHidden = true; if (mSpellBookItem != null) { mIsFaded = Globals.Me.GetSpellCooldown(mSpellBookItem.SpellId) > Globals.System.GetTimeMs(); if (mIsFaded) { mCooldownLabel.IsHidden = false; var secondsRemaining = (float)(Globals.Me.GetSpellCooldown(mSpellBookItem.SpellId) - Globals.System.GetTimeMs()) / 1000f; if (secondsRemaining > 10f) { mCooldownLabel.Text = Strings.Spells.cooldown.ToString(secondsRemaining.ToString("N0")); } else { mCooldownLabel.Text = Strings.Spells.cooldown.ToString( secondsRemaining.ToString("N1").Replace(".", Strings.Numbers.dec) ); } } } else { mIsFaded = true; } mTexLoaded = true; mIsEquipped = false; } else { mContentPanel.Hide(); mTexLoaded = true; mIsEquipped = false; EquipPanel.IsHidden = true; EquipLabel.IsHidden = true; mCooldownLabel.IsHidden = true; } if (mIsFaded) { if (mCurrentSpell != null) { mContentPanel.RenderColor = new Color(100, 255, 255, 255); } if (mCurrentItem != null) { mContentPanel.RenderColor = new Color(100, mCurrentItem.Color.R, mCurrentItem.Color.G, mCurrentItem.Color.B); } } else { if (mCurrentSpell != null) { mContentPanel.RenderColor = Color.White; } if (mCurrentItem != null) { mContentPanel.RenderColor = mCurrentItem.Color; } } } if (mCurrentItem != null || mCurrentSpell != null) { if (!IsDragging) { if (mMouseOver) { if (!Globals.InputManager.MouseButtonDown(GameInput.MouseButtons.Left)) { mCanDrag = true; mMouseX = -1; mMouseY = -1; if (Globals.System.GetTimeMs() < mClickTime) { Activate(); mClickTime = 0; } } else { if (mCanDrag && Draggable.Active == null) { if (mMouseX == -1 || mMouseY == -1) { mMouseX = InputHandler.MousePosition.X - Pnl.LocalPosToCanvas(new Point(0, 0)).X; mMouseY = InputHandler.MousePosition.Y - Pnl.LocalPosToCanvas(new Point(0, 0)).Y; } else { var xdiff = mMouseX - (InputHandler.MousePosition.X - Pnl.LocalPosToCanvas(new Point(0, 0)).X); var ydiff = mMouseY - (InputHandler.MousePosition.Y - Pnl.LocalPosToCanvas(new Point(0, 0)).Y); if (Math.Sqrt(Math.Pow(xdiff, 2) + Math.Pow(ydiff, 2)) > 5) { IsDragging = true; mDragIcon = new Draggable( Pnl.LocalPosToCanvas(new Point(0, 0)).X + mMouseX, Pnl.LocalPosToCanvas(new Point(0, 0)).X + mMouseY, mContentPanel.Texture ); //SOMETHING SHOULD BE RENDERED HERE, RIGHT? } } } } } } else { if (mDragIcon.Update()) { mContentPanel.IsHidden = false; //Drug the item and now we stopped IsDragging = false; var dragRect = new FloatRect( mDragIcon.X - sItemXPadding / 2, mDragIcon.Y - sItemYPadding / 2, sItemXPadding / 2 + 32, sItemYPadding / 2 + 32 ); float bestIntersect = 0; var bestIntersectIndex = -1; if (Interface.GameUi.Hotbar.RenderBounds().IntersectsWith(dragRect)) { for (var i = 0; i < Options.MaxHotbar; i++) { if (Interface.GameUi.Hotbar.Items[i].RenderBounds().IntersectsWith(dragRect)) { if (FloatRect.Intersect(Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect) .Width * FloatRect.Intersect(Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect) .Height > bestIntersect) { bestIntersect = FloatRect.Intersect( Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect ) .Width * FloatRect.Intersect( Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect ) .Height; bestIntersectIndex = i; } } } if (bestIntersectIndex > -1 && bestIntersectIndex != mYindex) { Globals.Me.HotbarSwap(mYindex, (byte)bestIntersectIndex); } } mDragIcon.Dispose(); } else { mContentPanel.IsHidden = true; } } } }
public void Update() { var spell = SpellBase.Get(Globals.Me.Spells[mYindex].SpellId); if (!IsDragging && (mTexLoaded != "" && spell == null || spell != null && mTexLoaded != spell.Icon || mCurrentSpellId != Globals.Me.Spells[mYindex].SpellId || mIconCd != Globals.Me.GetSpellCooldown(Globals.Me.Spells[mYindex].SpellId) > Globals.System.GetTimeMs() || Globals.Me.GetSpellCooldown(Globals.Me.Spells[mYindex].SpellId) > Globals.System.GetTimeMs())) { mCooldownLabel.IsHidden = true; if (spell != null) { var spellTex = Globals.ContentManager.GetTexture(GameContentManager.TextureType.Spell, spell.Icon); if (spellTex != null) { Pnl.Texture = spellTex; if (Globals.Me.GetSpellCooldown(Globals.Me.Spells[mYindex].SpellId) > Globals.System.GetTimeMs()) { Pnl.RenderColor = new Color(100, 255, 255, 255); } else { Pnl.RenderColor = new Color(255, 255, 255, 255); } } else { if (Pnl.Texture != null) { Pnl.Texture = null; } } mTexLoaded = spell.Icon; mCurrentSpellId = Globals.Me.Spells[mYindex].SpellId; mIconCd = Globals.Me.GetSpellCooldown(Globals.Me.Spells[mYindex].SpellId) > Globals.System.GetTimeMs(); if (mIconCd) { mCooldownLabel.IsHidden = false; var secondsRemaining = (float)(Globals.Me.GetSpellCooldown(Globals.Me.Spells[mYindex].SpellId) - Globals.System.GetTimeMs()) / 1000f; if (secondsRemaining > 10f) { mCooldownLabel.Text = Strings.Spells.cooldown.ToString(secondsRemaining.ToString("N0")); } else { mCooldownLabel.Text = Strings.Spells.cooldown.ToString( secondsRemaining.ToString("N1").Replace(".", Strings.Numbers.dec) ); } } } else { if (Pnl.Texture != null) { Pnl.Texture = null; } mTexLoaded = ""; } } if (!IsDragging) { if (mMouseOver) { if (!Globals.InputManager.MouseButtonDown(GameInput.MouseButtons.Left)) { mCanDrag = true; mMouseX = -1; mMouseY = -1; if (Globals.System.GetTimeMs() < mClickTime) { Globals.Me.TryUseSpell(mYindex); mClickTime = 0; } } else { if (mCanDrag && Draggable.Active == null) { if (mMouseX == -1 || mMouseY == -1) { mMouseX = InputHandler.MousePosition.X - Pnl.LocalPosToCanvas(new Point(0, 0)).X; mMouseY = InputHandler.MousePosition.Y - Pnl.LocalPosToCanvas(new Point(0, 0)).Y; } else { var xdiff = mMouseX - (InputHandler.MousePosition.X - Pnl.LocalPosToCanvas(new Point(0, 0)).X); var ydiff = mMouseY - (InputHandler.MousePosition.Y - Pnl.LocalPosToCanvas(new Point(0, 0)).Y); if (Math.Sqrt(Math.Pow(xdiff, 2) + Math.Pow(ydiff, 2)) > 5) { IsDragging = true; mDragIcon = new Draggable( Pnl.LocalPosToCanvas(new Point(0, 0)).X + mMouseX, Pnl.LocalPosToCanvas(new Point(0, 0)).X + mMouseY, Pnl.Texture ); mTexLoaded = ""; } } } } } } else { if (mDragIcon.Update()) { //Drug the item and now we stopped IsDragging = false; var dragRect = new FloatRect( mDragIcon.X - (Container.Padding.Left + Container.Padding.Right) / 2, mDragIcon.Y - (Container.Padding.Top + Container.Padding.Bottom) / 2, (Container.Padding.Left + Container.Padding.Right) / 2 + Pnl.Width, (Container.Padding.Top + Container.Padding.Bottom) / 2 + Pnl.Height ); float bestIntersect = 0; var bestIntersectIndex = -1; //So we picked up an item and then dropped it. Lets see where we dropped it to. //Check spell first. if (mSpellWindow.RenderBounds().IntersectsWith(dragRect)) { for (var i = 0; i < Options.MaxInvItems; i++) { if (i < mSpellWindow.Items.Count && mSpellWindow.Items[i].RenderBounds().IntersectsWith(dragRect)) { if (FloatRect.Intersect(mSpellWindow.Items[i].RenderBounds(), dragRect).Width * FloatRect.Intersect(mSpellWindow.Items[i].RenderBounds(), dragRect).Height > bestIntersect) { bestIntersect = FloatRect.Intersect(mSpellWindow.Items[i].RenderBounds(), dragRect).Width * FloatRect.Intersect(mSpellWindow.Items[i].RenderBounds(), dragRect).Height; bestIntersectIndex = i; } } } if (bestIntersectIndex > -1) { if (mYindex != bestIntersectIndex) { //Try to swap.... PacketSender.SendSwapSpells(bestIntersectIndex, mYindex); Globals.Me.SwapSpells(bestIntersectIndex, mYindex); } } } else if (Interface.GameUi.Hotbar.RenderBounds().IntersectsWith(dragRect)) { for (var i = 0; i < Options.MaxHotbar; i++) { if (Interface.GameUi.Hotbar.Items[i].RenderBounds().IntersectsWith(dragRect)) { if (FloatRect.Intersect( Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect ) .Width * FloatRect.Intersect(Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect) .Height > bestIntersect) { bestIntersect = FloatRect.Intersect(Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect) .Width * FloatRect.Intersect(Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect) .Height; bestIntersectIndex = i; } } } if (bestIntersectIndex > -1) { Globals.Me.AddToHotbar((byte)bestIntersectIndex, 1, mYindex); } } mDragIcon.Dispose(); } } }