WoWInterface SVN oUF_Industrial

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 15 to Rev 16
    Reverse comparison

Rev 15 → Rev 16

todo.txt File deleted
oUF_Industrial.toc
1,3 → 1,2
## Interface: 20400
## Notes: My oUF layout.
## Interface: 30000
Addon.lua
Addon.lua
4,45 → 4,41
local ML, MC, MR = 'LEFT', 'CENTER', 'RIGHT'
local BL, BC, BR = 'BOTTOMLEFT', 'BOTTOM', 'BOTTOMRIGHT'
 
-- vars
local framebackdrop = {
local frames = {}
local frame_name = 'oUF_Industrial_'
local frame_backdrop = {
bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
tile = true,
tileSize = 16,
--edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
edgeFile = '',
edgeSize = 16,
--insets = {left=4,right=4,top=4,bottom=4},
insets = {left=0,right=0,top=0,bottom=0},
}
local framename = 'oUF_Industrial_'
local frames = {}
local frame_backdrop_color = {0, 0, 0, 1}
 
local bartexture = [[Interface\Addons\oUF_Industrial\media\textures\statusbar]]
local barheight = 15
local barwidth = 300
local padding = 1
local margin = 5
 
local healthtexture = bartexture
local healthheight = 30
local healthwidth = barwidth
local bar_width = 300
local bar_height = 15
local bar_texture = [[Interface\AddOns\oUF_Industrial\media\textures\statusbar]]
 
local powertexture = bartexture
local powerheight = 5
local powerwidth = barwidth
local health_width = bar_width
local health_height = 30
local health_texture = bar_texture
 
local textinset = 5
local textfont = _G.GameFontNormal:GetFont()
local textcolor = {1, 1, 1}
local power_width = bar_width
local power_height = 2
local power_texture = bar_texture
 
local raidcolors = _G.RAID_CLASS_COLORS
local buff_size = health_height + power_height + padding
 
local innerpadding = 1
local elementpadding = 1
local outerpadding = 5
local text_padding = 5
local text_font = _G.GameFontNormal:GetFont()
local text_color = {1, 1, 1}
 
--local buffsize = (healthheight + powerheight + innerpadding*2 + elementpadding)/2
local buffsize = (healthheight + elementpadding + powerheight)/2
 
local colors_raid = _G.RAID_CLASS_COLORS
local pethappiness = {':<',':|',':3'}
local shortclassnames = {
DEATHKNIGHT = 'DK',
DRUID = 'DR',
56,48 → 52,56
WARRIOR = 'WR',
}
 
-- functions
local showMenu
local updateHealth
local updatePower
local updateInfo
local updatePowerInfo
local createDefaultFrame
local createPartyFrame
local show_menu
local formattedtext_class
local formattedtext_happiness
local formattedtext_level
local formattedtext_name
local formattedtext_tapped
local update_health
local update_power
local update_name
local create_unitframe
 
-- text display
local formatTextClass
local formatTextHappiness
local formatTextLevel
local formatTextName
local formatTextRace
local formatTextTapped
function show_menu (frame)
local unit = frame.unit:sub(1, -2)
local cunit = frame.unit:gsub("(.)", string.upper, 1)
 
function formatTextClass (unit)
if(unit == "party" or unit == "partypet") then
ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..frame.id.."DropDown"], "cursor", 0, 0)
elseif(_G[cunit.."FrameDropDown"]) then
ToggleDropDownMenu(1, nil, _G[cunit.."FrameDropDown"], "cursor", 0, 0)
end
end
 
function formattedtext_class (unit)
local class = select(2, UnitClass(unit))
local color = RAID_CLASS_COLORS[class]
 
return color and ('|cff%02X%02X%02X%s|r'):format(color.r*255, color.g*255, color.b*255, shortclassnames[class]) or ''
end
 
function formatTextHappiness (unit)
local pethappiness = {':<',':|',':3'}
if unit == pet then
return GetPetHappiness() and pethappiness[GetPetHappiness()]
function formattedtext_happiness (unit)
if unit == 'pet' then
local happiness = GetPetHappiness()
if happiness then
return pethappiness[happiness]
end
else
return ''
end
return ''
end
 
function formatTextLevel (unit)
function formattedtext_level (unit)
local color = GetDifficultyColor(UnitLevel(unit))
return color and ('|cff%02X%02X%02X%s|r'):format(color.r*255, color.g*255, color.b*255, UnitLevel(unit)) or ''
return color and ('|cff%02X%02X%02X%s|r'):format(color.r*255, color.g*255, color.b*255, UnitLevel(unit))
end
 
