vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Text Sub functions for FlexBar |
||
3 | Last Modified |
||
4 | 02/09/2005 Initial version |
||
5 | 08/12/2005 Added Text3 Stuff - Sherkhan |
||
6 | --]] |
||
7 | local util = Utility_Class:New() |
||
8 | |||
9 | function FB_TextSub(buttonnum) |
||
10 | -- for the given button number, determine if the hotkey or text2 attributes are dynamic and set the text |
||
11 | local text = getglobal("FlexBarButton"..buttonnum.."HotKey") |
||
12 | local text2 = getglobal("FlexBarButton"..buttonnum.."Text2") |
||
13 | local text3 = getglobal("FlexBarButton"..buttonnum.."Text3") |
||
14 | |||
15 | if FBTextSubstitutions[FBState[buttonnum]["hotkeytext"]] then |
||
16 | text:SetText(FBTextSubstitutions[FBState[buttonnum]["hotkeytext"]]()) |
||
17 | elseif FBState[buttonnum]["hotkeytext"] ~= "%d" and FBState[buttonnum]["hotkeytext"] ~= "%c" and FBState[buttonnum]["hotkeytext"] ~= "%b" then |
||
18 | text:SetText(FBState[buttonnum]["hotkeytext"]) |
||
19 | end |
||
20 | |||
21 | if FBTextSubstitutions[FBState[buttonnum]["text2"]] then |
||
22 | text2:SetText(FBTextSubstitutions[FBState[buttonnum]["text2"]]()) |
||
23 | elseif FBState[buttonnum]["text2"] ~= "%d" and FBState[buttonnum]["text2"] ~= "%c" and FBState[buttonnum]["text2"] ~= "%b" then |
||
24 | text2:SetText(FBState[buttonnum]["text2"]) |
||
25 | end |
||
26 | |||
27 | if FBTextSubstitutions[FBState[buttonnum]["text3"]] then |
||
28 | text3:SetText(FBTextSubstitutions[FBState[buttonnum]["text3"]]()) |
||
29 | elseif FBState[buttonnum]["text3"] ~= "%d" and FBState[buttonnum]["text3"] ~= "%c" and FBState[buttonnum]["text3"] ~= "%b" then |
||
30 | text3:SetText(FBState[buttonnum]["text3"]) |
||
31 | end |
||
32 | |||
33 | if FBState[buttonnum]["hotkeycolor"] then |
||
34 | text:SetVertexColor(FBState[buttonnum]["hotkeycolor"][1], |
||
35 | FBState[buttonnum]["hotkeycolor"][2], |
||
36 | FBState[buttonnum]["hotkeycolor"][3]) |
||
37 | end |
||
38 | |||
39 | if FBState[buttonnum]["text2color"] then |
||
40 | text2:SetVertexColor(FBState[buttonnum]["text2color"][1], |
||
41 | FBState[buttonnum]["text2color"][2], |
||
42 | FBState[buttonnum]["text2color"][3]) |
||
43 | end |
||
44 | |||
45 | if FBState[buttonnum]["text3color"] then |
||
46 | text3:SetVertexColor(FBState[buttonnum]["text3color"][1], |
||
47 | FBState[buttonnum]["text3color"][2], |
||
48 | FBState[buttonnum]["text3color"][3]) |
||
49 | end |
||
50 | end |
||
51 | |||
52 | FBTextSubstitutions["%playerhealth"] = function() |
||
53 | return math.floor(UnitHealth("player")/UnitHealthMax("player") * 100) |
||
54 | end |
||
55 | FBTextSubstitutions["%party1health"] = function() |
||
56 | return math.floor(UnitHealth("party1")/UnitHealthMax("party1") * 100) |
||
57 | end |
||
58 | FBTextSubstitutions["%party2health"] = function() |
||
59 | return math.floor(UnitHealth("party2")/UnitHealthMax("party2") * 100) |
||
60 | end |
||
61 | FBTextSubstitutions["%party3health"] = function() |
||
62 | return math.floor(UnitHealth("party3")/UnitHealthMax("party3") * 100) |
||
63 | end |
||
64 | FBTextSubstitutions["%party4health"] = function() |
||
65 | return math.floor(UnitHealth("party4")/UnitHealthMax("party4") * 100) |
||
66 | end |
||
67 | FBTextSubstitutions["%pethealth"] = function() |
||
68 | return math.floor(UnitHealth("pet")/UnitHealthMax("pet") * 100) |
||
69 | end |
||
70 | FBTextSubstitutions["%targethealth"] = function() |
||
71 | return math.floor(UnitHealth("target")/UnitHealthMax("target") * 100) |
||
72 | end |
||
73 | FBTextSubstitutions["%playermana"] = function() |
||
74 | return math.floor(UnitMana("player")/UnitManaMax("player") * 100) |
||
75 | end |
||
76 | FBTextSubstitutions["%party1mana"] = function() |
||
77 | return math.floor(UnitMana("party1")/UnitManaMax("party1") * 100) |
||
78 | end |
||
79 | FBTextSubstitutions["%party2mana"] = function() |
||
80 | return math.floor(UnitMana("party2")/UnitManaMax("party2") * 100) |
||
81 | end |
||
82 | FBTextSubstitutions["%party3mana"] = function() |
||
83 | return math.floor(UnitMana("party3")/UnitManaMax("party3") * 100) |
||
84 | end |
||
85 | FBTextSubstitutions["%party4mana"] = function() |
||
86 | return math.floor(UnitMana("party4")/UnitManaMax("party4") * 100) |
||
87 | end |
||
88 | FBTextSubstitutions["%petmana"] = function() |
||
89 | return math.floor(UnitMana("pet")/UnitManaMax("pet") * 100) |
||
90 | end |
||
91 | FBTextSubstitutions["%targetmana"] = function() |
||
92 | return math.floor(UnitMana("target")/UnitManaMax("target") * 100) |
||
93 | end |
||
94 | FBTextSubstitutions["%combopts"] = function() |
||
95 | return GetComboPoints() |
||
96 | end |
||
97 | FBTextSubstitutions["%allbagsnumslots"] = function() |
||
98 | return FBBagContents["allbagsnumslots"] |
||
99 | end |
||
100 | FBTextSubstitutions["%allbagsnumslotsused"] = function() |
||
101 | return FBBagContents["allbagsnumslotsused"] |
||
102 | end |
||
103 | FBTextSubstitutions["%allbagsnumslotsleft"] = function() |
||
104 | return FBBagContents["allbagsnumslotsleft"] |
||
105 | end |
||
106 | FBTextSubstitutions["%backpacknumslots"] = function() |
||
107 | return FBBagContents["backpacknumslots"] |
||
108 | end |
||
109 | FBTextSubstitutions["%backpacknumslotsused"] = function() |
||
110 | return FBBagContents["backpacknumslotsused"] |
||
111 | end |
||
112 | FBTextSubstitutions["%backpacknumslotsleft"] = function() |
||
113 | return FBBagContents["backpacknumslotsleft"] |
||
114 | end |
||
115 | FBTextSubstitutions["%bag1numslots"] = function() |
||
116 | return FBBagContents["bag1numslots"] |
||
117 | end |
||
118 | FBTextSubstitutions["%bag1numslotsused"] = function() |
||
119 | return FBBagContents["bag1numslotsused"] |
||
120 | end |
||
121 | FBTextSubstitutions["%bag1numslotsleft"] = function() |
||
122 | return FBBagContents["bag1numslotsleft"] |
||
123 | end |
||
124 | FBTextSubstitutions["%bag2numslots"] = function() |
||
125 | return FBBagContents["bag2numslots"] |
||
126 | end |
||
127 | FBTextSubstitutions["%bag2numslotsused"] = function() |
||
128 | return FBBagContents["bag2numslotsused"] |
||
129 | end |
||
130 | FBTextSubstitutions["%bag2numslotsleft"] = function() |
||
131 | return FBBagContents["bag2numslotsleft"] |
||
132 | end |
||
133 | FBTextSubstitutions["%bag3numslots"] = function() |
||
134 | return FBBagContents["bag3numslots"] |
||
135 | end |
||
136 | FBTextSubstitutions["%bag3numslotsused"] = function() |
||
137 | return FBBagContents["bag3numslotsused"] |
||
138 | end |
||
139 | FBTextSubstitutions["%bag3numslotsleft"] = function() |
||
140 | return FBBagContents["bag3numslotsleft"] |
||
141 | end |
||
142 | FBTextSubstitutions["%bag4numslots"] = function() |
||
143 | return FBBagContents["bag4numslots"] |
||
144 | end |
||
145 | FBTextSubstitutions["%bag4numslotsused"] = function() |
||
146 | return FBBagContents["bag4numslotsused"] |
||
147 | end |
||
148 | FBTextSubstitutions["%bag4numslotsleft"] = function() |
||
149 | return FBBagContents["bag4numslotsleft"] |
||
150 | end |
||
151 | FBTextSubstitutions["%fbs"] = function() |
||
152 | -- Replace %fbs with the source of the last event |
||
153 | if FBLastSource then |
||
154 | return FBLastSource |
||
155 | else |
||
156 | return "" |
||
157 | end |
||
158 | end |
||
159 | FBTextSubstitutions["%fbe"] = function() |
||
160 | -- Replace %fbe with the last event |
||
161 | return FBLastEvent |
||
162 | end |
||
163 |