Keep counts on the tables loaded

This commit is contained in:
Kyle873 2024-05-26 20:11:10 -04:00
parent ac57ecb939
commit c6a5683fbc
1 changed files with 8 additions and 1 deletions

View File

@ -86,6 +86,10 @@ public static class Table
public static void Load()
{
int catchDataCount = 0;
int stcCount = 0;
int textCount = 0;
foreach (PropertyInfo? prop in typeof(Table).GetProperties().Where(x => x.GetCustomAttribute<LoadDataAttribute>() is not null))
{
LoadDataAttribute attr = prop.GetCustomAttribute<LoadDataAttribute>()!;
@ -98,18 +102,21 @@ public static class Table
object? value = JsonSerializer.Deserialize(entry.Value.GetRawText(), prop.PropertyType, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
prop.SetValue(null, value);
Log.Information($"Loaded {(prop.GetValue(null) as IList)?.Count} entries from {prop.Name} catchdata table");
catchDataCount++;
break;
case LoadDataType.STC:
prop.SetValue(null, typeof(JSON).GetMethod(nameof(JSON.Load))!.MakeGenericMethod(prop.PropertyType).Invoke(null, [Path.Combine(GetPath(attr.DataType), attr.FileName), false]));
Log.Information($"Loaded {(prop.GetValue(null) as IList)?.Count} entries from {prop.Name} stc table");
stcCount++;
break;
case LoadDataType.Text:
// TODO: textdata is just a flat list of key-value pairs that are looked up from stc
textCount++;
break;
}
}
Log.Information("All data tables loaded");
Log.Information($"Finished loading data tables ({catchDataCount} catchdata, {stcCount} stc, {textCount} text)");
}
public static string GetPath(LoadDataType type)