[DatFile] Fixes for split by level

This commit is contained in:
Matt Nadareski
2016-10-26 14:59:12 -07:00
parent b76099ba7a
commit bf2f3d5f64

View File

@@ -338,7 +338,7 @@ namespace SabreTools.Helper.Dats
+ rom.SourceID.ToString().PadLeft(10, '0') + "-") + rom.SourceID.ToString().PadLeft(10, '0') + "-")
+ (String.IsNullOrEmpty(rom.Machine.Name) + (String.IsNullOrEmpty(rom.Machine.Name)
? "Default" ? "Default"
: rom.Machine.Name.ToLowerInvariant()); : rom.Machine.Name);
newkey = HttpUtility.HtmlEncode(newkey); newkey = HttpUtility.HtmlEncode(newkey);
if (sortable.ContainsKey(newkey)) if (sortable.ContainsKey(newkey))
{ {
@@ -5290,17 +5290,18 @@ namespace SabreTools.Helper.Dats
if (tempDat.Name != null && tempDat.Name != Path.GetDirectoryName(key)) if (tempDat.Name != null && tempDat.Name != Path.GetDirectoryName(key))
{ {
// Get the path that the file will be written out to // Get the path that the file will be written out to
string path = (String.IsNullOrEmpty(tempDat.Name) string path = HttpUtility.HtmlDecode(String.IsNullOrEmpty(tempDat.Name)
? outDir ? outDir
: Path.Combine(outDir, tempDat.Name)); : Path.Combine(outDir, tempDat.Name));
// Now use the original DAT values and append the path to them // Now set the new output values
tempDat.FileName += " (" + tempDat.Name.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-') + ")"; tempDat.FileName = HttpUtility.HtmlDecode(String.IsNullOrEmpty(tempDat.Name) ? FileName : Path.GetFileName(tempDat.Name));
tempDat.Description += " (" + tempDat.Name.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-') + ")"; tempDat.Description += " (" + tempDat.Name.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-') + ")";
tempDat.Name = Name + " (" + tempDat.Name.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-') + ")"; tempDat.Name = Name + " (" + tempDat.Name.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-') + ")";
tempDat.Type = null;
// Write out the temporary DAT to the proper directory // Write out the temporary DAT to the proper directory
WriteToFile(path, logger); tempDat.WriteToFile(path, logger);
// Reset the DAT for the next items // Reset the DAT for the next items
tempDat = (DatFile)CloneHeader(); tempDat = (DatFile)CloneHeader();
@@ -5310,6 +5311,7 @@ namespace SabreTools.Helper.Dats
// Clean the input list and set all games to be pathless // Clean the input list and set all games to be pathless
List<DatItem> items = Files[key]; List<DatItem> items = Files[key];
items.ForEach(item => item.Machine.Name = Path.GetFileName(item.Machine.Name)); items.ForEach(item => item.Machine.Name = Path.GetFileName(item.Machine.Name));
items.ForEach(item => item.Machine.Description = Path.GetFileName(item.Machine.Description));
// Now add the game to the output DAT // Now add the game to the output DAT
if (tempDat.Files.ContainsKey(key)) if (tempDat.Files.ContainsKey(key))