-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMainFile.cs
More file actions
57 lines (44 loc) · 1.48 KB
/
MainFile.cs
File metadata and controls
57 lines (44 loc) · 1.48 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
57
using System;
using System.Runtime.InteropServices;
using BaseLib.Config;
using BaseLib.Config.UI;
using BaseLib.Patches.Content;
using Godot;
using HarmonyLib;
using MegaCrit.Sts2.Core.Modding;
namespace BaseLib;
[ModInitializer(nameof(Initialize))]
public static class MainFile
{
public const string ModId = "BaseLib";
public static MegaCrit.Sts2.Core.Logging.Logger Logger { get; } = new(ModId, MegaCrit.Sts2.Core.Logging.LogType.Generic);
public static void Initialize()
{
Libgcc();
ModConfigRegistry.Register(ModId, new BaseLibConfig());
Harmony harmony = new(ModId);
GetCustomLocKey.Patch(harmony);
TheBigPatchToCardPileCmdAdd.Patch(harmony);
harmony.PatchAll();
}
//Hopefully temporary fix for linux
[DllImport("libdl.so.2")]
static extern IntPtr dlopen(string filename, int flags);
[DllImport("libdl.so.2")]
static extern IntPtr dlerror();
[DllImport("libdl.so.2")]
static extern IntPtr dlsym(IntPtr handle, string symbol);
private static IntPtr _holder;
private static void Libgcc()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Logger.Info("Running on Linux, manually dlopen libgcc for Harmony");
_holder = dlopen("libgcc_s.so.1", 2 | 256);
if (_holder == IntPtr.Zero)
{
Logger.Info("Or Nor: "+Marshal.PtrToStringAnsi(dlerror()));
}
}
}
}