mirror of
https://github.com/sp-tarkov/assembly-tool.git
synced 2025-02-12 17:30:43 -05:00
DataProvider simplification
This commit is contained in:
parent
80c7d1ef21
commit
c9a036d6db
@ -25,8 +25,6 @@ public class AutoMatchCommand : ICommand
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console)
|
||||
{
|
||||
DataProvider.LoadAppSettings();
|
||||
|
||||
Logger.LogSync("Finding match...");
|
||||
|
||||
var remaps = new List<RemapModel>();
|
||||
|
@ -17,8 +17,6 @@ public class DeObfuscate : ICommand
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console)
|
||||
{
|
||||
DataProvider.LoadAppSettings();
|
||||
|
||||
Logger.Log("Deobfuscating assembly...");
|
||||
|
||||
Deobfuscator.Deobfuscate(AssemblyPath, IsLauncher);
|
||||
|
@ -14,8 +14,6 @@ public class Dumper : ICommand
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console)
|
||||
{
|
||||
DataProvider.LoadAppSettings();
|
||||
|
||||
Logger.Log("Creating DumperClass...");
|
||||
|
||||
var dumper = new DumperClass(ManagedDirectory);
|
||||
|
@ -19,7 +19,6 @@ public class ReMap : ICommand
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console)
|
||||
{
|
||||
DataProvider.LoadAppSettings();
|
||||
DataProvider.Settings.MappingPath = MappingJsonPath;
|
||||
|
||||
var remaps = DataProvider.LoadMappingFile(MappingJsonPath);
|
||||
|
@ -10,7 +10,8 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
||||
|
||||
private List<TypeDef>? CandidateTypes { get; set; }
|
||||
|
||||
private static List<string> _tokens = DataProvider.Settings!.TokensToMatch;
|
||||
private static List<string> _tokens = DataProvider.Settings.TypeNamesToMatch;
|
||||
private static List<string> _methodsToIgnore = DataProvider.Settings.TypeNamesToMatch;
|
||||
|
||||
public void AutoMatch(string assemblyPath, string oldTypeName, string newTypeName)
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ public class ReMapper
|
||||
/// <param name="mapping">Mapping to score</param>
|
||||
private void ScoreMapping(RemapModel mapping, IEnumerable<TypeDef> types)
|
||||
{
|
||||
var tokens = DataProvider.Settings?.TokensToMatch;
|
||||
var tokens = DataProvider.Settings?.TypeNamesToMatch;
|
||||
|
||||
if (mapping.UseForceRename)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ namespace ReCodeItLib.ReMapper;
|
||||
|
||||
internal class Renamer
|
||||
{
|
||||
private static List<string> TokensToMatch => DataProvider.Settings!.TokensToMatch;
|
||||
private static List<string> TokensToMatch => DataProvider.Settings!.TypeNamesToMatch;
|
||||
|
||||
/// <summary>
|
||||
/// Only used by the manual remapper, should probably be removed
|
||||
|
@ -1,7 +1,6 @@
|
||||
using dnlib.DotNet;
|
||||
using Newtonsoft.Json;
|
||||
using ReCodeItLib.Models;
|
||||
using ReCodeItLib.Dumper;
|
||||
|
||||
namespace ReCodeItLib.Utils;
|
||||
|
||||
@ -9,29 +8,15 @@ public static class DataProvider
|
||||
{
|
||||
static DataProvider()
|
||||
{
|
||||
LoadItems();
|
||||
Settings = LoadAppSettings();
|
||||
ItemTemplates = LoadItems();
|
||||
}
|
||||
|
||||
public static string DataPath => Path.Combine(AppContext.BaseDirectory, "Data");
|
||||
|
||||
public static List<RemapModel> Remaps { get; set; } = [];
|
||||
public static Dictionary<string, ItemTemplateModel>? ItemTemplates { get; private set; }
|
||||
public static Settings Settings { get; }
|
||||
|
||||
public static Settings? Settings { get; private set; }
|
||||
|
||||
public static void LoadAppSettings()
|
||||
{
|
||||
var settingsPath = Path.Combine(DataPath, "Settings.jsonc");
|
||||
|
||||
var jsonText = File.ReadAllText(settingsPath);
|
||||
|
||||
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
|
||||
Settings = JsonConvert.DeserializeObject<Settings>(jsonText, settings);
|
||||
}
|
||||
public static Dictionary<string, ItemTemplateModel> ItemTemplates { get; private set; }
|
||||
|
||||
private static readonly string DataPath = Path.Combine(AppContext.BaseDirectory, "Data");
|
||||
|
||||
public static List<RemapModel> LoadMappingFile(string path)
|
||||
{
|
||||
@ -83,11 +68,19 @@ public static class DataProvider
|
||||
return module;
|
||||
}
|
||||
|
||||
private static void LoadItems()
|
||||
private static Settings LoadAppSettings()
|
||||
{
|
||||
var settingsPath = Path.Combine(DataPath, "Settings.jsonc");
|
||||
var jsonText = File.ReadAllText(settingsPath);
|
||||
|
||||
return JsonConvert.DeserializeObject<Settings>(jsonText);
|
||||
}
|
||||
|
||||
private static Dictionary<string, ItemTemplateModel> LoadItems()
|
||||
{
|
||||
var itemsPath = Path.Combine(DataPath, "items.json");
|
||||
var jsonText = File.ReadAllText(itemsPath);
|
||||
|
||||
ItemTemplates = JsonConvert.DeserializeObject<Dictionary<string, ItemTemplateModel>>(jsonText);
|
||||
return JsonConvert.DeserializeObject<Dictionary<string, ItemTemplateModel>>(jsonText);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user