WoWInterface SVN oUF_Industrial

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

oUF_Industrial.toc New file
0,0 → 1,3
## Interface: 20400
## Notes: My oUF layout.
Addon.lua
media/textures/statusbar.tga Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream
Addon.lua New file
0,0 → 1,265
local _G = _G
 
local TL, TC, TR = 'TOPLEFT', 'TOP', 'TOPRIGHT'
local ML, MC, MR = 'LEFT', 'CENTER', 'RIGHT'
local BL, BC, BR = 'BOTTOMLEFT', 'BOTTOM', 'BOTTOMRIGHT'
 
-- vars
local framebackdrop = {
bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
tile = true,
tileSize = 16,
edgeFile = '',
edgeSize = 0,
insets = {
left = 0,
right = 0,
top = 0,
bottom = 0
}
}
local happinesstext = {
':<',
':|',
':3'
}
local framename = 'oUF_Industrial_'
local frames = {}
 
local bartexture = [[Interface\Addons\oUF_Industrial\media\textures\statusbar]]
local barheight = 25
local barwidth = 300
 
local healthtexture = bartexture
local healthheight = barheight
local healthwidth = barwidth
 
local powertexture = bartexture
local powerheight = 5
local powerwidth = barwidth
 
local textinset = 5
local textfont = _G.GameFontNormal:GetFont()
local textcolor = {1, 1, 1}
 
local raidcolors = _G.RAID_CLASS_COLORS
 
local buffsize = 16
 
local innerpadding = 1
local outerpadding = 1
 
-- functions
local showMenu
local updateHealth
local updatePower
local updateHealthInfo
local updatePowerInfo
local createNormalFrame
local siValue
 
function siValue (val)
if(val >= 1e4) then
return ("%.1f"):format(val / 1e3):gsub('%.', 'k')
else
return val
end
end
 
function showMenu (self)
local unit = self.unit:sub(1, -2)
local cunit = self.unit:gsub("(.)", string.upper, 1)
 
if(unit == "party" or unit == "partypet") then
ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..self.id.."DropDown"], "cursor", 0, 0)
elseif(_G[cunit.."FrameDropDown"]) then
ToggleDropDownMenu(1, nil, _G[cunit.."FrameDropDown"], "cursor", 0, 0)
end
end
 
function updateHealth (self, event, bar, unit, min, max)
if not unit == self.unit then return end
 
local class = select(2, UnitClass(unit))
local color = raidcolors[class]
 
bar:SetStatusBarColor(color.r, color.g, color.b)
 
if UnitIsDead(unit) then
bar:SetValue(0)
bar.value:SetText('Dead')
elseif UnitIsGhost(unit) then
bar:SetValue(0)
bar.value:SetText('Ghost')
elseif not UnitIsConnected(unit) then
bar:SetValue(0)
bar.value:SetText('Offline')
else
bar.value:SetText(siValue(min))
end
end
 
function updatePower (self, event, bar, unit, min, max)
if min == 0 then
bar.value:SetText(0)
else
bar.value:SetText(siValue(min))
end
end
 
function updateHealthInfo (self, event, unit)
if not unit == self.unit then return end
 
local level = UnitLevel(unit)
local name = UnitName(unit)
local happiness = ' '
 
if unit == 'pet' then
happpiness = GetPetHappiness() and happinesstext[GetPetHappiness()]..' '
end
 
self.Name:SetText(('%s %s %s'):format(level, happiness, name:sub(1,20)))
end
 
function updatePowerInfo ()
end
 
function createNormalFrame (settings, self, unit)
local health = CreateFrame('StatusBar', nil, self)
local power = CreateFrame('StatusBar', nil, self)
local buffs = CreateFrame('Frame', nil, self)
local debuffs = CreateFrame('Frame', nil, self)
local leader = self:CreateTexture(nil, 'OVERLAY')
health.info = health:CreateFontString(nil, 'OVERLAY')
health.value = health:CreateFontString(nil, 'OVERLAY')
power.info = power:CreateFontString(nil, 'OVERLAY')
power.value = power:CreateFontString(nil, 'OVERLAY')
self.menu = showMenu
 
-- healthbar
health:SetPoint(TL, self, TL, innerpadding, -innerpadding)
health:SetWidth(healthwidth)
health:SetHeight(healthheight)
health:SetStatusBarTexture(healthtexture)
 
