mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add SuperDAT output to merge/dedupe
This commit is contained in:
@@ -74,6 +74,7 @@ namespace SabreTools
|
|||||||
quotes = false,
|
quotes = false,
|
||||||
rem = false,
|
rem = false,
|
||||||
romba = false,
|
romba = false,
|
||||||
|
superdat = false,
|
||||||
trim = false,
|
trim = false,
|
||||||
skip = false,
|
skip = false,
|
||||||
usegame = true;
|
usegame = true;
|
||||||
@@ -198,6 +199,10 @@ namespace SabreTools
|
|||||||
case "--romba":
|
case "--romba":
|
||||||
romba = true;
|
romba = true;
|
||||||
break;
|
break;
|
||||||
|
case "-sd":
|
||||||
|
case "--superdat":
|
||||||
|
superdat = true;
|
||||||
|
break;
|
||||||
case "--skip":
|
case "--skip":
|
||||||
skip = true;
|
skip = true;
|
||||||
break;
|
break;
|
||||||
@@ -447,7 +452,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, diff, dedup, bare, forceunpack, old);
|
InitMergeDiff(inputs, name, desc, cat, version, author, diff, dedup, bare, forceunpack, old, superdat);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Close();
|
logger.Close();
|
||||||
@@ -909,7 +914,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 dedup = false, diff = false, bare = false, forceunpack = false, old = false;
|
bool dedup = false, diff = false, bare = false, forceunpack = false, old = false, superdat = false;
|
||||||
while (selection.ToLowerInvariant() != "b")
|
while (selection.ToLowerInvariant() != "b")
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
@@ -929,7 +934,8 @@ Make a selection:
|
|||||||
9) " + (bare ? "Don't append the date to the name" : "Append the date to the name") + @"
|
9) " + (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") + @"
|
10) " + (forceunpack ? "Remove 'forcepacking=\"unzip\"' from output" : "Add 'forcepacking=\"unzip\"' to output") + @"
|
||||||
11) " + (old ? "Enable XML output" : "Enable ClrMamePro output") + @"
|
11) " + (old ? "Enable XML output" : "Enable ClrMamePro output") + @"
|
||||||
12) Merge the DATs
|
12) " + (superdat ? "Disable SuperDAT output" : "Enable SuperDAT output") + @"
|
||||||
|
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: ");
|
||||||
@@ -982,9 +988,12 @@ Make a selection:
|
|||||||
old = !old;
|
old = !old;
|
||||||
break;
|
break;
|
||||||
case "12":
|
case "12":
|
||||||
|
superdat = !superdat;
|
||||||
|
break;
|
||||||
|
case "13":
|
||||||
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, diff, dedup, bare, forceunpack, old);
|
InitMergeDiff(inputs, name, desc, cat, version, author, diff, dedup, bare, forceunpack, old, superdat);
|
||||||
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 = "";
|
||||||
@@ -1520,7 +1529,9 @@ 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 diff, bool dedup, bool bare, bool forceunpack, bool old)
|
/// <param name="superdat">True if DATs should be merged in SuperDAT style, false otherwise</param>
|
||||||
|
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, bool superdat)
|
||||||
{
|
{
|
||||||
// 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>();
|
||||||
@@ -1532,7 +1543,7 @@ Make a selection:
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
newInputs.Add(Path.GetFullPath(file));
|
newInputs.Add(Path.GetFullPath(file) + "¬" + Path.GetFullPath(input.Replace("\"", "")));
|
||||||
}
|
}
|
||||||
catch (PathTooLongException)
|
catch (PathTooLongException)
|
||||||
{
|
{
|
||||||
@@ -1544,7 +1555,7 @@ Make a selection:
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
newInputs.Add(Path.GetFullPath(input.Replace("\"", "")));
|
newInputs.Add(Path.GetFullPath(input.Replace("\"", "") + "¬"));
|
||||||
}
|
}
|
||||||
catch (PathTooLongException)
|
catch (PathTooLongException)
|
||||||
{
|
{
|
||||||
@@ -1553,7 +1564,7 @@ Make a selection:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MergeDiff md = new MergeDiff(newInputs, name, desc, cat, version, author, diff, dedup, bare, forceunpack, old, logger);
|
MergeDiff md = new MergeDiff(newInputs, name, desc, cat, version, author, diff, dedup, bare, forceunpack, old, superdat, logger);
|
||||||
md.Process();
|
md.Process();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
using SabreTools.Helper;
|
using SabreTools.Helper;
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ namespace SabreTools
|
|||||||
private bool _bare;
|
private bool _bare;
|
||||||
private bool _forceunpack;
|
private bool _forceunpack;
|
||||||
private bool _old;
|
private bool _old;
|
||||||
|
private bool _superdat;
|
||||||
|
|
||||||
// User specified strings
|
// User specified strings
|
||||||
private string _name;
|
private string _name;
|
||||||
@@ -44,9 +46,10 @@ namespace SabreTools
|
|||||||
/// <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>
|
||||||
|
/// <param name="superdat">True if DATs should be parsed into SuperDAT format, 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 diff, bool dedup, bool bare, bool forceunpack, bool old, Logger logger)
|
bool diff, bool dedup, bool bare, bool forceunpack, bool old, bool superdat, Logger logger)
|
||||||
{
|
{
|
||||||
_inputs = inputs;
|
_inputs = inputs;
|
||||||
_name = name;
|
_name = name;
|
||||||
@@ -59,6 +62,7 @@ namespace SabreTools
|
|||||||
_bare = bare;
|
_bare = bare;
|
||||||
_forceunpack = forceunpack;
|
_forceunpack = forceunpack;
|
||||||
_old = old;
|
_old = old;
|
||||||
|
_superdat = superdat;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,11 +115,12 @@ namespace SabreTools
|
|||||||
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
||||||
MergeRoms = _dedup,
|
MergeRoms = _dedup,
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
Roms = new Dictionary<string, List<RomData>>(),
|
||||||
|
Type = (_superdat ? "SuperDAT" : ""),
|
||||||
};
|
};
|
||||||
foreach (string input in _inputs)
|
foreach (string input in _inputs)
|
||||||
{
|
{
|
||||||
_logger.User("Adding DAT: " + input);
|
_logger.User("Adding DAT: " + input.Split('¬')[0]);
|
||||||
userData = RomManipulation.Parse(input, i, 0, userData, _logger);
|
userData = RomManipulation.Parse(input.Split('¬')[0], i, 0, userData, _logger);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +173,7 @@ namespace SabreTools
|
|||||||
// Loop through _inputs first and filter from all diffed roms to find the ones that have the same "System"
|
// Loop through _inputs first and filter from all diffed roms to find the ones that have the same "System"
|
||||||
for (int j = 0; j < _inputs.Count; j++)
|
for (int j = 0; j < _inputs.Count; j++)
|
||||||
{
|
{
|
||||||
post = " (" + Path.GetFileNameWithoutExtension(_inputs[j]) + " Only)";
|
post = " (" + Path.GetFileNameWithoutExtension(_inputs[j].Split('¬')[0]) + " Only)";
|
||||||
DatData diffData = new DatData
|
DatData diffData = new DatData
|
||||||
{
|
{
|
||||||
Name = _name + post,
|
Name = _name + post,
|
||||||
@@ -249,6 +254,30 @@ namespace SabreTools
|
|||||||
// Output all entries with user-defined merge
|
// Output all entries with user-defined merge
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// If we're in SuperDAT mode, prefix all games with their respective DATs
|
||||||
|
if (_superdat)
|
||||||
|
{
|
||||||
|
List<string> keys = userData.Roms.Keys.ToList();
|
||||||
|
foreach (string key in keys)
|
||||||
|
{
|
||||||
|
List<RomData> newroms = new List<RomData>();
|
||||||
|
foreach (RomData rom in userData.Roms[key])
|
||||||
|
{
|
||||||
|
RomData newrom = rom;
|
||||||
|
string filename = _inputs[newrom.SystemID].Split('¬')[0];
|
||||||
|
string rootpath = _inputs[newrom.SystemID].Split('¬')[1];
|
||||||
|
|
||||||
|
rootpath += (rootpath == "" ? "" : Path.DirectorySeparatorChar.ToString());
|
||||||
|
filename = filename.Remove(0, rootpath.Length);
|
||||||
|
newrom.Game = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar.ToString() +
|
||||||
|
Path.GetFileNameWithoutExtension(filename) + Path.DirectorySeparatorChar + newrom.Game;
|
||||||
|
newroms.Add(newrom);
|
||||||
|
Console.WriteLine(newrom.Game);
|
||||||
|
}
|
||||||
|
userData.Roms[key] = newroms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Output.WriteDatfile(userData, "", _logger);
|
Output.WriteDatfile(userData, "", _logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ Options:
|
|||||||
-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
|
||||||
-o, --old Output DAT in CMP format instead of XML
|
-o, --old Output DAT in CMP format instead of XML
|
||||||
|
-sd, --superdat Enable SuperDAT creation
|
||||||
-n=, --name= Set the internal name of the DAT
|
-n=, --name= Set the internal name of the DAT
|
||||||
-d=, --desc= Set the filename and description of the DAT
|
-d=, --desc= Set the filename and description of the DAT
|
||||||
-c=, --cat= Set the category of the DAT
|
-c=, --cat= Set the category of the DAT
|
||||||
|
|||||||
Reference in New Issue
Block a user