mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
|
|
using System.Collections.Generic;
|
|||
|
|
using Mono.Data.Sqlite;
|
|||
|
|
|
|||
|
|
using SabreTools.Helper;
|
|||
|
|
|
|||
|
|
namespace SabreTools
|
|||
|
|
{
|
|||
|
|
public partial class DATabase
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Wrap generating a DAT from the library
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="system">System ID to be used in the DAT (blank means all)</param>
|
|||
|
|
/// <param name="norename">True if files should not be renamed with system and/or source in merged mode (default false)</param>
|
|||
|
|
/// <param name="old">True if the output file should be in ClrMamePro format (default false)</param>
|
|||
|
|
private static void InitGenerate(string systemid, bool norename, bool old)
|
|||
|
|
{
|
|||
|
|
IGenerate gen = new GenerateTwo(systemid, "" /* sourceid */, _datroot, _outroot, _connectionString, _logger, norename, old);
|
|||
|
|
gen.Export();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Wrap generating all standard DATs from the library
|
|||
|
|
/// </summary>
|
|||
|
|
private static void InitGenerateAll(bool norename, bool old)
|
|||
|
|
{
|
|||
|
|
List<string> systems = new List<string>();
|
|||
|
|
using (SqliteConnection dbc = new SqliteConnection(_connectionString))
|
|||
|
|
{
|
|||
|
|
dbc.Open();
|
|||
|
|
|
|||
|
|
string query = "SELECT id FROM system";
|
|||
|
|
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
|||
|
|
{
|
|||
|
|
using (SqliteDataReader sldr = slc.ExecuteReader())
|
|||
|
|
{
|
|||
|
|
// If nothing is found, tell the user and exit
|
|||
|
|
if (!sldr.HasRows)
|
|||
|
|
{
|
|||
|
|
_logger.Warning("No systems found! Please add a system and then try again.");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
while (sldr.Read())
|
|||
|
|
{
|
|||
|
|
systems.Add(sldr.GetInt32(0).ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Loop through the inputs
|
|||
|
|
foreach (string system in systems)
|
|||
|
|
{
|
|||
|
|
_logger.User("Generating DAT for system id " + system);
|
|||
|
|
InitGenerate(system, norename, old);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|