mirror of
https://github.com/sp-tarkov/assembly-tool.git
synced 2025-02-13 01:50:45 -05:00
Add events, remove unused property, move other properties
This commit is contained in:
parent
4c82026a84
commit
b58fee548f
@ -10282,7 +10282,7 @@
|
||||
"GenericParams": {
|
||||
"IsPublic": true,
|
||||
"IsNested": true,
|
||||
"NTParentName": "SkillManager",
|
||||
"NestedTypeParentName": "SkillManager",
|
||||
"IsDerived": false
|
||||
},
|
||||
"Methods": {
|
||||
@ -10322,7 +10322,7 @@
|
||||
"GenericParams": {
|
||||
"IsPublic": true,
|
||||
"IsNested": true,
|
||||
"NTParentName": "SkillManager"
|
||||
"NestedTypeParentName": "SkillManager"
|
||||
},
|
||||
"Methods": {
|
||||
"ConstructorParameterCount": -1,
|
||||
@ -10362,7 +10362,7 @@
|
||||
"IsPublic": true,
|
||||
"IsAbstract": true,
|
||||
"IsNested": true,
|
||||
"NTParentName": "SkillManager"
|
||||
"NestedTypeParentName": "SkillManager"
|
||||
},
|
||||
"Methods": {
|
||||
"ConstructorParameterCount": -1,
|
||||
@ -10450,7 +10450,7 @@
|
||||
"GenericParams": {
|
||||
"IsPublic": true,
|
||||
"IsNested": true,
|
||||
"NTParentName": "TraderDialogScreen",
|
||||
"NestedTypeParentName": "TraderDialogScreen",
|
||||
"IsSealed": true
|
||||
},
|
||||
"Methods": {
|
||||
@ -10496,7 +10496,7 @@
|
||||
"IsPublic": true,
|
||||
"IsAbstract": false,
|
||||
"IsNested": true,
|
||||
"NTParentName": "MatchmakerOfflineRaidScreen"
|
||||
"NestedTypeParentName": "MatchmakerOfflineRaidScreen"
|
||||
},
|
||||
"Methods": {
|
||||
"ConstructorParameterCount": -1,
|
||||
@ -10621,7 +10621,7 @@
|
||||
"GenericParams": {
|
||||
"IsPublic": true,
|
||||
"IsNested": true,
|
||||
"NTParentName": "Profile"
|
||||
"NestedTypeParentName": "Profile"
|
||||
},
|
||||
"Methods": {
|
||||
"ConstructorParameterCount": -1,
|
||||
@ -11019,7 +11019,7 @@
|
||||
"GenericParams": {
|
||||
"IsPublic": true,
|
||||
"IsNested": true,
|
||||
"NTParentName": "MatchmakerTimeHasCome",
|
||||
"NestedTypeParentName": "MatchmakerTimeHasCome",
|
||||
"IsSealed": false
|
||||
},
|
||||
"Methods": {
|
||||
@ -11201,7 +11201,7 @@
|
||||
"IsPublic": true,
|
||||
"IsInterface": true,
|
||||
"IsNested": true,
|
||||
"NTParentName": "BetterAudio"
|
||||
"NestedTypeParentName": "BetterAudio"
|
||||
},
|
||||
"Methods": {
|
||||
"ConstructorParameterCount": -1,
|
||||
@ -11243,7 +11243,7 @@
|
||||
"IsPublic": true,
|
||||
"IsInterface": true,
|
||||
"IsNested": true,
|
||||
"NTParentName": "ClientPlayer"
|
||||
"NestedTypeParentName": "ClientPlayer"
|
||||
},
|
||||
"Methods": {
|
||||
"ConstructorParameterCount": -1,
|
||||
@ -13990,7 +13990,7 @@
|
||||
"IsPublic": true,
|
||||
"IsAbstract": true,
|
||||
"IsNested": true,
|
||||
"NTParentName": "Player"
|
||||
"NestedTypeParentName": "Player"
|
||||
},
|
||||
"Methods": {
|
||||
"ConstructorParameterCount": -1,
|
||||
@ -15690,7 +15690,7 @@
|
||||
"IsPublic": true,
|
||||
"IsStruct": true,
|
||||
"IsNested": true,
|
||||
"NTParentName": "WorldInteractiveObject"
|
||||
"NestedTypeParentName": "WorldInteractiveObject"
|
||||
},
|
||||
"Methods": {
|
||||
"ConstructorParameterCount": -1,
|
||||
|
@ -227,20 +227,12 @@ public partial class ReCodeItForm : Form
|
||||
? bool.Parse(HasGenericParamsComboBox.GetSelectedItem<string>().AsSpan())
|
||||
: null,
|
||||
|
||||
IsNested = IsNestedUpDown.GetEnabled(),
|
||||
IsDerived = IsDerivedUpDown.GetEnabled(),
|
||||
|
||||
NTParentName = NestedTypeParentName.Text == string.Empty
|
||||
? null
|
||||
: NestedTypeParentName.Text,
|
||||
IsDerived = IsDerivedUpDown.GetEnabled(),
|
||||
|
||||
MatchBaseClass = BaseClassIncludeTextFIeld.Text == string.Empty
|
||||
? null
|
||||
: BaseClassIncludeTextFIeld.Text,
|
||||
|
||||
IgnoreBaseClass = BaseClassExcludeTextField.Text == string.Empty
|
||||
? null
|
||||
: BaseClassExcludeTextField.Text,
|
||||
},
|
||||
|
||||
Methods =
|
||||
@ -264,6 +256,10 @@ public partial class ReCodeItForm : Form
|
||||
},
|
||||
NestedTypes =
|
||||
{
|
||||
IsNested = IsNestedUpDown.GetEnabled(),
|
||||
NestedTypeParentName = NestedTypeParentName.Text == string.Empty
|
||||
? null
|
||||
: NestedTypeParentName.Text,
|
||||
NestedTypeCount = (int)NestedTypeCountEnabled.GetCount(NestedTypeCountUpDown),
|
||||
IncludeNestedTypes = GUIHelpers.GetAllEntriesFromListBox(NestedTypesIncludeBox).ToHashSet(),
|
||||
ExcludeNestedTypes = GUIHelpers.GetAllEntriesFromListBox(NestedTypesExcludeBox).ToHashSet(),
|
||||
@ -829,8 +825,7 @@ public partial class ReCodeItForm : Form
|
||||
RemapperUseForceRename.Checked = remap.UseForceRename;
|
||||
|
||||
BaseClassIncludeTextFIeld.Text = remap.SearchParams.GenericParams.MatchBaseClass;
|
||||
BaseClassExcludeTextField.Text = remap.SearchParams.GenericParams.IgnoreBaseClass;
|
||||
NestedTypeParentName.Text = remap.SearchParams.GenericParams.NTParentName;
|
||||
NestedTypeParentName.Text = remap.SearchParams.NestedTypes.NestedTypeParentName;
|
||||
|
||||
ConstructorCountEnabled.Checked = remap.SearchParams.Methods.ConstructorParameterCount >= 0;
|
||||
|
||||
@ -882,7 +877,7 @@ public partial class ReCodeItForm : Form
|
||||
? remap.SearchParams.GenericParams.HasGenericParameters.ToString()
|
||||
: "Disabled";
|
||||
|
||||
IsNestedUpDown.BuildStringList("IsNested", false, remap.SearchParams.GenericParams.IsNested);
|
||||
IsNestedUpDown.BuildStringList("IsNested", false, remap.SearchParams.NestedTypes.IsNested);
|
||||
IsDerivedUpDown.BuildStringList("IsDerived", false, remap.SearchParams.GenericParams.IsDerived);
|
||||
|
||||
foreach (var method in remap.SearchParams.Methods.IncludeMethods)
|
||||
|
@ -106,7 +106,7 @@ internal static class GUIHelpers
|
||||
var isInterface = model.SearchParams.GenericParams.IsInterface == null ? null : model.SearchParams.GenericParams.IsInterface;
|
||||
var isStruct = model.SearchParams.GenericParams.IsStruct == null ? null : model.SearchParams.GenericParams.IsStruct;
|
||||
var isEnum = model.SearchParams.GenericParams.IsEnum == null ? null : model.SearchParams.GenericParams.IsEnum;
|
||||
var isNested = model.SearchParams.GenericParams.IsNested == null ? null : model.SearchParams.GenericParams.IsNested;
|
||||
var isNested = model.SearchParams.NestedTypes.IsNested == null ? null : model.SearchParams.NestedTypes.IsNested;
|
||||
var isSealed = model.SearchParams.GenericParams.IsSealed == null ? null : model.SearchParams.GenericParams.IsSealed;
|
||||
var HasAttribute = model.SearchParams.GenericParams.HasAttribute == null ? null : model.SearchParams.GenericParams.HasAttribute;
|
||||
var IsDerived = model.SearchParams.GenericParams.IsDerived == null ? null : model.SearchParams.GenericParams.IsDerived;
|
||||
|
@ -61,26 +61,15 @@ public class GenericParams
|
||||
public bool? IsInterface { get; set; } = null;
|
||||
public bool? IsStruct { get; set; } = null;
|
||||
public bool? IsEnum { get; set; } = null;
|
||||
public bool? IsNested { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Name of the nested types parent
|
||||
/// </summary>
|
||||
public string? NTParentName { get; set; } = null;
|
||||
public bool? IsSealed { get; set; } = null;
|
||||
public bool? HasAttribute { get; set; } = null;
|
||||
public bool? HasGenericParameters { get; set; } = null;
|
||||
public bool? IsDerived { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Name of the derived classes declaring type
|
||||
/// </summary>
|
||||
public string? MatchBaseClass { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Name of the derived classes declaring type we want to ignore
|
||||
/// </summary>
|
||||
public string? IgnoreBaseClass { get; set; } = null;
|
||||
public bool? HasGenericParameters { get; set; } = null;
|
||||
}
|
||||
|
||||
public class MethodParams
|
||||
@ -107,6 +96,12 @@ public class PropertyParams
|
||||
|
||||
public class NestedTypeParams
|
||||
{
|
||||
public bool? IsNested { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Name of the nested types parent
|
||||
/// </summary>
|
||||
public string? NestedTypeParentName { get; set; } = null;
|
||||
public int NestedTypeCount { get; set; } = -1;
|
||||
public HashSet<string> IncludeNestedTypes { get; set; } = [];
|
||||
public HashSet<string> ExcludeNestedTypes { get; set; } = [];
|
||||
@ -114,6 +109,7 @@ public class NestedTypeParams
|
||||
|
||||
public class EventParams
|
||||
{
|
||||
public int EventCount { get; set; } = -1;
|
||||
public HashSet<string> IncludeEvents { get; set; } = [];
|
||||
public HashSet<string> ExcludeEvents { get; set; } = [];
|
||||
}
|
@ -78,6 +78,12 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
||||
}
|
||||
|
||||
if (!ContainsTargetNestedTypes(target, candidate, remapModel.SearchParams.NestedTypes))
|
||||
{
|
||||
CandidateTypes!.Remove(candidate);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ContainsTargetEvents(target, candidate, remapModel.SearchParams.Events))
|
||||
{
|
||||
CandidateTypes!.Remove(candidate);
|
||||
}
|
||||
@ -119,7 +125,6 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
||||
parms.IsEnum = target.IsEnum;
|
||||
parms.IsStruct = target.IsValueType && !target.IsEnum;
|
||||
parms.HasGenericParameters = target.HasGenericParameters;
|
||||
parms.IsNested = target.IsNested;
|
||||
parms.IsSealed = target.IsSealed;
|
||||
parms.HasAttribute = target.HasCustomAttributes;
|
||||
parms.IsDerived = target.BaseType != null && target.BaseType.Name != "Object";
|
||||
@ -320,10 +325,58 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
||||
}
|
||||
|
||||
nt.NestedTypeCount = target.NestedTypes.Count;
|
||||
nt.IsNested = target.IsNested;
|
||||
|
||||
if (target.DeclaringType is not null)
|
||||
{
|
||||
nt.NestedTypeParentName = target.DeclaringType.Name.String;
|
||||
}
|
||||
|
||||
return commonNts.Any() || !target.IsNested;
|
||||
}
|
||||
|
||||
private bool ContainsTargetEvents(TypeDef target, TypeDef candidate, EventParams events)
|
||||
{
|
||||
// Target has no events but type has events
|
||||
if (!target.Events.Any() && candidate.Events.Any())
|
||||
{
|
||||
events.EventCount = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Target has events but type has no events
|
||||
if (target.Events.Any() && !candidate.Events.Any()) return false;
|
||||
|
||||
// Target has a different number of events
|
||||
if (target.Events.Count != candidate.Events.Count) return false;
|
||||
|
||||
var commonEvents = target.Events
|
||||
.Select(s => s.Name)
|
||||
.Intersect(candidate.Events.Select(s => s.Name));
|
||||
|
||||
var includeEvents = target.Events
|
||||
.Select(s => s.Name.ToString())
|
||||
.Except(candidate.Events.Select(s => s.Name.ToString()));
|
||||
|
||||
var excludeEvents = candidate.Events
|
||||
.Select(s => s.Name.ToString())
|
||||
.Except(target.Events.Select(s => s.Name.ToString()));
|
||||
|
||||
foreach (var include in includeEvents)
|
||||
{
|
||||
events.IncludeEvents.Add(include);
|
||||
}
|
||||
|
||||
foreach (var exclude in excludeEvents)
|
||||
{
|
||||
events.ExcludeEvents.Add(exclude);
|
||||
}
|
||||
|
||||
events.EventCount = target.NestedTypes.Count;
|
||||
|
||||
return commonEvents.Any() || target.Events.Count == 0;
|
||||
}
|
||||
|
||||
private void ProcessEndQuestions(RemapModel remapModel, string assemblyPath)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
|
@ -17,7 +17,7 @@ internal static class GenericTypeFilters
|
||||
// REQUIRED PROPERTY
|
||||
if (parms.GenericParams.IsPublic)
|
||||
{
|
||||
if (parms.GenericParams.IsNested is true)
|
||||
if (parms.NestedTypes.IsNested is true)
|
||||
{
|
||||
types = types.Where(t => t.IsNestedPublic);
|
||||
|
||||
@ -30,7 +30,7 @@ internal static class GenericTypeFilters
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parms.GenericParams.IsNested is true)
|
||||
if (parms.NestedTypes.IsNested is true)
|
||||
{
|
||||
types = types.Where(t => t.IsNestedPrivate
|
||||
|| t.IsNestedFamily
|
||||
@ -50,9 +50,9 @@ internal static class GenericTypeFilters
|
||||
|
||||
private static IEnumerable<TypeDef> FilterNestedByName(IEnumerable<TypeDef> types, SearchParams parms)
|
||||
{
|
||||
if (parms.GenericParams.NTParentName is not null)
|
||||
if (parms.NestedTypes.NestedTypeParentName is not null)
|
||||
{
|
||||
types = types.Where(t => t.DeclaringType.Name.String == parms.GenericParams.NTParentName);
|
||||
types = types.Where(t => t.DeclaringType.Name.String == parms.NestedTypes.NestedTypeParentName);
|
||||
}
|
||||
|
||||
return types;
|
||||
@ -200,11 +200,6 @@ internal static class GenericTypeFilters
|
||||
{
|
||||
types = types.Where(t => t.GetBaseType()?.Name?.String == parms.GenericParams.MatchBaseClass);
|
||||
}
|
||||
|
||||
if (parms.GenericParams.IgnoreBaseClass is not null and not "")
|
||||
{
|
||||
types = types.Where(t => t.GetBaseType()?.Name?.String != parms.GenericParams.IgnoreBaseClass);
|
||||
}
|
||||
}
|
||||
else if (parms.GenericParams.IsDerived is false)
|
||||
{
|
||||
|
@ -180,7 +180,7 @@ public class ReMapper
|
||||
}
|
||||
|
||||
// Filter down nested objects
|
||||
if (mapping.SearchParams.GenericParams.IsNested is false or null)
|
||||
if (mapping.SearchParams.NestedTypes.IsNested is false or null)
|
||||
{
|
||||
types = types.Where(type => tokens!.Any(token => type.Name.StartsWith(token)));
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ internal static class RenameHelper
|
||||
|
||||
if (remap?.TypePrimeCandidate?.Name is null) { continue; }
|
||||
|
||||
if (remap.SearchParams.GenericParams.IsNested is true &&
|
||||
if (remap.SearchParams.NestedTypes.IsNested is true &&
|
||||
type.IsNested && type.Name == remap.TypePrimeCandidate.Name)
|
||||
{
|
||||
type.Name = remap.NewTypeName;
|
||||
|
Loading…
x
Reference in New Issue
Block a user