- Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathframes.lua
More file actions
Latest commit
405 lines (373 loc) · 18.3 KB
/
Copy pathframes.lua
File metadata and controls
405 lines (373 loc) · 18.3 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
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
---------------------
-- Creating Frames --
---------------------
functionNotGrid:CreateFrames()
self.Container=self:CreateContainerFrame()
fori=1,40do
self.UnitFrames["raid"..i] =self:CreateUnitFrame("raid"..i,i)
end
fori=1,4do
self.UnitFrames["party"..i] =self:CreateUnitFrame("party"..i)
end
fori=1,4do
self.UnitFrames["partypet"..i] =self:CreateUnitFrame("partypet"..i)
end
self.UnitFrames["player"] =self:CreateUnitFrame("player")
self.UnitFrames["pet"] =self:CreateUnitFrame("pet")
end
functionNotGrid:CreateContainerFrame()
localf=CreateFrame("Frame","NotGridContainer",UIParent)
f:SetWidth(1)
f:SetHeight(1)
--f:SetBackdrop({bgFile = "Interface\\Buttons\\WHITE8X8", edgeFile = "Interface\\Buttons\\WHITE8X8", tile = true, tileSize = 16, edgeSize = 10})
f:SetMovable(true)
f:SetPoint("CENTER",40,-40)
returnf
end
functionNotGrid:CreateUnitFrame(unitid,raidindex)
localf=CreateFrame("Button","$parent"..unitid,self.Container)
f.unit=unitid
f.lastseen=GetTime() -- we set this at creation, so we don't have to config frame as out of range alpha by default
ifraidindexthen
f.raidindex=raidindex-- :^)
end
ifstring.find(unitid,"pet") then
f.pet=true-- so I have a boolean to check against
end
f.border=CreateFrame("Frame","$parentborder",f) -- make a seperate frame for the edgefile/border for better customization possibilities
f.border.middleart=f.border:CreateTexture("NGArtworkMiddle", "ARTWORK")
f.healthbar=CreateFrame("StatusBar","$parenthealthbar",f)
f.healthbar.bgtex=f.healthbar:CreateTexture("$parentbgtex","BACKGROUND")
f.powerbar=CreateFrame("StatusBar","$parenthealthbar",f)
f.powerbar.bgtex=f.powerbar:CreateTexture("$parentbgtex","BACKGROUND")
f.incres=CreateFrame("Frame","$parentresicon",f.healthbar)
f.incres.bgtex=f.incres:CreateTexture("$parentbgtex","BACKGROUND")
f.incheal=CreateFrame("Frame","$parenthealcommbar",f.healthbar) -- Was using a statusbar behind the health frame but when the frame's alpha is low this would be seen through it
-- I was having problems with incheal covering up these fontstrings. My soluction is to parent them to the incheal, but set the relative point to the healthbar. And instead of hide/show the incheal I just lower/higher its color opacity
f.namehealthtext=f.incheal:CreateFontString("$parentnamehealthtext", "OVERLAY")
f.healcommtext=f.incheal:CreateFontString("$parenthealcommtext", "OVERLAY")
fori=1,8do
f.healthbar["trackingicon"..i] =CreateFrame("Frame","$parenttrackingicon"..i,f.healthbar) -- easier to work with digits than topleft/topright/etc..
end
--scripts and stuff
f:RegisterForClicks("LeftButtonDown", "RightButtonDown", "MiddleButtonDown", "Button4Down", "Button5Down") -- somehow I recall this not matterign?
f:RegisterForDrag("LeftButton")
f:SetScript("OnClick", function()
ifCliquethen
ifnotClique:OnClick(arg1, this.unit) then
self:ClickHandle(arg1) -- if it failed to find anything in clique then we send it to the regular handler
end
else
self:ClickHandle(arg1)
end
end)
f:SetScript("OnEnter", function()
ifUnitAffectingCombat("player") andself.o.disablemouseoverincombatthen
return
end
UnitFrame_OnEnter() -- a blizzard function that handles the tooltip for the unit
end)
f:SetScript("OnLeave", function()
UnitFrame_OnLeave() -- blizz function that handles tooltip for units
end)
f:SetScript("OnDragStart", function() -- on drag of any unit frame will drag the NotGridContainer frame
ifself.o.draggablethen
self.Container:StartMoving()
end
end)
f:SetScript("OnDragStop", function()
ifself.o.draggablethen
self.Container:StopMovingOrSizing()
end
end)
--we can split these up into their own relative frames & functions later
--might as well
f:RegisterEvent("UNIT_NAME_UPDATE")
f:RegisterEvent("UNIT_PORTRAIT_UPDATE")
--healthbar
f:RegisterEvent("UNIT_HEALTH")
f:RegisterEvent("UNIT_MAXHEALTH")
--manabar
f:RegisterEvent("UNIT_MANA")
f:RegisterEvent("UNIT_RAGE")
f:RegisterEvent("UNIT_FOCUS")
f:RegisterEvent("UNIT_ENERGY")
f:RegisterEvent("UNIT_HAPPINESS")
f:RegisterEvent("UNIT_MAXMANA")
f:RegisterEvent("UNIT_MAXRAGE")
f:RegisterEvent("UNIT_MAXFOCUS")
f:RegisterEvent("UNIT_MAXENERGY")
f:RegisterEvent("UNIT_MAXHAPPINESS")
f:RegisterEvent("UNIT_DISPLAYPOWER")
--aura
f:RegisterEvent("UNIT_AURA")
--used for highlight target feature
f:RegisterEvent("PLAYER_TARGET_CHANGED")
--banzai/healcomm are registered in core on enable
f:SetScript("OnEvent", function()
ifarg1andarg1==this.unitthen-- if an event has coniditions specific to a unit, then only specified unit will update
ifevent=="UNIT_AURA" then
self:UNIT_AURA(this.unit)
else
self:UNIT_MAIN(this.unit)
self:UNIT_BORDER(this.unit)
end
elseifevent=="PLAYER_TARGET_CHANGED" then-- all units will update their border
self:UNIT_BORDER(this.unit)
end
end)
returnf
end
-------------------
-- Config Frames --
-------------------
functionNotGrid:ConfigUnitFrames() -- this can get called on every setting change, instead of doing some wierd roundabout way. Hurray!
localo=self.o
for_,finself.UnitFramesdo
--f:SetAlpha(self.o.ooralpha) -- we set lastseen at frame creation instead. doing it like this makes config mode weird, and would obstruct disabling prox checking
localwidth, height
ifo.showpowerbarando.powerposition<=2then-- factor in a modifier for the powerbar width/height
width=o.unitwidth
height=o.unitheight+o.powersize+1
elseifo.showpowerbarando.powerposition>=3then
width=o.unitwidth+o.powersize+1
height=o.unitheight
else
width=o.unitwidth
height=o.unitheight
end
f:SetWidth(width)
f:SetHeight(height)
f:SetBackdrop({bgFile="Interface\\Buttons\\WHITE8X8", tile=true, tileSize=16})
f:SetBackdropColor(unpack(o.unitbgcolor))
ifo.borderartworkthen
f.border:SetWidth(width+o.unitborder) -- the way edgefile works is it basically sits on the center of the edge of the frame and expands both inward and outward. So to compensate asthetically for that I ahve to increase the size of my frame double the desired width of the edgefile/border
f.border:SetHeight(height+o.unitborder)
f.border:SetBackdrop({edgeFile="Interface\\AddOns\\NotGrid\\media\\borderartwork", edgeSize=16})
else
f.border:SetWidth(width+o.unitborder*2) -- the way edgefile works is it basically sits on the center of the edge of the frame and expands both inward and outward. So to compensate asthetically for that I ahve to increase the size of my frame double the desired width of the edgefile/border
f.border:SetHeight(height+o.unitborder*2)
f.border:SetBackdrop({edgeFile="Interface\\Buttons\\WHITE8X8", edgeSize=o.unitborder})
end
f.border:SetBackdropBorderColor(unpack(o.unitbordercolor))
f.border:SetPoint("CENTER",0,0)
f.border:SetFrameLevel(f:GetFrameLevel() +2)
f.border.middleart:SetTexture("Interface/TargetingFrame/UI-TargetingFrame")
ifo.powerposition<=2then
f.border.middleart:SetTexCoord((58/256)+(1/256/2), (82/256)+(1/256/2), (39/128)+(1/128/2), (44/128)+(1/128/2))
f.border.middleart:SetVertexColor(unpack(o.unitbordercolor))
else
f.border.middleart:SetTexCoord((26/256)+(1/256/2), (32/256)+(1/256/2), (27/128)+(1/128/2), (34/128)+(1/128/2))
f.border.middleart:SetVertexColor(unpack(o.unitbordercolor))
end
f.healthbar:SetWidth(o.unitwidth)
f.healthbar:SetHeight(o.unitheight)
ifo.unithealthorientation==1then
f.healthbar:SetOrientation("VERTICAL")
else
f.healthbar:SetOrientation("HORIZONTAL")
end
f.healthbar:SetStatusBarTexture(o.unithealthbartexture)
f.healthbar:SetStatusBarColor(unpack(o.unithealthbarcolor))
f.healthbar.bgtex:SetTexture(o.unithealthbarbgtexture)
f.healthbar.bgtex:SetVertexColor(unpack(o.unithealthbarbgcolor))
f.healthbar.bgtex:SetAllPoints()
--position health and powerbar
f.healthbar:ClearAllPoints()
f.powerbar:ClearAllPoints()
f.border.middleart:ClearAllPoints()
ifo.showpowerbarthen
ifo.powerposition<=2then-- power on top
ifo.powerposition==1then
f.healthbar:SetPoint("BOTTOM",0,0)
f.powerbar:SetPoint("TOP",0,0)
f.border.middleart:SetPoint("BOTTOM", f.powerbar, 0, -4)
else
f.healthbar:SetPoint("TOP",0,0)
f.powerbar:SetPoint("BOTTOM",0,0)
f.border.middleart:SetPoint("TOP", f.powerbar, 0, 4)
end
f.powerbar:SetWidth(o.unitwidth)
f.powerbar:SetHeight(o.powersize)
f.powerbar:SetOrientation("HORIZONTAL")
f.border.middleart:SetWidth(width)
f.border.middleart:SetHeight(6)
elseifo.powerposition>=3then
ifo.powerposition==3then
f.healthbar:SetPoint("LEFT",0,0)
f.powerbar:SetPoint("RIGHT",0,0)
f.border.middleart:SetPoint("LEFT", f.powerbar, -4, 0)
else
f.healthbar:SetPoint("RIGHT",0,0)
f.powerbar:SetPoint("LEFT",0,0)
f.border.middleart:SetPoint("RIGHT", f.powerbar, 4, 0)
end
f.powerbar:SetWidth(o.powersize)
f.powerbar:SetHeight(o.unitheight)
f.powerbar:SetOrientation("VERTICAL")
f.border.middleart:SetWidth(6)
f.border.middleart:SetHeight(height)
end
f.powerbar:Show()
ifo.borderartworkthen
f.border.middleart:Show()
else
f.border.middleart:Hide()
end
else
f.healthbar:SetPoint("CENTER",0,0)
f.powerbar:Hide()
f.border.middleart:Hide()
end
f.powerbar:SetStatusBarTexture(o.unithealthbartexture)
f.powerbar.bgtex:SetTexture(o.unithealthbartexture)
f.powerbar.bgtex:SetVertexColor(unpack(o.unitpowerbarbgcolor))
f.powerbar.bgtex:SetAllPoints()
--f.powerbar:SetStatusBarColor(unpack(o.unithealthbarcolor))
f.incres:SetWidth(o.unitheight) -- yep, so it stays square under most common sizes. Think of a mathematical way in the future
f.incres:SetHeight(o.unitheight)
f.incres:ClearAllPoints()
f.incres:SetPoint("CENTER",0,0)
f.incres.bgtex:SetTexture("Interface\\AddOns\\NotGrid\\media\\res")
f.incres.bgtex:SetAllPoints()
f.incres:Hide()
f.incheal:SetBackdrop({bgFile="Interface\\Buttons\\WHITE8X8", edgeFile="Interface\\Buttons\\WHITE8X8", tile=true, tileSize=16, edgeSize=1, insets= { left=0, right=0, top=0, bottom=0 }})
f.incheal:SetBackdropColor(0,0,0,0)
f.incheal:SetBackdropBorderColor(0,0,0,0) -- mostly just so its 0 opacity
f.incheal:SetWidth(o.unitwidth)
f.incheal:SetHeight(o.unitheight)
for_,fsnamein {"namehealthtext", "healcommtext"} do
localfs=f[fsname]
fs:SetShadowColor(0, 0, 0, 1.0)
fs:SetShadowOffset(0.80, -0.80)
fs:ClearAllPoints()
iffsname=="namehealthtext" then
ifnoto.colorunitnamehealthbyclassthen
fs:SetTextColor(unpack(o.unitnamehealthtextcolor))
end
fs:SetFont(o.unitfont, o.unitnamehealthtextsize)
fs:SetPoint("CENTER",f.healthbar,"CENTER",o.unitnamehealthoffx,o.unitnamehealthoffy)
elseiffsname=="healcommtext" then
fs:SetTextColor(unpack(o.unithealcommtextcolor))
fs:SetFont(o.unitfont, o.unithealcommtextsize)
fs:SetPoint("CENTER",f.healthbar,"CENTER",o.unithealcommtextoffx,o.unithealcommtextoffy)
ifnoto.showhealcommtextthen
fs:Hide()
end
end
end
fori,pointin {"TOPLEFT", "TOP", "TOPRIGHT", "RIGHT", "BOTTOMRIGHT", "BOTTOM", "BOTTOMLEFT", "LEFT"} do
localfi=f.healthbar["trackingicon"..i]
fi:SetWidth(o.unittrackingiconsize)
fi:SetHeight(o.unittrackingiconsize)
fi:SetBackdrop({bgFile="Interface\\Buttons\\WHITE8X8", edgeFile="Interface\\Buttons\\WHITE8X8", tile=true, tileSize=o.unittrackingiconsize, edgeSize=o.unittrackingiconborder})
fi:SetBackdropBorderColor(o.unittrackingiconbordercolor)
fi:SetBackdropColor(unpack(o["trackingicon"..i.."color"]))
fi:ClearAllPoints()
fi:SetPoint(point,0,0)
fi:Hide()
end
end
end
---------------------
-- Position Frames --
---------------------
functionNotGrid:PositionFrames()
localpartycount=GetNumPartyMembers()
localraidcount=GetNumRaidMembers()
localSubGroupCounts=self.Compost:Acquire(0,0,0,0,0,0,0,0,0,0) -- reset it every time
localTotalGroups=0
localTotalUnits=0
localo=self.o
localpowermodx=0-- so I can interject the width of the powerbar into the positioning calcs without doing a million more conditionals
localpowermody=0
ifo.showpowerbarthen
ifo.powerposition<=2then
powermody=o.powersize+1
else
powermodx=o.powersize+1
end
end
--handle all the unitframes and subgroups
fori=1,10do-- 1-8 is raid, 9 is party, 10 is partypet
forkey,finself.UnitFramesdo
ifUnitExists(f.unit) oro.configmodethen
-- first get the subgroup
localsubgroup=nil
iff.raidindexthen-- if a frame with raid unitid
ifo.configmodethen
subgroup= (math.ceil(math.abs(f.raidindex/5))) -- doing it like this does mean it loops and calcs this 10 times for all the unitframes, though
else
_,_,subgroup=GetRaidRosterInfo(f.raidindex)
end
elseif (string.find(f.unit,"party%d") or (f.unit=="player")) and ((raidcount>0ando.showpartyinraid) or (raidcount==0andpartycount>0ando.showinpartyandnoto.configmode) or (raidcount==0andpartycount==0ando.showwhilesoloandnoto.configmode) or (o.configmodeando.showpartyinraid)) then
subgroup=9
elseif (string.find(f.unit,"partypet%d") or (f.unit=="pet")) and ((raidcount>0ando.showpartyinraidando.showpets) or (raidcount==0andpartycount>0ando.showinpartyando.showpetsandnoto.configmode) or (raidcount==0andpartycount==0ando.showwhilesoloando.showpetsandnoto.configmode) or (o.configmodeando.showpartyinraidando.showpets)) then
subgroup=10
else
f:Hide() -- I won't set a subgroup so it will fail the next check, wont position, and won't get counted into subgroup/totalgroups
end
--then do all the positioning
ifsubgroup==ithen
f:ClearAllPoints()
ifo.growthdirection==1then-- groups grow left to right, units grow top to bottom
f:SetPoint("CENTER",(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)*TotalGroups,-(o.unitheight+powermody+o.unitborder*2+o.unitpadding)*SubGroupCounts[i])
elseifo.growthdirection==2then-- groups grow left to right, units grow bottom to top
f:SetPoint("CENTER",(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)*TotalGroups,(o.unitheight+powermody+o.unitborder*2+o.unitpadding)*SubGroupCounts[i])
elseifo.growthdirection==3then-- groups grow right to left, units grow bottom to top
f:SetPoint("CENTER",-(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)*TotalGroups,(o.unitheight+powermody+o.unitborder*2+o.unitpadding)*SubGroupCounts[i])
elseifo.growthdirection==4then-- groups grow right to left, units grow top to bottom
f:SetPoint("CENTER",-(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)*TotalGroups,-(o.unitheight+powermody+o.unitborder*2+o.unitpadding)*SubGroupCounts[i]) -- i do subgroup -1 so group 1 will be 0 and be at 0 offset
elseifo.growthdirection==5then-- groups grow top to bottom, units grow left to right
f:SetPoint("CENTER",(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)*SubGroupCounts[i],-(o.unitheight+powermody+o.unitborder*2+o.unitpadding)*TotalGroups)
elseifo.growthdirection==6then-- groups grow bottom to top, units grow left to right
f:SetPoint("CENTER",(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)*SubGroupCounts[i],(o.unitheight+powermody+o.unitborder*2+o.unitpadding)*TotalGroups)
elseifo.growthdirection==7then-- groups grow bottom to top, units grow right to left
f:SetPoint("CENTER",-(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)*SubGroupCounts[i],(o.unitheight+powermody+o.unitborder*2+o.unitpadding)*TotalGroups)
elseifo.growthdirection==8then-- groups grow top to bottom, units grow right to left
f:SetPoint("CENTER",-(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)*SubGroupCounts[i],-(o.unitheight+powermody+o.unitborder*2+o.unitpadding)*TotalGroups)
elseifo.growthdirection==9then-- single top to bottom
f:SetPoint("CENTER",0,-(o.unitheight+powermody+o.unitborder*2+o.unitpadding)*TotalUnits)
elseifo.growthdirection==10then-- single bottom to top
f:SetPoint("CENTER",0,(o.unitheight+powermody+o.unitborder*2+o.unitpadding)*TotalUnits)
elseifo.growthdirection==11then-- single left to right
f:SetPoint("CENTER",(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)*TotalUnits,0)
elseifo.growthdirection==12then-- single right to left
f:SetPoint("CENTER",-(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)*TotalUnits,0)
end
f:Show()
TotalUnits=TotalUnits+1
SubGroupCounts[i] =SubGroupCounts[i]+1
--DEFAULT_CHAT_FRAME:AddMessage(f.unit .. " positioned")
end
else
f:Hide()
end
end
ifSubGroupCounts[i] >0then
TotalGroups=TotalGroups+1
end
end
--handle the container frame
ifnoto.draggablethen
self.Container:ClearAllPoints()
ifo.smartcenter==trueand (o.growthdirection==1oro.growthdirection==2) then
self.Container:SetPoint(o.containerpoint,o.containeroffx-(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)/2*(TotalGroups-1),o.containeroffy)
elseifo.smartcenter==trueand (o.growthdirection==3oro.growthdirection==4) then
self.Container:SetPoint(o.containerpoint,o.containeroffx+(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)/2*(TotalGroups-1),o.containeroffy)
elseifo.smartcenter==trueand (o.growthdirection==5oro.growthdirection==6) then
table.sort(SubGroupCounts)
self.Container:SetPoint(o.containerpoint,o.containeroffx-(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)/2*(SubGroupCounts[10]-1),o.containeroffy)
elseifo.smartcenter==trueand (o.growthdirection==7oro.growthdirection==8) then
table.sort(SubGroupCounts)
self.Container:SetPoint(o.containerpoint,o.containeroffx+(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)/2*(SubGroupCounts[10]-1),o.containeroffy)
elseifo.smartcenter==trueando.growthdirection==11then
self.Container:SetPoint(o.containerpoint,o.containeroffx-(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)/2*(TotalUnits-1),o.containeroffy)
elseifo.smartcenter==trueando.growthdirection==12then
self.Container:SetPoint(o.containerpoint,o.containeroffx+(o.unitwidth+powermodx+o.unitborder*2+o.unitpadding)/2*(TotalUnits-1),o.containeroffy)
else
self.Container:SetPoint(o.containerpoint,o.containeroffx,o.containeroffy)
end
end
self.Compost:Reclaim(SubGroupCounts)
end