health.info:SetPoint(ML, health, ML, textinset, 0)
health.info:SetWidth(healthwidth/2 - textinset)
health.info:SetJustifyH('LEFT')
health.info:SetFont(textfont, 10)
health.info:SetTextColor(unpack(textcolor))
 
health.value:SetPoint(MR, health, MR, -textinset, 0)
health.value:SetJustifyH('RIGHT')
health.value:SetFont(textfont, 10)
health.value:SetTextColor(unpack(textcolor))
 
-- powerbar
power:SetPoint(TL, health, BL, 0, -innerpadding)
power:SetWidth(powerwidth)
power:SetHeight(powerheight)
power:SetStatusBarTexture(powertexture)
 
power.info:SetPoint(ML, power, ML, textinset, 0)
power.info:SetWidth(powerwidth/2 - textinset)
power.info:SetJustifyH('LEFT')
power.info:SetFont(textfont, 10)
power.info:SetTextColor(unpack(textcolor))
 
power.value:SetPoint(MR, health.value, ML, -textinset, 0)
power.value:SetJustifyH('RIGHT')
power.value:SetFont(textfont, 10)
power.value:SetTextColor(unpack(textcolor))
 
-- frame
self:SetScript('OnEnter', UnitFrame_OnEnter)
self:SetScript('OnLeave', UnitFrame_OnLeave)
 
self:RegisterForClicks('anyup')
self:SetAttribute('type2', 'menu')
 
self:SetBackdrop(framebackdrop)
self:SetBackdropColor(0, 0, 0, 1)
 
self.UNIT_LEVEL = updateHealthInfo
self:RegisterEvent('UNIT_LEVEL')
 
if unit == 'pet' then
self.UNIT_HAPPINESS = updateHealthInfo
self:RegisterEvent('UNIT_HAPPINESS')
end
 
-- buffs
buffs:SetPoint(TR, self, TL)
buffs:SetWidth(barwidth)
buffs:SetHeight(buffsize)
buffs.size = buffsize
buffs.num = math.floor(barwidth / buffs.size + 0.5)
buffs.initialAnchor = TR
buffs['growth-x'] = ML
buffs['growth-y'] = BC
 
debuffs:SetPoint(TL, self, TR)
debuffs:SetWidth(barwidth)
debuffs:SetHeight(buffsize)
debuffs.size = buffsize
debuffs.num = math.floor(barwidth / debuffs.size + 0.5)
debuffs.initialAnchor = TL
debuffs['growth-x'] = MR
debuffs['growth-y'] = BC
 
-- leader icon
leader:SetWidth(buffsize)
leader:SetHeight(buffsize)
leader:SetPoint(MC, health, TC)
leader:SetTexture([[Interface\GroupFrame\UI-Group-LeaderIcon]])
 
-- range fading
if not unit then
self.Range = true
self.inRangeAlpha = 1
self.outsideRangeAlpha = 0.5
end
 
self.Health = health
self.OverrideUpdateHealth = updateHealth
self.Power = power
self.PostUpdatePower = updatePower
self.Name = health.info
self.Info = power.info
self.Buffs = buffs
self.Debuffs = debuffs
self.Leader = leader
end
 
oUF:RegisterStyle('Industrial', setmetatable({
['initial-width'] = healthwidth + innerpadding*2,
['initial-height'] = healthheight + powerheight + innerpadding*3
}, {__call = createNormalFrame}))
 
oUF:RegisterSubTypeMapping('UNIT_LEVEL')
oUF:SetActiveStyle('Industrial')
 
local pet = oUF:Spawn('pet', framename..'pet')
local player = oUF:Spawn('player', framename..'player')
local target = oUF:Spawn('target', framename..'target')
local targettarget = oUF:Spawn('targettarget', framename..'targettarget')
local party = oUF:Spawn('header', 'oUF_Industrial_party')
 
pet:SetPoint(MC, UIParent, MC, 0, -400)
player:SetPoint(BC, pet, TC, 0, outerpadding)
target:SetPoint(BC, player, TC, 0, outerpadding)
targettarget:SetPoint(BC, target, TC, 0, outerpadding)
 
party:SetPoint(MC, UIParent, MC, -400, -300)
party:SetManyAttributes(
'showParty', 'true',
'yOffset', outerpadding,
'xOffset', outerpadding,
'maxColumns', 1,
'unitsPerColumn', 4,
'columnAnchorPoint', ML,
'columnSpacing', 15
)
party:Show()
 
RuneFrame:Hide()