Ejemplo n.º 1
0
		public static void Inventory_Update(ByteBuffer buff)
		{
            uint cnt = buff.ReadUInt16();//ushort

            Globals.InventoryLock.EnterWriteLock();
            try
            {
                for (int i = 0; i < cnt; i++)
                {
                    uint change = buff.ReadUInt16();//ushort

                    InventoryInfo inv_inf = new InventoryInfo();

                    if (change == 1 || change == 2)
                    {
                        inv_inf.Load(buff, 1);
                    }
                    else
                    {
                        inv_inf.Load(buff, 0);
                    }

                    if (inv_inf.Count == 0)
                    {
                        change = 3;
                    }

                    switch (change)
                    {
                        case 1://add
                            Add_Inventory(inv_inf);
                            break;
                        case 2://modify
                            Add_Inventory(inv_inf);
                            break;
                        case 3://remove
                            Remove_Inventory(inv_inf.ID);
                            break;
                    }
                }
            }
            finally
            {
                Globals.InventoryLock.ExitWriteLock();
            }

            Globals.l2net_home.timer_inventory.Start();
		}
Ejemplo n.º 2
0
        private void listView_inventory_SelectedIndexChanged(object sender, EventArgs e)
        {
            string text = "";

            if (listView_inventory.SelectedIndices.Count > 0)
            {
                uint          id   = Util.GetUInt32(listView_inventory.Items[listView_inventory.SelectedIndices[0]].SubItems[4].Text);
                InventoryInfo item = null;

                if (Globals.InventoryLock.TryEnterReadLock(Globals.THREAD_WAIT_GUI))
                {
                    try
                    {
                        item = Util.GetInventory(id);
                    }
                    finally
                    {
                        Globals.InventoryLock.ExitReadLock();
                    }
                }

                if (item != null)
                {
                    text = (item.Enchant == 0 ? "" : "+" + item.Enchant.ToString() + " ") + Util.GetItemName(item.ItemID) + Environment.NewLine +
                           (item.isEquipped == 0x01 ? "Equipped" + Environment.NewLine : "") +
                           "Count: " + item.Count.ToString() + Environment.NewLine +
                           "Augment: " + item.AugID.ToString() + Environment.NewLine +
                           "Mana: " + item.Mana.ToString() + Environment.NewLine +
                           "Slot: " + item.Slot.ToString() + Environment.NewLine +
                           "Type 1: " + item.Type.ToString() + Environment.NewLine +
                           "Type 2: " + item.Type2.ToString() + Environment.NewLine +
                           "Type 3: " + item.Type3.ToString() + Environment.NewLine +
                           "Type 4: " + item.Type4.ToString() + Environment.NewLine +
                           "Type ID: " + item.ItemID + Environment.NewLine +
                           "Unique ID: " + item.ID;
                }
            }

            toolTip1.SetToolTip(listView_inventory, text);
        }
Ejemplo n.º 3
0
        private void UpdateInventoryListInternal()
        {
            System.Collections.ArrayList dirty_items = new System.Collections.ArrayList();
            #region Equipped Items
            if (radioButton_inv_equipped.Checked)
            {
                for (int i = 0; i < listView_inventory_items.Count; i++)
                {
                    uint id = Util.GetUInt32(((ListViewItem)listView_inventory_items[i]).SubItems[4].Text);

                    if (Globals.gamedata.inventory.ContainsKey(id))
                    {
                        //already in the list...
                        InventoryInfo inv_inf = Util.GetInventory(id);
                        if (inv_inf.isEquipped == 0x01)
                        {
                            inv_inf.InList = true;

                            //update the entry
                            if (inv_inf.Enchant == 0)
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = Util.GetItemName(inv_inf.ItemID);
                            }
                            else
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = "+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID);
                            }
                            ((ListViewItem)listView_inventory_items[i]).SubItems[1].Text = inv_inf.Count.ToString(); //Count
                            if (inv_inf.isEquipped == 0x01)                                                          //isEquipped
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = "X";
                            }
                            else
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = " ";
                            }
                            //((ListViewItem)listView_inventory_items[i]).SubItems[3].Text = inv_inf.Slot.ToString();//Slot
                        }
                        else
                        {
                            //not in the list...
                            //delete this item
                            dirty_items.Add(i);
                        }
                    }
                    else
                    {
                        //not in the list...
                        //delete this item
                        dirty_items.Add(i);
                    }
                }

                //need to remove all dirty items now
                for (int i = dirty_items.Count - 1; i >= 0; i--)
                {
                    listView_inventory_items.RemoveAt((int)dirty_items[i]);
                }
                dirty_items.Clear();

                foreach (InventoryInfo inv_inf in Globals.gamedata.inventory.Values)
                {
                    if (!inv_inf.InList && inv_inf.isEquipped == 0x01)
                    {
                        inv_inf.InList = true;

                        //add it
                        System.Windows.Forms.ListViewItem ObjListItem;

                        if (inv_inf.Enchant == 0)
                        {
                            ObjListItem = new ListViewItem(Util.GetItemName(inv_inf.ItemID));
                        }
                        else
                        {
                            ObjListItem = new ListViewItem("+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID));
                        }
                        ObjListItem.SubItems.Add(inv_inf.Count.ToString()); //Count
                        if (inv_inf.isEquipped == 0x01)                     //isEquipped
                        {
                            ObjListItem.SubItems.Add("X");
                            //Do_Equip(inv_inf);
                        }
                        else
                        {
                            ObjListItem.SubItems.Add(" ");
                        }
                        ObjListItem.SubItems.Add(inv_inf.Slot.ToString()); //Slot
                        ObjListItem.SubItems.Add(inv_inf.ID.ToString());   //ObjID
                        ObjListItem.ImageIndex = AddInfo.Get_Item_Image_Index(inv_inf.ItemID);

                        listView_inventory_items.Add(ObjListItem);
                    }
                }
            }
            #endregion

            #region Normal Items
            if (radioButton_inv_items.Checked)
            {
                for (int i = 0; i < listView_inventory_items.Count; i++)
                {
                    uint id = Util.GetUInt32(((ListViewItem)listView_inventory_items[i]).SubItems[4].Text);

                    if (Globals.gamedata.inventory.ContainsKey(id))
                    {
                        //already in the list...
                        InventoryInfo inv_inf = Util.GetInventory(id);
                        if (inv_inf.isEquipped != 0x01 && inv_inf.Type2 != 0x03)
                        {
                            inv_inf.InList = true;

                            //update the entry
                            if (inv_inf.Enchant == 0)
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = Util.GetItemName(inv_inf.ItemID);
                            }
                            else
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = "+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID);
                            }
                            ((ListViewItem)listView_inventory_items[i]).SubItems[1].Text = inv_inf.Count.ToString(); //Count
                            if (inv_inf.isEquipped == 0x01)                                                          //isEquipped
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = "X";
                            }
                            else
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = " ";
                            }
                            //((ListViewItem)listView_inventory_items[i]).SubItems[3].Text = inv_inf.Slot.ToString();//Slot
                        }
                        else
                        {
                            //not in the list...
                            //delete this item
                            dirty_items.Add(i);
                        }
                    }
                    else
                    {
                        //not in the list...
                        //delete this item
                        dirty_items.Add(i);
                    }
                }

                //need to remove all dirty items now
                for (int i = dirty_items.Count - 1; i >= 0; i--)
                {
                    listView_inventory_items.RemoveAt((int)dirty_items[i]);
                }
                dirty_items.Clear();

                foreach (InventoryInfo inv_inf in Globals.gamedata.inventory.Values)
                {
                    if (!inv_inf.InList && inv_inf.isEquipped != 0x01 && inv_inf.Type2 != 0x03)
                    {
                        inv_inf.InList = true;

                        //add it
                        System.Windows.Forms.ListViewItem ObjListItem;

                        if (inv_inf.Enchant == 0)
                        {
                            ObjListItem = new ListViewItem(Util.GetItemName(inv_inf.ItemID));
                        }
                        else
                        {
                            ObjListItem = new ListViewItem("+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID));
                        }
                        ObjListItem.SubItems.Add(inv_inf.Count.ToString()); //Count
                        if (inv_inf.isEquipped == 0x01)                     //isEquipped
                        {
                            ObjListItem.SubItems.Add("X");
                            //Do_Equip(inv_inf);
                        }
                        else
                        {
                            ObjListItem.SubItems.Add(" ");
                        }
                        ObjListItem.SubItems.Add(inv_inf.Slot.ToString()); //Slot
                        ObjListItem.SubItems.Add(inv_inf.ID.ToString());   //ObjID
                        ObjListItem.ImageIndex = AddInfo.Get_Item_Image_Index(inv_inf.ItemID);

                        listView_inventory_items.Add(ObjListItem);
                    }
                }
            }
            #endregion

            #region Quest Items
            if (radioButton_inv_quest.Checked)
            {
                for (int i = 0; i < listView_inventory_items.Count; i++)
                {
                    uint id = Util.GetUInt32(((ListViewItem)listView_inventory_items[i]).SubItems[4].Text);

                    if (Globals.gamedata.inventory.ContainsKey(id))
                    {
                        //already in the list...
                        InventoryInfo inv_inf = Util.GetInventory(id);
                        if (inv_inf.Type2 == 0x03)
                        {
                            inv_inf.InList = true;

                            //update the entry
                            if (inv_inf.Enchant == 0)
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = Util.GetItemName(inv_inf.ItemID);
                            }
                            else
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = "+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID);
                            }
                            ((ListViewItem)listView_inventory_items[i]).SubItems[1].Text = inv_inf.Count.ToString(); //Count
                            if (inv_inf.isEquipped == 0x01)                                                          //isEquipped
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = "X";
                            }
                            else
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = " ";
                            }
                            //((ListViewItem)listView_inventory_items[i]).SubItems[3].Text = inv_inf.Slot.ToString();//Slot
                        }
                        else
                        {
                            //not in the list...
                            //delete this item
                            dirty_items.Add(i);
                        }
                    }
                    else
                    {
                        //not in the list...
                        //delete this item
                        dirty_items.Add(i);
                    }
                }

                //need to remove all dirty items now
                for (int i = dirty_items.Count - 1; i >= 0; i--)
                {
                    listView_inventory_items.RemoveAt((int)dirty_items[i]);
                }
                dirty_items.Clear();

                foreach (InventoryInfo inv_inf in Globals.gamedata.inventory.Values)
                {
                    if (!inv_inf.InList && inv_inf.Type2 == 0x03)
                    {
                        inv_inf.InList = true;

                        //add it
                        System.Windows.Forms.ListViewItem ObjListItem;

                        if (inv_inf.Enchant == 0)
                        {
                            ObjListItem = new ListViewItem(Util.GetItemName(inv_inf.ItemID));
                        }
                        else
                        {
                            ObjListItem = new ListViewItem("+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID));
                        }
                        ObjListItem.SubItems.Add(inv_inf.Count.ToString()); //Count
                        if (inv_inf.isEquipped == 0x01)                     //isEquipped
                        {
                            ObjListItem.SubItems.Add("X");
                            //Do_Equip(inv_inf);
                        }
                        else
                        {
                            ObjListItem.SubItems.Add(" ");
                        }
                        ObjListItem.SubItems.Add(inv_inf.Slot.ToString()); //Slot
                        ObjListItem.SubItems.Add(inv_inf.ID.ToString());   //ObjID
                        ObjListItem.ImageIndex = AddInfo.Get_Item_Image_Index(inv_inf.ItemID);

                        listView_inventory_items.Add(ObjListItem);
                    }
                }
            }
            #endregion
        }
