private void saveSongFragment(DirectoryInfo pDir, XmlWriter xml, ProjectSong ps, string version, string filename)
{
bool b = (filename != null && filename.Length != 0);
if (b)
{
try
{
FileHelper.Delete(filename);
xml = XmlWriter.Create(filename, xml.Settings);
xml.WriteComment("This is a copy of the settings from the project file. This file can be imported with TheGHOST using Smart Mode");
}
catch
{
return; //skip this
}
}
xml.WriteStartElement("Song");
if (!b)
{
//xml.WriteAttributeString("id", ps.SongQb.Id.Text);
xml.WriteAttributeString("lastApplied", ps.LastApplied.ToString("s"));
}
else
xml.WriteAttributeString("version", version);
#region QbSettings
xml.WriteStartElement("QbSettings");
xml.WriteAttributeString("artist", ps.Artist);
xml.WriteAttributeString("title", ps.Title);
xml.WriteAttributeString("year", ps.Year);
xml.WriteAttributeString("singer", ps.Singer.ToString());
xml.WriteAttributeString("guitarVolume", ps.GuitarVolume.ToString());
xml.WriteAttributeString("songVolume", ps.SongVolume.ToString());
xml.WriteAttributeString("lastChanged", ps.QbLastChanged.ToString("s"));
xml.WriteEndElement(); //QbSettings
#endregion
#region Notes
xml.WriteStartElement("Notes");
xml.WriteAttributeString("minMsBeforeStart", ps.MinMsBeforeNotesStart.ToString());
xml.WriteAttributeString("hoPoMeasure", ps.Notes.HoPoMeasure.ToString());
xml.WriteAttributeString("gh3SustainClipping", ps.Notes.Gh3SustainClipping.ToString());
xml.WriteAttributeString("forceNoStarPower", ps.Notes.ForceNoStarPower.ToString());
xml.WriteAttributeString("lastChanged", ps.Notes.LastChanged.ToString("s"));
xml.WriteStartElement("NotesFiles");
foreach (NotesFile nf in ps.Notes.Files)
{
xml.WriteStartElement("NotesFile");
if (ps.Notes.BaseFile == nf)
xml.WriteAttributeString("baseFile", true.ToString());
xml.WriteAttributeString("nonNoteSyncOffset", nf.NonNoteSyncOffset.ToString());
xml.WriteStartElement("Filename");
xml.WriteString(pathAbsToRel(nf.Filename, pDir, b));
xml.WriteEndElement(); //Filename
xml.WriteStartElement("Items");
foreach (NotesFileItem nfi in nf.Items)
{
xml.WriteStartElement("Item");
xml.WriteAttributeString("id", nfi.UniqueId.ToString());
xml.WriteAttributeString("name", nfi.SourceName);
xml.WriteAttributeString("syncOffset", nfi.SyncOffset.ToString());
xml.WriteEndElement(); //Item
}
xml.WriteEndElement(); //Items
xml.WriteEndElement(); //NotesFile
}
xml.WriteEndElement(); //NotesFiles
xml.WriteStartElement("MappedItems");
foreach (GhNotesItem ghi in ps.Notes.GhItems)
{
xml.WriteStartElement("MappedItem");
xml.WriteAttributeString("name", ghi.Name);
if (ghi.IsMapped)
{
if (ghi.MappedFileItem != null)
xml.WriteAttributeString("mapToItemId", ghi.MappedFileItem.UniqueId.ToString());
xml.WriteAttributeString("syncOffset", ghi.MappedFileItem.SyncOffset.ToString());
xml.WriteAttributeString("hasGeneratedBattlePower", ghi.MappedFileItem.HasGeneratedBattlePower.ToString());
xml.WriteAttributeString("hasGeneratedFaceOff", ghi.MappedFileItem.HasGeneratedFaceOff.ToString());
xml.WriteAttributeString("hasGeneratedStarPower", ghi.MappedFileItem.HasGeneratedStarPower.ToString());
xml.WriteAttributeString("hasGeneratedNotes", ghi.MappedFileItem.HasGeneratedNotes.ToString());
}
xml.WriteEndElement(); //MappedItem
}
xml.WriteEndElement(); //MappedItems
xml.WriteEndElement(); //Notes
#endregion
#region Audio
xml.WriteStartElement("Audio");
xml.WriteAttributeString("lastChanged", ps.Audio.LastChanged.ToString("s"));
xml.WriteStartElement("Preview");
xml.WriteAttributeString("start", ps.Audio.PreviewStart.ToString());
xml.WriteAttributeString("length", ps.Audio.PreviewLength.ToString());
xml.WriteAttributeString("fadeLength", ps.Audio.PreviewFadeLength.ToString());
xml.WriteAttributeString("volume", ps.Audio.PreviewVolume.ToString());
xml.WriteAttributeString("includeGuitar", ps.Audio.PreviewIncludeGuitar.ToString());
xml.WriteAttributeString("includeRhythm", ps.Audio.PreviewIncludeRhythm.ToString());
xml.WriteEndElement(); //Preview
xml.WriteStartElement("AudioFiles");
xml.WriteAttributeString("length", ps.Audio.AudioLength.ToString());
if (ps.Audio.SongFiles.Count != 0)
{
foreach (AudioFile af in ps.Audio.SongFiles)
{
xml.WriteStartElement("AudioFile");
xml.WriteAttributeString("type", "song");
xml.WriteAttributeString("volume", af.Volume.ToString());
xml.WriteString(pathAbsToRel(af.Name, pDir, b));
xml.WriteEndElement(); //AudioFile
}
}
else
{
xml.WriteStartElement("AudioFile");
xml.WriteAttributeString("type", "song");
xml.WriteAttributeString("volume", "100");
xml.WriteString(string.Empty);
xml.WriteEndElement(); //AudioFile
}
xml.WriteStartElement("AudioFile");
xml.WriteAttributeString("type", "guitar");
xml.WriteAttributeString("volume", (ps.Audio.GuitarFile == null || ps.Audio.GuitarFile.Name.Length == 0) ? "100" : ps.Audio.GuitarFile.Volume.ToString());
xml.WriteString(ps.Audio.GuitarFile == null ? string.Empty : pathAbsToRel(ps.Audio.GuitarFile.Name, pDir, b));
xml.WriteEndElement(); //AudioFile
xml.WriteStartElement("AudioFile");
xml.WriteAttributeString("type", "rhythm");
xml.WriteAttributeString("volume", (ps.Audio.RhythmFile == null || ps.Audio.RhythmFile.Name.Length == 0) ? "100" : ps.Audio.RhythmFile.Volume.ToString());
xml.WriteString(ps.Audio.RhythmFile == null ? string.Empty : pathAbsToRel(ps.Audio.RhythmFile.Name, pDir, b));
xml.WriteEndElement(); //AudioFile
xml.WriteEndElement(); //AudioFiles
xml.WriteEndElement(); //Audio
#endregion
xml.WriteEndElement(); //Song
if (b)
xml.Close();
}