diff --git a/.gitignore b/.gitignore index f3b5429f..6b81aebd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,9 +5,6 @@ /DATFromDir/obj /DATFromDir/obj/Debug /DATFromDir/obj/Release -/DatToMiss/obj -/DatToMiss/obj/Debug -/DatToMiss/obj/Release /Deheader/obj /Deheader/obj/Debug /Deheader/obj/Release diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs index 85825a9d..9a43f9f8 100644 --- a/DATabase/DATabase.cs +++ b/DATabase/DATabase.cs @@ -51,6 +51,7 @@ namespace SabreTools // Set all default values bool help = false, add = false, + convertMiss = false, convertRV = false, convertXml = false, disableForce = false, @@ -63,13 +64,19 @@ namespace SabreTools listsys = false, norename = false, old = false, + quotes = false, rem = false, trim = false, - skip = false; - string exta = "", + skip = false, + usegame = true; + string addext = "", + exta = "", extb = "", manu = "", outdir = "", + postfix = "", + prefix = "", + repext = "", sources = "", systems = "", root = "", @@ -90,6 +97,10 @@ namespace SabreTools case "--add": add = true; break; + case "-cm": + case "--convert-miss": + convertMiss = true; + break; case "-cr": case "--convert-rv": convertRV = true; @@ -138,7 +149,15 @@ namespace SabreTools case "--romvault": old = true; break; + case "-q": + case "--quotes": + quotes = true; + break; case "-r": + case "--roms": + usegame = false; + break; + case "-rm": case "--remove": rem = true; break; @@ -150,7 +169,11 @@ namespace SabreTools trim = true; break; default: - if (arg.StartsWith("exta=")) + if (arg.StartsWith("-ae=") || arg.StartsWith("--add-ext=")) + { + addext = arg.Split('=')[1]; + } + else if (arg.StartsWith("exta=")) { exta = arg.Split('=')[1]; } @@ -170,6 +193,14 @@ namespace SabreTools { outdir = arg.Split('=')[1]; } + else if (arg.StartsWith("-post=") || arg.StartsWith("--postfix=")) + { + postfix = arg.Split('=')[1]; + } + else if (arg.StartsWith("-pre=") || arg.StartsWith("--prefix=")) + { + prefix = arg.Split('=')[1]; + } else if (arg.StartsWith("source=") && sources == "") { sources = arg.Split('=')[1]; @@ -178,10 +209,14 @@ namespace SabreTools { systems = arg.Split('=')[1]; } - else if(arg.StartsWith("-rd=") || arg.StartsWith("--root-dir=")) + else if (arg.StartsWith("-rd=") || arg.StartsWith("--root-dir=")) { root = arg.Split('=')[1]; } + else if (arg.StartsWith("-re=") || arg.StartsWith("--rep-ext=")) + { + repext = arg.Split('=')[1]; + } else if (arg.StartsWith("url=") && url == "") { url = arg.Split('=')[1]; @@ -201,7 +236,7 @@ namespace SabreTools } // If more than one switch is enabled or help is set, show the help screen - if (help || !(add ^ convertRV ^ convertXml ^ extsplit ^ generate ^ genall ^ import ^ listsrc ^ listsys ^ rem ^ trim)) + if (help || !(add ^ convertMiss ^ convertRV ^ convertXml ^ extsplit ^ generate ^ genall ^ import ^ listsrc ^ listsys ^ rem ^ trim)) { Build.Help(); logger.Close(); @@ -209,7 +244,7 @@ namespace SabreTools } // If a switch that requires a filename is set and no file is, show the help screen - if (inputs.Count == 0 && (convertRV || convertXml || extsplit || import || trim)) + if (inputs.Count == 0 && (convertMiss || convertRV || convertXml || extsplit || import || trim)) { Build.Help(); logger.Close(); @@ -254,6 +289,15 @@ namespace SabreTools ListSystems(); } + // Convert DAT to missfile + else if (convertMiss) + { + foreach (string input in inputs) + { + InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext); + } + } + // Convert XML DAT to RV DAT else if (convertRV) { @@ -689,8 +733,9 @@ Make a selection: 1) Convert XML DAT to RV 2) Convert RV DAT to XML - 3) Trim all entries in DAT and merge into a single game - 4) Split DAT using 2 extensions + 3) Convert DAT to missfile + 4) Trim all entries in DAT and merge into a single game + 5) Split DAT using 2 extensions B) Go back to the previous menu "); Console.Write("Enter selection: "); @@ -704,9 +749,12 @@ Make a selection: ConvertXMLMenu(); break; case "3": - TrimMergeMenu(); + ConvertMissMenu(); break; case "4": + TrimMergeMenu(); + break; + case "5": ExtSplitMenu(); break; } @@ -826,6 +874,107 @@ or 'b' to go back to the previous menu: return; } + /// + /// Show the text-based DAT to missfile conversion menu + /// + private static void ConvertMissMenu() + { + string selection = "", input = "", prefix = "", postfix = "", addext = "", repext = ""; + bool usegame = true, quotes = false; + while (selection.ToLowerInvariant() != "b") + { + Console.Clear(); + Build.Start("DATabase"); + Console.WriteLine(@"DAT -> MISS CONVERT MENU +=========================== +Make a selection: + + 1) File to convert" + (input != "" ? ":\n\t" + input : "") + @" + 2) " + (usegame ? "Output roms instead of games" : "Output games instead of roms") + @" + 3) Prefix to add to each line" + (prefix != "" ? ":\n\t" + prefix : "") + @" + 4) Postfix to add to each line" + (postfix != "" ? ":\n\t" + postfix : "") + @" + 5) " + (quotes ? "Don't add quotes around each item" : "Add quotes around each item") + @" + 6) Replace all extensions with another" + (repext != "" ? ":\t" + repext : "") + @" + 7) Add extensions to each item" + (addext != "" ? ":\n\t" + addext : "") + @" + 8) Begin conversion + B) Go back to the previous menu +"); + Console.Write("Enter selection: "); + selection = Console.ReadLine(); + switch (selection) + { + case "1": + Console.Clear(); + Console.Write("Please enter the file name: "); + input = Console.ReadLine(); + break; + case "2": + usegame = !usegame; + break; + case "3": + Console.Clear(); + Console.Write("Please enter the prefix: "); + prefix = Console.ReadLine(); + break; + case "4": + Console.Clear(); + Console.Write("Please enter the postfix: "); + postfix = Console.ReadLine(); + break; + case "5": + quotes = !quotes; + break; + case "6": + Console.Clear(); + Console.Write("Please enter the replacement extension: "); + postfix = Console.ReadLine(); + break; + case "7": + Console.Clear(); + Console.Write("Please enter the additional extension: "); + postfix = Console.ReadLine(); + break; + case "8": + Console.Clear(); + InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext); + Console.Write("\nPress any key to continue..."); + Console.ReadKey(); + break; + } + } + } + + /// + /// Wrap converting a DAT to missfile + /// + /// File to be converted + /// True if games are to be used in output, false if roms are + /// Generic prefix to be added to each line + /// Generic postfix to be added to each line + /// Add quotes to each item + /// Replace all extensions with another + /// Add an extension to all items + private static void InitConvertMiss(string input, bool usegame, string prefix, string postfix, bool quotes, string repext, string addext) + { + // Strip any quotations from the name + input = input.Replace("\"", ""); + + if (input != "" && File.Exists(input)) + { + // Get the full input name + input = Path.GetFullPath(input); + + // Get the output name + string name = Path.GetFileNameWithoutExtension(input) + "-miss.txt"; + + // Read in the roms from the DAT and then write them to the file + logger.Log("Converting " + input); + Output.WriteToText(name, Path.GetDirectoryName(input), RomManipulation.Parse(input, 0, 0, logger), logger, usegame, prefix, postfix, addext, repext, quotes); + logger.Log(input + " converted to: " + name); + return; + } + } + /// /// Show the text-based TrimMerge menu /// diff --git a/DatToMiss/App.config b/DatToMiss/App.config deleted file mode 100644 index 88fa4027..00000000 --- a/DatToMiss/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DatToMiss/DatToMiss.cs b/DatToMiss/DatToMiss.cs deleted file mode 100644 index d580d603..00000000 --- a/DatToMiss/DatToMiss.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; - -using SabreTools.Helper; - -namespace SabreTools -{ - public class DatToMiss - { - private static Logger logger; - - public static void Main(string[] args) - { - Console.Clear(); - - // Credits take precidence over all - if ((new List(args)).Contains("--credits")) - { - Build.Credits(); - return; - } - - if (args.Length == 0) - { - Build.Help(); - return; - } - - logger = new Logger(false, "dattomiss.log"); - logger.Start(); - - // Output the title - Build.Start("DatToMiss"); - - string prefix = "", postfix = "", input = "", addext = "", repext = ""; - bool tofile = false, help = false, usegame = true, quotes = false; - foreach (string arg in args) - { - switch (arg) - { - case "-h": - case "-?": - case "--help": - help = true; - break; - case "-l": - case "--log": - tofile = true; - break; - case "-r": - case "--roms": - usegame = false; - break; - case "-q": - case "--quotes": - quotes = true; - break; - default: - if (arg.StartsWith("-pre=") || arg.StartsWith("--prefix=")) - { - prefix = arg.Split('=')[1]; - } - else if (arg.StartsWith("-post=") || arg.StartsWith("--postfix=")) - { - postfix = arg.Split('=')[1]; - } - else if (arg.StartsWith("-ae=") || arg.StartsWith("--add-ext=")) - { - addext = arg.Split('=')[1]; - } - else if (arg.StartsWith("-re=") || arg.StartsWith("--rep-ext=")) - { - repext = arg.Split('=')[1]; - } - else if (input == "" && File.Exists(arg.Replace("\"", ""))) - { - input = arg.Replace("\"", ""); - } - else - { - logger.Warning("Incorrect param or extra input found: " + arg + Environment.NewLine); - Build.Help(); - logger.Close(); - return; - } - break; - } - } - - // Set the possibly new value for logger - logger.ToFile = tofile; - - // Show help if explicitly asked for it or if not enough files are supplied - if (help || input == "") - { - Build.Help(); - logger.Close(); - return; - } - - // Get the full input name - input = Path.GetFullPath(input); - - // Get the output name - string name = Path.GetFileNameWithoutExtension(input) + "-miss.txt"; - - // Read in the roms from the DAT and then write them to the file - Output.WriteToText(name, Path.GetDirectoryName(input), RomManipulation.Parse(input, 0, 0, logger), logger, usegame, prefix, postfix, addext, repext, quotes); - } - } -} diff --git a/DatToMiss/DatToMiss.csproj b/DatToMiss/DatToMiss.csproj deleted file mode 100644 index 5d977d57..00000000 --- a/DatToMiss/DatToMiss.csproj +++ /dev/null @@ -1,66 +0,0 @@ - - - - - Debug - AnyCPU - {5AB8A989-21FC-4491-B8DB-E0C5B3983896} - Exe - Properties - DatToMiss - DatToMiss - v4.5.2 - 512 - true - - - AnyCPU - true - full - false - ..\..\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - ..\..\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - {225a1afd-0890-44e8-b779-7502665c23a5} - SabreHelper - - - - - \ No newline at end of file diff --git a/DatToMiss/Properties/AssemblyInfo.cs b/DatToMiss/Properties/AssemblyInfo.cs deleted file mode 100644 index 0099f0c9..00000000 --- a/DatToMiss/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("DatToMiss")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("DatToMiss")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5ab8a989-21fc-4491-b8db-e0c5b3983896")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/README.MD b/README.MD index 98588472..7f7a83df 100644 --- a/README.MD +++ b/README.MD @@ -20,7 +20,7 @@ A bare-bones attempt at providing a true GUI experience for the SabreTools suite The main tool of the SabreTools suite. Performs the majority of the core features of the parent project, including the following: -DatToMiss -

