-
-
Save NarusegawaNaru/137309 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
oUF NaruUI: 30100.05 | |
Credits: oUF Saul for the base layout I've used in this modified one | |
Credits: P3lim for his layout and coding | |
I grants anyone the right to use this work for any purpose, | |
without any conditions, unless such conditions are required by law. | |
--]] | |
--[[ =============================== | |
TEXTURE PATHS | |
--]] | |
local bufftexture = 'Interface\\AddOns\\oUF_NaruUI\\texture\\buff' | |
local bartexture = 'Interface\\AddOns\\oUF_NaruUI\\texture\\statusbar' | |
local cptex = "Interface\\AddOns\\oUF_NaruUI\\texture\\checkmark" | |
local mediaPath = "Interface\\AddOns\\oUF_NaruUI\\media\\" | |
--[[ =============================== | |
ADDON DEBUG | |
--]] | |
local gsub = string.gsub | |
local format = string.format | |
local floor = math.floor | |
local localized, playerClass = UnitClass('player') | |
local texture = [=[Interface\AddOns\oUF_NaruUI\minimalist]=] | |
local backdrop = { | |
bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], | |
insets = {top = -1, left = -1, bottom = -1, right = -1}, | |
} | |
local runeloadcolors = { | |
{0.77, 0.12, 0.23}, {0.77, 0.12, 0.23}, | |
{0.4, 0.8, 0.1}, {0.4, 0.8, 0.1}, | |
{0, 0.4, 0.7}, {0, 0.4, 0.7}, | |
} | |
local colors = setmetatable({ | |
power = setmetatable({ | |
['MANA'] = {0, 144/255, 1} | |
}, {__index = oUF.colors.power}), | |
reaction = setmetatable({ | |
[2] = {1, 0, 0}, | |
[4] = {1, 1, 0}, | |
[5] = {0, 1, 0} | |
}, {__index = oUF.colors.reaction}), | |
red = {1, 0, 0}, | |
white = {1, 1, 1}, | |
}, {__index = oUF.colors}) | |
--[[ =============================== | |
ADDON INIT | |
--]] | |
local layoutName = "oUF_NaruUI" | |
local addon = CreateFrame('Frame', 'oUF_NaruUI', UIParent) | |
addon:SetScript('OnEvent', function(self, event, ...) if(self[event]) then return self[event](self, event, ...) end end) | |
addon:RegisterEvent("ADDON_LOADED") | |
_G[layoutName] = addon | |
--local oUF = NaruUIEmbed | |
--[[ =============================== | |
ADDON DEBUG | |
--]] | |
addon.EnableDebugMessages = false | |
function addon:Print(msg,type) | |
print("|c"..(type~=nil and (type=="error" and "FFFF6600") or (type=="debug" and "FF66FF66") or "FF00FF00") ..layoutName.." : |r"..msg) | |
end | |
function addon:Debug(...) | |
if(self.EnableDebugMessages) then | |
local msg = {} | |
for index,var in pairs({...})do | |
table.insert(msg,tostring(index) .." : ".. tostring(var) ) | |
end | |
self:Print(table.concat(msg,",")) | |
end | |
end | |
--[[ =============================== | |
ADDON DEBUG | |
--]] | |
local function applyAuraIndicator(self) | |
addon:Print(self, self==nil and 'error' or 'debug' ); -- if self is nil this is an error message, otherwise it's going to be a debug msg type.' | |
self.AuraStatusTL = self.Health:CreateFontString(nil, "OVERLAY") | |
self.AuraStatusTL:ClearAllPoints() | |
self.AuraStatusTL:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -3, -7) | |
self.AuraStatusTL:SetFont(mediaPath.."font.ttf", "22", "THINOUTLINE") | |
self:Tag(self.AuraStatusTL, oUF.classIndicators[playerClass]["TL"]) | |
self.AuraStatusTR = self.Health:CreateFontString(nil, "OVERLAY") | |
self.AuraStatusTR:ClearAllPoints() | |
self.AuraStatusTR:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 3, -7) | |
self.AuraStatusTR:SetFont(mediaPath.."font.ttf", "22", "THINOUTLINE") | |
self:Tag(self.AuraStatusTR, oUF.classIndicators[playerClass]["TR"]) | |
if (self.Power) then | |
self.AuraStatusBL = self.Power:CreateFontString(nil, "OVERLAY") | |
else | |
self.AuraStatusBL = self.Health:CreateFontString(nil, "OVERLAY") | |
end | |
self.AuraStatusBL:ClearAllPoints() | |
self.AuraStatusBL:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", -3, -3) | |
self.AuraStatusBL:SetFont(mediaPath.."font.ttf", "22", "THINOUTLINE") | |
self:Tag(self.AuraStatusBL, oUF.classIndicators[playerClass]["BL"]) | |
if (self.Power) then | |
self.AuraStatusBR = self.Power:CreateFontString(nil, "OVERLAY") | |
else | |
self.AuraStatusBR = self.Health:CreateFontString(nil, "OVERLAY") | |
end | |
self.AuraStatusBR:ClearAllPoints() | |
self.AuraStatusBR:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 7, -3) | |
self.AuraStatusBR:SetFont(mediaPath.."PIZZADUDEBULLETS.ttf", "12", "THINOUTLINE") | |
self:Tag(self.AuraStatusBR, oUF.classIndicators[playerClass]["BR"]) | |
if (oUF.classIndicators[playerClass]["BL"]) then | |
self.HealOverTimeHighlight = self.Health:CreateTexture(nil, "OVERLAY") | |
self.HealOverTimeHighlight:SetAllPoints(self.Health) | |
self.HealOverTimeHighlight:SetWidth(252) | |
self.HealOverTimeHighlight:SetBlendMode("ADD") | |
self.HealOverTimeHighlight:SetVertexColor(0, 0, 0, 0.75) | |
self.HealOverTimeHighlightAlpha = 1 | |
self.HealOverTimeHighlightFilter = false -- only show curable ones | |
self.HealOverTimeHighlight:SetTexture('Interface\\AddOns\\oUF_NaruUI\\texture\\highlightTex.tga') | |
end | |
end | |
--[[ =============================== | |
DATA HELPERS | |
--]] | |
local function hex(r, g, b) | |
if(type(r) == 'table') then | |
if(r.r) then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end | |
end | |
return string.format('|cff%02x%02x%02x', r * 255, g * 255, b * 255) | |
end | |
local function truncate(value) | |
if(value >= 1e6) then | |
return gsub(format('%.2fm', value / 1e6), '%.?0+([km])$', '%1') | |
elseif(value >= 1e5) then | |
return gsub(format('%.1fk', value / 1e3), '%.?0+([km])$', '%1') | |
else | |
return value | |
end | |
end | |
local function ColourGradient(perc) | |
if perc <= 0.5 then | |
return 255, perc*510, 0 | |
else | |
return 510 - perc*510, 255, 0 | |
end | |
end | |
--[[ =============================== | |
FRAME HELPERS | |
--]] | |
local function menu(self) | |
local unit = self.unit:gsub("(.)", string.upper, 1) | |
if _G[unit.."FrameDropDown"] then | |
ToggleDropDownMenu(1, nil, _G[unit.."FrameDropDown"], "cursor") | |
elseif (self.unit:match("party")) then | |
ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..self.id.."DropDown"], "cursor") | |
else | |
FriendsDropDown.unit = self.unit | |
FriendsDropDown.id = self.id | |
FriendsDropDown.initialize = RaidFrameDropDown_Initialize | |
ToggleDropDownMenu(1, nil, FriendsDropDown, "cursor") | |
end | |
end | |
--[[ =============================== | |
oUF TAGS | |
--]] | |
oUF.Tags['[difficulty]'] = function(unit) | |
local level = UnitLevel(unit); | |
return UnitCanAttack('player', unit) and hex(GetDifficultyColor((level > 0) and level or 99)) or '|cff0090ff' | |
end | |
oUF.TagEvents['[custompvp]'] = 'PLAYER_FLAGS_CHANGED' | |
oUF.Tags['[custompvp]'] = function(unit) | |
return UnitIsPVP(unit) and not IsPVPTimerRunning() and '*' or IsPVPTimerRunning() and format('%d:%02d', floor((GetPVPTimer() / 1000) / 60), (GetPVPTimer() / 1000) % 60) | |
end | |
oUF.TagEvents['[customthreat]'] = 'UNIT_THREAT_LIST_UPDATE' | |
oUF.Tags['[customthreat]'] = function() | |
local tanking, _, perc = UnitDetailedThreatSituation('player', 'target') | |
return perc and hex(GetThreatStatusColor(UnitThreatSituation('player', 'target')))..floor(perc) | |
end | |
oUF.TagEvents['[customstatus]'] = 'UNIT_HEALTH' | |
oUF.Tags['[customstatus]'] = function(unit) | |
return not UnitIsConnected(unit) and PLAYER_OFFLINE or UnitIsGhost(unit) and 'Ghost' or UnitIsDead(unit) and DEAD | |
end | |
oUF.TagEvents['[customhp]'] = 'UNIT_HEALTH UNIT_MAXHEALTH' | |
oUF.Tags['[customhp]'] = function(unit) | |
local status = oUF.Tags['[customstatus]'](unit) | |
local min, max = UnitHealth(unit), UnitHealthMax(unit) | |
local r,g,b = ColourGradient(min/max) | |
return status and status or | |
(unit ~= 'player' and unit ~= 'target' and min-max ~= 0) and format('|cff%02x%02x%02x%s|r', r, g, b, truncate(min-max)) or | |
(unit == 'target' and min - max == 0) and format('|cff%02x%02x%02x%s|r', r, g, b, truncate(max)) or | |
(min - max == 0) and format('%s', max) or | |
(unit == 'target' or unit == 'player') and format('|cff00FF00%s|r . |cff%02x%02x%02x%s|r %d%%', truncate(max), r, g, b, truncate(min), floor(min/max*100)) or | |
(min~=max) and format('%s |cff0090ff/|r %s', truncate(min), truncate(max)) or max | |
end | |
oUF.TagEvents['[custompp]'] = oUF.TagEvents['[curpp]'] | |
oUF.Tags['[custompp]'] = function(unit) | |
local num, str = UnitPowerType(unit) | |
local c = colors.power[str] | |
if (oUF.Tags['[curpp]'](unit) ~= 0) then | |
return c and format('|cff%02x%02x%02x%s|r', c[1] * 255, c[2] * 255, c[3] * 255, oUF.Tags['[curpp]'](unit)) | |
end | |
end | |
oUF.TagEvents['[customname]'] = 'UNIT_NAME_UPDATE UNIT_REACTION UNIT_FACTION' | |
oUF.Tags['[customname]'] = function(unit) | |
local c = (UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) and colors.tapped or | |
(not UnitIsConnected(unit)) and colors.disconnected or | |
(not UnitIsPlayer(unit)) and colors.reaction[UnitReaction(unit, 'player')] or | |
(UnitFactionGroup(unit) and UnitIsEnemy(unit, 'player') and UnitIsPVP(unit)) and colors.red or colors.white | |
return format('|cff%02x%02x%02x%s|r', c[1] * 255, c[2] * 255, c[3] * 255, UnitName(unit)) | |
end | |
oUF.TagEvents['[druidpower]'] = 'UNIT_MANA UPDATE_SHAPESHIFT_FORM' | |
oUF.Tags['[druidpower]'] = function(unit) | |
local min, max = UnitPower(unit, 0), UnitPowerMax(unit, 0) | |
return UnitPowerType(unit) ~= 0 and format('|cff0090ff%d - %d%%|r', min, math.floor(min / max * 100)) | |
end | |
--[[ =============================== | |
FUNCTIONS | |
--]] | |
local function updateMasterLooter(self) | |
self.MasterLooter:ClearAllPoints() | |
if((UnitInParty(self.unit) or UnitInRaid(self.unit)) and UnitIsPartyLeader(self.unit)) then | |
self.MasterLooter:SetPoint('LEFT', self.Leader, 'RIGHT') | |
else | |
self.MasterLooter:SetPoint('TOPLEFT', self, 0, 8) | |
end | |
end | |
local function updateCombo(self, event, unit) | |
if(unit == PlayerFrame.unit and unit ~= self.CPoints.unit) then | |
self.CPoints.unit = unit | |
end | |
end | |
local function updateDruidPower(self, event, unit) | |
if(unit and unit ~= self.unit) then return end | |
local bar = self.DruidPower | |
local mana = UnitPowerType('player') == 0 | |
local min, max = UnitPower('player', mana and 3 or 0), UnitPowerMax('player', mana and 3 or 0) | |
bar:SetStatusBarColor(unpack(colors.power[mana and 'ENERGY' or 'MANA'])) | |
bar:SetMinMaxValues(0, max) | |
bar:SetValue(min) | |
bar:SetAlpha(min ~= max and 1 or 0) | |
end | |
local function updatePower(self, event, unit, bar, min, max) | |
if(max ~= 0) then | |
self.Health:SetHeight(22) | |
bar:Show() | |
else | |
self.Health:SetHeight(27) | |
bar:Hide() | |
end | |
end | |
local function updateReputationColor(self, event, unit, bar) | |
local name, id = GetWatchedFactionInfo() | |
bar:SetStatusBarColor(FACTION_BAR_COLORS[id].r, FACTION_BAR_COLORS[id].g, FACTION_BAR_COLORS[id].b) | |
end | |
local function castbarTime(self, duration) | |
if(self.channeling) then | |
self.Time:SetFormattedText('%.1f ', duration) | |
elseif(self.casting) then | |
self.Time:SetFormattedText('%.1f ', self.max - duration) | |
end | |
end | |
local function createAuraTooltip(self) | |
if(not self:IsVisible()) then return end | |
GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMRIGHT') | |
GameTooltip:SetUnitAura(self.frame.unit, self:GetID(), self.filter) | |
GameTooltip:AddLine(format('Casted by %s', self.owner and UnitName(self.owner) or UNKNOWN)) | |
GameTooltip:Show() | |
end | |
local function createAura(self, button, icons) | |
icons.showDebuffType = true | |
button.cd:SetReverse() | |
button.overlay:SetTexture([=[Interface\AddOns\oUF_NaruUI\border]=]) | |
button.overlay:SetTexCoord(0, 1, 0, 1) | |
button.overlay.Hide = function(self) self:SetVertexColor(0.25, 0.25, 0.25) end | |
button:SetScript('OnEnter', createAuraTooltip) | |
if(self.unit == 'player') then | |
icons.disableCooldown = false | |
button.time = button:CreateFontString(nil, 'OVERLAY', 'NumberFontNormal') | |
button.time:SetPoint('TOPLEFT', button) | |
end | |
end | |
local function updateTime(self) | |
if(self.expiration) then | |
local timeleft = floor(self.expiration - GetTime() + 0.5) | |
self.time:SetText(timeleft > 0 and timeleft or '') | |
else | |
self:SetScript('OnUpdate', nil) | |
end | |
end | |
local function updateBuff(self, icons, unit, icon, index) | |
local _, _, _, _, _, _, expiration = UnitAura(unit, index, icon.filter) | |
if(expiration and expiration > 0) then | |
icon.expiration = expiration | |
icon:SetScript('OnUpdate', updateTime) | |
icon:Show() | |
else | |
icon:Hide() | |
end | |
end | |
local function updateDebuff(self, icons, unit, icon, index) | |
if(not icon.debuff or not UnitIsEnemy('player', unit)) then return end | |
local _, _, _, _, _, _, _, caster = UnitAura(unit, index, icon.filter) | |
if(caster ~= 'player' and caster ~= 'vehicle') then | |
icon.icon:SetDesaturated(true) | |
icon.overlay:SetVertexColor(0.25, 0.25, 0.25) | |
else | |
icon.icon:SetDesaturated(false) | |
end | |
end | |
local function customFilter(icons, unit, icon, name, rank, texture, count, dtype, duration, timeLeft, caster) | |
-- Naru: Not sure what we're doing here... do I need this? Probably not but | |
-- going to leave in for now though. | |
-- This filter is made for me specifically, but you can create | |
-- your own table with spells that this filter can match to. | |
if(oUF_NaruUI_buffFilter and oUF_NaruUI_buffFilter[name] and caster == 'player') then | |
-- todo: set the buffs.visibleBuffs so it works with buffs.num | |
return true | |
end | |
end | |
--[[ =============================== | |
MAIN STYLE | |
--]] | |
local function styleFunction(self, unit) | |
self.colors = colors | |
--Naru: oUF_SortAura's addon busted, doesn't work. Waiting for oUF to implement this instead | |
--self.sortAuras = {} | |
self.menu = menu | |
self:RegisterForClicks('AnyUp') | |
self:SetAttribute('type2', 'menu') | |
self:SetScript('OnEnter', UnitFrame_OnEnter) | |
self:SetScript('OnLeave', UnitFrame_OnLeave) | |
self:SetBackdrop(backdrop) | |
self:SetBackdropColor(0, 0, 0) | |
self.Health = CreateFrame('StatusBar', self:GetName()..'_health', self) | |
if unit then | |
self.Health:SetFrameLevel(1) | |
elseif self:GetAttribute("unitsuffix") then | |
self.Health:SetFrameLevel(3) | |
elseif not unit then | |
self.Health:SetFrameLevel(2) | |
end | |
self.Health:SetPoint('TOPRIGHT', self) | |
self.Health:SetPoint('TOPLEFT', self) | |
self.Health:SetStatusBarTexture(texture) | |
self.Health:SetStatusBarColor(0.25, 0.25, 0.35) | |
self.Health:SetHeight((unit == 'focus' or unit == 'targettarget') and 22 or 22) | |
self.Health.frequentUpdates = true | |
self.Health.bg = self.Health:CreateTexture(nil, 'BORDER') | |
self.Health.bg:SetAllPoints(self.Health) | |
self.Health.bg:SetTexture(0.3, 0.3, 0.3) | |
local healthbg = self.Health:CreateTexture(nil, 'BORDER') | |
healthbg:SetPoint('TOP', self, 'BOTTOM', 0, -2) | |
healthbg:SetTexture(bartexture) | |
healthbg:SetWidth(252) | |
healthbg:SetHeight(14) | |
healthbg:SetVertexColor(0, 0, 0, 0.7) | |
healthbg:Hide() | |
local hpvalue = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight') | |
hpvalue:SetPoint('RIGHT', self.Health, -2, 0) | |
hpvalue.frequentUpdates = 0.1 | |
self:Tag(hpvalue, unit == 'player' and '[customthreat(%|r)]|cffff0000[custompvp]|r [customhp]' or '[customhp]') | |
if(self:GetParent():GetName():match"oUF_Raid") then | |
local info = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft') | |
info:SetPoint('LEFT', self.Health, 2, 3) | |
info:SetPoint('RIGHT', hpvalue, 'LEFT') | |
info.frequentUpdates = 0.1 | |
self:Tag(info, '[customname]') | |
elseif(unit ~= 'player') then | |
local info = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft') | |
info:SetPoint('LEFT', self.Health, 2, 3) | |
info:SetPoint('RIGHT', hpvalue, 'LEFT') | |
info.frequentUpdates = 0.1 | |
self:Tag(info, '[difficulty][smartlevel] [rare]|r[customname]') | |
end | |
if(unit ~= 'targettarget' and unit ~= 'focus') then | |
self.Power = CreateFrame('StatusBar', self:GetName()..'_power', self) | |
self.Power:SetPoint('BOTTOMRIGHT', self) | |
self.Power:SetPoint('BOTTOMLEFT', self) | |
self.Power:SetStatusBarTexture(texture) | |
self.Power:SetHeight(4) | |
self.Power.frequentUpdates = true | |
local pet = unit == 'pet' | |
self.Power.bg = self.Power:CreateTexture(nil, 'BORDER') | |
self.Power.bg:SetAllPoints(self.Power) | |
self.Power.bg:SetTexture([=[Interface\ChatFrame\ChatFrameBackground]=]) | |
self.Power.bg.multiplier = 0.3 | |
self.Power.colorTapping = true | |
self.Power.colorDisconnected = true | |
self.Power.colorClass = true | |
self.Power.colorPower = pet | |
self.Power.colorHappiness = pet | |
self.Power.colorReaction = not pet | |
if((not unit) and self:GetAttribute("unitsuffix") ~= "target" and self:GetAttribute("unitsuffix") ~= "pet") then | |
self.PostUpdatePower = updatePower | |
end | |
self.Leader = self.Health:CreateTexture(nil, 'OVERLAY') | |
self.Leader:SetPoint('TOPLEFT', self, 0, 8) | |
self.Leader:SetHeight(16) | |
self.Leader:SetWidth(16) | |
self.MasterLooter = self.Health:CreateTexture(nil, 'OVERLAY') | |
self.MasterLooter:SetPoint('LEFT', self.Leader, 'RIGHT') | |
self.MasterLooter:SetHeight(16) | |
self.MasterLooter:SetWidth(16) | |
table.insert(self.__elements, updateMasterLooter) | |
self:RegisterEvent('PARTY_LOOT_METHOD_CHANGED', updateMasterLooter) | |
self:RegisterEvent('PARTY_MEMBERS_CHANGED', updateMasterLooter) | |
self:RegisterEvent('PARTY_LEADER_CHANGED', updateMasterLooter) | |
else | |
local focus = unit == 'focus' | |
self.Debuffs = CreateFrame('Frame', nil, self) | |
self.Debuffs:SetPoint(focus and 'TOPLEFT' or 'TOPRIGHT', self, focus and 'TOPRIGHT' or 'TOPLEFT', focus and 6 or -6, 1) | |
self.Debuffs:SetHeight(23) | |
self.Debuffs:SetWidth(180) | |
self.Debuffs.num = 2 | |
self.Debuffs.size = 23 | |
self.Debuffs.spacing = 2 | |
self.Debuffs.onlyShowPlayer = focus | |
self.Debuffs.initialAnchor = focus and 'TOPLEFT' or 'TOPRIGHT' | |
self.Debuffs['growth-x'] = focus and 'RIGHT' or 'LEFT' | |
self.PostCreateAuraIcon = createAura | |
self:SetAttribute('initial-height', 22) | |
self:SetAttribute('initial-width', 180) | |
end | |
if(unit == 'pet') then | |
self.Debuffs = CreateFrame('Frame', nil, self) | |
self.Debuffs:SetPoint('TOPLEFT', self, 'TOPRIGHT', 5, 1) | |
self.Debuffs:SetHeight(24) | |
self.Debuffs:SetWidth(100) | |
self.Debuffs.num = 4 | |
self.Debuffs.size = 24 | |
self.Debuffs.spacing = 2 | |
self.Debuffs.onlyShowPlayer = focus | |
self.Debuffs.initialAnchor = 'TOPLEFT' | |
self.Debuffs['growth-x'] = 'RIGHT' | |
self.PostCreateAuraIcon = createAura | |
self:SetAttribute('initial-height', 27) | |
self:SetAttribute('initial-width', 130) | |
end | |
if(unit == 'targettarget') then | |
self.Debuffs:SetPoint('TOPLEFT', self, 'TOPRIGHT', 5, 1) | |
self.Debuffs:SetHeight(24) | |
self.Debuffs:SetWidth(100) | |
self.Debuffs.num = 2 | |
self.Debuffs.size = 24 | |
self.Debuffs.spacing = 2 | |
self.Debuffs.onlyShowPlayer = focus | |
self.Debuffs.initialAnchor = 'TOPLEFT' | |
self.Debuffs['growth-x'] = 'RIGHT' | |
end | |
if(unit == 'player') then | |
local power = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft') | |
power:SetPoint('TOPLEFT', self.Health, 2, -31) | |
power.frequentUpdates = 0.1 | |
self:Tag(power, '[custompp]') | |
healthbg:Show() | |
hpvalue:SetPoint('TOPRIGHT', self.Health, -2, -31) | |
self.Buffs = CreateFrame('Frame', nil, self) | |
self.Buffs:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 28) | |
self.Buffs:SetHeight(24) | |
self.Buffs:SetWidth(270) | |
self.Buffs.num = 20 | |
self.Buffs.size = 24 | |
self.Buffs.spacing = 2 | |
self.Buffs.initialAnchor = 'TOPLEFT' | |
self.PostCreateAuraIcon = createAura | |
self.PostUpdateAuraIcon = unit == 'player' and updateBuff | |
self.CustomAuraFilter = unit == 'player' and customFilter | |
self:SetAttribute('initial-height', 27) | |
self:SetAttribute('initial-width', 250) | |
end | |
if(unit == 'target') then | |
local power = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft') | |
power:SetPoint('TOPLEFT', self.Health, 2, -31) | |
power.frequentUpdates = 0.1 | |
self:Tag(power, '[custompp]') | |
healthbg:Show() | |
hpvalue:SetPoint('TOPRIGHT', self.Health, -2, -31) | |
healthbg:SetWidth(202) | |
self:SetWidth(200) | |
self:SetHeight(27) | |
self.Buffs = CreateFrame('Frame', nil, self) | |
self.Buffs:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 28) | |
self.Buffs:SetHeight(24) | |
self.Buffs:SetWidth(200) | |
self.Buffs.num = 20 | |
self.Buffs.size = 24 | |
self.Buffs.spacing = 2 | |
self.Buffs.initialAnchor = 'TOPLEFT' | |
self.PostCreateAuraIcon = createAura | |
self.PostUpdateAuraIcon = unit == 'player' and updateBuff | |
self.CustomAuraFilter = unit == 'player' and customFilter | |
self:SetAttribute('initial-height', 27) | |
self:SetAttribute('initial-width', 200) | |
end | |
if(IsAddOnLoaded'oUF_CombatFeedback' and (unit == 'player' or unit == 'target')) then | |
self.CombatFeedbackText = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight') | |
self.CombatFeedbackText:SetPoint("RIGHT", self.Health, "RIGHT", -2, 0) | |
end | |
if(unit == 'target') then | |
if(playerClass == "ROGUE" or playerClass == "DRUID") then | |
local cpframe = CreateFrame("Frame", nil, self) | |
cpframe:SetFrameStrata("MEDIUM") | |
self.CPoints = {} | |
self.CPoints.unit = "player" | |
self.CPoints[1] = cpframe:CreateTexture(nil, "OVERLAY") | |
self.CPoints[1]:SetHeight(14) | |
self.CPoints[1]:SetWidth(14) | |
self.CPoints[1]:SetPoint("LEFT", self.Health, "TOPLEFT", 4, 3) | |
self.CPoints[1]:SetTexture(cptex) | |
for i=2, 5 do | |
self.CPoints[i] = cpframe:CreateTexture(nil, "OVERLAY") | |
self.CPoints[i]:SetHeight(14) | |
self.CPoints[i]:SetWidth(14) | |
self.CPoints[i]:SetPoint("LEFT", self.CPoints[i-1], "RIGHT", 1) | |
self.CPoints[i]:SetTexture(cptex) | |
end | |
self.CPoints[5]:SetVertexColor(1, 0, 0) | |
self:RegisterEvent('UNIT_COMBO_POINTS', updateCombo) | |
end | |
self.Debuffs = CreateFrame('Frame', nil, self) | |
self.Debuffs:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -19) | |
self.Debuffs:SetHeight(24) | |
self.Debuffs:SetWidth(230) | |
self.Debuffs.size = 24 | |
self.Debuffs.spacing = 2 | |
self.Debuffs.initialAnchor = 'TOPLEFT' | |
self.PostCreateAuraIcon = createAura | |
self.PostUpdateAuraIcon = updateDebuff | |
end | |
if(unit == 'player' and playerClass == 'DRUID') then | |
self.DruidPower = CreateFrame('StatusBar', self:GetName()..'_druidpower', self) | |
self.DruidPower:SetPoint('TOP', self.Health, 'BOTTOM') | |
self.DruidPower:SetStatusBarTexture(texture) | |
self.DruidPower:SetHeight(1) | |
self.DruidPower:SetWidth(252) | |
self.DruidPower:SetAlpha(0) | |
local value = self.DruidPower:CreateFontString(nil, 'OVERLAY', 'GameFontNormalSmall') | |
value:SetPoint('CENTER', self.DruidPower) | |
self:Tag(value, '[druidpower]') | |
table.insert(self.__elements, updateDruidPower) | |
self:RegisterEvent('UNIT_MANA', updateDruidPower) | |
self:RegisterEvent('UNIT_ENERGY', updateDruidPower) | |
self:RegisterEvent('UPDATE_SHAPESHIFT_FORM', updateDruidPower) | |
end | |
-- ------------------------------------ | |
-- party | |
-- ------------------------------------ | |
if(self:GetParent():GetName():match"oUF_Party") then | |
self:SetWidth(230) | |
self:SetHeight(27) | |
self.Health:SetHeight(22) | |
self.Power:SetHeight(4) | |
if(self:GetAttribute("unitsuffix") ~= "target" and self:GetAttribute("unitsuffix") ~= "pet") then | |
self.Debuffs = CreateFrame('Frame', nil, self) | |
self.Debuffs:SetPoint('TOPLEFT', self, 'TOPLEFT', -1, -29) | |
self.Debuffs:SetHeight(22) | |
self.Debuffs:SetWidth(270) | |
self.Debuffs.num = 5 | |
self.Debuffs.size = 22 | |
self.Debuffs.spacing = 2 | |
self.Debuffs.initialAnchor = 'TOPLEFT' | |
self.Debuffs['growth-y'] = 'DOWN' | |
self.PostCreateAuraIcon = createAura | |
self.Buffs = CreateFrame('Frame', nil, self) | |
self.Buffs:SetPoint('TOPLEFT', self, 'TOPLEFT', -1, 30) | |
self.Buffs:SetHeight(22) | |
self.Buffs:SetWidth(230) | |
self.Buffs.size = 22 | |
self.Buffs.spacing = 2 | |
self.Buffs.initialAnchor = 'TOPLEFT' | |
self.Buffs.num = 10 | |
local afkIcon = self.Health:CreateTexture(nil, "OVERLAY") | |
afkIcon:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 40, 2) | |
afkIcon:SetWidth(16) | |
afkIcon:SetHeight(16) | |
afkIcon:Hide() | |
self.AFKIcon = afkIcon | |
self.AFKIconTexture = "Interface\\Icons\\Spell_Nature_TimeStop" | |
end | |
self.PostCreateAuraIcon = createAura | |
self.PostUpdateAuraIcon = updateDebuff | |
self.Leader = self.Health:CreateTexture(nil, 'OVERLAY') | |
self.Leader:SetPoint('TOPLEFT', self, 0, 8) | |
self.Leader:SetHeight(12) | |
self.Leader:SetWidth(12) | |
self.MasterLooter = self.Health:CreateTexture(nil, 'OVERLAY') | |
self.MasterLooter:SetPoint('LEFT', self.Leader, 'RIGHT') | |
self.MasterLooter:SetHeight(12) | |
self.MasterLooter:SetWidth(12) | |
end | |
if(self:GetAttribute("unitsuffix") == "target" or self:GetAttribute("unitsuffix") == "pet") then | |
self:SetHeight(20) | |
self:SetWidth(150) | |
self.Health:SetHeight(20) | |
if (unit) then | |
self.Power:SetHeight(4) | |
end | |
end | |
if(unit == 'player') then | |
local afkIcon = self.Health:CreateTexture(nil, "OVERLAY") | |
afkIcon:SetPoint("TOPLEFT", self, "TOPLEFT", 40, -3) | |
afkIcon:SetWidth(16) | |
afkIcon:SetHeight(16) | |
afkIcon:Hide() | |
self.AFKIcon = afkIcon | |
self.AFKIconTexture = "Interface\\Icons\\Spell_Nature_TimeStop" | |
self.RestingIcon = self.Power:CreateTexture(nil, 'OVERLAY') | |
self.RestingIcon:SetPoint("TOPLEFT", self, "TOPLEFT", 3, -3) | |
self.RestingIcon:SetHeight(16) | |
self.RestingIcon:SetWidth(16) | |
self.RestingIcon:SetTexture('Interface\\CharacterFrame\\UI-StateIcon') | |
self.RestingIcon:SetTexCoord(0.09, 0.43, 0.08, 0.42) | |
self.Resting = self.RestingIcon | |
self.Resting:SetAlpha((UnitLevel('player') ~= MAX_PLAYER_LEVEL) and 0.75 or 0) | |
self.CombatIcon = self.Health:CreateTexture(nil, 'OVERLAY') | |
self.CombatIcon:SetPoint('TOPLEFT', self, 'TOPLEFT', 20, -3) | |
self.CombatIcon:SetHeight(16) | |
self.CombatIcon:SetWidth(16) | |
self.CombatIcon:SetTexture('Interface\\CharacterFrame\\UI-StateIcon') | |
self.CombatIcon:SetTexCoord(0.58, 0.90, 0.08, 0.41) | |
self.Combat = self.CombatIcon | |
end | |
if(IsAddOnLoaded'oUF_Reputation' and unit == 'player') then | |
self.Reputation = CreateFrame('StatusBar', self:GetName()..'_reputation', self) | |
self.Reputation:SetPoint('TOP', self, 'BOTTOM', 0, -22) | |
self.Reputation:SetStatusBarTexture(texture) | |
self.Reputation:SetHeight(12) | |
self.Reputation:SetWidth(250) | |
self.Reputation:SetBackdrop(backdrop) | |
self.Reputation:SetBackdropColor(0, 0, 0) | |
self.Reputation.Tooltip = true | |
self.Reputation.PostUpdate = updateReputationColor | |
self.Reputation.Text = self.Reputation:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall') | |
self.Reputation.Text:SetPoint('CENTER', self.Reputation) | |
self.Reputation.bg = self.Reputation:CreateTexture(nil, 'BORDER') | |
self.Reputation.bg:SetAllPoints(self.Reputation) | |
self.Reputation.bg:SetTexture(0.3, 0.3, 0.3) | |
end | |
if(IsAddOnLoaded('oUF_RuneBar') and unit == 'player' and playerClass == 'DEATHKNIGHT') then | |
self.RuneBar = {} | |
for i = 1, 6 do | |
self.RuneBar[i] = CreateFrame('StatusBar', self:GetName()..'_runebar'..i, self) | |
if(i == 1) then | |
self.RuneBar[i]:SetPoint('BOTTOMLEFT', oUF_NaruUI_player, 'TOPLEFT', 0, 5) | |
else | |
self.RuneBar[i]:SetPoint('TOPLEFT', self.RuneBar[i-1], 'TOPRIGHT', 1, 0) | |
end | |
self.RuneBar[i]:SetStatusBarTexture(texture) | |
self.RuneBar[i]:SetStatusBarColor(unpack(runeloadcolors[i])) | |
self.RuneBar[i]:SetHeight(4) | |
self.RuneBar[i]:SetWidth(252/6 - 0.85) | |
self.RuneBar[i]:SetBackdrop(backdrop) | |
self.RuneBar[i]:SetBackdropColor(0, 0, 0) | |
self.RuneBar[i]:SetMinMaxValues(0, 1) | |
self.RuneBar[i].bg = self.RuneBar[i]:CreateTexture(nil, 'BORDER') | |
self.RuneBar[i].bg:SetAllPoints(self.RuneBar[i]) | |
self.RuneBar[i].bg:SetTexture(0.3, 0.3, 0.3) | |
end | |
end | |
if(IsAddOnLoaded('oUF_Experience') and ((unit == 'pet' and playerClass ~= 'WARLOCK' or unit == 'player') and UnitLevel('player') ~= MAX_PLAYER_LEVEL)) then | |
self.Experience = CreateFrame('StatusBar', self:GetName()..'_experience', self) | |
self.Experience:SetPoint('TOP', self, 'BOTTOM', 0, -38) | |
self.Experience:SetStatusBarTexture(texture) | |
self.Experience:SetStatusBarColor(unpack(colors.health)) | |
self.Experience:SetHeight(12) | |
self.Experience:SetWidth(self:GetAttribute('initial-width')) | |
self.Experience.Tooltip = true | |
self.Experience.Rested = CreateFrame('StatusBar', nil, self) | |
self.Experience.Rested:SetAllPoints(self.Experience) | |
self.Experience.Rested:SetStatusBarTexture(texture) | |
self.Experience.Rested:SetStatusBarColor(0, 0.4, 1, 0.6) | |
self.Experience.Rested:SetBackdrop(backdrop) | |
self.Experience.Rested:SetBackdropColor(0, 0, 0) | |
self.Experience.Rested:SetFrameLevel(1) | |
self.Experience.Text = self.Experience:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall') | |
self.Experience.Text:SetPoint('CENTER', self.Experience) | |
self.Experience.bg = self.Experience.Rested:CreateTexture(nil, 'BORDER') | |
self.Experience.bg:SetAllPoints(self.Experience) | |
self.Experience.bg:SetTexture(0.3, 0.3, 0.3) | |
end | |
-- | |
-- fading for party and raid | |
-- | |
if((not unit) and self:GetAttribute("unitsuffix") ~= "target" and self:GetAttribute("unitsuffix") ~= "pet") then -- fadeout if units are out of range | |
self.Range = true | |
self.inRangeAlpha = 1.0 | |
self.outsideRangeAlpha = 0.6 | |
end | |
self.DebuffHighlight = self.Health:CreateTexture(nil, "OVERLAY") | |
self.DebuffHighlight:SetAllPoints(self.Health) | |
self.DebuffHighlight:SetWidth(252) | |
self.DebuffHighlight:SetBlendMode("ADD") | |
self.DebuffHighlight:SetVertexColor(0, 0, 0, 0.75) | |
self.DebuffHighlightAlpha = 1 | |
self.DebuffHighlightFilter = true -- only show curable ones | |
self.DebuffHighlight:SetTexture('Interface\\AddOns\\oUF_NaruUI\\texture\\debuffHighlight.tga') | |
local cbft = self.Health:CreateFontString(nil, "OVERLAY") | |
cbft:SetPoint("CENTER", self, "CENTER", 0, 2) | |
cbft:SetFontObject(GameFontNormal) | |
self.CombatFeedbackText = cbft | |
self.CombatFeedbackText.maxAlpha = .8 | |
if not(self:GetAttribute('unitsuffix') == 'target')then | |
applyAuraIndicator(self) | |
end | |
end | |
addon.defaults = { | |
frames = { | |
units = { | |
player = { | |
enabled = true, | |
anchorFrom = 'TOPLEFT', | |
anchorObj = 'UIParent', | |
anchorTo = 'TOPLEFT', | |
anchorX = 10, | |
anchorY = -83, | |
width = 252, | |
height = 23, | |
}, | |
target = { | |
enabled = true, | |
anchorFrom = 'TOPLEFT', | |
anchorObj = 'player', | |
anchorTo = 'TOPRIGHT', | |
anchorX = 35, | |
anchorY = 0, | |
width = 200, | |
height = 23, | |
}, | |
targettarget = { | |
enabled = true, | |
anchorFrom = 'TOPLEFT', | |
anchorObj = 'target', | |
anchorTo = 'TOPRIGHT', | |
anchorX = 5, | |
anchorY = 0, | |
width = 100, | |
height = 23, | |
}, | |
focus = { | |
enabled = false, | |
anchorFrom = 'TOP', | |
anchorObj = 'UIParent', | |
anchorTo = 'TOP', | |
anchorX = 0, | |
anchorY = -83, | |
width = 230, | |
height = 23, | |
}, | |
focustarget = { | |
enabled = false, | |
anchorFrom = 'TOPLEFT', | |
anchorObj = 'focus', | |
anchorTo = 'BOTTOMLEFT', | |
anchorX = 0, | |
anchorY = -15, | |
width = 230, | |
height = 23, | |
}, | |
pet = { | |
enabled = true, | |
anchorFrom = 'TOPRIGHT', | |
anchorObj = 'player', | |
anchorTo = 'BOTTOMRIGHT', | |
anchorX = 10, | |
anchorY = -83, | |
width = 230, | |
height = 23, | |
}, | |
pettarget = { | |
enabled = false, | |
anchorFrom = 'TOPLEFT', | |
anchorObj = 'pet', | |
anchorTo = 'TOPRIGHT', | |
anchorX = 10, | |
anchorY = 0, | |
width = 230, | |
height = 23, | |
}, | |
}, | |
}, | |
groups = { | |
party = { | |
enabled = true, | |
anchorFrom = 'TOPLEFT', | |
anchorObj = 'player', | |
anchorTo = 'BOTTOMLEFT', | |
anchorX = 0, | |
anchorY = -109, | |
width = 230, | |
height = 23, | |
}, | |
raid = { | |
enabled = false, | |
}, | |
} | |
} | |
function addon:DetermineAnchorObject(data) | |
return self.units and self.units[data] or UIParent | |
end | |
function addon:OnEnable() | |
oUF:RegisterStyle('NaruUI', styleFunction) | |
oUF:SetActiveStyle('NaruUI') | |
local frame | |
for index, data in pairs(addon.defaults.frames.units)do | |
if(data.enabled)then | |
frame = oUF:Spawn(index,layoutName.."_"..index) | |
frame.db = data | |
addon.units[index] = frame | |
end | |
end | |
for index,unitFrame in pairs(addon.units)do | |
unitFrame:SetPoint( | |
unitFrame.db.anchorFrom, | |
self:DetermineAnchorObject(data.anchorObj), | |
unitFrame.db.anchorTo, | |
unitFrame.db.anchorX, | |
unitFrame.db.anchorY) | |
end | |
--[[ | |
oUF:Spawn('player', 'oUF_NaruUI_player'):SetPoint('TOPLEFT', UIParent, 10, -83) | |
oUF:Spawn('target', 'oUF_NaruUI_target'):SetPoint('TOPLEFT', UIParent, 450, -83) | |
oUF:Spawn('targettarget', 'oUF_NaruUI_targettarget'):SetPoint('TOPLEFT', oUF_NaruUI_target, 'TOPRIGHT', 5, 0) | |
oUF:Spawn('pet', 'oUF_NaruUI_pet'):SetPoint('TOPRIGHT', oUF_NaruUI_player, 'BOTTOMRIGHT', 0, -20) | |
--]] | |
local party = oUF:Spawn('header', layoutName..'_Party') | |
party:SetManyAttributes( | |
'template', 'oUF_Party', | |
'showParty', true, | |
'showPlayer', false, | |
'point', 'LEFT', | |
'xoffset', 0, | |
'yOffset', -60) | |
party:SetPoint() | |
addon:RegisterEvent('PLAYER_LOGIN') | |
addon:RegisterEvent('RAID_ROSTER_UPDATE') | |
addon:RegisterEvent('PARTY_LEADER_CHANGED') | |
addon:RegisterEvent('PARTY_MEMBERS_CHANGED') | |
addon.groups = {} | |
addon.groups.party = party | |
function addon:ToggleGroupLayout() | |
if(InCombatLockdown()) then | |
self:RegisterEvent('PLAYER_REGEN_ENABLED') | |
else | |
self:UnregisterEvent('PLAYER_REGEN_ENABLED') | |
if(GetNumRaidMembers() > 0) then | |
self.groups.party:Hide() | |
else | |
self.groups.party:Show() | |
end | |
end | |
end | |
function addon:PLAYER_LOGIN() | |
self:ToggleGroupLayout() | |
end | |
function addon:RAID_ROSTER_UPDATE() | |
self:ToggleGroupLayout() | |
end | |
function addon:PARTY_LEADER_CHANGED() | |
self:ToggleGroupLayout() | |
end | |
function addon:PARTY_MEMBERS_CHANGED() | |
self:ToggleGroupLayout() | |
end | |
end | |
function addon:LoadDB() | |
oUF_NaruUIDB = oUF_NaruUIDB or {} | |
for k, v in pairs(NaruUIDefaults) do | |
if(type(oUF_NaruUIDB[k]) == 'nil') then | |
oUF_NaruUIDB[k] = v | |
end | |
end | |
--self.db = oUF_NaruUIDB -- not used yet | |
self.db = NaruUIDefaults | |
end | |
function addon:ADDON_LOADED(event, frame) | |
if frame ~= self.layoutName then return end | |
self:LoadDB() | |
self:OnEnable() | |
self:UnregisterEvent("ADDON_LOADED") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment