private static void UpdateManifest2014(string songDirectory, Platform platform) { // UPDATE MANIFEST (RS2014) if (platform.version == GameVersion.RS2014) { var xmlFiles = Directory.EnumerateFiles(songDirectory, "*.xml", SearchOption.AllDirectories); var jsonFiles = Directory.EnumerateFiles(songDirectory, "*.json", SearchOption.AllDirectories); foreach (var xml in xmlFiles) { var xmlName = Path.GetFileNameWithoutExtension(xml); if (xmlName.ToUpperInvariant().Contains("SHOWLIGHT")) { continue; } if (xmlName.ToUpperInvariant().Contains("VOCAL")) { continue;//TODO: Re-generate vocals manifest. } string json = jsonFiles.Where(name => Path.GetFileNameWithoutExtension(name) == xmlName).FirstOrDefault(); if (!String.IsNullOrEmpty(json)) { var xmlContent = Song2014.LoadFromFile(xml); var manifest = new Manifest2014 <Attributes2014>(); var attr = Manifest2014 <Attributes2014> .LoadFromFile(json).Entries.First().Value.First().Value; var manifestFunctions = new ManifestFunctions(platform.version); attr.PhraseIterations = new List <Manifest.PhraseIteration>(); manifestFunctions.GeneratePhraseIterationsData(attr, xmlContent, platform.version); attr.Phrases = new List <Manifest.Phrase>(); manifestFunctions.GeneratePhraseData(attr, xmlContent); attr.Sections = new List <Manifest.Section>(); manifestFunctions.GenerateSectionData(attr, xmlContent); attr.MaxPhraseDifficulty = manifestFunctions.GetMaxDifficulty(xmlContent); var attributeDictionary = new Dictionary <string, Attributes2014> { { "Attributes", attr } }; manifest.Entries.Add(attr.PersistentID, attributeDictionary); manifest.SaveToFile(json); } } } }
private static void UpdateManifest2014(string songDirectory, Platform platform) { // UPDATE MANIFEST (RS2014) if (platform.version == GameVersion.RS2014) { var xmlFiles = Directory.EnumerateFiles(songDirectory, "*.xml", SearchOption.AllDirectories); var jsonFiles = Directory.EnumerateFiles(songDirectory, "*.json", SearchOption.AllDirectories); foreach (var xml in xmlFiles) { var xmlName = Path.GetFileNameWithoutExtension(xml); if (xmlName.ToUpperInvariant().Contains("SHOWLIGHT")) continue; if (xmlName.ToUpperInvariant().Contains("VOCAL")) continue;//TODO: Re-generate vocals manifest. string json = jsonFiles.FirstOrDefault(name => Path.GetFileNameWithoutExtension(name) == xmlName); if (!String.IsNullOrEmpty(json)) { var xmlContent = Song2014.LoadFromFile(xml); var manifest = new Manifest2014<Attributes2014>(); var attr = Manifest2014<Attributes2014>.LoadFromFile(json).Entries.First().Value.First().Value; var manifestFunctions = new ManifestFunctions(platform.version); attr.PhraseIterations = new List<Manifest.PhraseIteration>(); manifestFunctions.GeneratePhraseIterationsData(attr, xmlContent, platform.version); attr.Phrases = new List<Manifest.Phrase>(); manifestFunctions.GeneratePhraseData(attr, xmlContent); attr.Sections = new List<Manifest.Section>(); manifestFunctions.GenerateSectionData(attr, xmlContent); attr.MaxPhraseDifficulty = manifestFunctions.GetMaxDifficulty(xmlContent); var attributeDictionary = new Dictionary<string, Attributes2014> { { "Attributes", attr } }; manifest.Entries.Add(attr.PersistentID, attributeDictionary); manifest.SaveToFile(json); } } } }
private int ApplyPackageDD(string file, string remSUS, string rampPath, out string consoleOutputPkg) { int singleResult = -1; bool exitedByError = false; consoleOutputPkg = String.Empty; var tmpDir = Path.GetTempPath(); var platform = file.GetPlatform(); var unpackedDir = Packer.Unpack(file, tmpDir, false, true, false); var xmlFiles = Directory.GetFiles(unpackedDir, "*.xml", SearchOption.AllDirectories); foreach (var xml in xmlFiles) { if (Path.GetFileNameWithoutExtension(xml).ToLower().Contains("vocal")) { continue; } if (Path.GetFileNameWithoutExtension(xml).ToLower().Contains("showlight")) { continue; } singleResult = ApplyDD(xml, remSUS, rampPath, out consoleOutputPkg, true, false); // UPDATE MANIFEST (RS2014) for update if (platform.version == RocksmithToolkitLib.GameVersion.RS2014) { var json = Directory.GetFiles(unpackedDir, String.Format("*{0}.json", Path.GetFileNameWithoutExtension(xml)), SearchOption.AllDirectories); if (json.Length > 0) { Attributes2014 attr = Manifest2014 <Attributes2014> .LoadFromFile(json[0]).Entries.ToArray()[0].Value.ToArray()[0].Value; Song2014 xmlContent = Song2014.LoadFromFile(xml); var manifestFunctions = new ManifestFunctions(platform.version); attr.PhraseIterations = new List <PhraseIteration>(); manifestFunctions.GeneratePhraseIterationsData(attr, xmlContent, platform.version); attr.Phrases = new List <Phrase>(); manifestFunctions.GeneratePhraseData(attr, xmlContent); attr.Sections = new List <Section>(); manifestFunctions.GenerateSectionData(attr, xmlContent); attr.MaxPhraseDifficulty = manifestFunctions.GetMaxDifficulty(xmlContent); var manifest = new Manifest2014 <Attributes2014>(); var attributeDictionary = new Dictionary <string, Attributes2014> { { "Attributes", attr } }; manifest.Entries.Add(attr.PersistentID, attributeDictionary); manifest.SaveToFile(json[0]); } } if (singleResult == 1) { exitedByError = true; break; } else if (singleResult == 2) { consoleOutputPkg = String.Format("Arrangement file '{0}' => {1}", Path.GetFileNameWithoutExtension(xml), consoleOutputPkg); } } if (!exitedByError) { var newName = Path.Combine(Path.GetDirectoryName(file), String.Format("{0}_{1}{2}", Path.GetFileNameWithoutExtension(file).StripPlatformEndName().GetValidName(false).Replace("_DD", "").Replace("_NDD", ""), isNDD ? "NDD" : "DD", platform.GetPathName()[2])); Packer.Pack(unpackedDir, newName, true, platform); DirectoryExtension.SafeDelete(unpackedDir); } return(singleResult); }
private int ApplyPackageDD(string file, string remSUS, string rampPath, out string consoleOutputPkg) { int singleResult = -1; bool exitedByError = false; consoleOutputPkg = String.Empty; var tmpDir = Path.GetTempPath(); var platform = file.GetPlatform(); var unpackedDir = Packer.Unpack(file, tmpDir, false, true, false); var xmlFiles = Directory.GetFiles(unpackedDir, "*.xml", SearchOption.AllDirectories); foreach (var xml in xmlFiles) { if (Path.GetFileNameWithoutExtension(xml).ToLower().Contains("vocal")) continue; if (Path.GetFileNameWithoutExtension(xml).ToLower().Contains("showlight")) continue; singleResult = ApplyDD(xml, remSUS, rampPath, out consoleOutputPkg, true, false); // UPDATE MANIFEST (RS2014) for update if (platform.version == RocksmithToolkitLib.GameVersion.RS2014) { var json = Directory.GetFiles(unpackedDir, String.Format("*{0}.json", Path.GetFileNameWithoutExtension(xml)), SearchOption.AllDirectories); if (json.Length > 0) { Attributes2014 attr = Manifest2014<Attributes2014>.LoadFromFile(json[0]).Entries.ToArray()[0].Value.ToArray()[0].Value; Song2014 xmlContent = Song2014.LoadFromFile(xml); var manifestFunctions = new ManifestFunctions(platform.version); attr.PhraseIterations = new List<PhraseIteration>(); manifestFunctions.GeneratePhraseIterationsData(attr, xmlContent, platform.version); attr.Phrases = new List<Phrase>(); manifestFunctions.GeneratePhraseData(attr, xmlContent); attr.Sections = new List<Section>(); manifestFunctions.GenerateSectionData(attr, xmlContent); attr.MaxPhraseDifficulty = manifestFunctions.GetMaxDifficulty(xmlContent); var manifest = new Manifest2014<Attributes2014>(); var attributeDictionary = new Dictionary<string, Attributes2014> { { "Attributes", attr } }; manifest.Entries.Add(attr.PersistentID, attributeDictionary); manifest.SaveToFile(json[0]); } } if (singleResult == 1) { exitedByError = true; break; } else if (singleResult == 2) consoleOutputPkg = String.Format("Arrangement file '{0}' => {1}", Path.GetFileNameWithoutExtension(xml), consoleOutputPkg); } if (!exitedByError) { var newName = Path.Combine(Path.GetDirectoryName(file), String.Format("{0}_{1}{2}", Path.GetFileNameWithoutExtension(file).StripPlatformEndName().GetValidName(false).Replace("_DD", "").Replace("_NDD",""), isNDD ? "NDD" : "DD", platform.GetPathName()[2])); Packer.Pack(unpackedDir, newName, true, platform); DirectoryExtension.SafeDelete(unpackedDir); } return singleResult; }
private static void UpdateManifest2014(string songDirectory, Platform platform) { if (platform.version != GameVersion.RS2014) { return; } var hsanFiles = Directory.EnumerateFiles(songDirectory, "*.hsan", SearchOption.AllDirectories).ToList(); if (!hsanFiles.Any()) { throw new DataException("Error: could not find any hsan file"); } if (hsanFiles.Count > 1) { throw new DataException("Error: there is more than one hsan file"); } var manifestHeader = new ManifestHeader2014 <AttributesHeader2014>(platform); var hsanFile = hsanFiles.First(); var jsonFiles = Directory.EnumerateFiles(songDirectory, "*.json", SearchOption.AllDirectories).ToList(); var xmlFiles = Directory.EnumerateFiles(songDirectory, "*.xml", SearchOption.AllDirectories).ToList(); //var songFiles = xmlFiles.Where(x => !x.ToLower().Contains("showlight") && !x.ToLower().Contains("vocal")).ToList(); //var vocalFiles = xmlFiles.Where(x => x.ToLower().Contains("vocal")).ToList(); foreach (var xmlFile in xmlFiles) { var xmlName = Path.GetFileNameWithoutExtension(xmlFile); if (xmlName.ToLower().Contains("showlight")) { continue; } var json = jsonFiles.FirstOrDefault(name => Path.GetFileNameWithoutExtension(name) == xmlName); if (String.IsNullOrEmpty(json)) { continue; } var attr = Manifest2014 <Attributes2014> .LoadFromFile(json).Entries.First().Value.First().Value; if (!xmlName.ToLower().Contains("vocal")) { var manifestFunctions = new ManifestFunctions(platform.version); var xmlContent = Song2014.LoadFromFile(xmlFile); attr.PhraseIterations = new List <Manifest.PhraseIteration>(); manifestFunctions.GeneratePhraseIterationsData(attr, xmlContent, platform.version); attr.Phrases = new List <Manifest.Phrase>(); manifestFunctions.GeneratePhraseData(attr, xmlContent); attr.Sections = new List <Manifest.Section>(); manifestFunctions.GenerateSectionData(attr, xmlContent); attr.Tuning = new TuningStrings(); manifestFunctions.GenerateTuningData(attr, xmlContent); attr.MaxPhraseDifficulty = manifestFunctions.GetMaxDifficulty(xmlContent); } // else { // TODO: good place to update vocals } // write updated json file var attributeDictionary = new Dictionary <string, Attributes2014> { { "Attributes", attr } }; var manifest = new Manifest2014 <Attributes2014>(); manifest.Entries.Add(attr.PersistentID, attributeDictionary); manifest.SaveToFile(json); // update manifestHeader (hsan) entry var attributeHeaderDictionary = new Dictionary <string, AttributesHeader2014> { { "Attributes", new AttributesHeader2014(attr) } }; if (platform.IsConsole) { // One for each arrangements (Xbox360/PS3) manifestHeader = new ManifestHeader2014 <AttributesHeader2014>(platform); manifestHeader.Entries.Add(attr.PersistentID, attributeHeaderDictionary); } else { manifestHeader.Entries.Add(attr.PersistentID, attributeHeaderDictionary); } } // write updated hsan file manifestHeader.SaveToFile(hsanFile); }
private static void UpdateManifest2014(string songDirectory, Platform platform) { if (platform.version != GameVersion.RS2014) return; var hsanFiles = Directory.EnumerateFiles(songDirectory, "*.hsan", SearchOption.AllDirectories).ToList(); if (!hsanFiles.Any()) throw new DataException("Error: could not find any hsan file"); if (hsanFiles.Count > 1) throw new DataException("Error: there is more than one hsan file"); var manifestHeader = new ManifestHeader2014<AttributesHeader2014>(platform); var hsanFile = hsanFiles.First(); var jsonFiles = Directory.EnumerateFiles(songDirectory, "*.json", SearchOption.AllDirectories).ToList(); var xmlFiles = Directory.EnumerateFiles(songDirectory, "*.xml", SearchOption.AllDirectories).ToList(); //var songFiles = xmlFiles.Where(x => !x.ToLower().Contains("showlight") && !x.ToLower().Contains("vocal")).ToList(); //var vocalFiles = xmlFiles.Where(x => x.ToLower().Contains("vocal")).ToList(); foreach (var xmlFile in xmlFiles) { var xmlName = Path.GetFileNameWithoutExtension(xmlFile); if (xmlName.ToLower().Contains("showlight")) continue; var json = jsonFiles.FirstOrDefault(name => Path.GetFileNameWithoutExtension(name) == xmlName); if (String.IsNullOrEmpty(json)) continue; var attr = Manifest2014<Attributes2014>.LoadFromFile(json).Entries.First().Value.First().Value; if (!xmlName.ToLower().Contains("vocal")) { var manifestFunctions = new ManifestFunctions(platform.version); var xmlContent = Song2014.LoadFromFile(xmlFile); attr.PhraseIterations = new List<Manifest.PhraseIteration>(); manifestFunctions.GeneratePhraseIterationsData(attr, xmlContent, platform.version); attr.Phrases = new List<Manifest.Phrase>(); manifestFunctions.GeneratePhraseData(attr, xmlContent); attr.Sections = new List<Manifest.Section>(); manifestFunctions.GenerateSectionData(attr, xmlContent); attr.Tuning = new TuningStrings(); manifestFunctions.GenerateTuningData(attr, xmlContent); attr.MaxPhraseDifficulty = manifestFunctions.GetMaxDifficulty(xmlContent); } // else { // TODO: good place to update vocals } // write updated json file var attributeDictionary = new Dictionary<string, Attributes2014> { { "Attributes", attr } }; var manifest = new Manifest2014<Attributes2014>(); manifest.Entries.Add(attr.PersistentID, attributeDictionary); manifest.SaveToFile(json); // update manifestHeader (hsan) entry var attributeHeaderDictionary = new Dictionary<string, AttributesHeader2014> { { "Attributes", new AttributesHeader2014(attr) } }; if (platform.IsConsole) { // One for each arrangements (Xbox360/PS3) manifestHeader = new ManifestHeader2014<AttributesHeader2014>(platform); manifestHeader.Entries.Add(attr.PersistentID, attributeHeaderDictionary); } else manifestHeader.Entries.Add(attr.PersistentID, attributeHeaderDictionary); } // write updated hsan file manifestHeader.SaveToFile(hsanFile); }