vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --SM_VARS.macroTip1 = 1; -- for spell, item
2 --SM_VARS.macroTip2 = 1; -- for macro code
3  
4 oldActionButton_SetTooltip=ActionButton_SetTooltip;
5 function ActionButton_SetTooltip()
6 oldActionButton_SetTooltip();
7 SM_ActionButton_SetTooltip();
8 end
9  
10 function SM_ActionButton_SetTooltip()
11 local actionid=ActionButton_GetPagedID(this);
12 local macroname=GetActionText(actionid); --or getglobal(this:GetName().."Name"):GetText();
13 if ( macroname ) then
14 local macro, _, body = GetMacroInfo(GetMacroIndexByName(macroname));
15  
16 -- for supermacros
17 local superfound = SM_ACTION[actionid];
18 if ( superfound ) then
19 macro,_,body=GetSuperMacroInfo(superfound);
20 GameTooltipTextLeft1:SetText(macro);
21 GameTooltip:Show();
22 end
23  
24 if ( SM_VARS.macroTip1==1 ) then
25 local actiontype, spell = SM_GetActionSpell(macro, superfound);
26 if ( actiontype=="spell" ) then
27 local id, book = SM_FindSpell(spell);
28 GameTooltip:SetSpell(id, book);
29 local s, r = GetSpellName(id, book);
30 if ( r ) then
31 GameTooltipTextRight1:SetText("|cff00ffff"..r.."|r");
32 GameTooltipTextRight1:Show();
33 GameTooltip:Show();
34 end
35 return;
36 elseif ( actiontype=="item" ) then
37 local id, book = FindItem(spell);
38 if ( book ) then
39 GameTooltip:SetBagItem(id, book);
40 else
41 GameTooltip:SetInventoryItem( 'player', id);
42 end
43 return;
44 end
45 end
46 if ( SM_VARS.macroTip2 == 1 ) then
47 -- show macro code
48 if ( not GameTooltipTextLeft1:GetText() ) then return; end
49 body = gsub(body, "\n$", "");
50 GameTooltipTextLeft1:SetText( "|cff00ffff"..macro.."|r");
51 GameTooltipTextLeft2:SetText("|cffffffff"..body.."|r");
52 GameTooltipTextLeft2:Show();
53 GameTooltipTextLeft1:SetWidth(284);
54 GameTooltipTextLeft2:SetWidth(284);
55 GameTooltip:SetWidth(300);
56 GameTooltip:SetHeight( GameTooltipTextLeft1:GetHeight() + GameTooltipTextLeft2:GetHeight() + 23);
57 GameTooltipTextLeft2:SetNonSpaceWrap(true);
58 return;
59 end
60 end
61 -- brighten rank text on all tooltips
62 if ( GameTooltipTextRight1:GetText() ) then
63 local t = GameTooltipTextRight1:GetText();
64 GameTooltipTextRight1:SetText("|cff00ffff"..t.."|r");
65 end
66 -- show crit info for Attack
67 if ( GameTooltipTextLeft1:GetText()=="Attack" ) then
68 id, book = FindSpell("Attack","");
69 GameTooltip:SetSpell(id, book);
70 GameTooltip:Show();
71 end
72 end
73  
74 function SM_ActionButton_OnLeave()
75 this.updateTooltip=nil;
76 GameTooltipTextLeft2:SetWidth(100);
77 GameTooltipTextLeft2:SetText("");
78 GameTooltip:Hide();
79 end
80  
81 local oldGetActionCooldown = GetActionCooldown;
82 function GetActionCooldown( actionid )
83 -- start, duration, enable
84 local macro=GetActionText(actionid);
85 if ( macro and SM_VARS.checkCooldown==1 ) then
86 local name, icon, body = GetMacroInfo(GetMacroIndexByName(macro));
87 -- for supermacros
88 local superfound = SM_ACTION[actionid];
89 if ( superfound ) then
90 name,icon,body=GetSuperMacroInfo(superfound);
91 end
92  
93 local macroname, pic;
94 if ( this ) then
95 macroname=getglobal(this:GetName().."Name");
96 if ( macroname ) then
97 macroname:SetText(name);
98 end
99 pic = getglobal(this:GetName().."Icon");
100 if ( pic ) then
101 pic:SetTexture(icon);
102 end
103 end
104  
105 local actiontype, spell, texture = SM_GetActionSpell(name, superfound);
106 if ( actiontype=="spell") then
107 if ( SM_VARS.replaceIcon==1 and texture and pic) then
108 pic:SetTexture(texture);
109 end
110 local id, book = SM_FindSpell(spell);
111 return GetSpellCooldown( id, book);
112 elseif ( actiontype=="item") then
113 if ( SM_VARS.replaceIcon==1 and texture and pic) then
114 pic:SetTexture(texture);
115 end
116 local id, book, texture, count = FindItem(spell);
117 if ( count>1 and macroname ) then
118 macroname:Hide();
119 getglobal(this:GetName().."Count"):SetText(count);
120 elseif ( macroname ) then
121 macroname:Show();
122 getglobal(this:GetName().."Count"):SetText("");
123 end
124 if ( book ) then
125 return GetContainerItemCooldown(id, book);
126 elseif ( id ) then
127 return GetInventoryItemCooldown('player', id);
128 end
129 end
130 end
131 return oldGetActionCooldown( actionid );
132 end
133  
134 function FindFirstSpell( text )
135 if not text then return nil end;
136 local body = text;
137 if (ReplaceAlias and ASFOptions.aliasOn) then
138 -- correct aliases
139 body = ReplaceAlias(body);
140 end
141 local id, book, texture, spell;
142 while ( string.find(body, "CastSpellByName") ) do
143 spell = gsub(body,'^.-CastSpellByName.-%(.-(["\'])(.-)%1.*$','%2');
144 id, book = SM_FindSpell(spell);
145 if ( id ) then
146 texture = GetSpellTexture(id, book);
147 break;
148 end
149 body = gsub(body, "CastSpellByName","",1);
150 end
151 if ( not id and string.find(body,"/cast") ) then
152 spell = gsub(body,"^.*/cast%s*([%w'%(%) ]+)[\n]?%s*.*$","%1");
153 id, book = SM_FindSpell(spell);
154 if ( id and book ) then
155 texture = GetSpellTexture(id, book);
156 end
157 end
158 if ( not id ) then
159 while ( string.find(body, "[%p%s]cast%(") ) do
160 spell = gsub(body,'^.-[%p%s]-cast%(.-(["\'])(.-)%1.*$','%2');
161 id, book = SM_FindSpell(spell);
162 if ( id ) then
163 texture = GetSpellTexture(id, book);
164 break;
165 end
166 body = gsub(body, "[%p%s]cast%(","", 1);
167 end
168 end
169 if ( not id ) then
170 while ( string.find(body, "CastSpell")) do
171 spell = gsub(body,'^.-CastSpell.-%(%s-(.-)%s*%).*$','%1');
172 local _,_,spellid = strfind(spell,"^(%d+).*");
173 if ( spellid ) then
174 local _,_,spellbook=strfind(spell,"^.-"..spellid..",%s*'(%a+)'%s*");
175 id=spellid;
176 book=spellbook or 'spell';
177 texture = GetSpellTexture(id, book);
178 break;
179 end
180 body = gsub(body, "CastSpell","", 1);
181 end
182 end
183 return id, book, texture, spell;
184 end
185  
186 function FindFirstItem( text )
187 if not text then return nil end;
188 local body = text;
189 if (ReplaceAlias and ASFOptions.aliasOn) then
190 -- correct aliases
191 body = ReplaceAlias(body);
192 end
193 local bag, slot, texture, count, item;
194 if ( strfind(body,"UseItemByName") ) then
195 while ( string.find(body, "UseItemByName") ) do
196 item = gsub(body,'^.-UseItemByName.-%(.-(["\'])(.-)%1.*$','%2');
197 bag, slot, texture, count = FindItem(item);
198 if ( bag ) then
199 return bag, slot, texture, count, item;
200 end
201 body = gsub(body, "UseItemByName","", 1);
202 end
203 end
204 if ( strfind(body,"/use") ) then
205 while ( string.find(body, "/use") ) do
206 item = gsub(body,'^.-/use *(.-) *\n.*$','%1');
207 if ( item==body ) then
208 item = gsub(body,'^.-/use *(.-) *$','%1');
209 end
210 bag, slot, texture, count = FindItem(item);
211 if ( bag ) then
212 return bag, slot, texture, count, item;
213 end
214 body = gsub(body, "/use","", 1);
215 end
216 end
217 if ( strfind(body,"use") ) then
218 while ( string.find(body, "use") ) do
219 item = gsub(body,'^.-use.-%(.-(["\'])(.-)%1.*$','%2');
220 bag, slot, texture, count = FindItem(item);
221 if ( bag ) then
222 return bag, slot, texture, count, item;
223 end
224 body = gsub(body, "use","", 1);
225 end
226 end
227 while ( strfind(body, "UseInventoryItem") ) do
228 bag = gsub(body,'^.-UseInventoryItem.-(%d+)%s-%).*$','%1');
229 if ( bag~=body) then
230 texture = GetInventoryItemTexture('player', bag);
231 count = GetInventoryItemCount('player', bag);
232 end
233 if ( texture ) then
234 item=ItemLinkToName( GetInventoryItemLink('player', bag) );
235 return bag, slot, texture, count, item;
236 end
237 body = gsub(body, "UseInventoryItem","", 1);
238 end
239 while ( strfind(body, "UseContainerItem") ) do
240 bag = gsub(body,'^.-UseContainerItem.-(%d+)%s-,%s-(%d+)%s-%).*$','%1');
241 slot = gsub(body,'^.-UseContainerItem.-(%d+)%s-,%s-(%d+)%s-%).*$','%2');
242 if ( bag~=body and slot~=body) then
243 texture, count = GetContainerItemInfo(bag, slot);
244 end
245 if ( bag~=body and slot~=body and texture ) then
246 item=ItemLinkToName( GetContainerItemLink(bag, slot) );
247 return bag, slot, texture, count, item;
248 end
249 body = gsub(body, "UseContainerItem","", 1);
250 end
251 end