-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cs
More file actions
56 lines (49 loc) · 1.18 KB
/
Main.cs
File metadata and controls
56 lines (49 loc) · 1.18 KB
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
using HarmonyLib;
using System;
using System.Text;
using System.Windows.Forms;
using TaleWorlds.MountAndBlade;
namespace ExitSettlement
{
public class ExceptionHandler
{
public static string ToString(Exception ex)
{
return GetString(ex);
}
private static string GetString(Exception ex)
{
StringBuilder stringBuilder = new StringBuilder();
GetStringRecursive(ex, stringBuilder);
stringBuilder.AppendLine();
stringBuilder.AppendLine("Stack trace: ");
stringBuilder.AppendLine(ex.StackTrace);
return stringBuilder.ToString();
}
private static void GetStringRecursive(Exception ex, StringBuilder sb)
{
sb.AppendLine(ex.GetType().Name + ": ");
sb.AppendLine(ex.Message);
if (ex.InnerException != null)
{
sb.AppendLine();
GetStringRecursive(ex.InnerException, sb);
}
}
}
public class ExitSettlementSubModule : MBSubModuleBase
{
protected override void OnSubModuleLoad()
{
try
{
Harmony harmonyPatch = new Harmony("bannerlord.exitsettlement");
harmonyPatch.PatchAll();
}
catch (Exception ex)
{
MessageBox.Show("Failed hooking settlement exit on click code\n\n" + ExceptionHandler.ToString(ex));
}
}
}
}