-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.vb
84 lines (82 loc) · 3.22 KB
/
Main.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
Imports System.ComponentModel
Imports System.IO
Imports System.Net
Imports System.Reflection
Imports System.Threading
Imports System.Windows.Forms
Imports HarmonyLib
Imports TaleWorlds
Imports TaleWorlds.Core
Imports TaleWorlds.DotNet
Imports TaleWorlds.Engine
Imports TaleWorlds.InputSystem
Imports TaleWorlds.MountAndBlade
Imports TaleWorlds.MountAndBlade.View
Namespace Global.BetterExceptionWindow
Public Class Main
Inherits MBSubModuleBase
Private Sub LoadBetterExceptionMCMUI()
Dim bewUIDllFilePath = BewBinDir & "\BetterExceptionWindowConfigUI.dll"
If Not File.Exists(bewUIDllFilePath) Then
Print("Unable to load better exception window mcm ui. BetterExceptionWindowConfigUI.dll was not found. It's ok")
Exit Sub
End If
Dim theDll = Assembly.LoadFrom(bewUIDllFilePath)
Dim theSpecifiedModule = theDll.GetType("BetterExceptionWindowConfigUI.EntryPoint")
Dim methodInf = theSpecifiedModule.GetMethod("Start")
methodInf.Invoke(Nothing, New Object() {})
End Sub
Protected Overrides Sub OnBeforeInitialModuleScreenSetAsRoot()
If DisableBewButterlibException Or IsDebuggedByDnspy Then
DisableButterlibFull()
End If
ControlPanelMcmSupport()
End Sub
Private Sub ControlPanelMcmSupport()
Task.Delay(1000 * 2).ContinueWith(
Sub()
If Not CheckIsAssemblyLoaded("Bannerlord.ButterLib.dll") Then
Exit Sub
End If
If IsMcmLoaded() Then
LoadBetterExceptionMCMUI()
End If
End Sub)
End Sub
Private Sub DisableButterlibFull()
If CheckIsAssemblyLoaded("Bannerlord.ButterLib.dll") Then
DisableButterlibException()
End If
End Sub
Private Sub DownloadExceptionDefinitions()
Dim client As New WebClient
Dim url = DefinitionsDownloadUrl
Dim file = BewExceptionDefinitionsPath
ServicePointManager.Expect100Continue = True
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls Or
SecurityProtocolType.Tls11 Or
SecurityProtocolType.Tls12 Or
SecurityProtocolType.Ssl3
Task.Delay(1000 * 1).ContinueWith(
Sub()
Try
Console.WriteLine("Updating exception definitions")
client.DownloadFile(New Uri(url), file)
Catch ex As Exception
Console.WriteLine("Failed to update exception definitons due to this error " + ex.Message)
End Try
End Sub)
End Sub
Protected Overrides Sub OnSubModuleLoad()
ReadConfig()
If EnableStdoutConsole Then SpawnConsole() Else StartLogger()
DownloadExceptionDefinitions()
InitPatch()
If IsDebuggedByDnspy Then
Else
If AllowInDebugger Then InitPatch()
End If
End Sub
End Class
End Namespace