vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 function GB_Bar_OnEvent(event)
2 if (not GB_INITIALIZED) then return; end
3 local hidden = GB_Settings[GB_INDEX][this.index].hide;
4 if (not hidden) then
5 hidden = GB_Settings[GB_INDEX][this.index].mouseover;
6 end
7 if (event == "PARTY_MEMBERS_CHANGED") then
8 local numParty = GetNumPartyMembers();
9 if (this.index == "lowesthealth") then
10 if (numParty > 0) then
11 this.noshow = false;
12 if (not hidden) then this:Show(); end
13 else
14 this.noshow = true;
15 this:Hide();
16 end
17 elseif (not hidden) then
18 local partyBar, petBar;
19 for i=1,4 do
20 partyBar = getglobal(GB_Get_UnitBar("party"..i));
21 petBar = getglobal(GB_Get_UnitBar("partypet"..i));
22 partyBar.noshow = true;
23 petBar.noshow = true;
24 partyBar:Hide();
25 petBar:Hide();
26 end
27 if (GB_Settings[GB_INDEX].hideInRaid and GetNumRaidMembers() > 0) then
28 return;
29 end
30 for i=1,numParty do
31 partyBar = getglobal(GB_Get_UnitBar("party"..i));
32 partyBar.noshow = false;
33 partyBar:Show();
34 if (UnitName("partypet"..i) and UnitExists("partypet"..i) and (not GB_Settings[GB_INDEX].partypet.hide)) then
35 petBar = getglobal(GB_Get_UnitBar("partypet"..i));
36 petBar.noshow = false;
37 petBar:Show();
38 end
39 end
40 end
41 elseif (event == "PLAYER_TARGET_CHANGED") then
42 this.noshow = true;
43 if (UnitName("target")) then
44 if (UnitCanAttack("player", "target")) then
45 if (this.index == "hostiletarget" and UnitHealth("target") > 0) then
46 this.noshow = false
47 end
48 else
49 if (UnitIsPlayer("target") and UnitFactionGroup("target") ~= UnitFactionGroup("player")) then
50 if (this.index == "hostiletarget" and UnitHealth("target") > 0) then
51 this.noshow = false;
52 end
53 else
54 if (this.index == "friendlytarget") then
55 this.noshow = false;
56 end
57 end
58 end
59 end
60 if (this.noshow) then
61 this:Hide();
62 else
63 if (not hidden) then this:Show(); end
64 end
65 elseif (event == "RAID_ROSTER_UPDATE") then
66 this.noshow = true;
67 if (UnitExists(this.unit) and GB_RAID_MEMBERS[UnitName(this.unit)]) then
68 this.noshow = false;
69 end
70 if (this.noshow) then
71 this:Hide();
72 else
73 if (not hidden) then this:Show(); end
74 end
75 elseif (event == "UNIT_PET") then
76 if (GB_Settings[GB_INDEX].hideInRaid and GetNumRaidMembers() > 0) then
77 hidden = true;
78 end
79 this.noshow = true;
80 if (UnitExists(this.unit)) then
81 this.noshow = false;
82 end
83 if (this.noshow) then
84 this:Hide();
85 else
86 if (not hidden) then this:Show(); end
87 end
88 end
89 end
90  
91 function GB_Bar_OnUpdate()
92 if (this.index == "friendlytarget" and GB_INITIALIZED) then
93 if (UnitCanAttack("player", "target")) then
94 this.noshow = true;
95 this:Hide();
96 if (not GB_Settings[GB_INDEX]["hostiletarget"].hide) then
97 GB_HostileTargetBar.noshow = false;
98 GB_HostileTargetBar:Show();
99 end
100 end
101 end
102 if (this.timer) then
103 this.timer = this.timer - arg1;
104 if (this.timer < 0) then
105 this.timer = nil;
106 this:Hide();
107 end
108 end
109 end
110  
111 function GB_Bars_Raise()
112 for index in GB_UNITS_ARRAY do
113 for _, unitBar in GB_UNITS_ARRAY[index].frames do
114 getglobal(unitBar):Raise();
115 end
116 end
117 end
118  
119 function GB_Initialize_AllBars()
120 for index in GB_UNITS_ARRAY do
121 if (index ~= "lowesthealth") then
122 for _, unitBar in GB_UNITS_ARRAY[index].frames do
123 GB_Update_Auras(getglobal(unitBar).unit);
124 end
125 end
126 for i=1, GB_UNITS_ARRAY[index].buttons do
127 GB_ActionButton_Initialize(index, i);
128 end
129 GB_Set_Appearance(index);
130 end
131 end
132  
133 function GB_Labels_Hide()
134 for unit, value in GB_UNITS_ARRAY do
135 for index in value.frames do
136 getglobal(value.frames[index].."_Label"):Hide();
137 end
138 end
139 end
140  
141 function GB_Labels_Show()
142 for unit, value in GB_UNITS_ARRAY do
143 for index in value.frames do
144 getglobal(value.frames[index].."_Label"):Show();
145 end
146 end
147 end
148  
149 function GB_Set_Appearance(bar)
150 local settings = GB_Get(bar);
151 for _, unitBar in GB_UNITS_ARRAY[bar].frames do
152 getglobal(unitBar):SetAlpha(settings.alpha);
153 if (settings.hide or getglobal(unitBar).noshow or settings.mouseover) then
154 getglobal(unitBar):Hide();
155 elseif (GB_Settings[GB_INDEX].hideInRaid and GetNumRaidMembers() > 0 and string.find(bar, "party")) then
156 getglobal(unitBar):Hide();
157 else
158 getglobal(unitBar):Show();
159 end
160 if (settings.attach and bar ~= "lowesthealth") then
161 getglobal(unitBar):ClearAllPoints();
162 if (unitBar == "GB_PetBar0") then
163 local unitFrame = GB_UNITFRAMES.pet.frames[1];
164 getglobal(unitBar):SetPoint(settings.attachPoint, unitFrame, settings.attachTo, settings.xoffset, settings.yoffset);
165 elseif (bar == "raid") then
166 if (CT_RAMember1) then
167 local unitFrame = "CT_RAMember"..getglobal(unitBar):GetID();
168 getglobal(unitBar):SetPoint(settings.attachPoint, unitFrame, settings.attachTo, settings.xoffset, settings.yoffset);
169 elseif (beyondRaidGroup1) then
170 GB_SHUFFLE_RAID = true;
171 local found;
172 for i=1, 8 do
173 for j = 1, 5 do
174 local raidframe = "beyondRaidGroup"..i.."Member"..j;
175 if (getglobal(raidframe).unitID == "raid"..getglobal(unitBar):GetID()) then
176 found = true;
177 getglobal(raidframe):RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp", "Button4Up", "Button5Up");
178 getglobal(unitBar):SetPoint(settings.attachPoint, raidframe, settings.attachTo, settings.xoffset, settings.yoffset);
179 break;
180 end
181 end
182 end
183 if (not found) then
184 getglobal(unitBar):SetPoint(settings.attachPoint, "beyondRaidGroup1Member1", settings.attachTo, settings.xoffset, settings.yoffset);
185 end
186 elseif (MRConfigPanel) then
187 GB_SHUFFLE_RAID = true;
188 local found;
189 for i=1, 100 do
190 local raidframe = "MRF"..i;
191 if (getglobal(raidframe).unit == "raid"..getglobal(unitBar):GetID()) then
192 found = true;
193 getglobal(raidframe):RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp", "Button4Up", "Button5Up");
194 getglobal(unitBar):SetPoint(settings.attachPoint, raidframe, settings.attachTo, settings.xoffset, settings.yoffset);
195 break;
196 end
197 end
198 if (not found) then
199 getglobal(unitBar):SetPoint(settings.attachPoint, "MRF1", settings.attachTo, settings.xoffset, settings.yoffset);
200 end
201 else
202 GB_SHUFFLE_RAID = true;
203 if (RaidPullout1Button1) then
204 local found;
205 for i = 1, 12 do
206 for j = 1, 15 do
207 local raidframe = "RaidPullout"..i.."Button"..j;
208 if (getglobal(raidframe).unit == "raid"..getglobal(unitBar):GetID()) then
209 found = true;
210 getglobal(unitBar):SetPoint(settings.attachPoint, raidframe, settings.attachTo, settings.xoffset, settings.yoffset);
211 break;
212 end
213 end
214 end
215 if (not found) then
216 getglobal(unitBar):SetPoint(settings.attachPoint, "RaidPullout1Button1", settings.attachTo, settings.xoffset, settings.yoffset);
217 end
218 end
219 end
220 else
221 local id = getglobal(unitBar):GetID();
222 if (id == 0) then id = 1; end
223 local bar2 = bar;
224 if (string.find(bar, "target")) then bar2 = "target"; end
225 local unitFrame = GB_UNITFRAMES[bar2].frames[id];
226 getglobal(unitBar):SetPoint(settings.attachPoint, unitFrame, settings.attachTo, settings.xoffset, settings.yoffset);
227 end
228 end
229 local button, cooldown, modelscale, textscale;
230 for i=1, GB_UNITS_ARRAY[bar].buttons do
231 button = getglobal(unitBar.."_Button_"..i);
232 cooldown = getglobal(button:GetName().."_Cooldown");
233 if (GB_Settings[GB_INDEX].modifybyUIscale) then
234 modelscale = settings.buttonSize / 36 * UIParent:GetScale();
235 else
236 modelscale = settings.buttonSize / 36;
237 end
238 textscale = settings.buttonSize / 36;
239 getglobal(button:GetName().."TextFrame").textscale = textscale;
240 getglobal(button:GetName().."TextFrame"):SetScale(textscale);
241 button:SetHeight(settings.buttonSize);
242 button:SetWidth(settings.buttonSize);
243 cooldown:SetScale(modelscale);
244 cooldown.scale = modelscale;
245 end
246 if (GB_Options:IsVisible()) then
247 getglobal(unitBar):Show();
248 end
249 GB_Set_Layout(bar, unitBar, 1);
250 end
251 end
252  
253 function GB_Set_Layout(bar, unitBar, override)
254 if (not GB_INITIALIZED) then return; end
255 local rows = GB_Settings[GB_INDEX][bar].rows;
256 local buttonSize = GB_Settings[GB_INDEX][bar].buttonSize;
257 local spacing = GB_Settings[GB_INDEX][bar].spacing;
258 local frameheight = rows * buttonSize;
259 local framewidth;
260 if (not override) then
261 if (rows == 1 and (not GB_Settings[GB_INDEX][bar].collapse)) then
262 framewidth = GB_UNITS_ARRAY[bar].buttons * buttonSize;
263 getglobal(unitBar):SetHeight(frameheight);
264 getglobal(unitBar):SetWidth(framewidth);
265 return;
266 end
267 end
268 local count = 0;
269 local row = 0;
270 local visiblecount = 0;
271 local highest = 0;
272 local prevrowstart = nil;
273 local newrow = math.ceil(GB_UNITS_ARRAY[bar].buttons / rows);
274 local resetrow = math.mod(GB_UNITS_ARRAY[bar].buttons, rows);
275 local lastbutton = unitBar;
276 for i=1, GB_UNITS_ARRAY[bar].buttons do
277 local button = getglobal(unitBar.."_Button_"..i);
278 button:ClearAllPoints();
279 if (count == newrow) then
280 local attachto = unitBar.."_Button_"..(i - count);
281 button:SetPoint("TOP", attachto, "BOTTOM", 0, -spacing);
282 if (button:IsVisible() or (not GB_Settings[GB_INDEX][bar].collapse)) then
283 lastbutton = button:GetName();
284 else
285 prevrowstart = attachto;
286 end
287 count = 0;
288 row = row + 1;
289 if (visiblecount > highest) then
290 highest = visiblecount;
291 end
292 visiblecount = 0;
293 if (button:IsVisible()) then
294 visiblecount = 1;
295 end
296 if (row == resetrow) then
297 newrow = newrow - 1;
298 end
299 else
300 if (lastbutton == unitBar) then
301 button:SetPoint("TOPLEFT", lastbutton, "TOPLEFT", 0, 0);
302 elseif (prevrowstart) then
303 button:SetPoint("TOP", prevrowstart, "BOTTOM", 0, -spacing);
304 if (button:IsVisible()) then
305 lastbutton = button:GetName();
306 prevrowstart = nil;
307 end
308 else
309 button:SetPoint("LEFT", lastbutton, "RIGHT", spacing, 0);
310 end
311 if (button:IsVisible() or (not GB_Settings[GB_INDEX][bar].collapse)) then
312 visiblecount = visiblecount + 1;
313 lastbutton = button:GetName();
314 end
315 end
316 count = count + 1;
317 end
318 if (highest == 0) then highest = visiblecount; end
319 framewidth = highest * buttonSize;
320 getglobal(unitBar):SetHeight(frameheight);
321 getglobal(unitBar):SetWidth(framewidth);
322 end