private void checkPackage(Stream input, ListViewItem item) { detective.isCorrupt = false; detective.isDisabled = false; if (input.Length == 0) { item.BackColor = detective.pType.ToColor(MadScience.Detective.PackageTypes.emptyPackage); item.SubItems[3].Text = detective.pType.ToString(MadScience.Detective.PackageTypes.emptyPackage); } else { MadScience.Detective.PackageType packageType = detective.getType(input); item.BackColor = detective.pType.ToColor(); if (detective.isCorrupt) { item.SubItems[3].Text = detective.pType.ToString(); item.SubItems[4].Text = detective.pType.SubType; if (!detective.isDisabled) { item.BackColor = detective.pType.ToColor(MadScience.Detective.PackageTypes.corruptTXTC); } } else { item.SubItems[3].Text = detective.pType.ToString(); item.SubItems[4].Text = detective.pType.SubType; } } }
private void addFile(string filename) { FileInfo f = new FileInfo(filename); ListViewItem item = new ListViewItem(); item.Text = f.Name; item.SubItems.Add(f.FullName); detective.isCorrupt = false; detective.isDisabled = false; MadScience.Detective.PackageType pType = detective.getType(f.FullName); item.SubItems.Add(detective.pType.ToString()); item.SubItems.Add(""); item.BackColor = pType.ToColor(); listView1.Items.Add(item); }
private void addListItem(MadScience.Sims3Pack.Sims3PackFile.PackagedFile packagedFile) { detective.isCorrupt = false; detective.isDisabled = false; ListViewItem item = new ListViewItem(); item.Checked = true; item.Text = packagedFile.Name; item.SubItems.Add(""); // 1 - Size item.SubItems.Add(""); // 2 - Description item.SubItems.Add(""); // 3 - Type item.SubItems.Add(""); // 4 - Sub-Type item.SubItems[1].Text = packagedFile.Length.ToString(); if (packagedFile.Length == 0) { item.BackColor = detective.pType.ToColor(MadScience.Detective.PackageTypes.emptyPackage); item.SubItems[3].Text = detective.pType.ToString(MadScience.Detective.PackageTypes.emptyPackage); } else { MadScience.Detective.PackageType packageType = detective.getType(packagedFile.DBPF); item.BackColor = detective.pType.ToColor(); } if (!String.IsNullOrEmpty(packagedFile.MetaTags.description)) { item.SubItems[2].Text = packagedFile.MetaTags.description; } if (detective.isCorrupt) { item.SubItems[3].Text = detective.pType.ToString(); item.SubItems[4].Text = detective.pType.SubType; if (!detective.isDisabled) { item.BackColor = detective.pType.ToColor(MadScience.Detective.PackageTypes.corruptTXTC); } } else { item.SubItems[3].Text = detective.pType.ToString(); if (String.IsNullOrEmpty(item.SubItems[2].Text)) { item.SubItems[2].Text = detective.pType.SubType; } else { item.SubItems[4].Text = detective.pType.SubType; } } // Do some sanity checks... // If the description so far is empty, use the metatags name if (String.IsNullOrEmpty(item.SubItems[2].Text) && !String.IsNullOrEmpty(packagedFile.MetaTags.name)) { item.SubItems[2].Text = packagedFile.MetaTags.name; } listView1.Items.Add(item); }
private void checkPackage(string filename, ListViewItem item) { // Check 0 byte file FileInfo f = new FileInfo(filename); if (!alwaysUseFastScanToolStripMenuItem.Checked) { toolStripStatusLabel1.Text = "Checking " + f.Name; statusStrip1.Refresh(); } detective.isCorrupt = false; detective.isDisabled = false; if (f.Length == 0) { item.BackColor = detective.pType.ToColor(MadScience.Detective.PackageTypes.emptyPackage); item.SubItems[2].Text = detective.pType.ToString(MadScience.Detective.PackageTypes.emptyPackage); return; } if (filename.EndsWith(".disabled")) { detective.isDisabled = true; item.BackColor = detective.pType.ToColor(MadScience.Detective.PackageTypes.disabledPackage); } Stream input = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); MadScience.Wrappers.Database db = new MadScience.Wrappers.Database(input, true, false); try { if (filename.Contains(".dbc")) { MadScience.Detective.PackageType packageType = detective.getType(db, true); } else { MadScience.Detective.PackageType packageType = detective.getType(db, false); } } catch (System.Exception excpt) { MessageBox.Show(excpt.Message + " " + excpt.StackTrace, f.Name); detective.pType.MainType = MadScience.Detective.PackageTypes.corruptBadDownload; detective.isCorrupt = true; item.BackColor = detective.pType.ToColor(); item.SubItems[2].Text = detective.pType.ToString(); input.Close(); return; } if (detective.pType.MainType == MadScience.Detective.PackageTypes.sims2Package) { item.SubItems[2].Text = detective.pType.ToString(); if (!detective.isDisabled) { item.BackColor = detective.pType.ToColor(MadScience.Detective.PackageTypes.sims2Package); } input.Close(); return; } // Game number switch (db.dbpf.gameNumber) { case MadScience.Helpers.GameNumber.baseGame: item.SubItems[7].Text = "Base"; break; case MadScience.Helpers.GameNumber.worldAdventures: item.SubItems[7].Text = "WA"; break; case MadScience.Helpers.GameNumber.highEndLoftStuff: item.SubItems[7].Text = "HELS"; break; case MadScience.Helpers.GameNumber.ambitions: item.SubItems[7].Text = "AMB"; break; } if (detective.isCorrupt) { item.SubItems[2].Text = detective.pType.ToString(); item.SubItems[6].Text = detective.pType.SubType; if (!detective.isDisabled) { item.BackColor = detective.pType.ToColor(MadScience.Detective.PackageTypes.corruptTXTC); } input.Close(); return; } if (!detective.isDisabled) { item.BackColor = listView1.BackColor; } string pType = detective.pType.ToString(); // Check if any of this packages types exist in the entriesdb for (int i = 0; i < db.dbpf.Entries.Count; i++) { MadScience.Wrappers.DatabasePackedFile.Entry entry = db.dbpf.Entries[i]; bool dealtWith = false; string entryString = entry.Key.ToString(); if (Enum.IsDefined(typeof(ConflictTypes), entry.Key.typeId)) //foreach (uint typeHash in Enum.GetValues(typeof(ResourceTypes))) //{ // if (typeHash == entry.Key.typeId) { if (conflictList.ContainsKey(entryString)) { // Something already has this ResourceKey - mark file as conflicted. // But wait! Check if it's pointing to itself first. :) if (conflictList[entryString] == (int)item.Tag) { break; } // Check if it's an entire duplicate, or merely part FileInfo f2 = new FileInfo(packageList[conflictList[entryString]].SubItems[1].Text); //FileInfo f2 = new FileInfo(listView1.Items[conflictList[entryString]].SubItems[1].Text); if (f.Length == f2.Length) { pType = "Duplicate of " + Path.Combine(packageList[conflictList[entryString]].SubItems[5].Text, packageList[conflictList[entryString]].Text); if (!detective.isDisabled) { item.BackColor = detective.pType.ToColor(MadScience.Detective.PackageTypes.duplicatePackage); packageList[conflictList[entryString]].BackColor = detective.pType.ToColor(MadScience.Detective.PackageTypes.duplicatePackage); } dealtWith = true; break; } else { pType = "Conflicts with " + Path.Combine(packageList[conflictList[entryString]].SubItems[5].Text, packageList[conflictList[entryString]].Text); if (!detective.isDisabled) { item.BackColor = detective.pType.ToColor(MadScience.Detective.PackageTypes.conflictPackage); if (packageList[conflictList[entryString]].BackColor != detective.pType.ToColor(MadScience.Detective.PackageTypes.corruptTXTC)) { packageList[conflictList[entryString]].BackColor = detective.pType.ToColor(MadScience.Detective.PackageTypes.conflictPackage); } } dealtWith = true; break; } } else { conflictList.Add(entryString, (int)item.Tag); } // } } if (dealtWith == true) { break; } } input.Close(); //if (packageType == "unknown") //{ //packageType = "Sims 3 Package"; //} item.SubItems[2].Text = pType; item.SubItems[6].Text = detective.pType.SubType; }
private void installAllFiles() { displayTotal(); label1.Text = "Now, select the sub-folder where you want to install the packages to, or choose '<Base Mods\\Packages>'. When done, click 3) Install to install the files to your game."; int numInstalled = 0; toolStripProgressBar1.Maximum = listView1.Items.Count; for (int i = 0; i < listView1.Items.Count; i++) { detective.isCorrupt = false; detective.isDisabled = false; toolStripProgressBar1.Value++; string filePath = listView1.Items[i].SubItems[1].Text; toolStripStatusLabel1.Text = "Checking " + filePath; MadScience.Detective.PackageType pType = detective.getType(filePath); if (!detective.isCorrupt) { switch (pType.MainType) { case Detective.PackageTypes.sims3Store: case Detective.PackageTypes.sims2Package: case Detective.PackageTypes.pngThumbnail: listView1.Items[i].SubItems[3].Text = "Not a package file"; listView1.Items[i].BackColor = Color.Salmon; break; default: string copyResult = copyFileToFolder(filePath); if (copyResult == "") { listView1.Items[i].SubItems[3].Text = "File copied OK"; numInstalled++; } else { listView1.Items[i].SubItems[3].Text = copyResult; listView1.Items[i].BackColor = Color.Salmon; } break; } } else { listView1.Items[i].SubItems[3].Text = "Cannot install corrupt file: " + pType.ToString(); listView1.Items[i].BackColor = Color.Salmon; } } if (numInstalled < listView1.Items.Count) { picAccept.Visible = false; picRemove.Visible = true; lblHeader.Text = numInstalled.ToString() + " of " + listView1.Items.Count.ToString() + " files installed"; toolStripStatusLabel1.Text = "Any files NOT in white in the list are not installed!"; } else { picRemove.Visible = false; picAccept.Visible = true; lblHeader.Text = "All files installed ok!"; toolStripStatusLabel1.Text = "All files installed ok!"; } toolStripProgressBar1.Value = toolStripProgressBar1.Minimum; }