mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DATabase] Change Convert* to Update
New Update functionality allows for manipulating every possible thing about a DAT in one location. A step up from just being able to convert. Also allows users to easily change a single thing across multiple DATs. Secondarily, for sake of clarity, a couple new partial classes were spun off of DATabase until the menus can get cleaned up.
This commit is contained in:
60
DATabase/Partials/DATabase_InitGenerate.cs
Normal file
60
DATabase/Partials/DATabase_InitGenerate.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user