Ejemplo n.º 4
0
        public static void ExQuestItemList(ByteBuffer buffe)
        {
            uint h2 = buffe.ReadUInt16();//ushort


            //No need to clear stuff here, as Itemlist is always run first and fixes all that.
            Globals.InventoryLock.EnterWriteLock();
            try
            {

                for (uint i = 0; i < h2; i++)
                {
                    InventoryInfo inv_info = new InventoryInfo();
                    inv_info.Load(buffe,0);
                    AddInfo.Add_Inventory(inv_info);
                }
            }
            finally
            {
                Globals.InventoryLock.ExitWriteLock();
            }

            //Globals.l2net_home.timer_inventory.Start();
        }
Ejemplo n.º 5
0
        public static void ItemList(ByteBuffer buffe)
        {
            uint h1 = buffe.ReadUInt16();//1 - open the inventory window up//ushort
            uint h2 = buffe.ReadUInt16();//ushort

            //offset = 5;

            //flag all inventory as old
            Globals.InventoryLock.EnterReadLock();
            try
            {
                foreach (InventoryInfo inv_inf in Globals.gamedata.inventory.Values)
                {
                    inv_inf.InNewList = false;
                }
            }
            finally
            {
                Globals.InventoryLock.ExitReadLock();
            }

            Globals.InventoryLock.EnterWriteLock();
            try
            {
                Globals.gamedata.inventory.Clear();
                Globals.l2net_home.Clear_Equip();

                for (uint i = 0; i < h2; i++)
                {
                    InventoryInfo inv_info = new InventoryInfo();
                    inv_info.Load(buffe,0);
                    //inv_info.InNewList = true;
                    AddInfo.Add_Inventory(inv_info);
                }
            }
            finally
            {
                Globals.InventoryLock.ExitWriteLock();
            }

            Globals.l2net_home.timer_inventory.Start();
        }
