-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.lua
294 lines (263 loc) · 7.37 KB
/
lib.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
local addon, ns = ...
local cfg = ns.cfg
local lib = CreateFrame("Frame")
local backdrop_tab = {
bgFile = cfg.backdrop_texture,
edgeFile = cfg.backdrop_edge_texture,
tile = false,
tileSize = 0,
edgeSize = 5,
insets = {
left = 5,
right = 5,
top = 5,
bottom = 5,
},
}
lib.gen_backdrop = function(f)
f:SetBackdrop(backdrop_tab);
f:SetBackdropColor(0,0,0,0.7)
f:SetBackdropBorderColor(0,0,0,1)
end
lib.menu = function(self)
local unit = self.unit:sub(1, -2)
local cunit = self.unit:gsub("(.)", string.upper, 1)
if(unit == "party" or unit == "partypet") then
ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..self.id.."DropDown"], "cursor", 0, 0)
elseif(_G[cunit.."FrameDropDown"]) then
ToggleDropDownMenu(1, nil, _G[cunit.."FrameDropDown"], "cursor", 0, 0)
end
end
--[[lib.moveme = function(f)
f:SetMovable(true)
f:SetUserPlaced(true)
f:EnableMouse(true)
f:RegisterForDrag("LeftButton","RightButton")
f:SetScript("OnDragStart",function(self) self:StartMoving() end)
f:SetScript("OnDragStop",function(self) self:StopMovingOrSizing() end)
end]]
lib.gen_fontstring = function(f, name, size, outline)
local fs = f:CreateFontString(nil, "OVERLAY")
fs:SetFont(name, size, outline)
fs:SetShadowColor(0,0,0,1)
return fs
end
local dropdown=CreateFrame("Frame", addon.."DropDown",UIParent,"UIDropDownMenuTemplate")
UIDropDownMenu_Initialize(dropdown,function(self)
local unit=self:GetParent().unit
if not unit then return end
local menu, name, id
if UnitIsUnit(unit, "player") then
menu="SELF"
elseif UnitIsUnit(unit,"vehicle") then
menu="VEHICLE"
elseif UnitIsPlayer(unit) then
id=UnitInRaid(unit)
if id then
menu = "RAID_PLAYER"
name = GetRaidRosterInfo(id)
elseif UnitInParty(unit) then
menu = "PARTY"
else
menu = "PLAYER"
end
else
menu = "TARGET"
name = RAID_TARGET_ICON
end
if menu then
UnitPopup_ShowMenu(self,menu,unit,name,id)
end
end, "MENU")
lib.menu = function(self)
dropdown:SetParent(self)
ToggleDropDownMenu(1,nil,dropdown,"cursor",0,0)
end
do
for k,v in pairs(UnitPopupMenus) do
for x,y in pairs(UnitPopupMenus[k]) do
if y=="SET_FOCUS" then
table.remove(UnitPopupMenus[k],x)
elseif y=="CLEAR_FOCUS" then
table.remove(UnitPopupMenus[k],x)
end
end
end
end
lib.gen_hpbar = function(f)
local s = CreateFrame("StatusBar", nil, f)
s:SetStatusBarTexture(cfg.statusbar_texture)
s:SetHeight(f.height)
s:SetWidth(f.width)
--s:SetFrameLevel(0)
s:SetPoint("CENTER",0,0)
local h = CreateFrame("Frame", nil, s)
h:SetFrameLevel(0)
h:SetPoint("TOPLEFT",-5,5)
h:SetPoint("BOTTOMRIGHT",5,-5)
lib.gen_backdrop(h)
local b = s:CreateTexture(nil, "BACKGROUND")
b:SetTexture(cfg.statusbar_texture)
b:SetAllPoints(s)
f.Health = s
f.Health.bg = b
end
lib.gen_hpstrings = function(f)
local name, hpval
if not f.hidename then
name=lib.gen_fontstring(f.Health, cfg.font, 13, "THINOUTLINE")
name:SetPoint("LEFT", f.Health, "LEFT", 2, 0)
name:SetJustifyH("LEFT")
end
hpval = lib.gen_fontstring(f.Health, cfg.font, 13, "THINOUTLINE")
hpval:SetPoint("RIGHT", f.Health, "RIGHT", -2, 0)
if f.hidename then
hpval:SetJustifyH("LEFT")
hpval:SetPoint("LEFT",f.Health,"LEFT",2,0)
else
name:SetPoint("RIGHT", hpval, "LEFT", -5, 0)
if f.nametag then
f:Tag(name, f.nametag)
else
f:Tag(name, "[name]")
end
end
if f.hptag then
f:Tag(hpval,f.hptag)
else
f:Tag(hpval,"[ku:default]")
end
end
lib.gen_ppbar = function(f)
local s = CreateFrame("StatusBar", nil, f)
s:SetStatusBarTexture(cfg.statusbar_texture)
s:SetHeight(f.height/5)
s:SetWidth(f.width)
s:SetPoint("TOP",f,"BOTTOM",0,-3)
local h = CreateFrame("Frame", nil, s)
h:SetFrameLevel(0)
h:SetPoint("TOPLEFT",-5,5)
h:SetPoint("BOTTOMRIGHT",5,-5)
lib.gen_backdrop(h)
local b = s:CreateTexture(nil, "BACKGROUND")
b:SetTexture(cfg.statusbar_texture)
b:SetAllPoints(s)
f.Power = s
f.Power.bg = b
end
lib.gen_castbar = function(f)
local s = CreateFrame("StatusBar", "oUF_SimpleCastbar"..f.mystyle, f)
s:SetHeight(20)
s:SetWidth(f.width)
if f.mystyle == "player" then
s:SetPoint("CENTER",0,-37)
elseif f.mystyle == "target" then
s:SetPoint("CENTER",0,-37)
else
s:SetPoint("BOTTOM",f,"TOP",0,5)
end
s:SetStatusBarTexture(cfg.statusbar_texture)
s:SetStatusBarColor(1,0.8,0,1)
--helper
local h = CreateFrame("Frame", nil, s)
h:SetFrameLevel(0)
h:SetPoint("TOPLEFT",-5,5)
h:SetPoint("BOTTOMRIGHT",5,-5)
lib.gen_backdrop(h)
local b = s:CreateTexture(nil, "BACKGROUND")
b:SetTexture(cfg.statusbar_texture)
b:SetAllPoints(s)
b:SetVertexColor(1*0.3,0.8*0.3,0,0.7)
local txt = lib.gen_fontstring(s, cfg.font, 13, "THINOUTLINE")
txt:SetPoint("LEFT", 2, 0)
txt:SetJustifyH("LEFT")
--time
local t = lib.gen_fontstring(s, cfg.font, 16, "THINOUTLINE")
t:SetPoint("RIGHT", -2, 0)
txt:SetPoint("RIGHT", t, "LEFT", -5, 0)
--[[icon
local i = s:CreateTexture(nil, "ARTWORK")
i:SetWidth(f.height)
i:SetHeight(f.height)
i:SetPoint("RIGHT", s, "LEFT", -5, 0)
i:SetTexCoord(0.1, 0.9, 0.1, 0.9)
--helper2 for icon
local h2 = CreateFrame("Frame", nil, s)
h2:SetFrameLevel(0)
h2:SetPoint("TOPLEFT",i,"TOPLEFT",-5,5)
h2:SetPoint("BOTTOMRIGHT",i,"BOTTOMRIGHT",5,-5)
lib.gen_backdrop(h2)]]
if f.mystyle == "player" then
--latency only for player unit
local z = s:CreateTexture(nil,"OVERLAY")
z:SetTexture(cfg.statusbar_texture)
z:SetVertexColor(0.6,0,0,0.6)
z:SetPoint("TOPRIGHT")
z:SetPoint("BOTTOMRIGHT")
s.SafeZone = z
end
f.Castbar = s
f.Castbar.Text = txt
f.Castbar.Time = t
--f.Castbar.Icon = i
end
lib.PostCreateIcon = function(self, button)
button.cd:SetReverse()
button.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
button.icon:SetDrawLayer("BACKGROUND")
--count
button.count:ClearAllPoints()
button.count:SetJustifyH("RIGHT")
button.count:SetPoint("TOPRIGHT", 2, 2)
button.count:SetTextColor(0.7,0.7,0.7)
--helper
local h = CreateFrame("Frame", nil, button)
h:SetFrameLevel(0)
h:SetPoint("TOPLEFT",-5,5)
h:SetPoint("BOTTOMRIGHT",5,-5)
lib.gen_backdrop(h)
end
lib.createBuffs = function(f)
b = CreateFrame("Frame", nil, f)
b.size = 20
if f.mystyle == "target" then
b.num = 40
elseif f.mystyle == "player" then
b.num = 10
b.onlyShowPlayer = true
else
b.num = 5
end
b.spacing = 5
b.onlyShowPlayer = false
b:SetHeight((b.size+b.spacing)*4)
b:SetWidth(f.width)
b:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 0, 5)
b.initialAnchor = "BOTTOMLEFT"
b["growth-x"] = "RIGHT"
b["growth-y"] = "UP"
b.PostCreateIcon = lib.PostCreateIcon
f.Buffs = b
end
lib.createDebuffs = function(f)
b = CreateFrame("Frame", nil, f)
b.size = 20
if f.mystyle == "target" then
b.num = 40
elseif f.mystyle == "player" then
b.num = 10
else
b.num = 5
end
b.spacing = 5
b.onlyShowPlayer = false
b:SetHeight((b.size+b.spacing)*4)
b:SetWidth(f.width/2)
b:SetPoint("BOTTOMLEFT", f.Health, "TOPLEFT", 0, 5)
b.initialAnchor = "BOTTOMLEFT"
b["growth-x"] = "RIGHT"
b["growth-y"] = "UP"
b.PostCreateIcon = lib.PostCreateIcon
f.Debuffs = b
end
ns.lib = lib