本文整理汇总了C#中System.Platform.GetPathName方法的典型用法代码示例。如果您正苦于以下问题:C# Platform.GetPathName方法的具体用法?C# Platform.GetPathName怎么用?C# Platform.GetPathName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Platform
的用法示例。
在下文中一共展示了Platform.GetPathName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertPackageForSimilarPlatform
private static void ConvertPackageForSimilarPlatform(string unpackedDir, string targetFileName, Platform sourcePlatform, Platform targetPlatform, string appId)
{
// Old and new paths
var sourceDir0 = sourcePlatform.GetPathName()[0].ToLower();
var sourceDir1 = sourcePlatform.GetPathName()[1].ToLower();
var targetDir0 = targetPlatform.GetPathName()[0].ToLower();
var targetDir1 = targetPlatform.GetPathName()[1].ToLower();
if (!targetPlatform.IsConsole)
{
// Replace AppId
var appIdFile = Path.Combine(unpackedDir, "appid.appid");
File.WriteAllText(appIdFile, appId);
}
// Replace aggregate graph values
var aggregateFile = Directory.EnumerateFiles(unpackedDir, "*.nt", SearchOption.AllDirectories).FirstOrDefault();
var aggregateGraphText = File.ReadAllText(aggregateFile);
// Tags
aggregateGraphText = Regex.Replace(aggregateGraphText, GraphItem.GetPlatformTagDescription(sourcePlatform.platform), GraphItem.GetPlatformTagDescription(targetPlatform.platform), RegexOptions.Multiline);
// Paths
aggregateGraphText = Regex.Replace(aggregateGraphText, sourceDir0, targetDir0, RegexOptions.Multiline);
aggregateGraphText = Regex.Replace(aggregateGraphText, sourceDir1, targetDir1, RegexOptions.Multiline);
File.WriteAllText(aggregateFile, aggregateGraphText);
// Rename directories
foreach (var dir in Directory.GetDirectories(unpackedDir, "*.*", SearchOption.AllDirectories))
{
if (dir.EndsWith(sourceDir0))
{
var newDir = dir.Substring(0, dir.LastIndexOf(sourceDir0)) + targetDir0;
DirectoryExtension.SafeDelete(newDir);
DirectoryExtension.Move(dir, newDir);
}
else if (dir.EndsWith(sourceDir1))
{
var newDir = dir.Substring(0, dir.LastIndexOf(sourceDir1)) + targetDir1;
DirectoryExtension.SafeDelete(newDir);
DirectoryExtension.Move(dir, newDir);
}
}
// Recreates SNG because SNG have different keys in PC and Mac
bool updateSNG = ((sourcePlatform.platform == GamePlatform.Pc && targetPlatform.platform == GamePlatform.Mac) || (sourcePlatform.platform == GamePlatform.Mac && targetPlatform.platform == GamePlatform.Pc));
// Packing
var dirToPack = unpackedDir;
if (sourcePlatform.platform == GamePlatform.XBox360)
dirToPack = Directory.GetDirectories(Path.Combine(unpackedDir, Packer.ROOT_XBox360))[0];
Packer.Pack(dirToPack, targetFileName, updateSNG, targetPlatform, fixShowlights: false);
DirectoryExtension.SafeDelete(unpackedDir);
}
示例2: Convert
public static string Convert(string sourcePackage, Platform sourcePlatform, Platform targetPlatform, string appId)
{
var needRebuildPackage = sourcePlatform.IsConsole != targetPlatform.IsConsole;
var tmpDir = Path.GetTempPath();
var fileName = Path.GetFileNameWithoutExtension(sourcePackage);
if (sourcePlatform.platform == GamePlatform.PS3)
if (fileName.Contains(".psarc"))
fileName = fileName.Substring(0, fileName.LastIndexOf("."));
var unpackedDir = Packer.Unpack(sourcePackage, tmpDir, false, true, false, sourcePlatform);
// DESTINATION
var nameTemplate = (!targetPlatform.IsConsole) ? "{0}{1}.psarc" : "{0}{1}";
var packageName = Path.GetFileNameWithoutExtension(sourcePackage);
if (packageName.EndsWith(new Platform(GamePlatform.Pc, GameVersion.None).GetPathName()[2]) ||
packageName.EndsWith(new Platform(GamePlatform.Mac, GameVersion.None).GetPathName()[2]) ||
packageName.EndsWith(new Platform(GamePlatform.XBox360, GameVersion.None).GetPathName()[2]) ||
packageName.EndsWith(new Platform(GamePlatform.PS3, GameVersion.None).GetPathName()[2] + ".psarc"))
{
packageName = packageName.Substring(0, packageName.LastIndexOf("_"));
}
var targetFileName = Path.Combine(Path.GetDirectoryName(sourcePackage), String.Format(nameTemplate, Path.Combine(Path.GetDirectoryName(sourcePackage), packageName), targetPlatform.GetPathName()[2]));
// CONVERSION
if (needRebuildPackage)
ConvertPackageRebuilding(unpackedDir, targetFileName, targetPlatform, appId);
else
ConvertPackageForSimilarPlatform(unpackedDir, targetFileName, sourcePlatform, targetPlatform, appId);
DirectoryExtension.SafeDelete(unpackedDir);
return String.Empty;
}
示例3: Convert
/// <summary>
/// Converts CDLC packages between platforms
/// </summary>
/// <param name="sourcePackage"></param>
/// <param name="sourcePlatform"></param>
/// <param name="targetPlatform"></param>
/// <param name="appId"></param>
/// <returns>Errors if any</returns>
public static string Convert(string sourcePackage, Platform sourcePlatform, Platform targetPlatform, string appId)
{
var needRebuildPackage = sourcePlatform.IsConsole != targetPlatform.IsConsole;
var tmpDir = Path.GetTempPath();
var unpackedDir = Packer.Unpack(sourcePackage, tmpDir, false, false, sourcePlatform);
// DESTINATION
var nameTemplate = (!targetPlatform.IsConsole) ? "{0}{1}.psarc" : "{0}{1}";
var packageName = Path.GetFileNameWithoutExtension(sourcePackage).StripPlatformEndName();
packageName = packageName.Replace(".","_");
var targetFileName = String.Format( nameTemplate, Path.Combine(Path.GetDirectoryName(sourcePackage), packageName), targetPlatform.GetPathName()[2] );
// CONVERSION
if (needRebuildPackage)
ConvertPackageRebuilding(unpackedDir, targetFileName, sourcePlatform, targetPlatform, appId);
else
ConvertPackageForSimilarPlatform(unpackedDir, targetFileName, sourcePlatform, targetPlatform, appId);
DirectoryExtension.SafeDelete(unpackedDir);
return String.Empty;
}
示例4: UpdateSng2014
private static void UpdateSng2014(string songDirectory, Platform targetPlatform, bool fixShowlights = true)
{
var xmlFiles = Directory.EnumerateFiles(Path.Combine(songDirectory, "songs", "arr"), "*_*.xml", SearchOption.AllDirectories).ToList();
var sngFolder = Path.Combine(songDirectory, "songs", "bin", targetPlatform.GetPathName()[1].ToLower()); //-3 or more times re-calculation
foreach (var xmlFile in xmlFiles)
{
if (File.Exists(xmlFile))
{
var xmlName = Path.GetFileNameWithoutExtension(xmlFile);
bool noShowlights = true;
//Update Showlights
if (xmlName.ToLower().Contains("_showlights"))
UpdateShl(xmlFile, fixShowlights: fixShowlights);
else
{
var sngFile = Path.Combine(sngFolder, xmlName + ".sng");
var arrType = ArrangementType.Guitar;
if (Path.GetFileName(xmlFile).ToLower().Contains("vocal"))
arrType = ArrangementType.Vocal;
// Handle custom fonts
string fontSng = null;
if (arrType == ArrangementType.Vocal)
{
var vocSng = Sng2014File.LoadFromFile(sngFile, TryGetPlatformByEndName(songDirectory));
if (vocSng.IsCustomFont())
{
vocSng.WriteChartData((fontSng = Path.GetTempFileName()), new Platform(GamePlatform.Pc, GameVersion.None));
}
}
using (var fs = new FileStream(sngFile, FileMode.Create))
{
var sng = Sng2014File.ConvertXML(xmlFile, arrType, fontSng);
sng.WriteSng(fs, targetPlatform);
}
noShowlights &= !xmlFiles.Any(x => Path.GetFileName(x).Contains(xmlName.Split('_')[0].ToLower() + "_showlights"));
//Create Showlights
if (noShowlights && arrType != ArrangementType.Vocal)
{
var shlName = Path.Combine(Path.GetDirectoryName(xmlFile), xmlName.Split('_')[0] + "_showlights.xml");
var shl = new Showlight.Showlights(xmlFile);
if (shl.FixShowlights(shl))
{
using (var fs = new FileStream(shlName, FileMode.Create))
shl.Serialize(fs);
}
}
}
}
}
}
示例5: UpdateSng
private static void UpdateSng(string songDirectory, Platform platform)
{
var xmlFiles = Directory.EnumerateFiles(Path.Combine(songDirectory, @"GR\Behaviors\Songs"));
foreach (var xmlFile in xmlFiles)
{
if (File.Exists(xmlFile) && Path.GetExtension(xmlFile) == ".xml")
{
var sngFile = Path.Combine(songDirectory, "GRExports", platform.GetPathName()[1], Path.GetFileNameWithoutExtension(xmlFile) + ".sng");
var arrType = ArrangementType.Guitar;
if (Path.GetFileName(xmlFile).ToLower().Contains("vocal"))
{
arrType = ArrangementType.Vocal;
SngFileWriter.Write(xmlFile, sngFile, arrType, platform);
}
else
{
Song song = Song.LoadFromFile(xmlFile);
if (!Enum.TryParse<ArrangementType>(song.Arrangement, out arrType))
if (song.Arrangement.ToLower().Contains("bass"))
arrType = ArrangementType.Bass;
}
SngFileWriter.Write(xmlFile, sngFile, arrType, platform);
}
else
{
throw new ArgumentException(String.Format("'{0}' is not a valid XML file.", xmlFile));
}
}
}
示例6: GenerateSongPsarcRS1
private static void GenerateSongPsarcRS1(Stream output, DLCPackageData info, Platform platform)
{
var soundBankName = String.Format("Song_{0}", info.Name);
try
{
Stream albumArtStream = null,
audioStream = null;
string albumArtPath;
if (File.Exists(info.AlbumArtPath)) {
albumArtPath = info.AlbumArtPath;
} else {
using (var defaultArtStream = new MemoryStream(Resources.albumart)) {
albumArtPath = GeneralExtensions.GetTempFileName(".dds");
defaultArtStream.WriteFile(albumArtPath);
defaultArtStream.Dispose();
TMPFILES_ART.Add(albumArtPath);
}
}
var ddsfiles = info.ArtFiles;
if (ddsfiles == null) {
ddsfiles = new List<DDSConvertedFile>();
ddsfiles.Add(new DDSConvertedFile() { sizeX = 512, sizeY = 512, sourceFile = albumArtPath, destinationFile = GeneralExtensions.GetTempFileName(".dds") });
ToDDS(ddsfiles);
// Save for reuse
info.ArtFiles = ddsfiles;
}
albumArtStream = new FileStream(ddsfiles[0].destinationFile, FileMode.Open, FileAccess.Read, FileShare.Read);
// AUDIO
var audioFile = info.OggPath;
if (File.Exists(audioFile))
if (platform.IsConsole != audioFile.GetAudioPlatform().IsConsole)
audioStream = OggFile.ConvertAudioPlatform(audioFile);
else
audioStream = File.OpenRead(audioFile);
else
throw new InvalidOperationException(String.Format("Audio file '{0}' not found.", audioFile));
using (var aggregateGraphStream = new MemoryStream())
using (var manifestStream = new MemoryStream())
using (var xblockStream = new MemoryStream())
using (var soundbankStream = new MemoryStream())
using (var packageIdStream = new MemoryStream())
using (var soundStream = OggFile.ConvertOgg(audioStream))
using (var arrangementFiles = new DisposableCollection<Stream>()) {
var manifestBuilder = new ManifestBuilder {
AggregateGraph = new AggregateGraph.AggregateGraph {
SoundBank = new SoundBank { File = soundBankName + ".bnk" },
AlbumArt = new AlbumArt { File = info.AlbumArtPath }
}
};
foreach (var x in info.Arrangements) {
//Generate sng file in execution time
GenerateSNG(x, platform);
manifestBuilder.AggregateGraph.SongFiles.Add(x.SongFile);
manifestBuilder.AggregateGraph.SongXMLs.Add(x.SongXml);
}
manifestBuilder.AggregateGraph.XBlock = new XBlockFile { File = info.Name + ".xblock" };
manifestBuilder.AggregateGraph.Write(info.Name, platform.GetPathName(), platform, aggregateGraphStream);
aggregateGraphStream.Flush();
aggregateGraphStream.Seek(0, SeekOrigin.Begin);
{
var manifestData = manifestBuilder.GenerateManifest(info.Name, info.Arrangements, info.SongInfo, platform);
var writer = new StreamWriter(manifestStream);
writer.Write(manifestData);
writer.Flush();
manifestStream.Seek(0, SeekOrigin.Begin);
}
GameXblock<Entity>.Generate(info.Name, manifestBuilder.Manifest, manifestBuilder.AggregateGraph, xblockStream);
xblockStream.Flush();
xblockStream.Seek(0, SeekOrigin.Begin);
var soundFileName = SoundBankGenerator.GenerateSoundBank(info.Name, soundStream, soundbankStream, info.Volume, platform);
soundbankStream.Flush();
soundbankStream.Seek(0, SeekOrigin.Begin);
GenerateSongPackageId(packageIdStream, info.Name);
var songPsarc = new PSARC.PSARC();
songPsarc.AddEntry("PACKAGE_ID", packageIdStream);
songPsarc.AddEntry("AggregateGraph.nt", aggregateGraphStream);
songPsarc.AddEntry("Manifests/songs.manifest.json", manifestStream);
songPsarc.AddEntry(String.Format("Exports/Songs/{0}.xblock", info.Name), xblockStream);
songPsarc.AddEntry(String.Format("Audio/{0}/{1}.bnk", platform.GetPathName()[0], soundBankName), soundbankStream);
songPsarc.AddEntry(String.Format("Audio/{0}/{1}.ogg", platform.GetPathName()[0], soundFileName), soundStream);
songPsarc.AddEntry(String.Format("GRAssets/AlbumArt/{0}.dds", manifestBuilder.AggregateGraph.AlbumArt.Name), albumArtStream);
foreach (var x in info.Arrangements) {
var xmlFile = File.OpenRead(x.SongXml.File);
arrangementFiles.Add(xmlFile);
var sngFile = File.OpenRead(x.SongFile.File);
//.........这里部分代码省略.........
示例7: GenerateRS2014SongPsarc
//.........这里部分代码省略.........
using (var soundbankStream = new MemoryStream())
using (var soundbankPreviewStream = new MemoryStream())
using (var aggregateGraphStream = new MemoryStream())
using (var manifestHeaderHSANStream = new MemoryStream())
using (var manifestHeaderHSONStreamList = new DisposableCollection<Stream>())
using (var manifestStreamList = new DisposableCollection<Stream>())
using (var arrangementStream = new DisposableCollection<Stream>())
using (var showlightStream = new MemoryStream())
using (var xblockStream = new MemoryStream())
{
// TOOLKIT VERSION
GenerateToolkitVersion(toolkitVersionStream, info.PackageVersion);
packPsarc.AddEntry("toolkit.version", toolkitVersionStream);
// APP ID
if (!platform.IsConsole)
{
GenerateAppId(appIdStream, info.AppId, platform);
packPsarc.AddEntry("appid.appid", appIdStream);
}
if (platform.platform == GamePlatform.XBox360) {
var packageListWriter = new StreamWriter(packageListStream);
packageListWriter.Write(dlcName);
packageListWriter.Flush();
packageListStream.Seek(0, SeekOrigin.Begin);
string packageList = "PackageList.txt";
packageListStream.WriteTmpFile(packageList, platform);
}
// SOUNDBANK
var soundbankFileName = String.Format("song_{0}", dlcName);
var audioFileNameId = SoundBankGenerator2014.GenerateSoundBank(info.Name, soundStream, soundbankStream, info.Volume, platform);
packPsarc.AddEntry(String.Format("audio/{0}/{1}.bnk", platform.GetPathName()[0].ToLower(), soundbankFileName), soundbankStream);
packPsarc.AddEntry(String.Format("audio/{0}/{1}.wem", platform.GetPathName()[0].ToLower(), audioFileNameId), soundStream);
// SOUNDBANK PREVIEW
var soundbankPreviewFileName = String.Format("song_{0}_preview", dlcName);
dynamic audioPreviewFileNameId;
var previewVolume = (info.PreviewVolume != null) ? (float)info.PreviewVolume : info.Volume;
if (!soundPreviewStream.Equals(soundStream))
audioPreviewFileNameId = SoundBankGenerator2014.GenerateSoundBank(info.Name + "_Preview", soundPreviewStream, soundbankPreviewStream, previewVolume, platform, true);
else
audioPreviewFileNameId = SoundBankGenerator2014.GenerateSoundBank(info.Name + "_Preview", soundPreviewStream, soundbankPreviewStream, info.Volume, platform, true, true);
packPsarc.AddEntry(String.Format("audio/{0}/{1}.bnk", platform.GetPathName()[0].ToLower(), soundbankPreviewFileName), soundbankPreviewStream);
if (!soundPreviewStream.Equals(soundStream)) packPsarc.AddEntry(String.Format("audio/{0}/{1}.wem", platform.GetPathName()[0].ToLower(), audioPreviewFileNameId), soundPreviewStream);
// AGGREGATE GRAPH
var aggregateGraphFileName = String.Format("{0}_aggregategraph.nt", dlcName);
var aggregateGraph = new AggregateGraph2014(info, platform);
aggregateGraph.Serialize(aggregateGraphStream);
aggregateGraphStream.Flush();
aggregateGraphStream.Seek(0, SeekOrigin.Begin);
packPsarc.AddEntry(aggregateGraphFileName, aggregateGraphStream);
var manifestHeader = new ManifestHeader2014<AttributesHeader2014>(platform);
var songPartition = new SongPartition();
var songPartitionCount = new SongPartition();
foreach (var arrangement in info.Arrangements)
{
var arrangementFileName = songPartition.GetArrangementFileName(arrangement.Name, arrangement.ArrangementType).ToLower();
// GAME SONG (SNG)
UpdateToneDescriptors(info);
GenerateSNG(arrangement, platform);
示例8: Generate
public static void Generate(string packagePath, DLCPackageData info, Platform platform, DLCPackageType dlcType = DLCPackageType.Song)
{
switch (platform.platform)
{
case GamePlatform.XBox360:
if (!Directory.Exists(XBOX_WORKDIR))
Directory.CreateDirectory(XBOX_WORKDIR);
break;
case GamePlatform.PS3:
if (!Directory.Exists(PS3_WORKDIR))
Directory.CreateDirectory(PS3_WORKDIR);
break;
}
using (var packPsarcStream = new MemoryStream())
{
switch (platform.version)
{
case GameVersion.RS2014:
switch (dlcType)
{
case DLCPackageType.Song:
GenerateRS2014SongPsarc(packPsarcStream, info, platform);
break;
case DLCPackageType.Lesson:
throw new NotImplementedException("Lesson package type not implemented yet :(");
case DLCPackageType.Inlay:
GenerateRS2014InlayPsarc(packPsarcStream, info, platform);
break;
}
break;
case GameVersion.RS2012:
GeneratePsarcsForRS1(packPsarcStream, info, platform);
break;
case GameVersion.None:
throw new InvalidOperationException("Unexpected game version value");
}
var packageName = Path.GetFileNameWithoutExtension(packagePath).StripPlatformEndName();
var songFileName = String.Format("{0}{1}", Path.Combine(Path.GetDirectoryName(packagePath), packageName), platform.GetPathName()[2]);
switch (platform.platform)
{
case GamePlatform.Pc:
case GamePlatform.Mac:
switch (platform.version)
{
// SAVE PACKAGE
case GameVersion.RS2014:
using (FileStream fl = File.Create(songFileName + ".psarc"))
packPsarcStream.CopyTo(fl);
break;
case GameVersion.RS2012:
using (var fl = File.Create(songFileName + ".dat"))
RijndaelEncryptor.EncryptFile(packPsarcStream, fl, RijndaelEncryptor.DLCKey);
break;
default:
throw new InvalidOperationException("Unexpected game version value");
}
break;
case GamePlatform.XBox360:
BuildXBox360Package(songFileName, info, FILES_XBOX, platform.version, dlcType);
break;
case GamePlatform.PS3:
EncryptPS3EdatFiles(songFileName + ".psarc", platform);
break;
}
}
FILES_XBOX.Clear();
FILES_PS3.Clear();
DeleteTmpFiles(TMPFILES_SNG);
}
示例9: GenerateRS2014SongPsarc
//.........这里部分代码省略.........
using (var soundbankPreviewStream = new MemoryStream())
using (var aggregateGraphStream = new MemoryStream())
using (var manifestHeaderHSANStream = new MemoryStream())
using (var manifestHeaderHSONStreamList = new DisposableCollection<Stream>())
using (var manifestStreamList = new DisposableCollection<Stream>())
using (var arrangementStream = new DisposableCollection<Stream>())
using (var showlightStream = new MemoryStream())
using (var xblockStream = new MemoryStream())
{
// TOOLKIT VERSION
var stopHere = info;
GenerateToolkitVersion(toolkitVersionStream, info.ToolkitInfo.PackageAuthor, info.ToolkitInfo.PackageVersion, info.ToolkitInfo.PackageComment);
packPsarc.AddEntry("toolkit.version", toolkitVersionStream);
// APP ID
if (!platform.IsConsole)
{
GenerateAppId(appIdStream, info.AppId, platform);
packPsarc.AddEntry("appid.appid", appIdStream);
}
if (platform.platform == GamePlatform.XBox360)
{
var packageListWriter = new StreamWriter(packageListStream);
packageListWriter.Write(dlcName);
packageListWriter.Flush();
packageListStream.Seek(0, SeekOrigin.Begin);
packageListStream.WriteTmpFile("PackageList.txt", platform);
}
// SOUNDBANK
var soundbankFileName = String.Format("song_{0}", dlcName);
var audioFileNameId = SoundBankGenerator2014.GenerateSoundBank(info.Name, soundStream, soundbankStream, info.Volume, platform);
packPsarc.AddEntry(String.Format("audio/{0}/{1}.bnk", platform.GetPathName()[0].ToLower(), soundbankFileName), soundbankStream);
packPsarc.AddEntry(String.Format("audio/{0}/{1}.wem", platform.GetPathName()[0].ToLower(), audioFileNameId), soundStream);
// SOUNDBANK PREVIEW
var soundbankPreviewFileName = String.Format("song_{0}_preview", dlcName);
dynamic audioPreviewFileNameId;
var previewVolume = info.PreviewVolume ?? info.Volume;
audioPreviewFileNameId = SoundBankGenerator2014.GenerateSoundBank(info.Name + "_Preview", soundPreviewStream, soundbankPreviewStream, previewVolume, platform, true, !(File.Exists(previewAudioFile)));
packPsarc.AddEntry(String.Format("audio/{0}/{1}.bnk", platform.GetPathName()[0].ToLower(), soundbankPreviewFileName), soundbankPreviewStream);
if (!soundPreviewStream.Equals(soundStream)) packPsarc.AddEntry(String.Format("audio/{0}/{1}.wem", platform.GetPathName()[0].ToLower(), audioPreviewFileNameId), soundPreviewStream);
// AGGREGATE GRAPH
var aggregateGraphFileName = String.Format("{0}_aggregategraph.nt", dlcName);
var aggregateGraph = new AggregateGraph2014.AggregateGraph2014(info, platform);
aggregateGraph.Serialize(aggregateGraphStream);
aggregateGraphStream.Flush();
aggregateGraphStream.Seek(0, SeekOrigin.Begin);
packPsarc.AddEntry(aggregateGraphFileName, aggregateGraphStream);
var manifestHeader = new ManifestHeader2014<AttributesHeader2014>(platform);
var songPartition = new SongPartition();
var songPartitionCount = new SongPartition();
foreach (var arrangement in info.Arrangements)
{
if (arrangement.ArrangementType == ArrangementType.ShowLight)
continue;
var arrangementFileName = songPartition.GetArrangementFileName(arrangement.Name, arrangement.ArrangementType).ToLower();
// GAME SONG (SNG)
UpdateToneDescriptors(info);
GenerateSNG(arrangement, platform);
示例10: UpdateSng2014
private static void UpdateSng2014(string songDirectory, Platform platform)
{
var xmlFiles = Directory.GetFiles(Path.Combine(songDirectory, "songs", "arr"), "*_*.xml", SearchOption.AllDirectories);
var sngFolder = Path.Combine(songDirectory, "songs", "bin", platform.GetPathName()[1]); //-3 or more times re-calculation
foreach (var xmlFile in xmlFiles)
{
if (File.Exists(xmlFile))
{
var xmlName = Path.GetFileNameWithoutExtension(xmlFile);
bool noShowlights = true;
//Update Showlights
if (xmlName.ToLower().Contains("_showlights"))
updateShl(xmlFile);
else
{
var sngFile = Path.Combine(sngFolder, xmlName + ".sng");
var arrType = ArrangementType.Guitar;
if (Path.GetFileName(xmlFile).ToLower().Contains("vocal"))
arrType = ArrangementType.Vocal;
using (FileStream fs = new FileStream(sngFile, FileMode.Create)) {
Sng2014File sng = Sng2014File.ConvertXML(xmlFile, arrType);
sng.WriteSng(fs, platform);
}
if (xmlFiles.Any(x => Path.GetFileName(x).Contains(xmlName.Split('_')[0].ToLower() + "_showlights")))
noShowlights = false;
//Create Showlights
if (noShowlights && arrType != ArrangementType.Vocal)
{
var shlName = Path.Combine(Path.GetDirectoryName(xmlFile), xmlName.Split('_')[0] + "_showlights.xml");
var shl = new RocksmithToolkitLib.DLCPackage.Showlight.Showlights();
if (shl.PopShList(shl.FixShowlights(shl.Genegate(xmlFile).ShowlightList)))
{
shl.Count = shl.ShowlightList.Count;
using (var fs = new FileStream(shlName, FileMode.Create))
shl.Serialize(fs);
noShowlights = false;
}
}
}
}
}
}