Skip to content
Permalink
Browse files

- DDC tab menu reports errors correctly instead of throwing a mislead…

…ing exception

- Import Package will autosave xml template if General Config>Autosave Templates is enabled
  (turn off autosave if you do not want to unknowingly overwrite existing xml templates)
- use existing wem files if provided without checking for Wwise installation
  • Loading branch information...
cozy1 committed May 16, 2019
1 parent 8c0983e commit 7375af81b18d1427fd0677e2917f4e49071f0572

Large diffs are not rendered by default.

@@ -100,14 +100,24 @@ private int ApplyPackageDD(string srcPath, int phraseLen, bool removeSus, string
{
// validate existing SongInfo
var songXml = Song2014.LoadFromFile(arr.SongXml.File);
songXml.AlbumYear = packageData.SongInfo.SongYear.ToString().GetValidYear();
songXml.ArtistName = packageData.SongInfo.Artist.GetValidAtaSpaceName();
songXml.Title = packageData.SongInfo.SongDisplayName.GetValidAtaSpaceName();
songXml.AlbumName = packageData.SongInfo.Album.GetValidAtaSpaceName();
songXml.ArtistNameSort = packageData.SongInfo.ArtistSort.GetValidSortableName();
songXml.SongNameSort = packageData.SongInfo.SongDisplayNameSort.GetValidSortableName();
songXml.AlbumNameSort = packageData.SongInfo.AlbumSort.GetValidSortableName();
songXml.AverageTempo = Convert.ToSingle(packageData.SongInfo.AverageTempo.ToString().GetValidTempo());
songXml.AlbumYear = packageData.SongInfo.SongYear.ToString().GetValidYear();

// update packageData with validated SongInfo
packageData.SongInfo.Artist = songXml.ArtistName;
packageData.SongInfo.SongDisplayName = songXml.Title;
packageData.SongInfo.Album = songXml.AlbumName;
packageData.SongInfo.ArtistSort = songXml.ArtistNameSort;
packageData.SongInfo.SongDisplayNameSort = songXml.SongNameSort;
packageData.SongInfo.AlbumSort = songXml.AlbumNameSort;
packageData.SongInfo.AverageTempo = (int)songXml.AverageTempo;
packageData.SongInfo.SongYear = Convert.ToInt32(songXml.AlbumYear);

// write updated xml arrangement
using (var stream = File.Open(arr.SongXml.File, FileMode.Create))
@@ -575,41 +585,44 @@ private void bw_Completed(object sender, RunWorkerCompletedEventArgs e)
// file overwriting is done here as last step
pbUpdateProgress.Value = 100;

foreach (var file in FilesDb)
if (e.Result.Equals(0))
{
switch (Path.GetExtension(file.Value))
foreach (var file in FilesDb)
{
case ".xml": // Arrangement
{
var fileDir = Path.GetDirectoryName(file.Value);
var ddcArrXML = Path.Combine(fileDir, String.Format("DDC_{0}.xml", file.Key));
var srcShowlights = Path.Combine(fileDir, String.Format("{0}_showlights.xml", file.Key));
var destShowlights = Path.Combine(fileDir, String.Format("DDC_{0}_showlights.xml", file.Key));
switch (Path.GetExtension(file.Value))
{
case ".xml": // Arrangement
{
var fileDir = Path.GetDirectoryName(file.Value);
var ddcArrXML = Path.Combine(fileDir, String.Format("DDC_{0}.xml", file.Key));
var srcShowlights = Path.Combine(fileDir, String.Format("{0}_showlights.xml", file.Key));
var destShowlights = Path.Combine(fileDir, String.Format("DDC_{0}_showlights.xml", file.Key));

if (!chkOverwrite.Checked && !File.Exists(destShowlights) && File.Exists(srcShowlights) && File.Exists(ddcArrXML))
File.Copy(srcShowlights, destShowlights, true);
}
break;
if (!chkOverwrite.Checked && !File.Exists(destShowlights) && File.Exists(srcShowlights) && File.Exists(ddcArrXML))
File.Copy(srcShowlights, destShowlights, true);
}
break;

case ".psarc": // PC / Mac (RS2014)
case ".dat": // PC (RS1)
case ".edat": // PS3
case "": // XBox 360
if (chkOverwrite.Checked)
{
var filePath = file.Value;
var ddcFilePath = GenerateDdcFilePath(filePath);
if (!ddcFilePath.Equals(filePath))
case ".psarc": // PC / Mac (RS2014)
case ".dat": // PC (RS1)
case ".edat": // PS3
case "": // XBox 360
if (chkOverwrite.Checked)
{
// File.Move is prone to exceptions
File.Copy(ddcFilePath, filePath, true);
File.Delete(ddcFilePath);
var filePath = file.Value;
var ddcFilePath = GenerateDdcFilePath(filePath);
if (!ddcFilePath.Equals(filePath))
{
// File.Move is prone to exceptions
File.Copy(ddcFilePath, filePath, true);
File.Delete(ddcFilePath);
}
}
}
break;
}
break;
}

Invoke(new MethodInvoker(() => RemoveEntry(file.Value)));
Invoke(new MethodInvoker(() => RemoveEntry(file.Value)));
}
}

FilesDb.Clear();
@@ -594,6 +594,7 @@ public string SaveTemplateFile(string templateDir = "", bool validate = true)
if (!String.IsNullOrEmpty(arr.FontSng))
arr.FontSng = arr.FontSng.RelativeTo(BasePath);
}

