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,
|
||||
rem = false,
|
||||
romba = false,
|
||||
superdat = false,
|
||||
trim = false,
|
||||
skip = false,
|
||||
usegame = true;
|
||||
@@ -198,6 +199,10 @@ namespace SabreTools
|
||||
case "--romba":
|
||||
romba = true;
|
||||
break;
|
||||
case "-sd":
|
||||
case "--superdat":
|
||||
superdat = true;
|
||||
break;
|
||||
case "--skip":
|
||||
skip = true;
|
||||
break;
|
||||
@@ -447,7 +452,7 @@ namespace SabreTools
|
||||
// Merge, diff, and dedupe at least 2 DATs
|
||||
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();
|
||||
@@ -909,7 +914,7 @@ Make a selection:
|
||||
private static void MergeDiffMenu()
|
||||
{
|
||||
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")
|
||||
{
|
||||
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") + @"
|
||||
10) " + (forceunpack ? "Remove 'forcepacking=\"unzip\"' from output" : "Add 'forcepacking=\"unzip\"' to 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
|
||||
");
|
||||
Console.Write("Enter selection: ");
|
||||
@@ -982,9 +988,12 @@ Make a selection:
|
||||
old = !old;
|
||||
break;
|
||||
case "12":
|
||||
superdat = !superdat;
|
||||
break;
|
||||
case "13":
|
||||
Console.Clear();
|
||||
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.ReadKey();
|
||||
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="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>
|
||||
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
|
||||
List<string> newInputs = new List<string>();
|
||||
@@ -1532,7 +1543,7 @@ Make a selection:
|
||||
{
|
||||
try
|
||||
{
|
||||
newInputs.Add(Path.GetFullPath(file));
|
||||
newInputs.Add(Path.GetFullPath(file) + "¬" + Path.GetFullPath(input.Replace("\"", "")));
|
||||
}
|
||||
catch (PathTooLongException)
|
||||
{
|
||||
@@ -1544,7 +1555,7 @@ Make a selection:
|
||||
{
|
||||
try
|
||||
{
|
||||
newInputs.Add(Path.GetFullPath(input.Replace("\"", "")));
|
||||
newInputs.Add(Path.GetFullPath(input.Replace("\"", "") + "¬"));
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using SabreTools.Helper;
|
||||
|
||||
@@ -17,6 +18,7 @@ namespace SabreTools
|
||||
private bool _bare;
|
||||
private bool _forceunpack;
|
||||
private bool _old;
|
||||
private bool _superdat;
|
||||
|
||||
// User specified strings
|
||||
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="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="superdat">True if DATs should be parsed into SuperDAT format, false otherwise</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,
|
||||
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;
|
||||
_name = name;
|
||||
@@ -59,6 +62,7 @@ namespace SabreTools
|
||||
_bare = bare;
|
||||
_forceunpack = forceunpack;
|
||||
_old = old;
|
||||
_superdat = superdat;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -111,11 +115,12 @@ namespace SabreTools
|
||||
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
||||
MergeRoms = _dedup,
|
||||
Roms = new Dictionary<string, List<RomData>>(),
|
||||
Type = (_superdat ? "SuperDAT" : ""),
|
||||
};
|
||||
foreach (string input in _inputs)
|
||||
{
|
||||
_logger.User("Adding DAT: " + input);
|
||||
userData = RomManipulation.Parse(input, i, 0, userData, _logger);
|
||||
_logger.User("Adding DAT: " + input.Split('¬')[0]);
|
||||
userData = RomManipulation.Parse(input.Split('¬')[0], i, 0, userData, _logger);
|
||||
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"
|
||||
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
|
||||
{
|
||||
Name = _name + post,
|
||||
@@ -249,6 +254,30 @@ namespace SabreTools
|
||||
// Output all entries with user-defined merge
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ Options:
|
||||
-b, --bare Don't include date in file name
|
||||
-u, --unzip Force unzipping in created DAT
|
||||
-o, --old Output DAT in CMP format instead of XML
|
||||
-sd, --superdat Enable SuperDAT creation
|
||||
-n=, --name= Set the internal name of the DAT
|
||||
-d=, --desc= Set the filename and description of the DAT
|
||||
-c=, --cat= Set the category of the DAT
|
||||
|
||||
Reference in New Issue
Block a user