vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | NUM_SLOTS = 120; |
2 | |||
3 | ------------------------------------------------------------------------------- |
||
4 | -- tab management code, credits to guim author |
||
5 | ------------------------------------------------------------------------------- |
||
6 | |||
7 | SA_SUBFRAMES = { "SABasicOptionsFrame", "SAListOptionsFrame", "SAAdvancedOptionsFrame", "SmartActionsOptionsFrame" }; |
||
8 | |||
9 | function SA_ToggleDialog(tab) |
||
10 | local subFrame = getglobal(tab); |
||
11 | if ( subFrame ) then |
||
12 | PanelTemplates_SetTab(SAOptionsFrame, subFrame:GetID()); |
||
13 | if ( SAOptionsFrame:IsVisible() ) then |
||
14 | PlaySound("igCharacterInfoTab"); |
||
15 | else |
||
16 | ShowUIPanel(SAOptionsFrame); |
||
17 | end |
||
18 | SA_ShowSubFrame(tab); |
||
19 | end |
||
20 | end |
||
21 | |||
22 | function SA_ShowSubFrame(frameName) |
||
23 | for index, value in SA_SUBFRAMES do |
||
24 | if ( value == frameName ) then |
||
25 | getglobal(value):Show(); |
||
26 | else |
||
27 | getglobal(value):Hide(); |
||
28 | end |
||
29 | end |
||
30 | end |
||
31 | |||
32 | function SA_Tab_OnClick() |
||
33 | local id = this:GetID(); |
||
34 | local tab = SA_SUBFRAMES[id]; |
||
35 | local subFrame = getglobal(tab); |
||
36 | PanelTemplates_SetTab(SAOptionsFrame, id); |
||
37 | SA_ShowSubFrame(tab); |
||
38 | PlaySound("igCharacterInfoTab"); |
||
39 | end |
||
40 | |||
41 | ------------------------------------------------------------------------------- |
||
42 | -- spell & action drag hookups |
||
43 | ------------------------------------------------------------------------------- |
||
44 | |||
45 | local SA_DRAGSPELL = nil; |
||
46 | local SA_DRAGSLOT = nil; |
||
47 | local SA_DRAGNAME = nil; |
||
48 | |||
49 | function SA_ClearDragData() |
||
50 | SA_DRAGSPELL = nil; |
||
51 | SA_DRAGSLOT = nil; |
||
52 | SA_DRAGNAME = nil; |
||
53 | end |
||
54 | |||
55 | -- hook to spellbook pickup routine |
||
56 | local SA_BasePickupSpell = PickupSpell; |
||
57 | function PickupSpell(id, bookType) |
||
58 | SA_ClearDragData(); |
||
59 | local result = SA_BasePickupSpell(id, bookType); |
||
60 | --SA_Debug("picked up spell id="..id.." bookType="..bookType); |
||
61 | if (CursorHasSpell()) then |
||
62 | local name, rank = GetSpellName(id, bookType); |
||
63 | local texture = GetSpellTexture(id, bookType); |
||
64 | SA_DRAGSPELL = {}; |
||
65 | SA_DRAGSPELL.Id = id; |
||
66 | SA_DRAGSPELL.Texture = texture; |
||
67 | SA_DRAGSPELL.Name = name; |
||
68 | SA_DRAGSPELL.BookType = bookType; |
||
69 | SA_DRAGNAME = name; |
||
70 | end |
||
71 | return result; |
||
72 | end |
||
73 | |||
74 | local SA_BasePickupAction = PickupAction; |
||
75 | function PickupAction(slot) |
||
76 | SA_ClearDragData(); |
||
77 | SA_Debug("picked up spell from slot "..slot); |
||
78 | -- set drag slot |
||
79 | SA_DRAGSLOT = slot; |
||
80 | SA_DRAGNAME = SA_GetSlotName(slot); |
||
81 | SA_Debug("SA_DRAGNAME="..tostring(SA_DRAGNAME)); |
||
82 | return SA_BasePickupAction(slot); |
||
83 | end |
||
84 | |||
85 | ------------------------------------------------------------------------------- |
||
86 | -- smart assist configuration dialog |
||
87 | ------------------------------------------------------------------------------- |
||
88 | |||
89 | function SA_Options_Init() |
||
90 | end |
||
91 | |||
92 | function SA_Options_OnHide() |
||
93 | end |
||
94 | |||
95 | function SA_Options_OnLoad() |
||
96 | tinsert(UISpecialFrames, "SAOptionsFrame"); |
||
97 | -- Tab Handling code |
||
98 | PanelTemplates_SetNumTabs(this, 4); |
||
99 | PanelTemplates_SetTab(this, 1); |
||
100 | end |
||
101 | |||
102 | -- todo: this update is not anymore good since we have divided optiosn across several tabs ... |
||
103 | function SA_Options_OnShow() |
||
104 | SAPriorizeHealthCB:SetChecked(SA_OPTIONS.PriorizeHealth); |
||
105 | SAAssistOnEmoteCB:SetChecked(SA_OPTIONS.AssistOnEmote); |
||
106 | SAVisualWarningCB:SetChecked(SA_OPTIONS.VisualWarning); |
||
107 | SAFallbackTargetNearestCB:SetChecked(SA_OPTIONS.FallbackTargetNearest); |
||
108 | SACheckNearestCB:SetChecked(SA_OPTIONS.CheckNearest); |
||
109 | SANearestMustBePvPCB:SetChecked(SA_OPTIONS.NearestMustBePvP); |
||
110 | SANearestMustBeTargetingCB:SetChecked(SA_OPTIONS.NearestMustBeTargetting); |
||
111 | SAAutoAssistCB:SetChecked(SA_OPTIONS.AutoAssist); |
||
112 | |||
113 | SAAutoPetAttackCB:SetChecked(SA_OPTIONS.AutoPetAttack); |
||
114 | SAAutoPetAttackBusyCB:SetChecked(SA_OPTIONS.AutoPetAttackBusy); |
||
115 | |||
116 | SA_Options_UpdatePullerText(); |
||
117 | |||
118 | if (SA_OPTIONS.AutoAssistTexture) then |
||
119 | SAAssistText:SetText(SA_OPTIONS.AutoAssistName); |
||
120 | SA_Debug("setting button texture to="..SA_OPTIONS.AutoAssistTexture); |
||
121 | SetItemButtonTexture(SAAssistWithSlot, SA_OPTIONS.AutoAssistTexture); |
||
122 | end |
||
123 | SA_Options_UpdateClassOrder(); |
||
124 | |||
125 | -- set health slider value & update text |
||
126 | SAHealthSlider:SetValue(SA_OPTIONS.PriorizeHealthValue); |
||
127 | SA_Options_UpdateHealthSlider(); |
||
128 | end |
||
129 | |||
130 | ------------------------------------------------------------------------------- |
||
131 | -- Update list options tab |
||
132 | ------------------------------------------------------------------------------- |
||
133 | |||
134 | function SA_Options_VariablesLoaded() |
||
135 | SA_Options_AddIconPositions("SAClassIconMode"); |
||
136 | SA_Options_AddIconPositions("SATargetIconMode"); |
||
137 | SA_Options_AddIconPositions("SAHuntersMarkIconMode"); |
||
138 | end |
||
139 | |||
140 | function SA_Options_AddIconPositions(name) |
||
141 | local c = getglobal(name); |
||
142 | for i=1, table.getn(SA_ICONPOS) do |
||
143 | Selection_AddSelection(c, i, SA_ICONPOS[i].name); |
||
144 | end |
||
145 | end |
||
146 | |||
147 | function SA_Options_OnShowListOptions() |
||
148 | SAAudioWarningCB:SetChecked(SA_OPTIONS.AudioWarning); |
||
149 | SALostAudioWarningCB:SetChecked(SA_OPTIONS.LostAudioWarning); |
||
150 | |||
151 | SAVerboseAcquiredAggroCB:SetChecked(SA_OPTIONS.VerboseAcquiredAggro); |
||
152 | SAVerboseLostAggroCB:SetChecked(SA_OPTIONS.VerboseLostAggro); |
||
153 | |||
154 | SAShowAvailableCB:SetChecked(SA_OPTIONS.ShowAvailable); |
||
155 | SAPreservedOrderCB:SetChecked(SA_OPTIONS.PreservedOrder); |
||
156 | SATankModeCB:SetChecked(SA_OPTIONS.TankMode); |
||
157 | SAAddMyTargetCB:SetChecked(SA_OPTIONS.AddMyTarget); |
||
158 | SAOutOfCombatCB:SetChecked(SA_OPTIONS.OutOfCombat); |
||
159 | SAHideTBYCB:SetChecked(SA_OPTIONS.HideTBY); |
||
160 | SAHideTitleCB:SetChecked(SA_OPTIONS.HideTitle); |
||
161 | |||
162 | SAListWidthSlider:SetValue(SA_OPTIONS.ListWidth); |
||
163 | SAListScaleSlider:SetValue(SA_OPTIONS.ListScale); |
||
164 | |||
165 | SAListSpacingSlider:SetValue(SA_OPTIONS.ListSpacing); |
||
166 | SAListHorizontalCB:SetChecked(SA_OPTIONS.ListHorizontal); |
||
167 | SAListTwoRowCB:SetChecked(SA_OPTIONS.ListTwoRow); |
||
168 | |||
169 | SA_Options_UpdateListWidthSlider(); |
||
170 | SA_Options_UpdateListSpacingSlider(); |
||
171 | |||
172 | Selection_SetSelectedValue(SAClassIconMode, SA_OPTIONS.ClassIconMode); |
||
173 | Selection_SetSelectedValue(SATargetIconMode, SA_OPTIONS.TargetIconMode); |
||
174 | Selection_SetSelectedValue(SAHuntersMarkIconMode, SA_OPTIONS.HuntersMarkIconMode); |
||
175 | |||
176 | SA_Options_DisplayList(true); |
||
177 | end |
||
178 | |||
179 | function SA_Options_OnHideListOptions() |
||
180 | SA_Options_DisplayList(false); |
||
181 | end |
||
182 | |||
183 | function SA_Options_DisplayList(display) |
||
184 | if (display) then |
||
185 | SA_List_SetTitleButton(MODE_NORMAL); |
||
186 | else |
||
187 | SA_List_SetTitleButton(MODE_OOC); |
||
188 | end |
||
189 | for i=1, 10 do |
||
190 | local box = getglobal("Target"..i); |
||
191 | if (display) then |
||
192 | box:Show(); |
||
193 | else |
||
194 | box:Hide(); |
||
195 | end; |
||
196 | end |
||
197 | end |
||
198 | |||
199 | function SA_Options_UpdateListWidthSlider() |
||
200 | SA_OPTIONS.ListWidth = SAListWidthSlider:GetValue(); |
||
201 | SA_List_UpdateAppearance(); |
||
202 | end |
||
203 | |||
204 | function SA_Options_UpdateListScaleSlider() |
||
205 | SA_OPTIONS.ListScale = SAListScaleSlider:GetValue(); |
||
206 | SAListFrameScaler:SetScale(SA_OPTIONS.ListScale); |
||
207 | local s = string.sub(tostring(SA_OPTIONS.ListScale),0,4); |
||
208 | SAListScaleSliderText:SetText("list scale "..s); |
||
209 | end |
||
210 | |||
211 | function SA_Options_UpdateListSpacingSlider() |
||
212 | SA_OPTIONS.ListSpacing = SAListSpacingSlider:GetValue(); |
||
213 | SA_List_UpdateAppearance(); |
||
214 | end |
||
215 | |||
216 | function SA_Options_UpdateListSpacingSliderText() |
||
217 | if (SA_OPTIONS.ListHorizontal) then |
||
218 | SAListSpacingSliderHigh:SetText("right"); |
||
219 | SAListSpacingSliderLow:SetText("left"); |
||
220 | else |
||
221 | SAListSpacingSliderHigh:SetText("up"); |
||
222 | SAListSpacingSliderLow:SetText("down"); |
||
223 | end |
||
224 | end |
||
225 | |||
226 | -- callback from SmartSelection |
||
227 | function SA_Options_ClassIcon(value) |
||
228 | SA_OPTIONS["ClassIconMode"] = value; |
||
229 | SA_List_UpdateAppearance(); |
||
230 | end |
||
231 | |||
232 | -- callback from SmartSelection |
||
233 | function SA_Options_TargetIcon(value) |
||
234 | SA_OPTIONS["TargetIconMode"] = value; |
||
235 | SA_List_UpdateAppearance(); |
||
236 | end |
||
237 | |||
238 | function SA_Options_HuntersMarkIcon(value) |
||
239 | SA_OPTIONS["HuntersMarkIconMode"] = value; |
||
240 | SA_List_UpdateAppearance(); |
||
241 | end |
||
242 | |||
243 | ------------------------------------------------------------------------------- |
||
244 | -- Update advanced options tab |
||
245 | ------------------------------------------------------------------------------- |
||
246 | |||
247 | function SA_Options_OnShowAdvanced() |
||
248 | |||
249 | -- update the dropdown Select Modifier |
||
250 | UIDropDownMenu_SetSelectedID(SASelectModifierDD, SA_OPTIONS.AssistKeyMode); |
||
251 | SASelectModifierDDText:SetText(SELECT_MODIFIER_TEXTS[SA_OPTIONS.AssistKeyMode]); |
||
252 | if (SA_OPTIONS.AssistKeyMode == 4) then |
||
253 | SASelectModifierDDInfo:SetText("selecting does not assist"); |
||
254 | else |
||
255 | SASelectModifierDDInfo:SetText("assists player"); |
||
256 | end |
||
257 | -- update the dropdown Assist Modifier |
||
258 | UIDropDownMenu_SetSelectedID(SAAssistModifierDD, SA_OPTIONS.DisableAutoCastKeyMode); |
||
259 | SAAssistModifierDDText:SetText(ASSIST_MODIFIER_TEXTS[SA_OPTIONS.DisableAutoCastKeyMode]); |
||
260 | |||
261 | -- set disable slider value & update text |
||
262 | SADisableSlider:SetValue(SA_OPTIONS.DisableSliderValue); |
||
263 | SA_Options_UpdateDisableSlider(); |
||
264 | |||
265 | SAPauseResetsOrderCB:SetChecked(SA_OPTIONS.PauseResetsOrder); |
||
266 | SADisableTargetNearestCB:SetChecked(SA_OPTIONS.DisableTargetNearest); |
||
267 | SADisablePriorityHealthCB:SetChecked(SA_OPTIONS.DisablePriorityHealth); |
||
268 | |||
269 | SAVerboseAssistCB:SetChecked(SA_OPTIONS.VerboseAssist); |
||
270 | SAVerboseIncomingCB:SetChecked(SA_OPTIONS.VerboseIncoming); |
||
271 | SAVerboseNearestCB:SetChecked(SA_OPTIONS.VerboseNearest); |
||
272 | SAVerboseUnableToAssistCB:SetChecked(SA_OPTIONS.VerboseUnableToAssist); |
||
273 | |||
274 | SADisableAssistWithoutPullerCB:SetChecked(SA_OPTIONS.DisableAssistWithoutPuller); |
||
275 | end |
||
276 | |||
277 | function SA_Options_UpdatePullerText() |
||
278 | local candidates,_ = SA_GetCandidates(); |
||
279 | --SA_RefreshPuller(candidates); -- causes infinite loop and stack overflow because this method is called from refresh path also! |
||
280 | if (SA_OPTIONS["puller"]==nil) then |
||
281 | SACurrentPuller:SetText("Puller: none / pet when available"); |
||
282 | else |
||
283 | SACurrentPuller:SetText("Puller: "..SA_OPTIONS["puller"]); |
||
284 | end |
||
285 | end |
||
286 | |||
287 | ---------------------------------------------------------------------------------- |
||
288 | -- displays list of all available members in order of current assist configuration |
||
289 | ---------------------------------------------------------------------------------- |
||
290 | |||
291 | function SA_PullerText_OnEnter(arg) |
||
292 | local text = "Current assist order:\n\n"; |
||
293 | local candidates, members = SA_GetCandidates(false); |
||
294 | if (members > 0) then |
||
295 | table.sort(candidates, function(a,b) return SA_SortCandidate(a,b,members) end); |
||
296 | for _,candidate in candidates do |
||
297 | -- colorize text by class |
||
298 | local cv = RAID_CLASS_COLORS[string.upper(candidate["class"])]; |
||
299 | local color = ""; |
||
300 | if (not cv) then |
||
301 | color = "|cff888888"; |
||
302 | else |
||
303 | color = SA_ToTextCol(cv.r, cv.g, cv.b); |
||
304 | end |
||
305 | text = text .. color..candidate.unitName .. "|r" .. "\n"; |
||
306 | end |
||
307 | else |
||
308 | text = text .. "- no members"; |
||
309 | end |
||
310 | GameTooltip:SetOwner(arg, "ANCHOR_LEFT"); |
||
311 | GameTooltip:SetText(text,1,1,1,1,1); |
||
312 | end |
||
313 | |||
314 | function SA_PullerText_OnLeave(arg) |
||
315 | GameTooltip:Hide(); |
||
316 | end |
||
317 | |||
318 | ------------------------------------------------------------------------------- |
||
319 | -- togle a boolean option, play a tick sound |
||
320 | ------------------------------------------------------------------------------- |
||
321 | |||
322 | function SA_ToggleOption(option) |
||
323 | if (SA_OPTIONS[option]==nil or SA_OPTIONS[option]==false) then |
||
324 | SA_OPTIONS[option] = true; |
||
325 | PlaySound("igMainMenuOptionCheckBoxOff"); |
||
326 | else |
||
327 | SA_OPTIONS[option] = false; |
||
328 | PlaySound("igMainMenuOptionCheckBoxOn"); |
||
329 | end |
||
330 | end |
||
331 | |||
332 | function SA_ToggleAvailable() |
||
333 | SA_ToggleOption("ShowAvailable"); |
||
334 | if (SA_OPTIONS.ShowAvailable) then |
||
335 | printInfo("Enabling available assist list and related features"); |
||
336 | SAListFrame:Show(); |
||
337 | else |
||
338 | printInfo("Disabling available assist list and related features"); |
||
339 | SAListFrame:Hide(); |
||
340 | end |
||
341 | SA_Options_OnShow(); |
||
342 | end |
||
343 | |||
344 | ------------------------------------------------------------------------------- |
||
345 | -- auto cast on assist slot |
||
346 | ------------------------------------------------------------------------------- |
||
347 | |||
348 | function SA_SpellSlot_OnReceiveDrag() |
||
349 | SA_Debug("Received drag"); |
||
350 | |||
351 | -- enable whining again, incase user has Auto Attack enabled which will screw the cast |
||
352 | SA_OPTIONS.AutoAttackWhineIgnored = false; |
||
353 | |||
354 | if (CursorHasSpell() and not SA_DRAGSLOT) then |
||
355 | SA_OPTIONS.AutoAssist = true; |
||
356 | SA_OPTIONS.AutoAssistTexture = SA_DRAGSPELL.Texture; |
||
357 | SA_OPTIONS.AutoAssistName = SA_DRAGSPELL.Name; |
||
358 | |||
359 | -- drop icon |
||
360 | PickupSpell(SA_DRAGSPELL.Id, SA_DRAGSPELL.BookType); |
||
361 | |||
362 | -- update the config window |
||
363 | SA_Options_OnShow(); |
||
364 | else |
||
365 | SpellBookFrame:Show(); |
||
366 | end |
||
367 | end |
||
368 | |||
369 | ------------------------------------------------------------------------------- |
||
370 | -- updates classorder view |
||
371 | ------------------------------------------------------------------------------- |
||
372 | |||
373 | function SA_Options_UpdateClassOrder() |
||
374 | for k,v in SA_OPTIONS.ClassOrder do |
||
375 | getglobal("ClassOrderFrameClass" .. k .. "Text"):SetText(v); |
||
376 | end |
||
377 | end |
||
378 | |||
379 | ------------------------------------------------------------------------------- |
||
380 | -- update disable target |
||
381 | ------------------------------------------------------------------------------- |
||
382 | |||
383 | function SA_Options_UpdateDisableSlider() |
||
384 | SA_OPTIONS.DisableSliderValue = SADisableSlider:GetValue(); |
||
385 | SADisableSliderText:SetText("members > "..SA_OPTIONS.DisableSliderValue); |
||
386 | end |
||
387 | |||
388 | ------------------------------------------------------------------------------- |
||
389 | -- updates health slider TEXT (not value) |
||
390 | ------------------------------------------------------------------------------- |
||
391 | |||
392 | function SA_Options_UpdateHealthSlider() |
||
393 | SA_OPTIONS.PriorizeHealthValue = SAHealthSlider:GetValue(); |
||
394 | SAHealthSliderText:SetText("Priority health ("..SA_OPTIONS.PriorizeHealthValue.." %)"); |
||
395 | end |
||
396 | |||
397 | ------------------------------------------------------------------------------- |
||
398 | -- class order routines |
||
399 | ------------------------------------------------------------------------------- |
||
400 | |||
401 | function SA_ClassOrderMove(move) |
||
402 | local text = getglobal(this:GetParent():GetName() .. "Text"):GetText() |
||
403 | -- where is our text in table, also check for boundaries |
||
404 | local index = SA_TableIndex(SA_OPTIONS.ClassOrder, text); |
||
405 | -- move the element in our list |
||
406 | local moving = SA_OPTIONS.ClassOrder[index]; |
||
407 | table.remove(SA_OPTIONS.ClassOrder, index); |
||
408 | table.insert(SA_OPTIONS.ClassOrder, index+move, moving); |
||
409 | SA_Options_UpdateClassOrder(); |
||
410 | end |
||
411 | |||
412 | ------------------------------------------------------------------------------- |
||
413 | -- initialize dropdown (thanks to atlas) |
||
414 | ------------------------------------------------------------------------------- |
||
415 | |||
416 | SELECT_MODIFIER_TEXTS = {"Shift - select", "Ctrl - select", "Alt - select", "Disabled" }; |
||
417 | function SASelectModifierDD_Initialize() |
||
418 | local info; |
||
419 | for _,value in SELECT_MODIFIER_TEXTS do |
||
420 | info = { |
||
421 | text = value; |
||
422 | func = SASelectModifierDDButton_OnClick; |
||
423 | }; |
||
424 | UIDropDownMenu_AddButton(info); |
||
425 | end |
||
426 | end |
||
427 | |||
428 | function SASelectModifierDD_OnLoad() |
||
429 | UIDropDownMenu_Initialize(SASelectModifierDD, SASelectModifierDD_Initialize); |
||
430 | UIDropDownMenu_SetSelectedID(SASelectModifierDD, 1); |
||
431 | UIDropDownMenu_SetWidth(90); |
||
432 | end |
||
433 | |||
434 | function SASelectModifierDDButton_OnClick() |
||
435 | local oldID = UIDropDownMenu_GetSelectedID(SASelectModifierDD); |
||
436 | if(oldID ~= this:GetID()) then |
||
437 | SA_OPTIONS["AssistKeyMode"]=this:GetID() |
||
438 | SA_Options_OnShowAdvanced(); |
||
439 | end |
||
440 | end |
||
441 | |||
442 | ------------------------------------------------------------------------------- |
||
443 | |||
444 | ASSIST_MODIFIER_TEXTS = {"Shift", "Ctrl ", "Alt", "None" }; |
||
445 | function SAAssistModifierDD_Initialize() |
||
446 | local info; |
||
447 | for _,value in ASSIST_MODIFIER_TEXTS do |
||
448 | info = { |
||
449 | text = value; |
||
450 | func = SAAssistModifierDDButton_OnClick; |
||
451 | }; |
||
452 | UIDropDownMenu_AddButton(info); |
||
453 | end |
||
454 | end |
||
455 | |||
456 | function SAAssistModifierDD_OnLoad() |
||
457 | UIDropDownMenu_Initialize(SAAssistModifierDD, SAAssistModifierDD_Initialize); |
||
458 | UIDropDownMenu_SetSelectedID(SAAssistModifierDD, 1); |
||
459 | UIDropDownMenu_SetWidth(90); |
||
460 | end |
||
461 | |||
462 | function SAAssistModifierDDButton_OnClick() |
||
463 | local oldID = UIDropDownMenu_GetSelectedID(SAAssistModifierDD); |
||
464 | if(oldID ~= this:GetID()) then |
||
465 | SA_OPTIONS["DisableAutoCastKeyMode"]=this:GetID() |
||
466 | SA_Options_OnShowAdvanced(); |
||
467 | end |
||
468 | end |
||
469 | |||
470 | ------------------------------------------------------------------------------- |
||
471 | -- smart spell configuration methods |
||
472 | ------------------------------------------------------------------------------- |
||
473 | |||
474 | function SA_Options_SmartActions_OnShow() |
||
475 | SATriggerAssistCB:SetChecked(SA_OPTIONS.TriggerAssist); |
||
476 | SA_RefreshSlots(); |
||
477 | end |
||
478 | |||
479 | function SA_RefreshSlots() |
||
480 | |||
481 | local i = 0; |
||
482 | for _,spell in SA_OPTIONS.AssistSpells do |
||
483 | i = i + 1; |
||
484 | local slot = getglobal("SAAssistSlot"..i); |
||
485 | local texture = SA_GetTextureForSpell(spell); |
||
486 | if (texture) then |
||
487 | SetItemButtonTexture(slot, texture); |
||
488 | else |
||
489 | SA_Debug("unknown texture for spell "..tostring(spell)); |
||
490 | SetItemButtonTexture(slot, "Interface\\Icons\\INV_Misc_QuestionMark"); |
||
491 | end |
||
492 | end |
||
493 | |||
494 | -- clear old textures |
||
495 | for c = i+1, 20 do |
||
496 | local slot = getglobal("SAAssistSlot"..c); |
||
497 | SetItemButtonTexture(slot, nil); |
||
498 | end |
||
499 | |||
500 | end |
||
501 | |||
502 | function SA_SmartActionSlot_OnEnter(arg) |
||
503 | if (SA_DRAGSLOT or SA_DRAGSPELL) then return; end; |
||
504 | local text = SA_OPTIONS.AssistSpells[this:GetID()]; |
||
505 | if (text) then |
||
506 | GameTooltip:SetOwner(arg, "ANCHOR_RIGHT"); |
||
507 | GameTooltip:SetText(text,1,1,1,1,1); |
||
508 | end |
||
509 | end |
||
510 | |||
511 | function SA_SmartActionSlot_OnClick() |
||
512 | if (CursorHasSpell()) then |
||
513 | printInfo("This is drag instead of click!"); |
||
514 | SA_SmartActionSlot_OnReceiveDrag(); |
||
515 | return; |
||
516 | end |
||
517 | |||
518 | -- remove selected spell & update table element id's (why doesn't lua do this =P) |
||
519 | if (SA_OPTIONS.AssistSpells[this:GetID()]) then |
||
520 | table.remove(SA_OPTIONS.AssistSpells, this:GetID()); |
||
521 | local temp = {}; |
||
522 | for _,v in SA_OPTIONS.AssistSpells do |
||
523 | table.insert(temp, v); |
||
524 | end |
||
525 | SA_OPTIONS.AssistSpells = temp; |
||
526 | end |
||
527 | |||
528 | SA_Options_SmartActions_OnShow(); |
||
529 | end |
||
530 | |||
531 | function SA_SmartActionSlot_OnReceiveDrag() |
||
532 | -- get spell name and release drag, Todo: separate to function? |
||
533 | local spell = SA_DRAGNAME; |
||
534 | if (SA_DRAGSLOT) then |
||
535 | PickupAction(SA_DRAGSLOT); |
||
536 | elseif (SA_DRAGSPELL) then |
||
537 | PickupSpell(SA_DRAGSPELL.Id, SA_DRAGSPELL.BookType); |
||
538 | else |
||
539 | printInfo("bug #5933"); |
||
540 | end |
||
541 | SA_ClearDragData(); |
||
542 | |||
543 | if (not spell) then |
||
544 | printInfo("Problem: Unable to get spell name"); |
||
545 | return; |
||
546 | end |
||
547 | |||
548 | if (SA_TableIndex(SA_OPTIONS.AssistSpells, spell) ~= -1) then |
||
549 | printInfo("Spell already exists in list"); |
||
550 | return; |
||
551 | end |
||
552 | |||
553 | SA_Debug("Adding spell "..tostring(spell)); |
||
554 | table.insert(SA_OPTIONS.AssistSpells, spell); |
||
555 | |||
556 | -- refresh the view |
||
557 | SA_Options_SmartActions_OnShow() |
||
558 | end |
||
559 | |||
560 | ------------------------------------------------------------------------------- |
||
561 | -- reset all smartactions |
||
562 | ------------------------------------------------------------------------------- |
||
563 | |||
564 | function SA_ResetSmartActions() |
||
565 | SA_OPTIONS.AssistSpells = {}; |
||
566 | -- refresh the view |
||
567 | SA_Options_SmartActions_OnShow() |
||
568 | end |
||
569 | |||
570 | ------------------------------------------------------------------------------- |
||
571 | -- try to autoconfigure smart actions |
||
572 | ------------------------------------------------------------------------------- |
||
573 | |||
574 | function SA_AutoConfigureSmartActions() |
||
575 | local found = 0; |
||
576 | for slot = 1, NUM_SLOTS do |
||
577 | local spell = SA_GetSlotName(slot); |
||
578 | if (spell) then |
||
579 | if (AUTOCONF_ATTACKS[spell]) then |
||
580 | if (SA_TableIndex(SA_OPTIONS.AssistSpells, spell) == -1) then |
||
581 | SA_Debug("found attack "..spell); |
||
582 | table.insert(SA_OPTIONS.AssistSpells, spell); |
||
583 | found = found + 1; |
||
584 | end |
||
585 | end |
||
586 | end |
||
587 | end |
||
588 | if (found>0) then |
||
589 | printInfo("Auto configured "..found.." actions."); |
||
590 | else |
||
591 | printInfo("Auto configure was unable to find any actions. This is most likelly because your class does not (yet) have predefined set of spells or you are using non-english client."); |
||
592 | end |
||
593 | |||
594 | -- refresh the view |
||
595 | SA_Options_SmartActions_OnShow(); |
||
596 | end |
||
597 | |||
598 | ------------------------------------------------------------------------------- |
||
599 | -- slot & spell utilities |
||
600 | ------------------------------------------------------------------------------- |
||
601 | |||
602 | function SA_GetTextureForSpell(name) |
||
603 | local id = SA_FindSlotByName(name); |
||
604 | if (id==nil) then return nil; end; |
||
605 | return GetActionTexture(id); |
||
606 | end |
||
607 | |||
608 | function SA_FindSlotByName(name) |
||
609 | local textName; |
||
610 | for slot = 1, NUM_SLOTS do |
||
611 | slotName = SA_GetSlotName(slot); |
||
612 | if (slotName == name) then |
||
613 | return slot; |
||
614 | end |
||
615 | end |
||
616 | return nil; |
||
617 | end |
||
618 | |||
619 | function SA_GetSlotName(slot) |
||
620 | SAActionTip:SetAction(slot); |
||
621 | return SAActionTipTextLeft1:GetText(); |
||
622 | end |