try
{
using (var stm = XmlWriter.Create(templatePath, new XmlWriterSettings { CheckCharacters = true, Indent = true }))
@@ -918,15 +919,15 @@ public void FillPackageCreatorForm(DLCPackageData info, string filesBaseDir)
SelectComboAppId(AppId);

// validate on-load to address old CDLC issues
txtAlbum.Text = info.SongInfo.Album;
txtAlbum.Text = info.SongInfo.Album.GetValidAtaSpaceName();
txtAlbumSort.Text = info.SongInfo.AlbumSort.GetValidSortableName();
txtJapaneseSongTitle.Text = info.SongInfo.JapaneseSongName;
txtJapaneseArtistName.Text = info.SongInfo.JapaneseArtistName;
chkJapaneseTitle.Checked = !string.IsNullOrEmpty(txtJapaneseSongTitle.Text) || !string.IsNullOrEmpty(txtJapaneseArtistName.Text);
txtSongTitle.Text = info.SongInfo.SongDisplayName;
txtSongTitle.Text = info.SongInfo.SongDisplayName.GetValidAtaSpaceName();
txtSongTitleSort.Text = info.SongInfo.SongDisplayNameSort.GetValidSortableName();
txtYear.Text = info.SongInfo.SongYear.ToString();
txtArtist.Text = info.SongInfo.Artist;
txtArtist.Text = info.SongInfo.Artist.GetValidAtaSpaceName();
txtArtistSort.Text = info.SongInfo.ArtistSort.GetValidSortableName();
txtTempo.Text = info.SongInfo.AverageTempo.ToString();

@@ -1643,20 +1644,30 @@ private void btnArrangementAdd_Click(object sender, EventArgs e)
private void btnPackageGenerate_Click(object sender, EventArgs e)
{
var diaMsg = String.Empty;
var wwisePath = Wwise.GetWwisePath();
var wwiseVersion = FileVersionInfo.GetVersionInfo(wwisePath).ProductVersion;
if (CurrentGameVersion == GameVersion.RS2012 && !wwiseVersion.StartsWith("2010.3"))

if (CurrentGameVersion == GameVersion.RS2014 &&
Path.GetExtension(AudioPath) == ".wem" &&
File.Exists(String.Format(Path.Combine(Path.GetDirectoryName(AudioPath), Path.GetFileNameWithoutExtension(AudioPath)) + "_preview.wem")))
{
diaMsg = "Configuration Wwise Path is not set properly for RS1 ...";
BetterDialog2.ShowDialog(diaMsg, "Generate Button", null, null, "Ok", Bitmap.FromHicon(SystemIcons.Error.Handle), "Error", 150, 150);
return;
// use existing wem files without checking Wwise installation
}

if (CurrentGameVersion != GameVersion.RS2012 && wwiseVersion.StartsWith("2010"))
else
{
diaMsg = "Configuration Wwise Path is not set properly for RS2014 or Conversions ...";
BetterDialog2.ShowDialog(diaMsg, "Generate Button", null, null, "Ok", Bitmap.FromHicon(SystemIcons.Error.Handle), "Error", 150, 150);
return;
var wwisePath = Wwise.GetWwisePath();
var wwiseVersion = FileVersionInfo.GetVersionInfo(wwisePath).ProductVersion;
if (CurrentGameVersion == GameVersion.RS2012 && !wwiseVersion.StartsWith("2010.3"))
{
diaMsg = "Configuration Wwise Path is not set properly for RS1 ...";
BetterDialog2.ShowDialog(diaMsg, "Generate Button", null, null, "Ok", Bitmap.FromHicon(SystemIcons.Error.Handle), "Error", 150, 150);
return;
}

if (CurrentGameVersion != GameVersion.RS2012 && wwiseVersion.StartsWith("2010"))
{
diaMsg = "Configuration Wwise Path is not set properly for RS2014 or Conversions ...";
BetterDialog2.ShowDialog(diaMsg, "Generate Button", null, null, "Ok", Bitmap.FromHicon(SystemIcons.Error.Handle), "Error", 150, 150);
return;
}
}

if (String.IsNullOrEmpty(ArtistSort) || String.IsNullOrEmpty(SongTitleSort) || String.IsNullOrEmpty(PackageVersion) || String.IsNullOrEmpty(DLCKey))
@@ -2005,6 +2016,10 @@ private void btnPackageImport_Click(object sender, EventArgs e)
}

PackageImport(srcPath, destDir);

// autosave the dlc.xml template on first load
if (ConfigRepository.Instance().GetBoolean("creator_autosavetemplate"))
SaveTemplateFile(UnpackedDir, false);
}

