diff --git a/DATabase/MergeDiff.cs b/DATabase/MergeDiff.cs
index 1bdc6340..6451b1f0 100644
--- a/DATabase/MergeDiff.cs
+++ b/DATabase/MergeDiff.cs
@@ -140,7 +140,18 @@ namespace SabreTools
post = " (No Duplicates)";
// Output the difflist (a-b)+(b-a) diff
- Output.WriteToDatFromDict(_name + post, _desc + post, _version, _date, _cat, _author, _forceunpack, _old, _dedup, "", diffed, _logger);
+ DatData outerDiffData = new DatData
+ {
+ Name = _name + post,
+ Description = _desc + post,
+ Version = _version,
+ Date = _date,
+ Category = _cat,
+ Author = _author,
+ ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
+ OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
+ };
+ Output.WriteToDatFromDict(outerDiffData, _dedup, "", diffed, _logger);
// For the AB mode-style diffs, get all required dictionaries and output with a new name
// Loop through _inputs first and filter from all diffed roms to find the ones that have the same "System"
@@ -168,7 +179,19 @@ namespace SabreTools
}
post = " (" + Path.GetFileNameWithoutExtension(_inputs[j]) + " Only)";
- Output.WriteToDatFromDict(_name + post, _desc + post, _version, _date, _cat, _author, _forceunpack, _old, _dedup, "", sysDict, _logger);
+
+ DatData diffData = new DatData
+ {
+ Name = _name + post,
+ Description = _desc + post,
+ Version = _version,
+ Date = _date,
+ Category = _cat,
+ Author = _author,
+ ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
+ OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
+ };
+ Output.WriteToDatFromDict(diffData, _dedup, "", sysDict, _logger);
}
// Get all entries that have External dupes
@@ -196,12 +219,35 @@ namespace SabreTools
}
}
}
- Output.WriteToDatFromDict(_name + post, _desc + post, _version, _date, _cat, _author, _forceunpack, _old, _dedup, "", duplicates, _logger);
+
+ DatData dupeData = new DatData
+ {
+ Name = _name + post,
+ Description = _desc + post,
+ Version = _version,
+ Date = _date,
+ Category = _cat,
+ Author = _author,
+ ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
+ OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
+ };
+ Output.WriteToDatFromDict(dupeData, _dedup, "", duplicates, _logger);
}
// Output all entries with user-defined merge
else
{
- Output.WriteToDatFromDict(_name, _desc, _version, _date, _cat, _author, _forceunpack, _old, _dedup, "", dict, _logger);
+ DatData userData = new DatData
+ {
+ Name = _name,
+ Description = _desc,
+ Version = _version,
+ Date = _date,
+ Category = _cat,
+ Author = _author,
+ ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
+ OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
+ };
+ Output.WriteToDatFromDict(userData, _dedup, "", dict, _logger);
}
return true;
diff --git a/DATabaseTwo/Generate.cs b/DATabaseTwo/Generate.cs
index 0b98bfcd..775d0c68 100644
--- a/DATabaseTwo/Generate.cs
+++ b/DATabaseTwo/Generate.cs
@@ -225,7 +225,18 @@ namespace SabreTools
}
// Then write out the file
- Output.WriteToDatFromDict(name, description, "", date, "SabreTools", "SabreTools", false, _old, true, _outroot, roms, _logger, _norename);
+ DatData datdata = new DatData
+ {
+ Name = name,
+ Description = description,
+ Version = "",
+ Date = date,
+ Category = "SabreTools",
+ Author = "SabreTools",
+ ForcePacking = ForcePacking.None,
+ OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
+ };
+ Output.WriteToDatFromDict(datdata, true, _outroot, roms, _logger, _norename);
return true;
}
diff --git a/OfflineMerge/OfflineMerge.cs b/OfflineMerge/OfflineMerge.cs
index 07525413..7e049ab3 100644
--- a/OfflineMerge/OfflineMerge.cs
+++ b/OfflineMerge/OfflineMerge.cs
@@ -382,10 +382,55 @@ namespace SabreTools
}
// Finally, output all of the files
- Output.WriteToDatFromDict("Net New", "Net New", "", DateTime.Now.ToString("yyyy-MM-dd"), "", "SabreTools", false, false, true, "", netNew, _logger);
- Output.WriteToDatFromDict("Unneeded", "Unneeded", "", DateTime.Now.ToString("yyyy-MM-dd"), "", "SabreTools", false, false, true, "", unneeded, _logger);
- Output.WriteToDatFromDict("New Missing", "New Missing", "", DateTime.Now.ToString("yyyy-MM-dd"), "", "SabreTools", false, false, true, "", newMissing, _logger);
- Output.WriteToDatFromDict("Have", "Have", "", DateTime.Now.ToString("yyyy-MM-dd"), "", "SabreTools", false, false, true, "", have, _logger);
+ DatData netNewData = new DatData
+ {
+ Name = "Net New",
+ Description = "Net New",
+ Version = "",
+ Date = DateTime.Now.ToString("yyyy-MM-dd"),
+ Category = "",
+ Author = "SabreTools",
+ ForcePacking = ForcePacking.None,
+ OutputFormat = OutputFormat.Xml,
+ };
+ DatData unneededData = new DatData
+ {
+ Name = "Unneeded",
+ Description = "Unneeded",
+ Version = "",
+ Date = DateTime.Now.ToString("yyyy-MM-dd"),
+ Category = "",
+ Author = "SabreTools",
+ ForcePacking = ForcePacking.None,
+ OutputFormat = OutputFormat.Xml,
+ };
+ DatData newMissingData = new DatData
+ {
+ Name = "New Missing",
+ Description = "New Missing",
+ Version = "",
+ Date = DateTime.Now.ToString("yyyy-MM-dd"),
+ Category = "",
+ Author = "SabreTools",
+ ForcePacking = ForcePacking.None,
+ OutputFormat = OutputFormat.Xml,
+ };
+ DatData haveData = new DatData
+ {
+ Name = "Have",
+ Description = "Have",
+ Version = "",
+ Date = DateTime.Now.ToString("yyyy-MM-dd"),
+ Category = "",
+ Author = "SabreTools",
+ ForcePacking = ForcePacking.None,
+ OutputFormat = OutputFormat.Xml,
+ };
+
+ Output.WriteToDatFromDict(netNewData, true, "", netNew, _logger);
+ Output.WriteToDatFromDict(unneededData, true, "", unneeded, _logger);
+ Output.WriteToDatFromDict(newMissingData, true, "", newMissing, _logger);
+ Output.WriteToDatFromDict(haveData, true, "", have, _logger);
return true;
}
@@ -442,7 +487,18 @@ namespace SabreTools
}
}
- Output.WriteToDatFromDict("Have", "Have", "", DateTime.Now.ToString("yyyy-MM-dd"), "", "SabreTools", false, false, true, "", have, _logger);
+ DatData haveData = new DatData
+ {
+ Name = "Have",
+ Description = "Have",
+ Version = "",
+ Date = DateTime.Now.ToString("yyyy-MM-dd"),
+ Category = "",
+ Author = "SabreTools",
+ ForcePacking = ForcePacking.None,
+ OutputFormat = OutputFormat.Xml,
+ };
+ Output.WriteToDatFromDict(haveData, true, "", have, _logger);
return true;
}
@@ -499,7 +555,18 @@ namespace SabreTools
}
}
- Output.WriteToDatFromDict("Have", "Have", "", DateTime.Now.ToString("yyyy-MM-dd"), "", "SabreTools", false, false, true, "", have, _logger);
+ DatData haveData = new DatData
+ {
+ Name = "Have",
+ Description = "Have",
+ Version = "",
+ Date = DateTime.Now.ToString("yyyy-MM-dd"),
+ Category = "",
+ Author = "SabreTools",
+ ForcePacking = ForcePacking.None,
+ OutputFormat = OutputFormat.Xml,
+ };
+ Output.WriteToDatFromDict(haveData, true, "", have, _logger);
return true;
}
diff --git a/SabreHelper/Enums.cs b/SabreHelper/Enums.cs
index f62dac8a..a5c70d24 100644
--- a/SabreHelper/Enums.cs
+++ b/SabreHelper/Enums.cs
@@ -62,4 +62,35 @@ namespace SabreTools.Helper
ExternalHash,
ExternalAll,
}
+
+ public enum ForceMerging
+ {
+ None = 0,
+ Split,
+ Full,
+ }
+
+ public enum ForceNodump
+ {
+ None = 0,
+ Obsolete,
+ Required,
+ Ignore,
+ }
+
+ public enum ForcePacking
+ {
+ None = 0,
+ Zip,
+ Unzip,
+ }
+
+ public enum OutputFormat
+ {
+ Xml = 0,
+ ClrMamePro,
+ RomCenter,
+ DOSCenter,
+ MissFile,
+ }
}
diff --git a/SabreHelper/Output.cs b/SabreHelper/Output.cs
index 4c6d90f9..79aac5b0 100644
--- a/SabreHelper/Output.cs
+++ b/SabreHelper/Output.cs
@@ -141,14 +141,7 @@ namespace SabreTools.Helper
///
/// Create and open an output file for writing direct from a dictionary
///
- /// Internal name of the DAT
- /// Description and external name of the DAT
- /// Version or iteration of the DAT
- /// Usually the DAT creation date
- /// Category of the DAT
- /// DAT author
- /// Force all sets to be unzipped
- /// Set output mode to old-style DAT
+ /// All information for creating the datfile header
/// Enable output in merged mode (one game per hash)
/// Set the output directory
/// Dictionary containing all the roms to be written
@@ -161,8 +154,7 @@ namespace SabreTools.Helper
/// - Have the ability to strip special (non-ASCII) characters from rom information
/// - Add a flag for ignoring roms with blank sizes
///
- public static bool WriteToDatFromDict(string name, string description, string version, string date, string category, string author,
- bool forceunpack, bool old, bool merge, string outDir, Dictionary> dict, Logger logger, bool norename = true)
+ public static bool WriteToDatFromDict(DatData datdata, bool merge, string outDir, Dictionary> dict, Logger logger, bool norename = true)
{
// Get all values in the dictionary and write out
SortedDictionary> sortable = new SortedDictionary>();
@@ -208,38 +200,38 @@ namespace SabreTools.Helper
}
// (currently uses current time, change to "last updated time")
- logger.User("Opening file for writing: " + outDir + description + (old ? ".dat" : ".xml"));
+ logger.User("Opening file for writing: " + outDir + datdata.Description + (datdata.OutputFormat == OutputFormat.ClrMamePro ? ".dat" : ".xml"));
try
{
- FileStream fs = File.Create(outDir + description + (old ? ".dat" : ".xml"));
+ FileStream fs = File.Create(outDir + datdata.Description + (datdata.OutputFormat == OutputFormat.ClrMamePro ? ".dat" : ".xml"));
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
string header_old = "clrmamepro (\n" +
- "\tname \"" + HttpUtility.HtmlEncode(name) + "\"\n" +
- "\tdescription \"" + HttpUtility.HtmlEncode(description) + "\"\n" +
- "\tcategory \"" + HttpUtility.HtmlEncode(category) + "\"\n" +
- "\tversion \"" + HttpUtility.HtmlEncode(version) + "\"\n" +
- "\tdate \"" + HttpUtility.HtmlEncode(date) + "\"\n" +
- "\tauthor \"" + HttpUtility.HtmlEncode(author) + "\"\n" +
- (forceunpack ? "\tforcezipping no\n" : "") +
+ "\tname \"" + HttpUtility.HtmlEncode(datdata.Name) + "\"\n" +
+ "\tdescription \"" + HttpUtility.HtmlEncode(datdata.Description) + "\"\n" +
+ "\tcategory \"" + HttpUtility.HtmlEncode(datdata.Category) + "\"\n" +
+ "\tversion \"" + HttpUtility.HtmlEncode(datdata.Version) + "\"\n" +
+ "\tdate \"" + HttpUtility.HtmlEncode(datdata.Date) + "\"\n" +
+ "\tauthor \"" + HttpUtility.HtmlEncode(datdata.Author) + "\"\n" +
+ (datdata.ForcePacking == ForcePacking.Unzip ? "\tforcezipping no\n" : "") +
")\n";
string header = "\n" +
"\n\n" +
"\n" +
"\t\n" +
- "\t\t" + HttpUtility.HtmlEncode(name) + "\n" +
- "\t\t" + HttpUtility.HtmlEncode(description) + "\n" +
- "\t\t" + HttpUtility.HtmlEncode(category) + "\n" +
- "\t\t" + HttpUtility.HtmlEncode(version) + "\n" +
- "\t\t" + HttpUtility.HtmlEncode(date) + "\n" +
- "\t\t" + HttpUtility.HtmlEncode(author) + "\n" +
- (forceunpack ? "\t\t\n" : "") +
+ "\t\t" + HttpUtility.HtmlEncode(datdata.Name) + "\n" +
+ "\t\t" + HttpUtility.HtmlEncode(datdata.Description) + "\n" +
+ "\t\t" + HttpUtility.HtmlEncode(datdata.Category) + "\n" +
+ "\t\t" + HttpUtility.HtmlEncode(datdata.Version) + "\n" +
+ "\t\t" + HttpUtility.HtmlEncode(datdata.Date) + "\n" +
+ "\t\t" + HttpUtility.HtmlEncode(datdata.Author) + "\n" +
+ (datdata.ForcePacking == ForcePacking.Unzip ? "\t\t\n" : "") +
"\t\n";
// Write the header out
- sw.Write((old ? header_old : header));
+ sw.Write((datdata.OutputFormat == OutputFormat.ClrMamePro ? header_old : header));
// Write out each of the machines and roms
string lastgame = null;
@@ -250,18 +242,18 @@ namespace SabreTools.Helper
string state = "";
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Game.ToLowerInvariant())
{
- state += (old ? ")\n" : "\t\n");
+ state += (datdata.OutputFormat == OutputFormat.ClrMamePro ? ")\n" : "\t\n");
}
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Game.ToLowerInvariant())
{
- state += (old ? "game (\n\tname \"" + rom.Game + "\"\n" +
+ state += (datdata.OutputFormat == OutputFormat.ClrMamePro ? "game (\n\tname \"" + rom.Game + "\"\n" +
"\tdescription \"" + rom.Game + "\"\n" :
"\t\n" +
"\t\t" + HttpUtility.HtmlEncode(rom.Game) + "\n");
}
- if (old)
+ if (datdata.OutputFormat == OutputFormat.ClrMamePro)
{
state += "\t" + rom.Type + " ( name \"" + rom.Name + "\"" +
(rom.Size != 0 ? " size " + rom.Size : "") +
@@ -286,7 +278,7 @@ namespace SabreTools.Helper
}
}
- sw.Write((old ? ")" : "\t\n"));
+ sw.Write((datdata.OutputFormat == OutputFormat.ClrMamePro ? ")" : "\t\n"));
logger.User("File written!" + Environment.NewLine);
sw.Close();
fs.Close();
diff --git a/SabreHelper/Structs.cs b/SabreHelper/Structs.cs
index e77a77f1..9d734c98 100644
--- a/SabreHelper/Structs.cs
+++ b/SabreHelper/Structs.cs
@@ -20,4 +20,26 @@
public string SHA1;
public DupeType Dupe;
}
+
+ ///
+ /// Intermediate struct for holding DAT information
+ ///
+ public struct DatData
+ {
+ public string Name;
+ public string Description;
+ public string Category;
+ public string Version;
+ public string Date;
+ public string Author;
+ public string Email;
+ public string Homepage;
+ public string Url;
+ public string Comment;
+ public string Header;
+ public ForceMerging ForceMerging;
+ public ForceNodump ForceNodump;
+ public ForcePacking ForcePacking;
+ public OutputFormat OutputFormat;
+ }
}