private int DetectLength() { //return 40; var length = patchData.TotalSize + patchData.TotalSourceFiles() * 256 + 0x20000; var mb = 0x100000; if (length < 5 * mb) { return(5); } else if (length < 10 * mb) { return(10); } else if (length < 15 * mb) { return(15); } else if (length < 20 * mb) { return(20); } else if (length < 30 * mb) { return(30); } else if (length < 40 * mb) { return(40); } else { throw new ApplicationException("Data too long for known HDI types"); } }
private void CheckSourceFiles(string dirname, string[] files) { var source_files = new List <string>(); _patch.ClearState(); bSelectSysDisk.Enabled = true; bSelectSource.Enabled = true; //lSourceSelected.Text = "Searching for game files..."; progressBar1.Visible = true; progressBar1.Maximum = _patch.TotalSourceFiles(); progressBar1.Value = 0; this.Update(); var allSourceFiles = false; foreach (var file in files) { if (IsFloppy(file)) { if (string.IsNullOrEmpty(_sysImage) && Patcher.CheckSysDisk(file)) { _sysImage = file; lSysDiskPath.Text = file; lSysDiskPath.Visible = true; this.toolTip1.SetToolTip(this.lSysDiskPath, file); if (file.Length > maxLength) { var letter = Path.GetPathRoot(file); lSysDiskPath.Text = Path.Combine(letter, "...", Path.GetFileName(file)); } lSysDiskSelected.Text = "OK"; } else if (!allSourceFiles) { if (Patcher.CheckGameSource(_patch, file, () => { progressBar1.Value++; Update(); })) { source_files.Add(file); } } } else if (!allSourceFiles) { if (Patcher.CheckGameSource(_patch, file, () => { progressBar1.Value++; Update(); })) { source_files.Add(file); } } if (_patch.FoundFiles == _patch.TotalSourceFiles()) { allSourceFiles = true; } } if (string.IsNullOrEmpty(_sysImage)) { bSelectSysDisk.Enabled = true; } if (_patch.FoundFiles == _patch.TotalSourceFiles()) { lSourceSelected.Visible = true; var fname = dirname; this.toolTip1.SetToolTip(this.lSourcePath, fname); if (fname.Length > maxLength) { var letter = Path.GetPathRoot(fname); fname = Path.Combine(letter, "...", Path.GetFileName(fname)); } lSourcePath.Text = fname; lSourcePath.Visible = true; lSourceSelected.Text = "OK"; _sourceFiles = source_files; if (!string.IsNullOrEmpty(_sysImage)) { bApplyPatch.Enabled = true; } else { bSelectSysDisk.Enabled = true; } } else { bSelectSource.Enabled = true; var msg = string.Join("\r\n", _patch.ShowNotFoundFiles()); MessageBox.Show(msg, "Can't find source files"); } progressBar1.Hide(); }