Initial GUI Work

This commit is contained in:
Cj 2024-06-13 20:25:11 -04:00
parent b8fd1fa2da
commit d2b97a14eb
12 changed files with 1128 additions and 105 deletions

View File

@ -6,9 +6,9 @@
public class Settings
{
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

View File

@ -32,12 +32,12 @@ public class Remapper
if (DataProvider.Settings.AppSettings.MatchMode) { return; }
// 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();
}
if (!DataProvider.Settings.RemapperSettings.Unseal)
if (!DataProvider.Settings.Remapper.Unseal)
{
Publicizer.Unseal();
}
@ -54,8 +54,8 @@ public class Remapper
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
Logger.Log($"Starting remap...", ConsoleColor.Yellow);
Logger.Log($"Module contains {DataProvider.ModuleDefinition.Types.Count} Types", ConsoleColor.Yellow);
Logger.Log($"Publicize: {DataProvider.Settings.RemapperSettings.Publicize}", ConsoleColor.Yellow);
Logger.Log($"Unseal: {DataProvider.Settings.RemapperSettings.Unseal}", ConsoleColor.Yellow);
Logger.Log($"Publicize: {DataProvider.Settings.Remapper.Publicize}", ConsoleColor.Yellow);
Logger.Log($"Unseal: {DataProvider.Settings.Remapper.Unseal}", ConsoleColor.Yellow);
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
}
@ -199,7 +199,7 @@ public class Remapper
var filteredScores = scores
.OrderByDescending(score => score.Score)
.Take(DataProvider.Settings.RemapperSettings.MaxMatchCount);
.Take(DataProvider.Settings.Remapper.MaxMatchCount);
var highestScore = filteredScores.FirstOrDefault();
@ -235,7 +235,7 @@ public class Remapper
/// </summary>
private void WriteAssembly()
{
var filename = Path.GetFileNameWithoutExtension(DataProvider.Settings.RemapperSettings.AssemblyPath);
var filename = Path.GetFileNameWithoutExtension(DataProvider.Settings.Remapper.AssemblyPath);
var strippedPath = Path.GetDirectoryName(filename);
filename = $"{filename}-Remapped.dll";

View File

@ -5,7 +5,7 @@ using Mono.Collections.Generic;
namespace AssemblyRemapper.Remapper;
public static class Renamer
internal static class Renamer
{
public static void RenameAll(ScoringModel score)
{

View File

@ -8,7 +8,6 @@ public static class DataProvider
{
static DataProvider()
{
LoadAppSettings();
}
public static HashSet<RemapModel> Remaps { get; private set; } = [];
@ -21,7 +20,7 @@ public static class DataProvider
public static ModuleDefinition ModuleDefinition { get; private set; }
private static void LoadAppSettings()
public static void LoadAppSettings()
{
var settingsPath = Path.Combine(AppContext.BaseDirectory, "Data", "Settings.jsonc");
@ -38,16 +37,18 @@ public static class DataProvider
};
Settings = JsonConvert.DeserializeObject<Settings>(jsonText, settings);
Logger.Log($"Settings loaded from '{settingsPath}'");
}
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 = [];
ScoringModels = [];
@ -66,13 +67,15 @@ public static class DataProvider
}
}
}
Logger.Log($"Mapping file loaded from '{Settings.Remapper.MappingPath}'");
}
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
@ -100,28 +103,29 @@ public static class DataProvider
var jsonText = JsonConvert.SerializeObject(Remaps, settings);
File.WriteAllText(Settings.RemapperSettings.MappingPath, jsonText);
File.WriteAllText(Settings.Remapper.MappingPath, jsonText);
}
public static void LoadAssemblyDefinition()
{
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 };
AssemblyDefinition = AssemblyDefinition.ReadAssembly(Settings.RemapperSettings.AssemblyPath, parameters);
AssemblyDefinition = AssemblyDefinition.ReadAssembly(Settings.Remapper.AssemblyPath, parameters);
if (AssemblyDefinition is 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())
{
if (module.Name == fileName)
{
Logger.Log($"Module definition {module.Name} found'");
ModuleDefinition = module;
return;
}

View File

@ -24,26 +24,17 @@ public static class Logger
public static void Log(object message, ConsoleColor color = ConsoleColor.Gray, bool silent = false)
{
if (silent)
if (!silent)
{
WriteToDisk(message);
return;
Console.ForegroundColor = color;
Console.WriteLine(message);
}
Console.ForegroundColor = color;
Console.WriteLine(message);
Console.ResetColor();
WriteToDisk(message);
}
public static void LogDebug(object message, ConsoleColor color = ConsoleColor.Gray, bool silent = false)
{
if (silent)
{
WriteToDisk(message);
return;
}
if (DataProvider.Settings.AppSettings.Debug)
{
Console.ForegroundColor = color;
@ -51,6 +42,8 @@ public static class Logger
Console.ResetColor();
WriteToDisk(message);
}
WriteToDisk(message);
}
private static void WriteToDisk(object message)

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,93 @@
using AssemblyRemapper.Utils;
namespace AssemblyRemapperGUI
{
public partial class Form1 : Form
public partial class AssemblyToolGUI : Form
{
public Form1()
public AssemblyToolGUI()
{
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
}
}

View File

@ -117,7 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</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>
</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>

View File

@ -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>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
DataProvider.LoadAppSettings();
DataProvider.LoadMappingFile();
DataProvider.LoadAssemblyDefinition();
// To customize application configuration such as set high DPI settings or default font, see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new AssemblyToolGUI());
}
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AssemblyRemapper\RemapperLib.csproj" />
<ProjectReference Include="..\AssemblyRemapper\LibRemap.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123
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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemapperGUI", "AssemblyRemapperGUI\RemapperGUI.csproj", "{A854A2C9-EB8B-4B70-BB79-17F689756F48}"
EndProject