2016-04-06 14:19:01 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
|
|
namespace SabreTools.Helper
|
2016-04-06 00:01:54 -07:00
|
|
|
|
{
|
|
|
|
|
|
public class Build
|
|
|
|
|
|
{
|
2016-04-12 16:23:17 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns true if running in a Mono environment
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static bool MonoEnvironment
|
|
|
|
|
|
{
|
2016-04-12 16:33:15 -07:00
|
|
|
|
get { return (Type.GetType("Mono.Runtime") != null); }
|
2016-04-12 16:24:38 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-18 20:04:38 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Readies the console and outputs the header
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name">The name to be displayed as the program</param>
|
|
|
|
|
|
/// <remarks>Adapted from http://stackoverflow.com/questions/8200661/how-to-align-string-in-fixed-length-string</remarks>
|
|
|
|
|
|
public static void Start(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Dynamically create the header string
|
|
|
|
|
|
string border = "+-----------------------------------------------------------------------------+";
|
2016-05-22 13:15:13 -07:00
|
|
|
|
string mid = name + " " + Constants.Version;
|
2016-04-18 20:04:38 -07:00
|
|
|
|
mid = "|" + mid.PadLeft(((77 - mid.Length) / 2) + mid.Length).PadRight(77) + "|";
|
|
|
|
|
|
|
2016-06-10 01:38:58 -07:00
|
|
|
|
// If we're outputting to console, do fancy things
|
|
|
|
|
|
if (!Console.IsOutputRedirected)
|
2016-04-20 11:50:03 -07:00
|
|
|
|
{
|
2016-06-10 01:38:58 -07:00
|
|
|
|
// Set the console to ready state
|
|
|
|
|
|
ConsoleColor formertext = ConsoleColor.White;
|
|
|
|
|
|
ConsoleColor formerback = ConsoleColor.Black;
|
|
|
|
|
|
if (!MonoEnvironment)
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.SetBufferSize(Console.BufferWidth, 999);
|
|
|
|
|
|
formertext = Console.ForegroundColor;
|
|
|
|
|
|
formerback = Console.BackgroundColor;
|
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
|
|
|
|
|
Console.BackgroundColor = ConsoleColor.Blue;
|
|
|
|
|
|
}
|
2016-04-20 11:50:03 -07:00
|
|
|
|
|
2016-06-10 01:38:58 -07:00
|
|
|
|
Console.Title = "SabreTools-" + name + " " + Constants.Version;
|
2016-04-18 20:04:38 -07:00
|
|
|
|
|
2016-06-10 01:38:58 -07:00
|
|
|
|
// Output the header
|
|
|
|
|
|
Console.WriteLine(border);
|
|
|
|
|
|
Console.WriteLine(mid);
|
|
|
|
|
|
Console.WriteLine(border);
|
|
|
|
|
|
Console.WriteLine();
|
2016-04-18 20:04:38 -07:00
|
|
|
|
|
2016-06-10 01:38:58 -07:00
|
|
|
|
// Return the console to the original text and background colors
|
|
|
|
|
|
if (!MonoEnvironment)
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.ForegroundColor = formertext;
|
|
|
|
|
|
Console.BackgroundColor = formerback;
|
|
|
|
|
|
}
|
2016-04-20 11:50:03 -07:00
|
|
|
|
}
|
2016-04-18 20:04:38 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-06 14:19:01 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Show the help dialog for a given class
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void Help()
|
|
|
|
|
|
{
|
|
|
|
|
|
//http://stackoverflow.com/questions/14849367/how-to-determine-calling-method-and-class-name
|
|
|
|
|
|
StackTrace st = new StackTrace();
|
|
|
|
|
|
string className = st.GetFrame(1).GetMethod().ReflectedType.Name;
|
|
|
|
|
|
|
|
|
|
|
|
switch (className)
|
|
|
|
|
|
{
|
|
|
|
|
|
case "DATabase":
|
|
|
|
|
|
Console.Write(@"
|
|
|
|
|
|
DATabase - Import and Generate DAT files
|
|
|
|
|
|
-----------------------------------------
|
2016-04-20 01:47:44 -07:00
|
|
|
|
Usage: DATabase [option] [filename|dirname] ...
|
2016-04-06 14:19:01 -07:00
|
|
|
|
|
|
|
|
|
|
Options:
|
2016-04-20 00:01:58 -07:00
|
|
|
|
-?, -h, --help Show this help
|
|
|
|
|
|
-a, --add Add a new system or source to the database
|
2016-05-04 15:09:31 -07:00
|
|
|
|
-manu= Manufacturer name (system only)
|
|
|
|
|
|
-system= System name (system only)
|
|
|
|
|
|
-source= Source name (source only)
|
|
|
|
|
|
-url= URL (source only)
|
2016-04-20 11:27:17 -07:00
|
|
|
|
-es, --ext-split Split a DAT by two file extensions
|
2016-06-10 17:06:02 -07:00
|
|
|
|
-exta= First set of extensions (comma-separated)
|
|
|
|
|
|
-extb= Second set of extensions (comma-separated)
|
2016-05-04 15:09:31 -07:00
|
|
|
|
-out= Output directory
|
2016-04-06 14:19:01 -07:00
|
|
|
|
-g, --generate Start tool in generate mode
|
2016-05-28 16:36:39 -07:00
|
|
|
|
-system= System ID to generate from
|
2016-04-20 00:50:31 -07:00
|
|
|
|
-nr, --no-rename Don't auto-rename games
|
2016-04-20 21:55:28 -07:00
|
|
|
|
-o, --old Output DAT in CMP format instead of XML
|
|
|
|
|
|
-ga, --generate-all Start tool in generate all mode
|
|
|
|
|
|
-nr, --no-rename Don't auto-rename games
|
|
|
|
|
|
-o, --old Output DAT in CMP format instead of XML
|
2016-05-22 12:45:20 -07:00
|
|
|
|
-hs, --hash-split Split a DAT or folder by best-available hashes
|
|
|
|
|
|
-out= Output directory
|
2016-04-20 00:01:58 -07:00
|
|
|
|
-i, --import Start tool in import mode
|
2016-05-28 16:36:39 -07:00
|
|
|
|
-ig, --ignore Don't prompt for new sources
|
2016-04-06 14:19:01 -07:00
|
|
|
|
-lso, --list-sources List all sources (id <= name)
|
2016-04-21 14:21:40 -07:00
|
|
|
|
-lsy, --list-systems List all systems (id <= name)
|
2016-04-26 13:17:24 -07:00
|
|
|
|
-m, --merge Merge one or more DATs
|
2016-05-11 09:16:46 -07:00
|
|
|
|
-di, --diff Output all diffdats (merge flag not required)
|
2016-05-19 12:43:30 -07:00
|
|
|
|
-c, --cascade Enable cascaded diffing
|
2016-05-26 21:57:36 -07:00
|
|
|
|
-ip, --inplace Enable inplace, cascaded diffing
|
2016-04-21 13:32:35 -07:00
|
|
|
|
-dd, --dedup Enable deduping in the created DAT
|
|
|
|
|
|
-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
|
2016-05-29 14:04:06 -07:00
|
|
|
|
-clean Clean game names according to WoD standards
|
2016-05-27 13:04:53 -07:00
|
|
|
|
-out= Output directory (overridden by --inplace)
|
2016-05-17 23:29:03 -07:00
|
|
|
|
-sd, --superdat Enable SuperDAT creation
|
2016-05-17 00:38:51 -07:00
|
|
|
|
-n=, --name= Set the internal name of the DAT
|
2016-06-10 01:38:58 -07:00
|
|
|
|
-de=, --desc= Set the filename and description of the DAT
|
|
|
|
|
|
-ca=, --category= Set the category of the DAT
|
2016-04-21 14:21:40 -07:00
|
|
|
|
-v=, --version= Set the version of the DAT
|
|
|
|
|
|
-au=, --author= Set the author of the DAT
|
2016-04-21 14:35:11 -07:00
|
|
|
|
-rm, --remove Remove a system or source from the database
|
2016-05-04 15:09:31 -07:00
|
|
|
|
-system= System ID
|
|
|
|
|
|
-source= Source ID
|
2016-05-27 09:38:25 -07:00
|
|
|
|
-st, --stats Get statistics on all input DATs
|
|
|
|
|
|
-si, --single Show individual statistics
|
2016-04-20 01:27:15 -07:00
|
|
|
|
-tm, --trim-merge Consolidate DAT into a single game and trim entries
|
2016-04-21 15:24:31 -07:00
|
|
|
|
-rd=, --root-dir= Set the root directory for trimming calculation
|
2016-04-21 15:04:01 -07:00
|
|
|
|
-nr, --no-rename Keep game names instead of using '!'
|
2016-04-20 00:50:31 -07:00
|
|
|
|
-df, --disable-force Disable forceunzipping
|
2016-06-10 01:38:58 -07:00
|
|
|
|
-ud, --update Update a DAT file
|
|
|
|
|
|
-oc, --output-cmp Output in CMP format
|
|
|
|
|
|
-om, --output-miss Output in Missfile format
|
2016-06-10 13:28:11 -07:00
|
|
|
|
-r, --roms Output roms to miss instead of sets
|
2016-06-10 01:38:58 -07:00
|
|
|
|
-gp, --game-prefix Add game name as a prefix to each item
|
2016-06-10 13:28:11 -07:00
|
|
|
|
-pre=, --prefix= Set prefix for all lines
|
|
|
|
|
|
-post=, --postfix= Set postfix for all lines
|
|
|
|
|
|
-q, --quotes Put double-quotes around each item
|
|
|
|
|
|
-ae=, --add-ext= Add an extension to each item
|
|
|
|
|
|
-re=, --rep-ext= Replace all extensions with specified
|
|
|
|
|
|
-ro, --romba Output in Romba format (requires SHA-1)
|
|
|
|
|
|
-tsv, --tsv Output in Tab-Separated Value format
|
2016-06-10 01:38:58 -07:00
|
|
|
|
-or, --output-rc Output in RomCenter format
|
|
|
|
|
|
-os, --output-sd Output in SabreDAT format
|
|
|
|
|
|
-ox, --output-xml Output in Logiqx XML format
|
|
|
|
|
|
-f=, --filename= Set a new filename
|
|
|
|
|
|
-n=, --name= Set a new internal name
|
|
|
|
|
|
-de=, --desc= Set a new description
|
|
|
|
|
|
-ca=, --category= Set a new category
|
|
|
|
|
|
-v=, --version= Set a new version
|
|
|
|
|
|
-da=, --date= Set a new date
|
|
|
|
|
|
-au=, --author= Set a new author
|
|
|
|
|
|
-em=, --email= Set a new email
|
|
|
|
|
|
-hp=, --homepage= Set a new homepage
|
|
|
|
|
|
-u=, --url= Set a new URL
|
|
|
|
|
|
-co=, --comment= Set a new comment
|
|
|
|
|
|
-h=, --header= Set a new header skipper
|
|
|
|
|
|
-sd=, --superdat Set SuperDAT type
|
|
|
|
|
|
-fm=, --forcemerge= Set force merging
|
|
|
|
|
|
Supported values are:
|
2016-06-10 13:34:17 -07:00
|
|
|
|
None, Split, Full
|
2016-06-10 01:38:58 -07:00
|
|
|
|
-fn=, --forcend= Set force nodump
|
|
|
|
|
|
Supported values are:
|
2016-06-10 13:34:17 -07:00
|
|
|
|
None, Obsolete, Required, Ignore
|
2016-06-10 01:38:58 -07:00
|
|
|
|
-fp=, --forcepack= Set force packing
|
|
|
|
|
|
Supported values are:
|
2016-06-10 13:34:17 -07:00
|
|
|
|
None, Zip, Unzip
|
2016-06-10 01:38:58 -07:00
|
|
|
|
-clean Clean game names according to WoD standards
|
2016-06-11 14:25:25 -07:00
|
|
|
|
-dd, --dedup Enable deduping in the created DAT
|
2016-06-11 15:13:08 -07:00
|
|
|
|
-gn=, --game-name= Filter by game name
|
|
|
|
|
|
-rn=, --rom-name= Filter by rom name
|
|
|
|
|
|
-rt=, --rom-type= Filter by rom type
|
|
|
|
|
|
-sgt=, --greater= Filter by size >=
|
|
|
|
|
|
-slt=, --less= Filter by size <=
|
|
|
|
|
|
-seq=, --equal= Filter by size ==
|
|
|
|
|
|
-crc=, --crc= Filter by CRC hash
|
|
|
|
|
|
-md5=, --md5= Filter by MD5 hash
|
|
|
|
|
|
-sha1=, --sha1= Filter by SHA-1 hash
|
|
|
|
|
|
-nd, --nodump Include only match nodump roms
|
|
|
|
|
|
-nnd, --not-nodump Exclude all nodump roms
|
2016-06-10 01:38:58 -07:00
|
|
|
|
-out= Output directory
|
2016-04-06 14:19:01 -07:00
|
|
|
|
|
2016-04-20 01:27:15 -07:00
|
|
|
|
Filenames and directories can't start with a reserved string
|
2016-04-20 00:01:58 -07:00
|
|
|
|
unless prefixed by 'input='
|
2016-06-10 13:23:08 -07:00
|
|
|
|
|
2016-06-11 15:14:15 -07:00
|
|
|
|
Filter parameters game name, rom name, CRC, MD5, SHA-1 can
|
2016-06-10 13:28:11 -07:00
|
|
|
|
do partial matches using asterisks as follows (case insensitive):
|
2016-06-10 13:23:08 -07:00
|
|
|
|
*00 means ends with '00'
|
|
|
|
|
|
00* means starts with '00'
|
|
|
|
|
|
*00* means contains '00'
|
|
|
|
|
|
00 means exactly equals '00'");
|
2016-04-06 14:19:01 -07:00
|
|
|
|
break;
|
|
|
|
|
|
case "Headerer":
|
|
|
|
|
|
Console.WriteLine(@"Headerer - Remove and restore rom headers
|
|
|
|
|
|
-----------------------------------------
|
|
|
|
|
|
Usage: Headerer [option] [filename|dirname]
|
|
|
|
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
|
-e Detect and remove mode
|
|
|
|
|
|
-r Restore header to file based on SHA-1");
|
|
|
|
|
|
break;
|
2016-04-12 14:56:59 -07:00
|
|
|
|
case "DATFromDir":
|
|
|
|
|
|
Console.WriteLine(@"DATFromDir - Create a DAT file from a directory
|
|
|
|
|
|
-----------------------------------------
|
|
|
|
|
|
Usage: DATFromDir [options] [filename|dirname] <filename|dirname> ...
|
|
|
|
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
|
-h, -?, --help Show this help dialog
|
|
|
|
|
|
-m, --noMD5 Don't include MD5 in output
|
|
|
|
|
|
-s, --noSHA1 Don't include SHA1 in output
|
2016-04-12 23:46:10 -07:00
|
|
|
|
-b, --bare Don't include date in file name
|
2016-04-12 14:56:59 -07:00
|
|
|
|
-u, --unzip Force unzipping in created DAT
|
|
|
|
|
|
-f, --files Treat archives as files
|
2016-04-20 21:55:28 -07:00
|
|
|
|
-o, --old Output DAT in CMP format instead of XML
|
2016-05-22 17:38:17 -07:00
|
|
|
|
-gz, --gz-files Allow reading of GZIP files as archives
|
|
|
|
|
|
-ro, --romba Read files from a Romba input
|
2016-05-17 00:38:51 -07:00
|
|
|
|
-n=, --name= Set the internal name of the DAT
|
|
|
|
|
|
-d=, --desc= Set the filename and description of the DAT
|
2016-04-12 14:56:59 -07:00
|
|
|
|
-c=, --cat= Set the category of the DAT
|
|
|
|
|
|
-v=, --version= Set the version of the DAT
|
2016-04-21 13:32:35 -07:00
|
|
|
|
-au=, --author= Set the author of the DAT
|
2016-05-28 15:54:06 -07:00
|
|
|
|
-sd, --superdat Enable SuperDAT creation
|
|
|
|
|
|
-t=, --temp= Set the temporary directory to use");
|
2016-04-12 14:56:59 -07:00
|
|
|
|
break;
|
2016-04-28 15:40:54 -07:00
|
|
|
|
case "OfflineMerge":
|
|
|
|
|
|
Console.WriteLine(@"OfflineMerge - Update DATS for offline arrays
|
|
|
|
|
|
-----------------------------------------
|
2016-05-04 14:43:40 -07:00
|
|
|
|
Usage: OfflineMerge [options] [inputs]
|
2016-04-28 15:40:54 -07:00
|
|
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
|
-h, -?, --help Show this help dialog
|
2016-04-28 15:57:38 -07:00
|
|
|
|
-f, --fake Replace all hashes and sizes by the default
|
|
|
|
|
|
|
2016-05-04 14:43:40 -07:00
|
|
|
|
Inputs:
|
2016-05-04 15:09:31 -07:00
|
|
|
|
-com= Complete current DAT
|
|
|
|
|
|
-fix= Complete current Missing
|
|
|
|
|
|
-new= New Complete DAT
|
2016-05-04 14:43:40 -07:00
|
|
|
|
|
2016-04-28 15:57:38 -07:00
|
|
|
|
This program will output the following DATs:
|
|
|
|
|
|
(a) Net New - (NewComplete)-(Complete)
|
|
|
|
|
|
(b) Unneeded - (Complete)-(NewComplete)
|
2016-05-03 13:53:06 -07:00
|
|
|
|
(c) New Missing - (Net New)+(Missing-(Unneeded))
|
2016-05-04 14:43:40 -07:00
|
|
|
|
(d) Have - (NewComplete)-(New Missing)
|
|
|
|
|
|
OR (Complete or NewComplete)-(Missing) if one is missing");
|
2016-04-28 15:40:54 -07:00
|
|
|
|
break;
|
2016-04-06 14:19:01 -07:00
|
|
|
|
default:
|
|
|
|
|
|
Console.Write("This is the default help output");
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-04-18 16:20:12 -07:00
|
|
|
|
|
|
|
|
|
|
public static void Credits()
|
|
|
|
|
|
{
|
2016-04-18 16:47:59 -07:00
|
|
|
|
Console.WriteLine(@"-----------------------------------------
|
2016-04-18 16:20:12 -07:00
|
|
|
|
Credits
|
|
|
|
|
|
-----------------------------------------
|
2016-04-18 16:47:59 -07:00
|
|
|
|
|
|
|
|
|
|
Programmer / Lead: Matt Nadareski (darksabre76)
|
|
|
|
|
|
Additional code: emuLOAD, @tractivo
|
2016-05-23 20:12:53 -07:00
|
|
|
|
Testing: emuLOAD, @tractivo, Kludge, Obiwantje, edc
|
|
|
|
|
|
Suggestions: edc, AcidX, Amiga12, EliUmniCk
|
2016-04-18 16:47:59 -07:00
|
|
|
|
Based on work by: The Wizard of DATz");
|
2016-04-18 16:20:12 -07:00
|
|
|
|
}
|
2016-04-06 00:01:54 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|