function formatTextName (unit)
function formattedtext_name (unit)
return ('|cff%s%s|r'):format(UnitIsFriend(unit, 'player') == 1 and '00ff00' or 'ff0000', UnitName(unit))
end
 
function formatTextTapped (unit)
function formattedtext_tapped (unit)
if UnitIsTapped(unit) then
if UnitIsTappedByPlayer(unit) then
return '|cff00ff00*|r'
107,290 → 111,171
return ''
end
 
function showMenu (self)
local unit = self.unit:sub(1, -2)
local cunit = self.unit:gsub("(.)", string.upper, 1)
function update_health (frame, event, unit, bar, min, max)
if unit ~= frame.unit then return end
 
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 unit ~= self.unit then return end
 
local class = select(2, UnitClass(unit))
--[[local color = raidcolors[class]
local color = colors_raid[class]
 
if color then
bar:SetStatusBarColor(color.r, color.g, color.b)
end]]
bar:SetStatusBarColor(0.25, 0.25, 0.25)
 
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(min)
end
 
bar:SetStatusBarColor(0.25, 0.25, 0.25)
bar.value:SetText(min)
end
 
function updatePower (self, event, bar, unit, min, max)
--bar:SetStatusBarColor(255/255, 128/255, 0)
--bar:SetStatusBarColor(0, 128/255, 255/255)
function update_power (frame, event, unit, bar, min, max)
if unit ~= frame.unit then return end
 
bar:SetStatusBarColor(128/255, 255/255, 0)
if min == 0 then
bar.value:SetText(0)
else
bar.value:SetText(min)
end
bar.value:SetText(min == 0 and '' or min)
end
 
function updateInfo (self, event, unit)
if unit ~= self.unit then return end
function update_name (frame, event, unit)
if unit ~= frame.unit or not UnitExists(unit) then return end
 
if unit == 'player' or unit == 'pet' then
self.Name:SetText()
else
local class = formatTextClass(unit)
local happiness = formatTextHappiness(unit)
local level = formatTextLevel(unit)
local name = formatTextName(unit)
local tapped = formatTextTapped(unit)
self.Name:SetText(('%s %s %s%s %s'):format(level, class, name, tapped, happiness))
end
local class = formattedtext_class(unit)
local happiness = formattedtext_happiness(unit)
local level = formattedtext_level(unit)
local name = formattedtext_name(unit)
local tapped = formattedtext_tapped(unit)
 
frame.Name:SetText(('%s %s %s%s %s'):format(level, class, name, tapped, happiness))
end
 
function createDefaultFrame (settings, self, unit)
local bg = self:CreateTexture(nil, 'OVERLAY')
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 = health: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
function create_unitframe (frame, unit)
local background = frame:CreateTexture(nil, 'OVERLAY')
local health = CreateFrame('StatusBar', nil, frame)
local power = CreateFrame('StatusBar', nil, frame)
local buffs = CreateFrame('Frame', nil, frame)
local debuffs = CreateFrame('Frame', nil, frame)
local leader = health: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')
frame.menu = showMenu
 
-- healthbar
health:SetPoint(TL, self, TL, innerpadding, -innerpadding)
health:SetWidth(healthwidth)
health:SetHeight(healthheight)
health:SetStatusBarTexture(healthtexture)
health:SetPoint(TL, frame, TL, padding, -padding)
health:SetWidth(health_width)
health:SetHeight(health_height)
health:SetStatusBarTexture(health_texture)
health:SetStatusBarColor(0.75, 0.75, 0.75)
 
health.info:SetPoint(ML, health, ML, textinset, 0)
health.info:SetPoint(ML, health, ML, text_padding, 0)
health.info:SetJustifyH('LEFT')
health.info:SetFont(textfont, 10)
health.info:SetTextColor(unpack(textcolor))
health.info:SetFont(text_font, 10)
health.info:SetTextColor(unpack(text_color))
health.info:SetShadowColor(0, 0, 0)
health.info:SetShadowOffset(1, -1)
 
health.value:SetPoint(MR, health, MR, -textinset, 0)
health.value:SetPoint(MR, health, MR, -text_padding, 0)
health.value:SetJustifyH('RIGHT')
health.value:SetFont(textfont, 10)
health.value:SetTextColor(unpack(textcolor))
health.value:SetFont(text_font, 10)
health.value:SetTextColor(unpack(text_color))
health.value:SetShadowColor(0, 0, 0)
health.value:SetShadowOffset(1, -1)
health.value:Hide()
 
frame:Tag(health.info, '[difficulty][smartlevel]|r [raidcolor][name]|r')
 
