vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- hook API functions |
2 | |||
3 | local oldPickupMacro=PickupMacro; |
||
4 | local oldPickupContainerItem=PickupContainerItem; |
||
5 | local oldPickupInventoryItem=PickupInventoryItem; |
||
6 | local oldPickupSpell=PickupSpell; |
||
7 | local oldPickupAction=PickupAction; |
||
8 | local oldPlaceAction=PlaceAction; |
||
9 | local oldUseAction=UseAction; |
||
10 | local oldGetActionText=GetActionText; |
||
11 | local oldGetActionTexture=GetActionTexture; |
||
12 | |||
13 | function PickupMacro(macroid, supername) |
||
14 | if ( supername ) then |
||
15 | SM_CURSOR=supername; |
||
16 | local tempicon=SM_MACRO_ICON[GetSuperMacroInfo(supername,"texture")]; |
||
17 | local macroname, macroicon=GetMacroInfo(1); |
||
18 | macroicon=SM_MACRO_ICON[macroicon]; |
||
19 | EditMacro(1,macroname, tempicon); |
||
20 | oldPickupMacro(1); |
||
21 | EditMacro(1,macroname, macroicon); |
||
22 | else |
||
23 | SM_CURSOR=nil; |
||
24 | oldPickupMacro(macroid); |
||
25 | end |
||
26 | end |
||
27 | |||
28 | function PickupContainerItem(index, slot) |
||
29 | SM_CURSOR=nil; |
||
30 | oldPickupContainerItem(index, slot); |
||
31 | end |
||
32 | |||
33 | function PickupInventoryItem(index) |
||
34 | SM_CURSOR=nil; |
||
35 | oldPickupInventoryItem(index); |
||
36 | end |
||
37 | |||
38 | function PickupSpell(index, book) |
||
39 | SM_CURSOR=nil; |
||
40 | oldPickupSpell(index, book); |
||
41 | end |
||
42 | |||
43 | function PickupAction(id) |
||
44 | if ( SM_ACTION[id] ) then |
||
45 | SM_CURSOR=SM_ACTION[id]; |
||
46 | local tempicon=SM_MACRO_ICON[GetSuperMacroInfo(SM_CURSOR,"texture")]; |
||
47 | local macroname, macroicon=GetMacroInfo(1); |
||
48 | macroicon=SM_MACRO_ICON[macroicon]; |
||
49 | EditMacro(1,macroname, tempicon); |
||
50 | SM_ACTION[id]=nil; |
||
51 | oldPickupAction(id); |
||
52 | EditMacro(1,macroname, macroicon); |
||
53 | else |
||
54 | SM_CURSOR=nil; |
||
55 | SM_ACTION[id]=nil; |
||
56 | oldPickupAction(id); |
||
57 | end |
||
58 | end |
||
59 | |||
60 | |||
61 | function PlaceAction(id) |
||
62 | -- place and pickup super |
||
63 | local cursor; |
||
64 | if ( SM_ACTION[id] ) then |
||
65 | cursor=SM_ACTION[id]; |
||
66 | end |
||
67 | SM_ACTION[id]=SM_CURSOR; |
||
68 | SM_CURSOR=cursor; |
||
69 | oldPlaceAction(id); |
||
70 | end |
||
71 | |||
72 | function UseAction( id, click, selfcast) |
||
73 | lastActionUsed = id; |
||
74 | if ( SuperMacroFrame_SaveMacro and SuperMacroFrame:IsVisible() ) then |
||
75 | SuperMacroFrame_SaveMacro(); |
||
76 | end |
||
77 | if ( SM_ACTION[id] ) then |
||
78 | RunSuperMacro(SM_ACTION[id]); |
||
79 | elseif ( GetActionText(id) ) then |
||
80 | RunMacro(GetActionText(id)); |
||
81 | else |
||
82 | oldUseAction( id, click, selfcast ); |
||
83 | end |
||
84 | end |
||
85 | |||
86 | function GetActionText(id) |
||
87 | if ( SM_ACTION[id] ) then |
||
88 | return SM_ACTION[id]; |
||
89 | else |
||
90 | return oldGetActionText(id); |
||
91 | end |
||
92 | end |
||
93 | |||
94 | function GetActionTexture(id) |
||
95 | if ( SM_ACTION[id] ) then |
||
96 | local texture=GetSuperMacroInfo(SM_ACTION[id], "texture"); |
||
97 | return texture; |
||
98 | else |
||
99 | return oldGetActionTexture(id); |
||
100 | end |
||
101 | end |
||
102 | |||
103 | function SuperMacro_UpdateAction(oldsuper, newsuper) |
||
104 | for k,v in SM_ACTION do |
||
105 | if v==oldsuper then |
||
106 | SM_ACTION[k]=newsuper; |
||
107 | end |
||
108 | end |
||
109 | end |
||
110 | |||
111 | function SetActionSuperMacro(actionid, supername) |
||
112 | if ( supername and actionid > 0 and actionid <= 120 ) then |
||
113 | PickupAction( actionid ); |
||
114 | PickupMacro(1, supername ); |
||
115 | PlaceAction ( actionid ); |
||
116 | end |
||
117 | end |
||
118 | |||
119 | function SM_ActionButton_OnClick() |
||
120 | if ( SM_CURSOR ) then |
||
121 | PlaceAction(ActionButton_GetPagedID(this)); |
||
122 | ActionButton_UpdateState(); |
||
123 | return 1; |
||
124 | end |
||
125 | end |