vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | MAX_TALENT_TABS = 5; |
2 | MAX_NUM_TALENTS = 20; |
||
3 | MAX_NUM_TALENT_TIERS = 8; |
||
4 | NUM_TALENT_COLUMNS = 4; |
||
5 | SPECIAL_TALENT_BRANCH_ARRAY = {}; |
||
6 | SPECIAL_TALENT_BUTTON_SIZE = 32; |
||
7 | MAX_NUM_BRANCH_TEXTURES = 30; |
||
8 | MAX_NUM_ARROW_TEXTURES = 30; |
||
9 | INITIAL_SPECIAL_TALENT_OFFSET_X = 53; |
||
10 | INITIAL_SPECIAL_TALENT_OFFSET_Y = 45; |
||
11 | TALENT_POINTS_AT_60 = 51; |
||
12 | CYAN_FONT_COLOR_CODE = "|cff00ffff"; |
||
13 | |||
14 | TALENT_BRANCH_TEXTURECOORDS = { |
||
15 | up = { |
||
16 | [1] = {0.12890625, 0.25390625, 0 , 0.484375}, |
||
17 | [-1] = {0.12890625, 0.25390625, 0.515625 , 1.0} |
||
18 | }, |
||
19 | down = { |
||
20 | [1] = {0, 0.125, 0, 0.484375}, |
||
21 | [-1] = {0, 0.125, 0.515625, 1.0} |
||
22 | }, |
||
23 | left = { |
||
24 | [1] = {0.2578125, 0.3828125, 0, 0.5}, |
||
25 | [-1] = {0.2578125, 0.3828125, 0.5, 1.0} |
||
26 | }, |
||
27 | right = { |
||
28 | [1] = {0.2578125, 0.3828125, 0, 0.5}, |
||
29 | [-1] = {0.2578125, 0.3828125, 0.5, 1.0} |
||
30 | }, |
||
31 | topright = { |
||
32 | [1] = {0.515625, 0.640625, 0, 0.5}, |
||
33 | [-1] = {0.515625, 0.640625, 0.5, 1.0} |
||
34 | }, |
||
35 | topleft = { |
||
36 | [1] = {0.640625, 0.515625, 0, 0.5}, |
||
37 | [-1] = {0.640625, 0.515625, 0.5, 1.0} |
||
38 | }, |
||
39 | bottomright = { |
||
40 | [1] = {0.38671875, 0.51171875, 0, 0.5}, |
||
41 | [-1] = {0.38671875, 0.51171875, 0.5, 1.0} |
||
42 | }, |
||
43 | bottomleft = { |
||
44 | [1] = {0.51171875, 0.38671875, 0, 0.5}, |
||
45 | [-1] = {0.51171875, 0.38671875, 0.5, 1.0} |
||
46 | }, |
||
47 | tdown = { |
||
48 | [1] = {0.64453125, 0.76953125, 0, 0.5}, |
||
49 | [-1] = {0.64453125, 0.76953125, 0.5, 1.0} |
||
50 | }, |
||
51 | tup = { |
||
52 | [1] = {0.7734375, 0.8984375, 0, 0.5}, |
||
53 | [-1] = {0.7734375, 0.8984375, 0.5, 1.0} |
||
54 | }, |
||
55 | }; |
||
56 | |||
57 | TALENT_ARROW_TEXTURECOORDS = { |
||
58 | top = { |
||
59 | [1] = {0, 0.5, 0, 0.5}, |
||
60 | [-1] = {0, 0.5, 0.5, 1.0} |
||
61 | }, |
||
62 | right = { |
||
63 | [1] = {1.0, 0.5, 0, 0.5}, |
||
64 | [-1] = {1.0, 0.5, 0.5, 1.0} |
||
65 | }, |
||
66 | left = { |
||
67 | [1] = {0.5, 1.0, 0, 0.5}, |
||
68 | [-1] = {0.5, 1.0, 0.5, 1.0} |
||
69 | }, |
||
70 | }; |
||
71 | |||
72 | --UIPanelWindows["SpecialTalentFrame"] = { area = "doublewide", pushable = 6, whileDead = 1 }; |
||
73 | |||
74 | function SpecialTalentFrame_ToggleFrame() |
||
75 | if ( SpecialTalentFrame:IsVisible() ) then |
||
76 | HideUIPanel(SpecialTalentFrame); |
||
77 | else |
||
78 | ShowUIPanel(SpecialTalentFrame); |
||
79 | end |
||
80 | end |
||
81 | |||
82 | function SpecialTalentFrame_ToggleDragged() |
||
83 | if ( SpecialTalentFrame:IsVisible() ) then |
||
84 | SpecialTalentFrame:Hide(); |
||
85 | else |
||
86 | SpecialTalentFrame:Show(); |
||
87 | end |
||
88 | end |
||
89 | |||
90 | function SpecialTalentFrame_OnLoad() |
||
91 | this:RegisterEvent("CHARACTER_POINTS_CHANGED"); |
||
92 | this:RegisterEvent("SPELLS_CHANGED"); |
||
93 | this:RegisterEvent("UNIT_PORTRAIT_UPDATE"); |
||
94 | this:RegisterEvent("ADDON_LOADED"); |
||
95 | for tab=1, MAX_TALENT_TABS do |
||
96 | SPECIAL_TALENT_BRANCH_ARRAY[tab]={}; |
||
97 | for i=1, MAX_NUM_TALENT_TIERS do |
||
98 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i] = {}; |
||
99 | for j=1, NUM_TALENT_COLUMNS do |
||
100 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i][j] = {id=nil, up=0, left=0, right=0, down=0, leftArrow=0, rightArrow=0, topArrow=0}; |
||
101 | end |
||
102 | end |
||
103 | end |
||
104 | |||
105 | this.learnMode = "learned"; |
||
106 | PlayerOfRealm = UnitName("player").." of "..GetRealmName(); |
||
107 | SpecialTalentFrame_Toggle = SpecialTalentFrame_ToggleFrame; |
||
108 | |||
109 | if ( tp_webdata ) then |
||
110 | SPECIAL_TALENT_CLASSES = { Druid=1, Hunter=2, Mage=3, Paladin=4, Priest=5, Rogue=6, Shaman=7, Warlock=8, Warrior=9, }; |
||
111 | end |
||
112 | end |
||
113 | |||
114 | function SpecialTalentFrame_OnShow() |
||
115 | -- Stop buttons from flashing after skill up |
||
116 | SetButtonPulse(TalentMicroButton, 0, 1); |
||
117 | |||
118 | PlaySound("TalentScreenOpen"); |
||
119 | UpdateMicroButtons(); |
||
120 | |||
121 | SpecialTalentFrameTitleText:SetText(SPECIAL_TALENT.." - "..UnitClass("player")); |
||
122 | SetPortraitTexture(SpecialTalentFramePortrait, "player"); |
||
123 | --show total talent points |
||
124 | local tpoints = max(UnitLevel("player")-9, 0); |
||
125 | SpecialTalentFrameTalentPointsText:SetText(tpoints); |
||
126 | --set Planned label blue |
||
127 | SpecialTalentFramePlannedCheckButtonText:SetTextColor(0,1,1); |
||
128 | |||
129 | SpecialTalentFrame_Update(); |
||
130 | end |
||
131 | |||
132 | function SpecialTalentFrame_OnHide() |
||
133 | UpdateMicroButtons(); |
||
134 | PlaySound("TalentScreenClose"); |
||
135 | end |
||
136 | |||
137 | function SpecialTalentFrame_Minimize() |
||
138 | SpecialTalentFrameSaved.frameMinimized=1; |
||
139 | if ( not SpecialTalentFrameSaved.tabShown ) then |
||
140 | SpecialTalentFrameSaved.tabShown=1; |
||
141 | end |
||
142 | SpecialTalentFrameMinimizeButton:SetText("^"); |
||
143 | UIPanelWindows["SpecialTalentFrame"] = { area = "left", pushable = 6, whileDead = 1 }; |
||
144 | SpecialTalentFrame:SetWidth(345); |
||
145 | SpecialTalentFrame:SetHeight(586); |
||
146 | for i=2, 4 do |
||
147 | getglobal("SpecialTalentFrameBorder_TopLeft"..i):Hide(); |
||
148 | getglobal("SpecialTalentFrameBorder_BottomLeft"..i):Hide(); |
||
149 | end |
||
150 | for i=1, MAX_TALENT_TABS do |
||
151 | local button=getglobal("SpecialTalentFrameTab"..i); |
||
152 | if ( not button ) then |
||
153 | break; |
||
154 | end |
||
155 | button:Show(); |
||
156 | |||
157 | getglobal("SpecialTalentFrameTabFrame"..i):SetPoint("TOPLEFT", SpecialTalentFrame, "TOPLEFT", 0, -80); |
||
158 | end |
||
159 | |||
160 | SpecialTalentFrameTalentPointsText:Hide(); |
||
161 | SpecialTalentFrameTalentPoints:Hide(); |
||
162 | SpecialTalentFrameUnspentPointsText:SetPoint("LEFT", SpecialTalentFrame, "TOP", -145, -84); |
||
163 | --SpecialTalentFrameUnspentPoints:Hide(); |
||
164 | |||
165 | SpecialTalentFrameLearnedPointsText:SetPoint("RIGHT", SpecialTalentFrame, "TOP", 122, -65); |
||
166 | SpecialTalentFramePlannedPointsText:SetPoint("RIGHT", SpecialTalentFrame, "TOP", 122, -84); |
||
167 | SpecialTalentFrameLearnedCheckButton:SetPoint("RIGHT", SpecialTalentFrame, "TOP", -19, -65); |
||
168 | SpecialTalentFramePlannedCheckButton:SetPoint("RIGHT", SpecialTalentFrame, "TOP", -19, -84); |
||
169 | |||
170 | SpecialTalentFrameForceShiftCheckButton:SetPoint("LEFT", SpecialTalentFrame, "TOPLEFT", 215, -46); |
||
171 | end |
||
172 | |||
173 | function SpecialTalentFrame_Maximize() |
||
174 | SpecialTalentFrameSaved.frameMinimized=nil; |
||
175 | SpecialTalentFrameMinimizeButton:SetText("v"); |
||
176 | UIPanelWindows["SpecialTalentFrame"] = { area = "doublewide", pushable = 6, whileDead = 1 }; |
||
177 | SpecialTalentFrame:SetWidth(900); |
||
178 | SpecialTalentFrame:SetHeight(586); |
||
179 | for i=2, 4 do |
||
180 | getglobal("SpecialTalentFrameBorder_TopLeft"..i):Show(); |
||
181 | getglobal("SpecialTalentFrameBorder_BottomLeft"..i):Show(); |
||
182 | end |
||
183 | for i=1, MAX_TALENT_TABS do |
||
184 | local button=getglobal("SpecialTalentFrameTab"..i); |
||
185 | if ( not button ) then |
||
186 | break; |
||
187 | end |
||
188 | button:Hide(); |
||
189 | |||
190 | getglobal("SpecialTalentFrameTabFrame"..i):SetPoint("TOPLEFT", SpecialTalentFrame, "TOPLEFT", (i-1)*278, -80); |
||
191 | end |
||
192 | |||
193 | SpecialTalentFrameTalentPointsText:Show(); |
||
194 | SpecialTalentFrameTalentPoints:Show(); |
||
195 | SpecialTalentFrameUnspentPointsText:SetPoint("LEFT", SpecialTalentFrame, "TOP", 25, -81); |
||
196 | --SpecialTalentFrameUnspentPoints:SetPoint("RIGHT"); |
||
197 | |||
198 | SpecialTalentFrameLearnedPointsText:SetPoint("RIGHT", SpecialTalentFrame, "TOP", -25, -60); |
||
199 | SpecialTalentFramePlannedPointsText:SetPoint("RIGHT", SpecialTalentFrame, "TOP", -25, -81); |
||
200 | SpecialTalentFrameLearnedCheckButton:SetPoint("RIGHT", SpecialTalentFrame, "TOP", -165, -60); |
||
201 | SpecialTalentFramePlannedCheckButton:SetPoint("RIGHT", SpecialTalentFrame, "TOP", -165, -81); |
||
202 | |||
203 | SpecialTalentFrameForceShiftCheckButton:SetPoint("LEFT", SpecialTalentFrame, "TOPLEFT", 215, -60); |
||
204 | end |
||
205 | |||
206 | function SpecialTalentFrame_OnEvent() |
||
207 | if ( (event == "CHARACTER_POINTS_CHANGED") or (event == "SPELLS_CHANGED") ) then |
||
208 | SpecialTalentFrame_Update(); |
||
209 | elseif ( event == "UNIT_PORTRAIT_UPDATE" ) then |
||
210 | if ( arg1 == "player" ) then |
||
211 | SetPortraitTexture(SpecialTalentFramePortrait, "player"); |
||
212 | end |
||
213 | elseif ( event=="ADDON_LOADED" and arg1=="SpecialTalentUI" ) then |
||
214 | this:UnregisterEvent("ADDON_LOADED"); |
||
215 | if ( not SpecialTalentFrameSaved ) then |
||
216 | SpecialTalentFrameSaved={}; |
||
217 | end |
||
218 | SpecialTalent_LoadPlannedSaved(); |
||
219 | SpecialTalentFrame_CheckDragged(); |
||
220 | SpecialTalentFrameTabs_Initialize(); |
||
221 | end |
||
222 | |||
223 | end |
||
224 | |||
225 | function SpecialTalentFrameTalent_OnEvent() |
||
226 | if ( GameTooltip:IsOwned(this) ) then |
||
227 | GameTooltip:SetTalent(this.tabID, this:GetID()); |
||
228 | end |
||
229 | end |
||
230 | |||
231 | function SpecialTalentFrame_OnDrag() |
||
232 | if ( not SpecialTalentFrameSaved ) then |
||
233 | SpecialTalentFrameSaved={}; |
||
234 | end |
||
235 | SpecialTalentFrameSaved.frameDragged = 1; |
||
236 | SpecialTalentFrameSaved.frameLeft = SpecialTalentFrame:GetLeft(); |
||
237 | SpecialTalentFrameSaved.frameTop = SpecialTalentFrame:GetTop(); |
||
238 | SpecialTalentFrame:SetUserPlaced(0); |
||
239 | SpecialTalentFrame_CheckDragged(); |
||
240 | end |
||
241 | |||
242 | function SpecialTalentFrame_Update() |
||
243 | local numTabs = GetNumTalentTabs(); |
||
244 | local learnedText = SpecialTalentFrameLearnedPointsText; |
||
245 | local plannedText = SpecialTalentFramePlannedPointsText; |
||
246 | local learned = ""; |
||
247 | local planned = ""; |
||
248 | local player = PlayerOfRealm; |
||
249 | |||
250 | SpecialTalentFrame_UpdateTalentPoints(); |
||
251 | |||
252 | for f=1, MAX_TALENT_TABS do -- for each tab frame |
||
253 | |||
254 | local talentTabName = GetTalentTabInfo(f); |
||
255 | if ( not talentTabName ) then |
||
256 | break; |
||
257 | end |
||
258 | getglobal("SpecialTalentFrameTabFrame"..f):Hide(); |
||
259 | local base; |
||
260 | local name, iconTexture, pointsSpent, fileName = GetTalentTabInfo(f); |
||
261 | if ( talentTabName ) then |
||
262 | base = "Interface\\TalentFrame\\"..fileName.."-"; |
||
263 | else |
||
264 | -- temporary default for classes without talents poor guys |
||
265 | base = "Interface\\TalentFrame\\MageFire-"; |
||
266 | end |
||
267 | getglobal("SpecialTalentFrameTabFrame"..f.."BackgroundTopLeft"):SetTexture(base.."TopLeft"); |
||
268 | getglobal("SpecialTalentFrameTabFrame"..f.."BackgroundTopRight"):SetTexture(base.."TopRight"); |
||
269 | getglobal("SpecialTalentFrameTabFrame"..f.."BackgroundBottomLeft"):SetTexture(base.."BottomLeft"); |
||
270 | getglobal("SpecialTalentFrameTabFrame"..f.."BackgroundBottomRight"):SetTexture(base.."BottomRight"); |
||
271 | |||
272 | if ( f > 1 ) then |
||
273 | learned = learned.."/"; |
||
274 | planned = planned.."/"; |
||
275 | end |
||
276 | learned = learned..pointsSpent; |
||
277 | planned = planned..SpecialTalentPlannedSaved[player][f].points; |
||
278 | getglobal("SpecialTalentFrameTabFrame"..f.."SpentPoints"):SetText(format(MASTERY_POINTS_SPENT, name).." "..NORMAL_FONT_COLOR_CODE..pointsSpent..FONT_COLOR_CODE_CLOSE); |
||
279 | getglobal("SpecialTalentFrameTabFrame"..f.."SpentPoints"):SetText(CYAN_FONT_COLOR_CODE .. SpecialTalentPlannedSaved[player][f].points .. "|r :"..RED_FONT_COLOR_CODE..talentTabName.."|r: "..NORMAL_FONT_COLOR_CODE..pointsSpent.."|r"); |
||
280 | getglobal("SpecialTalentFrameTabFrame"..f).pointsSpent = pointsSpent; |
||
281 | |||
282 | local numTalents = GetNumTalents(f); |
||
283 | -- Just a reminder error if there are more talents than available buttons |
||
284 | if ( numTalents > MAX_NUM_TALENTS ) then |
||
285 | message("Too many talents in talent frame!"); |
||
286 | end |
||
287 | |||
288 | SpecialTalentFrame_ResetBranches(f); |
||
289 | local tier, column, rank, maxRank, isExceptional, isLearnable; |
||
290 | local forceDesaturated, tierUnlocked; |
||
291 | local button; |
||
292 | |||
293 | getglobal("SpecialTalentFrameTabFrame"..f).greatestTier = 0; |
||
294 | |||
295 | if ( not SpecialTalentFrameSaved.frameMinimized or SpecialTalentFrameSaved.tabShown==f ) then |
||
296 | getglobal("SpecialTalentFrameTabFrame"..f):Show(); |
||
297 | for i=1, MAX_NUM_TALENTS do |
||
298 | button = getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i); |
||
299 | if ( i <= numTalents ) then |
||
300 | -- Set the button info |
||
301 | name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(f, i); |
||
302 | |||
303 | -- Show planned points and border if necessary |
||
304 | local plannedPoints = SpecialTalentPlannedSaved[player][f][i]; |
||
305 | if ( not plannedPoints or plannedPoints<1 ) then |
||
306 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."Planned"):Hide(); |
||
307 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."PlannedBorder"):Hide(); |
||
308 | else |
||
309 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."Planned"):SetText(plannedPoints); |
||
310 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."Planned"):SetTextColor(0,1,1); |
||
311 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."Planned"):Show(); |
||
312 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."PlannedBorder"):Show(); |
||
313 | end |
||
314 | |||
315 | -- Show learned points and border if necessary |
||
316 | if ( rank > 0 ) then |
||
317 | if ( rank < maxRank ) then |
||
318 | getglobal( "SpecialTalentFrameTabFrame"..f.."Talent"..i.."Rank" ):SetTextColor( GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b ); |
||
319 | else |
||
320 | getglobal( "SpecialTalentFrameTabFrame"..f.."Talent"..i.."Rank" ):SetTextColor( NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b ); |
||
321 | end |
||
322 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."Rank"):SetText(rank); |
||
323 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."RankBorder"):Show(); |
||
324 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."Rank"):Show(); |
||
325 | else |
||
326 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."RankBorder"):Hide(); |
||
327 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."Rank"):Hide(); |
||
328 | end |
||
329 | |||
330 | SetSpecialTalentButtonLocation(button, tier, column); |
||
331 | SPECIAL_TALENT_BRANCH_ARRAY[f][tier][column].id = button:GetID(); |
||
332 | SetItemButtonTexture(button, iconTexture); |
||
333 | |||
334 | -- Determine learning or planning mode |
||
335 | local tabPointsSpent, talentPoints, requirementsMet; |
||
336 | if ( SpecialTalentFrame.learnMode == "learned" ) then |
||
337 | tabPointsSpent = getglobal("SpecialTalentFrameTabFrame"..f).pointsSpent; |
||
338 | talentPoints = SpecialTalentFrame.talentPoints; |
||
339 | elseif ( SpecialTalentFrame.learnMode == "planned" ) then |
||
340 | tabPointsSpent = SpecialTalentPlannedSaved[player][f].points; |
||
341 | talentPoints = TALENT_POINTS_AT_60 - SpecialTalentPlannedSaved[player].points; |
||
342 | rank = SpecialTalentPlannedSaved[player][f][i] or 0; |
||
343 | end |
||
344 | |||
345 | -- If player has no talent points then show only talents with points in them |
||
346 | if ( talentPoints <= 0 and rank == 0 ) then |
||
347 | forceDesaturated = 1; |
||
348 | else |
||
349 | forceDesaturated = nil; |
||
350 | end |
||
351 | |||
352 | -- If the player has spent at least 5 talent points in the previous tier |
||
353 | if ( (tier - 1) * 5 <= tabPointsSpent ) then |
||
354 | tierUnlocked = 1; |
||
355 | else |
||
356 | tierUnlocked = nil; |
||
357 | end |
||
358 | -- compare highest tier |
||
359 | if ( tier > getglobal("SpecialTalentFrameTabFrame"..f).greatestTier and rank>0 ) then |
||
360 | getglobal("SpecialTalentFrameTabFrame"..f).greatestTier = tier; |
||
361 | end |
||
362 | |||
363 | requirementsMet = SpecialTalentFrame_SetPrereqs(tier, column, forceDesaturated, tierUnlocked, f, SpecialTalent_GetTalentPrereqs(f, i)) and meetsPrereq; |
||
364 | |||
365 | -- Talent must meet prereqs or the player must have no points to spend |
||
366 | if ( requirementsMet ) then |
||
367 | --SetItemButtonDesaturated(button, nil); |
||
368 | getglobal(button:GetName().."IconTexture"):SetAlpha(1); |
||
369 | button.clickable = 1; |
||
370 | |||
371 | if ( rank < maxRank ) then |
||
372 | -- Rank is green if not maxed out |
||
373 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."Slot"):SetVertexColor(0.1, 1.0, 0.1); |
||
374 | else |
||
375 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."Slot"):SetVertexColor(1.0, 0.82, 0); |
||
376 | end |
||
377 | else |
||
378 | --SetItemButtonDesaturated(button, 2, .65, .65, .65); |
||
379 | getglobal(button:GetName().."IconTexture"):SetAlpha(.3); |
||
380 | button.clickable = nil; |
||
381 | getglobal("SpecialTalentFrameTabFrame"..f.."Talent"..i.."Slot"):SetVertexColor(0.5, 0.5, 0.5); |
||
382 | end |
||
383 | |||
384 | button:Show(); |
||
385 | else |
||
386 | button:Hide(); |
||
387 | end |
||
388 | end |
||
389 | end |
||
390 | |||
391 | -- Draw the prereq branches |
||
392 | local node; |
||
393 | local textureIndex = 1; |
||
394 | local xOffset, yOffset; |
||
395 | local texCoords; |
||
396 | -- Variable that decides whether or not to ignore drawing pieces |
||
397 | local ignoreUp; |
||
398 | local tempNode; |
||
399 | SpecialTalentFrame_ResetBranchTextureCount(f); |
||
400 | SpecialTalentFrame_ResetArrowTextureCount(f); |
||
401 | for i=1, MAX_NUM_TALENT_TIERS do |
||
402 | for j=1, NUM_TALENT_COLUMNS do |
||
403 | node = SPECIAL_TALENT_BRANCH_ARRAY[f][i][j]; |
||
404 | |||
405 | -- Setup offsets |
||
406 | xOffset = ((j - 1) * SPECIAL_TALENT_BUTTON_SIZE * 2) + INITIAL_SPECIAL_TALENT_OFFSET_X ; |
||
407 | yOffset = -((i - 1) * SPECIAL_TALENT_BUTTON_SIZE * 1.75) - INITIAL_SPECIAL_TALENT_OFFSET_Y + 4; |
||
408 | |||
409 | if ( node.id ) then |
||
410 | -- Has talent |
||
411 | if ( node.up ~= 0 ) then |
||
412 | if ( not ignoreUp ) then |
||
413 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["up"][node.up], xOffset, yOffset + SPECIAL_TALENT_BUTTON_SIZE, f); |
||
414 | else |
||
415 | ignoreUp = nil; |
||
416 | end |
||
417 | end |
||
418 | if ( node.down ~= 0 ) then |
||
419 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["down"][node.down], xOffset, yOffset - SPECIAL_TALENT_BUTTON_SIZE + 1, f); |
||
420 | end |
||
421 | if ( node.left ~= 0 ) then |
||
422 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["left"][node.left], xOffset - SPECIAL_TALENT_BUTTON_SIZE, yOffset, f); |
||
423 | end |
||
424 | if ( node.right ~= 0 ) then |
||
425 | -- See if any connecting branches are gray and if so color them gray |
||
426 | tempNode = SPECIAL_TALENT_BRANCH_ARRAY[f][i][j+1]; |
||
427 | if ( tempNode.left ~= 0 and tempNode.down < 0 ) then |
||
428 | SpecialTalentFrame_SetBranchTexture(i, j-1, TALENT_BRANCH_TEXTURECOORDS["right"][tempNode.down], xOffset + SPECIAL_TALENT_BUTTON_SIZE, yOffset, f); |
||
429 | else |
||
430 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["right"][node.right], xOffset + SPECIAL_TALENT_BUTTON_SIZE + 1, yOffset, f); |
||
431 | end |
||
432 | end |
||
433 | -- Draw arrows |
||
434 | if ( node.rightArrow ~= 0 ) then |
||
435 | SpecialTalentFrame_SetArrowTexture(i, j, TALENT_ARROW_TEXTURECOORDS["right"][node.rightArrow], xOffset + SPECIAL_TALENT_BUTTON_SIZE/2 + 5, yOffset, f); |
||
436 | end |
||
437 | if ( node.leftArrow ~= 0 ) then |
||
438 | SpecialTalentFrame_SetArrowTexture(i, j, TALENT_ARROW_TEXTURECOORDS["left"][node.leftArrow], xOffset - SPECIAL_TALENT_BUTTON_SIZE/2 - 5, yOffset, f); |
||
439 | end |
||
440 | if ( node.topArrow ~= 0 ) then |
||
441 | SpecialTalentFrame_SetArrowTexture(i, j, TALENT_ARROW_TEXTURECOORDS["top"][node.topArrow], xOffset, yOffset + SPECIAL_TALENT_BUTTON_SIZE/2, f); |
||
442 | end |
||
443 | else |
||
444 | -- Doesn't have a talent |
||
445 | if ( node.up ~= 0 and node.left ~= 0 and node.right ~= 0 ) then |
||
446 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["tup"][node.up], xOffset, yOffset, f); |
||
447 | elseif ( node.down ~= 0 and node.left ~= 0 and node.right ~= 0 ) then |
||
448 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["tdown"][node.down], xOffset, yOffset, f); |
||
449 | elseif ( node.left ~= 0 and node.down ~= 0 ) then |
||
450 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["topright"][node.left], xOffset , yOffset, f); |
||
451 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["down"][node.down], xOffset , yOffset - 32, f); |
||
452 | elseif ( node.left ~= 0 and node.up ~= 0 ) then |
||
453 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["bottomright"][node.left], xOffset , yOffset, f); |
||
454 | elseif ( node.left ~= 0 and node.right ~= 0 ) then |
||
455 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["right"][node.right], xOffset + SPECIAL_TALENT_BUTTON_SIZE, yOffset, f); |
||
456 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["left"][node.left], xOffset + 1, yOffset, f); |
||
457 | elseif ( node.right ~= 0 and node.down ~= 0 ) then |
||
458 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["topleft"][node.right], xOffset , yOffset, f); |
||
459 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["down"][node.down], xOffset , yOffset - 32, f); |
||
460 | elseif ( node.right ~= 0 and node.up ~= 0 ) then |
||
461 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["bottomleft"][node.right], xOffset , yOffset, f); |
||
462 | elseif ( node.up ~= 0 and node.down ~= 0 ) then |
||
463 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["up"][node.up], xOffset, yOffset, f); |
||
464 | SpecialTalentFrame_SetBranchTexture(i, j, TALENT_BRANCH_TEXTURECOORDS["down"][node.down], xOffset , yOffset - 32, f); |
||
465 | ignoreUp = 1; |
||
466 | end |
||
467 | end |
||
468 | end -- for |
||
469 | -- Hide any unused branch textures |
||
470 | for i=SpecialTalentFrame_GetBranchTextureCount(f), MAX_NUM_BRANCH_TEXTURES do |
||
471 | getglobal("SpecialTalentFrameTabFrame"..f.."Branch"..i):Hide(); |
||
472 | end |
||
473 | -- Hide and unused arrow textures |
||
474 | for i=SpecialTalentFrame_GetArrowTextureCount(f), MAX_NUM_ARROW_TEXTURES do |
||
475 | getglobal("SpecialTalentFrameTabFrame"..f.."ArrowFrameArrow"..i):Hide(); |
||
476 | end |
||
477 | end -- if |
||
478 | end --- for each tab frame |
||
479 | local maxpoints = max(UnitLevel("player")-9, 0); |
||
480 | local avail = maxpoints - SpecialTalentFrame.talentPoints; |
||
481 | learned = learned.." = "..avail.."/"..maxpoints; |
||
482 | learnedText:SetText(learned); |
||
483 | planned = planned.." = "..SpecialTalentPlannedSaved[player].points.."/"..TALENT_POINTS_AT_60; |
||
484 | plannedText:SetText(planned); |
||
485 | end |
||
486 | |||
487 | function SpecialTalentFrame_SetArrowTexture(tier, column, texCoords, xOffset, yOffset, tab) |
||
488 | local arrowTexture = SpecialTalentFrame_GetArrowTexture(tab); |
||
489 | arrowTexture:SetTexCoord(texCoords[1], texCoords[2], texCoords[3], texCoords[4]); |
||
490 | arrowTexture:SetPoint("TOPLEFT", "SpecialTalentFrameTabFrame"..tab.."ArrowFrame", "TOPLEFT", xOffset, yOffset); |
||
491 | end |
||
492 | |||
493 | function SpecialTalentFrame_SetBranchTexture(tier, column, texCoords, xOffset, yOffset, tab) |
||
494 | local branchTexture = SpecialTalentFrame_GetBranchTexture(tab); |
||
495 | branchTexture:SetTexCoord(texCoords[1], texCoords[2], texCoords[3], texCoords[4]); |
||
496 | branchTexture:SetPoint("TOPLEFT", "SpecialTalentFrameTabFrame"..tab, "TOPLEFT", xOffset, yOffset); |
||
497 | end |
||
498 | |||
499 | function SpecialTalentFrame_GetArrowTexture(tab) |
||
500 | local tabframe = getglobal("SpecialTalentFrameTabFrame"..tab); |
||
501 | local index = tabframe.arrowIndex; |
||
502 | local arrowTexture = getglobal("SpecialTalentFrameTabFrame"..tab.."ArrowFrameArrow".. index); |
||
503 | getglobal("SpecialTalentFrameTabFrame"..tab).arrowIndex = index + 1; |
||
504 | if ( not arrowTexture ) then |
||
505 | message("Not enough arrow textures"); |
||
506 | else |
||
507 | arrowTexture:Show(); |
||
508 | return arrowTexture; |
||
509 | end |
||
510 | end |
||
511 | |||
512 | function SpecialTalentFrame_GetBranchTexture(tab) |
||
513 | local tabframe = getglobal("SpecialTalentFrameTabFrame"..tab); |
||
514 | local index = tabframe.textureIndex; |
||
515 | local branchTexture = getglobal("SpecialTalentFrameTabFrame"..tab.."Branch"..index); |
||
516 | tabframe.textureIndex = index + 1; |
||
517 | if ( not branchTexture ) then |
||
518 | message("Not enough branch textures"); |
||
519 | else |
||
520 | branchTexture:Show(); |
||
521 | return branchTexture; |
||
522 | end |
||
523 | end |
||
524 | |||
525 | function SpecialTalentFrame_ResetArrowTextureCount(tab) |
||
526 | getglobal("SpecialTalentFrameTabFrame"..tab).arrowIndex = 1; |
||
527 | end |
||
528 | |||
529 | function SpecialTalentFrame_ResetBranchTextureCount(tab) |
||
530 | getglobal("SpecialTalentFrameTabFrame"..tab).textureIndex = 1; |
||
531 | end |
||
532 | |||
533 | function SpecialTalentFrame_GetArrowTextureCount(tab) |
||
534 | return getglobal("SpecialTalentFrameTabFrame"..tab).arrowIndex; |
||
535 | end |
||
536 | |||
537 | function SpecialTalentFrame_GetBranchTextureCount(tab) |
||
538 | return getglobal("SpecialTalentFrameTabFrame"..tab).textureIndex; |
||
539 | end |
||
540 | |||
541 | function SpecialTalentFrame_SetPrereqs(...) |
||
542 | local buttonTier = arg[1]; |
||
543 | local buttonColumn = arg[2]; |
||
544 | local forceDesaturated = arg[3]; |
||
545 | local tierUnlocked = arg[4]; |
||
546 | local tab = arg[5]; |
||
547 | local tier, column, isLearnable; |
||
548 | local requirementsMet; |
||
549 | if ( tierUnlocked and not forceDesaturated ) then |
||
550 | requirementsMet = 1; |
||
551 | else |
||
552 | requirementsMet = nil; |
||
553 | end |
||
554 | for i=6, arg.n, 3 do |
||
555 | tier = arg[i]; |
||
556 | column = arg[i+1]; |
||
557 | isLearnable = arg[i+2]; |
||
558 | if ( not isLearnable or forceDesaturated ) then |
||
559 | requirementsMet = nil; |
||
560 | end |
||
561 | SpecialTalentFrame_DrawLines(buttonTier, buttonColumn, tier, column, requirementsMet, tab); |
||
562 | end |
||
563 | return requirementsMet; |
||
564 | end |
||
565 | |||
566 | function SpecialTalentFrame_DrawLines(buttonTier, buttonColumn, tier, column, requirementsMet, tab) |
||
567 | if ( requirementsMet ) then |
||
568 | requirementsMet = 1; |
||
569 | else |
||
570 | requirementsMet = -1; |
||
571 | end |
||
572 | |||
573 | -- Check to see if are in the same column |
||
574 | if ( buttonColumn == column ) then |
||
575 | -- Check for blocking talents |
||
576 | if ( (buttonTier - tier) > 1 ) then |
||
577 | -- If more than one tier difference |
||
578 | for i=tier + 1, buttonTier - 1 do |
||
579 | if ( SPECIAL_TALENT_BRANCH_ARRAY[tab][i][buttonColumn].id ) then |
||
580 | -- If there's an id, there's a blocker |
||
581 | message("Error this layout is blocked vertically "..SPECIAL_TALENT_BRANCH_ARRAY[tab][buttonTier][i].id); |
||
582 | return; |
||
583 | end |
||
584 | end |
||
585 | end |
||
586 | |||
587 | -- Draw the lines |
||
588 | for i=tier, buttonTier - 1 do |
||
589 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i][buttonColumn].down = requirementsMet; |
||
590 | if ( (i + 1) <= (buttonTier - 1) ) then |
||
591 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i + 1][buttonColumn].up = requirementsMet; |
||
592 | end |
||
593 | end |
||
594 | |||
595 | -- Set the arrow |
||
596 | SPECIAL_TALENT_BRANCH_ARRAY[tab][buttonTier][buttonColumn].topArrow = requirementsMet; |
||
597 | return; |
||
598 | end |
||
599 | -- Check to see if they're in the same tier |
||
600 | if ( buttonTier == tier ) then |
||
601 | local left = min(buttonColumn, column); |
||
602 | local right = max(buttonColumn, column); |
||
603 | |||
604 | -- See if the distance is greater than one space |
||
605 | if ( (right - left) > 1 ) then |
||
606 | -- Check for blocking talents |
||
607 | for i=left + 1, right - 1 do |
||
608 | if ( SPECIAL_TALENT_BRANCH_ARRAY[tab][tier][i].id ) then |
||
609 | -- If there's an id, there's a blocker |
||
610 | message("there's a blocker"); |
||
611 | return; |
||
612 | end |
||
613 | end |
||
614 | end |
||
615 | -- If we get here then we're in the clear |
||
616 | for i=left, right - 1 do |
||
617 | SPECIAL_TALENT_BRANCH_ARRAY[tab][tier][i].right = requirementsMet; |
||
618 | SPECIAL_TALENT_BRANCH_ARRAY[tab][tier][i+1].left = requirementsMet; |
||
619 | end |
||
620 | -- Determine where the arrow goes |
||
621 | if ( buttonColumn < column ) then |
||
622 | SPECIAL_TALENT_BRANCH_ARRAY[tab][buttonTier][buttonColumn].rightArrow = requirementsMet; |
||
623 | else |
||
624 | SPECIAL_TALENT_BRANCH_ARRAY[tab][buttonTier][buttonColumn].leftArrow = requirementsMet; |
||
625 | end |
||
626 | return; |
||
627 | end |
||
628 | -- Now we know the prereq is diagonal from us |
||
629 | local left = min(buttonColumn, column); |
||
630 | local right = max(buttonColumn, column); |
||
631 | -- Don't check the location of the current button |
||
632 | if ( left == column ) then |
||
633 | left = left + 1; |
||
634 | else |
||
635 | right = right - 1; |
||
636 | end |
||
637 | -- Check for blocking talents |
||
638 | local blocked = nil; |
||
639 | for i=left, right do |
||
640 | if ( SPECIAL_TALENT_BRANCH_ARRAY[tab][tier][i].id ) then |
||
641 | -- If there's an id, there's a blocker |
||
642 | blocked = 1; |
||
643 | end |
||
644 | end |
||
645 | left = min(buttonColumn, column); |
||
646 | right = max(buttonColumn, column); |
||
647 | if ( not blocked ) then |
||
648 | SPECIAL_TALENT_BRANCH_ARRAY[tab][tier][buttonColumn].down = requirementsMet; |
||
649 | SPECIAL_TALENT_BRANCH_ARRAY[tab][buttonTier][buttonColumn].up = requirementsMet; |
||
650 | |||
651 | for i=tier, buttonTier - 1 do |
||
652 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i][buttonColumn].down = requirementsMet; |
||
653 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i + 1][buttonColumn].up = requirementsMet; |
||
654 | end |
||
655 | |||
656 | for i=left, right - 1 do |
||
657 | SPECIAL_TALENT_BRANCH_ARRAY[tab][tier][i].right = requirementsMet; |
||
658 | SPECIAL_TALENT_BRANCH_ARRAY[tab][tier][i+1].left = requirementsMet; |
||
659 | end |
||
660 | -- Place the arrow |
||
661 | SPECIAL_TALENT_BRANCH_ARRAY[tab][buttonTier][buttonColumn].topArrow = requirementsMet; |
||
662 | return; |
||
663 | end |
||
664 | -- If we're here then we were blocked trying to go vertically first so we have to go over first, then up |
||
665 | if ( left == buttonColumn ) then |
||
666 | left = left + 1; |
||
667 | else |
||
668 | right = right - 1; |
||
669 | end |
||
670 | -- Check for blocking talents |
||
671 | for i=left, right do |
||
672 | if ( SPECIAL_TALENT_BRANCH_ARRAY[tab][buttonTier][i].id ) then |
||
673 | -- If there's an id, then throw an error |
||
674 | message("Error, this layout is undrawable "..SPECIAL_TALENT_BRANCH_ARRAY[tab][buttonTier][i].id); |
||
675 | return; |
||
676 | end |
||
677 | end |
||
678 | -- If we're here we can draw the line |
||
679 | left = min(buttonColumn, column); |
||
680 | right = max(buttonColumn, column); |
||
681 | --SPECIAL_TALENT_BRANCH_ARRAY[tab][tier][column].down = requirementsMet; |
||
682 | --SPECIAL_TALENT_BRANCH_ARRAY[tab][buttonTier][column].up = requirementsMet; |
||
683 | |||
684 | for i=tier, buttonTier-1 do |
||
685 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i][column].up = requirementsMet; |
||
686 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i+1][column].down = requirementsMet; |
||
687 | end |
||
688 | |||
689 | -- Determine where the arrow goes |
||
690 | if ( buttonColumn < column ) then |
||
691 | SPECIAL_TALENT_BRANCH_ARRAY[tab][buttonTier][buttonColumn].rightArrow = requirementsMet; |
||
692 | else |
||
693 | SPECIAL_TALENT_BRANCH_ARRAY[tab][buttonTier][buttonColumn].leftArrow = requirementsMet; |
||
694 | end |
||
695 | end |
||
696 | |||
697 | function SpecialTalent_PlanTalent( tabID, talentID ) |
||
698 | --local tabID, talentID = this.tabID, this:GetID(); |
||
699 | |||
700 | -- Get talent info |
||
701 | local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tabID, talentID); |
||
702 | local saved = SpecialTalentPlannedSaved[PlayerOfRealm]; |
||
703 | local tab = saved[tabID]; |
||
704 | local plannedPoints = tab[talentID]; |
||
705 | local tabPoints = tab.points; |
||
706 | local talentPoints = saved.points; |
||
707 | |||
708 | if ( talentPoints<TALENT_POINTS_AT_60 ) then |
||
709 | if ( not plannedPoints ) then |
||
710 | tab[talentID] = 1; |
||
711 | tab.points = tabPoints + 1; |
||
712 | saved.points = talentPoints + 1; |
||
713 | elseif ( plannedPoints < maxRank ) then |
||
714 | plannedPoints = plannedPoints + 1; |
||
715 | tab[talentID] = plannedPoints; |
||
716 | tab.points = tabPoints + 1; |
||
717 | saved.points = talentPoints + 1; |
||
718 | end |
||
719 | end |
||
720 | SpecialTalentFrame_Update(); |
||
721 | end |
||
722 | |||
723 | function SpecialTalent_UnplanTalent( tabID, talentID ) |
||
724 | --local tabID, talentID = this.tabID, this:GetID(); |
||
725 | |||
726 | -- Get talent info |
||
727 | local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tabID, talentID); |
||
728 | local saved = SpecialTalentPlannedSaved[PlayerOfRealm]; |
||
729 | local tab = saved[tabID]; |
||
730 | local plannedPoints = tab[talentID]; |
||
731 | local tabPoints = tab.points; |
||
732 | local talentPoints = saved.points; |
||
733 | |||
734 | if ( plannedPoints and plannedPoints > 0 ) then |
||
735 | -- check if tiers below and enough talentPoints to spare |
||
736 | local hiTier = getglobal("SpecialTalentFrameTabFrame"..tabID).greatestTier; |
||
737 | local tierPoints, tierFine, tierTotal = 0, 1, {}; |
||
738 | for i=1, hiTier do |
||
739 | tierTotal[i]=0; |
||
740 | end |
||
741 | for i=1, GetNumTalents(tabID) do |
||
742 | local _,_,t,_,r = SpecialTalent_GetTalentInfo(tabID, i); |
||
743 | if ( t > hiTier ) then break; end |
||
744 | tierTotal[t]=tierTotal[t]+r; |
||
745 | -- check dependent talents |
||
746 | local rt, rc = SpecialTalent_GetTalentPrereqs(tabID, i); |
||
747 | if ( rt ) then |
||
748 | if ( r>0 and (rt==tier and rc==column) ) then |
||
749 | tierFine=nil; |
||
750 | end |
||
751 | end |
||
752 | end |
||
753 | if ( tierFine ) then |
||
754 | for i=tier+1, hiTier do |
||
755 | tierPoints=0; |
||
756 | for j=1, i-1 do |
||
757 | tierPoints=tierPoints + tierTotal[j]; |
||
758 | end |
||
759 | if ( tierPoints <= (i-1)*5 ) then |
||
760 | tierFine=nil; |
||
761 | end |
||
762 | end |
||
763 | end |
||
764 | if ( tier==hiTier or tierFine ) then |
||
765 | plannedPoints = plannedPoints > 1 and plannedPoints-1 or nil; |
||
766 | tab[talentID] = plannedPoints; |
||
767 | tab.points = tabPoints-1; |
||
768 | saved.points = talentPoints-1; |
||
769 | end |
||
770 | end |
||
771 | SpecialTalentFrame_Update(); |
||
772 | end |
||
773 | |||
774 | function SpecialTalentFrameTalent_OnClick() |
||
775 | local tabID, talentID = this.tabID, this:GetID(); |
||
776 | local force = SpecialTalentFrameSaved and SpecialTalentFrameSaved.forceShift; |
||
777 | if ( SpecialTalentFrame.learnMode=="learned" ) then |
||
778 | if ( not force or IsShiftKeyDown() ) then |
||
779 | LearnTalent(tabID, talentID); |
||
780 | SpecialTalentFrame_Update(); |
||
781 | end |
||
782 | elseif ( SpecialTalentFrame.learnMode=="planned" ) then |
||
783 | if ( IsShiftKeyDown() and force ) then |
||
784 | LearnTalent(tabID, talentID); |
||
785 | SpecialTalentFrame_Update(); |
||
786 | return; |
||
787 | end |
||
788 | -- check if requirements met |
||
789 | if ( not this.clickable ) then |
||
790 | return; |
||
791 | end |
||
792 | |||
793 | if ( arg1=="LeftButton" ) then |
||
794 | SpecialTalent_PlanTalent( tabID, talentID ); |
||
795 | elseif ( arg1=="RightButton" ) then |
||
796 | SpecialTalent_UnplanTalent( tabID, talentID ); |
||
797 | end |
||
798 | end |
||
799 | SpecialTalentButton_OnEnter(); |
||
800 | end |
||
801 | |||
802 | function SpecialTalentFrameTalent_OnMouseWheel(value) |
||
803 | -- check if requirements met |
||
804 | if ( SpecialTalentFrame.learnMode=="planned" and this.clickable ) then |
||
805 | if ( value > 0 ) then |
||
806 | SpecialTalent_PlanTalent( this.tabID, this:GetID() ); |
||
807 | elseif ( value < 0 ) then |
||
808 | SpecialTalent_UnplanTalent( this.tabID, this:GetID() ); |
||
809 | end |
||
810 | SpecialTalentButton_OnEnter(); |
||
811 | end |
||
812 | end |
||
813 | |||
814 | -- Helper functions |
||
815 | function SpecialTalentFrame_UpdateTalentPoints() |
||
816 | local cp1, cp2 = UnitCharacterPoints("player"); |
||
817 | SpecialTalentFrameUnspentPointsText:SetText(cp1); |
||
818 | SpecialTalentFrame.talentPoints = cp1; |
||
819 | end |
||
820 | |||
821 | function SetSpecialTalentButtonLocation(button, tier, column) |
||
822 | column = ((column - 1) * SPECIAL_TALENT_BUTTON_SIZE * 2) + INITIAL_SPECIAL_TALENT_OFFSET_X; |
||
823 | tier = -((tier - 1) * SPECIAL_TALENT_BUTTON_SIZE * 1.75) - INITIAL_SPECIAL_TALENT_OFFSET_Y ; |
||
824 | button:SetPoint("TOPLEFT", button:GetParent(), "TOPLEFT", column, tier); |
||
825 | end |
||
826 | |||
827 | function SpecialTalentFrame_ResetBranches(tab) |
||
828 | for i=1, MAX_NUM_TALENT_TIERS do |
||
829 | for j=1, NUM_TALENT_COLUMNS do |
||
830 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i][j].id = nil; |
||
831 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i][j].up = 0; |
||
832 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i][j].down = 0; |
||
833 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i][j].left = 0; |
||
834 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i][j].right = 0; |
||
835 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i][j].rightArrow = 0; |
||
836 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i][j].leftArrow = 0; |
||
837 | SPECIAL_TALENT_BRANCH_ARRAY[tab][i][j].topArrow = 0; |
||
838 | end |
||
839 | end |
||
840 | end |
||
841 | |||
842 | function SpecialTalent_LoadPlannedSaved() |
||
843 | local player= PlayerOfRealm; |
||
844 | if ( not SpecialTalentPlannedSaved ) then |
||
845 | SpecialTalentPlannedSaved={}; |
||
846 | end |
||
847 | if ( not SpecialTalentPlannedSaved[player] ) then |
||
848 | SpecialTalentPlannedSaved[player]={}; |
||
849 | end |
||
850 | for t=1, MAX_TALENT_TABS do |
||
851 | if ( GetTalentTabInfo(t) and not SpecialTalentPlannedSaved[player][t] ) then |
||
852 | SpecialTalentPlannedSaved[player].points = 0; |
||
853 | SpecialTalentPlannedSaved[player][t]={points=0}; |
||
854 | end |
||
855 | end |
||
856 | end |
||
857 | |||
858 | function SpecialTalentFrameTabs_Initialize() |
||
859 | for i=1, MAX_TALENT_TABS do |
||
860 | local button = getglobal("SpecialTalentFrameTab"..i); |
||
861 | if ( not button ) then |
||
862 | break; |
||
863 | end |
||
864 | local name, texture = GetTalentTabInfo(i); |
||
865 | button.tooltip = name; |
||
866 | button:SetNormalTexture(texture); |
||
867 | if ( button:GetID() == SpecialTalentFrameSaved.tabShown ) then |
||
868 | button:SetChecked(1); |
||
869 | end |
||
870 | end |
||
871 | end |
||
872 | |||
873 | function SpecialTalentFrameTab_OnClick() |
||
874 | for i=1, MAX_TALENT_TABS do |
||
875 | local button = getglobal("SpecialTalentFrameTab"..i); |
||
876 | if ( not button ) then |
||
877 | break; |
||
878 | end |
||
879 | button:SetChecked(0); |
||
880 | end |
||
881 | this:SetChecked(1); |
||
882 | |||
883 | SpecialTalentFrameSaved.tabShown = this:GetID(); |
||
884 | SpecialTalentFrame_Update(); |
||
885 | end |
||
886 | |||
887 | function SpecialTalentFrame_CheckDragged() |
||
888 | if ( SpecialTalentFrameSaved and SpecialTalentFrameSaved.frameDragged == 1 ) then |
||
889 | local left = SpecialTalentFrameSaved.frameLeft; |
||
890 | local top = SpecialTalentFrameSaved.frameTop; |
||
891 | SpecialTalentFrame:ClearAllPoints(); |
||
892 | SpecialTalentFrame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", left, top); |
||
893 | UIPanelWindows["SpecialTalentFrame"] = nil; |
||
894 | SpecialTalentFrame_Toggle = SpecialTalentFrame_ToggleDragged; |
||
895 | if ( SpecialTalentFrameSaved.frameMinimized ) then |
||
896 | SpecialTalentFrame_Minimize(); |
||
897 | else |
||
898 | SpecialTalentFrame_Maximize(); |
||
899 | end |
||
900 | else |
||
901 | SpecialTalentFrame_ResetDrag(); |
||
902 | end |
||
903 | end |
||
904 | |||
905 | function SpecialTalentFrame_ResetDrag() |
||
906 | if ( SpecialTalentFrameSaved and SpecialTalentFrameSaved.frameDragged ) then |
||
907 | SpecialTalentFrameSaved.frameDragged = nil; |
||
908 | SpecialTalentFrameSaved.frameLeft = nil; |
||
909 | SpecialTalentFrameSaved.frameTop = nil; |
||
910 | end |
||
911 | if ( SpecialTalentFrameSaved.frameMinimized ) then |
||
912 | SpecialTalentFrame_Minimize(); |
||
913 | else |
||
914 | SpecialTalentFrame_Maximize(); |
||
915 | end |
||
916 | SpecialTalentFrame_Toggle = SpecialTalentFrame_ToggleFrame; |
||
917 | SpecialTalentFrame_Toggle(); |
||
918 | SpecialTalentFrame_Toggle(); |
||
919 | --SpecialTalentFrame:Hide(); |
||
920 | --ShowUIPanel(SpecialTalentFrame); |
||
921 | end |
||
922 | |||
923 | function SpecialTalentFrame_SetForceShift( force ) |
||
924 | if ( force ) then |
||
925 | if ( not SpecialTalentFrameSaved ) then |
||
926 | SpecialTalentFrameSaved = {}; |
||
927 | end |
||
928 | SpecialTalentFrameSaved.forceShift = 1; |
||
929 | SpecialTalentFrameForceShiftCheckButton:SetChecked(1); |
||
930 | else |
||
931 | if ( SpecialTalentFrameSaved and SpecialTalentFrameSaved.forceShift ) then |
||
932 | SpecialTalentFrameSaved.forceShift = nil; |
||
933 | end |
||
934 | SpecialTalentFrameForceShiftCheckButton:SetChecked(0); |
||
935 | end |
||
936 | end |
||
937 | |||
938 | function SpecialTalent_GetTalentInfo(tabID, talentID, planned) |
||
939 | -- Set the button info |
||
940 | local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tabID, talentID); |
||
941 | if ( SpecialTalentFrame.learnMode == "planned" or planned ) then |
||
942 | rank = SpecialTalentPlannedSaved[PlayerOfRealm][tabID][talentID] or 0; |
||
943 | end |
||
944 | return name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq; |
||
945 | end |
||
946 | |||
947 | function SpecialTalent_GetTalentPrereqs(tabID, talentID, planned) |
||
948 | local prereqs = {GetTalentPrereqs(tabID, talentID)}; |
||
949 | local i=1; |
||
950 | while prereqs[i] do |
||
951 | local tier, column, isLearnable = prereqs[i], prereqs[i+1], prereqs[i+2]; |
||
952 | local _, _, _, _, rank, maxRank = SpecialTalent_GetTalentInfo(tabID, SPECIAL_TALENT_BRANCH_ARRAY[tabID][tier][column].id, (SpecialTalentFrame.learnMode == "planned" or planned) ); |
||
953 | if ( rank==maxRank ) then |
||
954 | prereqs[i+2]=1; |
||
955 | else |
||
956 | prereqs[i+2]=nil; |
||
957 | end |
||
958 | i=i+3; |
||
959 | end |
||
960 | return unpack(prereqs); |
||
961 | end |
||
962 | |||
963 | function SpecialTalentButton_OnEnter() |
||
964 | local tabID, talentID = this.tabID, this:GetID() |
||
965 | GameTooltip:Hide(); |
||
966 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
967 | GameTooltip:SetTalent(tabID, talentID); |
||
968 | if ( tp_webdata ) then -- requires either Talent Planner addon or WebData.lua in SpecialTalentUI folder |
||
969 | local name, texture, row, col, rank, maxRank = GetTalentInfo( tabID, talentID ); |
||
970 | local class = SPECIAL_TALENT_CLASSES[UnitClass("player")]; |
||
971 | local goalRank = SpecialTalentPlannedSaved[PlayerOfRealm][tabID][talentID]; |
||
972 | if ( not goalRank or not class ) then return; end |
||
973 | if ( (goalRank==1 and rank==0) or (goalRank==rank) ) then |
||
974 | local text=GameTooltipTextLeft2:GetText(); |
||
975 | GameTooltipTextLeft2:SetText( text.."\n"..CYAN_FONT_COLOR_CODE..format(PLANNED_RANK, goalRank, maxRank).."|r" ); |
||
976 | elseif ( goalRank==rank+1 ) then |
||
977 | GameTooltipTextLeft5:SetText( format(PLANNED_RANK, goalRank, maxRank)); |
||
978 | GameTooltipTextLeft5:SetTextColor(0, 1.0, 1.0); |
||
979 | else |
||
980 | GameTooltip:AddLine( " " ); |
||
981 | GameTooltip:AddLine( format(PLANNED_RANK, goalRank, maxRank), 0, 1.0, 1.0 ); |
||
982 | GameTooltip:AddLine( tp_webdata[class][tabID][talentID][goalRank], 1.0, 0.82, 0.0, 1.0, 1 ); |
||
983 | end |
||
984 | GameTooltip:Show(); |
||
985 | end |
||
986 | end |