WoWInterface SVN oUF_Industrial

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 24 to Rev 25
    Reverse comparison

Rev 24 → Rev 25

trunk/Addon.lua
20,8 → 20,6
local power_height = 5
local power_texture = bar_texture
 
local buff_size = (health_height + spacing + power_height) / 2
 
local text_inset = 3
local text_font = _G.GameFontNormal:GetFont()
local text_color = {1, 1, 1}
51,6 → 49,8
local update_power
local update_name
local create_unitframe
local nothing = function(...) end
local frame_onupdate
 
function show_menu (frame)
local unit = frame.unit:sub(1, -2)
71,14 → 71,11
end
 
function unit_happiness (unit)
if unit == 'pet' then
local happiness = GetPetHappiness()
if happiness then
return pethappiness[happiness]
end
else
return ''
local happiness = GetPetHappiness()
if unit == 'pet' and happiness then
return pethappiness[happiness]
end
return ''
end
 
function unit_level (unit)
100,39 → 97,41
return ''
end
 
function update_health (frame, event, unit, bar, min, max)
if unit ~= frame.unit then return end
 
bar:SetStatusBarColor(0.25, 0.25, 0.25)
bar.value:SetText(min)
function update_health (frame)
local unit = frame.unit
local health = UnitHealth(unit)
frame.Health:SetValue(health)
frame.Health.value:SetText(health)
end
 
function update_power (frame, event, unit, bar, min, max)
if unit ~= frame.unit then return end
 
bar:SetStatusBarColor(128/255, 255/255, 0)
bar.value:SetText(min == 0 and '' or min)
function update_power (frame)
local unit = frame.unit
local power = UnitMana(unit)
frame.Power:SetValue(power)
frame.Power.value:SetText(power > 0 and power or '')
end
 
function update_name (frame, event, unit)
if unit ~= frame.unit or not UnitExists(unit) then return end
function update_name (frame)
local unit = frame.unit
if not UnitExists(unit) then return end
 
local class = unit_class(unit)
local happiness = unit_happiness(unit)
local level = unit_level(unit)
local name = unit_name(unit)
local tapped = unit_tapped(unit)
 
frame.Name:SetText(('%s %s %s%s %s'):format(level, class, name, tapped, happiness))
frame.Name:SetText(('%s %s %s%s %s'):format(
unit_level(unit),
unit_class(unit),
unit_name(unit),
unit_tapped(unit),
unit_happiness(unit)
))
end
 
function create_unitframe (frame, unit)
local background = frame:CreateTexture(nil, 'OVERLAY')
local background = frame:CreateTexture(nil, 'BACKGROUND')
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')
local threat = frame:CreateTexture()
health.info = health:CreateFontString(nil, 'OVERLAY')
health.value = health:CreateFontString(nil, 'OVERLAY')
power.info = power:CreateFontString(nil, 'OVERLAY')
144,7 → 143,7
health:SetWidth(health_width)
health:SetHeight(health_height)
health:SetStatusBarTexture(health_texture)
health:SetStatusBarColor(0.75, 0.75, 0.75)
health:SetStatusBarColor(0.25, 0.25, 0.25)
 
health.info:SetPoint(ML, health, ML, text_inset, 0)
health.info:SetJustifyH('LEFT')
165,6 → 164,7
power:SetWidth(power_width)
power:SetHeight(power_height)
power:SetStatusBarTexture(power_texture)
power:SetStatusBarColor(128/255, 255/255, 0)
 
power.info:SetPoint(ML, power, ML, text_inset, 0)
power.info:SetJustifyH('LEFT')
181,20 → 181,24
power.value:SetShadowOffset(1, -1)
 
-- buffs
local h = health_height + spacing + power_height
local s = h / 2
local n = math.ceil(health_width / 2 / s) * 2
local w = n / 2 * s
buffs:SetPoint(TR, frame, TL, -padding / 2, -padding)
buffs:SetWidth(bar_width)
buffs:SetHeight(buff_size)
buffs.size = buff_size
buffs.num = math.floor(bar_width / 2 / buffs.size + 0.5)
buffs:SetWidth(w)
buffs:SetHeight(h)
buffs.size = s
buffs.num = n
buffs.initialAnchor = TR
buffs['growth-x'] = ML
buffs['growth-y'] = BC
 
debuffs:SetPoint(ML, frame, MR, padding / 2, -padding)
debuffs:SetWidth(bar_width)
debuffs:SetHeight(buff_size)
debuffs.size = buff_size
debuffs.num = math.floor(bar_width / 2 / debuffs.size + 0.5)
debuffs:SetWidth(w)
debuffs:SetHeight(h)
debuffs.size = s
debuffs.num = n
debuffs.initialAnchor = TL
debuffs['growth-x'] = MR
debuffs['growth-y'] = BC
205,6 → 209,11
leader:SetPoint(MC, health, TC)
leader:SetTexture([[Interface\GroupFrame\UI-Group-LeaderIcon]])
 
-- threat
threat:SetPoint(MC, frame, TR)
threat:SetWidth(16)
threat:SetHeight(16)
 
-- frame
frame:RegisterForClicks('anyup')
frame:SetAttribute('type2', 'menu')
214,7 → 223,7
background:SetAllPoints(frame)
background:SetTexture(0, 0, 0, 1)
 
frame:Tag(health.info, '[difficulty][smartlevel]|r [raidcolor][name]|r')
frame:SetScript('OnUpdate', frame_onupdate)
 
-- out of range fading
if unit and unit:match('party') or unit:match('raid') then
224,26 → 233,66
end
 
frame.Health = health
frame.OverrideUpdateHealth = update_health
frame.OverrideUpdateHealth = nothing
frame.Power = power
frame.PostUpdatePower = update_power
frame.OverrideUpdatePower = nothing
frame.Name = health.info
frame.Info = power.info
frame.Buffs = buffs
frame.Debuffs = debuffs
frame.Leader = leader
frame.Threat = threat
end
 
function create_party_unitframe (frame, unit)
create_unitframe(frame, unit)
 
local buffs = frame.Buffs
 
 
local w = bar_width
local h = buffs.size
local n = math.floor(w / h)
 
print(w, h, n)
buffs:SetPoint(TC, frame, BC, 0, -padding / 2)
buffs:SetWidth(w)
buffs:SetHeight(h)
buffs.num = n
buffs.initialAnchor = TL
buffs['growth-x'] = MR
buffs['growth-y'] = BC
end
 
function frame_onupdate (frame, elapsed)
update_health(frame)
update_power(frame)
update_name(frame)
end
 
oUF:RegisterStyle('Industrial', create_unitframe)
oUF:RegisterStyle('Industrial-party', create_party_unitframe)
 
oUF:SetActiveStyle('Industrial')
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')
oUF:SetActiveStyle('Industrial-party')
local party1 = oUF:Spawn('party1', frame_name..'party1')
local party2 = oUF:Spawn('party2', frame_name..'party2')
local party3 = oUF:Spawn('party3', frame_name..'party3')
local party4 = oUF:Spawn('party4', frame_name..'party4')
 
targettarget:SetScript('OnUpdate', frame_onupdate)
 
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)
 
party1:SetPoint(ML, UIParent, ML)
party2:SetPoint(TC, party1, BC, 0, -20)
party3:SetPoint(TC, party2, BC, 0, -20)
party4:SetPoint(TC, party3, BC, 0, -20)