private void UpdateItemsListInternal() { System.Collections.ArrayList dirty_items = new System.Collections.ArrayList(); for (int i = 0; i < listView_items_data_items.Count; i++) { uint id = Util.GetUInt32(((ListViewItem)listView_items_data_items[i]).SubItems[2].Text); if (Globals.gamedata.nearby_items.ContainsKey(id)) { ItemInfo item = Util.GetItem(id); item.InList = true; //update it //((ListViewItem)listView_items_data_items[i]).SubItems[0].Text = Util.GetItemName(item.ItemID); //((ListViewItem)listView_items_data_items[i]).SubItems[1].Text = item.Count.ToString(); //((ListViewItem)listView_items_data_items[i]).SubItems[2].Text = item.ID.ToString(); } else { dirty_items.Add(i); } } //need to remove all dirty items now for (int i = dirty_items.Count - 1; i >= 0; i--) { listView_items_data_items.RemoveAt((int)dirty_items[i]); } dirty_items.Clear(); foreach (ItemInfo item in Globals.gamedata.nearby_items.Values) { if (!item.InList) { item.InList = true; string mesh_info = ""; if (!item.HasMesh) { mesh_info = " [NO MESH]"; } //add it System.Windows.Forms.ListViewItem ObjListItem; ObjListItem = new ListViewItem(Util.GetItemName(item.ItemID) + mesh_info); //ItmID ObjListItem.SubItems.Add(item.Count.ToString()); //Count ObjListItem.SubItems.Add(item.ID.ToString()); //ObjID ObjListItem.ImageIndex = AddInfo.Get_Item_Image_Index(item.ItemID); listView_items_data_items.Add(ObjListItem); } } }
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 }