-
Notifications
You must be signed in to change notification settings - Fork 10
/
Loot.cs
92 lines (80 loc) · 1.94 KB
/
Loot.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using Loot.UI.Common.Core;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using log4net;
using Loot.Api.Loaders;
using Loot.Api.ModContent;
using Loot.UI;
using Terraria;
using Terraria.ModLoader;
using Terraria.UI;
/*
* original version by Hiccup
* reworked and maintained by Jofairden
* for tModLoader
*
* (c) Jofairden 2018
*/
[assembly: InternalsVisibleTo("LootTests")] // Allow doing unit tests
namespace Loot
{
public sealed class Loot : Mod
{
internal new static ILog Logger => ((Mod)Instance)?.Logger;
internal static Loot Instance;
internal UserInterface GuiInterface;
internal GuiTabWindow GuiState;
internal static ModContentManager ModContentManager;
public static bool IsLoaded;
public override void Load()
{
Instance = this;
LoadingFunneler.Load();
}
public override void PostAddRecipes()
{
LoadingFunneler.PostLoad();
}
public override void Unload()
{
LoadingFunneler.Unload();
Instance = null;
}
public override void PreSaveAndQuit()
{
if (GuiState.Visible)
{
GuiState.ToggleUI(GuiInterface);
}
}
private GameTime _lastUpdateUiGameTime;
public override void UpdateUI(GameTime gameTime)
{
_lastUpdateUiGameTime = gameTime;
if (GuiInterface?.CurrentState != null)
{
GuiInterface.Update(gameTime);
}
}
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
{
int mouseTextIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));
if (mouseTextIndex != -1)
{
layers.Insert(mouseTextIndex, new LegacyGameInterfaceLayer(
"Loot: GuiInterface",
delegate
{
if (GuiInterface?.CurrentState is VisibilityUI visibilityUi
&& visibilityUi.Visible && _lastUpdateUiGameTime != null)
{
GuiInterface.Draw(Main.spriteBatch, _lastUpdateUiGameTime);
}
return true;
},
InterfaceScaleType.UI));
}
}
}
}