mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, Filter, Utilties] Move helper methods to Utilities
This commit is contained in:
@@ -728,74 +728,5 @@ namespace SabreTools.Library.DatFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Static methods
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the machine type from a string
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="gametype">Machine type as a string</param>
|
|
||||||
/// <returns>A machine type based on the input</returns>
|
|
||||||
public static MachineType GetMachineTypeFromString(string gametype)
|
|
||||||
{
|
|
||||||
MachineType machineType = MachineType.NULL;
|
|
||||||
switch (gametype.ToLowerInvariant())
|
|
||||||
{
|
|
||||||
case "none":
|
|
||||||
machineType |= MachineType.None;
|
|
||||||
break;
|
|
||||||
case "bios":
|
|
||||||
machineType |= MachineType.Bios;
|
|
||||||
break;
|
|
||||||
case "dev":
|
|
||||||
case "device":
|
|
||||||
machineType |= MachineType.Device;
|
|
||||||
break;
|
|
||||||
case "mech":
|
|
||||||
case "mechanical":
|
|
||||||
machineType |= MachineType.Mechanical;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Globals.Logger.Warning("{0} is not a valid type", gametype);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return machineType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the item status from a string
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="status">Item status as a string</param>
|
|
||||||
/// <returns>An item status based on the input</returns>
|
|
||||||
public static ItemStatus GetStatusFromString(string status)
|
|
||||||
{
|
|
||||||
ItemStatus itemStatus = ItemStatus.NULL;
|
|
||||||
switch (status.ToLowerInvariant())
|
|
||||||
{
|
|
||||||
case "none":
|
|
||||||
itemStatus |= ItemStatus.None;
|
|
||||||
break;
|
|
||||||
case "good":
|
|
||||||
itemStatus |= ItemStatus.Good;
|
|
||||||
break;
|
|
||||||
case "baddump":
|
|
||||||
itemStatus |= ItemStatus.BadDump;
|
|
||||||
break;
|
|
||||||
case "nodump":
|
|
||||||
itemStatus |= ItemStatus.Nodump;
|
|
||||||
break;
|
|
||||||
case "verified":
|
|
||||||
itemStatus |= ItemStatus.Verified;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Globals.Logger.Warning("{0} is not a valid status", status);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,6 +362,52 @@ namespace SabreTools.Library.Tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get MachineType value from input string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gametype">String to get value from</param>
|
||||||
|
/// <returns>MachineType value corresponding to the string</returns>
|
||||||
|
public static MachineType GetMachineType(string gametype)
|
||||||
|
{
|
||||||
|
switch (gametype?.ToLowerInvariant())
|
||||||
|
{
|
||||||
|
case "none":
|
||||||
|
default:
|
||||||
|
return MachineType.None;
|
||||||
|
case "bios":
|
||||||
|
return MachineType.Bios;
|
||||||
|
case "dev":
|
||||||
|
case "device":
|
||||||
|
return MachineType.Device;
|
||||||
|
case "mech":
|
||||||
|
case "mechanical":
|
||||||
|
return MachineType.Mechanical;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get ItemStatus value from input string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="status">String to get value from</param>
|
||||||
|
/// <returns>ItemStatus value corresponding to the string</returns>
|
||||||
|
public static ItemStatus GetItemStatus(string status)
|
||||||
|
{
|
||||||
|
switch (status?.ToLowerInvariant())
|
||||||
|
{
|
||||||
|
case "none":
|
||||||
|
default:
|
||||||
|
return ItemStatus.None;
|
||||||
|
case "good":
|
||||||
|
return ItemStatus.Good;
|
||||||
|
case "baddump":
|
||||||
|
return ItemStatus.BadDump;
|
||||||
|
case "nodump":
|
||||||
|
return ItemStatus.Nodump;
|
||||||
|
case "verified":
|
||||||
|
return ItemStatus.Verified;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replace accented characters
|
/// Replace accented characters
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -740,7 +740,7 @@ namespace SabreTools
|
|||||||
break;
|
break;
|
||||||
case "-gt":
|
case "-gt":
|
||||||
case "--game-type":
|
case "--game-type":
|
||||||
filter.MachineTypes |= Filter.GetMachineTypeFromString(args[++i]);
|
filter.MachineTypes |= Utilities.GetMachineType(args[++i]);
|
||||||
break;
|
break;
|
||||||
case "-gz":
|
case "-gz":
|
||||||
case "--gz":
|
case "--gz":
|
||||||
@@ -759,7 +759,7 @@ namespace SabreTools
|
|||||||
break;
|
break;
|
||||||
case "-is":
|
case "-is":
|
||||||
case "--status":
|
case "--status":
|
||||||
filter.ItemStatuses |= Filter.GetStatusFromString(args[++i]);
|
filter.ItemStatuses |= Utilities.GetItemStatus(args[++i]);
|
||||||
break;
|
break;
|
||||||
case "-md5":
|
case "-md5":
|
||||||
case "--md5":
|
case "--md5":
|
||||||
@@ -790,11 +790,11 @@ namespace SabreTools
|
|||||||
break;
|
break;
|
||||||
case "-ngt":
|
case "-ngt":
|
||||||
case "--not-gtype":
|
case "--not-gtype":
|
||||||
filter.NotMachineTypes |= Filter.GetMachineTypeFromString(args[++i]);
|
filter.NotMachineTypes |= Utilities.GetMachineType(args[++i]);
|
||||||
break;
|
break;
|
||||||
case "-nis":
|
case "-nis":
|
||||||
case "--not-status":
|
case "--not-status":
|
||||||
filter.NotItemStatuses |= Filter.GetStatusFromString(args[++i]);
|
filter.NotItemStatuses |= Utilities.GetItemStatus(args[++i]);
|
||||||
break;
|
break;
|
||||||
case "-nmd5":
|
case "-nmd5":
|
||||||
case "--not-md5":
|
case "--not-md5":
|
||||||
@@ -1026,7 +1026,7 @@ namespace SabreTools
|
|||||||
break;
|
break;
|
||||||
case "-gt":
|
case "-gt":
|
||||||
case "--game-type":
|
case "--game-type":
|
||||||
filter.MachineTypes |= Filter.GetMachineTypeFromString(argsplit[1]);
|
filter.MachineTypes |= Utilities.GetMachineType(argsplit[1]);
|
||||||
break;
|
break;
|
||||||
case "-gz":
|
case "-gz":
|
||||||
case "--gz":
|
case "--gz":
|
||||||
@@ -1045,7 +1045,7 @@ namespace SabreTools
|
|||||||
break;
|
break;
|
||||||
case "-is":
|
case "-is":
|
||||||
case "--status":
|
case "--status":
|
||||||
filter.ItemStatuses |= Filter.GetStatusFromString(argsplit[1]);
|
filter.ItemStatuses |= Utilities.GetItemStatus(argsplit[1]);
|
||||||
break;
|
break;
|
||||||
case "-md5":
|
case "-md5":
|
||||||
case "--md5":
|
case "--md5":
|
||||||
@@ -1076,11 +1076,11 @@ namespace SabreTools
|
|||||||
break;
|
break;
|
||||||
case "-ngt":
|
case "-ngt":
|
||||||
case "--not-gtype":
|
case "--not-gtype":
|
||||||
filter.NotMachineTypes |= Filter.GetMachineTypeFromString(argsplit[1]);
|
filter.NotMachineTypes |= Utilities.GetMachineType(argsplit[1]);
|
||||||
break;
|
break;
|
||||||
case "-nis":
|
case "-nis":
|
||||||
case "--not-status":
|
case "--not-status":
|
||||||
filter.NotItemStatuses |= Filter.GetStatusFromString(argsplit[1]);
|
filter.NotItemStatuses |= Utilities.GetItemStatus(argsplit[1]);
|
||||||
break;
|
break;
|
||||||
case "-nmd5":
|
case "-nmd5":
|
||||||
case "--not-md5":
|
case "--not-md5":
|
||||||
|
|||||||
Reference in New Issue
Block a user