mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, Enums, DatFiles, Utilities] Add "Fields" (nw)
This commit is contained in:
@@ -451,6 +451,27 @@ namespace SabreTools.Library.DatFiles
|
||||
_datHeader.ExcludeOf = value;
|
||||
}
|
||||
}
|
||||
public List<Field> ExcludeFields
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_datHeader == null)
|
||||
{
|
||||
_datHeader = new DatHeader();
|
||||
}
|
||||
|
||||
return _datHeader.ExcludeFields;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_datHeader == null)
|
||||
{
|
||||
_datHeader = new DatHeader();
|
||||
}
|
||||
|
||||
_datHeader.ExcludeFields = value;
|
||||
}
|
||||
}
|
||||
public bool OneRom
|
||||
{
|
||||
get
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace SabreTools.Library.DatFiles
|
||||
private ForcePacking _forcePacking;
|
||||
private DatFormat _datFormat;
|
||||
private bool _excludeOf;
|
||||
private List<Field> _excludeFields;
|
||||
private bool _oneRom;
|
||||
private bool _keepEmptyGames;
|
||||
private bool _sceneDateStrip;
|
||||
@@ -149,6 +150,11 @@ namespace SabreTools.Library.DatFiles
|
||||
get { return _excludeOf; }
|
||||
set { _excludeOf = value; }
|
||||
}
|
||||
public List<Field> ExcludeFields
|
||||
{
|
||||
get { return _excludeFields; }
|
||||
set { _excludeFields = value; }
|
||||
}
|
||||
public bool OneRom
|
||||
{
|
||||
get { return _oneRom; }
|
||||
@@ -255,6 +261,7 @@ namespace SabreTools.Library.DatFiles
|
||||
_forcePacking = this._forcePacking,
|
||||
_datFormat = this._datFormat,
|
||||
_excludeOf = this._excludeOf,
|
||||
_excludeFields = this._excludeFields,
|
||||
_oneRom = this._oneRom,
|
||||
_keepEmptyGames = this._keepEmptyGames,
|
||||
_sceneDateStrip = this._sceneDateStrip,
|
||||
|
||||
@@ -357,6 +357,68 @@
|
||||
|
||||
#region DatItem related
|
||||
|
||||
/// <summary>
|
||||
/// List of valid field types within a DatItem/Machine
|
||||
/// </summary>
|
||||
public enum Field
|
||||
{
|
||||
NULL,
|
||||
|
||||
// Generic DatItem
|
||||
Name,
|
||||
PartName,
|
||||
PartInterface,
|
||||
Features,
|
||||
AreaName,
|
||||
AreaSize,
|
||||
|
||||
// Machine
|
||||
MachineName,
|
||||
Comment,
|
||||
Description,
|
||||
Year,
|
||||
Manufacturer,
|
||||
Publisher,
|
||||
RomOf,
|
||||
CloneOf,
|
||||
SampleOf,
|
||||
Supported,
|
||||
SourceFile,
|
||||
Runnable,
|
||||
Board,
|
||||
RebuildTo,
|
||||
Devices,
|
||||
SlotOptions,
|
||||
Infos,
|
||||
MachineType,
|
||||
|
||||
// BiosSet
|
||||
Default,
|
||||
|
||||
// Disk
|
||||
MD5,
|
||||
SHA1,
|
||||
SHA256,
|
||||
SHA384,
|
||||
SHA512,
|
||||
Merge,
|
||||
Region,
|
||||
Index,
|
||||
Writable,
|
||||
Optional,
|
||||
Status,
|
||||
|
||||
// Release
|
||||
Language,
|
||||
Date,
|
||||
|
||||
// Rom
|
||||
Bios,
|
||||
Size,
|
||||
CRC,
|
||||
Offset,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine what type of file an item is
|
||||
/// </summary>
|
||||
|
||||
@@ -786,6 +786,106 @@ namespace SabreTools.Library.Tools
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Field value from input string
|
||||
/// </summary>
|
||||
/// <param name="input">String to get value from</param>
|
||||
/// <returns>Field value corresponding to the string</returns>
|
||||
public static Field GetField(string input)
|
||||
{
|
||||
switch (input?.ToLowerInvariant())
|
||||
{
|
||||
case "areaname":
|
||||
return Field.AreaName;
|
||||
case "areasize":
|
||||
return Field.AreaSize;
|
||||
case "bios":
|
||||
return Field.Bios;
|
||||
case "board":
|
||||
return Field.Board;
|
||||
case "cloneof":
|
||||
return Field.CloneOf;
|
||||
case "comment":
|
||||
return Field.Comment;
|
||||
case "crc":
|
||||
return Field.CRC;
|
||||
case "default":
|
||||
return Field.Default;
|
||||
case "date":
|
||||
return Field.Date;
|
||||
case "description":
|
||||
return Field.Description;
|
||||
case "devices":
|
||||
return Field.Devices;
|
||||
case "features":
|
||||
return Field.Features;
|
||||
case "gamename":
|
||||
case "machinename":
|
||||
return Field.MachineName;
|
||||
case "gametype":
|
||||
case "machinetype":
|
||||
return Field.MachineType;
|
||||
case "index":
|
||||
return Field.Index;
|
||||
case "infos":
|
||||
return Field.Infos;
|
||||
case "language":
|
||||
return Field.Language;
|
||||
case "manufacturer":
|
||||
return Field.Manufacturer;
|
||||
case "md5":
|
||||
return Field.MD5;
|
||||
case "merge":
|
||||
return Field.Merge;
|
||||
case "name":
|
||||
return Field.Name;
|
||||
case "offset":
|
||||
return Field.Offset;
|
||||
case "optional":
|
||||
return Field.Optional;
|
||||
case "partinterface":
|
||||
return Field.PartInterface;
|
||||
case "partname":
|
||||
return Field.PartName;
|
||||
case "publisher":
|
||||
return Field.Publisher;
|
||||
case "rebuildto":
|
||||
return Field.RebuildTo;
|
||||
case "region":
|
||||
return Field.Region;
|
||||
case "romof":
|
||||
return Field.RomOf;
|
||||
case "runnable":
|
||||
return Field.Runnable;
|
||||
case "sampleof":
|
||||
return Field.SampleOf;
|
||||
case "sha1":
|
||||
return Field.SHA1;
|
||||
case "sha256":
|
||||
return Field.SHA256;
|
||||
case "sha384":
|
||||
return Field.SHA384;
|
||||
case "sha512":
|
||||
return Field.SHA512;
|
||||
case "size":
|
||||
return Field.Size;
|
||||
case "slotoptions":
|
||||
return Field.SlotOptions;
|
||||
case "sourcefile":
|
||||
return Field.SourceFile;
|
||||
case "status":
|
||||
return Field.Status;
|
||||
case "supported":
|
||||
return Field.Supported;
|
||||
case "writable":
|
||||
return Field.Writable;
|
||||
case "year":
|
||||
return Field.Year;
|
||||
default:
|
||||
return Field.NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get ForceMerging value from input string
|
||||
/// </summary>
|
||||
|
||||
@@ -1560,6 +1560,18 @@ namespace SabreTools
|
||||
longDescription: "User-supplied DAT for use in all operations. Multiple instances of this flag are allowed.");
|
||||
}
|
||||
}
|
||||
private static Feature _excludeFieldListInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Feature(
|
||||
"exclude-field",
|
||||
new List<string>() { "-ef", "--exclude-field" },
|
||||
"Exclude a game/rom field from outputs",
|
||||
FeatureType.List,
|
||||
longDescription: "Exclude any valid item or machine field from outputs. Examples include: romof, publisher, and offset.");
|
||||
}
|
||||
} // TODO: ADD THIS TO USED FLAGS
|
||||
private static Feature _extaListInput
|
||||
{
|
||||
get
|
||||
@@ -1920,6 +1932,18 @@ Possible values are:
|
||||
Possible values are: None, Good, BadDump, Nodump, Verified");
|
||||
}
|
||||
}
|
||||
private static Feature _updateFieldListInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Feature(
|
||||
"update-field",
|
||||
new List<string>() { "-uf", "--update-field" },
|
||||
"Update a game/rom field from base DAT(s)",
|
||||
FeatureType.List,
|
||||
longDescription: "Update any valid item or machine field from base DAT(s). Examples include: romof, publisher, and offset.");
|
||||
}
|
||||
} // TODO: ADD THIS TO USED FLAGS
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ namespace SabreTools
|
||||
List<string> exta = new List<string>();
|
||||
List<string> extb = new List<string>();
|
||||
List<string> inputs = new List<string>();
|
||||
List<Field> updateFields = new List<Field>();
|
||||
|
||||
// Get the first argument as a feature flag
|
||||
string feature = args[0];
|
||||
@@ -637,6 +638,12 @@ namespace SabreTools
|
||||
case "dat":
|
||||
datfiles.AddRange((List<string>)feat.Value.GetValue());
|
||||
break;
|
||||
case "exclude-field": // TODO: Use this
|
||||
foreach (string field in (List<string>)feat.Value.GetValue())
|
||||
{
|
||||
datHeader.ExcludeFields.Add(Utilities.GetField(field));
|
||||
}
|
||||
break;
|
||||
case "exta":
|
||||
exta.AddRange((List<string>)feat.Value.GetValue());
|
||||
break;
|
||||
@@ -741,6 +748,12 @@ namespace SabreTools
|
||||
filter.ItemStatuses |= Utilities.GetItemStatus(stat);
|
||||
}
|
||||
break;
|
||||
case "update-field": // TODO: Use this
|
||||
foreach (string field in (List<string>)feat.Value.GetValue())
|
||||
{
|
||||
updateFields.Add(Utilities.GetField(field));
|
||||
}
|
||||
break;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user