vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --------------------------------------------------------------------------
2 -- TitanSkills.lua
3 --------------------------------------------------------------------------
4 --[[
5  
6 Titan Panel [Skills]
7 Plug-in for Titan Panel that displays Professions, Secondary Skills
8 and Weapons Skills when hovered over.
9  
10 Author: Corgi - corgiwow@gmail.com
11  
12 v0.09 (April 5, 2006 22:00 PST)
13 - fixed level change
14 - toc# updated for 1.10 patch
15  
16 v0.08 (January 5, 2006 20:05 PST)
17 - added ability to toggle player's Level
18 - Shift-click opens Skills frame
19 - toc# updated for 1.9 patch
20  
21 v0.07 (October 26, 2005 10:18 PST)
22 - toc# updated for 1.8 patch
23 - added Skills (Right) options (thanks Forger)
24 - tooltip will now popup below/above Titan bar (thanks Forger)
25 - added skill bonuses (e.g. Skill 10(+5)/300) (thanks Forger)
26  
27 v0.06 (September 24, 2005 19:11 PST)
28 - toc# updated for 1.7 patch
29 - added French localization
30  
31 v0.05 (June 13, 2005 14:30 PST)
32 - updated for Titan Panel 1.24
33  
34 v0.04 (June 7, 2005 14:25 PST)
35 - toc updated for 1.5 patch
36 - minor french localization
37  
38 v0.03 (June 6, 2005 12:35 PST)
39 - complete German translation by Crowley
40 - added transparent icon
41  
42 v0.02 (June 3, 2005 20:00 PST)
43 - list non-passive Class Skills (ie, Rogue's Lockpicking and Poison skills)
44  
45 v0.01 (May 31, 2005 2:00 PST)
46 - Initial Release
47  
48 ]]--
49  
50 TITAN_SKILLS_ID = "Skills";
51 TITAN_SKILLS_RIGHT_ID = "SkillsRight";
52  
53 TITAN_SKILLS_ICON = "Interface\\Addons\\TitanSkills\\Artwork\\TitanSkills";
54  
55 --
56 -- OnFuctions
57 --
58 function TitanPanelSkillsButton_OnLoad()
59 this.registry = {
60 id = TITAN_SKILLS_ID,
61 menuText = TITAN_SKILLS_MENU_TEXT,
62 buttonTextFunction = "TitanPanelSkillsButton_GetButtonText",
63 tooltipTitle = TITAN_SKILLS_TOOLTIP,
64 tooltipTextFunction = "TitanPanelSkillsButton_GetTooltipText",
65 icon = TITAN_SKILLS_ICON,
66 iconWidth = 16,
67 savedVariables = {
68 ShowIcon = 1,
69 ShowLabelText = 1,
70 ShowLevel = TITAN_NIL,
71 }
72 };
73 this:RegisterEvent("SKILL_LINES_CHANGED");
74 this:RegisterEvent("PLAYER_LEVEL_UP");
75 end
76  
77 function TitanPanelSkillsRightButton_OnLoad()
78 this.registry = {
79 id = TITAN_SKILLS_RIGHT_ID,
80 menuText = TITAN_SKILLS_RIGHT_MENU_TEXT,
81 buttonTextFunction = "TitanPanelSkillsButton_GetButtonText",
82 tooltipTitle = TITAN_SKILLS_TOOLTIP,
83 tooltipTextFunction = "TitanPanelSkillsButton_GetTooltipText",
84 icon = TITAN_SKILLS_ICON,
85 iconWidth = 16,
86 };
87 end
88  
89 function TitanPanelSkillsButton_OnEvent()
90 TitanPanelButton_UpdateButton(TITAN_SKILLS_ID);
91 TitanPanelButton_UpdateTooltip();
92 end
93  
94 -- CROWGOBLIN ADDITION
95 function TitanPanelSkillsButton_OnClick()
96 if (IsShiftKeyDown()) then
97 ToggleCharacter("SkillFrame");
98 end
99 end
100  
101 --
102 -- Titan functions
103 --
104 function TitanPanelSkillsButton_GetButtonText(id)
105 local buttonRichText = "";
106  
107 if ( TitanGetVar(TITAN_SKILLS_ID,"ShowLevel") ~= nil ) then
108 buttonRichText = " "..TitanUtils_GetHighlightText(UnitLevel("player"));
109 end
110  
111 if ( id == TITAN_SKILLS_RIGHT_ID ) then
112 return "", "";
113 else
114 return TITAN_SKILLS_BUTTON_LABEL, buttonRichText;
115 end
116 end
117  
118 function TitanPanelSkillsButton_GetTooltipText()
119  
120 local tooltipRichText = "";
121  
122 local SkillList = TitanPanelSkills_BuildSkillList();
123  
124 local numSkills = table.getn(SkillList);
125  
126 local i = 0;
127 local currentHeader = "";
128 local prevHeader = "";
129  
130 for i=1, numSkills do
131  
132 currentHeader = SkillList[i].stype;
133  
134 if ( SkillList[i].stype == TRADE_SKILLS or SkillList[i].stype == TITAN_SKILLS_SECONDARY_TEXT or SkillList[i].stype == TITAN_SKILLS_WEAPON_TEXT or SkillList[i].stype == TITAN_SKILLS_CLASS_TEXT ) then
135 if ( currentHeader ~= prevHeader and SkillList[i].maxrank > 1 ) then
136 tooltipRichText = tooltipRichText..TitanUtils_GetNormalText(SkillList[i].stype).."\n";
137 prevHeader = currentHeader;
138 end
139 if ( SkillList[i].maxrank > 1 ) then
140 tooltipRichText = tooltipRichText..TitanUtils_GetGreenText(SkillList[i].name)..":".."\t"..SkillList[i].rank;
141 if ( SkillList[i].rankbonus > 0 ) then
142 tooltipRichText = tooltipRichText.."(+"..SkillList[i].rankbonus..")";
143 end
144 tooltipRichText = tooltipRichText.."/"..SkillList[i].maxrank.."\n";
145 end
146 end
147 end
148  
149 -- remove the last \n
150 tooltipRichText = string.sub(tooltipRichText, 1, string.len(tooltipRichText)-1);
151  
152 return tooltipRichText;
153 end
154  
155 --
156 -- create menus
157 --
158 function TitanPanelRightClickMenu_PrepareSkillsMenu()
159 TitanPanelRightClickMenu_PrepareMenu(TITAN_SKILLS_ID);
160 end
161  
162 function TitanPanelRightClickMenu_PrepareSkillsRightMenu()
163 TitanPanelRightClickMenu_PrepareMenu(TITAN_SKILLS_RIGHT_ID);
164 end
165  
166 function TitanPanelRightClickMenu_PrepareMenu(id)
167  
168 local info = {};
169  
170 if ( UIDROPDOWNMENU_MENU_LEVEL == 2 ) then
171  
172 if ( UIDROPDOWNMENU_MENU_VALUE == "DisplayAbout" ) then
173 info = {};
174 info.text = TITAN_SKILLS_ABOUT_POPUP_TEXT;
175 info.value = "AboutTextPopUP";
176 info.notClickable = 1;
177 info.isTitle = 0;
178 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
179 end
180 return;
181 end
182  
183 TitanPanelRightClickMenu_AddTitle(TitanPlugins[id].menuText);
184 if ( id == TITAN_SKILLS_ID ) then
185 info = {};
186 info.text = TITAN_SKILLS_SHOW_LEVEL_TEXT;
187 info.value = "ShowLevelToggle";
188 info.func = TitanPanelSkills_ShowLevelToggle;
189 info.checked = TitanGetVar(TITAN_SKILLS_ID, "ShowLevel");
190 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
191  
192 TitanPanelRightClickMenu_AddToggleLabelText(id);
193 TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, id, TITAN_PANEL_MENU_FUNC_HIDE);
194 end
195  
196 -- info about plugin
197 info = {};
198 info.text = TITAN_SKILLS_ABOUT_TEXT;
199 info.value = "DisplayAbout";
200 info.hasArrow = 1;
201 UIDropDownMenu_AddButton(info);
202 end
203  
204 --
205 -- Skills functions
206 --
207 function TitanPanelSkills_BuildSkillList()
208  
209 local skillName, isHeader, isExpanded, skillRank, numTempPoints, skillModifier, skillMaxRank, isAbandonable;
210 local stepCost, rankCost, minLevel, skillCostType;
211  
212 local skillType = "";
213 local skillIndex = 0;
214 local SkillList = { };
215  
216 local numSkills = GetNumSkillLines();
217  
218 for skillIndex=1, numSkills do
219  
220 skillName, isHeader, isExpanded, skillRank, numTempPoints, skillModifier, skillMaxRank, isAbandonable, stepCost, rankCost, minLevel, skillCostType = GetSkillLineInfo(skillIndex);
221  
222 if ( isHeader ) then
223 skillType = skillName;
224 else
225 local entry = { name = skillName, stype = skillType, rank = skillRank, maxrank = skillMaxRank, rankbonus = skillModifier };
226 table.insert(SkillList, entry);
227 end
228 end
229  
230 --TitanPanelSkills_DisplayTheList(SkillList);
231 return SkillList;
232 end
233  
234 function TitanPanelSkills_ShowLevelToggle()
235 if ( TitanGetVar(TITAN_SKILLS_ID, "ShowLevel") ) then
236 TitanSetVar(TITAN_SKILLS_ID, "ShowLevel", nil);
237 else
238 TitanSetVar(TITAN_SKILLS_ID, "ShowLevel", 1);
239 end
240  
241 TitanPanelButton_UpdateButton(TITAN_SKILLS_ID);
242 end
243  
244 --
245 -- debug
246 --
247 function TitanPanelSkills_DisplayTheList(thelist)
248 local i = 0;
249 for i=1, table.getn(thelist) do
250 TitanPanelSkills_ChatPrint(i..":"..thelist[i].name..":"..thelist[i].stype.."\n");
251 end
252 end
253  
254 function TitanPanelSkills_ChatPrint(msg)
255 DEFAULT_CHAT_FRAME:AddMessage(msg);
256 end