-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionCheck.cs
More file actions
108 lines (96 loc) · 3.81 KB
/
FunctionCheck.cs
File metadata and controls
108 lines (96 loc) · 3.81 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
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.GameContent.UI.Elements;
using Terraria.UI;
namespace WhereIAm
{
class FunctionCheck : UIState
{
public static bool visible = false;
public UIPanel checklistPanel;
private Vector2 offset;
private bool dragging;
private float panelWidth = 200f;
private float panelHeight = 110f;
private static Color textColor = Color.SandyBrown;
public UICheckBox biomeBox;
public static bool biome = true;
public UICheckBox timerBox;
public static bool timer = true;
public UICheckBox playerPosBox;
public static bool playerPos = true;
public UICheckBox FPSBox;
public static bool showFPS = true;
public override void OnInitialize()
{
checklistPanel = new UIPanel();
checklistPanel.SetPadding(10f);
checklistPanel.Left.Set((Main.screenWidth - panelWidth) /2, 0f);
checklistPanel.Top.Set((Main.screenHeight - panelHeight) /2, 0f);
checklistPanel.Width.Set(panelWidth, 0f);
checklistPanel.Height.Set(panelHeight, 0f);
checklistPanel.BackgroundColor = new Color(73, 94, 171);
checklistPanel.OnMouseDown += new MouseEvent(DragOn);
checklistPanel.OnMouseUp += new MouseEvent(DragOff);
Append(checklistPanel);
biomeBox = new UICheckBox("显示环境", "", textColor, true, 1f, false);
biomeBox.OnSelectedChanged += (object o, EventArgs e) =>
{
biome = !biome;
};
checklistPanel.Append(biomeBox);
timerBox = new UICheckBox("显示时间", "", textColor, true, 1f, false);
timerBox.Top.Set(25f, 0f);
timerBox.OnSelectedChanged += (object o, EventArgs e) =>
{
timer = !timer;
};
checklistPanel.Append(timerBox);
playerPosBox = new UICheckBox("显示坐标", "", textColor, true, 1f, false);
playerPosBox.Top.Set(50f, 0f);
playerPosBox.OnSelectedChanged += (object o, EventArgs e) =>
{
playerPos = !playerPos;
};
checklistPanel.Append(playerPosBox);
FPSBox = new UICheckBox("显示帧数", "", textColor, true, 1f, false);
FPSBox.Top.Set(75f, 0f);
FPSBox.OnSelectedChanged += (object o, EventArgs e) =>
{
showFPS = !showFPS;
};
checklistPanel.Append(FPSBox);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
Vector2 vector = new Vector2(Main.mouseX, Main.mouseY);
if (checklistPanel.ContainsPoint(vector))
{
Main.LocalPlayer.mouseInterface = true;
}
if (dragging)
{
checklistPanel.Left.Set(vector.X - offset.X, 0f);
checklistPanel.Top.Set(vector.Y - offset.Y, 0f);
Recalculate();
}
}
//鼠标拖拽窗口
//Code learning from Fargo:https://github.com/Fargowilta/Fargowiltas
private void DragOn(UIMouseEvent evt, UIElement listeningElement)
{
offset = new Vector2(evt.MousePosition.X - checklistPanel.Left.Pixels, evt.MousePosition.Y - checklistPanel.Top.Pixels);
dragging = true;
}
private void DragOff(UIMouseEvent evt, UIElement listeningElement)
{
Vector2 mousePosition = evt.MousePosition;
dragging = false;
checklistPanel.Left.Set(mousePosition.X - offset.X, 0f);
checklistPanel.Top.Set(mousePosition.Y - offset.Y, 0f);
Recalculate();
}
}
}