Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Jul 1, 2022
2 parents 9d407bd + 7c98ef0 commit c391c22
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal static class MixinManager

private static readonly Type? LauncherModuleVMType = AccessTools2.TypeByName("TaleWorlds.MountAndBlade.Launcher.LauncherModuleVM") ??
AccessTools2.TypeByName("TaleWorlds.MountAndBlade.Launcher.Library.LauncherModuleVM");

private static void AddMixin(ViewModel viewModel, object mixin)
{
if (Mixins.TryGetValue(viewModel, out var list))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,31 @@ internal static class LauncherModsVMPatch
private static readonly MethodInfo? CastModuleInfoMethodInfo = typeof(Enumerable).GetMethod(nameof(Enumerable.Cast))?.MakeGenericMethod(
AccessTools2.TypeByName("TaleWorlds.Library.ModuleInfo") ??
AccessTools2.TypeByName("TaleWorlds.ModuleManager.ModuleInfo"));

private static readonly MethodInfo? ToListModuleInfoMethodInfo = typeof(Enumerable).GetMethod(nameof(Enumerable.ToList))?.MakeGenericMethod(
AccessTools2.TypeByName("TaleWorlds.Library.ModuleInfo") ??
AccessTools2.TypeByName("TaleWorlds.ModuleManager.ModuleInfo"));

internal delegate IEnumerable CastDelegate(IEnumerable instance);
internal static readonly CastDelegate? CastMethod =
AccessTools2.GetDelegate<CastDelegate>(CastModuleInfoMethodInfo!);

internal delegate IEnumerable ToListDelegate(IEnumerable instance);
internal static readonly ToListDelegate? ToListMethod =
AccessTools2.GetDelegate<ToListDelegate>(ToListModuleInfoMethodInfo!);

private static readonly MethodInfo? GetDependentModulesOfMethodInfo =
AccessTools2.DeclaredMethod("TaleWorlds.MountAndBlade.Launcher.LauncherModsVM:GetDependentModulesOf") ??
AccessTools2.DeclaredMethod("TaleWorlds.ModuleManager.ModuleHelper:GetDependentModulesOf");

private static readonly MethodInfo? IsAllDependenciesOfModulePresentMethodInfo =
AccessTools2.DeclaredMethod("TaleWorlds.MountAndBlade.Launcher.LauncherModsVM:IsAllDependenciesOfModulePresent") ??
AccessTools2.DeclaredMethod("TaleWorlds.MountAndBlade.Launcher.Library.LauncherModsVM:IsAllDependenciesOfModulePresent");

private static readonly MethodInfo? ChangeIsSelectedOfMethodInfo =
AccessTools2.DeclaredMethod("TaleWorlds.MountAndBlade.Launcher.LauncherModsVM:ChangeIsSelectedOf") ??
AccessTools2.DeclaredMethod("TaleWorlds.MountAndBlade.Launcher.Library.LauncherModsVM:ChangeIsSelectedOf");

public static bool Enable(Harmony harmony)
{
var res1 = harmony.TryPatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class LauncherModuleVMPatch

private static readonly Type? LauncherModuleVMType = AccessTools2.TypeByName("TaleWorlds.MountAndBlade.Launcher.LauncherModuleVM") ??
AccessTools2.TypeByName("TaleWorlds.MountAndBlade.Launcher.Library.LauncherModuleVM");

public static bool Enable(Harmony harmony)
{
var res1 = harmony.TryPatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal static class LauncherVMPatch
{
private static readonly Type? UserDataManagerType = AccessTools2.TypeByName("TaleWorlds.MountAndBlade.Launcher.UserDatas.UserDataManager") ??
AccessTools2.TypeByName("TaleWorlds.MountAndBlade.Launcher.Library.UserDatas.UserDataManager");

public static bool Enable(Harmony harmony)
{
var res1 = harmony.TryPatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void SetVMProperty(string property)
SetVMProperty(nameof(IsDisabled2));
SetVMProperty(nameof(IsDangerous2));

if (ApplicationVersionHelper.GameVersion() is {Major: 1, Minor: >= 7})
if (ApplicationVersionHelper.GameVersion() is { Major: 1, Minor: >= 7 })
{
var id = moduleInfoWrapper.Info?.Id ?? string.Empty;
if (ModuleInfoHelper.LoadFromId(id) is { } moduleInfo && ModuleInfoHelper2.GetDependencyHint(moduleInfo) is { } str && LauncherHintVMWrapper.Create(str) is { } hint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal static class WidgetFactoryManager
private static readonly ReloadDelegate? Reload =
AccessTools2.GetDeclaredDelegate<ReloadDelegate>("TaleWorlds.GauntletUI.WidgetInfo:ReLoad") ??
AccessTools2.GetDeclaredDelegate<ReloadDelegate>("TaleWorlds.GauntletUI.WidgetInfo:Reload");

private static readonly AccessTools.FieldRef<object, IDictionary>? _liveCustomTypes =
AccessTools2.FieldRefAccess<IDictionary>("TaleWorlds.GauntletUI.PrefabSystem.WidgetFactory:_liveCustomTypes");

Expand Down Expand Up @@ -55,7 +55,7 @@ public static void SetWidgetFactory(WidgetFactory widgetFactory)
public static void Register(Type widgetType)
{
if (Reload is null) return;

BuiltinTypes[widgetType.Name] = widgetType;
Reload();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal sealed class LauncherModsVMWrapper
private static readonly GetIsDisabledOnMultiplayerDelegate? GetIsDisabledOnMultiplayer =
AccessTools2.GetPropertyGetterDelegate<GetIsDisabledOnMultiplayerDelegate>("TaleWorlds.MountAndBlade.Launcher.LauncherModsVM:IsDisabledOnMultiplayer") ??
AccessTools2.GetPropertyGetterDelegate<GetIsDisabledOnMultiplayerDelegate>("TaleWorlds.MountAndBlade.Launcher.Library.LauncherModsVM:IsDisabledOnMultiplayer");

private delegate void SetIsDisabledOnMultiplayerDelegate(object instance, bool value);
private static readonly SetIsDisabledOnMultiplayerDelegate? SetIsDisabledOnMultiplayer =
AccessTools2.GetPropertySetterDelegate<SetIsDisabledOnMultiplayerDelegate>("TaleWorlds.MountAndBlade.Launcher.LauncherModsVM:IsDisabledOnMultiplayer") ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal sealed class LauncherModuleVMWrapper
private static readonly GetIsSelectedDelegate? GetIsSelected =
AccessTools2.GetPropertyGetterDelegate<GetIsSelectedDelegate>("TaleWorlds.MountAndBlade.Launcher.LauncherModuleVM:IsSelected") ??
AccessTools2.GetPropertyGetterDelegate<GetIsSelectedDelegate>("TaleWorlds.MountAndBlade.Launcher.Library.LauncherModuleVM:IsSelected");

private delegate void SetIsSelectedDelegate(object instance, bool value);
private static readonly SetIsSelectedDelegate? SetIsSelected =
AccessTools2.GetPropertySetterDelegate<SetIsSelectedDelegate>("TaleWorlds.MountAndBlade.Launcher.LauncherModuleVM:IsSelected") ??
Expand All @@ -30,7 +30,7 @@ internal sealed class LauncherModuleVMWrapper
private static readonly GetIsDisabledDelegate? GetIsDisabled =
AccessTools2.GetPropertyGetterDelegate<GetIsDisabledDelegate>("TaleWorlds.MountAndBlade.Launcher.LauncherModuleVM:IsDisabled") ??
AccessTools2.GetPropertyGetterDelegate<GetIsDisabledDelegate>("TaleWorlds.MountAndBlade.Launcher.Library.LauncherModuleVM:IsDisabled");

private delegate void SetIsDisabledDelegate(object instance, bool value);
private static readonly SetIsDisabledDelegate? SetIsDisabled =
AccessTools2.GetPropertySetterDelegate<SetIsDisabledDelegate>("TaleWorlds.MountAndBlade.Launcher.LauncherModuleVM:IsDisabled") ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal sealed class LauncherNewsVMWrapper
private static readonly GetIsDisabledOnMultiplayerDelegate? GetIsDisabledOnMultiplayer =
AccessTools2.GetPropertyGetterDelegate<GetIsDisabledOnMultiplayerDelegate>("TaleWorlds.MountAndBlade.Launcher.LauncherNewsVM:IsDisabledOnMultiplayer") ??
AccessTools2.GetPropertyGetterDelegate<GetIsDisabledOnMultiplayerDelegate>("TaleWorlds.MountAndBlade.Launcher.Library.LauncherNewsVM:IsDisabledOnMultiplayer");

private delegate void SetIsDisabledOnMultiplayerDelegate(object instance, bool value);
private static readonly SetIsDisabledOnMultiplayerDelegate? SetIsDisabledOnMultiplayer =
AccessTools2.GetPropertySetterDelegate<SetIsDisabledOnMultiplayerDelegate>("TaleWorlds.MountAndBlade.Launcher.LauncherNewsVM:IsDisabledOnMultiplayer") ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ internal sealed class LauncherVMWrapper
private delegate bool GetIsSingleplayerDelegate(object instance);
private static readonly GetIsSingleplayerDelegate? GetIsSingleplayer =
AccessTools2.GetPropertyGetterDelegate<GetIsSingleplayerDelegate>(LauncherVMType!, "IsSingleplayer");

private delegate void SetIsSingleplayerDelegate(object instance, bool value);
private static readonly SetIsSingleplayerDelegate? SetIsSingleplayer =
AccessTools2.GetPropertySetterDelegate<SetIsSingleplayerDelegate>(LauncherVMType!, "IsSingleplayer");

private delegate bool GetIsMultiplayerDelegate(object instance);
private static readonly GetIsMultiplayerDelegate? GetIsMultiplayer =
AccessTools2.GetPropertyGetterDelegate<GetIsMultiplayerDelegate>(LauncherVMType!, "IsMultiplayer");

private delegate void SetIsMultiplayerDelegate(object instance, bool value);
private static readonly SetIsMultiplayerDelegate? SetIsMultiplayer =
AccessTools2.GetPropertySetterDelegate<SetIsMultiplayerDelegate>(LauncherVMType!, "IsMultiplayer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ internal sealed class ModuleInfoWrapper
internal static readonly GetIdDelegate? GetId =
AccessTools2.GetPropertyGetterDelegate<GetIdDelegate>("TaleWorlds.Library.ModuleInfo:Id") ??
AccessTools2.GetPropertyGetterDelegate<GetIdDelegate>("TaleWorlds.ModuleManager.ModuleInfo:Id");

internal delegate string GetAliasDelegate(object instance);
internal static readonly GetAliasDelegate? GetAlias =
AccessTools2.GetPropertyGetterDelegate<GetAliasDelegate>("TaleWorlds.Library.ModuleInfo:Alias");

internal delegate ApplicationVersion GetVersionDelegate(object instance);
internal static readonly GetVersionDelegate? GetVersion =
AccessTools2.GetPropertyGetterDelegate<GetVersionDelegate>("TaleWorlds.Library.ModuleInfo:Version") ??
AccessTools2.GetPropertyGetterDelegate<GetVersionDelegate>("TaleWorlds.ModuleManager.ModuleInfo:Version");

internal delegate bool GetIsSelectedDelegate(object instance);
internal static readonly GetIsSelectedDelegate? GetIsSelected =
AccessTools2.GetPropertyGetterDelegate<GetIsSelectedDelegate>("TaleWorlds.Library.ModuleInfo:IsSelected") ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal sealed class UserModDataWrapper
private static readonly GetIdDelegate? GetId =
AccessTools2.GetPropertyGetterDelegate<GetIdDelegate>("TaleWorlds.MountAndBlade.Launcher.UserDatas.UserModData:Id") ??
AccessTools2.GetPropertyGetterDelegate<GetIdDelegate>("TaleWorlds.MountAndBlade.Launcher.Library.UserDatas.UserModData:Id");

private delegate bool GetIsSelectedDelegate(object instance);
private static readonly GetIsSelectedDelegate? GetIsSelected =
AccessTools2.GetPropertyGetterDelegate<GetIsSelectedDelegate>("TaleWorlds.MountAndBlade.Launcher.UserDatas.UserModData:IsSelected") ??
Expand Down

0 comments on commit c391c22

Please sign in to comment.