vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | |||
3 | TalentSafe: |
||
4 | Confirm choices when learning a talent. |
||
5 | |||
6 | Bima, aka Tale, aka David C Lawrence <reg+wow-addons@dd.org> |
||
7 | |||
8 | ]] |
||
9 | |||
10 | local LEARN |
||
11 | |||
12 | if (GetLocale() == "frFR") then |
||
13 | LEARN = "Apprenez" |
||
14 | elseif (GetLocale() == "deDE") then |
||
15 | LEARN = "Erlernen" |
||
16 | else |
||
17 | LEARN = "Learn" |
||
18 | end |
||
19 | |||
20 | --- |
||
21 | --- Redefines the standard Blizzard function from FrameXML/TalenFrame.lua |
||
22 | --- Honestly, figuring out whether a talent is learnable is more painful |
||
23 | --- than it should be. |
||
24 | --- |
||
25 | function TalentSafe_OnClick() |
||
26 | if (TalentFrame.talentPoints < 1) then |
||
27 | return |
||
28 | end |
||
29 | |||
30 | local tab = PanelTemplates_GetSelectedTab(TalentFrame) |
||
31 | local talent = this:GetID() |
||
32 | |||
33 | local name, texture, tier, column, rank, maxrank, exceptional, prereqok = |
||
34 | GetTalentInfo(tab, talent) |
||
35 | |||
36 | if (rank == maxrank) then |
||
37 | return |
||
38 | end |
||
39 | |||
40 | if ((tier - 1) * 5 > TalentFrame.pointsSpent) then |
||
41 | return |
||
42 | end |
||
43 | |||
44 | -- I have no idea how come the 8th return value from GetTalentInfo, |
||
45 | -- which the standard TalentFrame.lua names "meetsPrereq", declares |
||
46 | -- a true value when in fact prereqs are not met. Furthermore, |
||
47 | -- why does TalentFrame.lua process the return values from |
||
48 | -- GetTalentPrereqs as though there can be more than one tuple? |
||
49 | -- Is there ever more than one prereq talent for any other talent? |
||
50 | local prereqs = { GetTalentPrereqs(tab, talent) } |
||
51 | |||
52 | local i; |
||
53 | for i = 1, table.getn(prereqs), 3 do |
||
54 | if (not prereqs[i+2]) then |
||
55 | return |
||
56 | end |
||
57 | end |
||
58 | |||
59 | local ranktext |
||
60 | if (maxrank > 1) then |
||
61 | ranktext = " (" .. (rank + 1) .. "/" .. maxrank .. ")" |
||
62 | else |
||
63 | ranktext = "" |
||
64 | end |
||
65 | |||
66 | StaticPopupDialogs["TALENTSAFE"] = { |
||
67 | text = LEARN .. " " .. name .. ranktext .. "?", |
||
68 | button1 = YES, |
||
69 | button2 = NO, |
||
70 | OnAccept = function() |
||
71 | LearnTalent(tab, talent) |
||
72 | end, |
||
73 | timeout = 0, |
||
74 | exclusive = 1, |
||
75 | whileDead = 1, |
||
76 | interruptCinematic = 1 |
||
77 | }; |
||
78 | StaticPopup_Show("TALENTSAFE"); |
||
79 | end |
||
80 |