-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.lua
209 lines (190 loc) · 5.24 KB
/
interface.lua
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
local AddonName, NS = ...
local CreateFrame = CreateFrame
local LibStub = LibStub
local IsInInstance = IsInInstance
local AceConfigDialog = LibStub("AceConfigDialog-3.0")
local Interface = {}
NS.Interface = Interface
function Interface:MakeUnmovable(frame)
frame:SetMovable(false)
frame:RegisterForDrag()
frame:SetScript("OnDragStart", nil)
frame:SetScript("OnDragStop", nil)
end
function Interface:MakeMoveable(frame)
frame:SetMovable(true)
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnDragStart", function(f)
if NS.db.global.lock == false and frame:IsVisible() and frame:GetAlpha() ~= 0 then
f:StartMoving()
end
end)
frame:SetScript("OnDragStop", function(f)
if NS.db.global.lock == false and frame:IsVisible() and frame:GetAlpha() ~= 0 then
f:StopMovingOrSizing()
local a, _, b, c, d = f:GetPoint()
NS.db.global.position[1] = a
NS.db.global.position[2] = b
NS.db.global.position[3] = c
NS.db.global.position[4] = d
end
end)
end
function Interface:RemoveControls(frame)
frame:EnableMouse(false)
frame:SetScript("OnMouseUp", nil)
end
function Interface:AddControls(frame)
frame:EnableMouse(true)
frame:SetScript("OnMouseUp", function(_, btn)
if NS.db.global.lock == false and not IsInInstance() and frame:IsVisible() and frame:GetAlpha() ~= 0 then
if btn == "RightButton" then
AceConfigDialog:Open(AddonName)
end
end
end)
end
function Interface:Lock(frame)
self:RemoveControls(frame)
self:MakeUnmovable(frame)
end
function Interface:Unlock(frame)
self:AddControls(frame)
self:MakeMoveable(frame)
end
function Interface:CreateInterface()
if not Interface.textFrame then
local TextFrame = CreateFrame("Frame", "HIRInterfaceTextFrame", UIParent)
TextFrame:SetClampedToScreen(true)
TextFrame:SetPoint(
NS.db.global.position[1],
UIParent,
NS.db.global.position[2],
NS.db.global.position[3],
NS.db.global.position[4]
)
local Text = TextFrame:CreateFontString(nil, "OVERLAY")
Text:SetTextColor(NS.db.global.color.r, NS.db.global.color.g, NS.db.global.color.b, NS.db.global.color.a)
Text:SetShadowOffset(0, 0)
Text:SetShadowColor(0, 0, 0, 1)
Text:SetJustifyH("CENTER")
Text:SetJustifyV("MIDDLE")
Text:SetPoint("CENTER", TextFrame, "CENTER", 0, 0)
NS.UpdateFont(Text)
NS.UpdateText(Text, NS.db.global.reverse)
Interface.text = Text
Interface.textFrame = TextFrame
if NS.db.global.lock then
self:Lock(Interface.textFrame)
else
self:Unlock(Interface.textFrame)
end
TextFrame:SetWidth(Text:GetStringWidth())
TextFrame:SetHeight(Text:GetStringHeight())
TextFrame:Hide()
if IsInInstance() then
if NS.isInGroup() then
if NS.isDead() then
TextFrame:Hide()
else
if NS.db.global.healer then
if NS.isHealer("player") then
TextFrame:Hide()
else
if NS.noHealersInGroup() then
TextFrame:Hide()
else
TextFrame:Show()
end
end
else
if NS.noHealersInGroup() then
TextFrame:Hide()
else
TextFrame:Show()
end
end
end
else
if NS.db.global.test then
TextFrame:Show()
else
TextFrame:Hide()
end
end
else
if NS.db.global.test then
TextFrame:Show()
else
if NS.db.global.showOutside then
if NS.isInGroup() then
if NS.isDead() then
TextFrame:Hide()
else
if NS.db.global.healer then
if NS.isHealer("player") then
TextFrame:Hide()
else
if NS.noHealersInGroup() then
TextFrame:Hide()
else
TextFrame:Show()
end
end
else
if NS.noHealersInGroup() then
TextFrame:Hide()
else
TextFrame:Show()
end
end
end
else
if NS.db.global.test then
TextFrame:Show()
else
TextFrame:Hide()
end
end
end
end
end
end
end
function Interface:ShowText(value)
if NS.isInGroup() then
if value then
Interface.textFrame:Show()
if NS.isDead() then
Interface.textFrame:SetAlpha(0)
else
if NS.db.global.healer then
if NS.isHealer("player") then
Interface.textFrame:SetAlpha(0)
else
if NS.noHealersInGroup() then
Interface.textFrame:SetAlpha(0)
else
Interface.textFrame:SetAlpha(1)
end
end
else
if NS.noHealersInGroup() then
Interface.textFrame:SetAlpha(0)
else
Interface.textFrame:SetAlpha(1)
end
end
end
else
Interface.textFrame:SetAlpha(0)
end
else
if NS.db.global.test then
Interface.textFrame:Show()
Interface.textFrame:SetAlpha(1)
else
Interface.textFrame:SetAlpha(0)
end
end
end