private void RefreshPCList() { PCDsiWareList.Items.Clear(); var ext = new List <string> { ".app", ".nds", ".srl" }; var myFiles = Directory.GetFiles(pcDirectory, "*.*", SearchOption.AllDirectories) .Where(s => ext.Contains(Path.GetExtension(s))); foreach (String NDSFile in myFiles) { if (CheckValidNDSDSiWareFile(NDSFile)) { DSiWareTitle dsiWare = new DSiWareTitle(NDSFile); icons.Images.Add(dsiWare.gameCode, dsiWare.icon); ListViewItem item = new ListViewItem(new string[] { dsiWare.title, dsiWare.blocks.ToString() + " blocks" }); item.ImageIndex = icons.Images.Count - 1; item.Tag = dsiWare; PCDsiWareList.Items.Add(item); } } }
private void RefreshSDList() { availableBlocks = 1024; validDriveSelected = true; DSiSDList.Items.Clear(); //This is an SD card with hiya CFW String DSiWareLocation = comboBox1.Text + "title\\00030004"; var ext = new List <string> { ".app" }; var myFiles = Directory.GetFiles(DSiWareLocation, "*.*", SearchOption.AllDirectories) .Where(s => ext.Contains(Path.GetExtension(s))); foreach (String NDSFile in myFiles) { DSiWareTitle dsiWare = new DSiWareTitle(NDSFile); icons.Images.Add(dsiWare.gameCode, dsiWare.icon); ListViewItem item = new ListViewItem(new string[] { dsiWare.title, dsiWare.blocks.ToString() + " blocks" }); item.ImageIndex = icons.Images.Count - 1; item.Tag = dsiWare; DSiSDList.Items.Add(item); availableBlocks -= dsiWare.blocks; availableBlocksLabel.Text = availableBlocks + " blocks"; } }
private void MoveToSD(object sender, EventArgs e) { if (PCDsiWareList.SelectedItems[0] != null && validDriveSelected) { foreach (ListViewItem item in PCDsiWareList.SelectedItems) { DSiWareTitle ware = (DSiWareTitle)item.Tag; String onelineTitle = ware.title.Replace("\n", " "); String messageString = onelineTitle.Replace("\0", "") + " cannot be installed onto the SD card. (WILL CRASH LAUNCHER!)\nContinue anyways?"; if (ware.blocks <= availableBlocks || MessageBox.Show(messageString, "Warning!", MessageBoxButtons.YesNo) == DialogResult.Yes) { string folderName = comboBox1.Text + "title\\00030004\\" + ware.titleID.ToLower(); Directory.CreateDirectory(folderName); Directory.CreateDirectory(folderName + "\\content"); Directory.CreateDirectory(folderName + "\\data"); if (System.IO.File.Exists(folderName + "\\data\\public.sav")) { File.Delete(folderName + "\\data\\public.sav"); } if (System.IO.File.Exists(folderName + "\\data\\private.sav")) { File.Delete(folderName + "\\data\\private.sav"); } if (System.IO.File.Exists(folderName + "\\content\\00000000.app")) { File.Delete(folderName + "\\content\\00000000.app"); } File.Copy(ware.NDSFile, folderName + "\\content\\00000000.app"); if (File.Exists(ware.NDSFile.Replace(".nds", ".pub"))) { Console.WriteLine(ware.NDSFile.Replace(".nds", ".pub")); File.Copy(ware.NDSFile.Replace(".nds", ".pub"), folderName + "\\data\\public.sav"); } else if (ware.publicSaveSize != 0) { File.WriteAllBytes(folderName + "\\data\\public.sav", new byte[ware.publicSaveSize]); } if (ware.privateSaveSize != 0) { File.WriteAllBytes(folderName + "\\data\\private.sav", new byte[ware.privateSaveSize]); } string path = Path.Combine(Path.GetTempPath(), "maketmd.exe"); File.WriteAllBytes(path, Resource1.maketmd); Process.Start(path, folderName + "\\content\\00000000.app " + folderName + "\\content\\title.tmd"); RefreshSDList(); } } } }
//Remove DSiWare from SD private void DeleteFromSD(object sender, EventArgs e) { if (DSiSDList.SelectedItems.Count > 0 && validDriveSelected) { foreach (ListViewItem item in DSiSDList.SelectedItems) { DSiWareTitle ware = (DSiWareTitle)item.Tag; if (Directory.Exists(comboBox1.Text + "title\\00030004\\" + ware.titleID.ToLower())) { Console.WriteLine("Removing: " + comboBox1.Text + "title\\00030004\\" + ware.titleID.ToLower()); Directory.Delete(comboBox1.Text + "title\\00030004\\" + ware.titleID.ToLower(), true); } } } RefreshSDList(); }
//Move DSiWare to PC dir private void DSiWareToPC(object sender, EventArgs e) { if (directorySelected && DSiSDList.SelectedItems.Count > 0) { foreach (ListViewItem item in DSiSDList.SelectedItems) { DSiWareTitle ware = (DSiWareTitle)item.Tag; String fileName = ware.title.Replace("\n", "-").Replace(" ", "_").Replace("\0", "").Replace(":", "_"); File.Copy(ware.NDSFile, pcDirectory + "\\" + fileName + ".nds"); if (ware.publicSaveSize > 0 && File.Exists(comboBox1.Text + "title\\00030004\\" + ware.titleID + "\\data\\public.sav")) { File.Copy(comboBox1.Text + "title\\00030004\\" + ware.titleID + "\\data\\public.sav", pcDirectory + "\\" + fileName + ".pub"); } } RefreshPCList(); } else { MessageBox.Show("Select a directory on PC to move DSiWare to."); } }
private void InstallNDSFromFileSelect(object sender, EventArgs e) { if (validDriveSelected) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { if (CheckValidNDSDSiWareFile(openFileDialog1.FileName)) { DSiWareTitle ware = new DSiWareTitle(openFileDialog1.FileName); String onelineTitle = ware.title.Replace("\n", " "); String messageString = onelineTitle.Replace("\0", "") + " cannot be installed onto the SD card. (WILL CRASH LAUNCHER!)\nContinue anyways?"; if (ware.blocks <= availableBlocks || MessageBox.Show(messageString, "Warning!", MessageBoxButtons.YesNo) == DialogResult.Yes) { string folderName = comboBox1.Text + "title\\00030004\\" + ware.titleID.ToLower(); Directory.CreateDirectory(folderName); Directory.CreateDirectory(folderName + "\\content"); Directory.CreateDirectory(folderName + "\\data"); if (System.IO.File.Exists(folderName + "\\data\\public.sav")) { File.Delete(folderName + "\\data\\public.sav"); } if (System.IO.File.Exists(folderName + "\\data\\private.sav")) { File.Delete(folderName + "\\data\\private.sav"); } if (System.IO.File.Exists(folderName + "\\content\\00000000.app")) { File.Delete(folderName + "\\content\\00000000.app"); } File.Copy(ware.NDSFile, folderName + "\\content\\00000000.app"); if (File.Exists(ware.NDSFile.Replace(".nds", ".pub"))) { Console.WriteLine(ware.NDSFile.Replace(".nds", ".pub")); File.Copy(ware.NDSFile.Replace(".nds", ".pub"), folderName + "\\data\\public.sav"); } else if (ware.publicSaveSize != 0) { File.WriteAllBytes(folderName + "\\data\\public.sav", new byte[ware.publicSaveSize]); } if (ware.privateSaveSize != 0) { File.WriteAllBytes(folderName + "\\data\\private.sav", new byte[ware.privateSaveSize]); } string path = Path.Combine(Path.GetTempPath(), "maketmd.exe"); File.WriteAllBytes(path, Resource1.maketmd); Process.Start(path, folderName + "\\content\\00000000.app " + folderName + "\\content\\title.tmd"); RefreshSDList(); } } } } else { MessageBox.Show("Select HiyaCFW SDNAND drive first!"); } }