vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | function DAB_Floater_Hide(id) |
2 | DAB_Settings[DAB_INDEX].Floaters[id].hide = 1; |
||
3 | getglobal("DAB_ActionButton_"..id):Hide(); |
||
4 | end |
||
5 | |||
6 | function DAB_Floater_Initialize(id) |
||
7 | local settings = DAB_Settings[DAB_INDEX].Floaters[id]; |
||
8 | local buttonName = "DAB_ActionButton_"..id; |
||
9 | local button = getglobal(buttonName); |
||
10 | |||
11 | local text = getglobal(buttonName.."_HotKey"); |
||
12 | text:SetFont(settings.Keybinding.font, settings.Keybinding.size, "outline='NORMAL'"); |
||
13 | text:SetTextColor(settings.Keybinding.color.r, settings.Keybinding.color.g, settings.Keybinding.color.b, 1); |
||
14 | if (settings.Keybinding.hide) then text:Hide(); else text:Show(); end |
||
15 | text = getglobal(buttonName.."_Count"); |
||
16 | text:SetFont(settings.Count.font, settings.Count.size, "outline='NORMAL'"); |
||
17 | text:SetTextColor(settings.Count.color.r, settings.Count.color.g, settings.Count.color.b, 1); |
||
18 | if (settings.Count.hide) then text:Hide(); else text:Show(); end |
||
19 | text = getglobal(buttonName.."_CooldownCount"); |
||
20 | text:SetFont(settings.Cooldown.font, settings.Cooldown.size, "outline='NORMAL'"); |
||
21 | text:SetTextColor(settings.Cooldown.color.r, settings.Cooldown.color.g, settings.Cooldown.color.b, 1); |
||
22 | if (settings.Cooldown.hide) then text:Hide(); else text:Show(); end |
||
23 | text = getglobal(buttonName.."_Timer"); |
||
24 | text:SetFont(settings.Cooldown.font, settings.Cooldown.size, "outline='NORMAL'"); |
||
25 | text:SetTextColor(settings.Cooldown.color.r, settings.Cooldown.color.g, settings.Cooldown.color.b, 1); |
||
26 | text = getglobal(buttonName.."_Name"); |
||
27 | text:SetFont(settings.Macro.font, settings.Macro.size, "outline='NORMAL'"); |
||
28 | text:SetTextColor(settings.Macro.color.r, settings.Macro.color.g, settings.Macro.color.b, 1); |
||
29 | if (settings.Macro.hide) then text:Hide(); else text:Show(); end |
||
30 | |||
31 | local icon = getglobal(buttonName.."_Icon"); |
||
32 | if (settings.trimEdges) then |
||
33 | icon:SetTexCoord(.078, .92, .079, .937); |
||
34 | else |
||
35 | icon:SetTexCoord(0, 1, 0, 1); |
||
36 | end |
||
37 | icon:SetVertexColor(1, 1, 1, settings.alpha); |
||
38 | background = getglobal(buttonName.."_Background"); |
||
39 | background:SetTexture(settings.buttonbg); |
||
40 | background:SetVertexColor(settings.buttonbgcolor.r, settings.buttonbgcolor.g, settings.buttonbgcolor.b, settings.alpha); |
||
41 | local checked = getglobal(buttonName.."_Checked"); |
||
42 | checked:SetTexture(settings.checked); |
||
43 | checked:SetVertexColor(settings.checkedcolor.r, settings.checkedcolor.g, settings.checkedcolor.b, settings.alpha); |
||
44 | local highlight = getglobal(buttonName.."_Highlight"); |
||
45 | highlight:SetTexture(settings.highlight); |
||
46 | highlight:SetVertexColor(settings.highlightcolor.r, settings.highlightcolor.g, settings.highlightcolor.b, settings.alpha); |
||
47 | local equipped = getglobal(buttonName.."_EquippedBorder"); |
||
48 | equipped:SetTexture(settings.ButtonBorder.etexture); |
||
49 | equipped:SetVertexColor(settings.ButtonBorder.ecolor.r, settings.ButtonBorder.ecolor.g, settings.ButtonBorder.ecolor.b, settings.alpha); |
||
50 | local border = getglobal(buttonName.."_Border"); |
||
51 | border:ClearAllPoints(); |
||
52 | border:SetPoint("TOPLEFT", button, "TOPLEFT", -settings.ButtonBorder.leftpadding, settings.ButtonBorder.toppadding); |
||
53 | border:SetHeight(36 + settings.ButtonBorder.toppadding + settings.ButtonBorder.bottompadding); |
||
54 | border:SetWidth(36 + settings.ButtonBorder.leftpadding + settings.ButtonBorder.rightpadding); |
||
55 | border:SetVertexColor(settings.ButtonBorder.color.r, settings.ButtonBorder.color.g, settings.ButtonBorder.color.b, settings.ButtonBorder.alpha); |
||
56 | |||
57 | button:SetParent(UIParent); |
||
58 | button:SetFrameStrata(settings.frameStrata); |
||
59 | local scale = settings.size / 36 * UIParent:GetScale(); |
||
60 | local cooldown = getglobal(buttonName.."_Cooldown"); |
||
61 | cooldown:SetFrameStrata(settings.frameStrata); |
||
62 | cooldown:SetFrameLevel(button:GetFrameLevel() + 1); |
||
63 | button:SetScale(scale); |
||
64 | local box = getglobal("DAB_FloaterBox_"..id); |
||
65 | button:ClearAllPoints(); |
||
66 | box:ClearAllPoints(); |
||
67 | button:SetPoint("CENTER", box, "CENTER", 0, 0); |
||
68 | box:SetPoint(settings.Anchor.point, settings.Anchor.frame, settings.Anchor.to, settings.Anchor.x, settings.Anchor.y); |
||
69 | box:SetHeight(settings.size); |
||
70 | box:SetWidth(settings.size); |
||
71 | |||
72 | button.hidden = nil; |
||
73 | button.OOR = nil; |
||
74 | button.OOM = nil; |
||
75 | button.AUN = nil; |
||
76 | |||
77 | if (settings.hide) then |
||
78 | button.hidden = nil; |
||
79 | button:Hide(); |
||
80 | else |
||
81 | button.hidden = true; |
||
82 | button:Show(); |
||
83 | end |
||
84 | |||
85 | button.activeConditions = {}; |
||
86 | button.fauxhidden = 1; |
||
87 | DAB_ActionButton_FauxShow(id); |
||
88 | end |
||
89 | |||
90 | function DAB_Floater_Location(id, x, y, frame, point, to) |
||
91 | if (not id) then return; end |
||
92 | local button = getglobal("DAB_ActionButton_"..id); |
||
93 | if (not button) then |
||
94 | DL_Error("Invalid button number sent to DAB_Floater_Location: "..id); |
||
95 | return; |
||
96 | elseif (not DAB_Settings[DAB_INDEX].Floaters[id]) then |
||
97 | DL_Error("Invalid floater number sent to DAB_Floater_Location: "..id); |
||
98 | return; |
||
99 | elseif (point and (not DL_VALID_ANCHOR[point])) then |
||
100 | DL_Error("Invalid anchor point sent to DAB_Floater_Location: "..point); |
||
101 | return; |
||
102 | elseif (to and (not DL_VALID_ANCHOR[to])) then |
||
103 | DL_Error("Invalid anchor to sent to DAB_Floater_Location: "..to); |
||
104 | return; |
||
105 | end |
||
106 | if (not x) then x = DAB_Settings[DAB_INDEX].Floaters[id].Anchor.x; end |
||
107 | if (not y) then y = DAB_Settings[DAB_INDEX].Floaters[id].Anchor.y; end |
||
108 | if (not frame) then frame = DAB_Settings[DAB_INDEX].Floaters[id].Anchor.frame; end |
||
109 | if (not point) then point = DAB_Settings[DAB_INDEX].Floaters[id].Anchor.point; end |
||
110 | if (not to) then to = DAB_Settings[DAB_INDEX].Floaters[id].Anchor.to; end |
||
111 | DAB_Settings[DAB_INDEX].Floaters[id].Anchor = {frame=frame, point=point, to=to, x=x, y=y}; |
||
112 | button = getglobal("DAB_FloaterBox_"..id); |
||
113 | button:ClearAllPoints(); |
||
114 | button:SetPoint(point, frame, to, x, y); |
||
115 | end |
||
116 | |||
117 | function DAB_Floater_MoveDown(id, amt) |
||
118 | if (not id) then return; end |
||
119 | local button = getglobal("DAB_ActionButton_"..id); |
||
120 | if (not button) then |
||
121 | DL_Error("Invalid button number sent to DAB_Floater_MoveDown: "..id); |
||
122 | return; |
||
123 | elseif (not DAB_Settings[DAB_INDEX].Floaters[id]) then |
||
124 | DL_Error("Invalid floater number sent to DAB_Floater_MoveDown: "..id); |
||
125 | return; |
||
126 | elseif (not amt) then |
||
127 | DL_Error("No amount sent to DAB_Floater_MoveDown: "..id); |
||
128 | return; |
||
129 | end |
||
130 | local y = DAB_Settings[DAB_INDEX].Floaters[id].Anchor.y - amt; |
||
131 | DAB_Settings[DAB_INDEX].Floaters[id].Anchor.y = y; |
||
132 | button = getglobal("DAB_FloaterBox_"..id); |
||
133 | button:ClearAllPoints(); |
||
134 | button:SetPoint(DAB_Settings[DAB_INDEX].Floaters[id].Anchor.point, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.frame, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.to, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.x, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.y); |
||
135 | end |
||
136 | |||
137 | function DAB_Floater_MoveLeft(id, amt) |
||
138 | if (not id) then return; end |
||
139 | local button = getglobal("DAB_ActionButton_"..id); |
||
140 | if (not button) then |
||
141 | DL_Error("Invalid button number sent to DAB_Floater_MoveLeft: "..id); |
||
142 | return; |
||
143 | elseif (not DAB_Settings[DAB_INDEX].Floaters[id]) then |
||
144 | DL_Error("Invalid floater number sent to DAB_Floater_MoveLeft: "..id); |
||
145 | return; |
||
146 | elseif (not amt) then |
||
147 | DL_Error("No amount sent to DAB_Floater_MoveLeft: "..id); |
||
148 | return; |
||
149 | end |
||
150 | local x = DAB_Settings[DAB_INDEX].Floaters[id].Anchor.x - amt; |
||
151 | DAB_Settings[DAB_INDEX].Floaters[id].Anchor.x = x; |
||
152 | button = getglobal("DAB_FloaterBox_"..id); |
||
153 | button:ClearAllPoints(); |
||
154 | button:SetPoint(DAB_Settings[DAB_INDEX].Floaters[id].Anchor.point, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.frame, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.to, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.x, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.y); |
||
155 | end |
||
156 | |||
157 | function DAB_Floater_MoveRight(id, amt) |
||
158 | if (not id) then return; end |
||
159 | local button = getglobal("DAB_ActionButton_"..id); |
||
160 | if (not button) then |
||
161 | DL_Error("Invalid button number sent to DAB_Floater_MoveRight: "..id); |
||
162 | return; |
||
163 | elseif (not DAB_Settings[DAB_INDEX].Floaters[id]) then |
||
164 | DL_Error("Invalid floater number sent to DAB_Floater_MoveRight: "..id); |
||
165 | return; |
||
166 | elseif (not amt) then |
||
167 | DL_Error("No amount sent to DAB_Floater_MoveRight: "..id); |
||
168 | return; |
||
169 | end |
||
170 | local x = DAB_Settings[DAB_INDEX].Floaters[id].Anchor.x + amt; |
||
171 | DAB_Settings[DAB_INDEX].Floaters[id].Anchor.x = x; |
||
172 | button = getglobal("DAB_FloaterBox_"..id); |
||
173 | button:ClearAllPoints(); |
||
174 | button:SetPoint(DAB_Settings[DAB_INDEX].Floaters[id].Anchor.point, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.frame, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.to, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.x, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.y); |
||
175 | end |
||
176 | |||
177 | function DAB_Floater_MoveUp(id, amt) |
||
178 | if (not id) then return; end |
||
179 | local button = getglobal("DAB_ActionButton_"..id); |
||
180 | if (not button) then |
||
181 | DL_Error("Invalid button number sent to DAB_Floater_MoveUp: "..id); |
||
182 | return; |
||
183 | elseif (not DAB_Settings[DAB_INDEX].Floaters[id]) then |
||
184 | DL_Error("Invalid floater number sent to DAB_Floater_MoveUp: "..id); |
||
185 | return; |
||
186 | elseif (not amt) then |
||
187 | DL_Error("No amount sent to DAB_Floater_MoveUp: "..id); |
||
188 | return; |
||
189 | end |
||
190 | local y = DAB_Settings[DAB_INDEX].Floaters[id].Anchor.y + amt; |
||
191 | DAB_Settings[DAB_INDEX].Floaters[id].Anchor.y = y; |
||
192 | button = getglobal("DAB_FloaterBox_"..id); |
||
193 | button:ClearAllPoints(); |
||
194 | button:SetPoint(DAB_Settings[DAB_INDEX].Floaters[id].Anchor.point, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.frame, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.to, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.x, DAB_Settings[DAB_INDEX].Floaters[id].Anchor.y); |
||
195 | end |
||
196 | |||
197 | function DAB_Floater_SetDefaults(id, action) |
||
198 | if (not action) then |
||
199 | action = id; |
||
200 | end |
||
201 | DAB_Settings[DAB_INDEX].Buttons[id] = { Bar="F", Conditions = {}, Scripts = {}, action=action }; |
||
202 | DAB_Settings[DAB_INDEX].Floaters[id] = { |
||
203 | alpha = 1, |
||
204 | buttonbg = "Interface\\AddOns\\DiscordLibrary\\EmptyButton", |
||
205 | buttonbgcolor = {r=1, g=1, b=1}, |
||
206 | cbgroup = i, |
||
207 | checked = "Interface\\Buttons\\CheckButtonHilight", |
||
208 | checkedcolor = {r=1, g=1, b=1}, |
||
209 | cooldownCount = 1, |
||
210 | frameStrata = "LOW", |
||
211 | highlight = "Interface\\Buttons\\ButtonHilight-Square", |
||
212 | highlightcolor = {r=1, g=1, b=1}, |
||
213 | middleClick = id, |
||
214 | rightClick = id, |
||
215 | size = 36, |
||
216 | rangecolor = {r=1, g=.1, b=.1}, |
||
217 | manacolor = {r=.2, g=.2, b=1}, |
||
218 | unusablecolor = {r=.6, g=.6, b=.6}, |
||
219 | manarecolor = 1, |
||
220 | rangerecolor = 1, |
||
221 | unusablerecolor = 1, |
||
222 | |||
223 | Keybinding = { |
||
224 | font = "Fonts\\FRIZQT__.TTF", |
||
225 | color = {r=1, g=1, b=1}, |
||
226 | size = 10 |
||
227 | }, |
||
228 | Count = { |
||
229 | font = "Fonts\\FRIZQT__.TTF", |
||
230 | color = {r=1, g=1, b=1}, |
||
231 | size = 10 |
||
232 | }, |
||
233 | Cooldown = { |
||
234 | font = "Fonts\\FRIZQT__.TTF", |
||
235 | color = {r=1, g=1, b=0}, |
||
236 | size = 16 |
||
237 | }, |
||
238 | Macro = { |
||
239 | font = "Fonts\\FRIZQT__.TTF", |
||
240 | color = {r=1, g=1, b=0}, |
||
241 | size = 10 |
||
242 | }, |
||
243 | |||
244 | Anchor = { |
||
245 | frame = "UIParent", |
||
246 | to = "CENTER", |
||
247 | point = "CENTER", |
||
248 | x = 0, |
||
249 | y = 0 |
||
250 | }, |
||
251 | |||
252 | ButtonBorder = { |
||
253 | alpha = 1, |
||
254 | color = {r=1, g=1, b=0}, |
||
255 | ecolor = {r=0, g=1, b=0}; |
||
256 | texture = "Interface\\Buttons\\UI-Quickslot2", |
||
257 | etexture = "Interface\\Buttons\\ButtonHilight-Square", |
||
258 | toppadding = 12, |
||
259 | bottompadding = 13, |
||
260 | leftpadding = 12, |
||
261 | rightpadding = 13 |
||
262 | }, |
||
263 | |||
264 | Scripts = {} |
||
265 | }; |
||
266 | end |
||
267 | |||
268 | function DAB_Floater_SetKeybinding(id, kbid) |
||
269 | if (not id) then return; end |
||
270 | local button = getglobal("DAB_ActionButton_"..id); |
||
271 | kbid = tonumber(kbid); |
||
272 | if (not button) then |
||
273 | DL_Error("Invalid button number sent to DAB_Floater_SetKeybinding: "..id); |
||
274 | return; |
||
275 | elseif (not DAB_Settings[DAB_INDEX].Floaters[id]) then |
||
276 | DL_Error("Invalid floater number sent to DAB_Floater_SetKeybinding: "..id); |
||
277 | return; |
||
278 | elseif (not kbid) then |
||
279 | DL_Error("Invalid keybinding ID sent to DAB_Floater_SetKeybinding: "..id); |
||
280 | return; |
||
281 | elseif (kbid < 1 or kbid > 120) then |
||
282 | DL_Error("Invalid keybinding ID sent to DAB_Floater_SetKeybinding: "..id); |
||
283 | return; |
||
284 | end |
||
285 | DAB_Settings[DAB_INDEX].Keybindings[kbid].option=3; |
||
286 | DAB_Settings[DAB_INDEX].Keybindings[kbid].suboption=id; |
||
287 | DAB_Update_Keybindings(); |
||
288 | end |
||
289 | |||
290 | function DAB_Floater_SetTarget(id, unit, force) |
||
291 | if (not DAB_Settings[DAB_INDEX].Floaters[id]) then |
||
292 | DL_Error("Invalid floater id passed to DAB_Floater_SetTarget: "..id); |
||
293 | end |
||
294 | DAB_Settings[DAB_INDEX].Floaters[id].target = unit; |
||
295 | DAB_Settings[DAB_INDEX].Floaters[id].forceTarget = force; |
||
296 | end |
||
297 | |||
298 | function DAB_Floater_Show(id) |
||
299 | DAB_Settings[DAB_INDEX].Floaters[id].hide = nil; |
||
300 | getglobal("DAB_ActionButton_"..id):Show(); |
||
301 | end |
||
302 | |||
303 | function DAB_Floater_Size(id, size) |
||
304 | if (not id) then return; end |
||
305 | local button = getglobal("DAB_ActionButton_"..id); |
||
306 | if (not button) then |
||
307 | DL_Error("Invalid button number sent to DAB_Floater_Size: "..id); |
||
308 | return; |
||
309 | elseif (not DAB_Settings[DAB_INDEX].Floaters[id]) then |
||
310 | DL_Error("Invalid floater number sent to DAB_Floater_Size: "..id); |
||
311 | return; |
||
312 | end |
||
313 | if (not size) then x = DAB_Settings[DAB_INDEX].Floaters[id].size; end |
||
314 | button:SetScale(size / 36 * UIParent:GetScale()); |
||
315 | button = getglobal("DAB_FloaterBox_"..id); |
||
316 | button:SetHeight(size); |
||
317 | button:SetWidth(size); |
||
318 | end |
||
319 | |||
320 | function DAB_Floater_TimeToHide(button, sec) |
||
321 | if (not DAB_Settings[DAB_INDEX].Floaters[button]) then |
||
322 | DL_Error("Attempt to call DAB_Floater_TimeToHide on a floater that doesn't exist: "..button); |
||
323 | return; |
||
324 | end |
||
325 | getglobal("DAB_ActionButton_"..button).timetohide = sec; |
||
326 | end |
||
327 | |||
328 | function DAB_Floater_Toggle(id) |
||
329 | if (DAB_Settings[DAB_INDEX].Floaters[id].hide) then |
||
330 | DAB_Floater_Show(id); |
||
331 | else |
||
332 | DAB_Floater_Hide(id); |
||
333 | end |
||
334 | end |