forked from PoctorDepper/LevelPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModSystem.cs
More file actions
74 lines (59 loc) · 1.78 KB
/
ModSystem.cs
File metadata and controls
74 lines (59 loc) · 1.78 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
using levelplus.UI;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using Terraria;
using Terraria.ModLoader;
using Terraria.UI;
namespace levelplus {
class levelplusModSystem : ModSystem {
internal GUI gui;
public static UserInterface guiInterface;
internal LevelUI levelUI;
public static UserInterface levelInterface;
public override void Load() {
base.Load();
//makes sure UI isn't opened server side
if (!Main.dedServ) {
gui = new GUI();
gui.Activate();
guiInterface = new UserInterface();
guiInterface.SetState(gui);
levelUI = new LevelUI();
levelUI.Activate();
levelInterface = new UserInterface();
levelInterface.SetState(levelUI);
}
}
public override void Unload() {
base.Unload();
if (!Main.dedServ) {
LevelUI.visible = false;
GUI.visible = false;
if (levelInterface != null && guiInterface != null) {
levelInterface.SetState(null);
guiInterface.SetState(null);
}
gui = null;
levelUI = null;
}
}
public override void UpdateUI(GameTime gameTime) {
if (GUI.visible)
guiInterface?.Update(gameTime);
if (LevelUI.visible)
levelInterface?.Update(gameTime);
}
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers) {
base.ModifyInterfaceLayers(layers);
int resourceBarsIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Resource Bars"));
//layers.RemoveAt(resourceBarsIndex);
layers.Insert(resourceBarsIndex, new LegacyGameInterfaceLayer("Level+: Resource Bars", delegate {
if (GUI.visible)
guiInterface.Draw(Main.spriteBatch, new GameTime());
if (LevelUI.visible)
levelInterface.Draw(Main.spriteBatch, new GameTime());
return true;
}, InterfaceScaleType.UI));
}
}
}