mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Allow bulk conversions, and combine InitConvertX methods
This commit is contained in:
@@ -375,7 +375,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
foreach (string input in inputs)
|
foreach (string input in inputs)
|
||||||
{
|
{
|
||||||
InitConvertCMP(input);
|
InitConvert(input, OutputFormat.ClrMamePro);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,7 +384,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
foreach (string input in inputs)
|
foreach (string input in inputs)
|
||||||
{
|
{
|
||||||
InitConvertRC(input);
|
InitConvert(input, OutputFormat.RomCenter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,7 +393,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
foreach (string input in inputs)
|
foreach (string input in inputs)
|
||||||
{
|
{
|
||||||
InitConvertXML(input);
|
InitConvert(input, OutputFormat.Xml);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -708,7 +708,7 @@ or 'b' to go back to the previous menu:
|
|||||||
if (selection.ToLowerInvariant() != "b")
|
if (selection.ToLowerInvariant() != "b")
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
InitConvertCMP(selection);
|
InitConvert(selection, OutputFormat.ClrMamePro);
|
||||||
Console.Write("\nPress any key to continue...");
|
Console.Write("\nPress any key to continue...");
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
@@ -735,7 +735,7 @@ or 'b' to go back to the previous menu:
|
|||||||
if (selection.ToLowerInvariant() != "b")
|
if (selection.ToLowerInvariant() != "b")
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
InitConvertRC(selection);
|
InitConvert(selection, OutputFormat.RomCenter);
|
||||||
Console.Write("\nPress any key to continue...");
|
Console.Write("\nPress any key to continue...");
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
@@ -762,7 +762,7 @@ or 'b' to go back to the previous menu:
|
|||||||
if (selection.ToLowerInvariant() != "b")
|
if (selection.ToLowerInvariant() != "b")
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
InitConvertXML(selection);
|
InitConvert(selection, OutputFormat.Xml);
|
||||||
Console.Write("\nPress any key to continue...");
|
Console.Write("\nPress any key to continue...");
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
@@ -1307,11 +1307,13 @@ Make a selection:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wrap converting DAT file from any format to ClrMamePro
|
/// Wrap converting DAT file from any format to any format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename"></param>
|
/// <param name="filename"></param>
|
||||||
private static void InitConvertCMP(string filename)
|
/// <param name="outputFormat"></param>
|
||||||
|
private static void InitConvert(string filename, OutputFormat outputFormat)
|
||||||
{
|
{
|
||||||
|
filename = filename.Replace("\"", "");
|
||||||
if (File.Exists(filename))
|
if (File.Exists(filename))
|
||||||
{
|
{
|
||||||
logger.User("Converting " + filename);
|
logger.User("Converting " + filename);
|
||||||
@@ -1327,34 +1329,31 @@ Make a selection:
|
|||||||
Homepage = "",
|
Homepage = "",
|
||||||
Url = "",
|
Url = "",
|
||||||
Comment = "",
|
Comment = "",
|
||||||
OutputFormat = OutputFormat.ClrMamePro,
|
OutputFormat = outputFormat,
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
Roms = new Dictionary<string, List<RomData>>(),
|
||||||
MergeRoms = false,
|
MergeRoms = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
datdata = RomManipulation.Parse(filename, 0, 0, datdata, logger);
|
datdata = RomManipulation.Parse(filename, 0, 0, datdata, logger);
|
||||||
|
|
||||||
logger.User("datdata.Description: " + datdata.Description);
|
// Sometimes the description doesn't match the filename, change this
|
||||||
|
if (datdata.Description != Path.GetFileNameWithoutExtension(filename))
|
||||||
|
{
|
||||||
|
datdata.Description = Path.GetFileNameWithoutExtension(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the extension matches, append ".new" to the filename
|
||||||
|
if (Path.GetExtension(filename) == (datdata.OutputFormat == OutputFormat.Xml ? ".xml" : ".dat"))
|
||||||
|
{
|
||||||
datdata.Description += ".new";
|
datdata.Description += ".new";
|
||||||
|
}
|
||||||
|
|
||||||
Output.WriteDatfile(datdata, Path.GetDirectoryName(filename), logger);
|
Output.WriteDatfile(datdata, Path.GetDirectoryName(filename), logger);
|
||||||
}
|
}
|
||||||
else
|
else if (Directory.Exists(filename))
|
||||||
{
|
{
|
||||||
logger.Error("I'm sorry but " + filename + " doesn't exist!");
|
foreach (string file in Directory.EnumerateFiles(filename, "*", SearchOption.AllDirectories))
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Wrap converting DAT file from any format to RomCenter
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename"></param>
|
|
||||||
private static void InitConvertRC(string filename)
|
|
||||||
{
|
{
|
||||||
if (File.Exists(filename))
|
logger.User("Converting " + file);
|
||||||
{
|
|
||||||
logger.User("Converting " + filename);
|
|
||||||
DatData datdata = new DatData
|
DatData datdata = new DatData
|
||||||
{
|
{
|
||||||
Name = "",
|
Name = "",
|
||||||
@@ -1367,57 +1366,26 @@ Make a selection:
|
|||||||
Homepage = "",
|
Homepage = "",
|
||||||
Url = "",
|
Url = "",
|
||||||
Comment = "",
|
Comment = "",
|
||||||
OutputFormat = OutputFormat.RomCenter,
|
OutputFormat = outputFormat,
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
Roms = new Dictionary<string, List<RomData>>(),
|
||||||
MergeRoms = false,
|
MergeRoms = false,
|
||||||
};
|
};
|
||||||
|
datdata = RomManipulation.Parse(file, 0, 0, datdata, logger);
|
||||||
|
|
||||||
datdata = RomManipulation.Parse(filename, 0, 0, datdata, logger);
|
// Sometimes the description doesn't match the filename, change this
|
||||||
|
if (datdata.Description != Path.GetFileNameWithoutExtension(file))
|
||||||
logger.User("datdata.Description: " + datdata.Description);
|
{
|
||||||
|
datdata.Description = Path.GetFileNameWithoutExtension(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the extension matches, append ".new" to the filename
|
||||||
|
if (Path.GetExtension(file) == (datdata.OutputFormat == OutputFormat.Xml ? ".xml" : ".dat"))
|
||||||
|
{
|
||||||
datdata.Description += ".new";
|
datdata.Description += ".new";
|
||||||
Output.WriteDatfile(datdata, Path.GetDirectoryName(filename), logger);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.Error("I'm sorry but " + filename + " doesn't exist!");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
Output.WriteDatfile(datdata, Path.GetDirectoryName(file), logger);
|
||||||
/// Wrap converting DAT file from any format to XML
|
}
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename"></param>
|
|
||||||
private static void InitConvertXML(string filename)
|
|
||||||
{
|
|
||||||
if (File.Exists(filename))
|
|
||||||
{
|
|
||||||
logger.User("Converting " + filename);
|
|
||||||
DatData datdata = new DatData
|
|
||||||
{
|
|
||||||
Name = "",
|
|
||||||
Description = "",
|
|
||||||
Category = "",
|
|
||||||
Version = "",
|
|
||||||
Date = "",
|
|
||||||
Author = "",
|
|
||||||
Email = "",
|
|
||||||
Homepage = "",
|
|
||||||
Url = "",
|
|
||||||
Comment = "",
|
|
||||||
OutputFormat = OutputFormat.Xml,
|
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
MergeRoms = false,
|
|
||||||
};
|
|
||||||
|
|
||||||
datdata = RomManipulation.Parse(filename, 0, 0, datdata, logger);
|
|
||||||
|
|
||||||
logger.User("datdata.Description: " + datdata.Description);
|
|
||||||
|
|
||||||
datdata.Description += ".new";
|
|
||||||
Output.WriteDatfile(datdata, Path.GetDirectoryName(filename), logger);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user