mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile] Add AttractMode as valid input and output format
This commit is contained in:
@@ -155,6 +155,7 @@ namespace SabreTools.Helper.Data
|
|||||||
helptext.Add(" -u, --unzip Force unzipping in created DAT");
|
helptext.Add(" -u, --unzip Force unzipping in created DAT");
|
||||||
helptext.Add(" -f, --files Treat archives as files");
|
helptext.Add(" -f, --files Treat archives as files");
|
||||||
helptext.Add(" -oa, --output-all Output in all formats");
|
helptext.Add(" -oa, --output-all Output in all formats");
|
||||||
|
helptext.Add(" -oam, --output-am Output in AttractMode format");
|
||||||
helptext.Add(" -oc, --output-cmp Output in CMP format");
|
helptext.Add(" -oc, --output-cmp Output in CMP format");
|
||||||
helptext.Add(" -ocsv, --output-csv Output in CSV format");
|
helptext.Add(" -ocsv, --output-csv Output in CSV format");
|
||||||
helptext.Add(" -od, --output-dc Output in DOSCenter format");
|
helptext.Add(" -od, --output-dc Output in DOSCenter format");
|
||||||
@@ -248,6 +249,7 @@ namespace SabreTools.Helper.Data
|
|||||||
// Update
|
// Update
|
||||||
helptext.Add(" -ud, --update Update a DAT file");
|
helptext.Add(" -ud, --update Update a DAT file");
|
||||||
helptext.Add(" -oa, --output-all Output in all formats");
|
helptext.Add(" -oa, --output-all Output in all formats");
|
||||||
|
helptext.Add(" -oam, --output-am Output in AttractMode format");
|
||||||
helptext.Add(" -oc, --output-cmp Output in CMP format");
|
helptext.Add(" -oc, --output-cmp Output in CMP format");
|
||||||
helptext.Add(" -ocsv, --output-csv Output in CSV format");
|
helptext.Add(" -ocsv, --output-csv Output in CSV format");
|
||||||
helptext.Add(" -pre=, --prefix= Set prefix for all lines");
|
helptext.Add(" -pre=, --prefix= Set prefix for all lines");
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ namespace SabreTools.Helper.Data
|
|||||||
OfflineList = 0x0400,
|
OfflineList = 0x0400,
|
||||||
TSV = 0x0800,
|
TSV = 0x0800,
|
||||||
CSV = 0x1000,
|
CSV = 0x1000,
|
||||||
|
AttractMode = 0x2000,
|
||||||
|
|
||||||
ALL = 0xFFFF,
|
ALL = 0xFFFF,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1196,7 +1196,7 @@ namespace SabreTools.Helper.Dats
|
|||||||
string[] split = inputs[j].Split('¬');
|
string[] split = inputs[j].Split('¬');
|
||||||
path = outDir + (split[0] == split[1]
|
path = outDir + (split[0] == split[1]
|
||||||
? Path.GetFileName(split[0])
|
? Path.GetFileName(split[0])
|
||||||
: (Path.GetDirectoryName(split[0]).Remove(0, split[1].Length)));;
|
: (Path.GetDirectoryName(split[0]).Remove(0, split[1].Length))); ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have more than 0 roms, output
|
// If we have more than 0 roms, output
|
||||||
@@ -1435,6 +1435,98 @@ namespace SabreTools.Helper.Dats
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parse an AttractMode DAT and return all found games within
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Name of the file to be parsed</param>
|
||||||
|
/// <param name="sysid">System ID for the DAT</param>
|
||||||
|
/// <param name="srcid">Source ID for the DAT</param>
|
||||||
|
/// <param name="filter">Filter object for passing to the DatItem level</param>
|
||||||
|
/// <param name="trim">True if we are supposed to trim names to NTFS length, false otherwise</param>
|
||||||
|
/// <param name="single">True if all games should be replaced by '!', false otherwise</param>
|
||||||
|
/// <param name="root">String representing root directory to compare against for length calculation</param>
|
||||||
|
/// <param name="logger">Logger object for console and/or file output</param>
|
||||||
|
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||||
|
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||||
|
private void ParseAttractMode(
|
||||||
|
// Standard Dat parsing
|
||||||
|
string filename,
|
||||||
|
int sysid,
|
||||||
|
int srcid,
|
||||||
|
|
||||||
|
// Rom filtering
|
||||||
|
Filter filter,
|
||||||
|
|
||||||
|
// Rom renaming
|
||||||
|
bool trim,
|
||||||
|
bool single,
|
||||||
|
string root,
|
||||||
|
|
||||||
|
// Miscellaneous
|
||||||
|
Logger logger,
|
||||||
|
bool keep,
|
||||||
|
bool clean)
|
||||||
|
{
|
||||||
|
// Open a file reader
|
||||||
|
Encoding enc = Style.GetEncoding(filename);
|
||||||
|
StreamReader sr = new StreamReader(File.OpenRead(filename), enc);
|
||||||
|
|
||||||
|
sr.ReadLine(); // Skip the first line since it's the header
|
||||||
|
while (!sr.EndOfStream)
|
||||||
|
{
|
||||||
|
string line = sr.ReadLine();
|
||||||
|
|
||||||
|
/*
|
||||||
|
The gameinfo order is as follows
|
||||||
|
0 - game name
|
||||||
|
1 - game description
|
||||||
|
2 - emulator name (filename)
|
||||||
|
3 - cloneof
|
||||||
|
4 - year
|
||||||
|
5 - manufacturer
|
||||||
|
6 - category
|
||||||
|
7 - players
|
||||||
|
8 - rotation
|
||||||
|
9 - control
|
||||||
|
10 - status
|
||||||
|
11 - displaycount
|
||||||
|
12 - displaytype
|
||||||
|
13 - alt romname
|
||||||
|
14 - alt title
|
||||||
|
15 - extra
|
||||||
|
16 - buttons
|
||||||
|
*/
|
||||||
|
|
||||||
|
string[] gameinfo = line.Split(';');
|
||||||
|
|
||||||
|
Rom rom = new Rom
|
||||||
|
{
|
||||||
|
Name = "-",
|
||||||
|
Size = Constants.SizeZero,
|
||||||
|
CRC = Constants.CRCZero,
|
||||||
|
MD5 = Constants.MD5Zero,
|
||||||
|
SHA1 = Constants.SHA1Zero,
|
||||||
|
ItemStatus = ItemStatus.None,
|
||||||
|
|
||||||
|
Machine = new Machine
|
||||||
|
{
|
||||||
|
Name = gameinfo[0],
|
||||||
|
Description = gameinfo[1],
|
||||||
|
CloneOf = gameinfo[3],
|
||||||
|
Year = gameinfo[4],
|
||||||
|
Manufacturer = gameinfo[5],
|
||||||
|
Comment = gameinfo[15],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Now process and add the rom
|
||||||
|
string key = "";
|
||||||
|
ParseAddHelper(rom, filter, trim, single, root, clean, logger, out key);
|
||||||
|
}
|
||||||
|
|
||||||
|
sr.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parse a ClrMamePro DAT and return all found games and roms within
|
/// Parse a ClrMamePro DAT and return all found games and roms within
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -5757,6 +5849,9 @@ namespace SabreTools.Helper.Dats
|
|||||||
string header = "";
|
string header = "";
|
||||||
switch (datFormat)
|
switch (datFormat)
|
||||||
{
|
{
|
||||||
|
case DatFormat.AttractMode:
|
||||||
|
header = "#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons\n";
|
||||||
|
break;
|
||||||
case DatFormat.ClrMamePro:
|
case DatFormat.ClrMamePro:
|
||||||
header = "clrmamepro (\n" +
|
header = "clrmamepro (\n" +
|
||||||
"\tname \"" + Name + "\"\n" +
|
"\tname \"" + Name + "\"\n" +
|
||||||
@@ -5964,6 +6059,25 @@ namespace SabreTools.Helper.Dats
|
|||||||
string state = "";
|
string state = "";
|
||||||
switch (datFormat)
|
switch (datFormat)
|
||||||
{
|
{
|
||||||
|
case DatFormat.AttractMode:
|
||||||
|
state += rom.Machine.Description + ";"
|
||||||
|
+ rom.Machine.Name + ";"
|
||||||
|
+ FileName + ";"
|
||||||
|
+ rom.Machine.CloneOf + ";"
|
||||||
|
+ rom.Machine.Year + ";"
|
||||||
|
+ rom.Machine.Manufacturer + ";"
|
||||||
|
/* + rom.Machine.Category */ + ";"
|
||||||
|
/* + rom.Machine.Players */ + ";"
|
||||||
|
/* + rom.Machine.Rotation */ + ";"
|
||||||
|
/* + rom.Machine.Control */ + ";"
|
||||||
|
/* + rom.Machine.Status */ + ";"
|
||||||
|
/* + rom.Machine.DisplayCount */ + ";"
|
||||||
|
/* + rom.Machine.DisplayType */ + ";"
|
||||||
|
/* + rom.Machine.AltRomname */ + ";"
|
||||||
|
/* + rom.Machine.AltTitle */ + ";"
|
||||||
|
+ rom.Machine.Comment + ";"
|
||||||
|
/* + rom.Machine.Buttons */ + "\n";
|
||||||
|
break;
|
||||||
case DatFormat.ClrMamePro:
|
case DatFormat.ClrMamePro:
|
||||||
state += "game (\n\tname \"" + rom.Machine.Name + "\"\n" +
|
state += "game (\n\tname \"" + rom.Machine.Name + "\"\n" +
|
||||||
(ExcludeOf ? "" :
|
(ExcludeOf ? "" :
|
||||||
|
|||||||
@@ -171,6 +171,9 @@ Options:
|
|||||||
Add outputting the created DAT in all available formats. See specific formats for
|
Add outputting the created DAT in all available formats. See specific formats for
|
||||||
additional flags that may be used.
|
additional flags that may be used.
|
||||||
|
|
||||||
|
-oam, --output-am Output in AttractMode format
|
||||||
|
Add outputting the created DAT to AttractMode format
|
||||||
|
|
||||||
-oc, --output-cmp Output in CMP format
|
-oc, --output-cmp Output in CMP format
|
||||||
Add outputting the created DAT to clrmamepro format
|
Add outputting the created DAT to clrmamepro format
|
||||||
|
|
||||||
@@ -348,7 +351,14 @@ Options:
|
|||||||
|
|
||||||
-s, --short Use short names for outputted DATs
|
-s, --short Use short names for outputted DATs
|
||||||
Instead of using ClrMamePro-style long names for DATs, use just the name of the
|
Instead of using ClrMamePro-style long names for DATs, use just the name of the
|
||||||
folder as the name of the DAT.
|
folder as the name of the DAT. This can be used inc onjunction with --base to
|
||||||
|
output in the format of "Original Name (Name)" instead.
|
||||||
|
|
||||||
|
-ba, --base Use source DAT as base name for outputs
|
||||||
|
If splitting an entire folder of DATs, some output files may be normally overwritten
|
||||||
|
since the names would be the same. With this flag, the original DAT name is used in
|
||||||
|
the output name, in the format of "Original Name (Dir - Name)". This can be used in
|
||||||
|
conjunction with --short to output in the format of "Original Name (Name)" instead.
|
||||||
|
|
||||||
-ss, --sort Sort input files by a set of DATs
|
-ss, --sort Sort input files by a set of DATs
|
||||||
This feature allows the user to quickly rebuild based on a supplied DAT file(s). By
|
This feature allows the user to quickly rebuild based on a supplied DAT file(s). By
|
||||||
@@ -515,6 +525,9 @@ Options:
|
|||||||
-oa, --output-all Output in all available formats
|
-oa, --output-all Output in all available formats
|
||||||
Add outputting the created DAT in all available formats. See specific formats for
|
Add outputting the created DAT in all available formats. See specific formats for
|
||||||
additional flags that may be used.
|
additional flags that may be used.
|
||||||
|
|
||||||
|
-oam, --output-am Output in AttractMode format
|
||||||
|
Add outputting the created DAT to AttractMode format
|
||||||
|
|
||||||
-oc, --output-cmp Output in CMP format
|
-oc, --output-cmp Output in CMP format
|
||||||
Add outputting the created DAT to clrmamepro format
|
Add outputting the created DAT to clrmamepro format
|
||||||
|
|||||||
@@ -158,6 +158,10 @@ namespace SabreTools.Helper.Tools
|
|||||||
{
|
{
|
||||||
return DatFormat.DOSCenter;
|
return DatFormat.DOSCenter;
|
||||||
}
|
}
|
||||||
|
else if (first.Contains("#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra"))
|
||||||
|
{
|
||||||
|
return DatFormat.AttractMode;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return DatFormat.ClrMamePro;
|
return DatFormat.ClrMamePro;
|
||||||
|
|||||||
@@ -102,6 +102,12 @@ namespace SabreTools.Helper.Tools
|
|||||||
|
|
||||||
// Get the extensions from the output type
|
// Get the extensions from the output type
|
||||||
|
|
||||||
|
// AttractMode
|
||||||
|
if ((datdata.DatFormat & DatFormat.AttractMode) != 0)
|
||||||
|
{
|
||||||
|
outfileNames.Add(DatFormat.AttractMode, CreateOutfileNamesHelper(outDir, ".txt", datdata, overwrite));
|
||||||
|
}
|
||||||
|
|
||||||
// ClrMamePro
|
// ClrMamePro
|
||||||
if ((datdata.DatFormat & DatFormat.ClrMamePro) != 0)
|
if ((datdata.DatFormat & DatFormat.ClrMamePro) != 0)
|
||||||
{
|
{
|
||||||
@@ -135,10 +141,16 @@ namespace SabreTools.Helper.Tools
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Missfile
|
// Missfile
|
||||||
if ((datdata.DatFormat & DatFormat.MissFile) != 0)
|
if ((datdata.DatFormat & DatFormat.MissFile) != 0
|
||||||
|
&& (datdata.DatFormat & DatFormat.AttractMode) == 0)
|
||||||
{
|
{
|
||||||
outfileNames.Add(DatFormat.MissFile, CreateOutfileNamesHelper(outDir, ".txt", datdata, overwrite));
|
outfileNames.Add(DatFormat.MissFile, CreateOutfileNamesHelper(outDir, ".txt", datdata, overwrite));
|
||||||
};
|
};
|
||||||
|
if ((datdata.DatFormat & DatFormat.MissFile) != 0
|
||||||
|
&& (datdata.DatFormat & DatFormat.AttractMode) != 0)
|
||||||
|
{
|
||||||
|
outfileNames.Add(DatFormat.MissFile, CreateOutfileNamesHelper(outDir, ".miss.txt", datdata, overwrite));
|
||||||
|
};
|
||||||
|
|
||||||
// OfflineList
|
// OfflineList
|
||||||
if (((datdata.DatFormat & DatFormat.OfflineList) != 0)
|
if (((datdata.DatFormat & DatFormat.OfflineList) != 0)
|
||||||
|
|||||||
@@ -302,6 +302,10 @@ namespace SabreTools
|
|||||||
case "--output-all":
|
case "--output-all":
|
||||||
datFormat |= DatFormat.ALL;
|
datFormat |= DatFormat.ALL;
|
||||||
break;
|
break;
|
||||||
|
case "-oam":
|
||||||
|
case "--output-am":
|
||||||
|
datFormat |= DatFormat.AttractMode;
|
||||||
|
break;
|
||||||
case "-oc":
|
case "-oc":
|
||||||
case "--output-cmp":
|
case "--output-cmp":
|
||||||
datFormat |= DatFormat.ClrMamePro;
|
datFormat |= DatFormat.ClrMamePro;
|
||||||
|
|||||||
Reference in New Issue
Block a user