mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add suggested feature for power users
Ignore is useful for users who don't particularly care about the source going into the system. This is especially useful in combination with norename enabled.
This commit is contained in:
@@ -53,21 +53,10 @@ namespace SabreTools
|
||||
_logger = new Logger(true, "database2.log");
|
||||
_logger.Start();
|
||||
|
||||
// Call initial setup
|
||||
Setup();
|
||||
|
||||
// If there's no arguments, show the menu
|
||||
if (args.Length == 0)
|
||||
{
|
||||
_logger.ToFile = true;
|
||||
ShowMainMenu();
|
||||
_logger.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
// Set all default values
|
||||
bool help = false,
|
||||
genall = false,
|
||||
ignore = false,
|
||||
listsys = false,
|
||||
norename = false,
|
||||
old = false;
|
||||
@@ -87,6 +76,10 @@ namespace SabreTools
|
||||
case "--generate-all":
|
||||
genall = true;
|
||||
break;
|
||||
case "-i":
|
||||
case "--ignore":
|
||||
ignore = true;
|
||||
break;
|
||||
case "-lsy":
|
||||
case "--list-systems":
|
||||
listsys = true;
|
||||
@@ -124,6 +117,18 @@ namespace SabreTools
|
||||
return;
|
||||
}
|
||||
|
||||
// Call initial setup because everything after here requires it
|
||||
Import(ignore);
|
||||
|
||||
// If there's no arguments, show the menu
|
||||
if (args.Length == 0)
|
||||
{
|
||||
_logger.ToFile = true;
|
||||
ShowMainMenu();
|
||||
_logger.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
// If we want a list of systems
|
||||
if (listsys)
|
||||
{
|
||||
@@ -512,7 +517,8 @@ ORDER BY system.manufacturer, system.name";
|
||||
/// <summary>
|
||||
/// Perform initial setup for the program
|
||||
/// </summary>
|
||||
private static void Setup()
|
||||
/// <param name="ignore">False if each DAT that has no defined source asks for user input (default), true otherwise</param>
|
||||
private static void Import(bool ignore = false)
|
||||
{
|
||||
Remapping.CreateRemappings();
|
||||
Build.Start("DATabaseTwo");
|
||||
@@ -556,7 +562,7 @@ ORDER BY system.manufacturer, system.name";
|
||||
{
|
||||
while (sldr.Read())
|
||||
{
|
||||
int id = sldr.GetInt32(0);
|
||||
int systemid = sldr.GetInt32(0);
|
||||
string system = _datroot + Path.DirectorySeparatorChar + sldr.GetString(1) + " - " + sldr.GetString(2);
|
||||
system = system.Trim();
|
||||
|
||||
@@ -601,6 +607,12 @@ COMMIT;";
|
||||
// Add the hash to the temporary Dictionary
|
||||
hashes.Add(hash, hashid);
|
||||
|
||||
// If we don't care about source, stop here
|
||||
if (ignore)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Now try to determine the source for the file based on the name
|
||||
string source = GetSourceFromFileName(Path.GetFileName(file));
|
||||
int sourceid = 0;
|
||||
@@ -679,8 +691,10 @@ COMMIT;";
|
||||
}
|
||||
// Otherwise, we should already have an ID
|
||||
|
||||
// Add the source link to the database
|
||||
string uquery = "INSERT OR IGNORE INTO datsdata (id, key, value) VALUES (" + hashid + ", 'source', '" + sourceid + "')";
|
||||
// Add the source and system link to the database
|
||||
string uquery = @"INSERT OR IGNORE INTO datsdata (id, key, value)
|
||||
VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
||||
(" + hashid + ", 'system', '" + systemid + "')";
|
||||
using (SqliteCommand uslc = new SqliteCommand(uquery, dbc))
|
||||
{
|
||||
uslc.ExecuteNonQuery();
|
||||
|
||||
Reference in New Issue
Block a user