/// <summary>
@@ -133,7 +133,7 @@ This can produce undesired results.
It is recommended that you delete
any existing *_preview.* audio files
first to ensure that the toolkit auto
generate them correctly. Unless of
generates them correctly. Unless of
course that is your desired effect to
have customized preview audio.</value>
</data>
@@ -225,17 +225,19 @@ public List<string> UnpackSongs(IEnumerable<string> srcPaths, string destPath)
break;
}

packageCreator.FillPackageCreatorForm(info, unpackedDir);
// fix descrepancies
packageCreator.CurrentGameVersion = srcPlatform.version;
// console files do not have an AppId
if (!srcPlatform.IsConsole)
packageCreator.AppId = info.AppId;
//packageCreator.SelectComboAppId(info.AppId);
// save template xml file except when SongPack
if (!srcPath.Contains("_sp_") && !srcPath.Contains("_songpack_"))
packageCreator.SaveTemplateFile(unpackedDir, false);
// save template xml file (except SongPacks)
if (ConfigRepository.Instance().GetBoolean("creator_autosavetemplate") &&
!srcPath.Contains("_sp_") && !srcPath.Contains("_songpack_"))
{
packageCreator.FillPackageCreatorForm(info, unpackedDir);
// fix descrepancies
packageCreator.CurrentGameVersion = srcPlatform.version;
// console files do not have an AppId
if (!srcPlatform.IsConsole)
packageCreator.AppId = info.AppId;

packageCreator.SaveTemplateFile(unpackedDir, false);
}
}

unpackedDirs.Add(unpackedDir);
@@ -221,8 +221,8 @@ public void ReloadControls()
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
// autosave the dlc.xml template on closing
//if (dlcPackageCreator1.IsDirty && ConfigRepository.Instance().GetBoolean("creator_autosavetemplate"))
// dlcPackageCreator1.SaveTemplateFile(dlcPackageCreator1.UnpackedDir, false);
if (dlcPackageCreator1.IsDirty && ConfigRepository.Instance().GetBoolean("creator_autosavetemplate"))
dlcPackageCreator1.SaveTemplateFile(dlcPackageCreator1.UnpackedDir, false);

// leave temp folder contents for developer debugging
if (GeneralExtension.IsInDesignMode)
@@ -29,5 +29,5 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.9.2.0")]
[assembly: AssemblyInformationalVersion("e43e7565")]
[assembly: AssemblyInformationalVersion("8c0983e6")]
[assembly: AssemblyConfiguration("")]
@@ -1,6 +1,10 @@
Rocksmith Toolkit Release Notes

- fix invalid artifact naming so that unpacker can extract recoverable data
- DDC tab menu reports errors correctly instead of throwing a misleading exception
- Import Package will autosave xml template if General Config>Autosave Templates is enabled
(turn off autosave if you do not want to unknowingly overwrite existing xml templates)
- use existing wem files if provided without checking for Wwise installation
- fix invalid artifact naming so that unpacker can extract any recoverable data
- prevent Unpacker CLI from redirecting standard output for dds to png conversions
- added error handler for TreeViewOfd exceptions
- added additional flexibility to Quick Add feature
@@ -22,6 +22,7 @@
using RocksmithToolkitLib.XmlRepository;
using System.Diagnostics;
using System.Drawing;
using System.Reflection;

