mirror of
https://github.com/sp-tarkov/assembly-tool.git
synced 2025-02-12 22:50:45 -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)
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
DataProvider.LoadAppSettings();
|
|
||||||
|
|
||||||
Logger.LogSync("Finding match...");
|
Logger.LogSync("Finding match...");
|
||||||
|
|
||||||
var remaps = new List<RemapModel>();
|
var remaps = new List<RemapModel>();
|
||||||
|
@ -17,8 +17,6 @@ public class DeObfuscate : ICommand
|
|||||||
|
|
||||||
public ValueTask ExecuteAsync(IConsole console)
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
DataProvider.LoadAppSettings();
|
|
||||||
|
|
||||||
Logger.Log("Deobfuscating assembly...");
|
Logger.Log("Deobfuscating assembly...");
|
||||||
|
|
||||||
Deobfuscator.Deobfuscate(AssemblyPath, IsLauncher);
|
Deobfuscator.Deobfuscate(AssemblyPath, IsLauncher);
|
||||||
|
@ -14,8 +14,6 @@ public class Dumper : ICommand
|
|||||||
|
|
||||||
public ValueTask ExecuteAsync(IConsole console)
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
DataProvider.LoadAppSettings();
|
|
||||||
|
|
||||||
Logger.Log("Creating DumperClass...");
|
Logger.Log("Creating DumperClass...");
|
||||||
|
|
||||||
var dumper = new DumperClass(ManagedDirectory);
|
var dumper = new DumperClass(ManagedDirectory);
|
||||||
|
@ -19,7 +19,6 @@ public class ReMap : ICommand
|
|||||||
|
|
||||||
public ValueTask ExecuteAsync(IConsole console)
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
DataProvider.LoadAppSettings();
|
|
||||||
DataProvider.Settings.MappingPath = MappingJsonPath;
|
DataProvider.Settings.MappingPath = MappingJsonPath;
|
||||||
|
|
||||||
var remaps = DataProvider.LoadMappingFile(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 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)
|
public void AutoMatch(string assemblyPath, string oldTypeName, string newTypeName)
|
||||||
{
|
{
|
||||||
|
@ -164,7 +164,7 @@ public class ReMapper
|
|||||||
/// <param name="mapping">Mapping to score</param>
|
/// <param name="mapping">Mapping to score</param>
|
||||||
private void ScoreMapping(RemapModel mapping, IEnumerable<TypeDef> types)
|
private void ScoreMapping(RemapModel mapping, IEnumerable<TypeDef> types)
|
||||||
{
|
{
|
||||||
var tokens = DataProvider.Settings?.TokensToMatch;
|
var tokens = DataProvider.Settings?.TypeNamesToMatch;
|
||||||
|
|
||||||
if (mapping.UseForceRename)
|
if (mapping.UseForceRename)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@ namespace ReCodeItLib.ReMapper;
|
|||||||
|
|
||||||
internal class Renamer
|
internal class Renamer
|
||||||
{
|
{
|
||||||
private static List<string> TokensToMatch => DataProvider.Settings!.TokensToMatch;
|
private static List<string> TokensToMatch => DataProvider.Settings!.TypeNamesToMatch;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Only used by the manual remapper, should probably be removed
|
/// Only used by the manual remapper, should probably be removed
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using dnlib.DotNet;
|
using dnlib.DotNet;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using ReCodeItLib.Models;
|
using ReCodeItLib.Models;
|
||||||
using ReCodeItLib.Dumper;
|
|
||||||
|
|
||||||
namespace ReCodeItLib.Utils;
|
namespace ReCodeItLib.Utils;
|
||||||
|
|
||||||
@ -9,29 +8,15 @@ public static class DataProvider
|
|||||||
{
|
{
|
||||||
static DataProvider()
|
static DataProvider()
|
||||||
{
|
{
|
||||||
LoadItems();
|
Settings = LoadAppSettings();
|
||||||
|
ItemTemplates = LoadItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string DataPath => Path.Combine(AppContext.BaseDirectory, "Data");
|
public static Settings Settings { get; }
|
||||||
|
|
||||||
public static List<RemapModel> Remaps { get; set; } = [];
|
|
||||||
public static Dictionary<string, ItemTemplateModel>? ItemTemplates { get; private set; }
|
|
||||||
|
|
||||||
public static Settings? Settings { get; private set; }
|
public static Dictionary<string, ItemTemplateModel> ItemTemplates { get; private set; }
|
||||||
|
|
||||||
public static void LoadAppSettings()
|
private static readonly string DataPath = Path.Combine(AppContext.BaseDirectory, "Data");
|
||||||
{
|
|
||||||
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 List<RemapModel> LoadMappingFile(string path)
|
public static List<RemapModel> LoadMappingFile(string path)
|
||||||
{
|
{
|
||||||
@ -83,11 +68,19 @@ public static class DataProvider
|
|||||||
return module;
|
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 itemsPath = Path.Combine(DataPath, "items.json");
|
||||||
var jsonText = File.ReadAllText(itemsPath);
|
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