private void addFolderToolStripMenuItem_Click(object sender, EventArgs e) { var sUsed = new StringCollection(); foreach (Node node in folderTree.SelectedNode.Nodes) { sUsed.Add(node.Text); } var newName = ""; while (string.IsNullOrWhiteSpace(newName) || sUsed.Contains(newName)) { var popup = new PasswordUnlocker(); popup.Renamer(); //change settings for renaming popup.ShowDialog(); newName = popup.EnteredText; popup.Dispose(); if (string.IsNullOrWhiteSpace(newName)) { return; } if (sUsed.Contains(newName)) { MessageBox.Show("That folder name is already used, try a different name", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } AddFolder(newName); GetSelFiles((CFolderEntry)(folderTree.FindNodeByText(Path.GetFileName(newName))).Tag); }
private void btnRename_Click(object sender, EventArgs e) { var name = cboCharacter.Text; var popup = new PasswordUnlocker(name); popup.Renamer(); //change settings for renaming popup.ShowDialog(); var newName = popup.EnteredText; popup.Dispose(); if (string.IsNullOrWhiteSpace(newName) || newName == name) { return; } if (newName.Length > 24) { newName = newName.Substring(0, 24).Trim(); } cboCharacter.Items[cboCharacter.SelectedIndex] = newName; if (Tools.SaveFileCharNames.Count >= cboCharacter.SelectedIndex) { Tools.SaveFileCharNames[cboCharacter.SelectedIndex] = newName; } NeedsToSave(true); }
private void btnChange_Click(object sender, EventArgs e) { var fails = new List <string> { "SONG ID MISSING", "NOT PRESENT IN DTA", "N/A", "N/A - PACK" }; var popup = new PasswordUnlocker(fails.Contains(lblSongID.Text) ? "" : lblSongID.Text); popup.IDChanger(); popup.ShowDialog(); var newID = popup.EnteredText; popup.Dispose(); if (string.IsNullOrWhiteSpace(newID) || newID.Trim() == lblSongID.Text) { return; } var dta = Path.GetTempPath() + "dta"; Tools.DeleteFile(dta); if (!activeDTA.ExtractToFile(dta)) { Log("Error extracting DTA file...failed to change song ID!"); return; } Tools.ReplaceSongID(dta, newID); if (!activeDTA.Replace(dta)) { Tools.DeleteFile(dta); Log("Error replacing DTA file...failed to change song ID!"); return; } Tools.DeleteFile(dta); lblSongID.Text = newID; Log("Changed song ID to '" + newID + "' successfully"); ShowChanges(true); }
private void btnBundle_Click(object sender, EventArgs e) { if (!File.Exists(orig_midi)) { Log("MIDI file " + Path.GetFileName(orig_midi) + " is missing! Did you just delete it?"); MIDIFixFailed(orig_midi, false); return; } if (!File.Exists(orig_dta)) { Log("DTA file " + Path.GetFileName(orig_dta) + " is missing! Did you just delete it?"); MIDIFixFailed(orig_dta, false); return; } newMIDI = Path.GetDirectoryName(orig_midi) + "\\" + Path.GetFileNameWithoutExtension(orig_midi) + " (bundled).mid"; newDTA = Path.GetDirectoryName(orig_dta) + "\\" + Path.GetFileNameWithoutExtension(orig_dta) + " (bundled).dta"; var skip_tracks = ignoreNoninstrumentTracks.Checked ? new List <string> { "EVENTS", "VENUE", "BEAT" } : new List <string>(); var midi = Tools.NemoLoadMIDI(orig_midi); if (midi == null) { MIDIFixFailed(orig_midi); return; } var harm1 = false; var harm2 = false; var harm3 = false; foreach (var UpgMidi in UpgradeMidis) { if (!File.Exists(UpgMidi)) { Log("Upgrade MIDI file " + Path.GetFileName(UpgMidi) + " is missing! Did you just delete it?"); continue; } var upgrade = Tools.NemoLoadMIDI(UpgMidi); if (upgrade == null) { MIDIFixFailed(UpgMidi); return; } Tools.DeleteFile(newMIDI); Tools.DeleteFile(newDTA); var origtracks = new List <string>(); //check which tracks are in original midi for (var i = 0; i < midi.Events.Tracks; i++) { var trackname = Tools.GetMidiTrackName(midi.Events[i][0].ToString()); if (!origtracks.Contains(trackname) && !skip_tracks.Contains(trackname)) { origtracks.Add(trackname); } } var upgtracks = new List <string>(); //check what tracks are in the upgrade midi //skip track 0 = tempo track for (var i = 1; i < upgrade.Events.Tracks; i++) { var trackname = Tools.GetMidiTrackName(upgrade.Events[i][0].ToString()); if (trackname.Contains("HARM1") || trackname.Contains("VOCALS")) { harm1 = true; } else if (trackname.Contains("HARM2")) { harm2 = true; } else if (trackname.Contains("HARM3")) { harm3 = true; } if (!upgtracks.Contains(trackname) && !skip_tracks.Contains(trackname)) { upgtracks.Add(trackname); } } if (overwriteExistingTrack.Checked) //only remove if checked to overwrite { var to_remove = new List <int>(); for (var i = 0; i < midi.Events.Tracks; i++) { var trackname = Tools.GetMidiTrackName(midi.Events[i][0].ToString()); if (upgtracks.Contains(trackname)) { to_remove.Add(i); //remove only if found in the upgrade midi and overwrite is checked } } to_remove.Sort(); for (var i = to_remove.Count - 1; i >= 0; i--) { var trackname = Tools.GetMidiTrackName(midi.Events[to_remove[i]][0].ToString()); try { midi.Events.RemoveTrack(to_remove[i]); } catch (Exception ex) { Log("There was an error deleting track " + trackname); Log("Error: " + ex.Message); } } } var rbhp_xkeys = false; var rbhp_ekeys = false; //combine upgrade with original for (var i = 0; i < upgrade.Events.Tracks; i++) { var trackname = Tools.GetMidiTrackName(upgrade.Events[i][0].ToString()); if (!upgtracks.Contains(trackname) || (origtracks.Contains(trackname) && onlyAddNewTracks.Checked)) { continue; } try { if (trackname.Contains("KEYS_X")) { if (!rbhp_xkeys) { midi.Events.AddTrack(upgrade.Events[i]); } rbhp_xkeys = true; //sometimes rbhp uses two pro keys x tracks for whatever reason, only add one continue; } if (trackname.Contains("KEYS_E")) { if (!rbhp_ekeys) { midi.Events.AddTrack(upgrade.Events[i]); } rbhp_ekeys = true; //sometimes rbhp uses two pro keys e tracks for whatever reason, only add one continue; } midi.Events.AddTrack(upgrade.Events[i]); } catch (Exception ex) { Log("There was an error processing the upgrade MIDI file"); Log("Error: " + ex.Message); } } } try { MidiFile.Export(newMIDI, midi.Events); } catch (Exception ex) { Log("There was an error exporting the combined MIDI file"); Log("Error: " + ex.Message); } if (File.Exists(newMIDI)) { Log("Combined MIDI files successfully"); } else { Log("There was an error creating the combined MIDI file"); return; } if (string.IsNullOrWhiteSpace(orig_con)) { Log("Process completed successfully"); Log("Bundled MIDI file can be found in:"); Log(newMIDI); return; } if (!string.IsNullOrWhiteSpace(newsongdta) && File.Exists(newsongdta)) { Log("Replacing original songs.dta with RBHP songs.dta file"); orig_dta = newsongdta; //if we got RBHP dta, completely replace original one } if (!string.IsNullOrWhiteSpace(newupgdta) && File.Exists(newupgdta)) { Log("Merging upgrades.dta information into songs.dta file"); var sr = new StreamReader(orig_dta, Encoding.Default); var sw = new StreamWriter(newDTA, false, Encoding.Default); var doneTuning = false; //first pass, replace values if already present while (sr.Peek() > 0) { var line = sr.ReadLine(); if (!string.IsNullOrWhiteSpace(line)) { if (line.Contains("rank")) { sw.WriteLine(line); while (line != null && !line.Contains("format")) { line = sr.ReadLine(); if (string.IsNullOrWhiteSpace(line)) { continue; } if (line.Contains("bass") && !line.Contains("real_bass")) { sw.WriteLine(line); sw.WriteLine(probassdiff); line = ""; } else if (line.Contains("guitar") && !line.Contains("real_guitar")) { sw.WriteLine(line); sw.WriteLine(proguitardiff); line = ""; } else if (line.Contains("real_guitar") || line.Contains("real_bass")) { line = ""; } if (!string.IsNullOrWhiteSpace(line)) { sw.WriteLine(line); } } } if (string.IsNullOrWhiteSpace(line)) { continue; } if (line.Contains("real_guitar") || line.Contains("real_bass")) { line = ""; } else if (line.Contains(";The following values")) { sw.WriteLine(proguitartuning); sw.WriteLine(probasstuning); doneTuning = true; } else if (line == ")" && !doneTuning) { if (sr.Peek() <= 0) { sw.WriteLine(proguitartuning); sw.WriteLine(probasstuning); } } } if (!string.IsNullOrWhiteSpace(line)) { sw.WriteLine(line); } } sr.Dispose(); sw.Dispose(); if (File.Exists(newDTA)) { Log("Merged DTA information successfully"); } else { Log("There was an error merging DTA information"); return; } } else { Tools.DeleteFile(newDTA); File.Copy(orig_dta, newDTA); } var vocals = harm3 ? 3 : (harm2 ? 2 : (harm1) ? 1 : 0); if (showSongIDPrompt.Checked) { var popup = new PasswordUnlocker(songID == NA || useUpgradeID.Checked ? upgradeID : songID); popup.IDChanger(); popup.ShowDialog(); var newID = popup.EnteredText; popup.Dispose(); if (!string.IsNullOrWhiteSpace(newID)) { songID = newID; } } else if (useUpgradeID.Checked) { songID = upgradeID; } Tools.ReplaceSongID(newDTA, songID, vocals.ToString(CultureInfo.InvariantCulture)); Log("Creating the bundled file"); EnableDisable(false); btnBundle.Visible = false; backgroundWorker1.RunWorkerAsync(); }