namespace RocksmithToolkitLib.DLCPackage
{
@@ -568,13 +569,23 @@ public static DLCPackageData LoadFromFolder(string unpackedDir, Platform targetP
var xmlName = attr.SongXml.Split(':')[3];
var xmlFile = Directory.EnumerateFiles(unpackedDir, xmlName + ".xml", SearchOption.AllDirectories).FirstOrDefault();

// throw exception for corrupt/missing XML file names
if (!File.Exists(xmlFile))
{
var artifactsDir = unpackedDir;
StackTrace stackTrace = new StackTrace();
var callerName = stackTrace.GetFrame(1).GetMethod().Name;

if (callerName.Equals("PackageImport") && ConfigRepository.Instance().GetBoolean("creator_structured"))
artifactsDir = Path.Combine(unpackedDir, "EOF");

throw new DataException(Environment.NewLine + Environment.NewLine + "*** READ ME *** READ ME *** READ ME ***" + Environment.NewLine + Environment.NewLine +
"<WARNING> CDLC artifact file naming is corrupt ..." + Environment.NewLine +
"1) Open the artifacts folder: " + Path.Combine(unpackedDir, "EOF") + Environment.NewLine +
"1) Open the artifacts folder: " + artifactsDir + " " + Environment.NewLine +
"2) Look for and rename any artifact file names that contain the '~' tilde character" + Environment.NewLine +
"3) (re)Author the CDLC like from an EOF project using: >CDLC Creator>Add>Edit>Generate" + Environment.NewLine + Environment.NewLine);

GlobalExtension.HideProgress();
}

if (attr.Phrases != null)
@@ -98,7 +98,7 @@ public static string GetValidAtaSpaceName(this string value)
// allow use of only these special characters \\-_ /&.:',!?()\"#
// allow use of alphanumerics a-zA-Z0-9
// tested and working ... Üuber!@#$%^&*()_+=-09{}][":';<>.,?/ñice

value = value.ReplaceSpecialCharacters();
Regex rgx = new Regex("[^a-zA-Z0-9\\-_/&:',!.?()\"#\\p{L} ]*");
value = rgx.Replace(value, "");
// commented out because some ODLC have these
@@ -247,6 +247,7 @@ public static string GetValidSortableName(this string value)
return String.Empty;

// processing order is important to achieve output like ODLC
value = value.ReplaceSpecialCharacters();
value = value.ReplaceAbbreviations();
value = value.ReplaceDiacritics();
value = value.StripSpecialCharacters();
@@ -538,6 +539,14 @@ public static string ReplaceSpaceWith(this string value, string replacementValue
return result;
}


public static string ReplaceSpecialCharacters(this string value)
{
// tilde not used in ODLC
var result = value.Replace('~', '-');
return result;
}

public static string RestoreCRLF(this string value)
{
// replace single lf with crlf
@@ -27,5 +27,5 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.9.2.0")]
[assembly: AssemblyInformationalVersion("e43e7565")]
[assembly: AssemblyInformationalVersion("8c0983e6")]
[assembly: AssemblyConfiguration("")]
@@ -1308,13 +1308,21 @@ private void numberNotes(Sng2014File sng, Notes[] notes)
continue;
}

// are we past phrase iteration boundary?
if (current.Time > sng.PhraseIterations.PhraseIterations[p].NextPhraseTime)
try
{
// are we past phrase iteration boundary?
if (current.Time > sng.PhraseIterations.PhraseIterations[p].NextPhraseTime)
{
// advance and re-run
// will be repeated through empty iterations
++p;
o = o - 1;
continue;
}
}
catch (Exception ex)
{
// advance and re-run
// will be repeated through empty iterations
++p;
o = o - 1;
// workaround for rare conversion exception 'Index was outside the bounds of the array'
continue;
}

@@ -29,5 +29,5 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.9.2.0")]
[assembly: AssemblyInformationalVersion("e43e7565")]
[assembly: AssemblyInformationalVersion("8c0983e6")]
[assembly: AssemblyConfiguration("")]
@@ -1,3 +1,3 @@
2.9.2.0
e43e7565
8c0983e6

0 comments on commit 7375af8

Please sign in to comment.
You can’t perform that action at this time.