-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModEntry.cs
More file actions
116 lines (102 loc) · 3.22 KB
/
ModEntry.cs
File metadata and controls
116 lines (102 loc) · 3.22 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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using HappyHomeDesigner.Data;
using HappyHomeDesigner.Framework;
using HappyHomeDesigner.Integration;
using HappyHomeDesigner.Menus;
using HappyHomeDesigner.Patches;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
using System;
namespace HappyHomeDesigner
{
public class ModEntry : Mod
{
public const string MOD_ID = "tlitookilakin.HappyHomeDesigner";
public static readonly bool ANDROID = Constants.TargetPlatform is GamePlatform.Android;
internal static IMonitor monitor;
internal static IManifest manifest;
internal static IModHelper helper;
internal static Config config;
internal static ITranslationHelper i18n;
internal static API api;
public override void Entry(IModHelper helper)
{
monitor = Monitor;
ModEntry.helper = helper;
i18n = Helper.Translation;
config = Helper.ReadConfig<Config>();
manifest = ModManifest;
api = new();
helper.Events.GameLoop.GameLaunched += Launched;
helper.Events.Input.ButtonPressed += OnButtonPressed;
helper.Events.Input.ButtonReleased += OnButtonReleased;
helper.Events.Input.MouseWheelScrolled += OnMouseScroll;
helper.Events.Player.Warped += OnWarp;
AssetManager.Init(Helper, config);
Catalog.Init(Helper);
InventoryWatcher.Init(Helper);
Commands.BindAll(Helper);
Debug.Init(Helper);
}
public override object GetApi()
{
return api;
}
private void OnWarp(object sender, WarpedEventArgs e)
{
if (Catalog.ActiveMenu.Value is Catalog catalog)
catalog.exitThisMenuNoSound();
}
private void OnMouseScroll(object sender, MouseWheelScrolledEventArgs e)
{
if (e.Delta is not 0 && Catalog.ActiveMenu.Value is Catalog catalog)
{
var mouse = Game1.getMousePosition(true);
if (config.AlwaysLockScroll || catalog.isWithinBounds(mouse.X, mouse.Y))
{
catalog.receiveScrollWheelAction(-Math.Sign(e.Delta));
e.Suppress();
}
}
}
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
{
if (!e.IsSuppressed() && Game1.activeClickableMenu is null && Catalog.TryApplyButton(e.Button, true))
e.Button.Suppress();
}
private void OnButtonReleased(object sender, ButtonReleasedEventArgs e)
{
if (!e.IsSuppressed() && Game1.activeClickableMenu is null && Catalog.TryApplyButton(e.Button, false))
e.Button.Suppress();
}
private void Launched(object sender, GameLaunchedEventArgs e)
{
if (Helper.ModRegistry.IsLoaded("spacechase0.GenericModConfigMenu"))
{
IGMCM.API = Helper.ModRegistry.GetApi<IGMCM>("spacechase0.GenericModConfigMenu");
IGMCM.Installed = true;
config.Register(IGMCM.API, ModManifest);
}
Patch(new(new(ModManifest.UniqueID), Monitor));
AlternativeTextures.Init(Helper);
CustomNPCPaintings.Init();
Spacecore.Init();
Calcifer.Init(helper);
}
private static void Patch(HarmonyHelper harmony)
{
ReplaceShop.Apply(harmony);
ItemCloneFix.Apply(harmony);
FurnitureAction.Apply(harmony);
InventoryCombine.Apply(harmony);
SearchFocusFix.Apply(harmony);
ItemReceive.Apply(harmony);
HandCatalogue.Apply(harmony);
CatalogFX.Apply(harmony);
Misc.Apply(harmony);
CraftablePlacement.Apply(harmony);
AltTex.Apply(harmony);
ManaBars.Apply(harmony);
}
}
}