public InventoryRetriever(CsgoItemsGameFileParser parser, InventoryFileLoader loader) { if (parser.IsValid) { _invSolver = new ItemSolver(parser); } _itemInv = new List<CompleteItemInfo>(); _inventoryFileLoader = loader; }
static void Main(string[] args) { CsgoItemsGameFileParser test = new CsgoItemsGameFileParser(@"c:\items_game.txt"); if (test.IsValid) { foreach (var item in test.GetOfficialItems()) { Console.WriteLine("Item = {0} : Paint = {1}", item.Item1.CodedName, item.Item2.Name); } } else { Console.WriteLine("Invalid file!"); } Console.ReadLine(); }
public ItemSolver(CsgoItemsGameFileParser parser) { _parser = parser; }
private void btnRescanInv_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtItems_games.Text) == false && string.IsNullOrWhiteSpace(txtItems_730Bin.Text) == false) { if (_kvFileReader == null || _kvFileReader.IsClosed) { _kvFileReader = new CsgoItemsGameFileParser(txtItems_games.Text); } if (_kvFileReader.IsValid) { lblItems_gameTxt.ForeColor = Color.Green; lblItems_gameTxt.Text = @"Correct file"; } else { lblItems_gameTxt.ForeColor = Color.Red; lblItems_gameTxt.Text = @"Invalid file"; } if (_inventoryFileLoader == null) { _inventoryFileLoader = new InventoryFileLoader(txtItems_730Bin.Text); } switch (_inventoryFileLoader.FileLoadResult) { case LoadFileReturnValue.ValidAndUseable: lblItems_730Bin.ForeColor = Color.Green; lblItems_730Bin.Text = @"Correct file"; btnReloadInv.Enabled = false; btnSave.Enabled = true; if (_inventoryFileLoader.Manager.IsClosed) { _inventoryFileLoader = new InventoryFileLoader(txtItems_730Bin.Text); } break; case LoadFileReturnValue.ReadOnly: lblItems_730Bin.ForeColor = Color.Red; lblItems_730Bin.Text = @"File is readonly!"; btnReloadInv.Enabled = true; btnSave.Enabled = false; break; case LoadFileReturnValue.ValidHeaderBrokenInside: lblItems_730Bin.ForeColor = Color.Red; lblItems_730Bin.Text = @"File is unsupported/wrong file!"; btnReloadInv.Enabled = true; btnSave.Enabled = false; break; case LoadFileReturnValue.NotValid: lblItems_730Bin.ForeColor = Color.Red; lblItems_730Bin.Text = @"Invalid file!"; btnReloadInv.Enabled = true; btnSave.Enabled = false; break; case LoadFileReturnValue.NotExist: lblItems_730Bin.ForeColor = Color.Red; lblItems_730Bin.Text = @"File does not exist!"; btnReloadInv.Enabled = true; btnSave.Enabled = false; break; default: break; } } clbInventories.Items.Clear(); if (_kvFileReader.IsValid && _inventoryFileLoader.FileLoadResult == LoadFileReturnValue.ValidAndUseable) { _invRetriever = new InventoryRetriever(_kvFileReader, _inventoryFileLoader); foreach (var item in _invRetriever.GetAllInventories()) { clbInventories.Items.Add(item); } clbInventories.SelectedIndex = 0; foreach (var item in _kvFileReader.GetItemSets()) { clbItemSets.Items.Add(item); } foreach (var item in _kvFileReader.GetOfficialItems()) { lvItem = new ListViewItem(); lvItem.Text = item.Item1.CodedName; lvItem.SubItems.Add(item.Item2.Name); lvItem.SubItems.Add(item.Item2.Rarity); lvItem.Checked = false; lvRecognizedOfficialItems.Items.Add(lvItem); } } }
private void btnBrowseItemsGame_Click(object sender, EventArgs e) { if (ofdFileTxt.ShowDialog() == DialogResult.OK) { txtItems_games.Text = ofdFileTxt.FileName; _kvFileReader = new CsgoItemsGameFileParser(ofdFileTxt.FileName); if (_kvFileReader.IsValid) { lblItems_gameTxt.ForeColor = Color.Green; lblItems_gameTxt.Text = @"Correct file"; } else { lblItems_gameTxt.ForeColor = Color.Red; lblItems_gameTxt.Text = @"Invalid file"; } } }