vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | DHUD_HexTable = { |
2 | ["0"] = 0, |
||
3 | ["1"] = 1, |
||
4 | ["2"] = 2, |
||
5 | ["3"] = 3, |
||
6 | ["4"] = 4, |
||
7 | ["5"] = 5, |
||
8 | ["6"] = 6, |
||
9 | ["7"] = 7, |
||
10 | ["8"] = 8, |
||
11 | ["9"] = 9, |
||
12 | ["a"] = 10, |
||
13 | ["b"] = 11, |
||
14 | ["c"] = 12, |
||
15 | ["d"] = 13, |
||
16 | ["e"] = 14, |
||
17 | ["f"] = 15 |
||
18 | } |
||
19 | |||
20 | -- hexcolor to rgb |
||
21 | function DHUD_hextodec(hex) |
||
22 | |||
23 | local r1 = tonumber(DHUD_HexTable[ string.lower(string.sub(hex,1,1)) ] * 16); |
||
24 | local r2 = tonumber(DHUD_HexTable[ string.lower(string.sub(hex,2,2)) ]); |
||
25 | local r = (r1 + r2) / 255; |
||
26 | |||
27 | local g1 = tonumber(DHUD_HexTable[ string.lower(string.sub(hex,3,3)) ] * 16); |
||
28 | local g2 = tonumber(DHUD_HexTable[ string.lower(string.sub(hex,4,4)) ]); |
||
29 | local g = (g1 + g2) / 255; |
||
30 | |||
31 | local b1 = tonumber(DHUD_HexTable[ string.lower(string.sub(hex,5,5)) ] * 16); |
||
32 | local b2 = tonumber(DHUD_HexTable[ string.lower(string.sub(hex,6,6)) ]); |
||
33 | local b = (b1 + b2) / 255; |
||
34 | |||
35 | return {r,g,b} |
||
36 | end |
||
37 | |||
38 | -- decimal to hex |
||
39 | function DHUD_DecToHex(red,green,blue) |
||
40 | if ( not red or not green or not blue ) then |
||
41 | return "ffffff" |
||
42 | end |
||
43 | |||
44 | red = floor(red * 255) |
||
45 | green = floor(green * 255) |
||
46 | blue = floor(blue * 255) |
||
47 | |||
48 | local a,b,c,d,e,f |
||
49 | |||
50 | a = DHUD_GiveHex(floor(red / 16)) |
||
51 | b = DHUD_GiveHex(math.mod(red,16)) |
||
52 | c = DHUD_GiveHex(floor(green / 16)) |
||
53 | d = DHUD_GiveHex(math.mod(green,16)) |
||
54 | e = DHUD_GiveHex(floor(blue / 16)) |
||
55 | f = DHUD_GiveHex(math.mod(blue,16)) |
||
56 | |||
57 | return a..b..c..d..e..f |
||
58 | end |
||
59 | |||
60 | function DHUD_GiveHex(dec) |
||
61 | for key, value in DHUD_HexTable do |
||
62 | if ( dec == value ) then |
||
63 | return key |
||
64 | end |
||
65 | end |
||
66 | return ""..dec |
||
67 | end |
||
68 | |||
69 | -- table copy |
||
70 | function DHUD_tablecopy(tbl) |
||
71 | if type(tbl) ~= "table" then return tbl end |
||
72 | local t = {} |
||
73 | for i,v in pairs(tbl) do |
||
74 | t[i] = DHUD_tablecopy(v) |
||
75 | end |
||
76 | table.setn(t, table.getn(tbl)) |
||
77 | return setmetatable(t, DHUD_tablecopy(getmetatable(tbl))) |
||
78 | end |
||
79 | |||
80 | -- telos mobhealth support |
||
81 | function DHUD_MobHealth_PPP(index) |
||
82 | if( index and MobHealthDB[index] ) then |
||
83 | local s, e; |
||
84 | local pts; |
||
85 | local pct; |
||
86 | |||
87 | s, e, pts, pct = string.find(MobHealthDB[index], "^(%d+)/(%d+)$"); |
||
88 | if( pts and pct ) then |
||
89 | pts = pts + 0; |
||
90 | pct = pct + 0; |
||
91 | if( pct ~= 0 ) then |
||
92 | return pts / pct; |
||
93 | end |
||
94 | end |
||
95 | end |
||
96 | return 0; |
||
97 | end |