Merge DatToMiss, parts 1-5

This commit is contained in:
Matt Nadareski
2016-04-20 15:09:26 -07:00
parent d97573848b
commit 3a88832980
9 changed files with 167 additions and 259 deletions

3
.gitignore vendored
View File

@@ -5,9 +5,6 @@
/DATFromDir/obj /DATFromDir/obj
/DATFromDir/obj/Debug /DATFromDir/obj/Debug
/DATFromDir/obj/Release /DATFromDir/obj/Release
/DatToMiss/obj
/DatToMiss/obj/Debug
/DatToMiss/obj/Release
/Deheader/obj /Deheader/obj
/Deheader/obj/Debug /Deheader/obj/Debug
/Deheader/obj/Release /Deheader/obj/Release

View File

@@ -51,6 +51,7 @@ namespace SabreTools
// Set all default values // Set all default values
bool help = false, bool help = false,
add = false, add = false,
convertMiss = false,
convertRV = false, convertRV = false,
convertXml = false, convertXml = false,
disableForce = false, disableForce = false,
@@ -63,13 +64,19 @@ namespace SabreTools
listsys = false, listsys = false,
norename = false, norename = false,
old = false, old = false,
quotes = false,
rem = false, rem = false,
trim = false, trim = false,
skip = false; skip = false,
string exta = "", usegame = true;
string addext = "",
exta = "",
extb = "", extb = "",
manu = "", manu = "",
outdir = "", outdir = "",
postfix = "",
prefix = "",
repext = "",
sources = "", sources = "",
systems = "", systems = "",
root = "", root = "",
@@ -90,6 +97,10 @@ namespace SabreTools
case "--add": case "--add":
add = true; add = true;
break; break;
case "-cm":
case "--convert-miss":
convertMiss = true;
break;
case "-cr": case "-cr":
case "--convert-rv": case "--convert-rv":
convertRV = true; convertRV = true;
@@ -138,7 +149,15 @@ namespace SabreTools
case "--romvault": case "--romvault":
old = true; old = true;
break; break;
case "-q":
case "--quotes":
quotes = true;
break;
case "-r": case "-r":
case "--roms":
usegame = false;
break;
case "-rm":
case "--remove": case "--remove":
rem = true; rem = true;
break; break;
@@ -150,7 +169,11 @@ namespace SabreTools
trim = true; trim = true;
break; break;
default: 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]; exta = arg.Split('=')[1];
} }
@@ -170,6 +193,14 @@ namespace SabreTools
{ {
outdir = arg.Split('=')[1]; 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 == "") else if (arg.StartsWith("source=") && sources == "")
{ {
sources = arg.Split('=')[1]; sources = arg.Split('=')[1];
@@ -178,10 +209,14 @@ namespace SabreTools
{ {
systems = arg.Split('=')[1]; 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]; root = arg.Split('=')[1];
} }
else if (arg.StartsWith("-re=") || arg.StartsWith("--rep-ext="))
{
repext = arg.Split('=')[1];
}
else if (arg.StartsWith("url=") && url == "") else if (arg.StartsWith("url=") && url == "")
{ {
url = arg.Split('=')[1]; 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 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(); Build.Help();
logger.Close(); 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 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(); Build.Help();
logger.Close(); logger.Close();
@@ -254,6 +289,15 @@ namespace SabreTools
ListSystems(); 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 // Convert XML DAT to RV DAT
else if (convertRV) else if (convertRV)
{ {
@@ -689,8 +733,9 @@ Make a selection:
1) Convert XML DAT to RV 1) Convert XML DAT to RV
2) Convert RV DAT to XML 2) Convert RV DAT to XML
3) Trim all entries in DAT and merge into a single game 3) Convert DAT to missfile
4) Split DAT using 2 extensions 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 B) Go back to the previous menu
"); ");
Console.Write("Enter selection: "); Console.Write("Enter selection: ");
@@ -704,9 +749,12 @@ Make a selection:
ConvertXMLMenu(); ConvertXMLMenu();
break; break;
case "3": case "3":
TrimMergeMenu(); ConvertMissMenu();
break; break;
case "4": case "4":
TrimMergeMenu();
break;
case "5":
ExtSplitMenu(); ExtSplitMenu();
break; break;
} }
@@ -826,6 +874,107 @@ or 'b' to go back to the previous menu:
return; return;
} }
/// <summary>
/// Show the text-based DAT to missfile conversion menu
/// </summary>
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;
}
}
}
/// <summary>
/// Wrap converting a DAT to missfile
/// </summary>
/// <param name="input">File to be converted</param>
/// <param name="usegame">True if games are to be used in output, false if roms are</param>
/// <param name="prefix">Generic prefix to be added to each line</param>
/// <param name="postfix">Generic postfix to be added to each line</param>
/// <param name="quotes">Add quotes to each item</param>
/// <param name="repext">Replace all extensions with another</param>
/// <param name="addext">Add an extension to all items</param>
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;
}
}
/// <summary> /// <summary>
/// Show the text-based TrimMerge menu /// Show the text-based TrimMerge menu
/// </summary> /// </summary>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

