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); }
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 }