Language:
Lua     Change language:
Pastebin: 108225
Author: jadakren
Subject: ouf maintank
Created: 2009-02-13 01:04:22
Download and save
Toggle line numbers
1 
2BuffFrame:UnregisterAllEvents() 
3BuffFrame:Hide() 
4TemporaryEnchantFrame:Hide() 
5 
6local layoutName = "Freebgrid" 
7local layoutPath = "Interface\\Addons\\oUF_"..layoutName 
8local mediaPath = layoutPath.."\\media\\" 
9 
10local texture = mediaPath.."gradient" 
11local hightlight = mediaPath.."white" 
12 
13local font,fontsize = mediaPath.."visitor.ttf",9 
14local height, width = 35, 35 
15local playerClass = select(2, UnitClass("player")) 
16 
17-- Vertical health? 
18local verticalhp = true 
19-- Debuff icon size 
20local iconsize = 20 
21-- Filter debuffs by your class? 
22local filterdebuff = true 
23local numberize = function(val) 
24    if(val >= 1e3) then 
25        return ("%.1fk"):format(val / 1e3
26    elseif (val >= 1e6) then 
27        return ("%.1fm"):format(val / 1e6
28    else 
29        return val 
30    end 
31end 
32 
33local backdrop = { 
34    bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], tile = true, tileSize = 16
35    insets = {top = -2, left = -2, bottom = -2, right = -2}
36} 
37 
38local colors = { 
39    class ={ 
40        ["DEATHKNIGHT"] = { 0.77, 0.12, 0.23 }
41        ["DRUID"] = { 1.0 , 0.49, 0.04 }
42        ["HUNTER"] = { 0.67, 0.83, 0.45 }
43        ["MAGE"] = { 0.41, 0.8 , 0.94 }
44        ["PALADIN"] = { 0.96, 0.55, 0.73 }
45        ["PRIEST"] = { 1.0 , 1.0 , 1.0 }
46        ["ROGUE"] = { 1.0 , 0.96, 0.41 }
47        ["SHAMAN"] = { 0,0.86,0.73 }
48        ["WARLOCK"] = { 0.58, 0.51, 0.7 }
49        ["WARRIOR"] = { 0.78, 0.61, 0.43 }
50    }
51} 
52setmetatable(colors.class, { 
53    __index = function(self, key) 
54        return { 0.78, 0.61, 0.43 } 
55    end 
56}
57local function Hex(r, g, b) 
58    if type(r) == "table" then 
59        if r.r then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end 
60    end 
61    return string.format("|cff%02x%02x%02x", r*255, g*255, b*255
62end 
63 
64local GetClassColor = function(unit) 
65    return unpack(colors.class[select(2, UnitClass(unit))]) 
66end 
67 
68local menu = function(self) 
69    local unit = self.unit:sub(1, -2
70    local cunit = self.unit:gsub("(.)", string.upper, 1
71 
72    if(unit == "party" or unit == "partypet" or self.id == nil) then 
73        ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..self.id.."DropDown"], "cursor", 0, 0
74    elseif(_G[cunit.."FrameDropDown"]) then 
75        ToggleDropDownMenu(1, nil, _G[cunit.."FrameDropDown"], "cursor", 0, 0
76    end 
77end 
78 
79-- Threat Function 
80function UpdateThreat(self, event, unit) 
81    local unitTarget = (unit =='player' and "target" or unit.."target"
82    local isTanking, status, threatpct, rawthreatpct, threatvalue = UnitDetailedThreatSituation(unit, unitTarget); 
83    if not(rawthreatpct == nil) then 
84        self.Threat:SetText( Hex(GetThreatStatusColor(status)) .. string.format("%.0f", rawthreatpct ) .. "|r"
85    else 
86        self.Threat:SetText(''
87    end 
88end 
89 
90-- Health Function 
91local updateHealth = function(self, event, unit, bar, min, max) 
92    if(max ~= 0)then 
93      r,g,b = self.ColorGradient((min/max), .9,.1,.1, .8,.8,.1, 1,1,1
94    end 
95    bar.value:SetTextColor(r,g,b) 
96    if UnitIsDeadOrGhost(unit) or not UnitIsConnected(unit) then 
97        bar.bg:SetVertexColor(0.3, 0.3, 0.3
98    else 
99        bar.bg:SetVertexColor(GetClassColor(unit)) 
100    end 
101 
102end 
103function combatFeedbackText(self) 
104    self.CombatFeedbackText = self.Health:CreateFontString(nil, "OVERLAY"
105    self.CombatFeedbackText:SetPoint("CENTER", self.Health, "CENTER", 0, 0
106    self.CombatFeedbackText:SetFont(font, fontsize, "OUTLINE"
107    self.CombatFeedbackText.maxAlpha = .8 
108 
109end 
110 
111local OnEnter = function(self) 
112    UnitFrame_OnEnter(self) 
113--  self.Highlight:Show() 
114end 
115 
116local OnLeave = function(self) 
117    UnitFrame_OnLeave(self) 
118--  self.Highlight:Hide() 
119end 
120local function updateBanzai(self, unit, aggro) 
121    if self.unit ~= unit then return end 
122    if aggro == 1 then 
123        self.BanzaiIndicator:Show() 
124    else 
125        self.BanzaiIndicator:Hide() 
126    end 
127end 
128 
129-- Style 
130local func = function(self, unit) 
131    self.menu = menu 
132    self:EnableMouse(true
133    self:SetScript("OnEnter", OnEnter) 
134    self:SetScript("OnLeave", OnLeave) 
135    self:RegisterForClicks"anyup" 
136    self:SetAttribute("*type2", "menu"
137 
138--==========-- 
139--  HEALTH  -- 
140--==========-- 
141    local hp = CreateFrame"StatusBar" 
142    hp:SetHeight(height) 
143    hp:SetStatusBarTexture(texture) 
144    hp:SetOrientation("VERTICAL"
145 
146    hp:SetStatusBarColor(0, 0, 0
147    hp:SetAlpha(0.6
148--  hp:SetBlendMode("ADD") 
149    hp.frequentUpdates = true 
150 
151    hp:SetParent(self) 
152    hp:SetPoint"TOPLEFT" 
153    hp:SetPoint"BOTTOMRIGHT" 
154 
155    local hpbg = hp:CreateTexture(nil, "BORDER"
156    hpbg:SetAllPoints(hp) 
157    hpbg:SetTexture(texture) 
158 
159    self:SetBackdrop(backdrop) 
160    self:SetBackdropColor(0, 0, 0, .8
161 
162    -- Health Text 
163    local hpp = hp:CreateFontString(nil, "OVERLAY"
164          hpp:SetFont(font, 11
165          hpp:SetShadowOffset(1,-1
166          hpp:SetPoint("CENTER"
167          hpp:SetJustifyH("CENTER"
168    self:Tag(hpp, "[raidhp]"
169 
170    hp.bg = hpbg 
171    hp.value = hpp 
172    self.Health = hp 
173    self.OverrideUpdateHealth = updateHealth 
174 
175--==========-- 
176--  POWER   -- 
177--==========-- 
178 
179--==========-- 
180--  ICONS   -- 
181--==========-- 
182--Leader Icon 
183    self.Leader = self.Health:CreateTexture(nil, "OVERLAY"
184    self.Leader:SetPoint("TOPLEFT", self, 0, 8
185    self.Leader:SetHeight(16
186    self.Leader:SetWidth(16
187 
188-- Raid Icon 
189    self.RaidIcon = self.Health:CreateTexture(nil, "OVERLAY"
190    self.RaidIcon:SetPoint("TOP", self, 0, 8
191    self.RaidIcon:SetHeight(16
192    self.RaidIcon:SetWidth(16
193 
194-- DebuffHidghtlight 
195    self.DebuffHighlightBackdrop = true 
196    self.DebuffHighlightAlpha = .5 
197 
198    if(filterdebuff)then 
199      self.DebuffHighlightFilter = true 
200    end 
201 
202    if(not unit) then 
203        self.Range = true 
204        self.inRangeAlpha = 1 
205        self.outsideRangeAlpha = .4 
206    end 
207 
208    self.ReadyCheck = self.Health:CreateTexture(nil, "OVERLAY"
209    self.ReadyCheck:SetPoint("TOPRIGHT", self, 0, 8
210    self.ReadyCheck:SetHeight(16
211    self.ReadyCheck:SetWidth(16
212 
213    self.Threat = self.Health:CreateFontString(nil, "OVERLAY"
214    self.Threat:SetFont(font, fontsize, "OUTLINE"
215    self.Threat:SetPoint('BOTTOM',self, 0, 0
216    self.Threat:SetJustifyH("CENTER"
217    self.PostUpdateThreat = UpdateThreat 
218 
219    self.AuraIndicators = true 
220 
221    self:SetAttribute('initial-height', height) 
222    self:SetAttribute('initial-width', width) 
223---Aggro Indicator 
224    self.Banzai = updateBanzai 
225    self.BanzaiIndicator = self.Health:CreateTexture(nil, "OVERLAY"
226    self.BanzaiIndicator:SetPoint("TOPRIGHT", self, 0, 0
227    self.BanzaiIndicator:SetHeight(4
228    self.BanzaiIndicator:SetWidth(4
229    self.BanzaiIndicator:SetTexture(1, .25, .25
230    self.BanzaiIndicator:Hide() 
231 
232    return self 
233end 
234 
235oUF:RegisterStyle("Freebgrid", func) 
236 
237oUF:SetActiveStyle"Freebgrid" 
238 
239 
240local bottom = 0 
241local raid = {} 
242for i = 1, 5 do 
243    local group = oUF:Spawn('header', 'oUF_Group'..i) 
244    group:SetManyAttributes( 
245        "groupFilter", tostring(i), 
246        "showRaid", true
247        "yOffSet", -5
248        "xOffSet", 5
249        "point", "LEFT"
250        "initial-height", 28
251        "initial-width", 48 
252    ) 
253 
254    table.insert(raid, group) 
255    if(i == 1) then 
256        group:SetManyAttributes('showParty', true, 'showPlayer', true
257 
258        if(GetNumRaidMembers() < 1) then 
259            group:SetAttribute("template", "oUF_Group"
260            bottom = 50 
261        end 
262 
263        if(oUF.units.player)then 
264            print("oUF_Player found, postioning in relation to oUF_Player"
265            group:SetPoint('BOTTOM', oUF.units.player, "TOP", 0, 35 + bottom) 
266        else 
267            print("no oUF_Player found, postioning in relation to UI_Parent"
268            group:SetPoint('BOTTOM', UIParent, "BOTTOM", 0, 165 + bottom) 
269        end 
270 
271    else 
272        group:SetPoint('BOTTOMLEFT', raid[i-1], 'TOPLEFT', 0, 4
273    end 
274    group:Show() 
275end 
276 
277local function CreateStyle(self, unit) 
278 
279    self:RegisterForClicks('AnyUp'
280 
281    self:SetScript('OnEnter', UnitFrame_OnEnter) 
282 
283    self:SetScript('OnLeave', UnitFrame_OnLeave) 
284 
285 
286 
287    self:SetAttribute('initial-height', 20
288 
289    self:SetAttribute('initial-width', 120
290 
291 
292 
293    self:SetBackdrop(backdrop) 
294 
295    self:SetBackdropColor(0, 0, 0
296 
297 
298 
299    self.Health = CreateFrame('StatusBar', nil, self) 
300 
301    self.Health:SetAllPoints(self) 
302 
303    self.Health:SetStatusBarTexture(texture) 
304 
305    self.Health.colorDisconnected = true 
306 
307    self.Health.colorClass = true 
308 
309 
310 
311    self.Health.bg = self.Health:CreateTexture(nil, 'BORDER'
312 
313    self.Health.bg:SetAllPoints(self.Health) 
314 
315    self.Health.bg:SetTexture([=[Interface\ChatFrame\ChatFrameBackground]=]
316 
317    self.Health.bg.multiplier = 0.3 
318 
319 
320 
321    local health = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight'
322 
323    health:SetPoint('RIGHT', -3, 0
324 
325    self:Tag(health, '[raidhp]'
326 
327    local name = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightLeft'
328 
329    name:SetPoint('RIGHT', self, 'LEFT', -5, 0
330 
331    self:Tag(name, '[name] |cff00ffff[raidtargetname] [raidtargeticon]'
332 
333 
334    self.Threat = self.Health:CreateFontString(nil, "OVERLAY"
335    self.Threat:SetFont(font, 11, "OUTLINE"
336    self.Threat:SetPoint('LEFT',self, 0, 0
337    self.Threat:SetJustifyH("LEFT"
338    self.PostUpdateThreat = UpdateThreat 
339 
340    self.AuraIndicators = true 
341 
342 
343    self.disallowVehicleSwap = true 
344 
345    if(not unit) then 
346        self.Range = true 
347        self.inRangeAlpha = 1 
348        self.outsideRangeAlpha = .4 
349    end 
350end 
351 
352 
353 
354oUF:RegisterStyle('PerfectM', CreateStyle) 
355 
356oUF:SetActiveStyle('PerfectM'
357 
358 
359 
360local tank = oUF:Spawn('header', 'oUF_MainTank'
361 
362tank:SetManyAttributes('showRaid', true, 'groupFilter', 'MAINTANK', 'yOffset', -5
363 
364tank:SetPoint('BOTTOMRIGHT', UIParent, 'BOTTOMRIGHT',-10, 20
365 
366tank:Show() 
367 
368 
369 
370local assist = oUF:Spawn('header', 'oUF_MainAssist'
371 
372assist:SetManyAttributes('showRaid', true, 'groupFilter', 'MAINASSIST', 'yOffset', -5
373 
374assist:SetPoint('BOTTOM', tank, 'TOP', 0, 10
375 
376assist:Show() 
Download and save
Toggle line numbers
Thread:
[108225] ouf maintank by jadakren at 2009-02-13 01:04:22
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.