vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | function BEBOptions_LoadDefaults() |
2 | if ( not BEBINITIALIZED ) then |
||
3 | BEBConfigFrame:Hide(); |
||
4 | return; |
||
5 | end |
||
6 | BEBSettings[BEB_INDEX] = nil |
||
7 | BEB_DefaultSettings() |
||
8 | BEB_SetupBars() |
||
9 | BEB_UpdateBars() |
||
10 | BEB_Feedback("BEB Defaults Loaded") |
||
11 | BEBOptions_OnShow(BEBCurrentFrame) |
||
12 | end |
||
13 | |||
14 | function BEBOptions_SelectFrame() |
||
15 | if ( not BEBINITIALIZED ) then |
||
16 | this:GetParent():Hide(); |
||
17 | return; |
||
18 | end |
||
19 | local frames = {"BEBConfigGeneralFrame", "BEBConfigPlacementFrame", "BEBConfigColorsFrame"} |
||
20 | for _,v in frames do |
||
21 | getglobal(v):Hide() |
||
22 | end |
||
23 | BEBCurrentFrame = this.index |
||
24 | getglobal("BEBConfig"..this.index.."Frame"):Show() |
||
25 | end |
||
26 | |||
27 | function BEBOptions_CheckButton_OnClick() |
||
28 | if ( not BEBINITIALIZED ) then |
||
29 | this:GetParent():Hide(); |
||
30 | return; |
||
31 | end |
||
32 | if (this == BEBEnabledButton) then |
||
33 | BEBSettings[BEB_INDEX].Disabled = (not this:GetChecked()); |
||
34 | if (BEBSettings[BEB_INDEX].Disabled) then |
||
35 | BEBOptions_DisableAddon() |
||
36 | else |
||
37 | BEBOptions_EnableAddon() |
||
38 | end |
||
39 | else |
||
40 | if (this.notindex) then |
||
41 | BEBSettings[BEB_INDEX][this.notindex] = (not this:GetChecked()) |
||
42 | else |
||
43 | BEBSettings[BEB_INDEX][this.index] = (not(not this:GetChecked())) |
||
44 | end |
||
45 | end |
||
46 | if (this == BEBFlashHighlightButton) then |
||
47 | BEBRestedXpTickGlowTexture:SetAlpha(1); |
||
48 | BEB_OnEvent("PLAYER_UPDATE_RESTING") |
||
49 | elseif (this == BEBShowXpTextButton) then |
||
50 | if (BEBSettings[BEB_INDEX].XpTextOnMouseOver) then |
||
51 | BEB_Feedback(BEB_TEXT.optionstextwasmouseover) |
||
52 | BEBSettings[BEB_INDEX].XpTextOnMouseOver = false |
||
53 | BEBTextOnMouseoverButton:SetChecked(false); |
||
54 | end |
||
55 | elseif (this == BEBTextOnMouseoverButton) then |
||
56 | if (BEBSettings[BEB_INDEX].XpTextHide) then |
||
57 | BEB_Feedback(BEB_TEXT.optionstextwashidden) |
||
58 | BEBSettings[BEB_INDEX].XpTextHide = false |
||
59 | BEBShowXpTextButton:SetChecked(true); |
||
60 | end |
||
61 | end |
||
62 | BEB_SetupBars() |
||
63 | BEB_UpdateBars() |
||
64 | end |
||
65 | |||
66 | function BEBOptions_ColorPicker_OnClick() |
||
67 | if (ColorPickerFrame:IsShown()) then |
||
68 | BEB_ColorPicker_Cancelled(ColorPickerFrame.previousValues) |
||
69 | ColorPickerFrame:Hide() |
||
70 | else |
||
71 | local Red, Green, Blue, Alpha |
||
72 | Red, Green, Blue, Alpha = unpack(BEBSettings[BEB_INDEX][this.objindex][this.whenindex]) |
||
73 | ColorPickerFrame.previousValues = {Red, Green, Blue, Alpha}; |
||
74 | ColorPickerFrame.cancelFunc = BEB_ColorPicker_Cancelled; |
||
75 | ColorPickerFrame.opacityFunc = BEB_ColorPicker_OpacityChanged; |
||
76 | ColorPickerFrame.func = BEB_ColorPicker_ColorChanged; |
||
77 | ColorPickerFrame.index = this:GetName().."Texture"; |
||
78 | ColorPickerFrame.objindex = this.objindex |
||
79 | ColorPickerFrame.whenindex = this.whenindex |
||
80 | ColorPickerFrame.hasOpacity = true; |
||
81 | ColorPickerFrame.opacity = Alpha; |
||
82 | ColorPickerFrame:SetColorRGB(Red, Green, Blue); |
||
83 | ColorPickerFrame:ClearAllPoints(); |
||
84 | local x = BEBConfigFrame:GetCenter() |
||
85 | if (x < UIParent:GetWidth() / 2) then |
||
86 | ColorPickerFrame:SetPoint("LEFT", "BEBConfigFrame", "RIGHT", 0, 0); |
||
87 | else |
||
88 | ColorPickerFrame:SetPoint("RIGHT", "BEBConfigFrame", "LEFT", 0, 0); |
||
89 | end |
||
90 | ColorPickerFrame:Show(); |
||
91 | end |
||
92 | end |
||
93 | |||
94 | function BEB_ColorPicker_Cancelled(color) |
||
95 | BEBSettings[BEB_INDEX][ColorPickerFrame.objindex][ColorPickerFrame.whenindex] = color |
||
96 | BEBOptions_OnShow(BEBCurrentFrame) |
||
97 | end |
||
98 | |||
99 | function BEB_ColorPicker_ColorChanged() |
||
100 | local r, g, b = ColorPickerFrame:GetColorRGB() |
||
101 | local a = OpacitySliderFrame:GetValue() |
||
102 | getglobal(ColorPickerFrame.index):SetVertexColor(r,g,b,a) |
||
103 | if (not ColorPickerFrame:IsShown()) then |
||
104 | BEBSettings[BEB_INDEX][ColorPickerFrame.objindex][ColorPickerFrame.whenindex] = {r,g,b,a} |
||
105 | BEB_SetupBars() |
||
106 | BEB_UpdateBars() |
||
107 | BEB_OnEvent("PLAYER_UPDATE_RESTING") |
||
108 | BEB_OnEvent("UPDATE_EXHAUSTION") |
||
109 | end |
||
110 | end |
||
111 | function BEB_ColorPicker_OpacityChanged() |
||
112 | local r, g, b = ColorPickerFrame:GetColorRGB() |
||
113 | local a = OpacitySliderFrame:GetValue() |
||
114 | getglobal(ColorPickerFrame.index):SetVertexColor(r, g, b, a) |
||
115 | end |
||
116 | |||
117 | function BEBOptions_SliderOnChange() |
||
118 | local value = this:GetValue() |
||
119 | getglobal(this:GetName().."_EditBox"):SetText(value) |
||
120 | BEBSettings[BEB_INDEX][this.objindex][this.whatindex][this.axisindex] = value |
||
121 | BEB_SetupBars() |
||
122 | BEB_UpdateBars() |
||
123 | if ((this==BEBFontHeightSlider) and (BEBSettings[BEB_INDEX].XpTextOnMouseOver)) then |
||
124 | BEBXpFontstring:Show() |
||
125 | BEBTextTimeToHide = 2 |
||
126 | end |
||
127 | end |
||
128 | function BEBOptions_SliderEditBox_OnValueChange() |
||
129 | local value = this:GetNumber() |
||
130 | local slidervalue = this:GetParent():GetValue(value) |
||
131 | if (value ~= slidervalue) then |
||
132 | this:GetParent():SetValue(value) |
||
133 | end |
||
134 | end |
||
135 | |||
136 | function BEBOptions_OnShow(frame) |
||
137 | if ( not BEBINITIALIZED ) then |
||
138 | if (BEBSettings[BEB_INDEX].Disabled) then |
||
139 | BEBEnableFrame:Show() |
||
140 | end |
||
141 | BEBConfigFrame:Hide(); |
||
142 | return; |
||
143 | end |
||
144 | if (BEBSettings[BEB_INDEX].Disabled) then |
||
145 | BEBEnableFrame:Show() |
||
146 | BEBConfigFrame:Hide(); |
||
147 | end |
||
148 | if (frame == "Options") then |
||
149 | local selectors = {"BEBGeneralSelector", "BEBColorsSelector", "BEBPlacementSelector"} |
||
150 | for _,v in selectors do |
||
151 | getglobal(v):SetText(BEB_SELECTOR_LABELS[v]) |
||
152 | end |
||
153 | local frames = {"BEBConfigGeneralFrame", "BEBConfigPlacementFrame", "BEBConfigColorsFrame"} |
||
154 | for _,v in frames do |
||
155 | getglobal(v):Hide() |
||
156 | end |
||
157 | getglobal("BEBConfig"..BEBCurrentFrame.."Frame"):Show() |
||
158 | elseif (frame == "General") then |
||
159 | local buttons = {"BEBEnabledButton", "BEBShowMarksButton", "BEBShowXpTicksButton", "BEBShowRestedXpTicksButton", "BEBShowBackgroundButton", "BEBShowXpTextButton", "BEBFlashHighlightButton", "BEBTextOnMouseoverButton", "BEBShowRestedBarButton", "BEBUnlockBarButton"} |
||
160 | for _,v in buttons do |
||
161 | local button = getglobal(v) |
||
162 | if (button.notindex) then |
||
163 | button:SetChecked(not BEBSettings[BEB_INDEX][button.notindex]) |
||
164 | else |
||
165 | button:SetChecked(BEBSettings[BEB_INDEX][button.index]) |
||
166 | end |
||
167 | getglobal(v.."Text"):SetText(BEB_CHECKBUTTONLABELS[v]) |
||
168 | getglobal(v.."Text"):SetWidth(105); |
||
169 | getglobal(v.."Text"):SetJustifyH("LEFT"); |
||
170 | end |
||
171 | BEB_TextStringFrame_Label:SetText(BEB_HEADINGS.BEB_TextStringFrame_Label) |
||
172 | BEB_TextStringFrameEditBox:SetText(BEBSettings[BEB_INDEX].BarText.text.string) |
||
173 | BEBGeneralSelector:LockHighlight() |
||
174 | BEBColorsSelector:UnlockHighlight() |
||
175 | BEBPlacementSelector:UnlockHighlight() |
||
176 | elseif (frame == "Colors") then |
||
177 | local headings = {"BEBXpBarHeading", "BEBRestedBarHeading", "BEBMarkerHeading", "BEBTickHeading", "BEBRestedTickHeading", "BEBBarTextHeading"} |
||
178 | local buttons = {"BEBBackgroundColorButton", "BEBXpUnrestedColorButton", "BEBXpRestedColorButton", "BEBXpMaxRestedColorButton", "BEBRestedBarColorButton", "BEBRestedBarMaxColorButton", "BEBMarkerUnrestColorButton", "BEBMarkerRestColorButton", "BEBMarkerMaxrestColorButton", "BEBTickUnrestColorButton", "BEBTickRestColorButton", "BEBTickMaxrestColorButton", "BEBRestedTickRestColorButton", "BEBRestedTickMaxrestColorButton", "BEBBarTextUnrestColorButton", "BEBBarTextRestColorButton", "BEBBarTextMaxrestColorButton"} |
||
179 | for _,v in buttons do |
||
180 | local button = getglobal(v) |
||
181 | getglobal(v.."Texture"):SetVertexColor(unpack(BEBSettings[BEB_INDEX][button.objindex][button.whenindex])) |
||
182 | getglobal(v.."Text"):SetText(BEB_BUTTONLABELS[v]) |
||
183 | end |
||
184 | for _,v in headings do |
||
185 | local heading = getglobal(v) |
||
186 | heading:SetText(BEB_HEADINGS[v]) |
||
187 | heading:SetHeight(20) |
||
188 | heading:SetJustifyH("LEFT") |
||
189 | heading:SetJustifyV("BOTTOM") |
||
190 | end |
||
191 | BEBColorsSelector:LockHighlight() |
||
192 | BEBGeneralSelector:UnlockHighlight() |
||
193 | BEBPlacementSelector:UnlockHighlight() |
||
194 | elseif (frame == "Placement") then |
||
195 | local headings = {"BEBMainSizeHeading", "BEBTickSizeHeading", "BEBMainPositionControlsTitle", "BEBTickPositionControlsTitle", "BEB_MainAttachPointButton_Label", "BEB_MainAttachToPointButton_Label", "BEB_MainAttachToFrame_Label"} |
||
196 | local sliders = {"BEBMainHeightSlider", "BEBMainWidthSlider", "BEBTickHeightSlider", "BEBTickWidthSlider", "BEBFontHeightSlider"} |
||
197 | for _,v in sliders do |
||
198 | local slider = getglobal(v) |
||
199 | slider:SetValue(BEBSettings[BEB_INDEX][slider.objindex][slider.whatindex][slider.axisindex]) |
||
200 | getglobal(v.."_Label"):SetText(BEB_TEXT[slider.label]) |
||
201 | getglobal(v.."_EditBox"):SetText(BEBSettings[BEB_INDEX][slider.objindex][slider.whatindex][slider.axisindex]) |
||
202 | getglobal(v.."_EditBox"):SetTextColor(1,0.82,0) |
||
203 | getglobal(v.."Text"):Hide() |
||
204 | local min, max = slider:GetMinMaxValues(); |
||
205 | getglobal(v.."Low"):SetText(min); |
||
206 | getglobal(v.."High"):SetText(max); |
||
207 | end |
||
208 | for _,v in headings do |
||
209 | local heading = getglobal(v) |
||
210 | heading:SetText(BEB_HEADINGS[v]) |
||
211 | end |
||
212 | BEBMainPositionControlsxEditBox:SetText(BEBSettings[BEB_INDEX].BEBMain.location.x) |
||
213 | BEBMainPositionControlsyEditBox:SetText(BEBSettings[BEB_INDEX].BEBMain.location.y) |
||
214 | BEBTickPositionControlsxEditBox:SetText(BEBSettings[BEB_INDEX].Tick.location.x) |
||
215 | BEBTickPositionControlsyEditBox:SetText(BEBSettings[BEB_INDEX].Tick.location.y) |
||
216 | BEBMainPositionControlsxEditBox:SetTextColor(1,0.82,0) |
||
217 | BEBMainPositionControlsyEditBox:SetTextColor(1,0.82,0) |
||
218 | BEBTickPositionControlsxEditBox:SetTextColor(1,0.82,0) |
||
219 | BEBTickPositionControlsyEditBox:SetTextColor(1,0.82,0) |
||
220 | BEB_MainAttachToFrameEditBox:SetTextColor(1,0.82,0) |
||
221 | local attachpoint = BEBSettings[BEB_INDEX].BEBMain.location.point |
||
222 | local attachtopoint = BEBSettings[BEB_INDEX].BEBMain.location.relpoint |
||
223 | BEB_MainAttachPointButtonText:SetText(BEB_ATTACHPOINTS[attachpoint]) |
||
224 | BEB_MainAttachToPointButtonText:SetText(BEB_ATTACHPOINTS[attachtopoint]) |
||
225 | local attachtoframe = BEBSettings[BEB_INDEX].BEBMain.location.relto |
||
226 | if (BEB_UIATTACHFRAMES[attachtoframe]) then |
||
227 | BEB_MainAttachToFrameEditBox:SetText(BEB_UIATTACHFRAMES[attachtoframe]) |
||
228 | else |
||
229 | BEB_MainAttachToFrameEditBox:SetText(attachtoframe) |
||
230 | end |
||
231 | BEBPlacementSelector:LockHighlight() |
||
232 | BEBGeneralSelector:UnlockHighlight() |
||
233 | BEBColorsSelector:UnlockHighlight() |
||
234 | end |
||
235 | end |
||
236 | |||
237 | function BEBOptions_DisableAddon() |
||
238 | if ( not BEBINITIALIZED ) then |
||
239 | this:GetParent():Hide(); |
||
240 | return; |
||
241 | end |
||
242 | BEBMain:UnregisterEvent("PLAYER_LEVEL_UP") |
||
243 | BEBMain:UnregisterEvent("PLAYER_UPDATE_RESTING") |
||
244 | BEBMain:UnregisterEvent("PLAYER_XP_UPDATE") |
||
245 | BEBMain:UnregisterEvent("CHAT_MSG_COMBAT_XP_GAIN") |
||
246 | BEBMain:UnregisterEvent("UPDATE_EXHAUSTION") |
||
247 | BEBMain:Hide() |
||
248 | BEBDisabled = true |
||
249 | BEBSettings[BEB_INDEX].Disabled = true |
||
250 | if (BEBConfigFrame:IsShown()) then |
||
251 | BEBConfigFrame:Hide() |
||
252 | BEBEnableFrame:Show() |
||
253 | end |
||
254 | end |
||
255 | function BEBOptions_EnableAddon() |
||
256 | BEBINITIALIZED = nil |
||
257 | BEBSettings[BEB_INDEX].Disabled = false |
||
258 | BEBDisabled = false |
||
259 | BEB_Initialize() |
||
260 | end |
||
261 | |||
262 | function BEBOptions_OnMouseDown() |
||
263 | BEBConfigFrame:StartMoving() |
||
264 | end |
||
265 | |||
266 | function BEBOptions_OnMouseUp() |
||
267 | BEBConfigFrame:StopMovingOrSizing() |
||
268 | end |
||
269 | |||
270 | function BEBOptions_Nudge(arg1,button) |
||
271 | local change |
||
272 | if (arg1 == "RightButton") then |
||
273 | change = 5 |
||
274 | else |
||
275 | change = 1 |
||
276 | end |
||
277 | local thing = getglobal(button) |
||
278 | local axis |
||
279 | local element = thing:GetParent().index |
||
280 | if (thing.index == "0") then |
||
281 | BEBSettings[BEB_INDEX][element].location.x = 0 |
||
282 | BEBSettings[BEB_INDEX][element].location.y = 0 |
||
283 | elseif (thing.index == "up") then |
||
284 | BEBSettings[BEB_INDEX][element].location.y = BEBSettings[BEB_INDEX][element].location.y + change |
||
285 | elseif (thing.index == "down") then |
||
286 | BEBSettings[BEB_INDEX][element].location.y = BEBSettings[BEB_INDEX][element].location.y - change |
||
287 | elseif (thing.index == "left") then |
||
288 | BEBSettings[BEB_INDEX][element].location.x = BEBSettings[BEB_INDEX][element].location.x - change |
||
289 | elseif (thing.index == "right") then |
||
290 | BEBSettings[BEB_INDEX][element].location.x = BEBSettings[BEB_INDEX][element].location.x + change |
||
291 | end |
||
292 | getglobal(thing:GetParent():GetName().."xEditBox"):SetText(BEBSettings[BEB_INDEX][element].location.x) |
||
293 | getglobal(thing:GetParent():GetName().."yEditBox"):SetText(BEBSettings[BEB_INDEX][element].location.y) |
||
294 | end |
||
295 | |||
296 | function BEBOptions_Placement_OnUpdate(elapsed) |
||
297 | if (BEBNudging) then |
||
298 | if (BEBNudgeTime <= 0) then |
||
299 | BEBOptions_Nudge("MiddleButton",BEBNudging) |
||
300 | BEBNudgeTime = 0.015 |
||
301 | else |
||
302 | BEBNudgeTime = BEBNudgeTime - elapsed |
||
303 | end |
||
304 | end |
||
305 | end |
||
306 | |||
307 | function BEBOptions_PositionEditBox_OnValueChange() |
||
308 | local axis = this.index |
||
309 | local element = this:GetParent().index |
||
310 | BEBSettings[BEB_INDEX][element].location[axis] = this:GetNumber() |
||
311 | BEB_SetupBars() |
||
312 | BEB_UpdateBars() |
||
313 | end |
||
314 | |||
315 | function BEBOptions_DDM_OnUpdate(elapsed) |
||
316 | if (this.timer) then |
||
317 | if (this.timer <= 0) then |
||
318 | this:Hide() |
||
319 | else |
||
320 | this.timer = this.timer - elapsed |
||
321 | end |
||
322 | end |
||
323 | end |
||
324 | |||
325 | function BEBOptions_ShowMenu() |
||
326 | if (BEB_DropDownMenu:IsVisible()) then |
||
327 | BEB_DropDownMenu:Hide() |
||
328 | return |
||
329 | end |
||
330 | if (this.how) then |
||
331 | BEB_DropDownMenu.how = this.how |
||
332 | end |
||
333 | BEB_DropDownMenu.whatindex = this.whatindex |
||
334 | BEB_DropDownMenu.typeindex = this.typeindex |
||
335 | BEB_DropDownMenu.subindex = this.subindex |
||
336 | BEB_DropDownMenu.controlbox = this.controlbox |
||
337 | local count = 0; |
||
338 | local widest = 0; |
||
339 | for value, text in getglobal(this.table) do |
||
340 | count = count + 1 |
||
341 | getglobal("BEB_DropDownMenu_Button"..count.."Text"):SetText(text) |
||
342 | getglobal("BEB_DropDownMenu_Button"..count).value = value |
||
343 | getglobal("BEB_DropDownMenu_Button"..count):Show() |
||
344 | local width = getglobal("BEB_DropDownMenu_Button"..count.."Text"):GetStringWidth() |
||
345 | widest = math.max(widest, width) |
||
346 | end |
||
347 | for i=1, BEB_DropDownMenu.count do |
||
348 | if (i <= count) then |
||
349 | getglobal("BEB_DropDownMenu_Button"..i):SetWidth(widest); |
||
350 | else |
||
351 | getglobal("BEB_DropDownMenu_Button"..i):Hide(); |
||
352 | end |
||
353 | end |
||
354 | BEB_DropDownMenu:SetWidth(widest + 20); |
||
355 | BEB_DropDownMenu:SetHeight(count * 15 + 20); |
||
356 | BEB_DropDownMenu:ClearAllPoints(); |
||
357 | BEB_DropDownMenu:SetPoint("TOPLEFT", getglobal(this.controlbox), "BOTTOMLEFT", 0, 0); |
||
358 | if (BEB_DropDownMenu:GetBottom() < UIParent:GetBottom()) then |
||
359 | local yoffset = UIParent:GetBottom() - BEB_DropDownMenu:GetBottom(); |
||
360 | BEB_DropDownMenu:ClearAllPoints(); |
||
361 | BEB_DropDownMenu:SetPoint("TOPLEFT", getglobal(this.controlbox), "BOTTOMLEFT", 20, yoffset); |
||
362 | end |
||
363 | BEB_DropDownMenu:Show() |
||
364 | BEB_DropDownMenu.timer = 5 |
||
365 | end |
||
366 | |||
367 | function BEBOptions_MenuOptionOnClick() |
||
368 | if (this:GetParent().how) then |
||
369 | getglobal(this:GetParent().controlbox):Insert(this.value) |
||
370 | else |
||
371 | getglobal(this:GetParent().controlbox):SetText(getglobal(this:GetName().."Text"):GetText()) |
||
372 | BEBSettings[BEB_INDEX][this:GetParent().whatindex][this:GetParent().typeindex][this:GetParent().subindex] = this.value |
||
373 | end |
||
374 | BEB_SetupBars() |
||
375 | BEB_DropDownMenu:Hide() |
||
376 | end |
||
377 | |||
378 | function BEBOption_ChangeAttachTo() |
||
379 | if (BEB_IsFrame(this:GetText())) then |
||
380 | BEBSettings[BEB_INDEX].BEBMain.location.relto = this:GetText() |
||
381 | BEB_SetupBars() |
||
382 | else |
||
383 | BEB_Feedback(BEB_TEXT.frameisinvalid) |
||
384 | this:SetText(this.prevvals) |
||
385 | end |
||
386 | end |
||
387 | |||
388 | function BEBOption_ChangeText() |
||
389 | for k,_ in BEBOverlayFrame.texttable.events do |
||
390 | BEBOverlayFrame:UnregisterEvent(k) |
||
391 | end |
||
392 | BEBOverlayFrame.texttable = BEB_CompileString(this:GetText()) |
||
393 | BEB_StringEvent("PLAYER_LEVEL_UP") |
||
394 | for k,_ in BEBOverlayFrame.texttable.events do |
||
395 | BEBOverlayFrame:RegisterEvent(k) |
||
396 | end |
||
397 | BEBSettings[BEB_INDEX].BarText.text.string = this:GetText() |
||
398 | end |