[SabreTools, DatFile, DatHeader, README.1ST] Add scene date strip (untested)

This commit is contained in:
Matt Nadareski
2017-10-30 15:17:13 -07:00
parent 91f52902dd
commit 2ddad9321b
6 changed files with 104 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web;
@@ -452,6 +453,27 @@ namespace SabreTools.Library.DatFiles
_datHeader.ExcludeOf = value;
}
}
public bool SceneDateStrip
{
get
{
if (_datHeader == null)
{
_datHeader = new DatHeader();
}
return _datHeader.SceneDateStrip;
}
set
{
if (_datHeader == null)
{
_datHeader = new DatHeader();
}
_datHeader.SceneDateStrip = value;
}
}
public DedupeType DedupeRoms
{
get
@@ -2441,6 +2463,42 @@ namespace SabreTools.Library.DatFiles
});
}
/// <summary>
/// Strip the dates from the beginning of scene-style set names
/// </summary>
private void StripSceneDatesFromItems()
{
// Output the logging statement
Globals.Logger.User("Stripping scene-style dates");
// Set the regex pattern to use
string pattern = @"([0-9]{2}\.[0-9]{2}\.[0-9]{2}-)(.*?-.*?)";
// Now process all of the roms
List<string> keys = Keys.ToList();
Parallel.ForEach(keys, Globals.ParallelOptions, key =>
{
List<DatItem> items = this[key];
for (int j = 0; j < items.Count; j++)
{
DatItem item = items[j];
if (Regex.IsMatch(item.MachineName, pattern))
{
Regex.Replace(item.MachineName, pattern, "$2");
}
if (Regex.IsMatch(item.MachineDescription, pattern))
{
Regex.Replace(item.MachineDescription, pattern, "$2");
}
items[j] = item;
}
Remove(key);
AddRange(key, items);
});
}
#endregion
#region Merging/Splitting
@@ -5555,6 +5613,12 @@ namespace SabreTools.Library.DatFiles
StripHashesFromItems();
}
// If we are removing scene dates, do that now
if (SceneDateStrip)
{
}
// Get the outfile names
Dictionary<DatFormat, string> outfiles = Style.CreateOutfileNames(outDir, this, overwrite);

View File

