mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[MergeDiff] Further abstraction of functionality
This commit is contained in:
@@ -120,17 +120,17 @@ namespace SabreTools
|
|||||||
// Modify the Dictionary if necessary and output the results
|
// Modify the Dictionary if necessary and output the results
|
||||||
if (_diff && !_cascade)
|
if (_diff && !_cascade)
|
||||||
{
|
{
|
||||||
DiffNoCascade(_name, _desc, _version, _date, _cat, _author, _forceunpack, _old, _dedup, _outdir, userData, _inputs, datHeaders, _logger);
|
DiffNoCascade(_outdir, userData, _inputs, _logger);
|
||||||
}
|
}
|
||||||
// If we're in cascade and diff, output only cascaded diffs
|
// If we're in cascade and diff, output only cascaded diffs
|
||||||
else if (_diff && _cascade)
|
else if (_diff && _cascade)
|
||||||
{
|
{
|
||||||
DiffCascade(_name, _desc, _version, _date, _cat, _author, _forceunpack, _old, _dedup, _outdir, _inplace, userData, _inputs, datHeaders, _logger);
|
DiffCascade(_outdir, _inplace, userData, _inputs, datHeaders, _logger);
|
||||||
}
|
}
|
||||||
// Output all entries with user-defined merge
|
// Output all entries with user-defined merge
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MergeNoDiff(_superdat, _outdir, userData, _inputs, datHeaders, _logger);
|
MergeNoDiff(_outdir, userData, _inputs, datHeaders, _logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -160,19 +160,7 @@ namespace SabreTools
|
|||||||
// If we are in inplace mode or redirecting output, save the DAT data
|
// If we are in inplace mode or redirecting output, save the DAT data
|
||||||
if (_inplace || !String.IsNullOrEmpty(_outdir))
|
if (_inplace || !String.IsNullOrEmpty(_outdir))
|
||||||
{
|
{
|
||||||
datHeaders.Add(new Dat
|
datHeaders.Add((Dat)userData.CloneHeader());
|
||||||
{
|
|
||||||
FileName = userData.FileName,
|
|
||||||
Name = userData.Name,
|
|
||||||
Description = userData.Description,
|
|
||||||
Version = userData.Version,
|
|
||||||
Date = userData.Date,
|
|
||||||
Category = userData.Category,
|
|
||||||
Author = userData.Author,
|
|
||||||
ForcePacking = userData.ForcePacking,
|
|
||||||
OutputFormat = userData.OutputFormat,
|
|
||||||
Type = userData.Type,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Reset the header values so the next can be captured
|
// Reset the header values so the next can be captured
|
||||||
userData.FileName = "";
|
userData.FileName = "";
|
||||||
@@ -207,45 +195,24 @@ namespace SabreTools
|
|||||||
/// Output non-cascading diffs
|
/// Output non-cascading diffs
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userData">Main DatData to draw information from</param>
|
/// <param name="userData">Main DatData to draw information from</param>
|
||||||
/// <param name="datHeaders">Dat headers used optionally</param>
|
public void DiffNoCascade(string outdir, Dat userData, List<string> inputs, Logger logger)
|
||||||
public void DiffNoCascade(string name, string desc, string version, string date, string cat, string author, bool forceunpack,
|
|
||||||
bool old, bool dedup, string outdir, Dat userData, List<string> inputs, List<Dat> datHeaders, Logger logger)
|
|
||||||
{
|
{
|
||||||
DateTime start = DateTime.Now;
|
DateTime start = DateTime.Now;
|
||||||
logger.User("Initializing all output DATs");
|
logger.User("Initializing all output DATs");
|
||||||
|
|
||||||
// Don't have External dupes
|
// Don't have External dupes
|
||||||
string post = " (No Duplicates)";
|
string post = " (No Duplicates)";
|
||||||
Dat outerDiffData = new Dat
|
Dat outerDiffData = (Dat)userData.CloneHeader();
|
||||||
{
|
outerDiffData.FileName += post;
|
||||||
FileName = desc + post,
|
outerDiffData.Name += post;
|
||||||
Name = name + post,
|
outerDiffData.Description += post;
|
||||||
Description = desc + post,
|
|
||||||
Version = version,
|
|
||||||
Date = date,
|
|
||||||
Category = cat,
|
|
||||||
Author = author,
|
|
||||||
ForcePacking = (forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
|
||||||
OutputFormat = (old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
|
||||||
MergeRoms = dedup,
|
|
||||||
Roms = new Dictionary<string, List<Rom>>(),
|
|
||||||
};
|
|
||||||
// Have External dupes
|
// Have External dupes
|
||||||
post = " (Duplicates)";
|
post = " (Duplicates)";
|
||||||
Dat dupeData = new Dat
|
Dat dupeData = (Dat)userData.CloneHeader();
|
||||||
{
|
dupeData.FileName += post;
|
||||||
FileName = desc + post,
|
dupeData.Name += post;
|
||||||
Name = name + post,
|
dupeData.Description += post;
|
||||||
Description = desc + post,
|
|
||||||
Version = version,
|
|
||||||
Date = date,
|
|
||||||
Category = cat,
|
|
||||||
Author = author,
|
|
||||||
ForcePacking = (forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
|
||||||
OutputFormat = (old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
|
||||||
MergeRoms = dedup,
|
|
||||||
Roms = new Dictionary<string, List<Rom>>(),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create a list of DatData objects representing individual output files
|
// Create a list of DatData objects representing individual output files
|
||||||
List<Dat> outDats = new List<Dat>();
|
List<Dat> outDats = new List<Dat>();
|
||||||
@@ -254,20 +221,10 @@ namespace SabreTools
|
|||||||
for (int j = 0; j < inputs.Count; j++)
|
for (int j = 0; j < inputs.Count; j++)
|
||||||
{
|
{
|
||||||
post = " (" + Path.GetFileNameWithoutExtension(inputs[j].Split('¬')[0]) + " Only)";
|
post = " (" + Path.GetFileNameWithoutExtension(inputs[j].Split('¬')[0]) + " Only)";
|
||||||
Dat diffData = new Dat
|
Dat diffData = (Dat)userData.CloneHeader();
|
||||||
{
|
diffData.FileName += post;
|
||||||
FileName = desc + post,
|
diffData.Name += post;
|
||||||
Name = name + post,
|
diffData.Description += post;
|
||||||
Description = desc + post,
|
|
||||||
Version = version,
|
|
||||||
Date = date,
|
|
||||||
Category = cat,
|
|
||||||
Author = author,
|
|
||||||
ForcePacking = (forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
|
||||||
OutputFormat = (old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
|
||||||
MergeRoms = dedup,
|
|
||||||
Roms = new Dictionary<string, List<Rom>>(),
|
|
||||||
};
|
|
||||||
outDats.Add(diffData);
|
outDats.Add(diffData);
|
||||||
}
|
}
|
||||||
logger.User("Initializing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
logger.User("Initializing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
||||||
@@ -367,8 +324,7 @@ namespace SabreTools
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userData">Main DatData to draw information from</param>
|
/// <param name="userData">Main DatData to draw information from</param>
|
||||||
/// <param name="datHeaders">Dat headers used optionally</param>
|
/// <param name="datHeaders">Dat headers used optionally</param>
|
||||||
private void DiffCascade(string name, string desc, string version, string date, string cat, string author, bool forceunpack,
|
private void DiffCascade(string outdir, bool inplace, Dat userData, List<string> inputs, List<Dat> datHeaders, Logger logger)
|
||||||
bool old, bool dedup, string outdir, bool inplace, Dat userData, List<string> inputs, List<Dat> datHeaders, Logger logger)
|
|
||||||
{
|
{
|
||||||
string post = "";
|
string post = "";
|
||||||
|
|
||||||
@@ -390,22 +346,11 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
diffData = new Dat
|
diffData = (Dat)userData.CloneHeader();
|
||||||
{
|
diffData.FileName += post;
|
||||||
FileName = desc + post,
|
diffData.Name += post;
|
||||||
Name = name + post,
|
diffData.Description += post;
|
||||||
Description = desc + post,
|
|
||||||
Version = version,
|
|
||||||
Date = date,
|
|
||||||
Category = cat,
|
|
||||||
Author = author,
|
|
||||||
ForcePacking = (forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
|
||||||
OutputFormat = (old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
|
||||||
MergeRoms = dedup,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
diffData.Roms = new Dictionary<string, List<Rom>>();
|
|
||||||
outDats.Add(diffData);
|
outDats.Add(diffData);
|
||||||
}
|
}
|
||||||
logger.User("Initializing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
logger.User("Initializing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
||||||
@@ -467,10 +412,10 @@ namespace SabreTools
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userData">Main DatData to draw information from</param>
|
/// <param name="userData">Main DatData to draw information from</param>
|
||||||
/// <param name="datHeaders">Dat headers used optionally</param>
|
/// <param name="datHeaders">Dat headers used optionally</param>
|
||||||
private void MergeNoDiff(bool superdat, string outdir, Dat userData, List<string> inputs, List<Dat> datHeaders, Logger logger)
|
private void MergeNoDiff(string outdir, Dat userData, List<string> inputs, List<Dat> datHeaders, Logger logger)
|
||||||
{
|
{
|
||||||
// If we're in SuperDAT mode, prefix all games with their respective DATs
|
// If we're in SuperDAT mode, prefix all games with their respective DATs
|
||||||
if (superdat)
|
if (userData.Type == "SuperDAT")
|
||||||
{
|
{
|
||||||
List<string> keys = userData.Roms.Keys.ToList();
|
List<string> keys = userData.Roms.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
|
|||||||
Reference in New Issue
Block a user