private void UpdateItemLocation(int newSlot) { if (Slot != newSlot && ((OldEOInventory)parent).MoveItem(this, newSlot)) { Slot = newSlot; } //top-left grid slot in the inventory is 115, 339 //parent top-left is 103, 330 //grid size is 26*26 (w/o borders 23*23) int width, height; OldEOInventory._getItemSizeDeltas(m_itemData.Size, out width, out height); DrawLocation = new Vector2(13 + 26 * (Slot % OldEOInventory.INVENTORY_ROW_LENGTH), 9 + 26 * (Slot / OldEOInventory.INVENTORY_ROW_LENGTH)); _setSize(width * 26, height * 26); if (m_nameLabel != null) //fix the position of the name label too if we aren't creating the inventoryitem { m_nameLabel.DrawLocation = new Vector2(DrawArea.Width, 0); if (!OldEOInventory.GRID_AREA.Contains(m_nameLabel.DrawAreaWithOffset)) { m_nameLabel.DrawLocation = new Vector2(-m_nameLabel.DrawArea.Width, 0); //show on the right if it isn't in bounds! } m_nameLabel.ResizeBasedOnText(16, 9); } }
public OldEOInventoryItem(PacketAPI api, int slot, EIFRecord itemData, InventoryItem itemInventoryInfo, OldEOInventory inventory) : base(null, null, inventory) { m_api = api; m_itemData = itemData; m_inventory = itemInventoryInfo; Slot = slot; UpdateItemLocation(Slot); m_itemgfx = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, 2 * itemData.Graphic, true); m_highlightBG = new Texture2D(Game.GraphicsDevice, DrawArea.Width - 3, DrawArea.Height - 3); Color[] highlight = new Color[(drawArea.Width - 3) * (drawArea.Height - 3)]; for (int i = 0; i < highlight.Length; ++i) { highlight[i] = Color.FromNonPremultiplied(200, 200, 200, 60); } m_highlightBG.SetData(highlight); _initItemLabel(); m_recentClickTimer = new Timer( _state => { if (m_recentClickCount > 0) { Interlocked.Decrement(ref m_recentClickCount); } }, null, 0, 1000); }