@@ -32,6 +32,7 @@ namespace SabreTools.Library.DatFiles
private ForcePacking _forcePacking;
private DatFormat _datFormat;
private bool _excludeOf;
private bool _sceneDateStrip;
private DedupeType _dedupeRoms;
private Hash _stripHash;
private bool _oneGameOneRegion;
@@ -148,6 +149,11 @@ namespace SabreTools.Library.DatFiles
get { return _excludeOf; }
set { _excludeOf = value; }
}
public bool SceneDateStrip
{
get { return _sceneDateStrip; }
set { _sceneDateStrip = value; }
}
public DedupeType DedupeRoms
{
get { return _dedupeRoms; }

View File

@@ -320,6 +320,11 @@ Options:
If this flag is enabled, then the romof, cloneof, and sampleof tags
will be omitted from the outputted DAT or DATs.
-sds, --scene-date-strip Remove date from scene-named sets
If this flag is enabled, sets with "scene" names will have the date
removed from the beginning. For example "01.01.01-Game_Name-GROUP"
would become "Game_Name-Group".
-ab, --add-blank Output blank files for folders
If this flag is set, then blank entries will be created for each of
the empty directories in the source. This is useful for tools that
@@ -1027,7 +1032,12 @@ Options:
-xof, --exclude-of Exclude romof, cloneof, sampleof tags
If this flag is enabled, then the romof, cloneof, and sampleof tags
will be omitted from the outputted DAT or DATs.
-sds, --scene-date-strip Remove date from scene-named sets
If this flag is enabled, sets with "scene" names will have the date
removed from the beginning. For example "01.01.01-Game_Name-GROUP"
would become "Game_Name-Group".
-clean Clean game names according to WoD standards
Game names will be santitized to remove what the original WoD
standards deemed as unneeded information, such as parenthized or

View File

@@ -260,6 +260,11 @@ namespace SabreTools
"Exclude romof, cloneof, sampleof tags",
FeatureType.Flag,
null));
datFromDir.AddFeature("scene-date-strip", new Feature(
new List<string>() { "-sds", "--scene-date-strip" },
"Remove date from scene-named sets",
FeatureType.Flag,
null));
datFromDir.AddFeature("add-blank", new Feature(
new List<string>() { "-ab", "--add-blank" },
"Output blank files for folders",
@@ -1045,6 +1050,11 @@ namespace SabreTools
"Exclude romof, cloneof, sampleof tags",
FeatureType.Flag,
null));
update.AddFeature("scene-date-strip", new Feature(
new List<string>() { "-sds", "--scene-date-strip" },
"Remove date from scene-named sets",
FeatureType.Flag,
null));
update.AddFeature("clean", new Feature(
new List<string>() { "-clean", "--clean" },
"Clean game names according to WoD standards",

View File

@@ -36,6 +36,7 @@ namespace SabreTools
/// <param name="comment">New comment</param>
/// <param name="forcepack">String representing the forcepacking flag</param>
/// <param name="excludeOf">True if cloneof, romof, and sampleof fields should be omitted from output, false otherwise</param>
/// <param name="sceneDateStrip">True if scene-named sets have the date stripped from the beginning, false otherwise</param>
/// <param name="datFormat">DatFormat to be used for outputting the DAT</param>
/// /* Standard DFD info */
/// <param name="romba">True to enable reading a directory like a Romba depot, false otherwise</param>
@@ -66,6 +67,7 @@ namespace SabreTools
string comment,
string forcepack,
bool excludeOf,
bool sceneDateStrip,
DatFormat datFormat,
/* Standard DFD info */
@@ -118,6 +120,7 @@ namespace SabreTools
DatFormat = (datFormat == 0 ? DatFormat.Logiqx : datFormat),
Romba = romba,
ExcludeOf = excludeOf,
SceneDateStrip = sceneDateStrip,
Type = (superdat ? "SuperDAT" : ""),
};
@@ -465,6 +468,7 @@ namespace SabreTools
/// <param name="forcend">None, Obsolete, Required, Ignore</param>
/// <param name="forcepack">None, Zip, Unzip</param>
/// <param name="excludeOf">True if cloneof, romof, and sampleof fields should be omitted from output, false otherwise</param>
/// <param name="sceneDateStrip">True if scene-named sets have the date stripped from the beginning, false otherwise</param>
/// <param name="datFormat">Non-zero flag for output format, zero otherwise for default</param>
/// /* Missfile-specific DAT info */
/// <param name="usegame">True if games are to be used in output, false if roms are</param>
@@ -521,6 +525,7 @@ namespace SabreTools
string forcend,
string forcepack,
bool excludeOf,
bool sceneDateStrip,
DatFormat datFormat,
/* Missfile-specific DAT info */
@@ -709,6 +714,7 @@ namespace SabreTools
ForcePacking = fp,
DedupeRoms = dedup,
ExcludeOf = excludeOf,
SceneDateStrip = sceneDateStrip,
DatFormat = datFormat,
StripHash = stripHash,
OneGameOneRegion = oneGameOneRegion,

View File

@@ -110,6 +110,7 @@ namespace SabreTools
removeDateFromAutomaticName = false,
removeUnicode = false,
romba = false,
sceneDateStrip = false,
showBaddumpColumn = false,
showNodumpColumn = false,
shortname = false,
@@ -571,6 +572,10 @@ namespace SabreTools
case "--superdat":
superdat = true;
break;
case "-sds":
case "--scene-date-strip":
sceneDateStrip = true;
break;
case "-sf":
case "--skip":
skip = true;
@@ -1241,7 +1246,7 @@ namespace SabreTools
if (datFromDir)
{
InitDatFromDir(inputs, filename, name, description, category, version, author, email, homepage, url, comment,
forcepack, excludeOf, datFormat, romba, superdat, omitFromScan, removeDateFromAutomaticName, parseArchivesAsFiles,
forcepack, excludeOf, sceneDateStrip, datFormat, romba, superdat, omitFromScan, removeDateFromAutomaticName, parseArchivesAsFiles,
enableGzip, skipFileType, addBlankFilesForEmptyFolder, addFileDates, tempDir, outDir, copyFiles, header);
}
@@ -1305,7 +1310,7 @@ namespace SabreTools
else if (update)
{
InitUpdate(inputs, basePaths, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header,
superdat, forcemerge, forcend, forcepack, excludeOf, datFormat, usegame, prefix, postfix, quotes, repext, addext, remext,
superdat, forcemerge, forcend, forcepack, excludeOf, sceneDateStrip, datFormat, usegame, prefix, postfix, quotes, repext, addext, remext,
datPrefix, romba, merge, diffMode, inplace, skip, removeDateFromAutomaticName, filter, oneGameOneRegion, regions,
splitType, trim, single, root, outDir, cleanGameNames, removeUnicode, descAsName, dedup, stripHash);
}