Ejemplo n.º 6
0
		public static void Add_Inventory(InventoryInfo inv_inf)
		{
            if (Globals.gamedata.inventory.ContainsKey(inv_inf.ID))
            {
                if (((InventoryInfo)Globals.gamedata.inventory[inv_inf.ID]).isEquipped == 1 && inv_inf.isEquipped != 1)
                {
                    //was equipped... not now
                    Globals.l2net_home.Clear_Equip(inv_inf.Slot);
                }
                else if (((InventoryInfo)Globals.gamedata.inventory[inv_inf.ID]).isEquipped != 1 && inv_inf.isEquipped == 1)
                {
                    //was not equipped... is now
                    Globals.l2net_home.Do_Equip(inv_inf);
                }

                //already in the array
                Globals.gamedata.inventory[inv_inf.ID] = inv_inf;
            }
            else
            {
                Globals.gamedata.inventory.Add(inv_inf.ID, inv_inf);

                if (inv_inf.isEquipped == 1)
                {
                    Globals.l2net_home.Do_Equip(inv_inf);
                }
            }
		}
Ejemplo n.º 7
0
        public void Do_Equip(InventoryInfo inv_inf)
        {
            if (this.panel_inven_lear.InvokeRequired)
            {
                Do_Equip_Callback d = new Do_Equip_Callback(Do_Equip);
                panel_inven_lear.Invoke(d, new object[] { inv_inf });
                return;
            }

            string name = Util.GetItemName(inv_inf.ItemID);
            string description = Util.GetItemDescription(inv_inf.ItemID);
            string path = Util.GetItemImagePath(inv_inf.ItemID);
            bool bmp = System.IO.File.Exists(path);

    		switch(inv_inf.Slot)
			{
                case InventorySlots.Shirt:
                    toolTip1.SetToolTip(panel_inven_shirt, "+" + inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
                    if (panel_inven_shirt.BackgroundImage != null)
                    {
                        panel_inven_shirt.BackgroundImage.Dispose();
                        panel_inven_shirt.BackgroundImage = null;
                    }
                    if (bmp)
                        panel_inven_shirt.BackgroundImage = new System.Drawing.Bitmap(path);
                    break;
                case InventorySlots.Ear:
					if(panel_inven_lear.BackgroundImage == null)
					{
						//load to lear
						toolTip1.SetToolTip(panel_inven_lear,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
						if(panel_inven_lear.BackgroundImage != null)
						{
							panel_inven_lear.BackgroundImage.Dispose();
							panel_inven_lear.BackgroundImage = null;
						}
						if(bmp)
                            panel_inven_lear.BackgroundImage = new System.Drawing.Bitmap(path);
					}
					else
					{
						//load to rear
						toolTip1.SetToolTip(panel_inven_rear,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
						if(panel_inven_rear.BackgroundImage != null)
						{
							panel_inven_rear.BackgroundImage.Dispose();
							panel_inven_rear.BackgroundImage = null;
						}
						if(bmp)
                            panel_inven_rear.BackgroundImage = new System.Drawing.Bitmap(path);
					}
					break;
                case InventorySlots.Neck:
					toolTip1.SetToolTip(panel_inven_neck,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
					if(panel_inven_neck.BackgroundImage != null)
					{
						panel_inven_neck.BackgroundImage.Dispose();
						panel_inven_neck.BackgroundImage = null;
					}
					if(bmp)
                        panel_inven_neck.BackgroundImage = new System.Drawing.Bitmap(path);
					break;
                case InventorySlots.Finger:
					if(panel_inven_lfinger.BackgroundImage == null)
					{
						//load to lear
						toolTip1.SetToolTip(panel_inven_lfinger,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
						if(panel_inven_lfinger.BackgroundImage != null)
						{
							panel_inven_lfinger.BackgroundImage.Dispose();
							panel_inven_lfinger.BackgroundImage = null;
						}
						if(bmp)
                            panel_inven_lfinger.BackgroundImage = new System.Drawing.Bitmap(path);
					}
					else
					{
						//load to rear
						toolTip1.SetToolTip(panel_inven_rfinger,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
						if(panel_inven_rfinger.BackgroundImage != null)
						{
							panel_inven_rfinger.BackgroundImage.Dispose();
							panel_inven_rfinger.BackgroundImage = null;
						}
						if(bmp)
                            panel_inven_rfinger.BackgroundImage = new System.Drawing.Bitmap(path);
					}
					break;
                case InventorySlots.Head:
					toolTip1.SetToolTip(panel_inven_head,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
					if(panel_inven_head.BackgroundImage != null)
					{
						panel_inven_head.BackgroundImage.Dispose();
						panel_inven_head.BackgroundImage = null;
					}
					if(bmp)
                        panel_inven_head.BackgroundImage = new System.Drawing.Bitmap(path);
					break;
                case InventorySlots.RHand:
					toolTip1.SetToolTip(panel_inven_rhand,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
					if(panel_inven_rhand.BackgroundImage != null)
					{
						panel_inven_rhand.BackgroundImage.Dispose();
						panel_inven_rhand.BackgroundImage = null;
					}
					if(bmp)
                        panel_inven_rhand.BackgroundImage = new System.Drawing.Bitmap(path);
					break;
                case InventorySlots.LHand:
					toolTip1.SetToolTip(panel_inven_lhand,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
					if(panel_inven_lhand.BackgroundImage != null)
					{
						panel_inven_lhand.BackgroundImage.Dispose();
						panel_inven_lhand.BackgroundImage = null;
					}
					if(bmp)
                        panel_inven_lhand.BackgroundImage = new System.Drawing.Bitmap(path);
					break;
                case InventorySlots.Gloves:
					toolTip1.SetToolTip(panel_inven_gloves,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
					if(panel_inven_gloves.BackgroundImage != null)
					{
						panel_inven_gloves.BackgroundImage.Dispose();
						panel_inven_gloves.BackgroundImage = null;
					}
					if(bmp)
                        panel_inven_gloves.BackgroundImage = new System.Drawing.Bitmap(path);
					break;
                case InventorySlots.Chest:
					toolTip1.SetToolTip(panel_inven_top,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
					if(panel_inven_top.BackgroundImage != null)
					{
						panel_inven_top.BackgroundImage.Dispose();
						panel_inven_top.BackgroundImage = null;
					}
					if(bmp)
                        panel_inven_top.BackgroundImage = new System.Drawing.Bitmap(path);
					break;
                case InventorySlots.Pants:
					toolTip1.SetToolTip(panel_inven_pants,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
					if(panel_inven_pants.BackgroundImage != null)
					{
						panel_inven_pants.BackgroundImage.Dispose();
						panel_inven_pants.BackgroundImage = null;
					}
					if(bmp)
                        panel_inven_pants.BackgroundImage = new System.Drawing.Bitmap(path);
					break;
                case InventorySlots.Feet:
					toolTip1.SetToolTip(panel_inven_boots,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
					if(panel_inven_boots.BackgroundImage != null)
					{
						panel_inven_boots.BackgroundImage.Dispose();
						panel_inven_boots.BackgroundImage = null;
					}
					if(bmp)
                        panel_inven_boots.BackgroundImage = new System.Drawing.Bitmap(path);
					break;
                case InventorySlots.Dunno:
					break;
                case InventorySlots.LRHand:
					toolTip1.SetToolTip(panel_inven_rhand,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
					if(panel_inven_rhand.BackgroundImage != null)
					{
						panel_inven_rhand.BackgroundImage.Dispose();
						panel_inven_rhand.BackgroundImage = null;
					}
					if(bmp)
                        panel_inven_rhand.BackgroundImage = new System.Drawing.Bitmap(path);
					break;
                case InventorySlots.FullBody:
					//just use the top image for now
					toolTip1.SetToolTip(panel_inven_top,"+"+inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
					if(panel_inven_top.BackgroundImage != null)
					{
						panel_inven_top.BackgroundImage.Dispose();
						panel_inven_top.BackgroundImage = null;
					}
					if(bmp)
                        panel_inven_top.BackgroundImage = new System.Drawing.Bitmap(path);
					break;
                case InventorySlots.Accessory:
                    toolTip1.SetToolTip(panel_inven_acc, "+" + inv_inf.Enchant.ToString() + " " + name + Environment.NewLine + description);
                    if (panel_inven_acc.BackgroundImage != null)
                    {
                        panel_inven_acc.BackgroundImage.Dispose();
                        panel_inven_acc.BackgroundImage = null;
                    }
                    if (bmp)
                        panel_inven_acc.BackgroundImage = new System.Drawing.Bitmap(path);
                    break;
            }
		}