forked from aerde/Inventory-Organizing-Features
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.cs
78 lines (64 loc) · 2.95 KB
/
Plugin.cs
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
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Logging;
using Seion.Iof.Reflection;
using Seion.Iof.Reflection.Extensions;
using Seion.Iof.Features;
using Seion.Iof.Patches;
namespace Seion.Iof
{
[BepInPlugin("com.seion.iof", "Seion.Iof", "1.2.0")]
public class Plugin : BaseUnityPlugin
{
public static bool EnableLogs = false;
public static ManualLogSource GlobalLogger;
private void Awake()
{
// Plugin startup logic
Logger.LogInfo($"Plugin com.seion.iof is loaded!");
GlobalLogger = Logger;
ReflectionHelper.Logger = Logger;
// Pre intialize static reflection classes
// since some of "method name" based searches can take a second or so,
// and it's pretty noticable when playing (well... being in your stash, doing stuff)
// E.g. First time you click on the "Organize" button it hangs for about a second.
// Every other time is quick.
RuntimeHelpers.RunClassConstructor(typeof(LocaleHelper).TypeHandle);
RuntimeHelpers.RunClassConstructor(typeof(ItemTransactionHelper).TypeHandle); // this one especially.
OrganizedContainer.Logger = Logger;
// Pull handbook from the init method.
new PostInitHanbook().Enable();
// Pre-load image from hideout button for organize button
new PostMenuScreenInit().Enable();
// Assign tag and show active tags when saving EditTagWindow.
new PostEditTagWindowShow().Enable();
// Sort lock
new PreGridClassRemoveAll().Enable(); // Prevent Sorting
// Move lock
new PreItemViewOnPointerDown().Enable(); // Prevent Drag
new PreItemViewOnBeginDrag().Enable(); // Prevent Drag
new PostGetFailedProperty().Enable(); // Prevent quick move(Ctrl/Shift+Click)
new PreQuickFindAppropriatePlace().Enable(); // Don't show warnings when item is Move Locked
// Clone sort button and make it an organize button
new PostGridSortPanelShow().Enable();
// Clean up the buttons. Perhaps unnecessary, but I'll leave it here for now
new PostSimpleStashPanelClose().Enable();
new PostTraderScreensGroupClose().Enable();
}
private static HashSet<string> AlreadyThrownPatches = new HashSet<string>();
public static Exception ShowErrorNotif(Exception ex)
{
if (!AlreadyThrownPatches.Add(ex.Source))
{
return ex;
}
NotificationManagerClass.DisplayWarningNotification(
$"Seion.Iof thew an exception. Perhaps version incompatibility? Exception: {ex.Message}",
duration: EFT.Communications.ENotificationDurationType.Infinite
);
return ex;
}
}
}