Initial GUI Work
This commit is contained in:
parent
b8fd1fa2da
commit
d2b97a14eb
@ -6,9 +6,9 @@
|
|||||||
public class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
public AppSettings AppSettings { get; set; }
|
public AppSettings AppSettings { get; set; }
|
||||||
public RemapperSettings RemapperSettings { get; set; }
|
public RemapperSettings Remapper { get; set; }
|
||||||
|
|
||||||
public AutoMapperSettings AutoMapperSettings { get; set; }
|
public AutoMapperSettings AutoMapper { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AppSettings
|
public class AppSettings
|
||||||
|
@ -32,12 +32,12 @@ public class Remapper
|
|||||||
if (DataProvider.Settings.AppSettings.MatchMode) { return; }
|
if (DataProvider.Settings.AppSettings.MatchMode) { return; }
|
||||||
|
|
||||||
// Dont publicize and unseal until after the remapping so we can use those as search parameters
|
// Dont publicize and unseal until after the remapping so we can use those as search parameters
|
||||||
if (!DataProvider.Settings.RemapperSettings.Publicize)
|
if (!DataProvider.Settings.Remapper.Publicize)
|
||||||
{
|
{
|
||||||
Publicizer.Publicize();
|
Publicizer.Publicize();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DataProvider.Settings.RemapperSettings.Unseal)
|
if (!DataProvider.Settings.Remapper.Unseal)
|
||||||
{
|
{
|
||||||
Publicizer.Unseal();
|
Publicizer.Unseal();
|
||||||
}
|
}
|
||||||
@ -54,8 +54,8 @@ public class Remapper
|
|||||||
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
|
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
|
||||||
Logger.Log($"Starting remap...", ConsoleColor.Yellow);
|
Logger.Log($"Starting remap...", ConsoleColor.Yellow);
|
||||||
Logger.Log($"Module contains {DataProvider.ModuleDefinition.Types.Count} Types", ConsoleColor.Yellow);
|
Logger.Log($"Module contains {DataProvider.ModuleDefinition.Types.Count} Types", ConsoleColor.Yellow);
|
||||||
Logger.Log($"Publicize: {DataProvider.Settings.RemapperSettings.Publicize}", ConsoleColor.Yellow);
|
Logger.Log($"Publicize: {DataProvider.Settings.Remapper.Publicize}", ConsoleColor.Yellow);
|
||||||
Logger.Log($"Unseal: {DataProvider.Settings.RemapperSettings.Unseal}", ConsoleColor.Yellow);
|
Logger.Log($"Unseal: {DataProvider.Settings.Remapper.Unseal}", ConsoleColor.Yellow);
|
||||||
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
|
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ public class Remapper
|
|||||||
|
|
||||||
var filteredScores = scores
|
var filteredScores = scores
|
||||||
.OrderByDescending(score => score.Score)
|
.OrderByDescending(score => score.Score)
|
||||||
.Take(DataProvider.Settings.RemapperSettings.MaxMatchCount);
|
.Take(DataProvider.Settings.Remapper.MaxMatchCount);
|
||||||
|
|
||||||
var highestScore = filteredScores.FirstOrDefault();
|
var highestScore = filteredScores.FirstOrDefault();
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ public class Remapper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void WriteAssembly()
|
private void WriteAssembly()
|
||||||
{
|
{
|
||||||
var filename = Path.GetFileNameWithoutExtension(DataProvider.Settings.RemapperSettings.AssemblyPath);
|
var filename = Path.GetFileNameWithoutExtension(DataProvider.Settings.Remapper.AssemblyPath);
|
||||||
var strippedPath = Path.GetDirectoryName(filename);
|
var strippedPath = Path.GetDirectoryName(filename);
|
||||||
|
|
||||||
filename = $"{filename}-Remapped.dll";
|
filename = $"{filename}-Remapped.dll";
|
||||||
|
@ -5,7 +5,7 @@ using Mono.Collections.Generic;
|
|||||||
|
|
||||||
namespace AssemblyRemapper.Remapper;
|
namespace AssemblyRemapper.Remapper;
|
||||||
|
|
||||||
public static class Renamer
|
internal static class Renamer
|
||||||
{
|
{
|
||||||
public static void RenameAll(ScoringModel score)
|
public static void RenameAll(ScoringModel score)
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,6 @@ public static class DataProvider
|
|||||||
{
|
{
|
||||||
static DataProvider()
|
static DataProvider()
|
||||||
{
|
{
|
||||||
LoadAppSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashSet<RemapModel> Remaps { get; private set; } = [];
|
public static HashSet<RemapModel> Remaps { get; private set; } = [];
|
||||||
@ -21,7 +20,7 @@ public static class DataProvider
|
|||||||
|
|
||||||
public static ModuleDefinition ModuleDefinition { get; private set; }
|
public static ModuleDefinition ModuleDefinition { get; private set; }
|
||||||
|
|
||||||
private static void LoadAppSettings()
|
public static void LoadAppSettings()
|
||||||
{
|
{
|
||||||
var settingsPath = Path.Combine(AppContext.BaseDirectory, "Data", "Settings.jsonc");
|
var settingsPath = Path.Combine(AppContext.BaseDirectory, "Data", "Settings.jsonc");
|
||||||
|
|
||||||
@ -38,16 +37,18 @@ public static class DataProvider
|
|||||||
};
|
};
|
||||||
|
|
||||||
Settings = JsonConvert.DeserializeObject<Settings>(jsonText, settings);
|
Settings = JsonConvert.DeserializeObject<Settings>(jsonText, settings);
|
||||||
|
|
||||||
|
Logger.Log($"Settings loaded from '{settingsPath}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadMappingFile()
|
public static void LoadMappingFile()
|
||||||
{
|
{
|
||||||
if (!File.Exists(Settings.RemapperSettings.MappingPath))
|
if (!File.Exists(Settings.Remapper.MappingPath))
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException($"path `{Settings.RemapperSettings.MappingPath}` does not exist...");
|
throw new InvalidOperationException($"path `{Settings.Remapper.MappingPath}` does not exist...");
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonText = File.ReadAllText(Settings.RemapperSettings.MappingPath);
|
var jsonText = File.ReadAllText(Settings.Remapper.MappingPath);
|
||||||
|
|
||||||
Remaps = [];
|
Remaps = [];
|
||||||
ScoringModels = [];
|
ScoringModels = [];
|
||||||
@ -66,13 +67,15 @@ public static class DataProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Log($"Mapping file loaded from '{Settings.Remapper.MappingPath}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateMapping()
|
public static void UpdateMapping()
|
||||||
{
|
{
|
||||||
if (!File.Exists(Settings.RemapperSettings.MappingPath))
|
if (!File.Exists(Settings.Remapper.MappingPath))
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException($"path `{Settings.RemapperSettings.MappingPath}` does not exist...");
|
throw new InvalidOperationException($"path `{Settings.Remapper.MappingPath}` does not exist...");
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonSerializerSettings settings = new JsonSerializerSettings
|
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||||
@ -100,28 +103,29 @@ public static class DataProvider
|
|||||||
|
|
||||||
var jsonText = JsonConvert.SerializeObject(Remaps, settings);
|
var jsonText = JsonConvert.SerializeObject(Remaps, settings);
|
||||||
|
|
||||||
File.WriteAllText(Settings.RemapperSettings.MappingPath, jsonText);
|
File.WriteAllText(Settings.Remapper.MappingPath, jsonText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadAssemblyDefinition()
|
public static void LoadAssemblyDefinition()
|
||||||
{
|
{
|
||||||
DefaultAssemblyResolver resolver = new();
|
DefaultAssemblyResolver resolver = new();
|
||||||
resolver.AddSearchDirectory(Path.GetDirectoryName(Settings.RemapperSettings.AssemblyPath)); // Replace with the correct path
|
resolver.AddSearchDirectory(Path.GetDirectoryName(Settings.Remapper.AssemblyPath)); // Replace with the correct path
|
||||||
ReaderParameters parameters = new() { AssemblyResolver = resolver };
|
ReaderParameters parameters = new() { AssemblyResolver = resolver };
|
||||||
|
|
||||||
AssemblyDefinition = AssemblyDefinition.ReadAssembly(Settings.RemapperSettings.AssemblyPath, parameters);
|
AssemblyDefinition = AssemblyDefinition.ReadAssembly(Settings.Remapper.AssemblyPath, parameters);
|
||||||
|
|
||||||
if (AssemblyDefinition is null)
|
if (AssemblyDefinition is null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("AssemblyDefinition was null...");
|
throw new InvalidOperationException("AssemblyDefinition was null...");
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileName = Path.GetFileName(Settings.RemapperSettings.AssemblyPath);
|
var fileName = Path.GetFileName(Settings.Remapper.AssemblyPath);
|
||||||
|
|
||||||
foreach (var module in AssemblyDefinition.Modules.ToArray())
|
foreach (var module in AssemblyDefinition.Modules.ToArray())
|
||||||
{
|
{
|
||||||
if (module.Name == fileName)
|
if (module.Name == fileName)
|
||||||
{
|
{
|
||||||
|
Logger.Log($"Module definition {module.Name} found'");
|
||||||
ModuleDefinition = module;
|
ModuleDefinition = module;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -24,26 +24,17 @@ public static class Logger
|
|||||||
|
|
||||||
public static void Log(object message, ConsoleColor color = ConsoleColor.Gray, bool silent = false)
|
public static void Log(object message, ConsoleColor color = ConsoleColor.Gray, bool silent = false)
|
||||||
{
|
{
|
||||||
if (silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
WriteToDisk(message);
|
Console.ForegroundColor = color;
|
||||||
return;
|
Console.WriteLine(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.ForegroundColor = color;
|
|
||||||
Console.WriteLine(message);
|
|
||||||
Console.ResetColor();
|
|
||||||
WriteToDisk(message);
|
WriteToDisk(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LogDebug(object message, ConsoleColor color = ConsoleColor.Gray, bool silent = false)
|
public static void LogDebug(object message, ConsoleColor color = ConsoleColor.Gray, bool silent = false)
|
||||||
{
|
{
|
||||||
if (silent)
|
|
||||||
{
|
|
||||||
WriteToDisk(message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DataProvider.Settings.AppSettings.Debug)
|
if (DataProvider.Settings.AppSettings.Debug)
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = color;
|
Console.ForegroundColor = color;
|
||||||
@ -51,6 +42,8 @@ public static class Logger
|
|||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
WriteToDisk(message);
|
WriteToDisk(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WriteToDisk(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WriteToDisk(object message)
|
private static void WriteToDisk(object message)
|
||||||
|
1042
AssemblyRemapperGUI/Form1.Designer.cs
generated
1042
AssemblyRemapperGUI/Form1.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,93 @@
|
|||||||
|
using AssemblyRemapper.Utils;
|
||||||
|
|
||||||
namespace AssemblyRemapperGUI
|
namespace AssemblyRemapperGUI
|
||||||
{
|
{
|
||||||
public partial class Form1 : Form
|
public partial class AssemblyToolGUI : Form
|
||||||
{
|
{
|
||||||
public Form1()
|
public AssemblyToolGUI()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region BUTTONS
|
||||||
|
|
||||||
|
private void AddRemapButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Logger.Log("Hello From GUI!");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveRemapButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ScoreButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MethodIncludeAddButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MethodIncludeRemoveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MethodExcludeAddButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MethodExcludeRemoveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FIeldIncludeAddButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FieldIncludeRemoveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FieldExcludeAddButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FieldExcludeRemoveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PropertiesIncludeAddButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PropertiesIncludeRemoveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PropertiesExcludeAddButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PropertiesExcludeRemoveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NestedTypesAddButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NestedTypesRemoveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NestedTypesExlcudeAddButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NestedTypesExcludeRemoveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion BUTTONS
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -117,7 +117,10 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="bindingSource1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>209, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -1,17 +1,21 @@
|
|||||||
namespace AssemblyRemapperGUI
|
using AssemblyRemapper.Utils;
|
||||||
|
|
||||||
|
namespace AssemblyRemapperGUI;
|
||||||
|
|
||||||
|
internal static class Program
|
||||||
{
|
{
|
||||||
internal static class Program
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
private static void Main()
|
||||||
{
|
{
|
||||||
/// <summary>
|
DataProvider.LoadAppSettings();
|
||||||
/// The main entry point for the application.
|
DataProvider.LoadMappingFile();
|
||||||
/// </summary>
|
DataProvider.LoadAssemblyDefinition();
|
||||||
[STAThread]
|
|
||||||
static void Main()
|
// To customize application configuration such as set high DPI settings or default font, see https://aka.ms/applicationconfiguration.
|
||||||
{
|
ApplicationConfiguration.Initialize();
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
Application.Run(new AssemblyToolGUI());
|
||||||
// see https://aka.ms/applicationconfiguration.
|
|
||||||
ApplicationConfiguration.Initialize();
|
|
||||||
Application.Run(new Form1());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0-windows</TargetFramework>
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
@ -9,7 +9,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\AssemblyRemapper\RemapperLib.csproj" />
|
<ProjectReference Include="..\AssemblyRemapper\LibRemap.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.9.34728.123
|
VisualStudioVersion = 17.9.34728.123
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RemapperLib", "AssemblyRemapper\RemapperLib.csproj", "{84BF5F6E-9EEC-4B08-BE72-9F419A369124}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibRemap", "AssemblyRemapper\LibRemap.csproj", "{84BF5F6E-9EEC-4B08-BE72-9F419A369124}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemapperGUI", "AssemblyRemapperGUI\RemapperGUI.csproj", "{A854A2C9-EB8B-4B70-BB79-17F689756F48}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemapperGUI", "AssemblyRemapperGUI\RemapperGUI.csproj", "{A854A2C9-EB8B-4B70-BB79-17F689756F48}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Loading…
x
Reference in New Issue
Block a user