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