-A program to convert a DAT to a miss file either for the games or the roms with the option to add a generic preface and postface to all of the outputted lines. -

Licensing

The preceeding programs use, in part or in whole, code, libraries, and/or applications from the 7-zip project. 7-zip is licenced under the GNU LGPL.
diff --git a/SabreHelper/Build.cs b/SabreHelper/Build.cs index 6d742388..0f32d141 100644 --- a/SabreHelper/Build.cs +++ b/SabreHelper/Build.cs @@ -87,6 +87,13 @@ Options: system= System name (system only) source= Source name (source only) url= URL (source only) + -cm, --convert-miss + -r, --roms Output roms to miss instead of sets + -pre=, --prefix= Set prefix to be printed in front of all lines + -post=, --postfix= Set postfix to be printed behind 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 -cr, --convert-rv Convert an XML DAT to RV out= Output directory -cx, --convert-xml Convert a RV DAT to XML @@ -106,7 +113,7 @@ Options: -l, --log Enable logging of program output -lso, --list-sources List all sources (id <= name) -lsy, --list-systems List all systems (id <= name) - -r, --remove Remove a system or source from the database + -rm, --remove Remove a system or source from the database system= System ID source= Source ID -tm, --trim-merge Consolidate DAT into a single game and trim entries @@ -159,21 +166,6 @@ Options: -di, --diff Switch to diffdat mode -dd, --dedup Enable deduping in the created DAT"); break; - case "DatToMiss": - Console.WriteLine(@"DatToMiss - Generate a miss file from a DAT ------------------------------------------ -Usage: DatToMiss [options] [filename] - -Options: - -h, -?, --help Show this help dialog - -l, --log Enable log to file - -r, --roms Output roms to miss instead of sets - -pre=, --prefix= Set prefix to be printed in front of all lines - -post=, --postfix= Set postfix to be printed behind all lines - -q, --quotes Put double-quotes around each outputted item (not prefix/postfix) - -ae=, --add-ext= Add an extension to each outputted item - -re=, --rep-ext= Replace all extensions with specified"); - break; default: Console.Write("This is the default help output"); break; diff --git a/SabreTools.sln b/SabreTools.sln index 28c3ea33..38d280d5 100644 --- a/SabreTools.sln +++ b/SabreTools.sln @@ -15,8 +15,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DATFromDir", "DATFromDir\DA EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MergeDAT", "MergeDAT\MergeDAT.csproj", "{785A4E9E-0DC1-4FAD-AA3A-57B5B122CD8E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatToMiss", "DatToMiss\DatToMiss.csproj", "{5AB8A989-21FC-4491-B8DB-E0C5B3983896}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -48,10 +46,6 @@ Global {785A4E9E-0DC1-4FAD-AA3A-57B5B122CD8E}.Debug|Any CPU.Build.0 = Debug|Any CPU {785A4E9E-0DC1-4FAD-AA3A-57B5B122CD8E}.Release|Any CPU.ActiveCfg = Release|Any CPU {785A4E9E-0DC1-4FAD-AA3A-57B5B122CD8E}.Release|Any CPU.Build.0 = Release|Any CPU - {5AB8A989-21FC-4491-B8DB-E0C5B3983896}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5AB8A989-21FC-4491-B8DB-E0C5B3983896}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5AB8A989-21FC-4491-B8DB-E0C5B3983896}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5AB8A989-21FC-4491-B8DB-E0C5B3983896}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE