private void btnSave_Click(object sender, EventArgs e) { List<CompleteItemInfo> itemsToBeWritten = new List<CompleteItemInfo>(); foreach (CompleteItemInfo item in clbInventories.Items) { itemsToBeWritten.Add(item); } CompleteItemInfo itemSets; foreach (ItemSetsInfo item in clbItemSets.CheckedItems) { foreach (var itemSet in item.ItemSet) { itemSets = new CompleteItemInfo(); itemSets.Item = itemSet.Item2; itemSets.PaintAttributeLookup = itemSet.Item1; itemSets.CompleteAttributes.Add(_invRetriever.InventorySolver.GetAttribute(6), new CSOEconItemAttribute() { def_index = 6, value_bytes = BitConverter.GetBytes((float)itemSet.Item1.CodedValue) }); itemSets.Rarity = _invRetriever.InventorySolver.GetRarity(itemSet.Item1.Rarity); if (chkStatTrakSets.Checked) { itemSets.CompleteAttributes.Add(_invRetriever.InventorySolver.GetAttribute(80), new CSOEconItemAttribute() { def_index = 80, value_bytes = new byte[4] { 0x00, 0x00, 0x00, 0x00 } }); itemSets.Quality = _invRetriever.InventorySolver.GetQuality("strange"); } else { itemSets.Quality = _invRetriever.InventorySolver.GetQuality("tournament"); } itemsToBeWritten.Add(itemSets); } } foreach (ListViewItem item in lvRecognizedOfficialItems.Items) { if (item.Checked) { itemSets = new CompleteItemInfo(); itemSets.Item = _invRetriever.InventorySolver.GetItem(item.Text); itemSets.PaintAttributeLookup = _invRetriever.InventorySolver.GetPaint(item.SubItems[1].Text); itemSets.CompleteAttributes.Add(_invRetriever.InventorySolver.GetAttribute(6), new CSOEconItemAttribute() { def_index = 6, value_bytes = BitConverter.GetBytes(Convert.ToSingle(itemSets.PaintAttributeLookup.CodedValue)) }); itemSets.Rarity = _invRetriever.InventorySolver.GetRarity(itemSets.PaintAttributeLookup.Rarity); if (chkStatTrakOfficial.Checked) { if (itemSets.Item.CodedName.Contains("knife") == false && itemSets.Item.CodedName.Contains("bayonet") == false) { itemSets.CompleteAttributes.Add(_invRetriever.InventorySolver.GetAttribute(80), new CSOEconItemAttribute() { def_index = 80, value_bytes = new byte[4] { 0x00, 0x00, 0x00, 0x00 } }); itemSets.Quality = _invRetriever.InventorySolver.GetQuality("strange"); } else { itemSets.CompleteAttributes.Add(_invRetriever.InventorySolver.GetAttribute(80), new CSOEconItemAttribute() { def_index = 80, value_bytes = new byte[4] { 0x00, 0x00, 0x00, 0x00 } }); itemSets.Quality = _invRetriever.InventorySolver.GetQuality("unusual"); } } else { itemSets.Quality = _invRetriever.InventorySolver.GetQuality("tournament"); } itemsToBeWritten.Add(itemSets); } } _inventoryFileLoader.Manager.WriteItems(itemsToBeWritten); btnSave.Enabled = false; btnReloadInv.Enabled = true; }
private void SaveCheckBoxListItemState() { savedSelected = new CompleteItemInfo(); Dictionary<AttributeInfo, CSOEconItemAttribute> attibuteInfoWithCso = new Dictionary<AttributeInfo, CSOEconItemAttribute>(); AttributeInfo attrInfo = new AttributeInfo(); CSOEconItemAttribute csoAttr = new CSOEconItemAttribute(); int stickerCount = 0; foreach (var item in tlpInventoryAttr.Controls) { if (item is ComboBox) { if (((ComboBox)item).Name.Contains("cmbReadItemAttr")) { attrInfo = (AttributeInfo)((ComboBox)item).SelectedItem; csoAttr = new CSOEconItemAttribute(); } if (((ComboBox)item).Name.Contains("cmbSelectedItemAttr")) { csoAttr.def_index = (uint)attrInfo.CodedValue; // paint kits if (attrInfo.CodedValue == 6) { if (((ComboBox)item).SelectedItem != null) { savedSelected.PaintAttributeLookup = (PaintInfo)((ComboBox)item).SelectedItem; csoAttr.value_bytes = BitConverter.GetBytes(Convert.ToSingle(savedSelected.PaintAttributeLookup.CodedValue)); } } // sticker else if (attrInfo.CodedName.Contains("sticker slot ")) { if (((ComboBox)item).SelectedItem != null) { savedSelected.StickerAttributeLookup.Add((StickerInfo)((ComboBox)item).SelectedItem); csoAttr.value_bytes = BitConverter.GetBytes(savedSelected.StickerAttributeLookup[stickerCount].CodedValue); stickerCount++; } } // music else if (attrInfo.CodedValue == 166) { if (((ComboBox)item).SelectedItem != null) { savedSelected.MusicAttributeLookup = (MusicInfo)((ComboBox)item).SelectedItem; csoAttr.value_bytes = BitConverter.GetBytes(savedSelected.MusicAttributeLookup.CodedValue); } } } }// wear else if (item is TrackBar) { if (string.IsNullOrEmpty(savedSelected.PaintAttributeLookup.Name) == false) { csoAttr.def_index = Convert.ToUInt32(attrInfo.CodedValue); float wearLevel = Convert.ToSingle((((TrackBar)item).Value / 100f)); csoAttr.value_bytes = BitConverter.GetBytes(wearLevel); } } else if (item is TextBox) { if (((TextBox)item).Name.Contains("tbAttrValue")) { csoAttr.def_index = Convert.ToUInt32(attrInfo.CodedValue); if (attrInfo.IsInteger) { csoAttr.value_bytes = BitConverter.GetBytes(int.Parse(((TextBox)item).Text)); } else if (attrInfo.IsString) { csoAttr.value = Convert.ToUInt32(int.Parse(((TextBox)item).Text)); } else { csoAttr.value_bytes = BitConverter.GetBytes(float.Parse(((TextBox)item).Text)); } } } else { continue; } if (attrInfo.CodedValue > 0 && csoAttr.def_index > 0) { savedSelected.CompleteAttributes.Add(attrInfo, csoAttr); } } foreach (var item in tlpInventoryDesc.Controls) { if (item is ComboBox) { if (((ComboBox)item).Name.Contains("cmbSelectedItemType")) { savedSelected.Item = (ItemInfo)((ComboBox)item).SelectedItem; } else if (((ComboBox)item).Name.Contains("cmbSelectedItemQuality")) { savedSelected.Quality = (QualityInfo)((ComboBox)item).SelectedItem; } else if (((ComboBox)item).Name.Contains("cmbSelectedItemRarity")) { savedSelected.Rarity = (RarityInfo)((ComboBox)item).SelectedItem; } } else if (item is TextBox) { foreach (var attr in savedSelected.CompleteAttributes) { // it has name tag if (attr.Key.CodedValue == 111) { if (((TextBox)item).Name.Contains("tbAttrNameTag")) { savedSelected.CustomName = ((TextBox)item).Text; } } } } savedSelected.IsChanged = true; } if (clbInventories.SelectedIndex != currentSelectedItemIdx) { if (currentSelectedItemIdx != -1) { oldSelectedItemIdx = currentSelectedItemIdx; currentSelectedItemIdx = clbInventories.SelectedIndex; } if (savedSelected != null) { if (savedSelected.Item.CodedValue > 0) { if (oldSelectedItemIdx < clbInventories.Items.Count) { clbInventories.SelectedIndexChanged -= clbInventories_SelectedIndexChanged; clbInventories.Items[oldSelectedItemIdx] = savedSelected; clbInventories.SelectedIndexChanged += clbInventories_SelectedIndexChanged; } } } } else { if (savedSelected != null) { if (savedSelected.Item.CodedValue > 0) { clbInventories.SelectedIndexChanged -= clbInventories_SelectedIndexChanged; clbInventories.Items[currentSelectedItemIdx] = savedSelected; clbInventories.SelectedIndexChanged += clbInventories_SelectedIndexChanged; } } } }
private void btnAddItem_Click(object sender, EventArgs e) { CompleteItemInfo newItem = new CompleteItemInfo(); newItem.Item = _invRetriever.InventorySolver.CsgoItemList[1]; newItem.Quality = _invRetriever.InventorySolver.CsgoQualityList[1]; newItem.Rarity = _invRetriever.InventorySolver.CsgoRarityList[1]; clbInventories.Items.Add(newItem); }