mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Make all-diff standard for diff
This commit is contained in:
@@ -51,7 +51,6 @@ namespace SabreTools
|
|||||||
|
|
||||||
// Set all default values
|
// Set all default values
|
||||||
bool help = false,
|
bool help = false,
|
||||||
ad = false,
|
|
||||||
add = false,
|
add = false,
|
||||||
bare = false,
|
bare = false,
|
||||||
convertMiss = false,
|
convertMiss = false,
|
||||||
@@ -109,10 +108,6 @@ namespace SabreTools
|
|||||||
case "--add":
|
case "--add":
|
||||||
add = true;
|
add = true;
|
||||||
break;
|
break;
|
||||||
case "-ad":
|
|
||||||
case "--all-diff":
|
|
||||||
ad = true;
|
|
||||||
break;
|
|
||||||
case "-b":
|
case "-b":
|
||||||
case "--bare":
|
case "--bare":
|
||||||
bare = true;
|
bare = true;
|
||||||
@@ -432,7 +427,7 @@ namespace SabreTools
|
|||||||
// Merge, diff, and dedupe at least 2 DATs
|
// Merge, diff, and dedupe at least 2 DATs
|
||||||
else if (merge || diff)
|
else if (merge || diff)
|
||||||
{
|
{
|
||||||
InitMergeDiff(inputs, name, desc, cat, version, author, ad, diff, dedup, bare, forceunpack, old);
|
InitMergeDiff(inputs, name, desc, cat, version, author, diff, dedup, bare, forceunpack, old);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Close();
|
logger.Close();
|
||||||
@@ -859,7 +854,7 @@ Make a selection:
|
|||||||
private static void MergeDiffMenu()
|
private static void MergeDiffMenu()
|
||||||
{
|
{
|
||||||
string selection = "", input = "", name = "", desc = "", cat = "", version = "", author = "";
|
string selection = "", input = "", name = "", desc = "", cat = "", version = "", author = "";
|
||||||
bool ad = false, dedup = false, diff = false, bare = false, forceunpack = false, old = false;
|
bool dedup = false, diff = false, bare = false, forceunpack = false, old = false;
|
||||||
while (selection.ToLowerInvariant() != "b")
|
while (selection.ToLowerInvariant() != "b")
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
@@ -874,13 +869,12 @@ Make a selection:
|
|||||||
4) Category" + (cat != "" ? ":\t" + cat : "") + @"
|
4) Category" + (cat != "" ? ":\t" + cat : "") + @"
|
||||||
5) Version" + (version != "" ? ":\t" + version : "") + @"
|
5) Version" + (version != "" ? ":\t" + version : "") + @"
|
||||||
6) Author" + (author != "" ? ":\t" + author : "") + @"
|
6) Author" + (author != "" ? ":\t" + author : "") + @"
|
||||||
7) " + (ad ? "Only output normal diff" : "Output all diff variants (2 files only)") + @"
|
7) " + (dedup ? "Don't dedup files in output" : "Dedup files in output") + @"
|
||||||
8) " + (dedup ? "Don't dedup files in output" : "Dedup files in output") + @"
|
8) " + (diff ? "Only merge the input files" : "Diff the input files") + @"
|
||||||
9) " + (diff ? "Only merge the input files" : "Diff the input files") + @"
|
9) " + (bare ? "Don't append the date to the name" : "Append the date to the name") + @"
|
||||||
10) " + (bare ? "Don't append the date to the name" : "Append the date to the name") + @"
|
10) " + (forceunpack ? "Remove 'forcepacking=\"unzip\"' from output" : "Add 'forcepacking=\"unzip\"' to output") + @"
|
||||||
11) " + (forceunpack ? "Remove 'forcepacking=\"unzip\"' from output" : "Add 'forcepacking=\"unzip\"' to output") + @"
|
11) " + (old ? "Enable XML output" : "Enable ClrMamePro output") + @"
|
||||||
12) " + (old ? "Enable XML output" : "Enable ClrMamePro output") + @"
|
12) Merge the DATs
|
||||||
13) Merge the DATs
|
|
||||||
B) Go back to the previous menu
|
B) Go back to the previous menu
|
||||||
");
|
");
|
||||||
Console.Write("Enter selection: ");
|
Console.Write("Enter selection: ");
|
||||||
@@ -918,31 +912,28 @@ Make a selection:
|
|||||||
author = Console.ReadLine();
|
author = Console.ReadLine();
|
||||||
break;
|
break;
|
||||||
case "7":
|
case "7":
|
||||||
ad = !ad;
|
|
||||||
break;
|
|
||||||
case "8":
|
|
||||||
dedup = !dedup;
|
dedup = !dedup;
|
||||||
break;
|
break;
|
||||||
case "9":
|
case "8":
|
||||||
diff = !diff;
|
diff = !diff;
|
||||||
break;
|
break;
|
||||||
case "10":
|
case "9":
|
||||||
bare = !bare;
|
bare = !bare;
|
||||||
break;
|
break;
|
||||||
case "11":
|
case "10":
|
||||||
forceunpack = !forceunpack;
|
forceunpack = !forceunpack;
|
||||||
break;
|
break;
|
||||||
case "12":
|
case "11":
|
||||||
old = !old;
|
old = !old;
|
||||||
break;
|
break;
|
||||||
case "13":
|
case "12":
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
List<string> inputs = new List<string>(input.Split(';'));
|
List<string> inputs = new List<string>(input.Split(';'));
|
||||||
InitMergeDiff(inputs, name, desc, cat, version, author, ad, diff, dedup, bare, forceunpack, old);
|
InitMergeDiff(inputs, name, desc, cat, version, author, diff, dedup, bare, forceunpack, old);
|
||||||
Console.Write("\nPress any key to continue...");
|
Console.Write("\nPress any key to continue...");
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
selection = ""; input = ""; name = ""; desc = ""; cat = ""; version = ""; author = "";
|
selection = ""; input = ""; name = ""; desc = ""; cat = ""; version = ""; author = "";
|
||||||
ad = false; dedup = false; diff = false; bare = false; forceunpack = false; old = false;
|
dedup = false; diff = false; bare = false; forceunpack = false; old = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1380,7 +1371,7 @@ Make a selection:
|
|||||||
/// <param name="bare">True if the date should be omitted from the DAT, false otherwise</param>
|
/// <param name="bare">True if the date should be omitted from the DAT, false otherwise</param>
|
||||||
/// <param name="forceunpack">True if the forcepacking="unzip" tag is to be added, false otherwise</param>
|
/// <param name="forceunpack">True if the forcepacking="unzip" tag is to be added, false otherwise</param>
|
||||||
/// <param name="old">True if a old-style DAT should be output, false otherwise</param>
|
/// <param name="old">True if a old-style DAT should be output, false otherwise</param>
|
||||||
private static void InitMergeDiff(List<string> inputs, string name, string desc, string cat, string version, string author, bool ad, bool diff, bool dedup, bool bare, bool forceunpack, bool old)
|
private static void InitMergeDiff(List<string> inputs, string name, string desc, string cat, string version, string author, bool diff, bool dedup, bool bare, bool forceunpack, bool old)
|
||||||
{
|
{
|
||||||
// Make sure there are no folders in inputs
|
// Make sure there are no folders in inputs
|
||||||
List<string> newInputs = new List<string>();
|
List<string> newInputs = new List<string>();
|
||||||
@@ -1399,7 +1390,7 @@ Make a selection:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MergeDiff md = new MergeDiff(newInputs, name, desc, cat, version, author, ad, diff, dedup, bare, forceunpack, old, logger);
|
MergeDiff md = new MergeDiff(newInputs, name, desc, cat, version, author, diff, dedup, bare, forceunpack, old, logger);
|
||||||
md.Process();
|
md.Process();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ namespace SabreTools
|
|||||||
private List<String> _inputs;
|
private List<String> _inputs;
|
||||||
|
|
||||||
// User specified flags
|
// User specified flags
|
||||||
private bool _ad;
|
|
||||||
private bool _diff;
|
private bool _diff;
|
||||||
private bool _dedup;
|
private bool _dedup;
|
||||||
private bool _bare;
|
private bool _bare;
|
||||||
@@ -47,7 +46,7 @@ namespace SabreTools
|
|||||||
/// <param name="old">True if a old-style DAT should be output, false otherwise</param>
|
/// <param name="old">True if a old-style DAT should be output, false otherwise</param>
|
||||||
/// <param name="logger">Logger object for console and file output</param>
|
/// <param name="logger">Logger object for console and file output</param>
|
||||||
public MergeDiff(List<String> inputs, string name, string desc, string cat, string version, string author,
|
public MergeDiff(List<String> inputs, string name, string desc, string cat, string version, string author,
|
||||||
bool ad, bool diff, bool dedup, bool bare, bool forceunpack, bool old, Logger logger)
|
bool diff, bool dedup, bool bare, bool forceunpack, bool old, Logger logger)
|
||||||
{
|
{
|
||||||
_inputs = inputs;
|
_inputs = inputs;
|
||||||
_name = name;
|
_name = name;
|
||||||
@@ -55,7 +54,6 @@ namespace SabreTools
|
|||||||
_cat = cat;
|
_cat = cat;
|
||||||
_version = version;
|
_version = version;
|
||||||
_author = author;
|
_author = author;
|
||||||
_ad = ad;
|
|
||||||
_diff = diff;
|
_diff = diff;
|
||||||
_dedup = dedup;
|
_dedup = dedup;
|
||||||
_bare = bare;
|
_bare = bare;
|
||||||
@@ -71,9 +69,9 @@ namespace SabreTools
|
|||||||
public bool Process()
|
public bool Process()
|
||||||
{
|
{
|
||||||
// Check if there are enough inputs
|
// Check if there are enough inputs
|
||||||
if ((!_ad && _inputs.Count < 1) || (_ad && _inputs.Count < 2))
|
if (_inputs.Count < 1)
|
||||||
{
|
{
|
||||||
_logger.Warning("At least " + (_ad ? "2" : "1") + " input(s) are required!");
|
_logger.Warning("At least 1 input is required!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +108,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Modify the Dictionary if necessary and output the results
|
// Modify the Dictionary if necessary and output the results
|
||||||
if (_diff || _ad)
|
if (_diff)
|
||||||
{
|
{
|
||||||
// Get all entries that don't have External dupes
|
// Get all entries that don't have External dupes
|
||||||
Dictionary<string, List<RomData>> diffed = new Dictionary<string, List<RomData>>();
|
Dictionary<string, List<RomData>> diffed = new Dictionary<string, List<RomData>>();
|
||||||
@@ -121,7 +119,7 @@ namespace SabreTools
|
|||||||
|
|
||||||
foreach (RomData rom in temp)
|
foreach (RomData rom in temp)
|
||||||
{
|
{
|
||||||
if ((_dedup && rom.Dupe != DupeType.InternalHash) || (!_dedup && rom.Dupe != DupeType.InternalAll))
|
if ((_dedup && rom.Dupe != DupeType.ExternalHash) || (!_dedup && rom.Dupe != DupeType.ExternalAll))
|
||||||
{
|
{
|
||||||
if (diffed.ContainsKey(key))
|
if (diffed.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -137,44 +135,68 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output the difflist only if we're in diff mode and not AB
|
// Output the difflist (a-b)+(b-a) diff
|
||||||
if (_diff)
|
Output.WriteToDatFromDict(_name, _desc, _version, _date, _cat, _author, _forceunpack, _old, _dedup, "", diffed, _logger);
|
||||||
{
|
|
||||||
Output.WriteToDatFromDict(_name, _desc, _version, _date, _cat, _author, _forceunpack, _old, _dedup, "", diffed, _logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
// For the AB mode, get all required dictionaries and output with a new name
|
// For the AB mode-style diffs, get all required dictionaries and output with a new name
|
||||||
if (_ad)
|
// Loop through _inputs first and filter from all diffed roms to find the ones that have the same "System"
|
||||||
|
string post = "";
|
||||||
|
int j = 0;
|
||||||
|
foreach (string filename in _inputs)
|
||||||
{
|
{
|
||||||
// Loop through _inputs first and filter from all diffed roms to find the ones that have the same "System"
|
Dictionary<string, List<RomData>> sysDict = new Dictionary<string, List<RomData>>();
|
||||||
string post = "";
|
foreach (string key in diffed.Keys)
|
||||||
foreach (string filename in _inputs)
|
|
||||||
{
|
{
|
||||||
Dictionary<string, List<RomData>> sysDict = new Dictionary<string, List<RomData>>();
|
foreach (RomData rom in diffed[key])
|
||||||
foreach (string key in diffed.Keys)
|
|
||||||
{
|
{
|
||||||
if (diffed[key][0].System == filename)
|
if (rom.SystemID == j)
|
||||||
{
|
{
|
||||||
sysDict.Add(key, diffed[key]);
|
if (sysDict.ContainsKey(key))
|
||||||
|
{
|
||||||
|
sysDict[key].Add(rom);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
List<RomData> tl = new List<RomData>();
|
||||||
|
tl.Add(rom);
|
||||||
|
sysDict.Add(key, tl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post = " (" + Path.GetFileNameWithoutExtension(filename) + ")";
|
|
||||||
Output.WriteToDatFromDict(_name + post, _desc + post, _version, _date, _cat, _author, _forceunpack, _old, _dedup, "", sysDict, _logger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then loop through all that have a count > 1 for the AB merged DAT
|
post = " (" + Path.GetFileNameWithoutExtension(filename) + ")";
|
||||||
Dictionary<string, List<RomData>> duplicates = new Dictionary<string, List<RomData>>();
|
Output.WriteToDatFromDict(_name + post, _desc + post, _version, _date, _cat, _author, _forceunpack, _old, _dedup, "", sysDict, _logger);
|
||||||
post = " (dupes)";
|
|
||||||
foreach (string key in dict.Keys)
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all entries that have External dupes
|
||||||
|
Dictionary<string, List<RomData>> duplicates = new Dictionary<string, List<RomData>>();
|
||||||
|
post = " (dupes)";
|
||||||
|
foreach (string key in dict.Keys)
|
||||||
|
{
|
||||||
|
List<RomData> temp = dict[key];
|
||||||
|
temp = RomManipulation.Merge(temp);
|
||||||
|
|
||||||
|
foreach (RomData rom in temp)
|
||||||
{
|
{
|
||||||
if (dict[key].Count > 1)
|
if ((_dedup && rom.Dupe == DupeType.ExternalHash) || (!_dedup && rom.Dupe == DupeType.ExternalAll))
|
||||||
{
|
{
|
||||||
duplicates.Add(key, dict[key]);
|
if (duplicates.ContainsKey(key))
|
||||||
|
{
|
||||||
|
duplicates[key].Add(rom);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
List<RomData> tl = new List<RomData>();
|
||||||
|
tl.Add(rom);
|
||||||
|
duplicates.Add(key, tl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Output.WriteToDatFromDict(_name + post, _desc + post, _version, _date, _cat, _author, _forceunpack, _old, _dedup, "", duplicates, _logger);
|
|
||||||
}
|
}
|
||||||
|
Output.WriteToDatFromDict(_name + post, _desc + post, _version, _date, _cat, _author, _forceunpack, _old, _dedup, "", duplicates, _logger);
|
||||||
}
|
}
|
||||||
// Output all entries with user-defined merge
|
// Output all entries with user-defined merge
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -117,8 +117,7 @@ Options:
|
|||||||
-lso, --list-sources List all sources (id <= name)
|
-lso, --list-sources List all sources (id <= name)
|
||||||
-lsy, --list-systems List all systems (id <= name)
|
-lsy, --list-systems List all systems (id <= name)
|
||||||
-m, --merge Merge one or more DATs
|
-m, --merge Merge one or more DATs
|
||||||
-ad, --all-diff Enable output of all diff variants
|
-di, --diff Output all diffdats (merge flag not required)
|
||||||
-di, --diff Switch to diffdat mode (merge flag not required)
|
|
||||||
-dd, --dedup Enable deduping in the created DAT
|
-dd, --dedup Enable deduping in the created DAT
|
||||||
-b, --bare Don't include date in file name
|
-b, --bare Don't include date in file name
|
||||||
-u, --unzip Force unzipping in created DAT
|
-u, --unzip Force unzipping in created DAT
|
||||||
|
|||||||
Reference in New Issue
Block a user