vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- |
2 | -- AutoBar |
||
3 | -- |
||
4 | -- Config functions |
||
5 | -- |
||
6 | -- Author: Marc aka Saien on Hyjal |
||
7 | -- http://64.168.251.69/wow |
||
8 | -- |
||
9 | |||
10 | UIPanelWindows["AutoBar_Options"] = { area = "center", pushable = 99, whileDead = 1 }; |
||
11 | |||
12 | StaticPopupDialogs["AUTOBAR_ITEMENTRY"] = { |
||
13 | text = "Enter Item Name or ItemID:", |
||
14 | button1 = TEXT(ACCEPT), |
||
15 | button2 = TEXT(CANCEL), |
||
16 | hasEditBox = 1, |
||
17 | maxLetters = 50, |
||
18 | hasWideEditBox = 1, |
||
19 | OnAccept = function() |
||
20 | local editBox = getglobal(this:GetParent():GetName().."WideEditBox"); |
||
21 | local text = editBox:GetText(); |
||
22 | if (tonumber(text) and tonumber(text) > 0) then |
||
23 | text = tonumber(text); |
||
24 | end |
||
25 | local tmp = AutoBar_Config[AutoBar_Player].buttons[AutoBar_Options_ConfigButton.editting]; |
||
26 | if (type(tmp) == "table") then |
||
27 | AutoBar_Config[AutoBar_Player].buttons[AutoBar_Options_ConfigButton.editting][AutoBar_Options_ConfigButton_ChooseCategory.editting] = text; |
||
28 | else |
||
29 | AutoBar_Config[AutoBar_Player].buttons[AutoBar_Options_ConfigButton.editting] = text; |
||
30 | end |
||
31 | AutoBar_Options_ConfigButton_ChooseCategory:Hide(); |
||
32 | end, |
||
33 | OnShow = function() |
||
34 | local editBox = getglobal(this:GetName().."WideEditBox"); |
||
35 | local tmp = AutoBar_Config[AutoBar_Player].buttons[AutoBar_Options_ConfigButton.editting]; |
||
36 | local txt; |
||
37 | if (type(tmp) == "table") then |
||
38 | txt = AutoBar_Config[AutoBar_Player].buttons[AutoBar_Options_ConfigButton.editting][AutoBar_Options_ConfigButton_ChooseCategory.editting]; |
||
39 | else |
||
40 | txt = AutoBar_Config[AutoBar_Player].buttons[AutoBar_Options_ConfigButton.editting]; |
||
41 | end |
||
42 | if (txt) then |
||
43 | editBox:SetText(txt); |
||
44 | else |
||
45 | editBox:SetText(""); |
||
46 | end |
||
47 | editBox:SetFocus(); |
||
48 | end, |
||
49 | OnHide = function() |
||
50 | local editBox = getglobal(this:GetName().."WideEditBox"); |
||
51 | if (ChatFrameEditBox:IsVisible()) then |
||
52 | ChatFrameEditBox:SetFocus(); |
||
53 | end |
||
54 | editBox:SetText(""); |
||
55 | end, |
||
56 | OnCancel = function() |
||
57 | this:GetParent():Hide(); |
||
58 | end, |
||
59 | EditBoxOnEnterPressed = function () |
||
60 | StaticPopupDialogs["AUTOBAR_ITEMENTRY"].OnAccept(); |
||
61 | this:GetParent():Hide(); |
||
62 | end, |
||
63 | EditBoxOnEscapePressed = function () |
||
64 | this:GetParent():Hide(); |
||
65 | end, |
||
66 | timeout = 0, |
||
67 | whileDead = 1, |
||
68 | hideOnEscape = 1 |
||
69 | }; |
||
70 | |||
71 | ------------------------------------ |
||
72 | ------------------------------------ |
||
73 | ------------------------------------ |
||
74 | |||
75 | local function AutoBar_Config_SlashCmd(msg) |
||
76 | --[[ |
||
77 | msg = string.lower (msg); |
||
78 | local firstword, restwords; |
||
79 | local idx = string.find(msg," "); |
||
80 | if (idx) then |
||
81 | firstword = string.sub(msg,1,idx-1); |
||
82 | restwords = string.sub(msg,idx+1); |
||
83 | else |
||
84 | firstword = msg; |
||
85 | end |
||
86 | ]] |
||
87 | |||
88 | AutoBar_ToggleConfig(); |
||
89 | end |
||
90 | |||
91 | ------------------------------------ |
||
92 | |||
93 | function AutoBar_Config_OnLoad() |
||
94 | SLASH_AUTOBAR1 = "/autobar"; |
||
95 | SlashCmdList["AUTOBAR"] = function (msg) |
||
96 | AutoBar_Config_SlashCmd(msg); |
||
97 | end |
||
98 | end |
||
99 | |||
100 | function AutoBar_Config_OnShow() |
||
101 | local idx,button,hotkey; |
||
102 | for idx = 1, AUTOBAR_MAXBUTTONS, 1 do |
||
103 | button = getglobal("AutoBar_Options_Buttons_Button"..idx); |
||
104 | hotkey = getglobal("AutoBar_Options_Buttons_Button"..idx.."HotKey"); |
||
105 | count = getglobal("AutoBar_Options_Buttons_Button"..idx.."Count"); |
||
106 | icon = getglobal("AutoBar_Options_Buttons_Button"..idx.."Icon"); |
||
107 | hotkey:SetText("#"..idx); |
||
108 | if (AutoBar_Config[AutoBar_Player].buttons[idx]) then |
||
109 | local buttoninfo = AutoBar_Config[AutoBar_Player].buttons[idx]; |
||
110 | icon:SetTexture(AutoBar_GetTexture(buttoninfo)); |
||
111 | count:SetText(""); |
||
112 | else |
||
113 | count:SetText("Empty"); |
||
114 | icon:SetTexture(""); |
||
115 | end |
||
116 | end |
||
117 | AutoBar_Options_Bar_Sliders(); |
||
118 | AutoBar_Options_CheckBox_Setup(); |
||
119 | end |
||
120 | |||
121 | function AutoBar_Config_ButtonSetTooltip() |
||
122 | local buttoninfo; |
||
123 | local preamble, extended; |
||
124 | if (this.itemid) then |
||
125 | local name,itemid = GetItemInfo(this.itemid); |
||
126 | if (name and itemid) then |
||
127 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
128 | GameTooltip:SetHyperlink(itemid); |
||
129 | else |
||
130 | local tmp = "item:"..this.itemid..":0:0:0"; |
||
131 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
132 | GameTooltip:SetHyperlink("item:"..this.itemid..":0:0:0"); |
||
133 | end |
||
134 | return; |
||
135 | end |
||
136 | if (this.category) then |
||
137 | buttoninfo = this.category; |
||
138 | extended=true; |
||
139 | elseif (string.find(this:GetName(), "^AutoBar_Options_Buttons_Button")) then |
||
140 | buttoninfo = AutoBar_Config[AutoBar_Player].buttons[this:GetID()]; |
||
141 | extended=true; |
||
142 | preamble=true; |
||
143 | elseif (string.find(this:GetName(), "^AutoBar_Options_ConfigButton_Button")) then |
||
144 | extended=true; |
||
145 | local tmp = AutoBar_Config[AutoBar_Player].buttons[AutoBar_Options_ConfigButton.editting]; |
||
146 | if (type(tmp) == "table") then |
||
147 | buttoninfo = tmp[this:GetID()] |
||
148 | else |
||
149 | buttoninfo = tmp; |
||
150 | end |
||
151 | end |
||
152 | local message = ""; |
||
153 | if (buttoninfo == "EMPTY") then |
||
154 | elseif (type(buttoninfo) == "table") then |
||
155 | if (preamble) then message = "Multi Category Button\n"; end |
||
156 | local idx,cat; |
||
157 | for idx,cat in buttoninfo do |
||
158 | if (type(cat) == "string" and AutoBar_Category_Info[cat]) then |
||
159 | message = message.."\n"..AutoBar_Category_Info[cat].description; |
||
160 | elseif (type(cat) == "number") then |
||
161 | local name = GetItemInfo(cat); |
||
162 | if (name) then |
||
163 | message = message.."\n"..name.." (Custom Item by ID)"; |
||
164 | else |
||
165 | message = message.."\n(Item ID not recognized)"; |
||
166 | end |
||
167 | else |
||
168 | message = message.."\n"..cat.." (Custom Item by Name)"; |
||
169 | end |
||
170 | end |
||
171 | elseif (type(buttoninfo) == "string" and AutoBar_Category_Info[buttoninfo]) then |
||
172 | if (preamble) then message = "Single Category Button\n\n"; end |
||
173 | message = message..AutoBar_Category_Info[buttoninfo].description; |
||
174 | if (extended) then |
||
175 | message = message.."\n"; |
||
176 | if (AutoBar_Category_Info[buttoninfo].notusable) then |
||
177 | message = message.."\nNot directly usable."; |
||
178 | end |
||
179 | if (AutoBar_Category_Info[buttoninfo].targetted) then |
||
180 | if (AutoBar_Category_Info[buttoninfo].targetted == "WEAPON") then |
||
181 | message = message.."\nWeapon Target\n(Left click main weapon\nRight click offhand weapon.)"; |
||
182 | else |
||
183 | message = message.."\nTargetted."; |
||
184 | end |
||
185 | end |
||
186 | if (AutoBar_Category_Info[buttoninfo].noncombat) then |
||
187 | message = message.."\nNon combat only."; |
||
188 | end |
||
189 | if (AutoBar_Category_Info[buttoninfo].combatonly) then |
||
190 | message = message.."\nCombat only."; |
||
191 | end |
||
192 | if (AutoBar_Category_Info[buttoninfo].location) then |
||
193 | message = message.."\nLocation: "..AutoBar_Category_Info[buttoninfo].location.."."; |
||
194 | end |
||
195 | if (AutoBar_Category_Info[buttoninfo].limit) then |
||
196 | message = message.."\nLimited Usage: "; |
||
197 | if (AutoBar_Category_Info[buttoninfo].limit.downhp) then |
||
198 | message = message.."Require HP restore"; |
||
199 | if (AutoBar_Category_Info[buttoninfo].limit.downmana) then |
||
200 | message = message..", "; |
||
201 | end |
||
202 | end |
||
203 | if (AutoBar_Category_Info[buttoninfo].limit.downmana) then |
||
204 | message = message.."Require Mana restore"; |
||
205 | end |
||
206 | end |
||
207 | |||
208 | end |
||
209 | elseif (type(buttoninfo) == "string" and not AutoBar_Category_Info[buttoninfo]) then |
||
210 | if (preamble) then message = "Single Item Button\n\n"; end |
||
211 | message = message..buttoninfo.." (Custom Item by Name)"; |
||
212 | elseif (type(buttoninfo) == "number") then |
||
213 | if (preamble) then message = "Single Item Button\n\n"; end |
||
214 | local name = GetItemInfo(buttoninfo); |
||
215 | if (name) then |
||
216 | message = message..name.." (Custom Item by ID)"; |
||
217 | else |
||
218 | message = message.."(Item ID not recognized)"; |
||
219 | end |
||
220 | end |
||
221 | |||
222 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
223 | GameTooltip:SetText(message); |
||
224 | end |
||
225 | |||
226 | function AutoBar_Config_Button_Edit(num) |
||
227 | if (not num) then num = AutoBar_Options_ConfigButton.editting; end |
||
228 | local buttoninfo = AutoBar_Config[AutoBar_Player].buttons[num]; |
||
229 | AutoBar_Options_ConfigButton.editting = num; |
||
230 | AutoBar_Options_ConfigButton:Show(); |
||
231 | AutoBar_Options_ConfigButtonTitleText:SetText("Edit Button #"..num); |
||
232 | local idx,tmp,i; |
||
233 | --- |
||
234 | if (type(buttoninfo) == "table") then |
||
235 | tmp = 0; |
||
236 | for idx = 1, 8, 1 do |
||
237 | if (AutoBar_Config[AutoBar_Player].buttons[num][idx]) then |
||
238 | tmp = idx; |
||
239 | end |
||
240 | end |
||
241 | idx = 1; |
||
242 | while (idx < tmp) do |
||
243 | if (AutoBar_Config[AutoBar_Player].buttons[num][idx]) then |
||
244 | idx = idx + 1; |
||
245 | else |
||
246 | AutoBar_Config[AutoBar_Player].buttons[num][idx] = |
||
247 | AutoBar_Config[AutoBar_Player].buttons[num][idx+1]; |
||
248 | AutoBar_Config[AutoBar_Player].buttons[num][idx+1] = nil; |
||
249 | tmp = 0; |
||
250 | for i = 1, 8, 1 do |
||
251 | if (AutoBar_Config[AutoBar_Player].buttons[num][i]) then |
||
252 | tmp = i; |
||
253 | end |
||
254 | end |
||
255 | end |
||
256 | end |
||
257 | end |
||
258 | --- |
||
259 | for idx = 1, 8, 1 do |
||
260 | local button = getglobal("AutoBar_Options_ConfigButton_Button"..idx); |
||
261 | local hotkey = getglobal("AutoBar_Options_ConfigButton_Button"..idx.."HotKey"); |
||
262 | local count = getglobal("AutoBar_Options_ConfigButton_Button"..idx.."Count"); |
||
263 | local icon = getglobal("AutoBar_Options_ConfigButton_Button"..idx.."Icon"); |
||
264 | local move = getglobal("AutoBar_Options_ConfigButton_Move"..idx); |
||
265 | local moveup = getglobal("AutoBar_Options_ConfigButton_Move"..idx.."_Up"); |
||
266 | local movedown = getglobal("AutoBar_Options_ConfigButton_Move"..idx.."_Down"); |
||
267 | local checkbox = getglobal("AutoBar_Options_ConfigButton_Option"..idx); |
||
268 | local checkboxtext = getglobal("AutoBar_Options_ConfigButton_Option"..idx.."Text"); |
||
269 | |||
270 | hotkey:Hide(); |
||
271 | if (type(buttoninfo) == "table") then |
||
272 | if (buttoninfo[idx]) then |
||
273 | move:Show(); |
||
274 | count:SetText(""); |
||
275 | if (AutoBar_Category_Info[buttoninfo[idx]] and AutoBar_Category_Info[buttoninfo[idx]].targetted) then |
||
276 | checkbox:Show(); |
||
277 | checkboxtext:SetText("Smart Self Cast"); |
||
278 | if (AutoBar_Config[AutoBar_Player].smartselfcast and AutoBar_Config[AutoBar_Player].smartselfcast[buttoninfo[idx]]) then |
||
279 | checkbox:SetChecked(1); |
||
280 | else |
||
281 | checkbox:SetChecked(0); |
||
282 | end |
||
283 | else |
||
284 | checkbox:Hide(); |
||
285 | end |
||
286 | if (idx == 1) then |
||
287 | moveup:Hide(); |
||
288 | else |
||
289 | moveup:Show(); |
||
290 | end |
||
291 | if (buttoninfo[idx+1]) then |
||
292 | movedown:Show(); |
||
293 | else |
||
294 | movedown:Hide(); |
||
295 | end |
||
296 | else |
||
297 | move:Hide(); |
||
298 | count:SetText("Empty"); |
||
299 | checkbox:Hide(); |
||
300 | end |
||
301 | icon:SetTexture(AutoBar_GetTexture(buttoninfo[idx])); |
||
302 | button:Show(); |
||
303 | else |
||
304 | move:Hide(); |
||
305 | if (idx == 1) then |
||
306 | icon:SetTexture(AutoBar_GetTexture(buttoninfo)); |
||
307 | button:Show(); |
||
308 | if (buttoninfo) then |
||
309 | count:SetText(""); |
||
310 | if (AutoBar_Category_Info[buttoninfo] and AutoBar_Category_Info[buttoninfo].targetted) then |
||
311 | checkbox:Show(); |
||
312 | checkboxtext:SetText("Smart Self Cast"); |
||
313 | if (AutoBar_Config[AutoBar_Player].smartselfcast and AutoBar_Config[AutoBar_Player].smartselfcast[buttoninfo]) then |
||
314 | checkbox:SetChecked(1); |
||
315 | else |
||
316 | checkbox:SetChecked(0); |
||
317 | end |
||
318 | else |
||
319 | checkbox:Hide(); |
||
320 | end |
||
321 | else |
||
322 | count:SetText("Empty"); |
||
323 | checkbox:Hide(); |
||
324 | end |
||
325 | else |
||
326 | button:Hide(); |
||
327 | checkbox:Hide(); |
||
328 | end |
||
329 | end |
||
330 | end |
||
331 | --- |
||
332 | if (type(buttoninfo) == "table") then |
||
333 | AutoBar_Options_ConfigButton_ConvertButton:SetText("Convert to Single Item"); |
||
334 | else |
||
335 | AutoBar_Options_ConfigButton_ConvertButton:SetText("Convert to Multi Item"); |
||
336 | end |
||
337 | end |
||
338 | |||
339 | local function AutoBar_ConfigButton_OnClick(mousebutton) |
||
340 | local tmp = AutoBar_Config[AutoBar_Player].buttons[AutoBar_Options_ConfigButton.editting]; |
||
341 | if (type(tmp) == "table") then |
||
342 | AutoBar_Options_ConfigButton_ChooseCategory.editting = this:GetID(); |
||
343 | else |
||
344 | AutoBar_Options_ConfigButton_ChooseCategory.editting = nil; |
||
345 | end |
||
346 | AutoBar_Options_ConfigButton_ChooseCategory:Show(); |
||
347 | end |
||
348 | |||
349 | local function AutoBar_ConfigButton_ChooseCategory_OnClick(mousebutton) |
||
350 | if (IsShiftKeyDown()) then |
||
351 | if (AutoBar_Options_ConfigButton_ChooseCategory.categoryexplore) then |
||
352 | AutoBar_Options_ConfigButton_ChooseCategory.categoryexplore = nil; |
||
353 | this:GetParent():Hide(); |
||
354 | else |
||
355 | local category = this.category; |
||
356 | if (category == "EMPTY") then category = nil; end |
||
357 | if (category) then |
||
358 | AutoBar_Options_ConfigButton_ChooseCategory.categoryexplore = category; |
||
359 | AutoBar_Config_ButtonChooseCategory_OnShow(); |
||
360 | end |
||
361 | end |
||
362 | else |
||
363 | local category = this.category; |
||
364 | if (category == "EMPTY") then category = nil; end |
||
365 | if (AutoBar_Options_ConfigButton_ChooseCategory.editting) then |
||
366 | AutoBar_Config[AutoBar_Player].buttons[AutoBar_Options_ConfigButton.editting][AutoBar_Options_ConfigButton_ChooseCategory.editting] = category; |
||
367 | else |
||
368 | AutoBar_Config[AutoBar_Player].buttons[AutoBar_Options_ConfigButton.editting] = category; |
||
369 | end |
||
370 | AutoBar_Options_ConfigButton_ChooseCategory.categoryexplore = nil; |
||
371 | this:GetParent():Hide(); |
||
372 | end |
||
373 | end |
||
374 | |||
375 | function AutoBar_Config_ButtonOnClick(mousebutton) |
||
376 | if (string.find(this:GetName(), "^AutoBar_Options_Buttons_Button")) then |
||
377 | return AutoBar_Config_Button_Edit(this:GetID()); |
||
378 | elseif (string.find(this:GetName(), "^AutoBar_Options_ConfigButton_Button")) then |
||
379 | return AutoBar_ConfigButton_OnClick(mousebutton); |
||
380 | elseif (string.find(this:GetName(), "^AutoBar_Options_ConfigButton_ChooseCategory_Button")) then |
||
381 | return AutoBar_ConfigButton_ChooseCategory_OnClick(mousebutton); |
||
382 | end |
||
383 | end |
||
384 | |||
385 | function AutoBar_Config_Button_ConvertOnClick() |
||
386 | local buttoninfo = AutoBar_Config[AutoBar_Player].buttons[AutoBar_Options_ConfigButton.editting]; |
||
387 | if (type(buttoninfo) == "table") then |
||
388 | local tmp = buttoninfo[1]; |
||
389 | AutoBar_Config[AutoBar_Player].buttons[AutoBar_Options_ConfigButton.editting] = tmp; |
||
390 | else |
||
391 | local tmp = buttoninfo; |
||
392 | AutoBar_Config[AutoBar_Player].buttons[AutoBar_Options_ConfigButton.editting] = { tmp }; |
||
393 | end |
||
394 | AutoBar_Config_Button_Edit(AutoBar_Options_ConfigButton.editting); |
||
395 | end |
||
396 | |||
397 | function AutoBar_Config_ButtonChooseCategory_OnShow() |
||
398 | if (AutoBar_Options_ConfigButton_ChooseCategory.categoryexplore and not AutoBar_Category_Info[AutoBar_Options_ConfigButton_ChooseCategory.categoryexplore]) then |
||
399 | AutoBar_Options_ConfigButton_ChooseCategory.categoryexplore = nil; |
||
400 | end |
||
401 | if (AutoBar_Options_ConfigButton_ChooseCategory.categoryexplore) then |
||
402 | AutoBar_Options_ConfigButton_ChooseCategory_HintText1:Hide(); |
||
403 | local category = AutoBar_Options_ConfigButton_ChooseCategory.categoryexplore; |
||
404 | |||
405 | FauxScrollFrame_Update(AutoBar_Options_ConfigButton_ChooseCategory_Scroll, table.getn(AutoBar_Category_Info[category].items), 7, 36); |
||
406 | local offset = FauxScrollFrame_GetOffset(AutoBar_Options_ConfigButton_ChooseCategory_Scroll); |
||
407 | local idx,name,texture; |
||
408 | for idx = 1, 7, 1 do |
||
409 | local button = getglobal("AutoBar_Options_ConfigButton_ChooseCategory_Button"..idx); |
||
410 | local hotkey = getglobal("AutoBar_Options_ConfigButton_ChooseCategory_Button"..idx.."HotKey"); |
||
411 | local count = getglobal("AutoBar_Options_ConfigButton_ChooseCategory_Button"..idx.."Count"); |
||
412 | local icon = getglobal("AutoBar_Options_ConfigButton_ChooseCategory_Button"..idx.."Icon"); |
||
413 | local text = getglobal("AutoBar_Options_ConfigButton_ChooseCategory_Text"..idx); |
||
414 | button.category = nil; |
||
415 | if (AutoBar_Category_Info[category].items[idx+offset]) then |
||
416 | if (type(AutoBar_Category_Info[category].items[idx+offset]) == "number") then |
||
417 | name,_,_,_,_,_,_,_,texture = GetItemInfo(AutoBar_Category_Info[category].items[idx+offset]); |
||
418 | if (not name) then |
||
419 | name = "(Not Found: Item "..AutoBar_Category_Info[category].items[idx+offset]..")"; |
||
420 | texture = "Interface\\Icons\\INV_Misc_Gift_01"; |
||
421 | elseif (not texture) then |
||
422 | texture = "Interface\\Icons\\INV_Misc_Gift_02"; |
||
423 | end |
||
424 | else |
||
425 | texture = "Interface\\Icons\\INV_Misc_Gift_03"; |
||
426 | name = AutoBar_Category_Info[category].items[idx+offset]; |
||
427 | end |
||
428 | icon:SetTexture(texture); |
||
429 | text:SetText(name); |
||
430 | count:SetText(""); |
||
431 | button:Show(); |
||
432 | button.itemid = tonumber(AutoBar_Category_Info[category].items[idx+offset]); |
||
433 | else |
||
434 | button:Hide(); |
||
435 | button.itemid = nil; |
||
436 | text:SetText(""); |
||
437 | end |
||
438 | end |
||
439 | else |
||
440 | AutoBar_Options_ConfigButton_ChooseCategory_HintText1:Show(); |
||
441 | local sortedCategories = {}; |
||
442 | for categoryName, rec in AutoBar_Category_Info do |
||
443 | table.insert(sortedCategories, categoryName); |
||
444 | end |
||
445 | table.sort (sortedCategories); |
||
446 | table.insert(sortedCategories, 1, "EMPTY"); |
||
447 | FauxScrollFrame_Update(AutoBar_Options_ConfigButton_ChooseCategory_Scroll, table.getn(sortedCategories), 7, 36); |
||
448 | local offset = FauxScrollFrame_GetOffset(AutoBar_Options_ConfigButton_ChooseCategory_Scroll); |
||
449 | local idx; |
||
450 | for idx = 1, 7, 1 do |
||
451 | local button = getglobal("AutoBar_Options_ConfigButton_ChooseCategory_Button"..idx); |
||
452 | local hotkey = getglobal("AutoBar_Options_ConfigButton_ChooseCategory_Button"..idx.."HotKey"); |
||
453 | local count = getglobal("AutoBar_Options_ConfigButton_ChooseCategory_Button"..idx.."Count"); |
||
454 | local icon = getglobal("AutoBar_Options_ConfigButton_ChooseCategory_Button"..idx.."Icon"); |
||
455 | local text = getglobal("AutoBar_Options_ConfigButton_ChooseCategory_Text"..idx); |
||
456 | button.itemid = nil; |
||
457 | if (sortedCategories[idx+offset] == "EMPTY") then |
||
458 | icon:SetTexture(""); |
||
459 | count:SetText("Empty"); |
||
460 | text:SetText("Delete Current Category"); |
||
461 | button:Show(); |
||
462 | button.category = sortedCategories[idx+offset]; |
||
463 | elseif (sortedCategories[idx+offset]) then |
||
464 | icon:SetTexture(AutoBar_GetTexture(sortedCategories[idx+offset])); |
||
465 | count:SetText(""); |
||
466 | text:SetText(AutoBar_Category_Info[sortedCategories[idx+offset]].description); |
||
467 | button.category = sortedCategories[idx+offset]; |
||
468 | button:Show(); |
||
469 | else |
||
470 | button:Hide(); |
||
471 | button.category = nil; |
||
472 | text:SetText(""); |
||
473 | end |
||
474 | end |
||
475 | end |
||
476 | end |
||
477 | |||
478 | function AutoBar_Config_ButtonChooseCategory_OnScroll() |
||
479 | GameTooltip:Hide(); |
||
480 | AutoBar_Config_ButtonChooseCategory_OnShow(); |
||
481 | end |
||
482 | |||
483 | function AutoBar_Config_Button_InsertCustomItem() |
||
484 | StaticPopup_Show("AUTOBAR_ITEMENTRY"); |
||
485 | end |
||
486 | |||
487 | function AutoBar_Options_Bar_Sliders(calledfromslider) |
||
488 | if (not AutoBar_Config[AutoBar_Player].display) then |
||
489 | AutoBar_Config[AutoBar_Player].display = {}; |
||
490 | end |
||
491 | -- |
||
492 | local rows, columns, gapping, alpha, width, height, dockshiftx, dockshifty; |
||
493 | if (calledfromslider) then |
||
494 | rows = AutoBar_Options_Bar_Rows:GetValue(); |
||
495 | columns = AutoBar_Options_Bar_Columns:GetValue(); |
||
496 | gapping = AutoBar_Options_Bar_Gapping:GetValue(); |
||
497 | alpha = AutoBar_Options_Bar_Alpha:GetValue(); |
||
498 | width = AutoBar_Options_Bar_ButtonWidth:GetValue(); |
||
499 | height = AutoBar_Options_Bar_ButtonHeight:GetValue(); |
||
500 | dockshiftx = AutoBar_Options_Bar_DockShiftX:GetValue(); |
||
501 | dockshifty = AutoBar_Options_Bar_DockShiftY:GetValue(); |
||
502 | end |
||
503 | -- |
||
504 | if ((not rows or rows == 0) and AutoBar_Config[AutoBar_Player].display.rows) then |
||
505 | rows = AutoBar_Config[AutoBar_Player].display.rows; |
||
506 | elseif (not rows or rows == 0) then |
||
507 | rows = 1; |
||
508 | end |
||
509 | if ((not columns or columns == 0) and AutoBar_Config[AutoBar_Player].display.columns) then |
||
510 | columns = AutoBar_Config[AutoBar_Player].display.columns; |
||
511 | elseif (not columns or columns == 0) then |
||
512 | columns = 6; |
||
513 | end |
||
514 | if ((not gapping or gapping == 0) and AutoBar_Config[AutoBar_Player].display.gapping) then |
||
515 | gapping = AutoBar_Config[AutoBar_Player].display.gapping; |
||
516 | elseif (not gapping or gapping == 0) then |
||
517 | gapping = 6; |
||
518 | end |
||
519 | if ((not alpha or alpha == 0) and AutoBar_Config[AutoBar_Player].display.alpha) then |
||
520 | alpha = AutoBar_Config[AutoBar_Player].display.alpha*10; |
||
521 | elseif (not alpha or alpha == 0) then |
||
522 | alpha = 10; |
||
523 | end |
||
524 | if ((not width or width == 0) and AutoBar_Config[AutoBar_Player].display.buttonwidth) then |
||
525 | width = AutoBar_Config[AutoBar_Player].display.buttonwidth; |
||
526 | elseif (not width or width == 0) then |
||
527 | width = 36; |
||
528 | end |
||
529 | if ((not height or height == 0) and AutoBar_Config[AutoBar_Player].display.buttonheight) then |
||
530 | height = AutoBar_Config[AutoBar_Player].display.buttonheight; |
||
531 | elseif (not height or height == 0) then |
||
532 | height = 36; |
||
533 | end |
||
534 | if ((not dockshiftx or dockshiftx == 0) and AutoBar_Config[AutoBar_Player].display.dockshiftx) then |
||
535 | dockshiftx = AutoBar_Config[AutoBar_Player].display.dockshiftx; |
||
536 | elseif (not dockshiftx or dockshiftx == 0) then |
||
537 | dockshiftx = 0; |
||
538 | end |
||
539 | if ((not dockshifty or dockshifty == 0) and AutoBar_Config[AutoBar_Player].display.dockshifty) then |
||
540 | dockshifty = AutoBar_Config[AutoBar_Player].display.dockshifty; |
||
541 | elseif (not dockshifty or dockshifty == 0) then |
||
542 | dockshifty = 0; |
||
543 | end |
||
544 | -- |
||
545 | if (calledfromslider) then |
||
546 | while (rows*columns > 12) do |
||
547 | this:SetValue(this:GetValue()-1); |
||
548 | rows = AutoBar_Options_Bar_Rows:GetValue(); |
||
549 | columns = AutoBar_Options_Bar_Columns:GetValue(); |
||
550 | end |
||
551 | if (height ~= width and not AutoBar_Config[AutoBar_Player].display.unlockbuttonratio) then |
||
552 | if (this:GetName() == "AutoBar_Options_Bar_ButtonWidth") then |
||
553 | height = width; |
||
554 | elseif (this:GetName() == "AutoBar_Options_Bar_ButtonHeight") then |
||
555 | width = height; |
||
556 | end |
||
557 | end |
||
558 | -- |
||
559 | if (rows == 1) then |
||
560 | AutoBar_Config[AutoBar_Player].display.rows = nil; |
||
561 | else |
||
562 | AutoBar_Config[AutoBar_Player].display.rows = rows; |
||
563 | end |
||
564 | if (columns == 6) then |
||
565 | AutoBar_Config[AutoBar_Player].display.columns = nil; |
||
566 | else |
||
567 | AutoBar_Config[AutoBar_Player].display.columns = columns; |
||
568 | end |
||
569 | if (gapping == 6) then |
||
570 | AutoBar_Config[AutoBar_Player].display.gapping = nil; |
||
571 | else |
||
572 | AutoBar_Config[AutoBar_Player].display.gapping = gapping; |
||
573 | end |
||
574 | if (alpha == 10) then |
||
575 | AutoBar_Config[AutoBar_Player].display.alpha = nil; |
||
576 | else |
||
577 | AutoBar_Config[AutoBar_Player].display.alpha = math.floor(alpha)/10; |
||
578 | end |
||
579 | if (width == 36) then |
||
580 | AutoBar_Config[AutoBar_Player].display.buttonwidth = nil; |
||
581 | else |
||
582 | AutoBar_Config[AutoBar_Player].display.buttonwidth = width; |
||
583 | end |
||
584 | if (height == 36) then |
||
585 | AutoBar_Config[AutoBar_Player].display.buttonheight = nil; |
||
586 | else |
||
587 | AutoBar_Config[AutoBar_Player].display.buttonheight = height; |
||
588 | end |
||
589 | if (dockshiftx == 0) then |
||
590 | AutoBar_Config[AutoBar_Player].display.dockshiftx = nil; |
||
591 | else |
||
592 | AutoBar_Config[AutoBar_Player].display.dockshiftx = dockshiftx; |
||
593 | end |
||
594 | if (dockshifty == 0) then |
||
595 | AutoBar_Config[AutoBar_Player].display.dockshifty = nil; |
||
596 | else |
||
597 | AutoBar_Config[AutoBar_Player].display.dockshifty = dockshifty; |
||
598 | end |
||
599 | end |
||
600 | -- |
||
601 | AutoBar_Options_Bar_RowsText:SetText("Rows - "..rows); |
||
602 | AutoBar_Options_Bar_Rows:SetValue(rows); |
||
603 | AutoBar_Options_Bar_ColumnsText:SetText("Columns - "..columns); |
||
604 | AutoBar_Options_Bar_Columns:SetValue(columns); |
||
605 | AutoBar_Options_Bar_GappingText:SetText("Icon Gapping - "..gapping); |
||
606 | AutoBar_Options_Bar_Gapping:SetValue(gapping); |
||
607 | AutoBar_Options_Bar_AlphaText:SetText("Icon Alpha - "..math.floor(alpha)/10); |
||
608 | AutoBar_Options_Bar_Alpha:SetValue(alpha); |
||
609 | AutoBar_Options_Bar_ButtonWidthText:SetText("Button Width - "..width); |
||
610 | AutoBar_Options_Bar_ButtonWidth:SetValue(width); |
||
611 | AutoBar_Options_Bar_ButtonHeightText:SetText("Button Height - "..height); |
||
612 | AutoBar_Options_Bar_ButtonHeight:SetValue(height); |
||
613 | AutoBar_Options_Bar_DockShiftXText:SetText("Shift Dock Left/Right - "..dockshiftx); |
||
614 | AutoBar_Options_Bar_DockShiftX:SetValue(dockshiftx); |
||
615 | AutoBar_Options_Bar_DockShiftYText:SetText("Shift Dock Up/Down - "..dockshifty); |
||
616 | AutoBar_Options_Bar_DockShiftY:SetValue(dockshifty); |
||
617 | |||
618 | AutoBar_SetupVisual(); |
||
619 | end |
||
620 | |||
621 | function AutoBar_Options_CheckBox_Setup() |
||
622 | AutoBar_Options_Bar_DockingMainBarText:SetText("Docked to Main Menu"); |
||
623 | AutoBar_Options_Bar_WidthHeightLockedText:SetText("Lock Button Height\nand Width Together"); |
||
624 | AutoBar_Options_Bar_ReverseButtonsText:SetText("Reverse Buttons"); |
||
625 | AutoBar_Options_Bar_HideKeyTextText:SetText("Hide Keybinding Text"); |
||
626 | AutoBar_Options_Bar_HideCountText:SetText("Hide Count text"); |
||
627 | AutoBar_Options_Bar_ShowEmptyButtonsText:SetText("Show Empty Buttons"); |
||
628 | if (AutoBar_Config[AutoBar_Player].display.docking == "MAINMENU") then |
||
629 | AutoBar_Options_Bar_DockingMainBar:SetChecked(1); |
||
630 | else |
||
631 | AutoBar_Options_Bar_DockingMainBar:SetChecked(0); |
||
632 | end |
||
633 | if (AutoBar_Config[AutoBar_Player].display.unlockbuttonratio) then |
||
634 | AutoBar_Options_Bar_WidthHeightLocked:SetChecked(0); |
||
635 | else |
||
636 | AutoBar_Options_Bar_WidthHeightLocked:SetChecked(1); |
||
637 | end |
||
638 | if (AutoBar_Config[AutoBar_Player].display.reversebuttons) then |
||
639 | AutoBar_Options_Bar_ReverseButtons:SetChecked(1); |
||
640 | else |
||
641 | AutoBar_Options_Bar_ReverseButtons:SetChecked(0); |
||
642 | end |
||
643 | if (AutoBar_Config[AutoBar_Player].display.hidekeytext) then |
||
644 | AutoBar_Options_Bar_HideKeyText:SetChecked(1); |
||
645 | else |
||
646 | AutoBar_Options_Bar_HideKeyText:SetChecked(0); |
||
647 | end |
||
648 | if (AutoBar_Config[AutoBar_Player].display.hidecount) then |
||
649 | AutoBar_Options_Bar_HideCount:SetChecked(1); |
||
650 | else |
||
651 | AutoBar_Options_Bar_HideCount:SetChecked(0); |
||
652 | end |
||
653 | if (AutoBar_Config[AutoBar_Player].display.showemptybuttons) then |
||
654 | AutoBar_Options_Bar_ShowEmptyButtons:SetChecked(1); |
||
655 | else |
||
656 | AutoBar_Options_Bar_ShowEmptyButtons:SetChecked(0); |
||
657 | end |
||
658 | end |
||
659 | |||
660 | function AutoBar_Options_CheckBox_OnCheck() |
||
661 | local button = this:GetName(); |
||
662 | if (this:GetChecked()) then |
||
663 | if (button == "AutoBar_Options_Bar_DockingMainBar") then |
||
664 | AutoBar_Config[AutoBar_Player].display.docking = "MAINMENU"; |
||
665 | elseif (button == "AutoBar_Options_Bar_WidthHeightLocked") then |
||
666 | AutoBar_Config[AutoBar_Player].display.unlockbuttonratio = nil; |
||
667 | elseif (button == "AutoBar_Options_Bar_ReverseButtons") then |
||
668 | AutoBar_Config[AutoBar_Player].display.reversebuttons = 1; |
||
669 | elseif (button == "AutoBar_Options_Bar_HideKeyText") then |
||
670 | AutoBar_Config[AutoBar_Player].display.hidekeytext = 1; |
||
671 | elseif (button == "AutoBar_Options_Bar_HideCount") then |
||
672 | AutoBar_Config[AutoBar_Player].display.hidecount = 1; |
||
673 | elseif (button == "AutoBar_Options_Bar_ShowEmptyButtons") then |
||
674 | AutoBar_Config[AutoBar_Player].display.showemptybuttons = 1; |
||
675 | end |
||
676 | else |
||
677 | if (button == "AutoBar_Options_Bar_DockingMainBar") then |
||
678 | AutoBar_Config[AutoBar_Player].display.docking = nil; |
||
679 | elseif (button == "AutoBar_Options_Bar_WidthHeightLocked") then |
||
680 | AutoBar_Config[AutoBar_Player].display.unlockbuttonratio = 1; |
||
681 | elseif (button == "AutoBar_Options_Bar_ReverseButtons") then |
||
682 | AutoBar_Config[AutoBar_Player].display.reversebuttons = nil; |
||
683 | elseif (button == "AutoBar_Options_Bar_HideKeyText") then |
||
684 | AutoBar_Config[AutoBar_Player].display.hidekeytext = nil; |
||
685 | elseif (button == "AutoBar_Options_Bar_HideCount") then |
||
686 | AutoBar_Config[AutoBar_Player].display.hidecount = nil; |
||
687 | elseif (button == "AutoBar_Options_Bar_ShowEmptyButtons") then |
||
688 | AutoBar_Config[AutoBar_Player].display.showemptybuttons = nil; |
||
689 | end |
||
690 | end |
||
691 | AutoBar_Options_CheckBox_Setup(); |
||
692 | AutoBar_SetupVisual(); |
||
693 | end |
||
694 | |||
695 | function AutoBar_Options_ConfigButton_Option_OnCheck() |
||
696 | local num = AutoBar_Options_ConfigButton.editting; |
||
697 | local buttoninfo = AutoBar_Config[AutoBar_Player].buttons[num]; |
||
698 | local category; |
||
699 | if (type(buttoninfo) == "table") then |
||
700 | category = buttoninfo[this:GetID()]; |
||
701 | else |
||
702 | category = buttoninfo; |
||
703 | end |
||
704 | if (not AutoBar_Config[AutoBar_Player].smartselfcast) then |
||
705 | AutoBar_Config[AutoBar_Player].smartselfcast = {}; |
||
706 | end |
||
707 | AutoBar_Config[AutoBar_Player].smartselfcast[category] = this:GetChecked(); |
||
708 | AutoBar_Config_Button_Edit(); |
||
709 | end |
||
710 | |||
711 | function AutoBar_Options_MoveArrow_OnClick(buttonnum, direction) |
||
712 | local primarybutton = AutoBar_Options_ConfigButton.editting; |
||
713 | local tmp; |
||
714 | if (type(AutoBar_Config[AutoBar_Player].buttons[primarybutton]) == "table") then |
||
715 | if (direction == "UP") then |
||
716 | tmp = AutoBar_Config[AutoBar_Player].buttons[primarybutton][buttonnum-1]; |
||
717 | AutoBar_Config[AutoBar_Player].buttons[primarybutton][buttonnum-1] = |
||
718 | AutoBar_Config[AutoBar_Player].buttons[primarybutton][buttonnum]; |
||
719 | AutoBar_Config[AutoBar_Player].buttons[primarybutton][buttonnum] = tmp; |
||
720 | elseif (direction == "DOWN") then |
||
721 | tmp = AutoBar_Config[AutoBar_Player].buttons[primarybutton][buttonnum+1]; |
||
722 | AutoBar_Config[AutoBar_Player].buttons[primarybutton][buttonnum+1] = |
||
723 | AutoBar_Config[AutoBar_Player].buttons[primarybutton][buttonnum]; |
||
724 | AutoBar_Config[AutoBar_Player].buttons[primarybutton][buttonnum] = tmp; |
||
725 | end |
||
726 | end |
||
727 | AutoBar_Config_Button_Edit(primarybutton); |
||
728 | end |
||
729 | |||
730 | ------------------------------------ |
||
731 | |||
732 | function AutoBar_ToggleConfig() |
||
733 | if (AutoBar_Options:IsVisible()) then |
||
734 | HideUIPanel(AutoBar_Options); |
||
735 | else |
||
736 | ShowUIPanel(AutoBar_Options); |
||
737 | end |
||
738 | end |
||
739 |