-- powerbar
power:SetPoint(TL, health, BL, 0, -elementpadding)
power:SetWidth(powerwidth)
power:SetHeight(powerheight)
power:SetStatusBarTexture(powertexture)
--power.colorType = true
power:SetPoint(TL, health, BL, 0, -padding)
power:SetWidth(power_width)
power:SetHeight(power_height)
power:SetStatusBarTexture(power_texture)
 
power.info:SetPoint(ML, power, ML, textinset, 0)
power.info:SetPoint(ML, power, ML, text_padding, 0)
power.info:SetJustifyH('LEFT')
power.info:SetFont(textfont, 10)
power.info:SetTextColor(unpack(textcolor))
power.info:SetFont(text_font, 10)
power.info:SetTextColor(unpack(text_color))
power.info:SetShadowColor(0, 0, 0)
power.info:SetShadowOffset(1, -1)
 
power.value:SetPoint(MR, health.value, ML, -textinset, 0)
power.value:SetPoint(MR, health.value, ML, -text_padding, 0)
power.value:SetJustifyH('RIGHT')
power.value:SetFont(textfont, 10)
power.value:SetTextColor(unpack(textcolor))
power.value:SetFont(text_font, 10)
power.value:SetTextColor(unpack(text_color))
power.value:SetShadowColor(0, 0, 0)
power.value:SetShadowOffset(1, -1)
power.value:Hide()
 
-- frame
self:SetScript('OnEnter', function(self)
health.value:Show()
power.value:Show()
end)
self:SetScript('OnLeave', function(self)
health.value:Hide()
power.value:Hide()
end)
frame:RegisterForClicks('anyup')
frame:SetAttribute('type2', 'menu')
 
self:RegisterForClicks('anyup')
self:SetAttribute('type2', 'menu')
frame:SetAttribute('initial-width', health_width + padding * 2)
frame:SetAttribute('initial-height', health_height + power_height + padding * 2 + padding)
 
bg:SetAllPoints(self)
bg:SetTexture(0, 0, 0, 1)
background:SetAllPoints(frame)
background:SetTexture(0, 0, 0, 1)
 
self:RegisterEvent('UNIT_LEVEL')
self:RegisterEvent('UNIT_NAME')
self:RegisterEvent('UNIT_HAPPINESS')
self:RegisterEvent('UNIT_CLASSIFICATION_CHANGED')
self:RegisterEvent('UNIT_COMBAT')
self:RegisterEvent('UNIT_FACTION')
self:RegisterEvent('UNIT_FLAGS')
self:RegisterEvent('UNIT_LEVEL')
self:RegisterEvent('UNIT_LOYALTY')
self:RegisterEvent('UNIT_NAME_UPDATE')
--frame:RegisterEvent('UNIT_LEVEL', update_name)
--frame:RegisterEvent('UNIT_NAME', update_name)
--frame:RegisterEvent('UNIT_HAPPINESS', update_name)
--frame:RegisterEvent('UNIT_CLASSIFICATION_CHANGED', update_name)
--frame:RegisterEvent('UNIT_COMBAT', update_name)
--frame:RegisterEvent('UNIT_FACTION', update_name)
--frame:RegisterEvent('UNIT_FLAGS', update_name)
--frame:RegisterEvent('UNIT_LEVEL', update_name)
--frame:RegisterEvent('UNIT_LOYALTY', update_name)
--frame:RegisterEvent('UNIT_NAME_UPDATE', update_name)
 
self.UNIT_LEVEL = updateInfo
self.UNIT_NAME = updateInfo
self.UNIT_HAPPINESS = updateInfo
self.UNIT_CLASSIFICATION_CHANGED = updateInfo
self.UNIT_COMBAT = updateInfo
self.UNIT_FACTION = updateInfo
self.UNIT_FLAGS = updateInfo
self.UNIT_LEVEL = updateInfo
self.UNIT_LOYALTY = updateInfo
self.UNIT_NAME_UPDATE = updateInfo
 
-- buffs
buffs:SetPoint(BL, self, TL, 0, elementpadding)
buffs:SetWidth(barwidth)
buffs:SetHeight(buffsize)
buffs.size = buffsize
buffs.num = math.floor(barwidth / buffs.size + 0.5)
buffs.initialAnchor = BL
buffs['growth-x'] = MR
buffs:SetPoint(MR, frame, ML, -padding, 0)
buffs:SetWidth(bar_width)
buffs:SetHeight(buff_size)
buffs.size = buff_size
buffs.num = math.floor(bar_width / buffs.size + 0.5)
buffs.initialAnchor = BR
buffs['growth-x'] = ML
buffs['growth-y'] = TC
 
