private void UpdateItemLocation(int newSlot) { if (Slot != newSlot && ((EOInventory)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; EOInventory._getItemSizeDeltas(m_itemData.Size, out width, out height); DrawLocation = new Vector2(13 + 26 * (Slot % EOInventory.INVENTORY_ROW_LENGTH), 9 + 26 * (Slot / EOInventory.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 (!EOInventory.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 override void Initialize() { World.Instance.ActiveMapRenderer.Visible = true; if (!Game.Components.Contains(World.Instance.ActiveMapRenderer)) { Game.Components.Add(World.Instance.ActiveMapRenderer); } World.Instance.ActiveCharacterRenderer.Visible = true; DateTime usageTracking = DateTime.Now; clockTimer = new Timer(threadState => { if ((DateTime.Now - usageTracking).TotalMinutes >= 1) { World.Instance.MainPlayer.ActiveCharacter.Stats.SetUsage(World.Instance.MainPlayer.ActiveCharacter.Stats.usage + 1); usageTracking = DateTime.Now; } string fmt = string.Format("{0,2:D2}:{1,2:D2}:{2,2:D2}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); lock (clockLock) clockLabel.Text = fmt; if (statusStartTime.HasValue && (DateTime.Now - statusStartTime.Value).TotalMilliseconds > 3000) { SetStatusLabel(""); m_statusRecentlySet = false; statusStartTime = null; } }, null, 0, 1000); //the draw orders are adjusted for child items in the constructor. //calling SetParent will break this. inventory = new EOInventory(pnlInventory, m_packetAPI); stats = new EOCharacterStats(pnlStats); stats.Initialize(); for (int i = 0; i < mainBtn.Length; ++i) { int offset = i; //prevent access to modified closure warning mainBtn[i].OnMouseOver += (o, e) => { if (!m_statusRecentlySet) { SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_HUD_BUTTON_HOVER_FIRST + offset); m_statusRecentlySet = false; } }; } SessionStartTime = DateTime.Now; m_fnListener = new FunctionKeyListener(); Game.Components.Add(m_fnListener); base.Initialize(); }
public EOInventoryItem(PacketAPI api, int slot, ItemRecord itemData, InventoryItem itemInventoryInfo, EOInventory inventory) : base(null, null, inventory) { m_api = api; m_itemData = itemData; m_inventory = itemInventoryInfo; Slot = slot; UpdateItemLocation(Slot); m_itemgfx = GFXLoader.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); }
public EOInventoryItem(PacketAPI api, int slot, ItemRecord itemData, InventoryItem itemInventoryInfo, EOInventory inventory) : base(null, null, inventory) { m_api = api; m_itemData = itemData; m_inventory = itemInventoryInfo; Slot = slot; UpdateItemLocation(Slot); m_itemgfx = GFXLoader.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); }
public override void Initialize() { World.Instance.ActiveMapRenderer.Visible = true; if (!Game.Components.Contains(World.Instance.ActiveMapRenderer)) Game.Components.Add(World.Instance.ActiveMapRenderer); World.Instance.ActiveCharacterRenderer.Visible = true; DateTime usageTracking = DateTime.Now; clockTimer = new Timer(threadState => { if ((DateTime.Now - usageTracking).TotalMinutes >= 1) { World.Instance.MainPlayer.ActiveCharacter.Stats.SetUsage(World.Instance.MainPlayer.ActiveCharacter.Stats.usage + 1); usageTracking = DateTime.Now; } string fmt = string.Format("{0,2:D2}:{1,2:D2}:{2,2:D2}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); lock(clockLock) clockLabel.Text = fmt; if (statusStartTime.HasValue && (DateTime.Now - statusStartTime.Value).TotalMilliseconds > 3000) { SetStatusLabel(""); m_statusRecentlySet = false; statusStartTime = null; } }, null, 0, 1000); //the draw orders are adjusted for child items in the constructor. //calling SetParent will break this. inventory = new EOInventory(pnlInventory, m_packetAPI); stats = new EOCharacterStats(pnlStats); stats.Initialize(); for (int i = 0; i < mainBtn.Length; ++i) { int offset = i; //prevent access to modified closure warning mainBtn[i].OnMouseOver += (o, e) => { if (!m_statusRecentlySet) { SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_HUD_BUTTON_HOVER_FIRST + offset); m_statusRecentlySet = false; } }; } SessionStartTime = DateTime.Now; m_fnListener = new FunctionKeyListener(); Game.Components.Add(m_fnListener); base.Initialize(); }