vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 TITAN_ITEMBONUSES_ID = "ItemBonuses";
2  
3 TitanItemBonuses_colors = {
4 X = 'FFD200', -- attributes
5 Y = '20FF20', -- skills
6 M = 'FFFFFF', -- melee
7 R = '00C0C0', -- ranged
8 C = 'FFFF00', -- spells
9 A = 'FF60FF', -- arcane
10 I = 'FF3600', -- fire
11 F = '00C0FF', -- frost
12 H = 'FFA400', -- holy
13 N = '00FF60', -- nature
14 S = 'AA12AC', -- shadow
15 L = '20FF20', -- life
16 P = '6060FF', -- mana
17 };
18  
19 TITAN_ITEMBONUSES_EFFECTS = {
20 { effect = "STR", format = "+%d", short = "XSTR", cat = "ATT" },
21 { effect = "AGI", format = "+%d", short = "XAGI", cat = "ATT" },
22 { effect = "STA", format = "+%d", short = "XSTA", cat = "ATT" },
23 { effect = "INT", format = "+%d", short = "XINT", cat = "ATT" },
24 { effect = "SPI", format = "+%d", short = "XSPI", cat = "ATT" },
25 { effect = "ARMOR", format = "+%d", short = "XARM", cat = "ATT" },
26  
27 { effect = "ARCANERES", format = "+%d", short = "AR", cat = "RES" },
28 { effect = "FIRERES", format = "+%d", short = "IR", cat = "RES" },
29 { effect = "NATURERES", format = "+%d", short = "NR", cat = "RES" },
30 { effect = "FROSTRES", format = "+%d", short = "FR", cat = "RES" },
31 { effect = "SHADOWRES", format = "+%d", short = "SR", cat = "RES" },
32  
33 { effect = "DEFENSE", format = "+%d", short = "YDEF", cat = "SKILL" },
34 { effect = "MINING", format = "+%d", short = "YMIN", cat = "SKILL" },
35 { effect = "HERBALISM", format = "+%d", short = "YHER", cat = "SKILL" },
36 { effect = "SKINNING", format = "+%d", short = "YSKI", cat = "SKILL" },
37 { effect = "FISHING", format = "+%d", short = "YFIS", cat = "SKILL" },
38  
39 { effect = "ATTACKPOWER", format = "+%d", short = "MA", cat = "BON" },
40 { effect = "CRIT", format = "+%d%%", short = "MC", cat = "BON" },
41 { effect = "BLOCK", format = "+%d%%", short = "MB", cat = "BON" },
42 { effect = "DODGE", format = "+%d%%", short = "MD", cat = "BON" },
43 { effect = "PARRY", format = "+%d%%", short = "MP", cat = "BON" },
44 { effect = "TOHIT", format = "+%d%%", short = "MH", cat = "BON" },
45 { effect = "RANGEDATTACKPOWER", format = "+%d", short = "RA", cat = "BON" },
46 { effect = "RANGEDCRIT", format = "+%d%%", short = "RC", cat = "BON" },
47  
48 { effect = "DMG", format = "+%d", short = "CD", cat = "SBON" },
49 { effect = "HEAL", format = "+%d", short = "CH", cat = "SBON"},
50 { effect = "HOLYCRIT", format = "+%d%%", short = "CHC", cat = "SBON" },
51 { effect = "SPELLCRIT", format = "+%d%%", short = "CSC", cat = "SBON" },
52 { effect = "SPELLTOHIT", format = "+%d%%", short = "CSH", cat = "SBON" },
53 { effect = "ARCANEDMG", format = "+%d", short = "AD", cat = "SBON" },
54 { effect = "FIREDMG", format = "+%d", short = "ID", cat = "SBON" },
55 { effect = "FROSTDMG", format = "+%d", short = "FD", cat = "SBON" },
56 { effect = "HOLYDMG", format = "+%d", short = "HD", cat = "SBON" },
57 { effect = "NATUREDMG", format = "+%d", short = "ND", cat = "SBON" },
58 { effect = "SHADOWDMG", format = "+%d", short = "SD", cat = "SBON" },
59  
60 { effect = "HEALTH", format = "+%d", short = "LP", cat = "OBON" },
61 { effect = "HEALTHREG", format = "%d HP/5s",short = "LR", cat = "OBON" },
62 { effect = "MANA", format = "+%d", short = "PP", cat = "OBON" },
63 { effect = "MANAREG", format = "%d MP/5s",short = "PR", cat = "OBON" },
64 };
65  
66 TITAN_ITEMBONUSES_CATEGORIES = {'ATT', 'BON', 'SBON', 'RES', 'SKILL', 'OBON'};
67  
68 TitanItemBonuses_active = nil;
69  
70 function TitanPanelItemBonusesButton_OnLoad()
71 this.registry = {
72 id = TITAN_ITEMBONUSES_ID,
73 builtIn = 1,
74 version = "0.9.1800",
75 menuText = TITAN_ITEMBONUSES_TEXT,
76 buttonTextFunction = "TitanPanelItemBonusesButton_GetButtonText",
77 tooltipTitle = TITAN_ITEMBONUSES_TEXT,
78 tooltipTextFunction = "TitanPanelItemBonusesButton_GetTooltipText",
79 icon = "Interface\\Icons\\Spell_Nature_EnchantArmor.blp";
80 iconWidth = 16,
81 savedVariables = {
82 ShowLabelText = 1,
83 ShowColoredText = TITAN_NIL,
84 ShowIcon = 1,
85 shortdisplay = TITAN_NIL,
86 displaybonuses = {},
87 }
88 };
89  
90 this:RegisterEvent("PLAYER_ENTERING_WORLD");
91 end
92  
93 function TitanPanelItemBonusesButton_OnEvent()
94 if (event == "PLAYER_ENTERING_WORLD") then
95 TitanItemBonuses_active = 1;
96 end
97 end
98  
99 function TitanPanelItemBonusesButton_FormatShortText(short,val)
100 local color = 'FFFFFF';
101 local text = string.sub(short,2);
102 local colorcode = string.sub(short,1,1);
103 if(TitanItemBonuses_colors[colorcode]) then
104 color = TitanItemBonuses_colors[colorcode];
105 end;
106 if(val) then
107 return '|cff'.. color .. val .. FONT_COLOR_CODE_CLOSE
108 else
109 return '|cff'.. color .. text .. FONT_COLOR_CODE_CLOSE
110 end;
111 end
112  
113  
114 function TitanPanelItemBonusesButton_GetButtonText(id)
115  
116 local title = TITAN_ITEMBONUSES_TEXT;
117 local text = "";
118 local disp = TitanGetVar(TITAN_ITEMBONUSES_ID, "displaybonuses");
119 -- preventing getting inaccessible due to no display at all
120 if( (not disp or (table.getn(disp) == 0 ) or not BonusScanner or not BonusScanner.active)
121 and not TitanGetVar(TITAN_ITEMBONUSES_ID, "ShowLabelText")
122 and not TitanGetVar(TITAN_ITEMBONUSES_ID, "ShowIcon")) then
123 TitanSetVar(TITAN_ITEMBONUSES_ID, "ShowLabelText", 1);
124 TitanPanelButton_UpdateButton(TITAN_ITEMBONUSES_ID);
125 end;
126  
127 if(not BonusScanner or not BonusScanner.active) then
128 return TITAN_ITEMBONUSES_TEXT,"";
129 end
130  
131 local i,d,e;
132 local liste = {};
133 for i,d in disp do
134 e = TITAN_ITEMBONUSES_EFFECTS[d];
135 if(TitanGetVar(TITAN_ITEMBONUSES_ID, "shortdisplay")) then
136 title = TitanPanelItemBonusesButton_FormatShortText(e.short);
137 else
138 title = BONUSSCANNER_NAMES[e.effect]..": ";
139 end
140 if(BonusScanner.bonuses[e.effect]) then
141 val = BonusScanner.bonuses[e.effect];
142 else
143 val = 0;
144 end
145 text = format(e.format,val);
146 if(TitanGetVar(TITAN_ITEMBONUSES_ID, "ShowColoredText")) then
147 text = TitanPanelItemBonusesButton_FormatShortText(e.short,text);
148 end;
149 table.insert(liste,title);
150 table.insert(liste,TitanUtils_GetHighlightText(text));
151 end;
152  
153 if(table.getn(liste) == 0) then
154 return TITAN_ITEMBONUSES_TEXT,"";
155 end
156 return unpack(liste);
157 end
158  
159 function TitanPanelItemBonusesButton_isdisp(val)
160 local disp = TitanGetVar(TITAN_ITEMBONUSES_ID, "displaybonuses");
161 local i,d;
162 for i,d in disp do
163 if(d==val) then
164 return 1;
165 end
166 end
167 return nil;
168 end
169  
170 function TitanPanelItemBonusesButton_hasdisp()
171 local disp = TitanGetVar(TITAN_ITEMBONUSES_ID, "displaybonuses");
172 if(not disp) then
173 return nil;
174 end
175 return table.getn(disp) > 0;
176 end
177  
178  
179 function TitanPanelItemBonusesButton_GetTooltipText()
180  
181 if(not BonusScanner or not BonusScanner.active) then
182 return "\n" ..TITAN_ITEMBONUSES_BONUSSCANNER_MISSING;
183 end
184  
185 local retstr,cat,val = "","","","";
186 local i;
187  
188 for i,e in TITAN_ITEMBONUSES_EFFECTS do
189  
190 if(BonusScanner.bonuses[e.effect]) then
191 if(e.format) then
192 val = format(e.format,BonusScanner.bonuses[e.effect]);
193 else
194 val = BonusScanner.bonuses[e.effect];
195 end;
196 if(e.cat ~= cat) then
197 cat = e.cat;
198 if(retstr ~= "") then
199 retstr = retstr .. "\n"
200 end
201 retstr = retstr .. "\n" .. TitanUtils_GetGreenText(getglobal('TITAN_ITEMBONUSES_CAT_'..cat)..":");
202 end
203  
204 retstr = retstr.. "\n".. BONUSSCANNER_NAMES[e.effect]..":\t".. TitanUtils_GetHighlightText(val);
205 end
206 end
207 return retstr;
208 end
209  
210 function TitanPanelItemBonuses_Update()
211 oldBonusScanner_Update();
212 if(TitanItemBonuses_active) then
213 TitanPanelButton_UpdateButton(TITAN_ITEMBONUSES_ID);
214 end
215 end
216  
217 oldBonusScanner_Update = BonusScanner_Update;
218 BonusScanner_Update = TitanPanelItemBonuses_Update;
219  
220 function TitanPanelRightClickMenu_PrepareItemBonusesMenu()
221 local id = "ItemBonuses";
222 local info = {};
223 local i,cat,disp,val;
224  
225 if ( UIDROPDOWNMENU_MENU_LEVEL == 2 ) then
226 for i,e in TITAN_ITEMBONUSES_EFFECTS do
227 if(e.cat == this.value) then
228 info = {};
229 info.text = '[' .. TitanPanelItemBonusesButton_FormatShortText(e.short) .. '] ' .. BONUSSCANNER_NAMES[e.effect];
230 if(BonusScanner.bonuses[e.effect]) then
231 val = BonusScanner.bonuses[e.effect];
232 info.text = info.text .. " (".. format(e.format,val).. ")";
233 end
234 info.value = i;
235 info.func = TitanPanelItemBonuses_SetDisplay;
236 info.checked = TitanPanelItemBonusesButton_isdisp(i);
237 info.keepShownOnClick = 1;
238 UIDropDownMenu_AddButton(info,UIDROPDOWNMENU_MENU_LEVEL);
239 end
240 end
241 else
242  
243 if(not BonusScanner or not BonusScanner.active) then
244 TitanPanelRightClickMenu_AddToggleIcon(TITAN_ITEMBONUSES_ID);
245 TitanPanelRightClickMenu_AddToggleLabelText(TITAN_ITEMBONUSES_ID);
246 TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, id, TITAN_PANEL_MENU_FUNC_HIDE);
247 else
248 TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_ITEMBONUSES_ID].menuText);
249 TitanPanelRightClickMenu_AddSpacer(UIDROPDOWNMENU_MENU_LEVEL);
250  
251 info = {};
252 info.text = TITAN_ITEMBONUSES_DISPLAY_NONE;
253 info.value = 0;
254 info.func = TitanPanelItemBonuses_SetDisplay;
255 disp = TitanGetVar(TITAN_ITEMBONUSES_ID, "displaybonuses");
256 info.checked = not TitanPanelItemBonusesButton_hasdisp();
257 UIDropDownMenu_AddButton(info);
258  
259 for i,cat in TITAN_ITEMBONUSES_CATEGORIES do
260 info = {};
261 info.text = getglobal('TITAN_ITEMBONUSES_CAT_'..cat);
262 info.hasArrow = 1;
263 info.value = cat;
264 UIDropDownMenu_AddButton(info);
265 end;
266  
267 TitanPanelRightClickMenu_AddSpacer(UIDROPDOWNMENU_MENU_LEVEL);
268  
269 TitanPanelRightClickMenu_AddToggleIcon(TITAN_ITEMBONUSES_ID);
270 TitanPanelRightClickMenu_AddToggleVar(TITAN_ITEMBONUSES_SHORTDISPLAY, TITAN_ITEMBONUSES_ID,'shortdisplay');
271 TitanPanelRightClickMenu_AddToggleLabelText(TITAN_ITEMBONUSES_ID);
272 TitanPanelRightClickMenu_AddToggleColoredText(TITAN_ITEMBONUSES_ID);
273 TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, id, TITAN_PANEL_MENU_FUNC_HIDE);
274 end
275  
276 end
277 end
278  
279 function TitanPanelItemBonuses_SetDisplay()
280 local db = TitanGetVar(TITAN_ITEMBONUSES_ID, "displaybonuses");
281 local i,d,found;
282 if(this.value == 0) then
283 TitanSetVar(TITAN_ITEMBONUSES_ID, "displaybonuses", {});
284 else
285 found = 0;
286 for i,d in db do
287 if(d == this.value)then
288 found = i;
289 end
290 end
291 if(found > 0) then
292 table.remove(db,found)
293 else
294 while(table.getn(db)>3) do
295 table.remove(db);
296 end;
297 table.insert(db,this.value);
298 end
299 TitanSetVar(TITAN_ITEMBONUSES_ID, "displaybonuses", db);
300 end;
301 TitanPanelButton_UpdateButton(TITAN_ITEMBONUSES_ID);
302 end