debuffs:SetPoint(TL, self, BL, 0, -elementpadding)
debuffs:SetWidth(barwidth)
debuffs:SetHeight(buffsize)
debuffs.size = buffsize
debuffs.num = math.floor(barwidth / debuffs.size + 0.5)
debuffs.initialAnchor = TL
debuffs:SetPoint(ML, frame, MR, padding, 0)
debuffs:SetWidth(bar_width)
debuffs:SetHeight(buff_size)
debuffs.size = buff_size
debuffs.num = math.floor(bar_width / debuffs.size + 0.5)
debuffs.initialAnchor = BL
debuffs['growth-x'] = MR
debuffs['growth-y'] = BC
debuffs['growth-y'] = TC
 
-- leader icon
leader:SetWidth(buffsize)
leader:SetHeight(buffsize)
leader:SetWidth(buff_size)
leader:SetHeight(buff_size)
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
frame.Range = true
frame.inRangeAlpha = 1
frame.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
frame.Health = health
frame.OverrideUpdateHealth = update_health
frame.Power = power
frame.PostUpdatePower = update_power
frame.Name = health.info
frame.Info = power.info
frame.Buffs = buffs
frame.Debuffs = debuffs
frame.Leader = leader
 
function createPetFrame (settings, self, unit)
createDefaultFrame(settings, self, unit)
 
self.Health:SetWidth(healthwidth/2)
self.Power:SetWidth(powerwidth/2)
 
self.Name:Hide()
self.Info:Hide()
self.Buffs = nil
self.Debuffs = nil
self.Leader:Hide()
self.Leader = nil
 
self:UnregisterEvent('UNIT_LEVEL')
self:UnregisterEvent('UNIT_NAME')
self:UnregisterEvent('UNIT_HAPPINESS')
self:UnregisterEvent('UNIT_CLASSIFICATION_CHANGED')
self:UnregisterEvent('UNIT_COMBAT')
self:UnregisterEvent('UNIT_FACTION')
self:UnregisterEvent('UNIT_FLAGS')
self:UnregisterEvent('UNIT_LEVEL')
self:UnregisterEvent('UNIT_LOYALTY')
self:UnregisterEvent('UNIT_NAME_UPDATE')
--update_name(frame, '', unit)
end
 
function createTargettargetFrame (settings, self, unit)
createDefaultFrame(settings, self, unit)
oUF:RegisterStyle('Industrial', create_unitframe)
 
self:SetScript('OnEnter', nil)
self:SetScript('OnLeave', nil)
 
self.Health:SetWidth(healthwidth/2)
self.Power:SetWidth(powerwidth/2)
 
self.Buffs = nil
self.Debuffs = nil
end
 
oUF:RegisterStyle('Industrial', setmetatable({
['initial-width'] = healthwidth + innerpadding*2,
['initial-height'] = healthheight + powerheight + innerpadding*2 + elementpadding
}, {__call = createDefaultFrame}))
 
oUF:RegisterStyle('Industrial-Pet', setmetatable({
['initial-width'] = healthwidth/2 + innerpadding*2,
['initial-height'] = healthheight + powerheight + innerpadding*2 + elementpadding
}, {__call = createPetFrame}))
 
oUF:RegisterStyle('Industrial-Targettarget', setmetatable({
['initial-width'] = healthwidth/2 + innerpadding*2,
['initial-height'] = healthheight + powerheight + innerpadding*2 + elementpadding
}, {__call = createTargettargetFrame}))
 
oUF:RegisterSubTypeMapping('UNIT_LEVEL')
 
oUF:SetActiveStyle('Industrial-Pet')
local pet = oUF:Spawn('pet', framename..'pet')
 
oUF:SetActiveStyle('Industrial-Targettarget')
local targettarget = oUF:Spawn('targettarget', framename..'targettarget')
 
oUF:SetActiveStyle('Industrial')
local player = oUF:Spawn('player', framename..'player')
local target = oUF:Spawn('target', framename..'target')
local party = oUF:Spawn('header', 'oUF_Industrial_party')
local pet = oUF:Spawn('pet', frame_name..'pet')
local player = oUF:Spawn('player', frame_name..'player')
local target = oUF:Spawn('target', frame_name..'target')
local targettarget = oUF:Spawn('targettarget', frame_name..'targettarget')
 
player:SetPoint(MR, UIParent, MC, -outerpadding/2, -300)
pet:SetPoint(MR, player, ML, -outerpadding, 0)
pet:SetPoint(MC, UIParent, MC, 0, -300)
player:SetPoint(BC, pet, TC, 0, margin)
target:SetPoint(BC, player, TC, 0, margin)
targettarget:SetPoint(BC, target, TC, 0, margin)
 
target:SetPoint(ML, UIParent, MC, outerpadding/2, -300)
targettarget:SetPoint(ML, target, MR, outerpadding, 0)
 
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()
 
if RuneFrame then
RuneFrame:Hide()
end