local _G = _G |
local TL, TC, TR = 'TOPLEFT', 'TOP', 'TOPRIGHT' |
local ML, MC, MR = 'LEFT', 'CENTER', 'RIGHT' |
local BL, BC, BR = 'BOTTOMLEFT', 'BOTTOM', 'BOTTOMRIGHT' |
|
local frame_name = 'oUF_Industrial_' |
|
local padding = 0 |
local spacing = 0 |
local margin = 0 |
local translucency = 1 |
|
local bar_width = 359 - padding * 2 |
local bar_texture = [[Interface\AddOns\oUF_Industrial\media\textures\statusbar]] |
|
local health_width = bar_width |
local health_height = 25 |
local health_texture = bar_texture |
--local health_color = {0.25, 0.25, 0.25, translucency + translucency/2} |
local health_color = {0.5, 0.5, 0.5, translucency + translucency / 2} |
|
local power_width = bar_width |
local power_height = 3 |
local power_texture = bar_texture |
--local power_color = {128/255, 255/255, 0, translucency + translucency/2} |
local power_color = {0.25, 0.5, 1, translucency + translucency / 2} |
|
local cast_color = {1, 1, 0, translucency + translucency / 2} |
|
local text_inset = 3 |
local text_font = _G.GameFontNormal:GetFont() |
local text_color = {1, 1, 1} |
|
local colors_raid = _G.RAID_CLASS_COLORS |
local pethappiness = {':<',':|',':3'} |
local shortclassnames = { |
DEATHKNIGHT = 'DK', |
DRUID = 'DR', |
HUNTER = 'HT', |
MAGE = 'MG', |
PALADIN = 'PL', |
PRIEST = 'PR', |
ROGUE = 'RG', |
SHAMAN = 'SH', |
WARLOCK = 'WL', |
WARRIOR = 'WR', |
} |
|
local show_menu |
local unit_class |
local unit_level |
local unit_name |
local unit_tapped |
local update_health |
local update_power |
local update_name |
local create_unitframe |
local create_pet_unitframe |
local create_party_unitframe |
local target_onupdate |
|
function show_menu (frame) |
local unit = frame.unit:sub(1, -2) |
local cunit = frame.unit:gsub("(.)", string.upper, 1) |
|
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 unit_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 unit_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)) |
end |
|
function unit_name (unit) |
return ('|cff%s%s|r'):format(UnitIsFriend(unit, 'player') == 1 and '00ff00' or 'ff0000', UnitName(unit)) |
end |
|
function unit_tapped (unit) |
if UnitIsTapped(unit) then |
if UnitIsTappedByPlayer(unit) then |
return '|cff00ff00*|r' |
end |
return '|cffff0000*|r' |
end |
return '' |
end |
|
function unit_threat (unit) |
if UnitIsEnemy('player', unit) then |
local threat_percent = select(3, UnitDetailedThreatSituation('player', 'target')) |
if threat_percent then |
return math.ceil(threat_percent) .. '%' |
else |
return '' |
end |
else |
return '' |
end |
end |
|
function update_health (frame, event, unit, bar, min, max) |
bar.value:SetText(min) |
update_name(frame) |
end |
|
function update_power (frame, event, unit, bar, min, max) |
bar.value:SetText(min > 0 and min or '') |
update_name(frame) |
end |
|
function update_name (frame) |
local unit = frame.unit |
if not UnitExists(unit) then return end |
|
frame.Name:SetText(('%s %s %s%s %s'):format( |
unit_level(unit), |
unit_class(unit), |
unit_name(unit), |
unit_tapped(unit), |
unit_threat(unit) |
)) |
end |
|
function create_unitframe (frame, unit) |
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 rlicon = health:CreateTexture(nil, 'OVERLAY') |
local ricon = health:CreateTexture() |
local mlicon = health:CreateTexture() |
local threat = health:CreateTexture() |
local castbar = CreateFrame('StatusBar', nil, health) |
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 = show_menu |
castbar.Icon = castbar:CreateTexture() |
|
-- healthbar |
health:SetPoint(TL, frame, TL, padding, -padding) |
health:SetWidth(health_width) |
health:SetHeight(health_height) |
health:SetStatusBarTexture(health_texture) |
health:SetStatusBarColor(unpack(health_color)) |
|
health.info:SetPoint(ML, health, ML, text_inset, 0) |
health.info:SetJustifyH('LEFT') |
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, -text_inset, 0) |
health.value:SetJustifyH('RIGHT') |
health.value:SetFont(text_font, 10) |
health.value:SetTextColor(unpack(text_color)) |
health.value:SetShadowColor(0, 0, 0) |
health.value:SetShadowOffset(1, -1) |
|
-- powerbar |
power:SetPoint(TL, health, BL, 0, -spacing) |
power:SetWidth(power_width) |
power:SetHeight(power_height) |
power:SetStatusBarTexture(power_texture) |
power:SetStatusBarColor(unpack(power_color)) |
|
power.info:SetPoint(ML, power, ML, text_inset, 0) |
power.info:SetJustifyH('LEFT') |
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, -text_inset, 0) |
power.value:SetJustifyH('RIGHT') |
power.value:SetFont(text_font, 10) |
power.value:SetTextColor(unpack(text_color)) |
power.value:SetShadowColor(0, 0, 0) |
power.value:SetShadowOffset(1, -1) |
|
-- castbar |
castbar:SetAllPoints(power) |
castbar:SetToplevel(true) |
castbar:SetStatusBarTexture(health_texture) |
castbar:SetStatusBarColor(unpack(cast_color)) |
|
-- buffs |
local size = 16 |
local height = health_height + spacing + power_height |
local width = health_width |
local number = math.floor(width / height) |
buffs:SetPoint(TR, frame, TL, -padding / 2, -padding) |
buffs:SetWidth(width) |
buffs:SetHeight(height) |
buffs.size = height |
buffs.num = number |
buffs.initialAnchor = TR |
buffs['growth-x'] = 'LEFT' |
buffs['growth-y'] = 'DOWN' |
|
debuffs:SetPoint(ML, frame, MR, padding / 2, -padding) |
debuffs:SetWidth(width) |
debuffs:SetHeight(height) |
debuffs.size = height |
debuffs.num = number |
debuffs.initialAnchor = TL |
debuffs['growth-x'] = 'RIGHT' |
debuffs['growth-y'] = 'DOWN' |
|
-- rlicon icon |
rlicon:SetPoint(MC, frame, TL) |
rlicon:SetWidth(16) |
rlicon:SetHeight(16) |
|
-- raid icon |
ricon:SetPoint(MC, frame, TC) |
ricon:SetWidth(16) |
ricon:SetHeight(16) |
|
-- master looter icon |
mlicon:SetPoint(ML, rlicon, MR) |
mlicon:SetWidth(16) |
mlicon:SetHeight(16) |
|
-- threat |
threat:SetPoint(MC, frame, TR) |
threat:SetWidth(16) |
threat:SetHeight(16) |
|
-- frame |
frame:RegisterForClicks('anyup') |
frame:SetAttribute('type2', 'menu') |
frame:SetAttribute('initial-width', health_width + padding * 2) |
frame:SetAttribute('initial-height', health_height + power_height + padding * 2 + spacing) |
|
background:SetAllPoints(frame) |
background:SetTexture(0, 0, 0, translucency) |
|
frame.Health = health |
frame.PostUpdateHealth = update_health |
frame.Power = power |
frame.PostUpdatePower = update_power |
frame.Name = health.info |
frame.Info = power.info |
frame.Castbar = castbar |
frame.Buffs = buffs |
frame.Debuffs = debuffs |
frame.Leader = rlicon |
frame.RaidIcon = ricon |
frame.MasterLooter = mlicon |
frame.Threat = threat |
end |
|
function create_pet_unitframe(frame, unit) |
create_unitframe(frame, unit) |
|
local happiness = frame.Health:CreateTexture() |
happiness:SetPoint(MC, frame, BR) |
happiness:SetWidth(16) |
happiness:SetHeight(16) |
|
frame.Happiness = happiness |
end |
|
function create_party_unitframe (frame, unit) |
create_unitframe(frame, unit) |
|
-- out of range fading |
frame.Range = true |
frame.inRangeAlpha = 1 |
frame.outsideRangeAlpha = 0.5 |
|
local buffs = frame.Buffs |
|
local size = 16 |
local width = power_width |
local height = size |
local number = math.floor(width / size) |
buffs:SetPoint(TL, frame, BL, 0, -padding / 2) |
buffs:SetWidth(width) |
buffs:SetHeight(height) |
buffs.size = size |
buffs.num = number |
buffs.initialAnchor = TL |
buffs['growth-x'] = 'RIGHT' |
buffs['growth-y'] = 'BOTTOM' |
end |
|
function target_onupdate (frame) |
-- the default ouf .+target updating is .5 seconds, I'd like it instant |
frame:PLAYER_ENTERING_WORLD('OnTargetUpdate') |
end |
|
oUF:RegisterStyle('Industrial', create_unitframe) |
oUF:RegisterStyle('Industrial-pet', create_pet_unitframe) |
--oUF:RegisterStyle('Industrial-party', create_party_unitframe) |
|
oUF:SetActiveStyle('Industrial-pet') |
local pet = oUF:Spawn('pet', frame_name..'pet') |
oUF:SetActiveStyle('Industrial') |
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', target_onupdate) |
|
pet:SetPoint(MC, UIParent, MC, 0, -305) |
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, -18) |
--party3:SetPoint(TC, party2, BC, 0, -18) |
--party4:SetPoint(TC, party3, BC, 0, -18) |
|