Language:
None specified     Change language:
Pastebin: 123430
Author: Anonymous
Subject: oUF_FavHUD
Created: 2009-08-26 14:13:33
Download and save
Toggle line numbers
1--[[ 
2 Version: 1.3.0 
3 Based Code provided by oUF_Freeb 
4 Supported Plugins 
5 -- oUF_Smooth 
6 
7]] 
8local _, class = UnitClass('player') 
9local texture = "Interface\\AddOns\\oUF_FavHUD\\media\\HalM" 
10local border = "Interface\\AddOns\\oUF_FavHUD\\media\\border" 
11local font = "Interface\\AddOns\\oUF_FavHUD\\media\\font.ttf" 
12local fontsize = 15 
13local height, width = 140, 6 
14 
15-- Toggle Castbars 
16local castBars = true 
17 
18RuneFrame:Hide() --------- Hides the Rune Frame, DKs will need to get a Rune Addon 
19 
20local backdrop = { 
21 bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], 
22 insets = {top = -1, left = -1, bottom = -1, right = -1}, 
23 
24
25 
26local colors = setmetatable({ 
27 power = setmetatable({ 
28 ['MANA'] = {0.14,0.35,1}, 
29 ['RAGE'] = {0.89,0.07,0.19}, 
30 ['FOCUS'] = {.71,.43,.27}, 
31 ['ENERGY'] = {1.0,0.96,0.41}, 
32 }, {__index = oUF.colors.power}), 
33}, {__index = oUF.colors}) 
34 
35 
36 
37-- Druid Power Credits to P3lim 
38local function UpdateDruidPower(self) 
39 local bar = self.DruidPower 
40 local num, str = UnitPowerType('player') 
41 local min = UnitPower('player', (num ~= 0) and 0 or 3) 
42 local max = UnitPowerMax('player', (num ~= 0) and 0 or 3) 
43 
44 bar:SetMinMaxValues(0, max) 
45 
46 if(min ~= max) then 
47 bar:SetValue(min) 
48 bar:SetAlpha(1) 
49 
50 if(num ~= 0) then 
51 bar:SetStatusBarColor(unpack(colors.power['MANA'])) 
52 bar.Text:SetFormattedText('%d - %d%%', min, math.floor(min / max * 100)) 
53 else 
54 bar:SetStatusBarColor(unpack(colors.power['ENERGY'])) 
55 bar.Text:SetText() 
56 end 
57 else 
58 bar:SetAlpha(0) 
59 bar.Text:SetText() 
60 end 
61end 
62 
63local menu = function(self) 
64 local unit = self.unit:sub(1, -2) 
65 local cunit = self.unit:gsub("(.)", string.upper, 1) 
66 
67 if(unit == "party" or unit == "partypet") then 
68 ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..self.id.."DropDown"], "cursor", 0, 0) 
69 elseif(_G[cunit.."FrameDropDown"]) then 
70 ToggleDropDownMenu(1, nil, _G[cunit.."FrameDropDown"], "cursor", 0, 0) 
71 end 
72end 
73 
74-- Shorten Values 
75local function ShortValue(value) 
76 if value >= 1e7 then 
77 return ('%.1fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1') 
78 elseif value >= 1e6 then 
79 return ('%.2fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1') 
80 else 
81 return value 
82 end 
83end 
84 
85local playerClass = select(2, UnitClass("player")) 
86 
87-- Health Function 
88local updateHealth = function(self, event, unit, bar, min, max) 
89 if(max ~= 0) then 
90 r, g, b = self.ColorGradient(min/max, 1,0,0, 1,1,0.33, 0,1,0) 
91 end 
92 
93 if(not UnitIsConnected(unit)) then 
94 bar:SetValue(0) 
95 bar.value:SetText('|cffD7BEA5'..'Offline') 
96 elseif(unit == 'targettarget' or unit == 'pet' or unit == 'focus') then 
97 bar.value:SetText() 
98 elseif(UnitIsDead(unit)) then 
99 bar.value:SetText('|cffD7BEA5'..'Dead') 
100 elseif(UnitIsGhost(unit)) then 
101 bar.value:SetText('|cffD7BEA5'..'Ghost') 
102 else 
103    if (unit == "player") then 
104 bar.value:SetFormattedText('|cff%02x%02x%02x%d|r \n|cff00ff00%s|r', r*255, g*255, b*255, (min/max)*100, ShortValue(min)) 
105 end 
106    if (unit == "target") then 
107 bar.value:SetFormattedText("%s", ShortValue(min)) 
108 end 
109 end 
110 
111 -- BarColor 
112    if (unit == "player") then 
113 bar:SetStatusBarColor(0,1,0) 
114 end 
115     if(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) or not UnitIsConnected(unit)) then 
116 bar:SetStatusBarColor(.6, .6, .6) 
117 else 
118 local t, r, g, b 
119 t = UnitIsPlayer(unit) and self.colors.class[select(2, UnitClass(unit))] 
120 if not t then 
121 if UnitPlayerControlled(unit) then 
122 r, g, b = 0, 1, 0 
123 else 
124 r, g, b = UnitSelectionColor(unit) 
125 end 
126 else 
127 r, g, b = t[1], t[2], t[3] 
128 end 
129 bar:SetStatusBarColor(r, g, b) 
130 bar:SetBackdropColor(r/2.5,g/2.5,b/2.5,0.8) 
131 end 
132end 
133 
134-- Power Function 
135local updatePower = function(self, event, unit, bar, min, max) 
136    local num, str = UnitPowerType('player') 
137        if(max ~= 0) and (playerClass=="ROGUE") then 
138    r, g, b = self.ColorGradient(min/max, 1,0,0, 0.9,0.5,0.1, 1.0,0.96,0.41) 
139 else 
140   if(max ~= 0) and (playerClass=="WARRIOR") then 
141       r, g, b = self.ColorGradient(min/max, 0.7,0.3,0.3, 0.9,0.2,0.2, 1,0,0) 
142   else 
143      if(max ~= 0) and (playerClass=="DRUID") then 
144         if (num == 0) then --mana 
145            r, g, b = self.ColorGradient(min/max, 1,0,0, 0.14,0.35,1, 0.14,0.35,1) 
146         end 
147         if (num == 1) then --rage 
148            r, g, b = self.ColorGradient(min/max, 0.7,0.3,0.3, 0.9,0.2,0.2, 1,0,0) 
149         end 
150         if (num == 3) then --energy 
151            r, g, b = self.ColorGradient(min/max, 1,0,0, 0.9,0.5,0.1, 1.0,0.96,0.41) 
152         end 
153          else 
154             if(max ~= 0) then 
155                r, g, b = self.ColorGradient(min/max, 1,0,0, 0.6,0,0.6, 0.14,0.35,1) 
156             end 
157      end 
158       end 
159    end 
160 
161 if(min==0 or UnitIsDead(unit) or UnitIsGhost(unit) or not UnitIsConnected(unit)) then 
162  bar.value:SetText() 
163  else 
164    if (unit == "player") then 
165 bar.value:SetFormattedText("|cff%02x%02x%02x%d|r\n%s", r*255, g*255, b*255, (min/max)*100, ShortValue(min)) 
166 end 
167    if (unit == "target") then 
168 bar.value:SetFormattedText("%s", ShortValue(min)) 
169 end 
170 end 
171 local _, pType = UnitPowerType(unit) 
172 local color = self.colors.power[pType] 
173 if(color) then 
174   bar.value:SetTextColor(color[1], color[2], color[3]) 
175   bar:SetStatusBarColor(color[1], color[2], color[3]) 
176 
177 end 
178end 
179 
180-- Style 
181local func = function(self, unit) 
182 self.colors = colors 
183 self.menu = menu 
184 self.ignoreHealComm = true 
185 
186 self:EnableMouse(true) 
187 self:SetScript("OnEnter", UnitFrame_OnEnter) 
188 self:SetScript("OnLeave", UnitFrame_OnLeave) 
189 self:RegisterForClicks"anyup" 
190 self:SetAttribute("*type2", "menu") 
191 
192 -- Health 
193 local hp = CreateFrame"StatusBar" 
194 hp:SetOrientation("VERTICAL") 
195    hp:SetHeight(height) 
196 hp:SetStatusBarTexture(texture) 
197 -- Smooth 
198 hp.Smooth = true 
199 hp.frequentUpdates = true 
200 hp:SetParent(self) 
201 hp:SetPoint"TOP" 
202 hp:SetPoint"LEFT" 
203 hp:SetPoint"RIGHT" 
204 
205 local hpbg = hp:CreateTexture(nil, "BORDER") 
206 hpbg:SetAllPoints(hp) 
207 -- Background color 
208 hpbg:SetTexture(.08, .08, .08) 
209 self:SetBackdrop(backdrop) 
210 self:SetBackdropColor(0, 0, 0) 
211 
212 -- Health Text 
213 local hpp = hp:CreateFontString(nil, "OVERLAY") 
214 hpp:SetFont(font, fontsize) 
215 hpp:SetShadowOffset(1, -1) 
216 hpp:SetTextColor(1, 1, 1) 
217   if (unit == "player") then 
218   hpp:SetPoint("LEFT", hp, "RIGHT", 20, -80) 
219   hpp:SetJustifyH"LEFT" 
220 end 
221 if (unit == "target") then 
222   hpp:SetPoint("RIGHT", hp, "LEFT", -20, -86) 
223   hpp:SetJustifyH"RIGHT" 
224 end 
225 hp.bg = hpbg 
226 hp.value = hpp 
227 self.Health = hp 
228 self.OverrideUpdateHealth = updateHealth 
229 -- Power 
230  local pp = CreateFrame"StatusBar" 
231  pp:SetOrientation("VERTICAL") 
232  if (unit == "player") then 
233   pp:SetPoint('CENTER', UIParent, 'CENTER', -180, -10) 
234  end 
235  if (unit == "target") then 
236   pp:SetPoint('CENTER', UIParent, 'CENTER', 182, -10) 
237  end 
238  pp:SetHeight(height) 
239  pp:SetWidth(width) 
240  pp:SetStatusBarTexture(texture) 
241      pp.frequentUpdates = true 
242  -- Smooth 
243  pp.Smooth = false 
244  pp:SetParent(self) 
245  pp:SetBackdrop(backdrop) 
246  pp:SetBackdropColor(0, 0, 0) 
247 
248  local ppbg = pp:CreateTexture(nil, "BORDER") 
249  ppbg:SetAllPoints(pp) 
250  ppbg:SetTexture(.08, .08, .08) 
251  ppbg.multiplier = .3 
252 
253  -- Power Text 
254  local ppp = pp:CreateFontString(nil, "OVERLAY") 
255  ppp:SetFont(font, fontsize) 
256  ppp:SetShadowOffset(1, -1) 
257   if (unit == "player") then 
258   ppp:SetPoint("LEFT", hp, "RIGHT", 20, -110) 
259   ppp:SetJustifyH"LEFT" 
260 end 
261 if (unit == "target") then 
262   ppp:SetPoint("RIGHT", hp, "LEFT", -20, -101) 
263   ppp:SetJustifyH"RIGHT" 
264 end 
265  ppp:SetTextColor(1, 1, 1) 
266 
267  pp.value = ppp 
268  pp.bg = ppbg 
269  self.Power = pp 
270  self.PostUpdatePower = updatePower 
271 
272 -- CastBar 
273 if(castBars)then 
274  if not (unit == "targettarget") then 
275 local cb = CreateFrame"StatusBar" 
276 cb:SetOrientation("VERTICAL") 
277 cb:SetStatusBarTexture(texture) 
278 -- CastBar Color 
279 cb:SetStatusBarColor(.9,.7,0) 
280 cb:SetWidth(width) 
281 cb:SetHeight(height) 
282 cb:SetParent(self) 
283 if (unit == "player") then 
284   cb:SetPoint('CENTER', UIParent, 'CENTER', -173, -10) 
285 end 
286 if (unit == "target") then 
287   cb:SetPoint('CENTER', UIParent, 'CENTER', 175, -10) 
288 end 
289 cb:SetBackdrop(backdrop) 
290    cb:SetBackdropColor(0, 0, 0) 
291 cb:SetToplevel(false) 
292 self.Castbar = cb 
293 self.Castbar.bg = self.Castbar:CreateTexture(nil, 'BORDER') 
294 self.Castbar.bg:SetAllPoints(self.Castbar) 
295 self.Castbar.bg:SetTexture(.1, .1, .1) 
296  end 
297 end 
298 
299 if(not unit) then 
300 self.Range = true 
301 self.inRangeAlpha = 1 
302 self.outsideRangeAlpha = .5 
303 end 
304 
305 self:SetAttribute('initial-height', height) 
306 self:SetAttribute('initial-width', width) 
307 self.disallowVehicleSwap = true 
308 self.PostCreateAuraIcon = auraIcon 
309 return self 
310end 
311 
312oUF:RegisterStyle("FavHUD", func) 
313 
314oUF:SetActiveStyle"FavHUD" 
315 
316local player = oUF:Spawn('player'):SetPoint('CENTER', UIParent, 'CENTER', -187, -10) -- ñïàâíèì ôðåéì èãðîêà 
317local target = oUF:Spawn('target'):SetPoint('CENTER', UIParent, 'CENTER',  189, -10) -- ... öåëè 
318 
319 
320 
Download and save
Toggle line numbers
Thread:
[123430] oUF_FavHUD by Anonymous at 2009-08-26 14:13:33
Tip: Click the line numbers to toggle highliting on that line.

Paste followup:

Language:
Author:
Subject:


    Tabstop:     bigger biggest
Note: You can prefix a line with "@@@" to highlight it.