vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local compost = CompostLib:GetInstance('compost-1') |
2 | |||
3 | local COLOR_HEX_RED = "ff0000" |
||
4 | local COLOR_HEX_ORANGE = "ff7f00" |
||
5 | local COLOR_HEX_YELLOW = "ffff00" |
||
6 | local COLOR_HEX_GREEN = "00ff00" |
||
7 | local COLOR_HEX_WHITE = "ffffff" |
||
8 | local COLOR_HEX_COPPER = "eda55f" |
||
9 | local COLOR_HEX_SILVER = "c7c7cf" |
||
10 | local COLOR_HEX_GOLD = "ffd700" |
||
11 | |||
12 | local function VersionToNumber(version) |
||
13 | if version == nil then |
||
14 | return 0 |
||
15 | elseif type(version) == "number" then |
||
16 | return version |
||
17 | end |
||
18 | local num = 0 |
||
19 | local place = 1 |
||
20 | string.gsub(version, "(%d+)", function (w) |
||
21 | num = num + tonumber(w) * math.pow(10, place * 2) |
||
22 | if place > 0 then |
||
23 | place = place - 1 |
||
24 | else |
||
25 | place = place - 2 |
||
26 | end |
||
27 | end) |
||
28 | return num |
||
29 | end |
||
30 | |||
31 | local function GetVersionPoint(version, point) |
||
32 | if version == nil then |
||
33 | return 0 |
||
34 | elseif type(version) == "number" then |
||
35 | if point == 1 then |
||
36 | return floor(version / 100) |
||
37 | elseif point == 2 then |
||
38 | return mod(floor(version), 100) |
||
39 | elseif point == 3 then |
||
40 | return mod(floor(version * 10000), 10000) |
||
41 | elseif point == 4 then |
||
42 | return mod(floor(version * 100000000), 10000) |
||
43 | elseif point < 1 then |
||
44 | return 0 |
||
45 | elseif point > 4 then |
||
46 | return mod(floor(version * math.pow(10000, point - 2)), 10000) |
||
47 | end |
||
48 | end |
||
49 | local place = 1 |
||
50 | local num = 0 |
||
51 | string.gsub(version, "(%d+)", function (w) |
||
52 | if place == point |
||
53 | then num = tonumber(w) |
||
54 | return |
||
55 | end |
||
56 | place = place + 1 |
||
57 | end) |
||
58 | return num |
||
59 | end |
||
60 | |||
61 | local function GetMajorNumber(version) |
||
62 | return GetVersionPoint(version, 1) |
||
63 | end |
||
64 | |||
65 | local function GetMinorNumber(version) |
||
66 | return GetVersionPoint(version, 2) |
||
67 | end |
||
68 | |||
69 | local function GetRevisionNumber(version) |
||
70 | return GetVersionPoint(version, 3) |
||
71 | end |
||
72 | |||
73 | local function GetTrivialNumber(version) |
||
74 | return GetVersionPoint(version, 4) |
||
75 | end |
||
76 | |||
77 | local crayon = CrayonLib:GetInstance('1.0') |
||
78 | local abacus = AbacusLib:GetInstance('1.0') |
||
79 | |||
80 | FuBarUtils = { |
||
81 | COLOR_HEX_RED = crayon.COLOR_HEX_RED, |
||
82 | COLOR_HEX_ORANGE = crayon.COLOR_HEX_ORANGE, |
||
83 | COLOR_HEX_YELLOW = crayon.COLOR_HEX_YELLOW, |
||
84 | COLOR_HEX_GREEN = crayon.COLOR_HEX_GREEN, |
||
85 | COLOR_HEX_WHITE = crayon.COLOR_HEX_WHITE, |
||
86 | COLOR_HEX_COPPER = crayon.COLOR_HEX_COPPER, |
||
87 | COLOR_HEX_SILVER = crayon.COLOR_HEX_SILVER, |
||
88 | COLOR_HEX_GOLD = crayon.COLOR_HEX_GOLD, |
||
89 | |||
90 | Colorize = function(hexColor, text) |
||
91 | return crayon:Colorize(hexColor, text) |
||
92 | end, |
||
93 | |||
94 | Red = function(text) |
||
95 | return crayon:Red(text) |
||
96 | end, |
||
97 | |||
98 | Orange = function(text) |
||
99 | return crayon:Orange(text) |
||
100 | end, |
||
101 | |||
102 | Yellow = function(text) |
||
103 | return crayon:Yellow(text) |
||
104 | end, |
||
105 | |||
106 | Green = function(text) |
||
107 | return crayon:Green(text) |
||
108 | end, |
||
109 | |||
110 | White = function(text) |
||
111 | return crayon:White(text) |
||
112 | end, |
||
113 | |||
114 | GetThresholdHexColor = function(quality, a, b, c, d, e) |
||
115 | return crayon:GetThresholdHexColor(quality, a, b, c, d, e) |
||
116 | end, |
||
117 | |||
118 | GetThresholdColor = function(quality, a, b, c, d, e) |
||
119 | return crayon:GetThresholdColor(quality, a, b, c, d, e) |
||
120 | end, |
||
121 | |||
122 | GetThresholdHexColorTrivial = function(quality, a, b, c, d, e) |
||
123 | return crayon:GetThresholdHexColorTrivial(quality, a, b, c, d, e) |
||
124 | end, |
||
125 | |||
126 | GetThresholdColorTrivial = function(quality, a, b, c, d, e) |
||
127 | return crayon:GetThresholdColorTrivial(quality, a, b, c, d, e) |
||
128 | end, |
||
129 | |||
130 | FormatMoneyExtended = function(value, colorize, textColor) |
||
131 | return abacus:FormatMoneyExtended(value, colorize, textColor) |
||
132 | end, |
||
133 | |||
134 | FormatMoneyFull = function(value, colorize, textColor) |
||
135 | return abacus:FormatMoneyFull(value, colorize, textColor) |
||
136 | end, |
||
137 | |||
138 | FormatMoneyShort = function(value, colorize, textColor) |
||
139 | return abacus:FormatMoneyShort(value, colorize, textColor) |
||
140 | end, |
||
141 | |||
142 | FormatMoneyCondensed = function(value, colorize, textColor) |
||
143 | return abacus:FormatMoneyCondensed(value, colorize, textColor) |
||
144 | end, |
||
145 | |||
146 | FormatDurationExtended = function(duration, colorize, hideSeconds) |
||
147 | return abacus:FormatDurationExtended(duration, colorize, hideSeconds) |
||
148 | end, |
||
149 | |||
150 | FormatDurationFull = function(duration, colorize, hideSeconds) |
||
151 | return abacus:FormatDurationFull(duration, colorize, hideSeconds) |
||
152 | end, |
||
153 | |||
154 | FormatDurationShort = function(duration, colorize, hideSeconds) |
||
155 | return abacus:FormatDurationShort(duration, colorize, hideSeconds) |
||
156 | end, |
||
157 | |||
158 | FormatDurationCondensed = function(duration, colorize, hideSeconds) |
||
159 | return abacus:FormatDurationCondensed(duration, colorize, hideSeconds) |
||
160 | end, |
||
161 | |||
162 | VersionToNumber = VersionToNumber, |
||
163 | GetVersionPoint = GetVersionPoint, |
||
164 | GetMajorNumber = GetMajorNumber, |
||
165 | GetMinorNumber = GetMinorNumber, |
||
166 | GetRevisionNumber = GetRevisionNumber, |
||
167 | GetTrivialNumber = GetTrivialNumber, |
||
168 | } |
||
169 | |||
170 | local old_UIDropDownMenu_AddButton = UIDropDownMenu_AddButton |
||
171 | local spacerDropDown = nil |
||
172 | function FuBarUtils.AddSpacerDropDownMenu(level) |
||
173 | if spacerDropDown ~= (level or 1) then |
||
174 | spacerDropDown = level or 1 |
||
175 | local info = compost:AcquireHash( |
||
176 | 'disabled', true |
||
177 | ) |
||
178 | old_UIDropDownMenu_AddButton(info, level or 1) |
||
179 | compost:Reclaim(info) |
||
180 | end |
||
181 | end |
||
182 | |||
183 | UIDropDownMenu_AddButton = function(info, level) |
||
184 | spacerDropDown = nil |
||
185 | old_UIDropDownMenu_AddButton(info, level) |
||
186 | end |
||
187 | |||
188 | local old_ToggleDropDownMenu = ToggleDropDownMenu |
||
189 | ToggleDropDownMenu = function(level, value, dropDownFrame, anchorName, xOffset, yOffset) |
||
190 | spacerDropDown = nil |
||
191 | old_ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset, yOffset) |
||
192 | end |
||
193 | |||
194 | print = function(...) |
||
195 | local s = "" |
||
196 | for i = 1, table.getn(arg) do |
||
197 | if s ~= "" then |
||
198 | s = s .. " " |
||
199 | end |
||
200 | if type(arg[i]) == "table" and type(arg[i][0]) == "userdata" then |
||
201 | local name = arg[i]:GetName() |
||
202 | if name == "" or name == nil then |
||
203 | name = "" |
||
204 | else |
||
205 | name = ":" .. name |
||
206 | end |
||
207 | s = s .. "<" .. arg[i]:GetObjectType() .. name .. ">" |
||
208 | else |
||
209 | s = s .. tostring(arg[i]) |
||
210 | end |
||
211 | end |
||
212 | if string.len(s) == 0 then |
||
213 | s = "\n" |
||
214 | end |
||
215 | DEFAULT_CHAT_FRAME:AddMessage(s) |
||
216 | end |
||
217 | |||
218 | local start |
||
219 | tableToString = function(t, depth) |
||
220 | if t[".recurse"] then |
||
221 | return "<recursion>" |
||
222 | end |
||
223 | t[".recurse"] = 1 |
||
224 | if depth == nil then |
||
225 | depth = 0 |
||
226 | start = GetTime() |
||
227 | end |
||
228 | if GetTime() - start >= 0.05 then |
||
229 | return "{too large}" |
||
230 | end |
||
231 | local s = "" |
||
232 | s = "{\n" |
||
233 | for k,v in pairs(t) do |
||
234 | if k ~= ".recurse" then |
||
235 | s = s .. string.rep(" ", depth + 1) |
||
236 | if type(k) == "table" then |
||
237 | s = s .. "[" .. tableToString(k, depth + 1) .. "]" |
||
238 | elseif type(k) == "string" then |
||
239 | local u = format("[%q]", k) |
||
240 | if not string.find(k, "[^A-Za-z0-9_]") and string.sub(u, 3, -3) == k then |
||
241 | s = s .. k |
||
242 | else |
||
243 | s = s .. u |
||
244 | end |
||
245 | else |
||
246 | s = s .. "[" .. tostring(k) .. "]" |
||
247 | end |
||
248 | s = s .. " = " |
||
249 | if type(v) == "table" then |
||
250 | s = s .. tableToString(v, depth + 1) |
||
251 | elseif type(v) == "string" then |
||
252 | s = s .. format("%q", v) |
||
253 | else |
||
254 | s = s .. tostring(v) |
||
255 | end |
||
256 | s = s .. ",\n" |
||
257 | end |
||
258 | end |
||
259 | s = s .. string.rep(" ", depth) .. "}" |
||
260 | t[".recurse"] = nil |
||
261 | if depth == 0 then |
||
262 | start = nil |
||
263 | end |
||
264 | return s |
||
265 | end |
||
266 | local tableToString = tableToString |
||
267 | |||
268 | printFull = function(k, t) |
||
269 | if t == nil then |
||
270 | k, t = nil, k |
||
271 | end |
||
272 | local s |
||
273 | if type(t) == "table" and type(t[0]) == "userdata" then |
||
274 | local name = t:GetName() |
||
275 | if name == "" or name == nil then |
||
276 | name = "" |
||
277 | else |
||
278 | name = ":" .. name |
||
279 | end |
||
280 | t = "<" .. t:GetObjectType() .. name .. ">" |
||
281 | end |
||
282 | if type(t) == "table" and type(t[0]) ~= "userdata" then |
||
283 | if k == nil then |
||
284 | s = tableToString(t) |
||
285 | else |
||
286 | s = k .. " = " .. tableToString(t) |
||
287 | end |
||
288 | else |
||
289 | if k == nil then |
||
290 | s = t |
||
291 | else |
||
292 | s = k .. " = " .. t |
||
293 | end |
||
294 | end |
||
295 | string.gsub(s, "[^\n]+", print) |
||
296 | end |
||
297 | |||
298 | codeposition = function(num) |
||
299 | return strsub(debugstack((num or 0) + 2, 1, 0), 0, -5) |
||
300 | end |
||
301 |