View File

@@ -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<string>(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);
}
}
}

View File

@@ -1,66 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5AB8A989-21FC-4491-B8DB-E0C5B3983896}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DatToMiss</RootNamespace>
<AssemblyName>DatToMiss</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DatToMiss.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SabreHelper\SabreHelper.csproj">
<Project>{225a1afd-0890-44e8-b779-7502665c23a5}</Project>
<Name>SabreHelper</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -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")]

View File

@@ -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: The main tool of the SabreTools suite. Performs the majority of the core features of the parent project, including the following:
<ul> <ul>
<li>Importing and Generating DAT files in RomVault and XML formats</li> <li>Importing and Generating DAT files in RomVault and XML formats</li>
<li>Converting DATs from RomVault to XML format</li> <li>Converting DATs from RomVault to XML format, vice versa, and to missfile (last part formerly <i>DatToMiss</i>; requested by Obiwantje)</li>
<li>Trim DAT entries and optionally merge into a single game (formerly <i>SingleGame</i>; requested by Kludge)</li> <li>Trim DAT entries and optionally merge into a single game (formerly <i>SingleGame</i>; requested by Kludge)</li>
<li>Split a DAT using two different file extensions within the DAT (formerly <i>DatSplit</i>)</li> <li>Split a DAT using two different file extensions within the DAT (formerly <i>DatSplit</i>)</li>
<li>Add and remove sources and systems from the database</li> <li>Add and remove sources and systems from the database</li>
@@ -76,10 +76,6 @@ A program to merge (or diff) an arbitrary number of DATs
<li>Optionally merge the output DAT so no partial duplicates are included</li> <li>Optionally merge the output DAT so no partial duplicates are included</li>
</ul> </ul>
<b>DatToMiss</b>
<p/>
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.
<h3>Licensing</h3> <h3>Licensing</h3>
<p/> <p/>
The preceeding programs use, in part or in whole, code, libraries, and/or applications from the <a href="www.7-zip.org">7-zip project</a>. 7-zip is licenced under the GNU LGPL.<br/> The preceeding programs use, in part or in whole, code, libraries, and/or applications from the <a href="www.7-zip.org">7-zip project</a>. 7-zip is licenced under the GNU LGPL.<br/>

View File

@@ -87,6 +87,13 @@ Options:
system= System name (system only) system= System name (system only)
source= Source name (source only) source= Source name (source only)
url= URL (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 -cr, --convert-rv Convert an XML DAT to RV
out= Output directory out= Output directory
-cx, --convert-xml Convert a RV DAT to XML -cx, --convert-xml Convert a RV DAT to XML
@@ -106,7 +113,7 @@ Options:
-l, --log Enable logging of program output -l, --log Enable logging of program output
-lso, --list-sources List all sources (id <= name) -lso, --list-sources List all sources (id <= name)
-lsy, --list-systems List all systems (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 system= System ID
source= Source ID source= Source ID
-tm, --trim-merge Consolidate DAT into a single game and trim entries -tm, --trim-merge Consolidate DAT into a single game and trim entries
@@ -159,21 +166,6 @@ Options:
-di, --diff Switch to diffdat mode -di, --diff Switch to diffdat mode
-dd, --dedup Enable deduping in the created DAT"); -dd, --dedup Enable deduping in the created DAT");
break; 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: default:
Console.Write("This is the default help output"); Console.Write("This is the default help output");
break; break;

View File

@@ -15,8 +15,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DATFromDir", "DATFromDir\DA
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MergeDAT", "MergeDAT\MergeDAT.csproj", "{785A4E9E-0DC1-4FAD-AA3A-57B5B122CD8E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MergeDAT", "MergeDAT\MergeDAT.csproj", "{785A4E9E-0DC1-4FAD-AA3A-57B5B122CD8E}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatToMiss", "DatToMiss\DatToMiss.csproj", "{5AB8A989-21FC-4491-B8DB-E0C5B3983896}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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}.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.ActiveCfg = Release|Any CPU
{785A4E9E-0DC1-4FAD-AA3A-57B5B122CD8E}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE