private bool SaveEntry(LevelSetupEntry Entry) { try { File.WriteAllBytes(Entry.FilePath, Entry.ToBytes()); Globals.LoadedStagesJsonHash = Helpers.GetStringSHA1OfString(JsonConvert.SerializeObject(Globals.LevelSetups)); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
private bool LoadStages(string Path) { try { Globals.LevelSetups.Clear(); string[] Files = Directory.GetFiles(Path); int i = 0; foreach (string File in Files) { if (LevelSetupEntry.IsValid(File)) { Globals.LevelSetups.Add(new LevelSetupEntry(File)); i++; int Percent = (int)(((decimal)i / (decimal)(Files.Count())) * 100); SetProgressVal(Percent); } } string f = ""; foreach (LevelSetupEntry e in Globals.LevelSetups) { FileInfo fi = new FileInfo(e.FilePath); f += e.Entries.Count() + ", " + System.BitConverter.ToString(e.Header) + ", " + fi.Length + Environment.NewLine; } File.WriteAllText("test.txt", f); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
private void openSetupFileToolStripMenuItem_Click(object sender, EventArgs e) { try { using (OpenFileDialog fd = new OpenFileDialog()) { fd.Title = Resources.select_setup_file; DialogResult dr = fd.ShowDialog(); if (dr == DialogResult.OK) { if (!LevelSetupEntry.IsValid(fd.FileName)) { throw new Exception(Resources.setup_file_invalid); } Globals.LevelSetups.Clear(); Globals.LevelSetups.Add(new LevelSetupEntry(fd.FileName)); lstbox_Stages.Items.Clear(); foreach (LevelSetupEntry Setup in Globals.LevelSetups) { lstbox_Stages.Items.Add(Setup); } Globals.LoadedStagesJsonHash = Helpers.GetStringSHA1OfString(JsonConvert.SerializeObject(Globals.LevelSetups)); } } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }