966 lines
33 KiB
C#
Raw Normal View History

/// This entire file is fucked beyond belief, its just hacked together to make things work for now
2024-06-18 17:35:31 -04:00
using ReCodeIt.AutoMapper;
using ReCodeIt.CrossCompiler;
2024-06-14 19:06:21 -04:00
using ReCodeIt.Enums;
using ReCodeIt.Models;
using ReCodeIt.ReMapper;
using ReCodeIt.Utils;
2024-06-13 20:25:11 -04:00
2024-06-14 19:06:21 -04:00
namespace ReCodeIt.GUI;
2024-06-14 18:07:01 -04:00
2024-06-14 19:06:21 -04:00
public partial class ReCodeItForm : Form
2024-06-13 18:09:31 -04:00
{
2024-06-14 19:06:21 -04:00
public static ReCodeItRemapper Remapper { get; private set; } = new();
2024-06-15 16:21:12 -04:00
public static ReCodeItAutoMapper AutoMapper { get; private set; } = new();
2024-06-14 18:07:01 -04:00
public static ReCodeItCrossCompiler CrossCompiler { get; private set; }
2024-06-18 17:35:31 -04:00
2024-06-14 20:52:16 -04:00
private RemapModel CurrentRemap { get; set; }
2024-06-14 21:29:53 -04:00
private int _selectedRemapTreeIndex = 0;
2024-06-14 19:06:21 -04:00
public ReCodeItForm()
2024-06-13 18:09:31 -04:00
{
2024-06-14 18:07:01 -04:00
InitializeComponent();
CrossCompiler = new();
2024-06-17 17:29:26 -04:00
DataProvider.LoadMappingFile(DataProvider.Settings.Remapper.MappingPath);
2024-06-18 17:35:31 -04:00
LoadedMappingFilePath.Text = DataProvider.Settings.Remapper.MappingPath;
2024-06-18 21:06:37 -04:00
2024-06-14 18:07:01 -04:00
PopulateDomainUpDowns();
2024-06-15 16:21:12 -04:00
RefreshSettingsPage();
RefreshAutoMapperPage();
2024-06-18 21:06:37 -04:00
RefreshCrossCompilerPage();
2024-06-14 21:29:53 -04:00
2024-06-18 21:06:37 -04:00
RemapTreeView.NodeMouseDoubleClick += EditSelectedRemap;
2024-06-14 18:07:01 -04:00
Remapper.OnComplete += ReloadTreeView;
2024-06-18 21:06:37 -04:00
2024-06-14 18:07:01 -04:00
ReloadTreeView(this, EventArgs.Empty);
}
2024-06-14 13:47:30 -04:00
2024-06-17 17:29:26 -04:00
#region MANUAL_REMAPPER
2024-06-14 18:07:01 -04:00
#region BUTTONS
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
#region MAIN_BUTTONS
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
/// <summary>
/// Construct a new remap when the button is pressed
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AddRemapButton_Click(object sender, EventArgs e)
{
if (NewTypeName.Text == string.Empty)
{
MessageBox.Show("Please enter a new type name", "Invalid data");
return;
}
2024-06-14 13:47:30 -04:00
2024-06-14 20:52:16 -04:00
var newRemap = new RemapModel
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
Succeeded = false,
FailureReason = EFailureReason.None,
NewTypeName = NewTypeName.Text,
OriginalTypeName = OriginalTypeName.Text == string.Empty ? null : OriginalTypeName.Text,
2024-06-17 17:29:26 -04:00
UseForceRename = RemapperUseForceRename.Checked,
2024-06-14 18:07:01 -04:00
SearchParams = new SearchParams
2024-06-14 11:01:21 -04:00
{
2024-06-14 18:07:01 -04:00
IsPublic = IsPublicUpDown.GetEnabled(),
IsAbstract = IsAbstractUpDown.GetEnabled(),
IsInterface = IsInterfaceUpDown.GetEnabled(),
IsEnum = IsEnumUpDown.GetEnabled(),
IsNested = IsNestedUpDown.GetEnabled(),
IsSealed = IsSealedUpDown.GetEnabled(),
HasAttribute = HasAttributeUpDown.GetEnabled(),
IsDerived = IsDerivedUpDown.GetEnabled(),
HasGenericParameters = HasGenericParametersUpDown.GetEnabled(),
ParentName = NestedTypeParentName.Text == string.Empty
? null
: NestedTypeParentName.Text,
MatchBaseClass = BaseClassIncludeTextFIeld.Text == string.Empty
? null
: BaseClassIncludeTextFIeld.Text,
IgnoreBaseClass = BaseClassExcludeTextField.Text == string.Empty
? null
: BaseClassExcludeTextField.Text,
// Constructor - TODO
ConstructorParameterCount = ConstructorCountEnabled.GetCount(ConstuctorCountUpDown),
MethodCount = MethodCountEnabled.GetCount(MethodCountUpDown),
FieldCount = FieldCountEnabled.GetCount(FieldCountUpDown),
PropertyCount = PropertyCountEnabled.GetCount(PropertyCountUpDown),
NestedTypeCount = NestedTypeCountEnabled.GetCount(NestedTypeCountUpDown),
2024-06-14 19:06:21 -04:00
IncludeMethods = GUIHelpers.GetAllEntriesFromListBox(MethodIncludeBox),
ExcludeMethods = GUIHelpers.GetAllEntriesFromListBox(MethodExcludeBox),
IncludeFields = GUIHelpers.GetAllEntriesFromListBox(FieldIncludeBox),
ExcludeFields = GUIHelpers.GetAllEntriesFromListBox(FieldExcludeBox),
IncludeProperties = GUIHelpers.GetAllEntriesFromListBox(PropertiesIncludeBox),
ExcludeProperties = GUIHelpers.GetAllEntriesFromListBox(PropertiesExcludeBox),
IncludeNestedTypes = GUIHelpers.GetAllEntriesFromListBox(NestedTypesIncludeBox),
ExcludeNestedTypes = GUIHelpers.GetAllEntriesFromListBox(NestedTypesExcludeBox),
2024-06-14 11:01:21 -04:00
}
2024-06-14 18:07:01 -04:00
};
2024-06-13 21:20:48 -04:00
2024-06-14 20:52:16 -04:00
var existingRemap = DataProvider.Remaps
2024-06-18 17:35:31 -04:00
.Where(remap => remap.NewTypeName == newRemap.NewTypeName)
2024-06-14 20:52:16 -04:00
.FirstOrDefault();
// Handle overwriting an existing remap
if (existingRemap != null)
{
var index = DataProvider.Remaps.IndexOf(existingRemap);
DataProvider.Remaps.Remove(existingRemap);
RemapTreeView.Nodes.RemoveAt(index);
DataProvider.Remaps.Insert(index, newRemap);
RemapTreeView.Nodes.Insert(index, GUIHelpers.GenerateTreeNode(newRemap, this));
2024-06-18 17:35:31 -04:00
DataProvider.SaveMapping();
2024-06-14 20:52:16 -04:00
CurrentRemap = existingRemap;
ResetAll();
return;
}
CurrentRemap = newRemap;
RemapTreeView.Nodes.Add(GUIHelpers.GenerateTreeNode(newRemap, this));
DataProvider.Remaps.Add(newRemap);
2024-06-18 17:35:31 -04:00
DataProvider.SaveMapping();
2024-06-14 20:52:16 -04:00
2024-06-14 18:07:01 -04:00
ResetAll();
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void RemoveRemapButton_Click(object sender, EventArgs e)
{
DataProvider.Remaps?.RemoveAt(RemapTreeView.SelectedNode.Index);
RemapTreeView.SelectedNode?.Remove();
2024-06-18 17:35:31 -04:00
DataProvider.SaveMapping();
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 20:52:16 -04:00
private void EditRemapButton_Click(object sender, EventArgs e)
{
2024-06-14 21:29:53 -04:00
EditSelectedRemap(this, null);
2024-06-18 17:35:31 -04:00
DataProvider.SaveMapping();
2024-06-14 20:52:16 -04:00
}
2024-06-14 18:07:01 -04:00
private void RunRemapButton_Click(object sender, EventArgs e)
{
2024-06-14 19:06:21 -04:00
if (ReCodeItRemapper.IsRunning) { return; }
2024-06-14 14:18:17 -04:00
2024-06-17 17:29:26 -04:00
if (string.IsNullOrEmpty(DataProvider.Settings.Remapper.AssemblyPath))
{
2024-06-17 17:29:26 -04:00
MessageBox.Show("Please select an assembly path", "Assembly not loaded");
return;
}
2024-06-14 18:07:01 -04:00
Console.Clear();
2024-06-14 16:18:43 -04:00
2024-06-18 17:35:31 -04:00
var settings = DataProvider.Settings;
Remapper.InitializeRemap(settings.Remapper.AssemblyPath, settings.Remapper.OutputPath);
2024-06-14 18:07:01 -04:00
}
2024-06-14 13:47:30 -04:00
2024-06-14 18:07:01 -04:00
private void SaveMappingFileButton_Click(object sender, EventArgs e)
{
if (MessageBox.Show(
"Are you sure?",
"Confirmation",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button2) == DialogResult.Yes)
2024-06-14 13:47:30 -04:00
{
2024-06-18 17:35:31 -04:00
DataProvider.SaveMapping();
2024-06-14 13:47:30 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-14 13:47:30 -04:00
2024-06-14 18:07:01 -04:00
private void LoadMappingFileButton_Click(object sender, EventArgs e)
{
2024-06-17 18:38:06 -04:00
var result = GUIHelpers.OpenFileDialog("Select a mapping file",
"JSON Files (*.json)|*.json|JSONC Files (*.jsonc)|*.jsonc|All Files (*.*)|*.*");
2024-06-14 13:47:30 -04:00
2024-06-17 18:38:06 -04:00
if (result == string.Empty) { return; }
DataProvider.LoadMappingFile(result);
2024-06-18 17:35:31 -04:00
DataProvider.Settings.Remapper.MappingPath = result;
DataProvider.SaveAppSettings();
LoadedMappingFilePath.Text = result;
2024-06-14 13:47:30 -04:00
2024-06-14 18:07:01 -04:00
RemapTreeView.Nodes.Clear();
2024-06-14 13:47:30 -04:00
2024-06-14 18:07:01 -04:00
foreach (var remap in DataProvider.Remaps)
{
2024-06-14 19:06:21 -04:00
RemapTreeView.Nodes.Add(GUIHelpers.GenerateTreeNode(remap, this));
2024-06-14 13:47:30 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-14 13:47:30 -04:00
2024-06-17 17:29:26 -04:00
private void PickAssemblyPathButton_Click_1(object sender, EventArgs e)
{
2024-06-17 18:38:06 -04:00
var result = GUIHelpers.OpenFileDialog("Select a DLL file",
"DLL Files (*.dll)|*.dll|All Files (*.*)|*.*");
2024-06-17 17:29:26 -04:00
2024-06-17 18:38:06 -04:00
if (result != string.Empty)
2024-06-17 17:29:26 -04:00
{
2024-06-17 18:38:06 -04:00
DataProvider.Settings.Remapper.AssemblyPath = result;
TargetAssemblyPath.Text = result;
2024-06-17 17:29:26 -04:00
}
}
private void OutputDirectoryButton_Click_1(object sender, EventArgs e)
{
2024-06-17 18:38:06 -04:00
var result = GUIHelpers.OpenFolderDialog("Select an output directory");
2024-06-17 17:29:26 -04:00
2024-06-17 18:38:06 -04:00
if (result != string.Empty)
2024-06-17 17:29:26 -04:00
{
2024-06-17 18:38:06 -04:00
DataProvider.Settings.Remapper.OutputPath = result;
RemapperOutputDirectoryPath.Text = result;
2024-06-17 17:29:26 -04:00
}
}
2024-06-15 16:21:12 -04:00
private void RunAutoMapButton_Click(object sender, EventArgs e)
{
AutoMapper.InitializeAutoMapping();
}
2024-06-14 18:07:01 -04:00
#endregion MAIN_BUTTONS
2024-06-14 13:47:30 -04:00
2024-06-14 18:07:01 -04:00
#region LISTBOX_BUTTONS
2024-06-14 13:47:30 -04:00
2024-06-14 18:07:01 -04:00
private void MethodIncludeAddButton_Click(object sender, EventArgs e)
{
if (!MethodIncludeBox.Items.Contains(IncludeMethodTextBox.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
MethodIncludeBox.Items.Add(IncludeMethodTextBox.Text);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void MethodIncludeRemoveButton_Click(object sender, EventArgs e)
{
if (MethodIncludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
MethodIncludeBox.Items.Remove(MethodIncludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void MethodExcludeAddButton_Click(object sender, EventArgs e)
{
if (!MethodExcludeBox.Items.Contains(ExcludeMethodTextBox.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
MethodExcludeBox.Items.Add(ExcludeMethodTextBox.Text);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void MethodExcludeRemoveButton_Click(object sender, EventArgs e)
{
if (MethodExcludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
MethodExcludeBox.Items.Remove(MethodExcludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void FIeldIncludeAddButton_Click(object sender, EventArgs e)
{
if (!FieldIncludeBox.Items.Contains(FieldsIncludeTextInput.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
FieldIncludeBox.Items.Add(FieldsIncludeTextInput.Text);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void FieldIncludeRemoveButton_Click(object sender, EventArgs e)
{
if (FieldIncludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
FieldIncludeBox.Items.Remove(FieldIncludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void FieldExcludeAddButton_Click(object sender, EventArgs e)
{
if (!FieldExcludeBox.Items.Contains(FieldsExcludeTextInput.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
FieldExcludeBox.Items.Add(FieldsExcludeTextInput.Text);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void FieldExcludeRemoveButton_Click(object sender, EventArgs e)
{
if (FieldExcludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
FieldExcludeBox.Items.Remove(FieldExcludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void PropertiesIncludeAddButton_Click(object sender, EventArgs e)
{
if (!PropertiesIncludeBox.Items.Contains(PropertiesIncludeTextField.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
PropertiesIncludeBox.Items.Add(PropertiesIncludeTextField.Text);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void PropertiesIncludeRemoveButton_Click(object sender, EventArgs e)
{
if (PropertiesIncludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
PropertiesIncludeBox.Items.Remove(PropertiesIncludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void PropertiesExcludeAddButton_Click(object sender, EventArgs e)
{
if (!PropertiesExcludeBox.Items.Contains(PropertiesExcludeTextField.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
PropertiesExcludeBox.Items.Add(PropertiesExcludeTextField.Text);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void PropertiesExcludeRemoveButton_Click(object sender, EventArgs e)
{
if (PropertiesExcludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
PropertiesExcludeBox.Items.Remove(PropertiesExcludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void NestedTypesAddButton_Click(object sender, EventArgs e)
{
if (!NestedTypesIncludeBox.Items.Contains(NestedTypesIncludeTextField.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
NestedTypesIncludeBox.Items.Add(NestedTypesIncludeTextField.Text);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void NestedTypesRemoveButton_Click(object sender, EventArgs e)
{
if (NestedTypesIncludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
NestedTypesIncludeBox.Items.Remove(NestedTypesIncludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void NestedTypesExlcudeAddButton_Click(object sender, EventArgs e)
{
if (!NestedTypesExcludeBox.Items.Contains(NestedTypesExcludeTextField.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
NestedTypesExcludeBox.Items.Add(NestedTypesExcludeTextField.Text);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void NestedTypesExcludeRemoveButton_Click(object sender, EventArgs e)
{
if (NestedTypesExcludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
NestedTypesExcludeBox.Items.Remove(NestedTypesExcludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-15 16:21:12 -04:00
private void AutoMapperExcludeAddButton_Click(object sender, EventArgs e)
{
2024-06-16 13:56:55 -04:00
if (!AutoMapperTypesExcludeBox.Items.Contains(AutoMapperTypesToIgnoreTextField.Text))
2024-06-15 16:21:12 -04:00
{
2024-06-16 13:56:55 -04:00
DataProvider.Settings.AutoMapper.TypesToIgnore.Add(AutoMapperTypesToIgnoreTextField.Text);
AutoMapperTypesExcludeBox.Items.Add(AutoMapperTypesToIgnoreTextField.Text);
AutoMapperTypesToIgnoreTextField.Clear();
2024-06-15 16:21:12 -04:00
DataProvider.SaveAppSettings();
}
}
private void AutoMapperExcludeRemoveButton_Click(object sender, EventArgs e)
{
2024-06-16 13:56:55 -04:00
if (AutoMapperTypesExcludeBox.SelectedItem != null)
2024-06-15 16:21:12 -04:00
{
2024-06-16 13:56:55 -04:00
DataProvider.Settings.AutoMapper.TypesToIgnore.RemoveAt(AutoMapperTypesExcludeBox.SelectedIndex);
AutoMapperTypesExcludeBox.Items.Remove(AutoMapperTypesExcludeBox.SelectedItem);
2024-06-15 16:21:12 -04:00
DataProvider.SaveAppSettings();
}
}
private void RunAutoRemapButton_Click(object sender, EventArgs e)
{
2024-06-17 17:29:26 -04:00
if (string.IsNullOrEmpty(DataProvider.Settings.AutoMapper.AssemblyPath))
{
MessageBox.Show("Please go to the settings tab and load an assembly and select and output location", "Assembly not loaded");
return;
}
2024-06-15 16:21:12 -04:00
AutoMapper.InitializeAutoMapping();
}
2024-06-14 18:07:01 -04:00
#endregion LISTBOX_BUTTONS
2024-06-14 13:47:30 -04:00
2024-06-14 18:07:01 -04:00
#endregion BUTTONS
2024-06-14 13:47:30 -04:00
2024-06-17 17:29:26 -04:00
#endregion MANUAL_REMAPPER
2024-06-14 19:06:21 -04:00
#region SETTINGS_TAB
public void RefreshSettingsPage()
{
2024-06-17 17:29:26 -04:00
// Settings page
2024-06-14 19:06:21 -04:00
DebugLoggingCheckbox.Checked = DataProvider.Settings.AppSettings.Debug;
SilentModeCheckbox.Checked = DataProvider.Settings.AppSettings.SilentMode;
2024-06-17 17:29:26 -04:00
// Remapper page
TargetAssemblyPath.Text = DataProvider.Settings.Remapper.AssemblyPath;
RemapperOutputDirectoryPath.Text = DataProvider.Settings.Remapper.OutputPath;
2024-06-17 18:19:17 -04:00
RenameFieldsCheckbox.Checked = DataProvider.Settings.Remapper.MappingSettings.RenameFields;
RenamePropertiesCheckbox.Checked = DataProvider.Settings.Remapper.MappingSettings.RenameProperties;
RemapperPublicicize.Checked = DataProvider.Settings.Remapper.MappingSettings.Publicize;
RemapperUnseal.Checked = DataProvider.Settings.Remapper.MappingSettings.Unseal;
2024-06-14 19:06:21 -04:00
}
#region CHECKBOXES
private void DebugLoggingCheckbox_CheckedChanged(object sender, EventArgs e)
{
DataProvider.Settings.AppSettings.Debug = DebugLoggingCheckbox.Checked;
DataProvider.SaveAppSettings();
}
private void SilentModeCheckbox_CheckedChanged(object sender, EventArgs e)
{
DataProvider.Settings.AppSettings.SilentMode = SilentModeCheckbox.Checked;
DataProvider.SaveAppSettings();
}
private void RenameFieldsCheckbox_CheckedChanged(object sender, EventArgs e)
{
DataProvider.Settings.AppSettings.RenameFields = RenameFieldsCheckbox.Checked;
DataProvider.SaveAppSettings();
}
private void RenamePropertiesCheckbox_CheckedChanged(object sender, EventArgs e)
{
DataProvider.Settings.AppSettings.RenameProperties = RenamePropertiesCheckbox.Checked;
DataProvider.SaveAppSettings();
}
private void PublicizeCheckbox_CheckedChanged(object sender, EventArgs e)
{
2024-06-17 18:19:17 -04:00
DataProvider.Settings.Remapper.MappingSettings.Publicize = PublicizeCheckbox.Checked;
2024-06-14 19:06:21 -04:00
DataProvider.SaveAppSettings();
}
private void UnsealCheckbox_CheckedChanged(object sender, EventArgs e)
{
2024-06-17 18:19:17 -04:00
DataProvider.Settings.Remapper.MappingSettings.Unseal = UnsealCheckbox.Checked;
2024-06-14 19:06:21 -04:00
DataProvider.SaveAppSettings();
}
#endregion CHECKBOXES
#region UPDOWNS
private void AutoMapperRequiredMatchesUpDown_ValueChanged(object sender, EventArgs e)
{
DataProvider.Settings.AutoMapper.RequiredMatches = (int)AutoMapperRequiredMatchesUpDown.Value;
DataProvider.SaveAppSettings();
}
#endregion UPDOWNS
#endregion SETTINGS_TAB
#region AUTOMAPPER
public void RefreshAutoMapperPage()
{
2024-06-16 13:56:55 -04:00
AutoMapperTypesExcludeBox.Items.Clear();
AutoMapperTokensBox.Items.Clear();
AutoMapperFPBox.Items.Clear();
2024-06-16 13:56:55 -04:00
AutoMapperRequiredMatchesUpDown.Value = DataProvider.Settings.AutoMapper.RequiredMatches;
2024-06-17 17:51:00 -04:00
AutoMapperMinLengthUpDown.Value = DataProvider.Settings.AutoMapper.MinLengthToMatch;
2024-06-16 16:21:42 -04:00
AutoMapperSearchMethodsCheckBox.Checked = DataProvider.Settings.AutoMapper.SearchMethods;
2024-06-17 18:19:17 -04:00
AutoMapperRenameFields.Checked = DataProvider.Settings.AutoMapper.MappingSettings.RenameFields;
AutoMapperRenameProps.Checked = DataProvider.Settings.AutoMapper.MappingSettings.RenameProperties;
AutoMapperPublicize.Checked = DataProvider.Settings.AutoMapper.MappingSettings.Publicize;
AutoMapperUnseal.Checked = DataProvider.Settings.AutoMapper.MappingSettings.Unseal;
2024-06-16 13:56:55 -04:00
foreach (var type in DataProvider.Settings.AutoMapper.TypesToIgnore)
{
2024-06-16 13:56:55 -04:00
AutoMapperTypesExcludeBox.Items.Add(type);
}
2024-06-16 13:56:55 -04:00
foreach (var token in DataProvider.Settings.AutoMapper.TokensToMatch)
{
AutoMapperTokensBox.Items.Add(token);
}
foreach (var fp in DataProvider.Settings.AutoMapper.PropertyFieldBlackList)
{
AutoMapperFPBox.Items.Add(fp);
}
2024-06-16 16:21:42 -04:00
foreach (var mp in DataProvider.Settings.AutoMapper.MethodParamaterBlackList)
{
AutoMapperMethodBox.Items.Add(mp);
}
}
2024-06-17 17:51:00 -04:00
private void AutoMapperChooseTargetPathButton_Click(object sender, EventArgs e)
{
2024-06-17 18:38:06 -04:00
var result = GUIHelpers.OpenFileDialog("Select a DLL file",
"DLL Files (*.dll)|*.dll|All Files (*.*)|*.*");
2024-06-17 17:51:00 -04:00
2024-06-17 18:38:06 -04:00
if (result != string.Empty)
2024-06-17 17:51:00 -04:00
{
2024-06-17 18:38:06 -04:00
DataProvider.Settings.AutoMapper.AssemblyPath = result;
TargetAssemblyPath.Text = result;
2024-06-17 17:51:00 -04:00
DataProvider.SaveAppSettings();
}
}
private void AutoMapperChooseOutpathButton_Click(object sender, EventArgs e)
{
2024-06-17 18:38:06 -04:00
var result = GUIHelpers.OpenFolderDialog("Select an output directory");
2024-06-17 17:51:00 -04:00
2024-06-17 18:38:06 -04:00
if (result != string.Empty)
2024-06-17 17:51:00 -04:00
{
2024-06-17 18:38:06 -04:00
DataProvider.Settings.AutoMapper.OutputPath = result;
RemapperOutputDirectoryPath.Text = result;
2024-06-17 17:51:00 -04:00
DataProvider.SaveAppSettings();
}
}
private void AutoMapperRequiredMatchesUpDown_ValueChanged_1(object sender, EventArgs e)
{
DataProvider.Settings.AutoMapper.RequiredMatches = (int)AutoMapperRequiredMatchesUpDown.Value;
DataProvider.SaveAppSettings();
}
private void AutoMapperMinLengthUpDown_ValueChanged(object sender, EventArgs e)
{
DataProvider.Settings.AutoMapper.MinLengthToMatch = (int)AutoMapperMinLengthUpDown.Value;
DataProvider.SaveAppSettings();
}
2024-06-16 13:56:55 -04:00
private void AutoMapperTokensAddButton_Click(object sender, EventArgs e)
{
if (!AutoMapperTokensBox.Items.Contains(AutoMapperTokensTextField.Text))
{
AutoMapperTokensBox.Items.Add(AutoMapperTokensTextField.Text);
2024-06-16 16:21:42 -04:00
DataProvider.Settings.AutoMapper.TokensToMatch.Add(AutoMapperTokensTextField.Text);
2024-06-16 13:56:55 -04:00
AutoMapperTokensTextField.Clear();
DataProvider.SaveAppSettings();
}
}
private void AutoMapperTokensRemoveButton_Click(object sender, EventArgs e)
{
if (AutoMapperTokensBox.SelectedItem != null)
{
AutoMapperTokensBox.Items.Remove(AutoMapperTokensBox.SelectedItem);
2024-06-16 16:21:42 -04:00
DataProvider.Settings.AutoMapper.TokensToMatch.RemoveAt(AutoMapperTokensBox.SelectedIndex + 1);
2024-06-16 13:56:55 -04:00
DataProvider.SaveAppSettings();
}
}
private void AutoMapperFPAddButton_Click(object sender, EventArgs e)
{
if (!AutoMapperFPBox.Items.Contains(AutoMapperFPTextField.Text))
{
AutoMapperFPBox.Items.Add(AutoMapperFPTextField.Text);
2024-06-16 16:21:42 -04:00
DataProvider.Settings.AutoMapper.PropertyFieldBlackList.Add(AutoMapperFPTextField.Text);
2024-06-16 13:56:55 -04:00
AutoMapperFPTextField.Clear();
DataProvider.SaveAppSettings();
}
}
private void AutoMapperFPRemoveButton_Click(object sender, EventArgs e)
{
if (AutoMapperFPBox.SelectedItem != null)
{
AutoMapperFPBox.Items.Remove(AutoMapperFPBox.SelectedItem);
DataProvider.Settings.AutoMapper.PropertyFieldBlackList.RemoveAt(AutoMapperFPBox.SelectedIndex);
DataProvider.SaveAppSettings();
}
}
2024-06-16 16:21:42 -04:00
private void AutoMapperMethodAddButton_Click(object sender, EventArgs e)
{
if (!AutoMapperMethodBox.Items.Contains(AutoMapperMethodTextBox.Text))
{
AutoMapperMethodBox.Items.Add(AutoMapperMethodTextBox.Text);
DataProvider.Settings.AutoMapper.MethodParamaterBlackList.Add(AutoMapperMethodTextBox.Text);
AutoMapperMethodTextBox.Clear();
DataProvider.SaveAppSettings();
}
}
private void AutoMapperMethodRemoveButton_Click(object sender, EventArgs e)
{
if (AutoMapperMethodBox.SelectedItem != null)
{
AutoMapperMethodBox.Items.Remove(AutoMapperMethodBox.SelectedItem);
DataProvider.Settings.AutoMapper.MethodParamaterBlackList.RemoveAt(AutoMapperMethodBox.SelectedIndex > 0 ? AutoMapperMethodBox.SelectedIndex : 0);
DataProvider.SaveAppSettings();
}
}
private void SearchMethodsCheckBox_CheckedChanged(object sender, EventArgs e)
{
DataProvider.Settings.AutoMapper.SearchMethods = AutoMapperSearchMethodsCheckBox.Checked;
DataProvider.SaveAppSettings();
}
2024-06-17 17:51:00 -04:00
private void AutoMapperRenameFields_CheckedChanged(object sender, EventArgs e)
{
2024-06-17 18:19:17 -04:00
DataProvider.Settings.AutoMapper.MappingSettings.RenameFields = AutoMapperRenameFields.Checked;
2024-06-17 17:51:00 -04:00
DataProvider.SaveAppSettings();
}
private void AutoMapperRenameProps_CheckedChanged(object sender, EventArgs e)
{
2024-06-17 18:19:17 -04:00
DataProvider.Settings.AutoMapper.MappingSettings.RenameProperties = AutoMapperRenameProps.Checked;
2024-06-17 17:51:00 -04:00
DataProvider.SaveAppSettings();
}
private void AutoMapperPublicize_CheckedChanged(object sender, EventArgs e)
{
2024-06-17 18:19:17 -04:00
DataProvider.Settings.AutoMapper.MappingSettings.Publicize = AutoMapperPublicize.Checked;
2024-06-17 17:51:00 -04:00
DataProvider.SaveAppSettings();
}
private void AutoMapperUnseal_CheckedChanged(object sender, EventArgs e)
{
2024-06-17 18:19:17 -04:00
DataProvider.Settings.AutoMapper.MappingSettings.Unseal = AutoMapperUnseal.Checked;
2024-06-17 17:51:00 -04:00
DataProvider.SaveAppSettings();
}
#endregion AUTOMAPPER
2024-06-18 17:35:31 -04:00
#region CROSS_COMPILER
2024-06-17 20:25:53 -04:00
2024-06-18 21:06:37 -04:00
private void RefreshCrossCompilerPage()
2024-06-17 20:25:53 -04:00
{
2024-06-18 21:06:37 -04:00
var ccSettings = DataProvider.Settings.CrossCompiler;
CCAutoLoadLastProj.Checked = ccSettings.AutoLoadLastActiveProject;
if (ccSettings.AutoLoadLastActiveProject)
{
// Dont continue if its an empty string, it hasnt been set yet
if (ccSettings.LastLoadedProject == string.Empty)
{
return;
}
if (!File.Exists(ccSettings.LastLoadedProject))
{
MessageBox.Show("Couldnt find last loaded project");
return;
}
ProjectManager.LoadProject(ccSettings.LastLoadedProject);
}
if (CrossCompiler.ActiveProject == null)
{
return;
}
var activeProj = CrossCompiler.ActiveProject;
CCOriginalAssemblyText.Text = activeProj.OriginalAssemblyPath;
CCRemappedOutputText.Text = activeProj.RemappedAssemblyPath;
CCVisualStudioProjDirText.Text = activeProj.VisualStudioSolutionPath;
CCBuildDirText.Text = activeProj.BuildDirectory;
}
private void CCOriginalAssemblyButton_Click(object sender, EventArgs e)
{
var result = GUIHelpers.OpenFileDialog("Select a DLL file",
2024-06-17 20:25:53 -04:00
"DLL Files (*.dll)|*.dll|All Files (*.*)|*.*");
if (result != string.Empty)
{
CCOriginalAssemblyText.Text = result;
2024-06-17 20:25:53 -04:00
DataProvider.SaveAppSettings();
}
}
private void CCRemappedOutputButton_Click(object sender, EventArgs e)
2024-06-17 20:25:53 -04:00
{
var result = GUIHelpers.OpenFolderDialog("Select a Folder for the remapped reference dll");
2024-06-17 20:25:53 -04:00
if (result != string.Empty)
{
CCRemappedOutputText.Text = result;
2024-06-17 20:25:53 -04:00
DataProvider.SaveAppSettings();
}
}
private void CCVisualStudioProjDirButton_Click(object sender, EventArgs e)
2024-06-17 20:25:53 -04:00
{
var result = GUIHelpers.OpenFolderDialog("Select your visual studio project directory");
2024-06-17 20:25:53 -04:00
if (result != string.Empty)
{
CCVisualStudioProjDirText.Text = result;
2024-06-17 20:25:53 -04:00
DataProvider.SaveAppSettings();
}
}
private void CCBuildDirButton_Click(object sender, EventArgs e)
2024-06-17 20:25:53 -04:00
{
var result = GUIHelpers.OpenFolderDialog("Select where you want to final dll built at");
2024-06-17 20:25:53 -04:00
if (result != string.Empty)
{
CCBuildDirText.Text = result;
2024-06-17 20:25:53 -04:00
DataProvider.SaveAppSettings();
}
}
private void CrossPatchRemapButton_Click(object sender, EventArgs e)
{
CrossCompiler.StartRemap();
2024-06-17 20:25:53 -04:00
}
private void CrossPatchRunButton_Click(object sender, EventArgs e)
{
CrossCompiler.StartCrossCompile();
2024-06-18 17:35:31 -04:00
}
private void CrossCompilerNewProjectButton_Click(object sender, EventArgs e)
{
if (CCOriginalAssemblyText.Text == string.Empty
|| CCRemappedOutputText.Text == string.Empty
|| CCVisualStudioProjDirText.Text == string.Empty
|| CCBuildDirText.Text == string.Empty)
{
// Dont create a project if any required fields are empty
MessageBox.Show("Cannot create a project without setting all paths in the project settings");
return;
}
ProjectManager.CreateProject(
CCOriginalAssemblyText.Text,
CCRemappedOutputText.Text,
CCVisualStudioProjDirText.Text,
CCBuildDirText.Text);
2024-06-18 17:35:31 -04:00
}
private void CCLoadProjButton_Click(object sender, EventArgs e)
2024-06-18 17:35:31 -04:00
{
var result = GUIHelpers.OpenFileDialog("select a ReCodeItProj.json File",
"JSON Files (*.json)|*.json|JSONC Files (*.jsonc)|*.jsonc|All Files (*.*)|*.*");
if (result != string.Empty)
{
ProjectManager.LoadProject(result);
}
2024-06-17 20:25:53 -04:00
}
2024-06-18 21:06:37 -04:00
private void CCAutoLoadLastProj_CheckedChanged_1(object sender, EventArgs e)
{
DataProvider.Settings.CrossCompiler.AutoLoadLastActiveProject = CCAutoLoadLastProj.Checked;
DataProvider.SaveAppSettings();
}
// Use the projects remap list on the remap tab
private void ActiveProjectMappingsCheckbox_CheckedChanged(object sender, EventArgs e)
{
// TODO
}
2024-06-18 17:35:31 -04:00
#endregion CROSS_COMPILER
2024-06-17 20:25:53 -04:00
2024-06-14 18:07:01 -04:00
// Reset All UI elements to default
private void ResetAll()
{
PopulateDomainUpDowns();
// Text fields
NewTypeName.Clear();
BaseClassIncludeTextFIeld.Clear();
BaseClassExcludeTextField.Clear();
NestedTypeParentName.Clear();
BaseClassExcludeTextField.Clear();
IncludeMethodTextBox.Clear();
ExcludeMethodTextBox.Clear();
FieldsIncludeTextInput.Clear();
FieldsExcludeTextInput.Clear();
PropertiesIncludeTextField.Clear();
PropertiesExcludeTextField.Clear();
NestedTypesIncludeTextField.Clear();
NestedTypesExcludeTextField.Clear();
// Numeric UpDowns
2024-06-14 20:52:16 -04:00
ConstuctorCountUpDown.Value = 0;
2024-06-14 18:07:01 -04:00
MethodCountUpDown.Value = 0;
FieldCountUpDown.Value = 0;
PropertyCountUpDown.Value = 0;
NestedTypeCountUpDown.Value = 0;
// Check boxes
2024-06-17 17:29:26 -04:00
RemapperUseForceRename.Checked = false;
2024-06-14 20:52:16 -04:00
ConstructorCountEnabled.Checked = false;
2024-06-14 18:07:01 -04:00
MethodCountEnabled.Checked = false;
FieldCountEnabled.Checked = false;
PropertyCountEnabled.Checked = false;
NestedTypeCountEnabled.Checked = false;
// List boxes
MethodIncludeBox.Items.Clear();
MethodExcludeBox.Items.Clear();
FieldIncludeBox.Items.Clear();
FieldExcludeBox.Items.Clear();
PropertiesIncludeBox.Items.Clear();
PropertiesExcludeBox.Items.Clear();
NestedTypesIncludeBox.Items.Clear();
NestedTypesExcludeBox.Items.Clear();
}
2024-06-14 13:47:30 -04:00
2024-06-14 21:29:53 -04:00
private void EditSelectedRemap(object? sender, TreeNodeMouseClickEventArgs e)
2024-06-14 20:52:16 -04:00
{
2024-06-15 16:21:12 -04:00
if (e?.Node.Level != 0 || RemapTreeView?.SelectedNode?.Index < 0 || RemapTreeView?.SelectedNode?.Index == null)
2024-06-14 21:29:53 -04:00
{
return;
}
_selectedRemapTreeIndex = RemapTreeView.SelectedNode.Index;
2024-06-14 20:52:16 -04:00
ResetAll();
2024-06-14 21:29:53 -04:00
var remap = DataProvider.Remaps.ElementAt(_selectedRemapTreeIndex);
2024-06-14 20:52:16 -04:00
NewTypeName.Text = remap.NewTypeName;
OriginalTypeName.Text = remap.OriginalTypeName;
2024-06-17 17:29:26 -04:00
RemapperUseForceRename.Checked = remap.UseForceRename;
2024-06-14 20:52:16 -04:00
BaseClassIncludeTextFIeld.Text = remap.SearchParams.MatchBaseClass;
BaseClassExcludeTextField.Text = remap.SearchParams.IgnoreBaseClass;
NestedTypeParentName.Text = remap.SearchParams.ParentName;
ConstructorCountEnabled.Checked = remap.SearchParams.ConstructorParameterCount != null ? remap.SearchParams.ConstructorParameterCount > 0 : false;
MethodCountEnabled.Checked = remap.SearchParams.MethodCount != null ? remap.SearchParams.MethodCount > 0 : false;
FieldCountEnabled.Checked = remap.SearchParams.FieldCount != null ? remap.SearchParams.FieldCount > 0 : false;
PropertyCountEnabled.Checked = remap.SearchParams.PropertyCount != null ? remap.SearchParams.PropertyCount > 0 : false;
NestedTypeCountEnabled.Checked = remap.SearchParams.NestedTypeCount != null ? remap.SearchParams.NestedTypeCount > 0 : false;
ConstuctorCountUpDown.Value = (decimal)((remap.SearchParams.ConstructorParameterCount != null ? remap.SearchParams.ConstructorParameterCount : 0));
MethodCountUpDown.Value = (decimal)(remap.SearchParams.MethodCount != null ? remap.SearchParams.MethodCount : 0);
FieldCountUpDown.Value = (decimal)(remap.SearchParams.FieldCount != null ? remap.SearchParams.FieldCount : 0);
PropertyCountUpDown.Value = (decimal)(remap.SearchParams.PropertyCount != null ? remap.SearchParams.PropertyCount : 0);
NestedTypeCountUpDown.Value = (decimal)(remap.SearchParams.NestedTypeCount != null ? remap.SearchParams.NestedTypeCount : 0);
IsPublicUpDown.BuildStringList("IsPublic", remap.SearchParams.IsPublic);
IsAbstractUpDown.BuildStringList("IsAbstract", remap.SearchParams.IsAbstract);
IsInterfaceUpDown.BuildStringList("IsInterface", remap.SearchParams.IsInterface);
IsEnumUpDown.BuildStringList("IsEnum", remap.SearchParams.IsEnum);
IsNestedUpDown.BuildStringList("IsNested", remap.SearchParams.IsNested);
IsSealedUpDown.BuildStringList("IsSealed", remap.SearchParams.IsSealed);
HasAttributeUpDown.BuildStringList("HasAttribute", remap.SearchParams.HasAttribute);
IsDerivedUpDown.BuildStringList("IsDerived", remap.SearchParams.IsDerived);
HasGenericParametersUpDown.BuildStringList("HasGenericParams", remap.SearchParams.HasGenericParameters);
foreach (var method in remap.SearchParams.IncludeMethods)
{
MethodIncludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.ExcludeMethods)
{
MethodExcludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.IncludeFields)
{
FieldIncludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.ExcludeFields)
{
FieldExcludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.IncludeProperties)
{
PropertiesIncludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.ExcludeProperties)
{
PropertiesExcludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.IncludeNestedTypes)
{
NestedTypesIncludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.ExcludeNestedTypes)
{
NestedTypesExcludeBox.Items.Add(method);
}
}
2024-06-14 18:07:01 -04:00
private void PopulateDomainUpDowns()
{
// Clear them all first just incase
IsPublicUpDown.BuildStringList("IsPublic");
IsAbstractUpDown.BuildStringList("IsAbstract");
IsInterfaceUpDown.BuildStringList("IsInterface");
IsEnumUpDown.BuildStringList("IsEnum");
IsNestedUpDown.BuildStringList("IsNested");
IsSealedUpDown.BuildStringList("IsSealed");
HasAttributeUpDown.BuildStringList("HasAttribute");
IsDerivedUpDown.BuildStringList("IsDerived");
HasGenericParametersUpDown.BuildStringList("HasGenericParams");
}
2024-06-17 20:25:53 -04:00
#region TAB_REFRESH
2024-06-17 17:51:00 -04:00
private void AutoMapperTab_Click(object sender, EventArgs e)
{
RefreshAutoMapperPage();
}
2024-06-17 20:25:53 -04:00
private void tabPage5_Click(object sender, EventArgs e)
{
2024-06-18 21:06:37 -04:00
RefreshCrossCompilerPage();
2024-06-17 20:25:53 -04:00
}
2024-06-17 17:51:00 -04:00
private void SettingsTab_Click(object sender, EventArgs e)
{
RefreshSettingsPage();
}
2024-06-17 20:25:53 -04:00
#endregion TAB_REFRESH
2024-06-14 18:07:01 -04:00
/// <summary>
/// Subscribes the the remappers OnComplete event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ReloadTreeView(object sender, EventArgs e)
{
RemapTreeView.Nodes.Clear();
2024-06-14 18:07:01 -04:00
foreach (var remap in DataProvider.Remaps)
{
2024-06-14 19:06:21 -04:00
RemapTreeView.Nodes.Add(GUIHelpers.GenerateTreeNode(remap, this));
}
2024-06-13 18:09:31 -04:00
}
private void groupBox4_Enter(object sender, EventArgs e)
{
}
2024-06-13 20:25:11 -04:00
}