-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProtectTools.cs
88 lines (78 loc) · 2.79 KB
/
ProtectTools.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
using System.IO;
using System.Collections.Generic;
using Terraria;
using Terraria.UI;
using Terraria.ModLoader;
namespace ProtectTools
{
class ProtectTools : Mod
{
internal static string OldConfigFilePath = Path.Combine(Main.SavePath, "Mod Configs", "ProtectTools.json");
internal static ProtectTools instance;
internal ModHotKey HotKey;
internal TileWallTool tileWallTool;
public bool LoadedFKTModSettings = false;
int lastSeenScreenWidth;
int lastSeenScreenHeight;
public ProtectTools()
{
Properties = new ModProperties()
{
Autoload = true,
AutoloadGores = true,
AutoloadSounds = true
};
}
public override void Load()
{
instance = this;
HotKey = RegisterHotKey("Toggle Protect Tool", "Y");
if (!Main.dedServ)
{
// 旧設定ファイルの削除
var oldConfigPath = Path.Combine(Main.SavePath, "Mod Configs", "TeraBackup.json"); ;
if (File.Exists(oldConfigPath))
{
File.Delete(oldConfigPath);
}
tileWallTool = new TileWallTool();
}
}
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
{
int layerIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Interface Logic 1"));
if (layerIndex != -1)
{
layers.Insert(layerIndex, new LegacyGameInterfaceLayer(
"Protect Tools: UI",
delegate
{
if (lastSeenScreenWidth != Main.screenWidth || lastSeenScreenHeight != Main.screenHeight)
{
tileWallTool.ScreenResolutionChanged();
lastSeenScreenWidth = Main.screenWidth;
lastSeenScreenHeight = Main.screenHeight;
}
tileWallTool.UIUpdate();
tileWallTool.UIDraw();
return true;
},
InterfaceScaleType.UI)
);
}
layerIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));
if (layerIndex != -1)
{
layers.Insert(layerIndex, new LegacyGameInterfaceLayer(
"Protect Tools: Tooltip",
delegate
{
tileWallTool.TooltipDraw();
return true;
},
InterfaceScaleType.UI)
);
}
}
}
}