private static bool HandleCommandLinePatch(string[] args) { System.Collections.Generic.KeyValuePair <string, string> patchFilepaths = PatcherLib.Utilities.Utilities.GetPatchFilepaths(args, ".ffttext", new string[3] { ".bin", ".iso", ".img" }); if ((string.IsNullOrEmpty(patchFilepaths.Key)) || (string.IsNullOrEmpty(patchFilepaths.Value))) { return(false); } else { System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); try { FFTText fftText = FFTTextFactory.GetFilesXml(patchFilepaths.Key); fftText.PatchISOSimple(patchFilepaths.Value); } catch (Exception ex) { AttachConsole(ATTACH_PARENT_PROCESS); Console.WriteLine("Error: " + ex.Message); } return(true); } }
void saveMenuItem_Click(object sender, EventArgs e) { saveFileDialog.OverwritePrompt = true; saveFileDialog.FileName = string.Empty; saveFileDialog.CheckFileExists = false; saveFileDialog.Filter = "FFTText files (*.ffttext)|*.ffttext"; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { FFTTextFactory.WriteXml(internalFile, saveFileDialog.FileName); } }
protected AbstractFile( GenericCharMap charmap, FFTTextFactory.FileInfo layout, IList<IList<string>> strings, bool compressible ) : this( charmap, layout, compressible ) { List<IList<string>> sections = new List<IList<string>>( NumberOfSections ); for ( int i = 0; i < NumberOfSections; i++ ) { string[] thisSection = new string[strings[i].Count]; strings[i].CopyTo( thisSection, 0 ); for ( int j = 0; j < thisSection.Length; j++ ) { if ( !CharMap.ValidateString( thisSection[j] ) ) { throw new InvalidStringException( layout.Guid.ToString(), i, j, thisSection[j] ); } } sections.Add( thisSection ); } this.Sections = sections.AsReadOnly(); PopulateDisallowedSections(); }
private void LoadFile(LoadType loadType, string filename, Stream isoStream, Stream tblStream) { BackgroundWorker worker = new BackgroundWorker(); worker.WorkerSupportsCancellation = true; worker.WorkerReportsProgress = true; DialogResult missingFilesResult = DialogResult.No; string missingFilesIsoFilename = null; MethodInvoker missingPrompt = null; missingPrompt = delegate() { var res = MyMessageBox.Show(this, "Some files are missing." + Environment.NewLine + "Load missing files from ISO?", "Files missing", MessageBoxButtons.YesNoCancel); if (res == DialogResult.Yes) { openFileDialog.Filter = "ISO files (*.iso, *.bin, *.img)|*.iso;*.bin;*.img"; openFileDialog.FileName = string.Empty; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { missingFilesIsoFilename = openFileDialog.FileName; } else { missingPrompt(); } } missingFilesResult = res; }; worker.DoWork += delegate(object sender, DoWorkEventArgs args) { FFTText text = null; switch (loadType) { case LoadType.Open: Set <Guid> missing = FFTTextFactory.DetectMissingGuids(filename); if (missing.Count > 0) { if (InvokeRequired) { Invoke(missingPrompt); } else { missingPrompt(); } if (missingFilesResult == DialogResult.Yes) { using (Stream missingStream = File.OpenRead(missingFilesIsoFilename)) { text = FFTTextFactory.GetFilesXml(filename, worker, missing, missingStream); } } else if (missingFilesResult == DialogResult.Cancel) { text = null; } else if (missingFilesResult == DialogResult.No) { text = FFTTextFactory.GetFilesXml(filename, worker); } } else { text = FFTTextFactory.GetFilesXml(filename, worker); } break; case LoadType.PspFilename: text = FFTText.ReadPSPIso(filename, worker); break; case LoadType.PsxFilename: text = FFTText.ReadPSXIso(filename, worker); break; } if (text == null || worker.CancellationPending) { args.Cancel = true; return; } LoadFile(text); }; MethodInvoker enableForm = delegate() { fileMenuItem.Enabled = true; isoMenuItem.Enabled = true; textMenuItem.Enabled = true; fileEditor1.Enabled = true; helpMenuItem.Enabled = true; Cursor = Cursors.Default; }; worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs args) { if (args.Error != null) { MyMessageBox.Show(this, "Error loading file: " + args.Error.Message, "Error", MessageBoxButtons.OK); } if (InvokeRequired) { Invoke(enableForm); } else { enableForm(); } }; fileMenuItem.Enabled = false; isoMenuItem.Enabled = false; textMenuItem.Enabled = false; fileEditor1.Enabled = false; helpMenuItem.Enabled = false; Cursor = Cursors.WaitCursor; worker.RunWorkerAsync(); }
public static FFTText ReadPSXIso(FileStream stream, BackgroundWorker worker) { return(FFTTextFactory.GetPsxText(stream, worker)); }
private void LoadFile(LoadType loadType, string filename, Stream isoStream, Stream tblStream) { BackgroundWorker worker = new BackgroundWorker(); worker.WorkerSupportsCancellation = true; worker.WorkerReportsProgress = true; worker.DoWork += delegate(object sender, DoWorkEventArgs args) { FFTText text = null; switch (loadType) { case LoadType.Open: text = FFTTextFactory.GetFilesXml(filename, worker); break; case LoadType.PspFilename: text = FFTText.ReadPSPIso(filename, worker); break; case LoadType.PsxFilename: text = FFTText.ReadPSXIso(filename, worker); break; case LoadType.PspStreamAndTable: text = FFTTextFactory.GetPspText(isoStream, tblStream, worker); break; case LoadType.PsxStreamAndTable: text = FFTTextFactory.GetPsxText(isoStream, tblStream, worker); break; } if (text == null || worker.CancellationPending) { args.Cancel = true; return; } LoadFile(text); }; MethodInvoker enableForm = delegate() { fileMenuItem.Enabled = true; isoMenuItem.Enabled = true; textMenuItem.Enabled = true; fileEditor1.Enabled = true; helpMenuItem.Enabled = true; Cursor = Cursors.Default; }; worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs args) { if (args.Error != null) { MessageBox.Show(this, "Error loading file: " + args.Error.Message, "Error", MessageBoxButtons.OK); } if (InvokeRequired) { Invoke(enableForm); } else { enableForm(); } }; fileMenuItem.Enabled = false; isoMenuItem.Enabled = false; textMenuItem.Enabled = false; fileEditor1.Enabled = false; helpMenuItem.Enabled = false; Cursor = Cursors.WaitCursor; worker.RunWorkerAsync(); }
public CompressibleOneShotFile( GenericCharMap map, FFTTextFactory.FileInfo layout, IList<IList<string>> strings, string fileComments, IList<string> sectionComments ) : base(map, layout, strings, fileComments, sectionComments, true) { }
public PartitionedFile( GenericCharMap map, FFTTextFactory.FileInfo layout, IList<IList<string>> strings ) : base( map, layout, strings, false ) { PartitionSize = layout.Size / NumberOfSections; }
public SectionedFile( GenericCharMap map, FFTTextFactory.FileInfo layout, IList<IList<string>> strings, string fileComments, IList<string> sectionComments, bool compressed ) : base(map, layout, strings, fileComments, sectionComments, compressed) { }
public SectionedFile( GenericCharMap map, FFTTextFactory.FileInfo layout, IList<IList<string>> strings, string fileComments, IList<string> sectionComments ) : this(map, layout, strings, fileComments, sectionComments, false) { }