private void savingThread_DoWork(object sender, DoWorkEventArgs e) { saveBuild(selectedChampion, generateItemString(), "", true); string cFileName = ""; foreach (string item in LeagueUtils.FileFinder.findInibinFiles()) if (item.Contains(selectedChampion + ".inibin")) cFileName = item; if (File.Exists(cFileName)) { LeagueUtils.FileRepair.BackupFile(cFileName); FileStream fs = new FileStream(cFileName, FileMode.Open); FileInfo fi = new FileInfo(cFileName); byte[] cBytes = new byte[fi.Length]; int read = fs.Read(cBytes, 0, cBytes.Length); fs.Close(); LeagueUtils.IniBinParser parser = new LeagueUtils.IniBinParser(cBytes); int[] beforeSave = parser.GetRecommendedItems(); int[] newItems = {int.Parse(recommendedItems[0]),int.Parse(recommendedItems[1]), int.Parse(recommendedItems[2]),int.Parse(recommendedItems[3]), int.Parse(recommendedItems[4]),int.Parse(recommendedItems[5])}; parser.SetRecommendedItems(newItems); int[] afterSave = parser.GetRecommendedItems(); File.WriteAllBytes(cFileName, parser.returnByteArray()); } else { //save failed...no message about this for now System.Diagnostics.Debug.WriteLine("saving failure..???"); return; } }
public void selectChampion(string name) { try { string cName = name; selectedChampion = cName; autoAbilityTool.getAutoAbilityInfo(); autoAbilityTool.initAbilityButtons(); bool setManagerVisible = setManager.IsVisible; if (setManagerVisible) setManager.Visibility = Visibility.Hidden; // Get the champion data from the zip (stored in "DATA\\Characters\\" + cName + "\\" + cName + ".inibin") // extractChampionData(cName); string cFileName = ""; foreach (string item in LeagueUtils.FileFinder.findInibinFiles()) if (item.Contains("\\" + cName + ".inibin")) { cFileName = item; break; } bool inXml = false; if (File.Exists("itemBuilds.xml")) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("itemBuilds.xml"); for (int i = 0; i < xmlDoc.DocumentElement.ChildNodes.Count; i++) { if (xmlDoc.DocumentElement.ChildNodes[i].Name == name) { inXml = true; string[] items = xmlDoc.DocumentElement.ChildNodes[i].InnerText.Split('-'); for (int j = 0; j < 6; j++) { recommendedItems[j] = items[j]; } } } } if (File.Exists(cFileName) && inXml == false) { FileStream fs = new FileStream(cFileName, FileMode.Open); FileInfo fi = new FileInfo(cFileName); byte[] cBytes = new byte[fi.Length]; int read = fs.Read(cBytes, 0, cBytes.Length); fs.Close(); LeagueUtils.IniBinParser parser = new LeagueUtils.IniBinParser(cBytes); int i = 0; foreach (int item in parser.GetRecommendedItems()) { recommendedItems[i] = item.ToString(); i++; } } updateItemDisplay(); skinCount = 1; while (File.Exists(LeagueUtils.FileFinder.findChampImageFolder() + "\\" + cName + "_Splash_" + skinCount + ".jpg")) skinCount++; Random r = new Random(); currentSkinNum = r.Next(0, skinCount); backgroundImage.Source = new BitmapImage( new Uri(LeagueUtils.FileFinder.findChampImageFolder() + "\\" + cName + "_Splash_" + currentSkinNum + ".jpg")); //mark the champion name championNameLbl.Content = heroData[cName].name; if (setManagerVisible) setManager.Visibility = System.Windows.Visibility.Visible; } catch (Exception e) { new LeagueOverlay.ScriptControl(null).log("[ERROR] (" + e.Source + "): " + e.Message + "\n" + e.StackTrace); throw; } }