Language:
Lua     Change language:
Pastebin: 86057
Author: Adalyn
Subject: oUF
Created: 2008-04-19 19:30:20
Download and save
Toggle line numbers
1--[[------------------------------------------------------------------------- 
2  Trond A Ekseth grants anyone the right to use this work for any purpose, 
3  without any conditions, unless such conditions are required by law. 
4---------------------------------------------------------------------------]] 
5local select = select 
6local UnitClass = UnitClass 
7local UnitLevel = UnitLevel 
8local UnitIsDead = UnitIsDead 
9local UnitIsPVP = UnitIsPVP 
10local UnitIsGhost = UnitIsGhost 
11local UnitIsPlayer = UnitIsPlayer 
12local UnitReaction = UnitReaction 
13local UnitIsConnected = UnitIsConnected 
14local UnitCreatureType = UnitCreatureType 
15local UnitClassification = UnitClassification 
16local UnitReactionColor = UnitReactionColor 
17local RAID_CLASS_COLORS = RAID_CLASS_COLORS 
18--[[textures and font and stuff]]-- 
19local buffborder = "Interface\\AddOns\\rTextures\\gloss" 
20local tex = "Interface\\Addons\\rTextures\\statusbar" 
21local font = "Interface\\Addons\\rTextures\\font.ttf" 
22local height, width = 22, 220 
23 
24--[[core menu]]-- 
25local menu = function(self) 
26    local unit = self.unit:sub(1, -2
27    local cunit = self.unit:gsub("(.)", string.upper, 1
28 
29    if(unit == "party" or unit == "partypet") then 
30        ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..self.id.."DropDown"], "cursor", 0, 0
31    elseif(_G[cunit.."FrameDropDown"]) then 
32        ToggleDropDownMenu(1, nil, _G[cunit.."FrameDropDown"], "cursor", 0, 0
33    end 
34end 
35 
36--[[Update Names]]-- 
37local updateName = function(self, event, unit) 
38if(self.unit ~= unit) then return end 
39 
40    local name = UnitName(unit) 
41    local lvl = UnitLevel(unit) 
42 
43    self.Name:SetTextColor(0.6, 0.6, 0.6
44 
45    if UnitReactionColor[UnitReaction(unit, "player")] then 
46      local color = UnitReactionColor[UnitReaction(unit, "player")] 
47      self.Name:SetTextColor(color.r, color.g, color.b) 
48    end 
49 
50    --if(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) or not UnitIsConnected(unit)) then 
51    --self.Name:SetTextColor(.5, .5, .5)     
52    --end 
53 
54    if UnitIsPlayer(unit) then 
55      local color = UnitIsPlayer(unit) and RAID_CLASS_COLORS[select(2, UnitClass(unit))] 
56      self.Name:SetTextColor(color.r, color.g, color.b) 
57    end 
58 
59    if(unit == "target") then 
60      if(UnitClassification(unit)=="worldboss") then 
61      self.Name:SetText("b++ "..name) 
62      elseif(UnitClassification(unit)=="rareelite") then 
63      self.Name:SetText(lvl.."r+ "..name) 
64      elseif(UnitClassification(unit)=="elite") then 
65      self.Name:SetText(lvl.."+ "..name) 
66      elseif(UnitClassification(unit)=="rare") then 
67      self.Name:SetText(lvl.."r "..name) 
68      else 
69      self.Name:SetText(lvl.." "..name) 
70      end 
71    else 
72      self.Name:SetText(name) 
73    end 
74 
75    if(UnitIsDead(unit)) then 
76        self.Name:SetTextColor(0.6, 0.6, 0.6
77    elseif(UnitIsGhost(unit)) then 
78        self.Name:SetTextColor(0.6, 0.6, 0.6
79    elseif(not UnitIsConnected(unit)) then 
80        self.Name:SetTextColor(0.6, 0.6, 0.6
81    end 
82end 
83 
84--[[Update Health]]-- 
85local updateHealth = function(self, event, bar, unit, min, max) 
86    local health = oUF.colors.health 
87    local min, max, bar, color 
88    if(self.unit ~= unit) then return end 
89 
90    min, max = UnitHealth(unit), UnitHealthMax(unit) 
91 
92    bar = self.Health 
93 
94    bar:SetMinMaxValues(0, max) 
95    bar:SetValue(min) 
96 
97    if(unit == "pet" and GetPetHappiness()) then 
98            color = happiness[GetPetHappiness()] 
99        elseif(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) or not UnitIsConnected(unit)) then 
100            color = health[1
101        else 
102            color = UnitIsPlayer(unit) and RAID_CLASS_COLORS[select(2, UnitClass(unit))] or UnitReactionColor[UnitReaction(unit, "player")] 
103            --color = health[2] 
104        end 
105        if(color) then 
106            bar:SetStatusBarColor(color.r, color.g, color.b) 
107 
108            if(bar.bg) then 
109                --bar.bg:SetVertexColor(color.r*.5, color.g*.5, color.b*.5) 
110                bar.bg:SetVertexColor(1,1,1,0.3
111            end 
112        end 
113 
114    local c = max - min 
115    local d = floor(min/max*100
116 
117    bar.value:SetTextColor(1,1,1
118 
119    --color = UnitReactionColor[UnitReaction(unit, "player")] 
120    --bar.value:SetTextColor(color.r, color.g, color.b) 
121 
122    --if(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) or not UnitIsConnected(unit)) then 
123    --   bar.value:SetTextColor(.5, .5, .5)   
124    --end 
125 
126    if UnitIsPlayer(unit) then 
127      local color = UnitIsPlayer(unit) and RAID_CLASS_COLORS[select(2, UnitClass(unit))] 
128      bar.value:SetTextColor(color.r, color.g, color.b) 
129    end 
130 
131    if(UnitIsDead(unit)) then 
132        bar.value:SetText"Dead" 
133        bar.value:SetTextColor(0.6, 0.6, 0.6
134    elseif(UnitIsGhost(unit)) then 
135        bar.value:SetText"Ghost" 
136        bar.value:SetTextColor(0.6, 0.6, 0.6
137    elseif(not UnitIsConnected(unit)) then 
138        bar.value:SetText"Offline" 
139        bar.value:SetTextColor(0.6, 0.6, 0.6
140    elseif(UnitIsEnemy("player",unit)) then 
141        if(c > 0) then 
142            bar.value:SetText(max-c.."%"
143        else 
144            bar.value:SetText(max.."%"
145        end 
146    elseif(unit == "pet")then 
147        if(c > 0) then 
148            bar.value:SetText(max-c.." / "..max) 
149        else 
150            bar.value:SetText(max) 
151        end 
152    elseif(UnitIsPlayer(unit)) then 
153        bar.value:SetText(min.." . "..d.."%"
154    else 
155        --bar.value:SetText(d.."%") 
156    end 
157end 
158 
159--[[Main Power Func]]-- 
160local updatePower = function(self, event, bar, unit, min, max) 
161    local power = oUF.colors.power 
162    local happiness = oUF.colors.happiness 
163    local min, max, bar, color 
164 
165    if(self.unit ~= unit) then return end 
166        min, max = UnitMana(unit), UnitManaMax(unit) 
167        bar = self.Power 
168 
169        local c = max - min 
170        local d = floor(min/max*100
171 
172        bar:SetMinMaxValues(0, max) 
173        bar:SetValue(min) 
174 
175        color = power[UnitPowerType(unit)] 
176 
177        if(color) then 
178            bar:SetStatusBarColor(color.r, color.g, color.b) 
179            if(bar.bg) then 
180                bar.bg:SetVertexColor(color.r*0.5, color.g*0.5, color.b*0.5
181            end 
182        end 
183 
184        bar.value:SetTextColor(1, 1, 1
185 
186            if(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) or not UnitIsConnected(unit)) then 
187        bar.value:SetTextColor(.5, .5, .5
188    end 
189 
190    if UnitIsPlayer(unit) then 
191      local color = UnitIsPlayer(unit) and RAID_CLASS_COLORS[select(2, UnitClass(unit))] 
192      bar.value:SetTextColor(color.r, color.g, color.b) 
193    end 
194 
195    if(min < 0) then 
196        bar.value:SetText() 
197    elseif(UnitIsDead(unit)) then 
198        bar.value:SetText() 
199    elseif(UnitIsGhost(unit)) then 
200        bar.value:SetText() 
201    elseif(not UnitIsConnected(unit)) then 
202        bar.value:SetText() 
203    elseif(unit == "player") then 
204      local c = max - min 
205      bar.value:SetText(min.." . "
206    else 
207        local c = max - min 
208        if(c > 0) then 
209            bar.value:SetText(max-c.." | "
210        else 
211            bar.value:SetText(max.." | "
212        end 
213    end 
214 
215end 
216 
217--[[Auras reskin code ]]-- 
218local auraIcon = function(self, button) 
219    button.icon:SetTexCoord(.07, .93, .07, .93
220 
221    local tex = button:CreateTexture(nil, "OVERLAY"
222    tex:SetTexture(buffborder) 
223    tex:SetAllPoints(button) 
224 
225        -- make it color right  
226    if(button.overlay) then 
227        button.overlay:Hide() 
228        button.overlay = tex 
229    else 
230        tex:SetVertexColor(.25,.25,.35
231    end 
232end 
233 
234--[[Aura Offset]]-- 
235local auraOffset = function(self, icons, x) 
236        local total, col, row, size, anchor, button, growthx, growthy, cols, rows 
237        if(icons and x > 0) then 
238            col = 0 
239            row = 0 
240            size = icons.size or 16 
241            anchor = icons.initialAnchor or "BOTTOMLEFT" 
242            growthx = (icons["growth-x"] == "LEFT" and -1.1) or 1.1 -- This is the offset  
243            growthy = (icons["growth-y"] == "DOWN" and -1.1) or 1.1 -- This is the offset  
244            cols = math.floor(icons:GetWidth() / size) 
245            rows = math.floor(icons:GetHeight() / size) 
246 
247            for i = 1, x do 
248                button = icons[i] 
249                button:ClearAllPoints() 
250                button:SetPoint(anchor, icons, anchor, col * size * growthx, row * size * growthy) 
251 
252                if(col >= cols) then 
253                    col = 0 
254                    row = row + 1 
255                else 
256                    col = col + 1 
257                end 
258            end 
259        end 
260    end 
261 
262--[[Main Layout Func]]-- 
263local func = function(settings, self, unit) 
264    local hp = CreateFrame("StatusBar"
265    local pp = CreateFrame("StatusBar"
266    local hpbg = hp:CreateTexture(nil, "BORDER"
267    local ppbg = pp:CreateTexture(nil, "BORDER"
268    local hpp = hp:CreateFontString(nil, "OVERLAY"
269    local ppp = pp:CreateFontString(nil, "OVERLAY"
270 
271    local leader = self:CreateTexture(nil, "OVERLAY"
272    local name = hp:CreateFontString(nil, "OVERLAY"
273    local level = hp:CreateFontString(nil, "OVERLAY"
274 
275    self.menu = menu 
276 
277    self:EnableMouse(true
278    self:SetMovable(true
279 
280    self:SetScript("OnEnter", UnitFrame_OnEnter) 
281    self:SetScript("OnLeave", UnitFrame_OnLeave) 
282    self:SetScript("OnMouseDown", function(self) if(IsAltKeyDown()) then self:StartMoving() end end
283    self:SetScript("OnMouseUp", function(self) self:StopMovingOrSizing() end
284 
285    self:RegisterForClicks"anyup" 
286    self:SetAttribute("*type2", "menu"
287 
288    hp:SetHeight(24
289    hp:SetStatusBarTexture(tex) 
290    hp:SetStatusBarColor(.10, .10, .12
291 
292    hp:SetParent(self) 
293    hp:SetPoint"TOP" 
294    hp:SetPoint"LEFT" 
295    hp:SetPoint"RIGHT" 
296    hp:SetBackdrop({ 
297            bgFile ="Interface\\ChatFrame\\ChatFrameBackground", tile = true, tileSize = 16
298            insets = {left = -1.5, right = -1.5, top = -1.5, bottom = -1.5}
299        }
300    hp:SetBackdropColor(0, 0, 0, 1
301 
302 
303    hpbg:SetAllPoints(hp) 
304    hpbg:SetTexture(0, 0, 0, .5
305 
306    hpp:SetFont(font, 11
307    hpp:SetShadowOffset(1, -1
308    hpp:SetTextColor(1, 1, 1
309 
310    hp.bg = hpbg 
311    hp.value = hpp 
312    self.Health = hp 
313    self.OverrideUpdateHealth = updateHealth 
314 
315    pp:SetHeight(6
316    pp:SetStatusBarTexture(tex) 
317    pp:SetStatusBarTexture(tex) 
318    pp:SetStatusBarColor(.25, .25, .35
319 
320    pp:SetParent(self) 
321    pp:SetPoint"LEFT" 
322    pp:SetPoint"RIGHT" 
323    pp:SetPoint("TOP", hp, "BOTTOM", 0, -1.35
324    pp:SetBackdrop({ 
325            bgFile ="Interface\\ChatFrame\\ChatFrameBackground", tile = true, tileSize = 16
326            insets = {left = -1.5, right = -1.5, top = -1.5, bottom = -1.5}
327        }
328    pp:SetBackdropColor(0, 0, 0, 1
329 
330    ppbg:SetAllPoints(pp) 
331    ppbg:SetTexture(0, 0, 0, .5
332 
333    ppp:SetPoint("RIGHT", hpp, "LEFT", 0, 0
334    ppp:SetFont(font, 11
335    ppp:SetShadowOffset(1, -1
336    ppp:SetTextColor(1, 1, 1
337 
338    pp.value = ppp 
339    pp.bg = ppbg 
340    self.Power = pp 
341    self.OverrideUpdatePower = updatePower 
342 
343    leader:SetHeight(16
344    leader:SetWidth(16
345    leader:SetPoint("BOTTOMLEFT", hp, "TOPLEFT", 0, -5
346    leader:SetTexture"Interface\\GroupFrame\\UI-Group-LeaderIcon" 
347    self.Leader = leader 
348 
349    name:SetJustifyH"LEFT" 
350    name:SetFont(font, 11
351    name:SetShadowOffset(1, -1
352    name:SetTextColor(1, 1, 1
353    self.Name = name 
354    self.UNIT_NAME_UPDATE = updateName 
355 
356    level:SetPoint("LEFT", name, "RIGHT", 0, -5
357    level:SetJustifyH("LEFT"
358    level:SetFont(font, 11
359    level:SetShadowOffset(1, -1
360    level:SetTextColor(1,1,1
361    self.Level = level 
362    self.UNIT_LEVEL = updateLevel 
363 
364    --[[ ToT ]]-- 
365    if(unit and unit == "targettarget") then 
366        self:SetWidth(100
367        self:SetHeight(23
368        hp:SetHeight(18
369        pp:SetHeight(4
370        ppp:Hide() 
371        hpp:Hide() 
372        name:SetPoint("LEFT", 2, 0
373    end 
374    --[[ Player ]]-- 
375    if(unit and unit == "player") then 
376        name:SetPoint("LEFT", 2, 0
377        hpp:SetPoint("RIGHT", -2, 0
378        self:SetWidth(223
379        self:SetHeight(23
380        hp:SetHeight(18
381        pp:SetHeight(4
382 
383        local debuffs = CreateFrame("Frame", nil, self) 
384        debuffs.size = self:GetHeight() * 1.1 
385        debuffs:SetHeight(debuffs.size) 
386        debuffs:SetWidth(debuffs.size * 8
387        debuffs:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -5
388        debuffs.initialAnchor = "BOTTOMLEFT" 
389        debuffs["growth-y"] = "DOWN" 
390        debuffs.num = 40 
391        self.Debuffs = debuffs 
392 
393        local buffs = CreateFrame("Frame", nil, self) 
394        buffs.size = self:GetHeight() * 1.1 
395        buffs:SetHeight(buffs.size) 
396        buffs:SetWidth(buffs.size * 8
397        buffs:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 5
398        buffs.initialAnchor = "TOPLEFT" 
399        buffs["growth-y"] = "UP" 
400        buffs.num = 40 
401        self.Buffs = buffs 
402    end 
403    --[[ Target ]]--  
404    if(unit and unit == "target") then 
405        name:SetPoint("RIGHT", -2, 0
406        self:SetWidth(223
407        self:SetHeight(23
408        hp:SetHeight(18
409        pp:SetHeight(4
410        hpp:SetPoint("LEFT", 2, 0
411        ppp:Hide() 
412 
413        local debuffs = CreateFrame("Frame", nil, self) 
414        debuffs.size = self:GetHeight() * 1.1 
415        debuffs:SetHeight(debuffs.size) 
416        debuffs:SetWidth(debuffs.size * 8
417        debuffs:SetPoint("TOPRIGHT", self, "BOTTOMRIGHT", 0, -5
418        debuffs.initialAnchor = "BOTTOMRIGHT" 
419        debuffs["growth-x"] = "LEFT" 
420        debuffs["growth-y"]   = "DOWN" 
421        debuffs.num = 40 
422        self.Debuffs = debuffs 
423 
424        local buffs = CreateFrame("Frame", nil, self) 
425        buffs.size = self:GetHeight() * 1.1 
426        buffs:SetHeight(buffs.size) 
427        buffs:SetWidth(buffs.size * 8
428        buffs:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 0, 5
429        buffs.initialAnchor = "TOPRIGHT" 
430        buffs["growth-x"] = "LEFT" 
431        buffs["growth-y"] = "UP" 
432        buffs.num = 40 
433        self.Buffs = buffs 
434    end 
435    --[[ Focus ]]-- 
436    if(unit and unit == "focus") then 
437      self:SetWidth(100
438      self:SetHeight(23
439      hp:SetHeight(18
440      pp:SetHeight(4
441      hpp:Hide() 
442      ppp:Hide() 
443      name:SetPoint("RIGHT", -2, 0
444 
445    end 
446    --[[ Raid ]]-- 
447    if(self:GetParent():GetName():sub(1, 8)=="oUF_Raid") then 
448        self:SetWidth(100
449        self:SetHeight(23
450        hp:SetHeight(18
451        pp:SetHeight(4
452        ppp:Hide() 
453        ppp:Hide() 
454        hpp:Hide() 
455        name:SetPoint("RIGHT", hp, "RIGHT"
456    end 
457 
458 
459    self.RAID_TARGET_UPDATE = updateName 
460    self:RegisterEvent("RAID_TARGET_UPDATE"
461 
462    self.PostCreateAuraIcon = auraIcon 
463    self.SetAuraPosition = auraOffset 
464 
465    return self 
466end 
467 
468oUF:RegisterStyle("Adalyn", setmetatable({ 
469}, {__call = func})) 
470 
471oUF:SetActiveStyle("Adalyn"
472 
473local player    = oUF:Spawn("player", "oUF_Player"
474local target    = oUF:Spawn("target", "oUF_Target"
475local tot       = oUF:Spawn("targettarget", "oUF_ToT"
476local focus     = oUF:Spawn("focus", "oUF_Focus"
477local pet       = oUF:Spawn("pet", "oUF_Pet"
478 
479player:SetPoint("CENTER", -230, -150
480target:SetPoint("LEFT", player, "RIGHT", 241, 0
481tot:SetPoint("RIGHT", target, "LEFT", -10, 0
482focus:SetPoint("LEFT", player, "RIGHT", 10, 0
483pet:SetPoint("LEFT", player, "RIGHT", 10, 0
484 
485oUF:RegisterStyle("Adalyn-Party", setmetatable({ 
486    ["initial-width"] = 200
487    ["initial-height"] = 25
488}, {__call = func})) 
489 
490oUF:SetActiveStyle("Adalyn-Party"
491 
492local party     = oUF:Spawn("party", "oUF_Party"
493party:SetPoint("TOPLEFT", 15, -15
494 
495 
496oUF:RegisterStyle("Adalyn-Raid", setmetatable({ 
497    ["initial-width"] = 100
498    ["initial-height"] = 23
499}, {__call = func})) 
500 
501oUF:SetActiveStyle("Adalyn-Raid"
502 
503local raid      = oUF:Spawn("raid", "oUF_Raid"
504raid:SetPoint("TOPLEFT", 13, -13
505raid:SetManyAttributes( 
506    "point",   "TOP"
507    "sortDir",     "ASC"
508    "xOffset",     4
509    "yOffset",     -4.1
510    "groupingOrder",   "1,2,3,4,5,6,7,8"
511    "groupBy",     "GROUP"
512    "unitsPerColumn",  5
513    "columnAnchorPoint",   "LEFT"
514    "columnSpacing",   4.9
515    "maxColumns",  8 
516
517 
518local temptoggle = CreateFrame"Frame" 
519temptoggle:SetScript("OnEvent", function(self, event, ...) 
520    if GetNumRaidMembers() > 1 then 
521        if GetNumRaidMembers() > 30 then 
522            raid:Hide() 
523            party:Hide() 
524        elseif GetNumRaidMembers() < 31 then 
525            party:Hide() 
526            raid:Show() 
527        end 
528    elseif GetNumPartyMembers() > 1  then 
529        party:Show() 
530    end 
531  end
532  temptoggle:RegisterEvent"PARTY_MEMBERS_CHANGED" 
533  temptoggle:RegisterEvent"PARTY_LEADER_CHANGED" 
534  temptoggle:RegisterEvent"RAID_ROSTER_UPDATE" 
535  temptoggle:RegisterEvent"PLAYER_LOGIN" 
Download and save
Toggle line numbers
Thread:
[86057] oUF by Adalyn at 2008-04-19 19:30:20
  [86872] Re: oUF by Anonymous at 2008-04-29 08:08:21 (diff)
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.