/trunk
local max = math.max |
local floor = math.floor |
local flat = [=[Interface\AddOns\ncMedia\flat]=] |
local backdrop = { |
bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], |
insets = {top = -1, bottom = -1, left = -1, right = -1} |
} |
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}), |
runes = setmetatable({ |
[1] = {0.8, 0, 0}, |
[3] = {0, 0.4, 0.7}, |
[4] = {0.8, 0.8, 0.8} |
}, {__index = oUF.colors.runes}) |
}, {__index = oUF.colors}) |
local buffFilter = { |
[GetSpellInfo(62600)] = true, |
[GetSpellInfo(61336)] = true, |
[GetSpellInfo(52610)] = true, |
[GetSpellInfo(22842)] = true, |
[GetSpellInfo(22812)] = true, |
[GetSpellInfo(16870)] = true |
} |
local function menu(self) |
local drop = _G[string.gsub(self.unit, '(.)', string.upper, 1) .. 'FrameDropDown'] |
if(drop) then |
ToggleDropDownMenu(1, nil, drop, 'cursor') |
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 updatePower(self, event, unit, bar, minVal, maxVal) |
if(unit ~= 'target') then return end |
if(maxVal ~= 0) then |
self.Health:SetHeight(22) |
bar:Show() |
else |
self.Health:SetHeight(27) |
bar:Hide() |
end |
end |
local function castIcon(self, event, unit) |
local castbar = self.Castbar |
if(castbar.interrupt) then |
castbar.Button:SetBackdropColor(0, 0.9, 1) |
else |
castbar.Button:SetBackdropColor(0, 0, 0) |
end |
end |
local function castTime(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 updateTime(self, elapsed) |
self.remaining = max(self.remaining - elapsed, 0) |
self.time:SetText(self.remaining < 90 and floor(self.remaining) or '') |
end |
local function updateBuff(self, icons, unit, icon, index) |
local _, _, _, _, _, duration, expiration = UnitAura(unit, index, icon.filter) |
if(duration > 0 and expiration) then |
icon.remaining = expiration - GetTime() |
icon:SetScript('OnUpdate', updateTime) |
else |
icon:SetScript('OnUpdate', nil) |
icon.time:SetText() |
end |
end |
local function updateDebuff(self, icons, unit, icon, index) |
local _, _, _, _, dtype = UnitAura(unit, index, icon.filter) |
if(icon.debuff) then |
if(not UnitIsFriend('player', unit) and icon.owner ~= 'player' and icon.owner ~= 'vehicle') then |
icon:SetBackdropColor(0, 0, 0) |
icon.icon:SetDesaturated(true) |
else |
local color = DebuffTypeColor[dtype] or DebuffTypeColor.none |
icon:SetBackdropColor(color.r * 0.6, color.g * 0.6, color.b * 0.6) |
icon.icon:SetDesaturated(false) |
end |
end |
end |
local function createAura(self, button, icons) |
icons.showDebuffType = true |
button.cd:SetReverse() |
button:SetBackdrop(backdrop) |
button:SetBackdropColor(0, 0, 0) |
button.icon:SetTexCoord(0.06, 0.94, 0.06, 0.94) |
button.icon:SetDrawLayer('ARTWORK') |
button.overlay:SetTexture() |
if(self.unit == 'player') then |
icons.disableCooldown = true |
button.time = button:CreateFontString(nil, 'OVERLAY', 'NumberFontNormal') |
button.time:SetPoint('TOPLEFT', button) |
end |
end |
local function customFilter(icons, unit, icon, name, rank, texture, count, dtype, duration, expiration, caster) |
if(buffFilter[name] and caster == 'player') then |
return true |
end |
end |
local function style(self, unit) |
self.colors = colors |
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', nil, self) |
self.Health:SetPoint('TOPRIGHT') |
self.Health:SetPoint('TOPLEFT') |
self.Health:SetStatusBarTexture(flat) |
self.Health:SetStatusBarColor(0.25, 0.25, 0.35) |
self.Health:SetHeight((unit == 'focus' or unit == 'targettarget') and 20 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 health = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight') |
health:SetPoint('RIGHT', self.Health, -2, -1) |
health.frequentUpdates = 0.25 |
self:Tag(health, '[phealth]') |
self.RaidIcon = self.Health:CreateTexture(nil, 'OVERLAY') |
self.RaidIcon:SetPoint('TOP', self, 0, 8) |
self.RaidIcon:SetHeight(16) |
self.RaidIcon:SetWidth(16) |
if(unit == 'focus' or unit == 'targettarget') then |
self:SetAttribute('initial-height', 20) |
self:SetAttribute('initial-width', 182) |
self.Debuffs = CreateFrame('Frame', nil, self) |
self.Debuffs:SetHeight(20) |
self.Debuffs:SetWidth(44) |
self.Debuffs.num = 2 |
self.Debuffs.size = 20 |
self.Debuffs.spacing = 4 |
self.PostCreateAuraIcon = createAura |
if(unit == 'focus') then |
self.Debuffs:SetPoint('TOPLEFT', self, 'TOPRIGHT', 4, 0) |
self.Debuffs.onlyShowPlayer = true |
self.Debuffs.initialAnchor = 'TOPLEFT' |
else |
self.Debuffs:SetPoint('TOPRIGHT', self, 'TOPLEFT', -4, 0) |
self.Debuffs.initialAnchor = 'TOPRIGHT' |
self.Debuffs['growth-x'] = 'LEFT' |
end |
else |
self.Power = CreateFrame('StatusBar', nil, self) |
self.Power:SetPoint('BOTTOMRIGHT') |
self.Power:SetPoint('BOTTOMLEFT') |
self.Power:SetPoint('TOP', self.Health, 'BOTTOM', 0, -1) |
self.Power:SetStatusBarTexture(flat) |
self.Power.frequentUpdates = true |
self.Power.colorClass = true |
self.Power.colorTapping = true |
self.Power.colorDisconnected = true |
self.Power.colorReaction = unit ~= 'pet' |
self.Power.colorHappiness = unit == 'pet' |
self.Power.colorPower = 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 |
end |
if(unit == 'player' or unit == 'pet') then |
if(IsAddOnLoaded('oUF_Experience')) then |
self.Experience = CreateFrame('StatusBar', nil, self) |
self.Experience:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -10) |
self.Experience:SetPoint('TOPRIGHT', self, 'BOTTOMRIGHT', 0, -10) |
self.Experience:SetHeight(11) |
self.Experience:SetStatusBarTexture(flat) |
self.Experience:SetStatusBarColor(0.15, 0.7, 0.1) |
self.Experience.Tooltip = true |
self.Experience.Rested = CreateFrame('StatusBar', nil, self) |
self.Experience.Rested:SetAllPoints(self.Experience) |
self.Experience.Rested:SetStatusBarTexture(flat) |
self.Experience.Rested:SetStatusBarColor(0, 0.4, 1, 0.6) |
self.Experience.Rested:SetBackdrop(backdrop) |
self.Experience.Rested:SetBackdropColor(0, 0, 0) |
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 |
local power = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft') |
power:SetPoint('LEFT', self.Health, 2, -1) |
power.frequentUpdates = 0.1 |
self:Tag(power, '[ppower][( )druidpower]') |
else |
local info = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft') |
info:SetPoint('LEFT', self.Health, 2, -1) |
info:SetPoint('RIGHT', health, 'LEFT') |
self:Tag(info, '[pname]|cff0090ff[( )rare]|r') |
end |
if(unit == 'pet') then |
self:SetAttribute('initial-height', 27) |
self:SetAttribute('initial-width', 130) |
self.Auras = CreateFrame('Frame', nil, self) |
self.Auras:SetPoint('TOPRIGHT', self, 'TOPLEFT', -4, 0) |
self.Auras:SetHeight(4) |
self.Auras:SetWidth(256) |
self.Auras.size = 22 |
self.Auras.spacing = 4 |
self.Auras.initialAnchor = 'TOPRIGHT' |
self.Auras['growth-x'] = 'LEFT' |
self.PostCreateAuraIcon = createAura |
end |
if(unit == 'player' or unit == 'target') then |
self:SetAttribute('initial-height', 27) |
self:SetAttribute('initial-width', 230) |
self.Buffs = CreateFrame('Frame', nil, self) |
self.Buffs:SetPoint('TOPLEFT', self, 'TOPRIGHT', 4, 0) |
self.Buffs:SetHeight(44) |
self.Buffs:SetWidth(236) |
self.Buffs.num = 20 |
self.Buffs.size = 20 |
self.Buffs.spacing = 4 |
self.Buffs.initialAnchor = 'TOPLEFT' |
self.Buffs['growth-y'] = 'DOWN' |
self.PostCreateAuraIcon = createAura |
self.Castbar = CreateFrame('StatusBar', nil, self) |
self.Castbar:SetWidth(205) |
self.Castbar:SetHeight(16) |
self.Castbar:SetStatusBarTexture(flat) |
self.Castbar:SetStatusBarColor(0.25, 0.25, 0.35) |
self.Castbar:SetBackdrop(backdrop) |
self.Castbar:SetBackdropColor(0, 0, 0) |
self.Castbar.bg = self.Castbar:CreateTexture(nil, 'BORDER') |
self.Castbar.bg:SetAllPoints(self.Castbar) |
self.Castbar.bg:SetTexture(0.3, 0.3, 0.3) |
self.Castbar.Text = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft') |
self.Castbar.Text:SetPoint('LEFT', 2, 1) |
self.Castbar.Time = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight') |
self.Castbar.Time:SetPoint('RIGHT', -2, 1) |
self.Castbar.CustomTimeText = castTime |
self.Castbar.Button = CreateFrame('Frame', nil, self.Castbar) |
self.Castbar.Button:SetHeight(21) |
self.Castbar.Button:SetWidth(21) |
self.Castbar.Button:SetBackdrop(backdrop) |
self.Castbar.Button:SetBackdropColor(0, 0, 0) |
self.Castbar.Icon = self.Castbar.Button:CreateTexture(nil, 'ARTWORK') |
self.Castbar.Icon:SetAllPoints(self.Castbar.Button) |
self.Castbar.Icon:SetTexCoord(0.08, 0.92, 0.08, 0.92) |
if(unit == 'target') then |
self.PostCastStart = castIcon |
self.PostChannelStart = castIcon |
self.Castbar:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -60) |
self.Castbar.Button:SetPoint('BOTTOMLEFT', self.Castbar, 'BOTTOMRIGHT', 4, 0) |
else |
self.Castbar:SetPoint('TOPRIGHT', self, 'BOTTOMRIGHT', 0, -60) |
self.Castbar.Button:SetPoint('BOTTOMRIGHT', self.Castbar, 'BOTTOMLEFT', -4, 0) |
end |
self.PostUpdatePower = updatePower |
end |
if(unit == 'target') then |
self.Debuffs = CreateFrame('Frame', nil, self) |
self.Debuffs:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -4) |
self.Debuffs:SetHeight(20 * 0.97) |
self.Debuffs:SetWidth(230) |
self.Debuffs.num = 20 |
self.Debuffs.size = 20 * 0.97 |
self.Debuffs.spacing = 4 |
self.Debuffs.initialAnchor = 'TOPLEFT' |
self.Debuffs['growth-y'] = 'DOWN' |
self.PostCreateAuraIcon = createAura |
self.PostUpdateAuraIcon = updateDebuff |
self.CPoints = self:CreateFontString(nil, 'OVERLAY', 'SubZoneTextFont') |
self.CPoints:SetPoint('RIGHT', self, 'LEFT', -9, 0) |
self.CPoints:SetTextColor(1, 1, 1) |
self.CPoints:SetJustifyH('RIGHT') |
self.CPoints.unit = PlayerFrame.unit |
self:RegisterEvent('UNIT_COMBO_POINTS', updateCombo) |
end |
if(unit == 'player') then |
if(select(2, UnitClass('player')) == 'DEATHKNIGHT') then |
self.Runes = CreateFrame('Frame', nil, self) |
self.Runes:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -1) |
self.Runes:SetHeight(4) |
self.Runes:SetWidth(230) |
self.Runes:SetBackdrop(backdrop) |
self.Runes:SetBackdropColor(0, 0, 0) |
self.Runes.anchor = 'TOPLEFT' |
self.Runes.growth = 'RIGHT' |
self.Runes.height = 4 |
self.Runes.width = 230 / 6 - 0.85 |
for index = 1, 6 do |
self.Runes[index] = CreateFrame('StatusBar', nil, self.Runes) |
self.Runes[index]:SetStatusBarTexture(flat) |
self.Runes[index].bg = self.Runes[index]:CreateTexture(nil, 'BACKGROUND') |
self.Runes[index].bg:SetAllPoints(self.Runes[index]) |
self.Runes[index].bg:SetTexture(0.3, 0.3, 0.3) |
end |
end |
self.Leader = self.Health:CreateTexture(nil, 'OVERLAY') |
self.Leader:SetPoint('TOPLEFT', self, 0, 8) |
self.Leader:SetHeight(16) |
self.Leader:SetWidth(16) |
self.Assistant = self.Health:CreateTexture(nil, 'OVERLAY') |
self.Assistant:SetPoint('TOPLEFT', self, 0, 8) |
self.Assistant:SetHeight(16) |
self.Assistant:SetWidth(16) |
local info = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall') |
info:SetPoint('CENTER', 0, -1) |
info.frequentUpdates = 0.25 |
self:Tag(info, '[pthreat]|cffff0000[pvptime]|r') |
self.PostUpdateAuraIcon = updateBuff |
self.CustomAuraFilter = customFilter |
end |
self.DebuffHighlightBackdrop = true |
self.DebuffHighlightFilter = true |
end |
oUF:RegisterStyle('P3lim', style) |
oUF:SetActiveStyle('P3lim') |
oUF:Spawn('player'):SetPoint('CENTER', UIParent, -220, -250) |
oUF:Spawn('target'):SetPoint('CENTER', UIParent, 220, -250) |
oUF:Spawn('targettarget'):SetPoint('BOTTOMRIGHT', oUF.units.target, 'TOPRIGHT', 0, 5) |
oUF:Spawn('focus'):SetPoint('BOTTOMLEFT', oUF.units.player, 'TOPLEFT', 0, 5) |
oUF:Spawn('pet'):SetPoint('RIGHT', oUF.units.player, 'LEFT', -25, 0) |
local format = string.format |
local gsub = string.gsub |
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}), |
}, {__index = oUF.colors}) |
local function shortVal(value) |
if(value >= 1e6) then |
return ('%.2fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1') |
elseif(value >= 1e4) then |
return ('%.1fk'):format(value / 1e3):gsub('%.?0+([km])$', '%1') |
else |
return value |
end |
end |
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 ('|cff%02x%02x%02x'):format(r * 255, g * 255, b * 255) |
end |
oUF.Tags['[pvptime]'] = function(unit) |
return UnitIsPVP(unit) and not IsPVPTimerRunning() and '*' or IsPVPTimerRunning() and ('%d:%02d'):format((GetPVPTimer() / 1000) / 60, (GetPVPTimer() / 1000) % 60) |
end |
oUF.TagEvents['[pthreat]'] = 'UNIT_THREAT_LIST_UPDATE' |
oUF.Tags['[pthreat]'] = function() |
local _, _, perc = UnitDetailedThreatSituation('player', 'target') |
return perc and ('%s%d%%|r'):format(hex(GetThreatStatusColor(UnitThreatSituation('player', 'target'))), perc) |
end |
oUF.Tags['[phealth]'] = function(unit) |
local min, max = UnitHealth(unit), UnitHealthMax(unit) |
local status = not UnitIsConnected(unit) and 'Offline' or UnitIsGhost(unit) and 'Ghost' or UnitIsDead(unit) and 'Dead' |
local target = unit == 'target' and UnitCanAttack('player', unit) and ('%s (%d|cff0090ff%%|r)'):format(shortVal(min), min / max * 100) |
local player = unit == 'player' and min ~= max and ('|cffff8080%d|r %d|cff0090ff%%|r'):format(min - max, min / max * 100) |
return status and status or target and target or player and player or min ~= max and ('%s |cff0090ff/|r %s'):format(shortVal(min), shortVal(max)) or max |
end |
oUF.Tags['[ppower]'] = function(unit) |
local _, str = UnitPowerType(unit) |
return ('%s%d|r'):format(hex(colors.power[str] or {1, 1, 1}), oUF.Tags['[curpp]'](unit) or '') |
end |
oUF.TagEvents['[pname]'] = 'UNIT_NAME_UPDATE UNIT_REACTION UNIT_FACTION' |
oUF.Tags['[pname]'] = function(unit) |
local colorString = hex((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 {1, 0, 0} or {1, 1, 1}) |
return ('%s%s|r'):format(colorString, 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 unit == 'player' and UnitPowerType(unit) ~= 0 and min ~= max and ('|cff0090ff%d%%|r'):format(min / max * 100) |
end |
## Interface: 30200 |
## Author: p3lim |
## Version: 30200.2-Beta |
## Title: oUF P3lim |
## Notes: Just another oUF layout |
## RequiredDeps: oUF |
## OptionalDeps: oUF_DebuffHighlight, oUF_Experience |
tags.lua |
oUF_P3lim.lua |
## Interface: 30200 +## Author: Nightcracker +## Version: 1.0 +## Title: ncBags +## Notes: Bag replacement + +ncBags.lua |
local blank = "Interface\\AddOns\\ncMedia\\blank" +local blank2 = "Interface\\AddOns\\ncMedia\\blank2" +local g = CreateFrame("Frame", "BagBackgroundAnchor") +CreatePanel(g, 20, 50, "CENTER", UIParent, "CENTER", 0, 400) +g:EnableMouse(true) +g:SetMovable(true) +g:SetUserPlaced(true) +g:RegisterForDrag("LeftButton") +g:SetScript("OnDragStart", g.StartMoving) +g:SetScript("OnDragStop", g.StopMovingOrSizing) +g:SetScale(.64) +g:Hide() + +g.text = g:CreateFontString(nil, "OVERLAY") +g.text:SetFont("Interface\\AddOns\\ncMedia\\slkscr.TTF", 12, "MONOCHROME") +g.text:SetPoint("CENTER", g) +g.text:SetText("BAGS") + +local f = CreateFrame("Frame", "BagBackgroundFrame", BagBackgroundAnchor) +CreatePanel(f, 0, 480, "TOPLEFT", BagBackgroundAnchor, "BOTTOMLEFT", 0, -5) +f:SetFrameStrata("DIALOG") + +local h = CreateFrame("Frame", "BagClosebutton", BagBackgroundAnchor) +CreatePanel(h, 20, 20, "BOTTOMRIGHT", f, "TOPRIGHT", 0, 5) +h:EnableMouse(true) +h:SetScript("OnMouseup", CloseAllBags) +h.x = g:CreateFontString(nil, "OVERLAY") +h.x:SetFont("Interface\\AddOns\\ncMedia\\slkscr.TTF", 12, "MONOCHROME") +h.x:SetPoint("CENTER", h, "CENTER", -1, 1) +h.x:SetText("X") + +local i = CreateFrame("Frame", "BagMoneyBackground", BagBackgroundAnchor) +i:EnableMouse(true) +i.moneyType = "PLAYER" +i:SetScript("OnMouseup", function() OpenCoinPickupFrame(COPPER_PER_GOLD, MoneyTypeInfo["PLAYER"].UpdateFunc(), i) end) +i.x = i:CreateFontString(nil, "OVERLAY") +i.x:SetFont("Interface\\AddOns\\ncMedia\\slkscr.TTF", 12, "MONOCHROME") +i.x:SetPoint("CENTER", i, "CENTER", -1, 1) +local co = GetMoney() +local go, si, co = tonumber(string.sub(co,1,-5)) or 0, tonumber(string.sub(co,-4,-3)) or 0, tonumber(string.sub(co,-2,-1)) or 0 +i.x:SetText("|cFF999999"..go.."|cffffd700g|cFF999999 "..si.."|cffc7c7cfs|cFF999999 "..co.."|cffeda55fc") +CreatePanel(i, 20, i.x:GetStringWidth()+10, "BOTTOM", f, "TOP", 0, 5) + +ContainerFrame5:HookScript("OnShow", function() + local numrows, lastrowbutton, numbuttons, lastbutton = 0, ContainerFrame1Item1, 1, ContainerFrame1Item1 + for i=1,5 do + for j=1,GetContainerNumSlots(i-1) do + local b = _G["ContainerFrame"..i.."Item"..j] + b:ClearAllPoints() + if j==1 and i==1 then + b:SetPoint("TOPLEFT", BagBackgroundFrame, "TOPLEFT", 10, -10) + elseif numbuttons/10==floor(numbuttons/10) then + b:SetPoint("TOP", lastrowbutton, "BOTTOM", 0, -10) + lastrowbutton = _G["ContainerFrame"..i.."Item"..j] + numrows = numrows+1 + numbuttons = numbuttons + 1 + else + b:SetPoint("LEFT", lastbutton, "RIGHT", 10, 0) + numbuttons = numbuttons + 1 + end + if not _G[b:GetName().."Panel"] then + local p = CreateFrame("Frame", b:GetName().."Panel", b) + p:SetFrameStrata("DIALOG") + p:SetWidth(b:GetWidth()+4) + p:SetHeight(b:GetHeight()+4) + p:SetPoint("TOPLEFT", b, "TOPLEFT", -2, 2) + p:SetBackdrop({ + bgFile = blank2, + edgeFile = blank, + tile = false, tileSize = 0, edgeSize = 1, + insets = { left = -1, right = -1, top = -1, bottom = -1 } + }) + p:SetBackdropColor(.1,.1,.1) + p:SetBackdropBorderColor(.6,.6,.6) + _G[b:GetName().."IconTexture"]:SetTexCoord(0.1,0.9,0.1,0.9) + b:SetNormalTexture(blank2) + b:SetPushedTexture(blank2) + b:SetHighlightTexture(blank2) + b:HookScript("OnEnter", function() _G[b:GetName().."Panel"]:SetBackdropBorderColor(.8,.8,.8) end) + b:HookScript("OnLeave", function() _G[b:GetName().."Panel"]:SetBackdropBorderColor(.6,.6,.6) end) + b:HookScript("OnMouseDown", function() _G[b:GetName().."Panel"]:SetBackdropBorderColor(1,1,1) end) + b:HookScript("OnMouseUp", function() _G[b:GetName().."Panel"]:SetBackdropBorderColor(.6,.6,.6) end) + local count = _G[b:GetName().."Count"] + count:ClearAllPoints() + count:SetPoint("BOTTOMRIGHT", 0, 2) + count:SetFont("Interface\\Addons\\ncMedia\\slkscr.ttf", 11, "MONOCHROME, THINOUTLINE") + end + b:SetFrameStrata("DIALOG") + lastbutton = b + end + end + f:SetHeight(47*(numrows+1)+10) + g:Show() +end) + +hooksecurefunc("ContainerFrame_OnHide", function() g:Hide() end) + +ToggleBag = function() + if ( IsOptionFrameOpen() ) then + return + end + for id=0,NUM_CONTAINER_FRAMES do + if not GetBagName(id) then return end + local size = GetContainerNumSlots(id) + if ( size > 0 or id == KEYRING_CONTAINER ) then + local containerShowing + for i=1, NUM_CONTAINER_FRAMES, 1 do + local frame = _G["ContainerFrame"..i] + if ( frame:IsShown() and frame:GetID() == id ) then + containerShowing = i + frame:Hide() + end + end + if ( not containerShowing ) then + ContainerFrame_GenerateFrame(ContainerFrame_GetOpenFrame(), size, id) + end + end + _G["ContainerFrame"..(id+1).."PortraitButton"]:Hide() + _G["ContainerFrame"..(id+1).."CloseButton"]:Hide() + _G["ContainerFrame"..(id+1)]:EnableMouse(false) + _G["ContainerFrame"..(id+1)]:SetPoint("TOPLEFT", UIParent, "BOTTOMRIGHT", 1000, -1000) + end +end |
local f = CreateFrame("Frame") |
f:SetScript("OnEvent", function(self, event, ...) |
if (event=="PLAYER_DEAD") then |
if (tostring(GetZoneText()) == "Wintergrasp") then |
RepopMe() |
end |
for i=1,MAX_BATTLEFIELD_QUEUES do |
local a = select(1, GetBattlefieldStatus(i)) |
if (a == "active") then |
RepopMe() |
end |
end |
else |
AcceptResurrect() |
StaticPopup1:Hide() |
end |
end) |
-- Register when I die and get resurrected |
f:RegisterEvent("PLAYER_DEAD") |
f:RegisterEvent("RESURRECT_REQUEST") |
## Interface: 30200 |
## Author: Nightcracker |
## Version: 1.0 |
## Title: ncResurrect |
## Notes: Lightweight addon for releasing in battlegrounds and accepting resses. |
ncResurrect.lua |
## Interface: 30200 |
## Author: Nightcracker |
## Version: 1.0 |
## Title: ncUI |
## Notes: Main config addon for ncUI and loads all libs |
## SavedVariables: ncUIdb |
LibStub.lua |
!ncUI.lua |
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info |
-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke |
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! |
local LibStub = _G[LIBSTUB_MAJOR] |
if not LibStub or LibStub.minor < LIBSTUB_MINOR then |
LibStub = LibStub or {libs = {}, minors = {} } |
_G[LIBSTUB_MAJOR] = LibStub |
LibStub.minor = LIBSTUB_MINOR |
function LibStub:NewLibrary(major, minor) |
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") |
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") |
local oldminor = self.minors[major] |
if oldminor and oldminor >= minor then return nil end |
self.minors[major], self.libs[major] = minor, self.libs[major] or {} |
return self.libs[major], oldminor |
end |
function LibStub:GetLibrary(major, silent) |
if not self.libs[major] and not silent then |
error(("Cannot find a library instance of %q."):format(tostring(major)), 2) |
end |
return self.libs[major], self.minors[major] |
end |
function LibStub:IterateLibraries() return pairs(self.libs) end |
setmetatable(LibStub, { __call = LibStub.GetLibrary }) |
end |
ncUIdb = { + installed = {}, + colorscheme = {} +} +local p = UnitName("player") +local blank, border = "Interface\\AddOns\\ncMedia\\Blank", "Interface\\AddOns\\ncMedia\\border" + +function CreatePanel(f, h, w, a1, p, a2, x, y) + f:SetFrameLevel(1) + f:SetHeight(h) + f:SetWidth(w) + f:SetFrameStrata("BACKGROUND") + f:SetPoint(a1, p, a2, x, y) + f:SetBackdrop( { + bgFile = blank, + edgeFile = blank, + tile = false, tileSize = 0, edgeSize = 1, + insets = { left = -1, right = -1, top = -1, bottom = -1 } + }) + f:SetBackdropColor(.1, .1, .1, 1) + f:SetBackdropBorderColor(.6, .6, .6, 1) +end + +function ncUIdb:install() + SetCVar("useUiScale", 1) + SetCVar("uiScale", 0.63999998569489) + SetCVar("chatLocked", 1) + SetCVar("showClock", 0) + SetCVar("screenshotQuality", 10) + SetCVar("cameraDistanceMax", 50) + SetCVar("cameraDistanceMaxFactor", 3.4) + SetCVar("buffDurations", 1) + SetCVar("nameplateShowEnemies", 1) + + CoolLineDB = { + ["bgcolor"] = { + ["a"] = 0, + ["r"] = 0.9490196078431372, + ["g"] = 0.9490196078431372, + ["b"] = 0.9490196078431372, + }, + ["border"] = "Blizzard Dialog", + ["statusbar"] = "Blizzard", + ["fontsize"] = 10, + ["block"] = { + ["Hearthstone"] = true, + }, + ["spellcolor"] = { + ["a"] = 1, + ["r"] = 0.8, + ["g"] = 0.4, + ["b"] = 0, + }, + ["nospellcolor"] = { + ["a"] = 1, + ["r"] = 0, + ["g"] = 0, + ["b"] = 0, + }, + ["inactivealpha"] = 0.9999999999999999, + ["bordercolor"] = { + ["a"] = 0, + ["r"] = 1, + ["g"] = 1, + ["b"] = 1, + }, + ["w"] = 431, + ["y"] = -509, + ["font"] = "Friz Quadrata TT", + ["dbinit"] = 1, + ["activealpha"] = 0.9999999999999999, + ["h"] = 21, + ["fontcolor"] = { + ["a"] = 0.8, + ["r"] = 1, + ["g"] = 1, + ["b"] = 1, + }, + ["x"] = 0, + } + + local p = UnitName("player") + ncUIdb["installed"][p] = 1 + ReloadUI() +end + +StaticPopupDialogs.ncUI = { + text = "Set ncUI to the default configuration?", + button1 = ACCEPT, + button2 = CANCEL, + OnAccept = ncUIdb.install, + timeout = 0, + whileDead = 1, + hideOnEscape = 1 +} + +SLASH_CONFIGURE1 = "/configure" +SlashCmdList.CONFIGURE = function() StaticPopup_Show("ncUI") end +local f = CreateFrame("Frame") +f:RegisterEvent("PLAYER_ENTERING_WORLD") +f:SetScript("OnEvent", function() +if not (ncUIdb["installed"][p]) then + StaticPopupDialogs["ncUI"].text = "It seems that this is the first time you use ncUI on this character, install ncUI now?" + StaticPopup_Show("ncUI") + StaticPopupDialogs["ncUI"].text = "Set ncUI to the default configuration?" +end +f:UnregisterEvent("PLAYER_ENTERING_WORLD") +end) |
local _G = _G |
local function colorborder(name, action) |
local normal = _G[name.."NormalTexture"] |
if IsEquippedAction(action) then |
normal:SetVertexColor(.6, 1, .6, 1) |
elseif IsCurrentAction(action) then |
normal:SetVertexColor(1, 1, 1, 1) |
else |
normal:SetVertexColor(.6, .6, .6, 1) |
end |
normal:SetHeight(36) |
normal:SetWidth(36) |
normal:SetPoint("CENTER", 0, 0) |
end |
local function style(self) |
local name = self:GetName() |
local action = self.action |
local Button = _G[name] |
local Icon = _G[name.."Icon"] |
local Count = _G[name.."Count"] |
local Flash = _G[name.."Flash"] |
local HotKey = _G[name.."HotKey"] |
local Border = _G[name.."Border"] |
local Btname = _G[name.."Name"] |
local Button = _G[name] |
Icon:SetTexCoord(.08, .92, .08, .92) |
Icon:SetPoint("TOPLEFT", Button, 3, -3) |
Icon:SetPoint("BOTTOMRIGHT", Button, -3, 3) |
Flash:SetTexture("") |
Button:SetCheckedTexture("Interface\\Addons\\ncMedia\\button") |
Button:SetHighlightTexture("Interface\\Addons\\ncMedia\\button_hover") |
Button:SetPushedTexture("Interface\\Addons\\ncMedia\\button") |
Button:SetNormalTexture("Interface\\Addons\\ncMedia\\button") |
Count:ClearAllPoints() |
Count:SetPoint("BOTTOMRIGHT", 0, 2) |
Count:SetFont("Interface\\Addons\\ncMedia\\slkscr.ttf", 11, "MONOCHROME, THINOUTLINE") |
HotKey:SetText("") |
HotKey:Hide() |
HotKey.Show = function() end |
Btname:SetText("") |
Btname:Hide() |
Btname.Show = function() end |
Border:Hide() |
colorborder(name, action) |
end |
local function stylepet() |
for i=1, NUM_PET_ACTION_SLOTS do |
local name = "PetActionButton"..i |
local button = _G[name] |
local icon = _G[name.."Icon"] |
local normal = _G[name.."NormalTexture2"] |
normal:ClearAllPoints() |
normal:SetPoint("TOPLEFT", button, "TOPLEFT", -1, 1) |
normal:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 1, -1) |
normal:SetVertexColor(.6, .6, .6, 1) |
button:SetCheckedTexture("Interface\\Addons\\ncMedia\\button") |
button:SetHighlightTexture("Interface\\Addons\\ncMedia\\button_hover") |
button:SetPushedTexture("Interface\\Addons\\ncMedia\\button") |
button:SetNormalTexture("Interface\\Addons\\ncMedia\\button") |
icon:SetTexCoord(.08, .92, .08, .92) |
icon:SetPoint("TOPLEFT", button, 3, -3) |
icon:SetPoint("BOTTOMRIGHT", button, -3, 3) |
end |
end |
local function usable(self) |
local name = self:GetName() |
local action = self.action |
local icon = _G[name.."Icon"] |
local isUsable, notEnoughMana = IsUsableAction(action) |
if ActionHasRange(action) and IsActionInRange(action) == 0 then |
icon:SetVertexColor(0.8, 0.1, 0.1) |
return |
elseif notEnoughMana then |
icon:SetVertexColor(.1, .3, 1) |
return |
elseif isUsable then |
icon:SetVertexColor(.6, .6, .6) |
return |
else |
icon:SetVertexColor(.4, .4, .4) |
return |
end |
colorborder(name, action) |
end |
function onupdate(self, elapsed) |
if self.rangeTimer == TOOLTIP_UPDATE_TIME then |
usable(self) |
end |
end |
hooksecurefunc("ActionButton_OnUpdate", onupdate) |
hooksecurefunc("ActionButton_Update", style) |
hooksecurefunc("ActionButton_UpdateUsable", usable) |
hooksecurefunc("PetActionBar_Update", stylepet) |
## Interface: 30200 |
## Author: Nightcracker |
## Version: 1.0 |
## Title: ncButtonstyler |
## Notes: Styles all buttons |
ncButtonstyler.lua |
-- The default value will be used if no value is specified in the frame. These are the default values set in ncDatatext, this frame won't show up, it is for documentation only. |
LibStub("ncDatatext"):Create("Defaults", { |
rate = 1,-- This value determines how often all frames update in seconds(aka global update). Realtime updating(when the event occurs) must be done by registering the frame with the value "event". If an event is registered with the frame, it will not update with the global update anymore. (Self, event, ...) are passed to the content function if registered with an event. |
font = "Fonts\\FRIZQT__.ttf", -- The font that should be used. If you want to use an other font than the default, place your font in the ncDatatext folder, and change this value to "Interface\\Addons\\ncDatatext\\<Yourfontname>.ttf". It must be a TrueType font. |
fontsize = 8, -- The font size, simple. |
anchor = "CENTER", -- Which the frame should anchor to, can be any frame or BOTTOMLEFT, BOTTOM, BOTTOMRIGHT, LEFT, CENTER, RIGHT, TOPLEFT, TOP, TOPRIGHT. |
parent = "UIParent", -- The parent of the frame. |
x = 0, -- The horizontal offset from the anchor. A negative value moves x pixels to the left, a positive value x pixels to the right. |
y = 0, -- Same as above, but vertical. |
flags = "", -- Can be any comma-seperated combination of MONOCHROME, OUTLINE and THICKOUTLINE. For example flags = "OUTLINE" creates a little black border around the font. |
content = function(self, event, ...)return "" end, -- The actual content of the frame. Must always be a function, the return value is the displayed value. If the frame is registered to an event the update function will pass trough self, event and ... to the content function(as shown here). |
event = nil, -- The registered event of the frame, if one is given the frame will not update with the global update anymore(see rate). |
onclick = function(button) end, -- If the frame is clicked this function is run. The variable button will be passed wich can be LeftButton, RightButton, MiddleButton, Button4, Button5. |
}) |
-- 5 examples |
LibStub("ncDatatext"):Create("ExperienceRep", { |
x = 100, |
y = 100, |
content = function() |
if (UnitLevel("player")<MAX_PLAYER_LEVEL) then |
return "XP: "..UnitXP('player').."/"..UnitXPMax('player').." | "..string.format("%.2f", (UnitXP('player')/UnitXPMax('player')*100)).."%" |
else |
local _, _, minimum, maximum, value = GetWatchedFactionInfo() |
if ((value-minimum)==999) and ((maximum-minimum)==1000) then |
return "REP: "..(value-minimum).."/"..(maximum-minimum).." | 100%" |
else |
return "REP: "..(value-minimum).."/"..(maximum-minimum).." | "..string.format("%.2f", (value-minimum)/(maximum-minimum)*100).."%" |
end |
end |
end, |
event = "PLAYER_XP_UPDATE", |
}) |
LibStub("ncDatatext"):Create("FPS", { |
x = -100, |
y = -100, |
content = function() |
return "FPS: "..floor(GetFramerate()) |
end, |
}) |
LibStub("ncDatatext"):Create("Mail", { |
x = -100, |
y = 100, |
content = function() |
local mail = (HasNewMail() or 0) |
if mail>0 then |
return "You've got mail" |
else |
return "No new mail" |
end |
end, |
}) |
LibStub("ncDatatext"):Create("Latency", { |
x = 100, |
y = -100, |
content = function() |
return select(3, GetNetStats()).." MS" |
end, |
}) |
LibStub("ncDatatext"):Create("Memory", { |
content = function() |
local t = 0 |
UpdateAddOnMemoryUsage() |
for i=1, GetNumAddOns(), 1 do |
t = t + GetAddOnMemoryUsage(i) |
end |
if t > 1024 then |
return "Memory: "..(floor(t)/1024).." MB" |
else |
return "Memory: "..floor(t).." KB" |
end |
end, |
}) |
local lib = LibStub:NewLibrary("ncDatatext", 1) |
if not lib then return end |
function lib:Create(name, tab) |
assert(type(tab) == "table", "ncDatatext: Bad arguments given, for reference look at the config file.") |
assert(type(tab.content) == "function", "ncDatatext: Content must be a function, the value of the frame is the return value of the function.") |
local f = CreateFrame("Frame", name) |
local t, rate, font, fontsize, anchor, parent, x, y, flags, event, content, onclick, tooltip = f:CreateFontString(nil, "OVERLAY"), tab.rate or 1, tab.font or "Fonts\\FRIZQT__.ttf", tab.fontsize or 8, tab.anchor or "CENTER", tab.parent or "UIParent", tab.x or 0, tab.y or 0, tab.flags or "", tab.event or nil, tab.content or function() return "" end, tab.onclick or nil, tab.tooltip or nil |
t:SetFont(font, fontsize, flags) |
f:SetPoint(anchor, parent, anchor, x, y) |
t:SetPoint("CENTER", f) |
function f:Update(self, event, ...) |
t:SetText(content(self, event, ...)) |
f:SetHeight(t:GetStringHeight()) |
f:SetWidth(t:GetStringWidth()) |
end |
if onclick then |
f:EnableMouse(true) |
f:SetScript("OnMouseDown", function(self, button) |
onclick(button) |
end) |
end |
if tooltip then |
f:EnableMouse(true) |
f:SetScript("OnEnter", function() |
GameTooltip:SetOwner(this, "ANCHOR_CURSOR"); |
for i=1,#tooltip do |
if type(tooltip[i]) == "table" then |
GameTooltip:AddDoubleLine(tooltip[i][1],tooltip[i][2]) |
elseif type(tooltip[i]) == "function" then |
tooltip[i]() |
else |
GameTooltip:AddLine(tooltip[i]) |
end |
end |
GameTooltip:Show() |
end) |
f:SetScript("OnLeave", function() |
GameTooltip:Hide() |
end) |
end |
f:SetScript("OnEvent", function() |
f:Update() |
end) |
if event then |
f:RegisterEvent(event) |
f:Update() |
else |
f.elapsed = 0 |
f:SetScript("OnUpdate", function(self, elapsed) |
f.elapsed = f.elapsed + elapsed |
if (f.elapsed>rate) then |
f.elapsed = 0 |
f:Update() |
end |
end) |
f:RegisterEvent("PLAYER_ENTERING_WORLD") |
end |
end |
## Interface: 30200 +## Author: Nightcracker +## Version: 1.2 +## Title: ncDatatext +## Notes: Lightweight datatext addon, configuration in the Lua file. + +ncDatatext.lua +config.lua |
LibStub("ncDatatext"):Create("Bag", { |
x = -130, |
y = 3, |
font = "Interface\\Addons\\ncMedia\\slkscr.TTF", |
flags = "MONOCHROME", |
anchor = "BOTTOMRIGHT", |
content = function() |
local totfree = 0 |
for i=0,4 do |
totfree = totfree + GetContainerNumFreeSlots(i) |
end |
return "|cFF999999Bag: "..totfree |
end, |
}) |
LibStub("ncDatatext"):Create("Money", { |
x = 6, |
y = 3, |
font = "Interface\\Addons\\ncMedia\\slkscr.TTF", |
flags = "MONOCHROME", |
anchor = "BOTTOMLEFT", |
content = function() |
local c = GetMoney() |
local g, s, c = tonumber(string.sub(c,1,-5)) or 0, tonumber(string.sub(c,-4,-3)) or 0, tonumber(string.sub(c,-2,-1)) or 0 |
return "|cFF999999"..g.."|cffffd700g|cFF999999 "..s.."|cffc7c7cfs|cFF999999 "..c.."|cffeda55fc" |
end, |
}) |
LibStub("ncDatatext"):Create("Durability", { |
x = 180, |
y = 3, |
font = "Interface\\Addons\\ncMedia\\slkscr.TTF", |
flags = "MONOCHROME", |
anchor = "BOTTOM", |
content = function() |
local curDur, maxDur = 0,0 |
for i = 1, 20 do |
local curD, maxD = GetInventoryItemDurability(i) |
if maxD then |
curDur = curDur + curD |
maxDur = maxDur + maxD |
end |
end |
return "|cFF999999Durability: "..floor((curDur/maxDur)*100).."%" |
end, |
}) |
LibStub("ncDatatext"):Create("FPS", { |
x = 0, |
y = 3, |
anchor = "BOTTOM", |
font = "Interface\\Addons\\ncMedia\\slkscr.TTF", |
flags = "MONOCHROME", |
content = function() |
return "|cFF999999FPS: "..floor(GetFramerate()) |
end, |
}) |
LibStub("ncDatatext"):Create("Mail", { |
x = 186, |
y = 3, |
anchor = "BOTTOMLEFT", |
font = "Interface\\Addons\\ncMedia\\slkscr.TTF", |
flags = "MONOCHROME", |
content = function() |
local mail = (HasNewMail() or 0) |
if mail>0 then |
return "|cFF999999You've got mail" |
else |
return "|cFF999999No new mail" |
end |
end, |
}) |
LibStub("ncDatatext"):Create("Latency", { |
x = -6, |
y = 3, |
anchor = "BOTTOMRIGHT", |
font = "Interface\\Addons\\ncMedia\\slkscr.TTF", |
flags = "MONOCHROME", |
content = function() |
return "|cFF999999"..select(3, GetNetStats()).." MS" |
end, |
}) |
local function formatMem(memory, color) |
if color then |
statColor = { "", "" } |
else |
statColor = { "", "" } |
end |
local mult = 10^1 |
if memory > 999 then |
local mem = floor((memory/1024) * mult + 0.5) / mult |
if mem % 1 == 0 then |
return mem..string.format(".0 %sMB%s", unpack(statColor)) |
else |
return mem..string.format(" %sMB%s", unpack(statColor)) |
end |
else |
local mem = floor(memory * mult + 0.5) / mult |
if mem % 1 == 0 then |
return mem..string.format(".0 %sKB%s", unpack(statColor)) |
else |
return mem..string.format(" %sKB%s", unpack(statColor)) |
end |
end |
end |
local Total, Mem, MEMORY_TEXT, LATENCY_TEXT, Memory |
LibStub("ncDatatext"):Create("Memory", { |
x = -180, |
y = 3, |
anchor = "BOTTOM", |
font = "Interface\\Addons\\ncMedia\\slkscr.TTF", |
flags = "MONOCHROME", |
content = function() |
local t = 0 |
UpdateAddOnMemoryUsage() |
for i=1, GetNumAddOns(), 1 do |
t = t + GetAddOnMemoryUsage(i) |
end |
if t > 1024 then |
return "|cFF999999Memory: "..(floor(t/10.24)/100).." MB" |
else |
return "|cFF999999Memory: "..floor(t).." KB" |
end |
end, |
tooltip = { |
function() |
Memory = {} |
UpdateAddOnMemoryUsage() |
Total = 0 |
for i = 1, GetNumAddOns() do |
Mem = GetAddOnMemoryUsage(i) |
Memory[i] = { select(2, GetAddOnInfo(i)), Mem, IsAddOnLoaded(i) } |
Total = Total + Mem |
end |
MEMORY_TEXT = formatMem(Total, true) |
table.sort(Memory, function(a, b) |
if a and b then |
return a[2] > b[2] |
end |
end) |
GameTooltip:AddDoubleLine("MEMORY USAGE:",MEMORY_TEXT) |
for i = 1, #Memory do |
if Memory[i][3] then |
local red = Memory[i][2]/Total*2 |
local green = 1 - red |
GameTooltip:AddDoubleLine(Memory[i][1], formatMem(Memory[i][2], false), 1, 1, 1, red, green+1, 0) |
end |
end |
end, |
}, |
}) |
LibStub("ncDatatext"):Create("ExperienceRep", { |
x = -230, |
y = 3, |
anchor = "BOTTOMRIGHT", |
font = "Interface\\Addons\\ncMedia\\slkscr.TTF", |
flags = "MONOCHROME", |
content = function() |
if (UnitLevel("player")<MAX_PLAYER_LEVEL) then |
return "|cFF999999XP: "..UnitXP('player').."/"..UnitXPMax('player').." | "..string.format("%.2f", (UnitXP('player')/UnitXPMax('player')*100)).."%" |
else |
local t, _, minimum, maximum, value = GetWatchedFactionInfo() |
if not t then |
return "|cFF999999No faction watched" |
elseif ((value-minimum)==999) and ((maximum-minimum)==1000) then |
return "|cFF999999REP: "..(value-minimum).."/"..(maximum-minimum).." | 100%" |
else |
return "|cFF999999REP: "..(value-minimum).."/"..(maximum-minimum).." | "..string.format("%.2f", (value-minimum)/(maximum-minimum)*100).."%" |
end |
end |
end, |
}) |
## Interface: 30200 |
## Title: ncChat |
## Author: Nightcracker |
## Version: 1.0 |
## Notes: Addon for changing the chat layout and settings. |
ncChat.lua |
local hooks = {} |
local dummy = function() end |
local replaces = { |
['Guild'] = 'G', |
['Party'] = 'P', |
['Raid'] = 'R', |
['Raid Leader'] = 'RL', |
['Raid Warning'] = 'RW', |
['Officer'] = 'O', |
['Battleground'] = 'B', |
['Battleground Leader'] = 'BL', |
['(%d+)%. .-'] = '%1', |
} |
-- The function for timestamp and other stamps |
local function AddMessage(frame, text, red, green, blue, id) |
text = tostring(text) or '' |
for k,v in pairs(replaces) do |
text = text:gsub('|h%['..k..'%]|h', '|h'..v..'|h') |
end |
text = text:gsub('(|Hplayer.-|h)%[(.-)%]|h', '%1%2|h') |
text = text:gsub(' says:', ':') |
text = text:gsub(' whispers:', ' <') |
text = text:gsub('To (|Hplayer.+|h):', '%1 >') |
text = text:gsub('(|Hplayer.+|h) has earned the achievement (.+)!', '%1 ! %2') |
text = '|cff999999' .. date('%H%M') .. '|r ' .. text |
return hooks[frame](frame, text, red, green, blue, id) |
end |
-- The function for hiding a frame forever |
local function HideFrame(f) |
f.Show = dummy |
f:Hide() |
end |
-- Set up editbox |
local x=({ChatFrameEditBox:GetRegions()}) |
x[6]:SetAlpha(0) |
x[7]:SetAlpha(0) |
x[8]:SetAlpha(0) |
ChatFrameEditBox:SetAltArrowKeyMode(nil) |
ChatFrameEditBox:ClearAllPoints() |
ChatFrameEditBox:SetPoint("BOTTOMLEFT", _G.ChatFrame1, "TOPLEFT", -5, 20) |
ChatFrameEditBox:SetPoint("BOTTOMRIGHT", _G.ChatFrame1, "TOPRIGHT", 5, 20) |
-- Set up chatframe1 |
ChatFrame1:SetUserPlaced(nil) |
ChatFrame1:SetFrameLevel(3) |
ChatFrame1:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 18, 43) |
ChatFrame1:SetWidth(380) |
ChatFrame1:SetHeight(120) |
ChatFrame1.ClearAllPoints = dummy |
ChatFrame1.SetPoint = dummy |
HideFrame(ChatFrameMenuButton) |
-- sticky channels |
ChatTypeInfo.SAY.sticky = 1 |
ChatTypeInfo.EMOTE.sticky = 1 |
ChatTypeInfo.YELL.sticky = 1 |
ChatTypeInfo.PARTY.sticky = 1 |
ChatTypeInfo.GUILD.sticky = 1 |
ChatTypeInfo.OFFICER.sticky = 1 |
ChatTypeInfo.RAID.sticky = 1 |
ChatTypeInfo.RAID_WARNING.sticky = 1 |
ChatTypeInfo.BATTLEGROUND.sticky = 1 |
ChatTypeInfo.WHISPER.sticky = 1 |
ChatTypeInfo.CHANNEL.sticky = 1 |
-- Hide the chatframe textures |
for i = 1,7 do |
for k,v in pairs(CHAT_FRAME_TEXTURES) do |
_G["ChatFrame"..i..v]:Hide() |
end |
end |
for k in pairs(CHAT_FRAME_TEXTURES) do |
CHAT_FRAME_TEXTURES[k] = nil |
end |
-- Set up the chatframes |
for i=1,7 do |
local f = _G['ChatFrame'..i] |
HideFrame(_G['ChatFrame'..i..'UpButton']) |
HideFrame(_G['ChatFrame'..i..'DownButton']) |
HideFrame(_G['ChatFrame'..i..'BottomButton']) |
f:SetFading(false) |
f:EnableMouseWheel(true) |
f:SetScript('OnMouseWheel', function(frame, delta) |
if delta > 0 and IsShiftKeyDown() then |
frame:ScrollToTop() |
elseif delta > 0 then |
frame:ScrollUp() |
elseif delta < 0 and IsShiftKeyDown() then |
frame:ScrollToBottom() |
else |
frame:ScrollDown() |
end |
end) |
hooks[f] = f.AddMessage |
f.AddMessage = AddMessage |
end |
## Interface: 30200 +## Author: Nightcracker +## Version: 1.2 +## Title: ncPanels +## Notes: All panels in ncUI in one addon. + +ncPanels.lua |
local a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q = CreateFrame("Frame", "ActionBarBackground"), CreateFrame("Frame", "LineToActionBar"), CreateFrame("Frame", "LineToActionBar2"), CreateFrame("Frame", "Dataframe"), CreateFrame("Frame", "ChatBackground"), CreateFrame("Frame", "LineToChat"), CreateFrame("Frame", "LineToChat2"), CreateFrame("Frame", "ChatTab1"), CreateFrame("Frame", "ChatTab2"), CreateFrame("Frame", "ChatFrameEditBoxBackground", ChatFrameEditBox), CreateFrame("Frame", "LineToEditbox", ChatFrameEditBox), CreateFrame("Frame", "LineToEditbox2", ChatFrameEditBox), CreateFrame("Frame", "LineToMinimap"), CreateFrame("Frame", "LineToMinimap2"), CreateFrame("Frame", "PetActionBarBackground", PetActionButton1), CreateFrame("Frame", "LineToPetActionBarBackground", PetActionBarBackground), CreateFrame("Frame", "LineToPetActionBarBackground2", PetActionBarBackground) +local htext, itext = h:CreateFontString(nil, "OVERLAY"), i:CreateFontString(nil, "OVERLAY") + +CreatePanel(a, 46, 357, "BOTTOM", "UIParent", "BOTTOM", 0, 22) +CreatePanel(b, 9, 2, "TOP", "ActionBarBackground", "BOTTOM", 357/-3, 0) +CreatePanel(c, 9, 2, "TOP", "ActionBarBackground", "BOTTOM", 357/3, 0) +CreatePanel(d, 17, 1440, "BOTTOM", "UIParent", "BOTTOM", -3, -3) +CreatePanel(e, 86, 250, "BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 8, 22) +CreatePanel(f, 9, 2, "TOP", "ChatBackground", "BOTTOM", 250/-3, 0) +CreatePanel(g, 9, 2, "TOP", "ChatBackground", "BOTTOM", 250/3, 0) +CreatePanel(h, 10, 30, "BOTTOMLEFT", "ChatBackground", "TOPLEFT", 5, -1) +h:EnableMouse(true) +h:SetScript("OnMouseDown", function(self, button) + h:SetBackdropColor(.2,.2,.2) + ChatFrame1:Show() + ChatFrame2:Hide() + i:SetBackdropColor(.1,.1,.1) +end) +h:SetBackdropColor(.2,.2,.2) +htext:SetFont("Interface\\AddOns\\ncMedia\\slkscr.TTF", 7, "MONOCHROME") +htext:SetPoint("CENTER", h) +htext:SetText("Chat") +CreatePanel(i, 10, 42, "LEFT", "ChatTab1", "RIGHT", 2, 0) +i:EnableMouse(true) +i:SetScript("OnMouseDown", function(self, button) + i:SetBackdropColor(.2,.2,.2) + ChatFrame2:Show() + ChatFrame1:Hide() + h:SetBackdropColor(.1,.1,.1) +end) +itext:SetFont("Interface\\AddOns\\ncMedia\\slkscr.TTF", 7, "MONOCHROME") +itext:SetPoint("CENTER", i, -1, 0) +itext:SetText("Combat") +CreatePanel(j, 20, 384, "LEFT", "ChatFrameEditBox", "LEFT", 7, -1) +CreatePanel(k, 19, 2, "TOP", "ChatFrameEditBox", "BOTTOM", 50+310/-3, 5) +CreatePanel(l, 19, 2, "TOP", "ChatFrameEditBox", "BOTTOM", 50+310/3, 5) +CreatePanel(m, 9, 2, "TOP", "Minimap", "BOTTOM", 88/3, 0) +CreatePanel(n, 9, 2, "TOP", "Minimap", "BOTTOM", 88/-3, 0) +CreatePanel(o, 48, 394, "LEFT", "PetActionButton1", "LEFt", -10, 0) +CreatePanel(p, 12, 2, "TOP", "PetActionBarBackground", "BOTTOM", 394/3, -1) +CreatePanel(q, 12, 2, "TOP", "PetActionBarBackground", "BOTTOM", 394/-3, -1) |
## Interface: 30200 |
## Title: CoolLine |
## Notes: Shows cooldowns on a single bar. |
## Author: TotalPackage |
## Version: 3.2.004 |
## SavedVariables: CoolLineDB |
## SavedVariablesPerCharacter: CoolLineCharDB |
## LoadManagers: AddonLoader |
## X-LoadOn-Always: delayed |
core.lua |
local CoolLine = CreateFrame("Frame", "CoolLine", UIParent) |
local self = CoolLine |
self:SetScript("OnEvent", function(this, event, ...) |
this[event](this, ...) |
end) |
local _G = getfenv(0) |
local pairs, ipairs = pairs, ipairs |
local tinsert, tremove = tinsert, tremove |
local GetTime = GetTime |
local random = math.random |
local strmatch = strmatch |
local UnitExists, HasPetUI = UnitExists, HasPetUI |
local db, block |
local backdrop = { edgeSize=16, } |
local section, iconsize = 0, 0 |
local tick0, tick1, tick10, tick30, tick60, tick120, tick300 |
local BOOKTYPE_SPELL, BOOKTYPE_PET = BOOKTYPE_SPELL, BOOKTYPE_PET |
local spells = { [BOOKTYPE_SPELL] = { }, [BOOKTYPE_PET] = { }, } |
local frames, cooldowns = { }, { } |
local SetValue, updatelook, createfs, ShowOptions, RuneCheck |
local function SetValueH(this, v, just) |
this:SetPoint(just or "CENTER", self, "LEFT", v, 0) |
end |
local function SetValueHR(this, v, just) |
this:SetPoint(just or "CENTER", self, "LEFT", db.w - v, 0) |
end |
local function SetValueV(this, v, just) |
this:SetPoint(just or "CENTER", self, "BOTTOM", 0, v) |
end |
local function SetValueVR(this, v, just) |
this:SetPoint(just or "CENTER", self, "BOTTOM", 0, db.h - v) |
end |
self:RegisterEvent("ADDON_LOADED") |
function CoolLine:ADDON_LOADED(a1) |
if a1 ~= "CoolLine" then return end |
self:UnregisterEvent("ADDON_LOADED") |
self.ADDON_LOADED = nil |
CoolLineDB = CoolLineDB or { } |
if CoolLineDB.perchar then |
CoolLineCharDB = CoolLineCharDB or CoolLineDB |
db = CoolLineCharDB |
else |
CoolLineCharDB = nil |
db = CoolLineDB |
end |
if db.dbinit ~= 1 then |
db.dbinit = 1 |
for k, v in pairs({ |
w = 360, h = 18, x = 0, y = -240, |
statusbar = "Blizzard", |
bgcolor = { r = 0, g = 0, b = 0, a = 0.6, }, |
border = "Blizzard Dialog", |
bordercolor = { r = 1, g = 1, b = 1, a = 1, }, |
font = "Friz Quadrata TT", |
fontsize = 10, |
fontcolor = { r = 1, g = 1, b = 1, a = 0.8, }, |
spellcolor = { r = 0.8, g = 0.4, b = 0, a = 1, }, |
nospellcolor = { r = 0, g = 0, b = 0, a = 1, }, |
inactivealpha = 0.5, |
activealpha = 1.0, |
block = { -- [spell or item name] = true, |
[GetItemInfo(6948) or "Hearthstone"] = true, -- Hearthstone |
}, |
}) do |
db[k] = (db[k] ~= nil and db[k]) or v |
end |
end |
block = db.block |
if select(2, UnitClass("player")) == "DEATHKNIGHT" then |
local runecd = { -- fix by NeoSyrex |
[GetSpellInfo(50977) or "Death Gate"] = 11, |
[GetSpellInfo(43265) or "Death and Decay"] = 11, |
[GetSpellInfo(48263) or "Frost Presence"] = 1, |
[GetSpellInfo(48266) or "Blood Presence"] = 1, |
[GetSpellInfo(48265) or "Unholy Presence"] = 1, |
[GetSpellInfo(42650) or "Army of the Dead"] = 11, |
[GetSpellInfo(49222) or "Bone Shield"] = 11, |
[GetSpellInfo(47476) or "Strangulate"] = 11, |
[GetSpellInfo(51052) or "Anti-Magic Zone"] = 11, |
[GetSpellInfo(63560) or "Ghoul Frenzy"] = 10, |
[GetSpellInfo(49184) or "Howling Blast"] = 8, |
[GetSpellInfo(51271) or "Unbreakable Armor"] = 11, |
[GetSpellInfo(55233) or "Vampiric Blood"] = 11, |
[GetSpellInfo(49005) or "Mark of Blood"] = 11, |
[GetSpellInfo(48982) or "Rune Tap"] = 11, |
} |
RuneCheck = function(name, duration) |
local rc = runecd[name] |
if not rc or (rc <= duration and (rc > 10 or rc >= duration)) then |
return true |
end |
end |
end |
createfs = function(f, text, offset, just) |
local fs = f or self.overlay:CreateFontString(nil, "OVERLAY") |
fs:SetFont("Fonts\\FRIZQT__.TTF", 9) |
fs:SetTextColor(db.fontcolor.r, db.fontcolor.g, db.fontcolor.b, db.fontcolor.a) |
fs:SetText(text) |
fs:SetWidth(db.fontsize * 3) |
fs:SetHeight(db.fontsize + 2) |
fs:SetShadowColor(db.bgcolor.r, db.bgcolor.g, db.bgcolor.b, db.bgcolor.a) |
fs:SetShadowOffset(1, -1) |
if just then |
fs:ClearAllPoints() |
if db.vertical then |
fs:SetJustifyH("CENTER") |
just = db.reverse and ((just == "LEFT" and "TOP") or "BOTTOM") or ((just == "LEFT" and "BOTTOM") or "TOP") |
elseif db.reverse then |
just = (just == "LEFT" and "RIGHT") or "LEFT" |
offset = offset + ((just == "LEFT" and 1) or -1) |
fs:SetJustifyH(just) |
else |
offset = offset + ((just == "LEFT" and 1) or -1) |
fs:SetJustifyH(just) |
end |
else |
fs:SetJustifyH("CENTER") |
end |
SetValue(fs, offset, just) |
return fs |
end |
updatelook = function() |
self:SetWidth(db.w or 130) |
self:SetHeight(db.h or 18) |
self:SetPoint("CENTER", UIParent, "CENTER", db.x or 0, db.y or -240) |
self.bg = self.bg or self:CreateTexture(nil, "ARTWORK") |
self.bg:SetTexture("Interface\\Addons\\ncMedia\\flat") |
self.bg:SetVertexColor(db.bgcolor.r, db.bgcolor.g, db.bgcolor.b, db.bgcolor.a) |
self.bg:SetAllPoints(self) |
if db.vertical then |
self.bg:SetTexCoord(1,0, 0,0, 1,1, 0,1) |
else |
self.bg:SetTexCoord(0,1, 0,1) |
end |
self.border = self.border or CreateFrame("Frame", nil, self) |
self.border:SetPoint("TOPLEFT", -4, 4) |
self.border:SetPoint("BOTTOMRIGHT", 4, -4) |
backdrop.edgeFile = "Interface\\Addons\\ncMedia\\border" |
self.border:SetBackdrop(backdrop) |
self.border:SetBackdropBorderColor(db.bordercolor.r, db.bordercolor.g, db.bordercolor.b, db.bordercolor.a) |
self.overlay = self.overlay or CreateFrame("Frame", nil, self.border) |
self.overlay:SetFrameLevel(11) |
section = (db.vertical and db.h or db.w) / 6 |
iconsize = db.vertical and db.w or db.h |
SetValue = (db.vertical and (db.reverse and SetValueVR or SetValueV)) or (db.reverse and SetValueHR or SetValueH) |
tick0 = createfs(tick0, "0", 0, "LEFT") |
tick1 = createfs(tick1, "1", section) |
tick10 = createfs(tick10, "10", section * 2) |
tick30 = createfs(tick30, "30", section * 3) |
tick60 = createfs(tick60, "60", section * 4) |
tick120 = createfs(tick120, "2m", section * 5) |
tick300 = createfs(tick300, "6m", section * 6, "RIGHT") |
if db.hidepet then |
self:UnregisterEvent("UNIT_PET") |
self:UnregisterEvent("PET_BAR_UPDATE_COOLDOWN") |
else |
self:RegisterEvent("UNIT_PET") |
self:UNIT_PET("player") |
end |
if db.hidebag and db.hideinv then |
self:UnregisterEvent("BAG_UPDATE_COOLDOWN") |
else |
self:RegisterEvent("BAG_UPDATE_COOLDOWN") |
end |
if db.hidefail then |
self:UnregisterEvent("UNIT_SPELLCAST_FAILED") |
else |
self:RegisterEvent("UNIT_SPELLCAST_FAILED") |
end |
CoolLine:SetAlpha((CoolLine.unlock or #cooldowns > 0) and db.activealpha or db.inactivealpha) |
for _, frame in ipairs(cooldowns) do |
frame:SetWidth(iconsize) |
frame:SetHeight(iconsize) |
end |
end |
if IsLoggedIn() then |
CoolLine:PLAYER_LOGIN() |
else |
self:RegisterEvent("PLAYER_LOGIN") |
end |
end |
-------------------------------- |
function CoolLine:PLAYER_LOGIN() |
-------------------------------- |
self.PLAYER_LOGIN = nil |
self:RegisterEvent("SPELL_UPDATE_COOLDOWN") |
self:RegisterEvent("SPELLS_CHANGED") |
self:RegisterEvent("UNIT_ENTERED_VEHICLE") |
if UnitHasVehicleUI("player") then |
self:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN") |
self:RegisterEvent("UNIT_EXITED_VEHICLE") |
end |
updatelook() |
self:SPELLS_CHANGED() |
self:SPELL_UPDATE_COOLDOWN() |
self:BAG_UPDATE_COOLDOWN() |
self:SetAlpha((#cooldowns == 0 and db.inactivealpha) or db.activealpha) |
end |
local iconback = { bgFile="Interface\\AddOns\\CoolLine\\backdrop.tga" } |
local elapsed, throt, ptime, isactive = 0, 1.5, 0, false |
local function ClearCooldown(f, name) |
name = name or (f and f.name) |
for index, frame in ipairs(cooldowns) do |
if frame.name == name then |
frame:Hide() |
frame.name = nil |
frame.endtime = nil |
tinsert(frames, tremove(cooldowns, index)) |
break |
end |
end |
end |
local function SetupIcon(frame, position, tthrot, active, fl) |
throt = (throt < tthrot and throt) or tthrot |
isactive = active or isactive |
if fl then |
frame:SetFrameLevel(random(1,4) * 2 + 2) |
end |
SetValue(frame, position) |
end |
local function OnUpdate(this, a1, ctime, dofl) |
elapsed = elapsed + a1 |
if elapsed < throt then return end |
elapsed = 0 |
if #cooldowns == 0 then |
if not CoolLine.unlock then |
self:SetScript("OnUpdate", nil) |
self:SetAlpha(db.inactivealpha) |
end |
return |
end |
ctime = ctime or GetTime() |
if ctime > ptime then |
dofl, ptime = true, ctime + 0.4 |
end |
isactive, throt = false, 1.5 |
for index, frame in pairs(cooldowns) do |
local remain = frame.endtime - ctime |
if remain < 10 then |
if remain > 1 then |
SetupIcon(frame, section * (remain + 8) * 0.111, 0.03, true, dofl) -- 1 + (remain - 1) / 9 |
elseif remain > 0.3 then |
SetupIcon(frame, section * remain, 0, true, dofl) |
elseif remain > 0 then |
local size = iconsize * (0.5 - remain) * 5 -- iconsize + iconsize * (0.3 - remain) / 0.2 |
frame:SetWidth(size) |
frame:SetHeight(size) |
SetupIcon(frame, section * remain, 0, true, dofl) |
elseif remain > -0.5 then |
SetupIcon(frame, 0, 0, true, dofl) |
frame:SetAlpha(1 + remain * 2) -- fades |
else |
throt = (throt < 0.2 and throt) or 0.2 |
isactive = true |
ClearCooldown(frame) |
end |
elseif remain < 30 then |
SetupIcon(frame, section * (remain + 30) * 0.05, remain > 11 and 0.06 or 0.02, true, dofl) -- 2 + (remain - 10) / 20 |
elseif remain < 60 then |
SetupIcon(frame, section * (remain + 60) * 0.03333, 0.12, true, dofl) -- 3 + (remain - 30) / 30 |
elseif remain < 120 then |
SetupIcon(frame, section * (remain + 180) * 0.01666, 0.25, true, dofl) -- 4 + (remain - 60) / 60 |
elseif remain < 360 then |
SetupIcon(frame, section * (remain + 1080) * 0.004166, 1.2, true, dofl) -- 5 + (remain - 120) / 240 |
frame:SetAlpha(1) |
else |
SetupIcon(frame, 6 * section, 2, false, dofl) |
end |
end |
if not isactive and not CoolLine.unlock then |
self:SetAlpha(db.inactivealpha) |
end |
end |
local function NewCooldown(name, icon, endtime, isplayer) |
local f |
for index, frame in pairs(cooldowns) do |
if frame.name == name and frame.isplayer == isplayer then |
f = frame |
break |
elseif frame.endtime == endtime then |
return |
end |
end |
if not f then |
f = f or tremove(frames) |
if not f then |
f = CreateFrame("Frame", nil, CoolLine.border) |
f:SetBackdrop(iconback) |
f.icon = f:CreateTexture(nil, "ARTWORK") |
f.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93) |
f.icon:SetPoint("TOPLEFT", 1, -1) |
f.icon:SetPoint("BOTTOMRIGHT", -1, 1) |
end |
tinsert(cooldowns, f) |
end |
local ctime = GetTime() |
f:SetWidth(iconsize) |
f:SetHeight(iconsize) |
f:SetAlpha((endtime - ctime > 360) and 0.6 or 1) |
f.name, f.endtime, f.isplayer = name, endtime, isplayer |
f.icon:SetTexture(icon) |
local c = db[isplayer and "spellcolor" or "nospellcolor"] |
f:SetBackdropColor(c.r, c.g, c.b, c.a) |
f:Show() |
self:SetScript("OnUpdate", OnUpdate) |
self:SetAlpha(db.activealpha) |
OnUpdate(self, 2, ctime) |
end |
CoolLine.NewCooldown, CoolLine.ClearCooldown = NewCooldown, ClearCooldown |
do -- cache spells that have a cooldown |
local CLTip = CreateFrame("GameTooltip", "CLTip", CoolLine, "GameTooltipTemplate") |
CLTip:SetOwner(CoolLine, "ANCHOR_NONE") |
local GetSpellName = GetSpellName |
local cooldown1 = gsub(SPELL_RECAST_TIME_MIN, "%%%.%d[fg]", "(.+)") |
local cooldown2 = gsub(SPELL_RECAST_TIME_SEC, "%%%.%d[fg]", "(.+)") |
local function CheckRight(rtext) |
local text = rtext and rtext:GetText() |
if text and (strmatch(text, cooldown1) or strmatch(text, cooldown2)) then |
return true |
end |
end |
local function CacheBook(btype) |
local name, last |
local sb = spells[btype] |
for i = 1, 500, 1 do |
name = GetSpellName(i, btype) |
if not name then break end |
if name ~= last then |
last = name |
if sb[name] then |
sb[name] = i |
else |
CLTip:SetSpell(i, btype) |
if CheckRight(CLTipTextRight2) or CheckRight(CLTipTextRight3) or CheckRight(CLTipTextRight4) then |
sb[name] = i |
end |
end |
end |
end |
end |
---------------------------------- |
function CoolLine:SPELLS_CHANGED() |
---------------------------------- |
CacheBook(BOOKTYPE_SPELL) |
if not db.hidepet then |
CacheBook(BOOKTYPE_PET) |
end |
end |
end |
do -- scans spellbook to update cooldowns, throttled since the event fires a lot |
local selap = 0 |
local spellthrot = CreateFrame("Frame", nil, CoolLine) |
local GetSpellCooldown, GetSpellTexture = GetSpellCooldown, GetSpellTexture |
local function CheckSpellBook(btype) |
for name, id in pairs(spells[btype]) do |
local start, duration, enable = GetSpellCooldown(id, btype) |
if enable == 1 and start > 0 then |
if duration > 2.5 and not block[name] and (not RuneCheck or RuneCheck(name, duration))then |
NewCooldown(name, GetSpellTexture(id, btype), start + duration, btype == BOOKTYPE_SPELL) |
end |
else |
ClearCooldown(nil, name) |
end |
end |
end |
spellthrot:SetScript("OnUpdate", function(this, a1) |
selap = selap + a1 |
if selap < 0.5 then return end |
selap = 0 |
this:Hide() |
CheckSpellBook(BOOKTYPE_SPELL) |
if not db.hidepet and HasPetUI() then |
CheckSpellBook(BOOKTYPE_PET) |
end |
end) |
spellthrot:Hide() |
----------------------------------------- |
function CoolLine:SPELL_UPDATE_COOLDOWN() |
----------------------------------------- |
spellthrot:Show() |
end |
end |
do -- scans equipments and bags for item cooldowns |
local GetItemInfo = GetItemInfo |
local GetInventoryItemCooldown, GetInventoryItemTexture = GetInventoryItemCooldown, GetInventoryItemTexture |
local GetContainerItemCooldown, GetContainerItemInfo = GetContainerItemCooldown, GetContainerItemInfo |
local GetContainerNumSlots = GetContainerNumSlots |
--------------------------------------- |
function CoolLine:BAG_UPDATE_COOLDOWN() |
--------------------------------------- |
for i = 1, (db.hideinv and 0) or 18, 1 do |
local start, duration, enable = GetInventoryItemCooldown("player", i) |
if enable == 1 then |
local name = GetItemInfo(GetInventoryItemLink("player", i)) |
if start > 0 and not block[name] then |
if duration > 3 and duration < 3601 then |
NewCooldown(name, GetInventoryItemTexture("player", i), start + duration) |
end |
else |
ClearCooldown(nil, name) |
end |
end |
end |
for i = 0, (db.hidebag and -1) or 4, 1 do |
for j = 1, GetContainerNumSlots(i), 1 do |
local start, duration, enable = GetContainerItemCooldown(i, j) |
if enable == 1 then |
local name = GetItemInfo(GetContainerItemLink(i, j)) |
if start > 0 and not block[name] then |
if duration > 3 and duration < 3601 then |
NewCooldown(name, GetContainerItemInfo(i, j), start + duration) |
end |
else |
ClearCooldown(nil, name) |
end |
end |
end |
end |
end |
end |
------------------------------------------- |
function CoolLine:PET_BAR_UPDATE_COOLDOWN() |
------------------------------------------- |
for i = 1, 10, 1 do |
local start, duration, enable = GetPetActionCooldown(i) |
if enable == 1 then |
local name, _, texture = GetPetActionInfo(i) |
if name then |
if start > 0 and not block[name] then |
if duration > 3 then |
NewCooldown(name, texture, start + duration) |
end |
else |
ClearCooldown(nil, name) |
end |
end |
end |
end |
end |
------------------------------ |
function CoolLine:UNIT_PET(a1) |
------------------------------ |
if a1 ~= "player" then return end |
if UnitExists("pet") and not HasPetUI() then |
self:RegisterEvent("PET_BAR_UPDATE_COOLDOWN") |
else |
self:UnregisterEvent("PET_BAR_UPDATE_COOLDOWN") |
end |
end |
local GetActionCooldown, HasAction = GetActionCooldown, HasAction |
--------------------------------------------- |
function CoolLine:ACTIONBAR_UPDATE_COOLDOWN() -- used only for vehicles |
--------------------------------------------- |
for i = 1, 6, 1 do |
local b = _G["VehicleMenuBarActionButton"..i] |
if b and HasAction(b.action) then |
local start, duration, enable = GetActionCooldown(b.action) |
if enable == 1 then |
if start > 0 and not block[GetActionInfo(b.action)] then |
if duration > 3 then |
NewCooldown("vhcle"..i, GetActionTexture(b.action), start + duration) |
end |
else |
ClearCooldown(nil, "vhcle"..i) |
end |
end |
end |
end |
end |
------------------------------------------ |
function CoolLine:UNIT_ENTERED_VEHICLE(a1) |
------------------------------------------ |
if a1 ~= "player" or not UnitHasVehicleUI("player") then return end |
self:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN") |
self:RegisterEvent("UNIT_EXITED_VEHICLE") |
self:ACTIONBAR_UPDATE_COOLDOWN() |
end |
----------------------------------------- |
function CoolLine:UNIT_EXITED_VEHICLE(a1) |
----------------------------------------- |
if a1 ~= "player" then return end |
self:UnregisterEvent("ACTIONBAR_UPDATE_COOLDOWN") |
for index, frame in ipairs(cooldowns) do |
if strmatch(frame.name, "vhcle") then |
ClearCooldown(nil, frame.name) |
end |
end |
end |
local failborder |
---------------------------------------------------- |
function CoolLine:UNIT_SPELLCAST_FAILED(unit, spell) |
---------------------------------------------------- |
if unit ~= "player" or #cooldowns == 0 then return end |
for index, frame in pairs(cooldowns) do |
if frame.name == spell then |
if not failborder then |
failborder = CreateFrame("Frame", nil, CoolLine.border) |
failborder:SetBackdrop(iconback) |
failborder:SetBackdropColor(1, 0, 0, 0.9) |
failborder:Hide() |
failborder:SetScript("OnUpdate", function(this, a1) |
this.alp = this.alp - a1 |
if this.alp < 0 then return this:Hide() end |
this:SetAlpha(this.alp > 1 and 1 or this.alp) |
end) |
end |
failborder.alp = 1.2 |
failborder:SetPoint("TOPLEFT", frame, "TOPLEFT", -2, 2) |
failborder:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 2, -2) |
failborder:Show() |
break |
end |
end |
end |
local CoolLineDD, Set |
local info = { } |
local ncCooldown = CreateFrame("Frame") |
local function FormatTime(s) |
if s >= 3600 then |
return format('%dh', floor(s/3600 + 0.5)) |
elseif s >= 60 then |
return format('%dm', floor(s/60 + 0.5)) |
end |
return floor(s + 0.5) |
end |
local function UpdateCooldown(self, elapsed) |
local remaining = self.endTime - GetTime() |
if floor(remaining + .5) > 0 and self.text:IsShown() then |
self.text:SetText(FormatTime(remaining)) |
if remaining > 6.5 then |
self.text:SetTextColor(1, 1, 1) |
else |
self.text:SetTextColor(1, 0, 0) |
end |
else |
self.text:SetText("") |
self.text:Hide() |
end |
end |
local function CreateText(self) |
local text = self:CreateFontString(nil, "OVERLAY") |
text:SetPoint("CENTER") |
self.text = text |
self:SetScript("OnUpdate", UpdateCooldown) |
text:SetParent(self:GetParent()) |
self:SetAlpha(0) |
self:SetScript("OnHide", function() text:Hide() end) |
self:SetScript("OnShow", function() text:Show() end) |
return text |
end |
local function startCooldown(self, start, duration) |
self.endTime = start + duration |
local fontSize = self:GetParent():GetWidth() / 2.1 |
local text = self.text or CreateText(self) |
local height = self:GetHeight() |
if height==0 then |
height = 20 |
end |
text:SetFont("Fonts\\FRIZQT__.ttf", 0.5*height, "THINOUTLINE") |
text:Show() |
end |
local function SetCooldown(self, start, duration) |
if start > 0 and duration > 3 then |
startCooldown(self, start, duration) |
end |
end |
local methods = getmetatable(ActionButton1Cooldown).__index |
hooksecurefunc(methods, "SetCooldown", SetCooldown) |
## Interface: 30200 |
## Title: ncCooldown |
## Author: Nightcracker |
## Version: 1.0 |
## Notes: Shows cooldown in numbers on buttons |
ncCooldown.lua |
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info |
-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke |
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! |
local LibStub = _G[LIBSTUB_MAJOR] |
if not LibStub or LibStub.minor < LIBSTUB_MINOR then |
LibStub = LibStub or {libs = {}, minors = {} } |
_G[LIBSTUB_MAJOR] = LibStub |
LibStub.minor = LIBSTUB_MINOR |
function LibStub:NewLibrary(major, minor) |
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") |
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") |
local oldminor = self.minors[major] |
if oldminor and oldminor >= minor then return nil end |
self.minors[major], self.libs[major] = minor, self.libs[major] or {} |
return self.libs[major], oldminor |
end |
function LibStub:GetLibrary(major, silent) |
if not self.libs[major] and not silent then |
error(("Cannot find a library instance of %q."):format(tostring(major)), 2) |
end |
return self.libs[major], self.minors[major] |
end |
function LibStub:IterateLibraries() return pairs(self.libs) end |
setmetatable(LibStub, { __call = LibStub.GetLibrary }) |
end |
-- This is the addon tekPanel, included with permission from the author tekkub |
local lib, oldminor = LibStub:NewLibrary("tekPanel-Auction", 2) |
if not lib then return end |
oldminor = oldminor or 0 |
local function createtex(parent, layer, w, h, ...) |
local tex = parent:CreateTexture(nil, layer) |
tex:SetWidth(w) tex:SetHeight(h) |
tex:SetPoint(...) |
return tex |
end |
function lib.new(name, titletext, splitstyle) |
local frame = CreateFrame("Frame", name, UIParent) |
frame:CreateTitleRegion() |
frame:SetFrameStrata("DIALOG") |
frame:SetWidth(832) frame:SetHeight(447) |
frame:SetPoint("TOPLEFT", 0, -104) |
frame:Hide() |
frame:SetAttribute("UIPanelLayout-defined", true) |
frame:SetAttribute("UIPanelLayout-enabled", true) |
frame:SetAttribute("UIPanelLayout-area", "doublewide") |
frame:SetAttribute("UIPanelLayout-whileDead", true) |
table.insert(UISpecialFrames, name) |
local title = frame:GetTitleRegion() |
title:SetWidth(757) title:SetHeight(20) |
title:SetPoint("TOPLEFT", 75, -15) |
local portrait = createtex(frame, "OVERLAY", 57, 57, "TOPLEFT", 9, -7) |
SetPortraitTexture(portrait, "player") |
frame:SetScript("OnEvent", function(self, event, unit) if unit == "player" then SetPortraitTexture(portrait, "player") end end) |
frame:RegisterEvent("UNIT_PORTRAIT_UPDATE") |
local title = frame:CreateFontString(nil, "OVERLAY") |
title:SetFontObject(GameFontNormal) |
title:SetPoint("TOP", 0, -18) |
title:SetText(titletext) |
local topleft = createtex(frame, "ARTWORK", 256, 256, "TOPLEFT", 0, 0) |
local top = createtex(frame, "ARTWORK", 320, 256, "TOPLEFT", 256, 0) |
local topright = createtex(frame, "ARTWORK", 256, 256, "TOPLEFT", top, "TOPRIGHT") |
local bottomleft = createtex(frame, "ARTWORK", 256, 256, "TOPLEFT", 0, -256) |
local bottom = createtex(frame, "ARTWORK", 320, 256, "TOPLEFT", 256, -256) |
local bottomright = createtex(frame, "ARTWORK", 256, 256, "TOPLEFT", bottom, "TOPRIGHT") |
if splitstyle then |
topleft:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Browse-TopLeft") |
top:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Browse-Top") |
topright:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Browse-TopRight") |
bottomleft:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Browse-BotLeft") |
bottom:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Browse-Bot") |
bottomright:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Browse-BotRight") |
else |
topleft:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-TopLeft") |
top:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-Top") |
topright:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-TopRight") |
bottomleft:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-BotLeft") |
bottom:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-Bot") |
bottomright:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-BotRight") |
end |
local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton") |
close:SetPoint("TOPRIGHT", 3, -8) |
close:SetScript("OnClick", function() HideUIPanel(frame) end) |
return frame |
end |
local LINEHEIGHT, maxoffset, offset = 12, 0, 0 |
local panel = LibStub("tekPanel-Auction").new("tekPadPanel", "Developer's pad") |
local scroll = CreateFrame("ScrollFrame", nil, panel) |
scroll:SetPoint("TOPLEFT", 21, -73) |
scroll:SetPoint("BOTTOMRIGHT", -10, 38) |
local HEIGHT = scroll:GetHeight() |
local editbox = CreateFrame("EditBox", nil, scroll) |
scroll:SetScrollChild(editbox) |
editbox:SetPoint("TOP") |
editbox:SetPoint("LEFT") |
editbox:SetPoint("RIGHT") |
editbox:SetHeight(1000) |
editbox:SetFontObject(GameFontHighlightSmall) |
editbox:SetTextInsets(2,2,2,2) |
editbox:SetMultiLine(true) |
editbox:SetAutoFocus(false) |
editbox:SetScript("OnEscapePressed", editbox.ClearFocus) |
editbox:SetScript("OnEditFocusLost", function(self) tekPadDB = self:GetText() end) |
editbox:SetScript("OnShow", function(self) |
local text = tekPadDB or "" |
self:SetText(text) |
self:SetFocus() |
end) |
local function doscroll(v) |
offset = math.max(math.min(v, 0), maxoffset) |
scroll:SetVerticalScroll(-offset) |
editbox:SetPoint("TOP", 0, offset) |
end |
editbox:SetScript("OnCursorChanged", function(self, x, y, width, height) |
LINEHEIGHT = height |
if offset < y then |
doscroll(y) |
elseif math.floor(offset - HEIGHT + height*2) > y then |
local v = y + HEIGHT - height*2 |
maxoffset = math.min(maxoffset, v) |
doscroll(v) |
end |
end) |
scroll:UpdateScrollChildRect() |
scroll:EnableMouseWheel(true) |
scroll:SetScript("OnMouseWheel", function(self, val) doscroll(offset + val*LINEHEIGHT*3) end) |
local butt = CreateFrame("Button", nil, panel) |
butt:SetWidth(80) butt:SetHeight(22) |
butt:SetPoint("BOTTOMRIGHT", -7, 14) |
butt:SetHighlightFontObject(GameFontHighlightSmall) |
butt:SetNormalFontObject(GameFontNormalSmall) |
butt:SetNormalTexture("Interface\\Buttons\\UI-Panel-Button-Up") |
butt:SetPushedTexture("Interface\\Buttons\\UI-Panel-Button-Down") |
butt:SetHighlightTexture("Interface\\Buttons\\UI-Panel-Button-Highlight") |
butt:SetDisabledTexture("Interface\\Buttons\\UI-Panel-Button-Disabled") |
butt:GetNormalTexture():SetTexCoord(0, 0.625, 0, 0.6875) |
butt:GetPushedTexture():SetTexCoord(0, 0.625, 0, 0.6875) |
butt:GetHighlightTexture():SetTexCoord(0, 0.625, 0, 0.6875) |
butt:GetDisabledTexture():SetTexCoord(0, 0.625, 0, 0.6875) |
butt:GetHighlightTexture():SetBlendMode("ADD") |
butt:SetText("Run") |
butt:SetScript("OnClick", function() RunScript(editbox:GetText()) end) |
-- End tekpad |
-- This is the addon align, credit to Akeru/Amadeo (swyatt@gmail.com) |
local grid |
local boxSize = 32 |
local isAligning = false |
function Grid_Show() |
if not grid then |
Grid_Create() |
elseif grid.boxSize ~= boxSize then |
grid:Hide() |
Grid_Create() |
else |
grid:Show() |
end |
end |
function Grid_Hide() |
if grid then |
grid:Hide() |
end |
end |
function Grid_Create() |
grid = CreateFrame('Frame', nil, UIParent) |
grid.boxSize = boxSize |
grid:SetAllPoints(UIParent) |
local size = 2 |
local width = GetScreenWidth() |
local ratio = width / GetScreenHeight() |
local height = GetScreenHeight() * ratio |
local wStep = width / boxSize |
local hStep = height / boxSize |
for i = 0, boxSize do |
local tx = grid:CreateTexture(nil, 'BACKGROUND') |
if i == boxSize / 2 then |
tx:SetTexture(1, 0, 0, 0.5) |
else |
tx:SetTexture(0, 0, 0, 0.5) |
end |
tx:SetPoint("TOPLEFT", grid, "TOPLEFT", i*wStep - (size/2), 0) |
tx:SetPoint('BOTTOMRIGHT', grid, 'BOTTOMLEFT', i*wStep + (size/2), 0) |
end |
height = GetScreenHeight() |
do |
local tx = grid:CreateTexture(nil, 'BACKGROUND') |
tx:SetTexture(1, 0, 0, 0.5) |
tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height/2) + (size/2)) |
tx:SetPoint('BOTTOMRIGHT', grid, 'TOPRIGHT', 0, -(height/2 + size/2)) |
end |
for i = 1, math.floor((height/2)/hStep) do |
local tx = grid:CreateTexture(nil, 'BACKGROUND') |
tx:SetTexture(0, 0, 0, 0.5) |
tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height/2+i*hStep) + (size/2)) |
tx:SetPoint('BOTTOMRIGHT', grid, 'TOPRIGHT', 0, -(height/2+i*hStep + size/2)) |
tx = grid:CreateTexture(nil, 'BACKGROUND') |
tx:SetTexture(0, 0, 0, 0.5) |
tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height/2-i*hStep) + (size/2)) |
tx:SetPoint('BOTTOMRIGHT', grid, 'TOPRIGHT', 0, -(height/2-i*hStep + size/2)) |
end |
end |
-- End align |
-- Start own code |
-- Start copy/paste buttons on colorpickframe |
local r, g, b = .1, .1, .1 |
local cp = CreateFrame('Button', nil, ColorPickerFrame, 'OptionsButtonTemplate') |
local ps = CreateFrame('Button', nil, ColorPickerFrame, 'OptionsButtonTemplate') |
cp:SetText('Paste') |
cp:SetPoint('BOTTOMLEFT', ColorPickerFrame, 'TOPLEFT',0,2) |
cp:SetScript('OnClick', function() ColorPickerFrame:SetColorRGB(r,g,b) end) |
ps:SetText('Copy') |
ps:SetPoint('BOTTOMRIGHT', ColorPickerFrame, 'TOPRIGHT',0,2) |
ps:SetScript('OnClick', function() r,g,b = ColorPickerFrame:GetColorRGB() end) |
-- End |
-- Start framefinder |
local shown |
local a1, a2, x, y = 'TOP', 'TOP', 0, 0 |
local ff = CreateFrame('Frame', 'FFind') |
ff:SetFrameStrata('TOOLTIP') |
ff:SetWidth(100) |
ff:SetHeight(100) |
ff:SetPoint(a1, UIParent, a2, x, y) |
ff.text = ff:CreateFontString() |
ff.text:SetFont('Fonts\\FRIZQT__.TTF', 8) |
ff.text:SetPoint('TOPLEFT', ff, 'TOPLEFT', 0, 0) |
ff.text:SetJustifyH('LEFT') |
ff.text:SetShadowOffset(-.4,-.4) |
local buf |
local function out(...) |
for i=1,select('#',...) do |
buf[ #buf+1 ] = select(i,...) |
end |
end |
local function showFrame(f) |
local name = f:GetName() |
local strata = f.GetFrameStrata and f:GetFrameStrata() |
local level = f.GetFrameLevel and f:GetFrameLevel() |
out('|cFFFFFFFF',name and name or '--',' ') |
if strata then out('|cFFAAAAAA',tostring(strata)) end |
if level then out('(', tostring(level),')') end |
out('\n') |
end |
local function showGroup(header, ...) |
out( format('\n|cFFFF8800%s|cFFFFFFFF', header), '\n' ) |
for _, f in pairs{...} do |
showFrame(f) |
end |
end |
local function UpdateText(f) |
if f then |
buf = { '|cFFFF2200' } |
showFrame(f) |
local parent = f:GetParent() |
showGroup("parent", par) |
showGroup("parent's parent", parent and parent:GetParent()) |
showGroup("children", f:GetChildren()) |
showGroup("regions", f:GetRegions()) |
ff.text:SetText(table.concat(buf)) |
else |
ff.text:SetText('') |
end |
end |
local currentframe |
local function OnUpdate() |
local obj = GetMouseFocus() |
if obj then |
local name = obj:GetName() |
if currentframe ~= name then |
currentframe = name |
UpdateText(obj) |
end |
end |
end |
-- End framefinder |
-- Slash handling |
SLASH_NCDEVELOPER1 = "/dev" |
SLASH_NCDEVELOPER2 = "/developer" |
function SlashCmdList.NCDEVELOPER(input) |
arg1, arg2, arg3 = string.split(" ", input) |
if (arg1=="grid") then |
if (isAligning and not arg2) then |
Grid_Hide() |
isAligning = false |
else |
boxSize = (math.ceil((tonumber(arg2) or boxSize) / 32) * 32) |
if boxSize > 256 then |
boxSize = 256 |
end |
Grid_Show() |
isAligning = true |
end |
elseif (arg1=="pad") then |
ShowUIPanel(panel) |
elseif (arg1=="rl" or arg1=="reload") then |
ReloadUI() |
elseif (arg1=="fquit" or arg1=="forcequit") then |
ForceQuit() |
elseif (arg1=="print" or arg1=="echo") then |
print(arg2) |
elseif (arg1=="ff" or arg1=="framefinder") then |
if shown then |
ff:SetScript('OnUpdate', nil) |
ff:Hide() |
shown = nil |
else |
ff:SetScript('OnUpdate', OnUpdate) |
ff:Show() |
shown = 1 |
end |
end |
end |
-- End slash handling |
## Interface: 30200 |
## Title: ncDeveloper |
## Author: Nightcracker |
## Version: 1.0 |
## Notes: Various developer tools. |
## SavedVariables: tekPadDB |
LibStub.lua |
ncDeveloper.lua |
-- Fontstring on bottom of worldmap |
local function setup(a) |
f = WorldMapButton:CreateFontString(nil, "ARTWORK") |
f:SetPoint(a, WorldMapButton, 0, -21) |
f:SetFontObject("GameFontNormal") |
f:SetTextColor(1,1,1) |
return f |
end |
local p, c = setup("BOTTOMLEFT"), setup("BOTTOMRIGHT") |
-- When the worldmap shows |
WorldMapButton:HookScript("OnUpdate", function(self, u) |
local PlayerX, PlayerY = GetPlayerMapPosition("player") |
PlayerX = math.floor(PlayerX*100*10+0.5)/10 |
PlayerY = math.floor(PlayerY*100*10+0.5)/10 |
p:SetText(PlayerX.." - "..PlayerY) |
local cX, cY = WorldMapDetailFrame:GetCenter() |
local CursorX, CursorY = GetCursorPosition() |
CursorX = math.floor((((CursorX/WorldMapFrame:GetScale())-(cX-(WorldMapDetailFrame:GetWidth()/2)))/10)*10+.05)/10 |
CursorY = math.floor(((((cY+(WorldMapDetailFrame:GetHeight()/2))-(CursorY/WorldMapFrame:GetScale()))/WorldMapDetailFrame:GetHeight())*100)*10+.05)/10 |
if CursorX >= 100 or CursorY >= 100 or CursorX <= 0 or CursorY <= 0 then |
c:SetText("0 . 0") |
else |
c:SetText(CursorX.." - "..CursorY) |
end |
end) |
-- Keep mouse and keyboard avaiable to the rest of the UI |
WorldMapFrame:EnableKeyboard(false) |
WorldMapFrame:EnableMouse(false) |
-- Hide the ugly black background, scale and move the worldmap |
BlackoutWorld:Hide() |
UIPanelWindows["WorldMapFrame"] = {area = "center"} |
WorldMapFrame:HookScript("OnShow", function(self) self:SetScale(0.7) end) |
## Interface: 30200 |
## Title: ncWorldmap |
## Author: Nightcracker |
## Version: 1.0 |
## Notes: Modifies the worldmap |
ncWorldmap.lua |
## Interface: 30200 |
## Title: ncDequip |
## Notes: Adds the /dequip command. |
## Version: 1.2 |
## Author: Nightcracker |
ncDequip.lua |
local black = {} |
function Dequip(msg) |
if GetInventoryItemLink("player",msg) then |
for i=0,4 do |
for j=1,GetContainerNumSlots(i) do |
if not GetContainerItemLink(i,j) and not black[i.."-"..j] then |
PickupInventoryItem(msg) PickupContainerItem(i,j) |
black[i.."-"..j] = true |
return |
end |
end |
end |
end |
end |
function Dequipall() |
for m=0,19 do |
Dequip(m) |
end |
black = {} |
end |
SLASH_DEQUIP1 = "/dq" |
SLASH_DEQUIP2 = "/dequip" |
function SlashCmdList.DEQUIP(msg) |
if (not msg or msg == "" or msg == "help") then |
print('/dequip xxx | /dq xxx - Dequips slot where xxx can be the following slot or "all":') |
print("Ammo = 0") |
print("Head = 1") |
print("Neck = 2") |
print("Shoulder = 3") |
print("Shirt = 4") |
print("Chest = 5") |
print("Waist = 6") |
print("Legs = 7") |
print("Feet = 8") |
print("Wrist = 9") |
print("Hands = 10") |
print("First finger = 11") |
print("Second finger = 12") |
print("First trinket = 13") |
print("Second trinket = 14") |
print("Cloak = 15") |
print("Mainhand = 16") |
print("Offhand = 17") |
print("Ranged = 18") |
print("Tabard = 19") |
elseif (msg=="all") then |
Dequipall() |
else |
Dequip(msg) |
end |
end |
## Interface: 30200 +## Title: ncError +## Version: 1.1 +## Author: Nightcracker +## Notes: Yet another error hiding addon. + +ncError.lua |
local f, o, ncErrorDB = CreateFrame("Frame"), "No error yet.", { + ["Inventory is full"] = true, +} +f:SetScript("OnEvent", function(self, event, error) + if ncErrorDB[error] then + UIErrorsFrame:AddMessage(error) + else + o = error + end +end) +SLASH_NCERROR1 = "/error" +function SlashCmdList.NCERROR() print(o) end +UIErrorsFrame:UnregisterEvent("UI_ERROR_MESSAGE") +f:RegisterEvent("UI_ERROR_MESSAGE") |
## Interface: 30200 |
## Title: ncNameplates |
## Author: Nightcracker |
## Version: 1.1 |
## Notes: Addon for changing the look of the nameplates. |
ncNameplates.lua |
-- CONFIG |
local glowtexture = "Interface\\Addons\\ncMedia\\blank2" |
local font, fontSize, fontOutline = "Fonts\\FRIZQT__.TTF", 11, "MONOCHROME" |
local bartexture = "Interface\\Addons\\ncMedia\\flat" |
-- DON'T EDIT BELOW THIS LINE |
local ncPlates, numkids, lastupdate, select = CreateFrame("Frame", nil, UIParent), 0, 0, select |
local backdrop = { |
edgeFile = glowtexture, edgeSize = 0, |
insets = {left = 3, right = 3, top = 3, bottom = 3} |
} |
local function GetClass(r, g, b) |
local r, g, b = floor(r*100+.5)/100, floor(g*100+.5)/100, floor(b*100+.5)/100 |
for class, color in pairs(RAID_CLASS_COLORS) do |
if RAID_CLASS_COLORS[class].r == r and RAID_CLASS_COLORS[class].g == g and RAID_CLASS_COLORS[class].b == b then |
return class |
end |
end |
return 0 |
end |
local function ClassIconTexCoord(r, g, b) |
class = GetClass(r,g,b) |
if not (class==0) then |
local texcoord = CLASS_BUTTONS[class] |
if (texcoord) then |
return unpack(texcoord) |
end |
end |
return 0.5, 0.75, 0.5, 0.75 |
end |
local IsValidFrame = function(frame) |
if frame:GetName() then |
return |
end |
overlayRegion = select(2, frame:GetRegions()) |
return overlayRegion and overlayRegion:GetObjectType() == "Texture" and overlayRegion:GetTexture() == "Interface\\Tooltips\\Nameplate-Border" |
end |
local UpdateTime = function(self, curValue) |
local minValue, maxValue = self:GetMinMaxValues() |
if self.channeling then |
self.time:SetFormattedText("%.1f ", curValue) |
else |
self.time:SetFormattedText("%.1f ", maxValue - curValue) |
end |
end |
local ThreatUpdate = function(self, elapsed) |
self.elapsed = self.elapsed + elapsed |
if self.elapsed >= 0.2 then |
if not self.oldglow:IsShown() then |
self.healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0) |
else |
self.healthBar.hpGlow:SetBackdropBorderColor(self.oldglow:GetVertexColor()) |
end |
self.healthBar:SetStatusBarColor(self.r, self.g, self.b) |
self.elapsed = 0 |
end |
end |
local UpdateFrame = function(self) |
if (self.oldname:GetText()=="Viper" or self.oldname:GetText()=="Venomous Snake") then |
self:Hide() |
end |
SetCVar("ShowClassColorInNameplate", 1) |
local r, g, b = self.healthBar:GetStatusBarColor() |
local newr, newg, newb |
if g + b == 0 then |
newr, newg, newb = 0.69, 0.31, 0.31 |
self.healthBar:SetStatusBarColor(0.69, 0.31, 0.31) |
elseif r + b == 0 then |
newr, newg, newb = 0.33, 0.59, 0.33 |
self.healthBar:SetStatusBarColor(0.33, 0.59, 0.33) |
elseif r + g == 0 then |
newr, newg, newb = 0.31, 0.45, 0.63 |
self.healthBar:SetStatusBarColor(0.31, 0.45, 0.63) |
elseif 2 - (r + g) < 0.05 and b == 0 then |
newr, newg, newb = 0.65, 0.63, 0.35 |
self.healthBar:SetStatusBarColor(0.65, 0.63, 0.35) |
else |
newr, newg, newb = r, g, b |
end |
self.icon:SetTexCoord(ClassIconTexCoord(r, g, b)) |
self.r, self.g, self.b = newr, newg, newb |
self.healthBar:ClearAllPoints() |
self.healthBar:SetPoint("CENTER", self.healthBar:GetParent()) |
self.healthBar:SetHeight(10) |
self.healthBar:SetWidth(100) |
self.castBar:ClearAllPoints() |
self.castBar:SetPoint("TOP", self.healthBar, "BOTTOM", 0, -4) |
self.castBar:SetHeight(5) |
self.castBar:SetWidth(100) |
self.highlight:ClearAllPoints() |
self.highlight:SetAllPoints(self.healthBar) |
self.name:SetText(self.oldname:GetText()) |
local level, elite, mylevel = tonumber(self.level:GetText()), self.elite:IsShown(), UnitLevel("player") |
self.level:ClearAllPoints() |
self.level:SetPoint("RIGHT", self.healthBar, "LEFT", -2, 1) |
if self.boss:IsShown() then |
self.level:SetText("B") |
self.level:SetTextColor(0.8, 0.05, 0) |
self.level:Show() |
elseif not elite and level == mylevel then |
self.level:Hide() |
else |
self.level:SetText(level..(elite and "+" or "")) |
end |
end |
local FixCastbar = function(self) |
self.castbarOverlay:Hide() |
self:SetHeight(5) |
self:ClearAllPoints() |
self:SetPoint("TOP", self.healthBar, "BOTTOM", 0, -4) |
end |
local ColorCastBar = function(self, shielded) |
if shielded then |
self:SetStatusBarColor(0.8, 0.05, 0) |
self.cbGlow:SetBackdropBorderColor(0.75, 0.75, 0.75) |
else |
self.cbGlow:SetBackdropBorderColor(0, 0, 0) |
end |
end |
local OnSizeChanged = function(self) |
self.needFix = true |
end |
local OnValueChanged = function(self, curValue) |
UpdateTime(self, curValue) |
if self.needFix then |
FixCastbar(self) |
self.needFix = nil |
end |
end |
local OnShow = function(self) |
self.channeling = UnitChannelInfo("target") |
FixCastbar(self) |
ColorCastBar(self, self.shieldedRegion:IsShown()) |
end |
local OnHide = function(self) |
self.highlight:Hide() |
self.healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0) |
end |
local OnEvent = function(self, event, unit) |
if unit == "target" then |
if self:IsShown() then |
ColorCastBar(self, event == "UNIT_SPELLCAST_NOT_INTERRUPTIBLE") |
end |
end |
end |
local CreateFrame = function(frame) |
if frame.done then |
return |
end |
frame.nameplate = true |
frame.healthBar, frame.castBar = frame:GetChildren() |
local r, g, b = frame.healthBar:GetStatusBarColor() |
local healthBar, castBar = frame.healthBar, frame.castBar |
local glowRegion, overlayRegion, castbarOverlay, shieldedRegion, spellIconRegion, highlightRegion, nameTextRegion, levelTextRegion, bossIconRegion, raidIconRegion, stateIconRegion = frame:GetRegions() |
frame.oldname = nameTextRegion |
nameTextRegion:Hide() |
local newNameRegion = frame:CreateFontString() |
newNameRegion:SetPoint("BOTTOM", healthBar, "TOP", 0, 1) |
newNameRegion:SetFont(font, fontSize, fontOutline) |
newNameRegion:SetTextColor(0.84, 0.75, 0.65) |
newNameRegion:SetShadowOffset(1.25, -1.25) |
frame.name = newNameRegion |
local classicontexture = frame:CreateTexture(nil, "OVERLAY") |
classicontexture:SetPoint("BOTTOM", healthBar, "TOP", 0, 10) |
classicontexture:SetTexture("Interface\\WorldStateFrame\\Icons-Classes") |
classicontexture:SetWidth(40) |
classicontexture:SetHeight(40) |
frame.icon = classicontexture |
frame.level = levelTextRegion |
levelTextRegion:SetFont(font, fontSize, fontOutline) |
levelTextRegion:SetShadowOffset(1.25, -1.25) |
local securehandler |
local function SetHeightWidth() |
securehandler = CreateFrame("Frame", nil, nil, "SecureHandlerBaseTemplate") |
securehandler:WrapScript(frame, "OnShow", "self:SetHeight(10)") |
securehandler:WrapScript(frame, "OnShow", "self:SetWidth(100)") |
end |
if InCombatLockdown() then |
local f = CreateFrame("Frame") |
f:RegisterEvent("PLAYER_REGEN_ENABLED") |
f:SetScript("OnEvent", function(self) |
SetHeightWidth() |
self:SetScript("OnEvent", nil) |
self:UnregisterAllEvents() |
end) |
else |
frame:SetHeight(10) |
frame:SetWidth(100) |
SetHeightWidth() |
end |
healthBar:SetStatusBarTexture(bartexture) |
healthBar.hpBackground = healthBar:CreateTexture(nil, "BORDER") |
healthBar.hpBackground:SetAllPoints(healthBar) |
healthBar.hpBackground:SetTexture(bartexture) |
healthBar.hpBackground:SetVertexColor(0.15, 0.15, 0.15) |
healthBar.hpGlow = CreateFrame("Frame", nil, healthBar) |
healthBar.hpGlow:SetPoint("TOPLEFT", healthBar, "TOPLEFT", -4.5, 4) |
healthBar.hpGlow:SetPoint("BOTTOMRIGHT", healthBar, "BOTTOMRIGHT", 4.5, -4.5) |
healthBar.hpGlow:SetBackdrop(backdrop) |
healthBar.hpGlow:SetBackdropColor(0, 0, 0) |
healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0) |
castBar.castbarOverlay = castbarOverlay |
castBar.healthBar = healthBar |
castBar.shieldedRegion = shieldedRegion |
castBar:SetStatusBarTexture(bartexture) |
castBar:HookScript("OnShow", OnShow) |
castBar:HookScript("OnSizeChanged", OnSizeChanged) |
castBar:HookScript("OnValueChanged", OnValueChanged) |
castBar:HookScript("OnEvent", OnEvent) |
castBar:RegisterEvent("UNIT_SPELLCAST_INTERRUPTIBLE") |
castBar:RegisterEvent("UNIT_SPELLCAST_NOT_INTERRUPTIBLE") |
castBar.time = castBar:CreateFontString(nil, "ARTWORK") |
castBar.time:SetPoint("RIGHT", castBar, "LEFT", -2, 1) |
castBar.time:SetFont(font, fontSize, fontOutline) |
castBar.time:SetTextColor(0.84, 0.75, 0.65) |
castBar.time:SetShadowOffset(1.25, -1.25) |
castBar.cbBackground = castBar:CreateTexture(nil, "BORDER") |
castBar.cbBackground:SetAllPoints(castBar) |
castBar.cbBackground:SetTexture(bartexture) |
castBar.cbBackground:SetVertexColor(0.15, 0.15, 0.15) |
castBar.cbGlow = CreateFrame("Frame", nil, castBar) |
castBar.cbGlow:SetPoint("TOPLEFT", castBar, "TOPLEFT", -4.5, 4) |
castBar.cbGlow:SetPoint("BOTTOMRIGHT", castBar, "BOTTOMRIGHT", 4.5, -4.5) |
castBar.cbGlow:SetBackdrop(backdrop) |
castBar.cbGlow:SetBackdropColor(0, 0, 0) |
castBar.cbGlow:SetBackdropBorderColor(0, 0, 0) |
spellIconRegion:SetHeight(0.01) |
spellIconRegion:SetWidth(0.01) |
highlightRegion:SetTexture(bartexture) |
highlightRegion:SetVertexColor(0.25, 0.25, 0.25) |
frame.highlight = highlightRegion |
raidIconRegion:ClearAllPoints() |
raidIconRegion:SetPoint("LEFT", healthBar, "RIGHT", 2, 0) |
raidIconRegion:SetHeight(15) |
raidIconRegion:SetWidth(15) |
frame.oldglow = glowRegion |
frame.elite = stateIconRegion |
frame.boss = bossIconRegion |
frame.done = true |
glowRegion:SetTexture(nil) |
overlayRegion:SetTexture(nil) |
shieldedRegion:SetTexture(nil) |
castbarOverlay:SetTexture(nil) |
stateIconRegion:SetTexture(nil) |
bossIconRegion:SetTexture(nil) |
UpdateFrame(frame) |
frame:SetScript("OnShow", UpdateFrame) |
frame:SetScript("OnHide", OnHide) |
frame.elapsed = 0 |
frame:SetScript("OnUpdate", ThreatUpdate) |
end |
local function OnUpdate(self, elapsed) |
lastupdate = lastupdate + elapsed |
if lastupdate > 0.1 then |
lastupdate = 0 |
if WorldFrame:GetNumChildren() ~= numkids then |
numkids = WorldFrame:GetNumChildren() |
for i = 1, select("#", WorldFrame:GetChildren()) do |
frame = select(i, WorldFrame:GetChildren()) |
if IsValidFrame(frame) then |
CreateFrame(frame) |
end |
end |
end |
end |
end |
ncPlates:SetScript("OnUpdate", OnUpdate) |
ncPlates:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end) |
local blank = "Interface\\Addons\\ncMedia\\blank" |
local function kill() end |
local p = CreateFrame("Frame", mapborder, Minimap) |
p:SetFrameLevel(1) |
p:SetFrameStrata("BACKGROUND") |
p:SetHeight(144) |
p:SetWidth(144) |
p:SetPoint("CENTER",-0.5,0) |
p:SetScale(1) |
p:SetBackdrop({ |
bgFile = blank, |
edgeFile = blank, |
tile = false, tileSize = 0, edgeSize = 2, |
insets = { left = -1, right = -1, top = -1, bottom = -1 } |
}) |
p:SetBackdropColor(0.1,0.1,0.1) |
p:SetBackdropBorderColor(0.6,0.6,0.6) |
p:Show() |
Minimap:SetFrameStrata("BACKGROUND") |
Minimap:ClearAllPoints() |
Minimap:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -14, 36) |
MinimapBorder:Hide() |
MinimapBorderTop:Hide() |
MinimapZoomIn:Hide() |
MinimapZoomOut:Hide() |
MiniMapVoiceChatFrame:Hide() |
MiniMapVoiceChatFrame:UnregisterAllEvents() |
MiniMapVoiceChatFrame.Show = kill |
GameTimeFrame:Hide() |
MinimapZoneTextButton:Hide() |
MinimapZoneTextButton:UnregisterAllEvents() |
MinimapToggleButton:Hide() |
MinimapToggleButton:UnregisterAllEvents() |
MiniMapTracking:Hide() |
MiniMapTracking:UnregisterAllEvents() |
MiniMapMailBorder:Hide() |
MiniMapMailIcon.Show = kill |
MiniMapMailIcon:Hide() |
MiniMapBattlefieldFrame:ClearAllPoints() |
MiniMapBattlefieldFrame:SetPoint("BOTTOMRIGHT", Minimap, 3, 0) |
MinimapNorthTag.Show = kill |
MinimapNorthTag:Hide() |
MiniMapWorldMapButton:Hide() |
MiniMapWorldMapButton:UnregisterAllEvents() |
Minimap:EnableMouseWheel(true) |
Minimap:SetScript("OnMouseWheel", function(self, d) |
if d > 0 then |
_G.MinimapZoomIn:Click() |
elseif d < 0 then |
_G.MinimapZoomOut:Click() |
end |
end) |
Minimap:SetScript("OnMouseUp", function(self, btn) |
if btn == "RightButton" then |
ToggleDropDownMenu(1, nil, MiniMapTrackingDropDown, self) |
elseif btn == "MiddleButton" then |
GameTimeFrame:Click() |
else |
Minimap_OnClick(self) |
end |
end) |
Minimap:SetMaskTexture("Interface\\Addons\\ncMedia\\Mask.blp") |
## Interface: 30200 |
## Title: ncMinimap |
## Author: Nightcracker |
## Version: 1.0 |
## Notes: Minimap enhancing. |
ncMinimap.lua |
-- Credit Fatalentity |
local gt = GameTooltip |
local unitExists, maxHealth |
local tooltips = { |
GameTooltip, |
ItemRefTooltip, |
ShoppingTooltip1, |
ShoppingTooltip2, |
ShoppingTooltip3, |
WorldMapTooltip |
} |
for i=1, #tooltips do |
tooltips[i]:SetBackdrop{bgFile = "Interface\\AddOns\\ncMedia\\blank", edgeFile = "Interface\\AddOns\\ncMedia\\blank", tile = 0, tileSize = 0, edgeSize = 2, insets = { left = -1, right = -1, top = -1, bottom = -1 } } |
tooltips[i]:SetScript("OnShow", function(self) self:SetBackdropColor(.1,.1,.1,1) self:SetBackdropBorderColor(.6,.6,.6,1) end) |
tooltips[i]:SetScale(.9) |
end |
-- Setup new health statusbar |
local StatusBar = CreateFrame("StatusBar", nil, GameTooltip); |
StatusBar:SetWidth(1) |
StatusBar:SetHeight(1) |
StatusBar:ClearAllPoints() |
StatusBar:SetPoint("BOTTOMLEFT", 2, 2); |
StatusBar:SetPoint("BOTTOMRIGHT", -2, 2); |
StatusBar:SetStatusBarTexture("Interface\\AddOns\\ncMedia\\flat") |
StatusBar:Hide() |
-- Setup Anchor/Healthbar/Instanthide |
local function gtUpdate(self, ...) |
local owner = self:GetOwner() |
if self:GetAnchorType() == "ANCHOR_CURSOR" then |
return |
end |
-- Align World Units/Objects to mouse |
if owner == UIParent and not unitExists then |
self:ClearAllPoints() |
self:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMLEFT", -8, -2) |
end |
-- Update Health bar for world units |
if unitExists then |
local currentHealth = UnitHealth("mouseover") |
local green = currentHealth/maxHealth*2 |
local red = 1-green |
StatusBar:SetValue(currentHealth) |
StatusBar:SetStatusBarColor(red+1, green, 0) |
else |
StatusBar:Hide() |
end |
if not UnitExists("mouseover") and unitExists then |
self:Hide() |
unitExists = false |
end |
end |
------------------------------------------------------------------------------------------------------------------------------------------------ |
-- Get Unit Name |
local function unitName(unit) |
if not unit then return end |
local unitName = UnitName(unit) or "" |
local Reaction = UnitReaction(unit, "player") or 5 |
local Attackable = UnitCanAttack("player", unit) |
local Dead = UnitIsDead(unit) |
local AFK = UnitIsAFK(unit) |
local DND = UnitIsDND(unit) |
local Tapped = UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) |
if Attackable then |
if Tapped or Dead then |
return "|cff888888"..unitName.."|r" |
else |
if Reaction<4 then |
return "|cffff4444"..unitName.."|r" |
elseif Reaction == 4 then |
return "|cffffff44"..unitName.."|r" |
end |
end |
else |
if AFK then Status = " (AFK)" elseif DND then Status = " (DND)" elseif Dead then Status = " (Dead)" else Status = "" end |
if Reaction<4 then |
return "|cff3071bf"..unitName..Status.."|r" |
else |
return "|cffffffff"..unitName..Status.."|r" |
end |
end |
end |
-- Get Unit Information |
local function unitInformation(unit) |
if not unit then return end |
local Race = UnitRace(unit) or "" |
local Class, engClass = UnitClass(unit) |
local Classification = UnitClassification(unit) or "" |
local creatureType = UnitCreatureType(unit) or "" |
local PlayerLevel = UnitLevel("player") |
local Level = UnitLevel(unit) or "" |
local Player = UnitIsPlayer(unit) |
local Difficulty = GetQuestDifficultyColor(Level) |
local LevelColor = string.format("%02x%02x%02x", Difficulty.r*255, Difficulty.g*255, Difficulty.b*255) |
if Level == -1 then |
Level = "??" |
LevelColor = "ff0000" |
end |
if Player then |
local Color = string.format("%02x%02x%02x", RAID_CLASS_COLORS[engClass].r*255, RAID_CLASS_COLORS[engClass].g*255, RAID_CLASS_COLORS[engClass].b*255) |
return "Level |cff"..LevelColor..Level.."|r |cff"..Color..Class.."|r "..Race |
else |
if Classification == "worldboss" then Type = " Boss" elseif |
Classification == "rareelite" then Type = " Rare Elite" elseif |
Classification == "rare" then Type = " Rare" elseif |
Classification == "elite" then Type = " Elite" else |
Type = "" end |
return "Level |cff"..LevelColor..Level.."|r"..Type.." "..creatureType |
end |
end |
-- Get Unit Guild |
local function unitGuild(unit) |
local GuildName = GameTooltipTextLeft2:GetText() |
if GuildName and not GuildName:find("^Level") then |
return "<"..GuildName..">" |
else |
return nil |
end |
end |
-- Get Unit Target |
local function unitTarget(unit) |
if UnitExists(unit.."target") then |
local mouseoverTarget, _ = UnitName(unit.."target") |
if mouseoverTarget == UnitName("Player") and not UnitIsPlayer(unit) then |
return "|cffff4444>>TARGETING YOU<<|r" |
else |
if UnitCanAttack("player", unit.."target") or UnitIsPlayer(unit.."target") then |
local Color = string.format("%02x%02x%02x", RAID_CLASS_COLORS[select(2, UnitClass(unit.."target"))].r*255, RAID_CLASS_COLORS[select(2, UnitClass(unit.."target"))].g*255, RAID_CLASS_COLORS[select(2, UnitClass(unit.."target"))].b*255) |
return "|cff"..Color..mouseoverTarget.."|r" |
else |
return "|cffffffff"..mouseoverTarget.."|r" |
end |
end |
else |
return nil |
end |
end |
-- Set Unit Tooltip |
local function gtUnit(self, ...) |
-- Make sure the unit exists |
local _, unit = self:GetUnit() |
if not unit then return end |
-- Only show unit tooltips for world units, not frames |
if self:GetOwner() ~= UIParent then self:Hide(); return end |
unitExists = true |
-- Setup statusbar |
maxHealth = UnitHealthMax(unit) |
StatusBar:SetMinMaxValues(0, maxHealth) |
StatusBar:Show() |
-- Setup tooltip |
gtText = { unitName(unit), unitGuild(unit), unitInformation(unit), unitTarget(unit) } |
self:ClearLines() |
for i = 1, 4 do |
local line = gtText[i] |
if line then |
self:AddLine(line, 1, 1, 1, 1) |
end |
end |
end |
local function default(tooltip, parent) |
tooltip:SetOwner(parent, "ANCHOR_NONE") |
tooltip:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMLEFT", -8, -2) |
end |
gt:SetScript("OnUpdate", gtUpdate) |
gt:HookScript("OnTooltipSetUnit", gtUnit) |
hooksecurefunc("GameTooltip_SetDefaultAnchor", default) |
## Interface: 30200 |
## Author: Nightcracker |
## Version: 1.0 |
## Title: ncTooltip |
## Notes: Tooltip modification addon |
ncTooltip.lua |
local ncBind, localmacros = CreateFrame("Frame", nil, UIParent), 0 |
ncBind:SetFrameStrata("DIALOG") |
ncBind:EnableMouse(true) |
ncBind:EnableKeyboard(true) |
ncBind:EnableMouseWheel(true) |
ncBind.Texture = ncBind:CreateTexture() |
ncBind.Texture:SetAllPoints(ncBind) |
ncBind.Texture:SetTexture(0, 0, 0, .5) |
ncBind:Hide() |
function ncBind:UpdateKBHover(b, spellmacro) |
if self.Enabled == true and not InCombatLockdown() then |
ncBind:SetScript("OnKeyUp", function(self, key) self:BindingSetListener(key, spellmacro) end) |
ncBind:SetScript("OnMouseUp", function(self, key) self:BindingSetListener(key, spellmacro) end) |
ncBind:SetScript("OnMouseWheel", function(frame, delta) if delta>0 then ncBind:BindingSetListener("MOUSEWHEELUP", spellmacro) else ncBind:BindingSetListener("MOUSEWHEELDOWN", spellmacro) end end) |
self.button = b |
self:ClearAllPoints() |
self:SetAllPoints(b) |
self:Show() |
if spellmacro=="SPELL" then |
self.button.id = SpellBook_GetSpellID(self.button:GetID()) |
self.button.name = GetSpellName(self.button.id, SpellBookFrame.bookType) |
GameTooltip:AddLine("Trigger") |
GameTooltip:Show() |
GameTooltip:SetScript("OnHide", function(self) |
self:SetOwner(ncBind, "ANCHOR_NONE") |
self:SetPoint("BOTTOM", ncBind, "TOP", 0, 1) |
self:AddLine(ncBind.button.name, 0, 1, 0) |
ncBind.button.Bindings = {GetBindingKey(spellmacro.." "..ncBind.button.name)} |
if #ncBind.button.Bindings == 0 then |
self:AddLine("No Bindings Set") |
else |
for i = 1, #ncBind.button.Bindings do |
self:AddDoubleLine("Binding"..i, ncBind.button.Bindings[i], 1, 1, 1) |
end |
end |
self:Show() |
self:SetScript("OnHide", nil) |
end) |
else |
self.button.id = self.button:GetID() |
if localmacros==1 then self.button.id = self.button.id + 36 end |
self.button.name = GetMacroInfo(self.button.id) |
GameTooltip:SetOwner(ncBind, "ANCHOR_NONE") |
GameTooltip:SetPoint("BOTTOM", ncBind, "TOP", 0, 1) |
GameTooltip:AddLine(ncBind.button.name, 0, 1, 0) |
ncBind.button.Bindings = {GetBindingKey(spellmacro.." "..ncBind.button.name)} |
if #ncBind.button.Bindings == 0 then |
GameTooltip:AddLine("No Bindings Set") |
else |
for i = 1, #ncBind.button.Bindings do |
GameTooltip:AddDoubleLine("Binding"..i, ncBind.button.Bindings[i], 1, 1, 1) |
end |
end |
GameTooltip:Show() |
end |
end |
end |
function ncBind:BindingSetListener(Key, spellmacro) |
if Key == "ESCAPE" or Key == "RightButton" then |
for i = 1, #self.button.Bindings do |
SetBinding(self.button.Bindings[i]) |
end |
print("All keybindings cleared for |cff00ff00"..self.button.name.."|r.") |
self:UpdateKBHover(self.button, spellmacro) |
if spellmacro=="SPELL" then |
GameTooltip:Hide() |
end |
return |
end |
if Key == "LSHIFT" |
or Key == "RSHIFT" |
or Key == "LCTRL" |
or Key == "RCTRL" |
or Key == "LALT" |
or Key == "RALT" |
or Key == "UNKNOWN" |
or Key == "LeftButton" |
or Key == "MiddleButton" |
then return end |
if Key == "Button4" then Key = "BUTTON4" end |
if Key == "Button5" then Key = "BUTTON5" end |
local altDown = IsAltKeyDown() or "" |
local ctrlDown = IsControlKeyDown() or "" |
local shiftDown = IsShiftKeyDown() or "" |
if altDown == 1 then altDown = "ALT-" |
elseif ctrlDown == 1 then ctrlDown = "CTRL-" |
elseif shiftDown == 1 then shiftDown = "SHIFT-" |
end |
SetBinding(altDown..ctrlDown..shiftDown..Key, spellmacro.." "..self.button.name) |
print("|cFF00FF00"..altDown..ctrlDown..shiftDown..Key.." |ris now bound to |cFF00FF00"..spellmacro.." "..self.button.name..".") |
self:UpdateKBHover(self.button, spellmacro) |
if spellmacro=="SPELL" then |
GameTooltip:Hide() |
end |
end |
function ncBind:HideFrame() |
self:ClearAllPoints() |
self:Hide() |
GameTooltip:Hide() |
end |
function ncBind:Activate() |
self.Enabled = true |
self:RegisterEvent("PLAYER_REGEN_DISABLED") |
end |
function ncBind:Deactivate(save) |
if save then |
SaveBindings(2) |
print("All keybindings have been saved.") |
else |
LoadBindings(2) |
print("All newly set keybindings have been discarded.") |
end |
self.Enabled = false |
self:HideFrame() |
self:UnregisterEvent("PLAYER_REGEN_DISABLED") |
StaticPopup_Hide("KEYBIND_MODE") |
end |
StaticPopupDialogs["KEYBIND_MODE"] = { |
text = "Hover your mouse over any of the spells in your spellbook or macro frame to bind them. Press the Escape key or right click to clear the current spell/macro binding.", |
button1 = "Save bindings", |
button2 = "Discard bindings", |
OnAccept = function() ncBind:Deactivate(true) end, |
OnCancel = function() ncBind:Deactivate(false) end, |
timeout = 0, |
whileDead = 1, |
hideOnEscape = false |
} |
function SlashCmdList.ncBind() |
if InCombatLockdown() then |
print("Cannot bind keys while in combat") |
elseif not ncBind.Enabled then |
ncBind:Activate() |
StaticPopup_Show("KEYBIND_MODE") |
end |
end |
SLASH_ncBind1 = "/bind" |
LoadAddOn("Blizzard_MacroUI") |
for i=1,12 do |
local b = _G["SpellButton"..i] |
b:HookScript("OnEnter", function(self) ncBind:UpdateKBHover(self, "SPELL") end) |
end |
for i=1,36 do |
local b = _G["MacroButton"..i] |
b:HookScript("OnEnter", function(self) ncBind:UpdateKBHover(self, "MACRO") end) |
end |
ncBind:SetScript("OnEvent", function() ncBind:Deactivate(false) end) |
ncBind:SetScript("OnLeave", function(self) self:HideFrame() end) |
MacroFrameTab1:HookScript("OnMouseUp", function() localmacros = 0 end) |
MacroFrameTab2:HookScript("OnMouseUp", function() localmacros = 1 end) |
## Interface: 30200 |
## Title: ncBindings |
## Author: Nightcracker |
## Version: 1.0 |
## Notes: Addon for binding on mouseover. |
ncBindings.lua |
local f = CreateFrame("Frame", "MostValueableFrame", QuestRewardScrollChildFrame) |
f:SetFrameLevel(1) |
f:SetFrameStrata("HIGH") |
f:SetBackdrop( { |
bgFile = "Interface\\AddOns\\ncMedia\\Blank", |
edgeFile = "Interface\\AddOns\\ncMedia\\Blank", |
tile = false, tileSize = 0, edgeSize = 3, |
insets = { left = 1, right = 1, top = 1, bottom = 1 } |
}) |
f:SetBackdropColor(0.1,0.1,0.1,0) |
f:SetBackdropBorderColor(0.6,0.6,0.6,1) |
local function MostValueable() |
f:Hide() |
local bestp, besti = 0 |
for i=1,GetNumQuestChoices() do |
local link, name, _, qty = GetQuestItemLink("choice", i), GetQuestItemInfo("choice", i) |
local price = link and select(11, GetItemInfo(link)) |
if not price then |
return |
elseif (price * (qty or 1)) > bestp then |
bestp, besti = (price * (qty or 1)), i |
end |
if besti then |
f:ClearAllPoints() |
f:SetAllPoints("QuestRewardItem"..besti.."IconTexture") |
f:Show() |
end |
end |
end |
f:SetScript("OnEvent", function(self, event, ...) |
if (event == "QUEST_DETAIL") then |
AcceptQuest() |
CompleteQuest() |
elseif (event == "QUEST_COMPLETE") then |
if (GetNumQuestChoices() and GetNumQuestChoices() < 1) then |
GetQuestReward() |
else |
MostValueable() |
end |
elseif (event == "QUEST_ACCEPT_CONFIRM") then |
ConfirmAcceptQuest() |
end |
end) |
f:RegisterEvent("QUEST_ACCEPT_CONFIRM") |
f:RegisterEvent("QUEST_DETAIL") |
f:RegisterEvent("QUEST_COMPLETE") |
f:Hide() |
if QuestRewardItem1:IsVisible() then |
MostValueable() |
end |
## Interface: 30200 |
## Author: Nightcracker |
## Version: 1.0 |
## Title: ncQuest |
## Notes: Automaticly accepts/completes quests |
ncQuest.lua |
-- Credit Cidrei, license is included, see readme |
local ncExtrabuttons, header, _, class = {}, CreateFrame("Button", "ncExtrabuttonsHeader", UIParent, "SecureHandlerClickTemplate"), UnitClass("player") |
ncExtrabuttons.buttons = {} |
-- Setup class specific actionbutton id's |
if class == "DRUID" then |
ncExtrabuttons["buttonids"] = { |
26, |
27, |
28, |
29, |
30, |
31, |
32, |
33, |
34, |
35, |
36, |
49, |
50, |
51, |
52, |
53, |
54, |
55, |
56, |
57, |
58, |
59, |
60, |
38, |
39, |
} |
elseif class == "WARRIOR" then |
ncExtrabuttons["buttonids"] = { |
1, |
2, |
3, |
4, |
5, |
6, |
7, |
8, |
9, |
10, |
11, |
12, |
60, |
109, |
110, |
111, |
112, |
113, |
114, |
115, |
116, |
117, |
118, |
119, |
120, |
} |
else |
ncExtrabuttons["buttonids"] = { |
96, |
97, |
98, |
99, |
100, |
101, |
102, |
103, |
104, |
105, |
106, |
107, |
108, |
109, |
110, |
111, |
112, |
113, |
114, |
115, |
116, |
117, |
118, |
119, |
120, |
} |
end |
-- Setup the virtual button with binding |
header:RegisterForClicks("AnyDown","AnyUp") |
header:Hide() |
header:SetAttribute("_onclick", [[ |
self:SetPoint("CENTER", "$cursor") |
if geistOpen then |
geistOpen = nil |
self:Hide() |
else |
geistOpen = 1 |
self:Show() |
end]]) |
BINDING_HEADER_ncExtrabuttons = "ncExtrabuttons" |
_G["BINDING_NAME_CLICK ncExtrabuttonsHeader:LeftButton"] = "Show ncExtrabuttons" |
-- Create the frame |
for i = 1, 25 do |
local button = CreateFrame("CheckButton", "ncExtrabuttonsButton"..i, ncExtrabuttonsHeader, "ActionBarButtonTemplate") |
ncExtrabuttons.buttons[i] = button |
if i == 1 then |
button:SetPoint("CENTER", ncExtrabuttonsHeader, "CENTER", 0, 0) |
elseif i == 2 then |
button:SetPoint("RIGHT", ncExtrabuttons.buttons[i-1], "LEFT", -2, 0) |
elseif i == 3 then |
button:SetPoint("LEFT", ncExtrabuttons.buttons[i-2], "RIGHT", 2, 0) |
elseif i == 4 then |
button:SetPoint("BOTTOM", ncExtrabuttons.buttons[i-3], "TOP", 0, 2) |
elseif i == 5 then |
button:SetPoint("TOP", ncExtrabuttons.buttons[i-4], "BOTTOM", 0, -2) |
elseif i == 6 or i == 14 then |
button:SetPoint("RIGHT", ncExtrabuttons.buttons[i-2], "LEFT", -2, 0) |
elseif i == 7 or i == 15 then |
button:SetPoint("LEFT", ncExtrabuttons.buttons[i-3], "RIGHT", 2, 0) |
elseif i == 8 or i == 16 then |
button:SetPoint("RIGHT", ncExtrabuttons.buttons[i-3], "LEFT", -2, 0) |
elseif i == 9 or i == 17 then |
button:SetPoint("LEFT", ncExtrabuttons.buttons[i-4], "RIGHT", 2, 0) |
elseif i == 10 or i == 22 or i == 24 then |
button:SetPoint("RIGHT", ncExtrabuttons.buttons[i-8], "LEFT", -2, 0) |
elseif i == 11 or i == 23 or i == 25 then |
button:SetPoint("LEFT", ncExtrabuttons.buttons[i-8], "RIGHT", 2, 0) |
elseif i == 12 then |
button:SetPoint("BOTTOM", ncExtrabuttons.buttons[i-8], "TOP", 0, 2) |
elseif i == 13 then |
button:SetPoint("TOP", ncExtrabuttons.buttons[i-8], "BOTTOM", 0, -2) |
elseif i == 18 or i == 20 then |
button:SetPoint("RIGHT", ncExtrabuttons.buttons[i-12], "LEFT", -2, 0) |
elseif i == 19 or i == 21 then |
button:SetPoint("LEFT", ncExtrabuttons.buttons[i-12], "RIGHT", 2, 0) |
end |
button:SetAttribute("*type*", "action") |
button:SetAttribute("*action*", ncExtrabuttons["buttonids"][i]) |
header:SetScale(1) |
end |
## Interface: 30200 |
## Title: ncExtrabuttons |
## Notes: Quick mouse access for 25 buttons |
## Version: 1.0 |
## Author: Nightcracker |
## SavedVariablesPerCharacter: Geist |
ncExtrabuttons.lua |
<Bindings> |
<Binding name="CLICK ncExtrabuttonsHeader:LeftButton" header="ncExtrabuttons"> |
</Binding> |
</Bindings> |
-- Credit Tukz and FatalEntity |
local blank = "Interface\\AddOns\\ncMedia\\blank" |
local mainhand, _, _, offhand = GetWeaponEnchantInfo() |
local function CreatePanel(height, width, x, y, anchorPoint, anchorPointRel, anchor, level, parent, strata) |
local p = CreateFrame("Frame", _, parent) |
p:SetFrameLevel(level) |
p:SetFrameStrata(strata) |
p:SetHeight(height) |
p:SetWidth(width) |
p:SetPoint(anchorPoint, anchor, anchorPointRel, x, y) |
p:SetBackdrop( { |
bgFile = blank, |
edgeFile = blank, |
tile = false, tileSize = 0, edgeSize = 1, |
insets = { left = -1, right = -1, top = -1, bottom = -1 } |
}) |
p:SetBackdropColor(.1,.1,.1) |
p:SetBackdropBorderColor(.6,.6,.6) |
p:EnableMouse(true) |
p:Show() |
return p |
end |
TemporaryEnchantFrame:ClearAllPoints() |
TemporaryEnchantFrame:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, -20) |
TempEnchant1:ClearAllPoints() |
TempEnchant2:ClearAllPoints() |
TempEnchant1:SetPoint("TOPRIGHT", -20, 0) |
TempEnchant2:SetPoint("RIGHT", TempEnchant1, "LEFT", -9, 0) |
for i = 1, 2 do |
local TempBG = CreatePanel(30, 30, -2, 2, "TOPLEFT", "TOPLEFT", _G["TempEnchant"..i], 1, _G["TempEnchant"..i], "BACKGROUND") |
_G["TempEnchant"..i.."Border"]:Hide() |
_G["TempEnchant"..i.."Icon"]:SetTexCoord(.1, .9, .1, .9) |
_G["TempEnchant"..i]:SetHeight(26) |
_G["TempEnchant"..i]:SetWidth(26) |
_G["TempEnchant"..i.."Duration"]:ClearAllPoints() |
_G["TempEnchant"..i.."Duration"]:SetPoint("BOTTOM", 0, -16) |
_G["TempEnchant"..i.."Duration"]:SetFont("Interface\\Addons\\ncMedia\\slkscr.TTF", 11, "MONOCHROME") |
end |
local function StyleBuffs(buttonName, index, debuff) |
local buff = _G[buttonName..index] |
local icon = _G[buttonName..index.."Icon"] |
local border = _G[buttonName..index.."Border"] |
local Duration = _G[buttonName..index.."Duration"] |
if icon and not _G[buttonName..index.."Panel"] then |
icon:SetTexCoord(.1, .9, .1, .9) |
buff:SetHeight(26) |
buff:SetWidth(26) |
Duration:ClearAllPoints() |
Duration:SetPoint("BOTTOM", 0, -16) |
Duration:SetFont("Interface\\Addons\\ncMedia\\slkscr.TTF",11, "MONOCHROME") |
_G[buttonName..index.."Panel"] = CreatePanel(30, 30, -2, 2, "TOPLEFT", "TOPLEFT", buff, 1, buff, "BACKGROUND") |
if debuff then |
_G[buttonName..index.."Panel"]:SetBackdropBorderColor(134/255, 12/255, 12/255) |
end |
end |
if border then border:Hide() end |
end |
function UpdateBuffAnchors(buttonName, index) |
local buff = _G[buttonName..index] |
buff:ClearAllPoints() |
StyleBuffs(buttonName, index, false) |
if index == 16 then |
-- New row |
buff:SetPoint("TOPRIGHT",UIParent, "TOPRIGHT", -180, -79) |
elseif index == 1 then |
if (mainhand and not offhand) or (offhand and not mainhand) then |
buff:SetPoint("TOPRIGHT", "UIParent", "TOPRIGHT", -55, -20) |
elseif (mainhand and offhand) then |
buff:SetPoint("TOPRIGHT", "UIParent", "TOPRIGHT", -90, -20) |
else |
buff:SetPoint("TOPRIGHT", "UIParent", "TOPRIGHT", -20, -20) |
end |
else |
buff:SetPoint("RIGHT", _G[buttonName..(index-1)], "LEFT", -9, 0) |
end |
end |
function UpdateDebuffAnchors(buttonName, index) |
local debuff = _G[buttonName..index]; |
StyleBuffs(buttonName, index, true) |
debuff:ClearAllPoints() |
if index == 1 then |
debuff:SetPoint("TOPLEFT",UIParent, "TOPLEFT", 20, -20) |
else |
debuff:SetPoint("LEFT", _G[buttonName..(index-1)], "RIGHT", 9, 0) |
end |
end |
local function UpdateTime(button, timeLeft) |
local duration = _G[button:GetName().."Duration"] |
if SHOW_BUFF_DURATIONS == "1" and timeLeft then |
if (timeLeft < 3600 and timeLeft >= 60) then |
local m = floor(timeLeft / 60 + 1) |
duration:SetFormattedText("%dm", m); |
elseif (timeLeft < 60) then |
duration:SetFormattedText("%ds", timeLeft); |
else |
local h = floor(timeLeft / 3600 + 1) |
duration:SetFormattedText("%dh", h); |
end |
end |
end |
local f = CreateFrame("Frame") |
f:SetScript("OnEvent", function() |
mainhand, _, _, offhand = GetWeaponEnchantInfo() |
local buff = BuffButton1 |
if buff then |
if (mainhand and not offhand) or (offhand and not mainhand) then |
buff:SetPoint("TOPRIGHT", "UIParent", "TOPRIGHT", -55, -20) |
elseif (mainhand and offhand) then |
buff:SetPoint("TOPRIGHT", "UIParent", "TOPRIGHT", -90, -20) |
else |
buff:SetPoint("TOPRIGHT", "UIParent", "TOPRIGHT", -20, -20) |
end |
end |
end) |
f:RegisterEvent("UNIT_INVENTORY_CHANGED") |
f:RegisterEvent("PLAYER_EVENTERING_WORLD") |
hooksecurefunc("BuffButton_UpdateAnchors", UpdateBuffAnchors) |
hooksecurefunc("DebuffButton_UpdateAnchors", UpdateDebuffAnchors) |
hooksecurefunc("AuraButton_UpdateDuration", UpdateTime) |
## Interface: 30200 |
## Title: ncBuffs |
## Author: Nightcracker |
## Version: 1.0 |
## Notes: Addon for changing the position and look of the buffs. |
ncBuffs.lua |
-- define most of the variables |
local myname, _ = UnitName("player") |
local _, myclass = UnitClass("player") |
local button_system, testmode |
local bags_on_mouseover, bar3_on_mouseover, bar2_on_mouseover |
local move_micro, move_bags, move_rightbars, move_shapeshift, move_bar1, move_bar2, move_bar3 |
local lock_micro, lock_bags, lock_rightbars, lock_shapeshift, lock_bar1, lock_bar2, lock_bar3 |
local bar1scale, bar2scale, bar3scale, bar45scale, petscale, shapeshiftscale, micromenuscale, bagscale |
-- Config |
testmode = 0 |
button_system = 1 |
move_bar1 = 0 |
lock_bar1 = 1 |
move_bar2 = 0 |
lock_bar2 = 1 |
move_bar3 = 0 |
lock_bar3 = 1 |
move_rightbars = 0 |
lock_rightbars = 1 |
move_shapeshift = 0 |
lock_shapeshift = 1 |
hide_shapeshift = 1 |
move_pet = 0 |
lock_pet = 1 |
hide_pet = 0 |
move_micro = 1 |
lock_micro = 1 |
hide_micro = 1 |
move_bags = 1 |
lock_bags = 1 |
hide_bags = 1 |
move_veb = 0 |
lock_veb = 1 |
bar1scale = 1 |
bar2scale = 1 |
bar3scale = 0.001 |
bar45scale = 1.5 |
petscale = 0.8 |
shapeshiftscale = 0.65 |
micromenuscale = 0.8 |
bagscale = 0.9 |
local frame_positions = { |
[1] = { a = "BOTTOM", x = -94, y = 34 }, --fbar1_button_system_1 |
[2] = { a = "BOTTOM", x = 0, y = 0 }, --fbar1_button_system_0 |
[3] = { a = "BOTTOM", x = 122, y = 34 }, --fbar2_button_system_1 |
[4] = { a = "BOTTOM", x = 0, y = 60 }, --fbar2_button_system_0 |
[5] = { a = "BOTTOM", x = 0, y = 0 }, --fbar3 |
[6] = { a = "BOTTOM", x = -141, y = 15 }, --fbar45 |
[7] = { a = "BOTTOMRIGHT", x = 5, y = -5 }, --bags |
[8] = { a = "TOP", x = 0, y = 5 }, --micromenu |
[9] = { a = "BOTTOM", x = 3.5, y = 145 }, --petbar |
[10] = { a = "BOTTOM", x = 0, y = 240 }, --shapeshift |
[11] = { a = "BOTTOM", x = 120, y = 120 }, --my own vehicle exit button |
} |
--------------------------------------------------- |
-- CONFIG END |
--------------------------------------------------- |
-- Only edit stuff below if you _know_ what you are doing. |
--------------------------------------------------- |
-- CREATE ALL THE HOLDER FRAMES |
--------------------------------------------------- |
-- Frame to hold the ActionBar1 and the BonusActionBar |
local fbar1 = CreateFrame("Frame","rABS_Bar1Holder",UIParent) |
if button_system == 1 then |
fbar1:SetWidth(264) |
fbar1:SetHeight(116) |
fbar1:SetPoint(frame_positions[1].a,frame_positions[1].x,frame_positions[1].y) |
else |
fbar1:SetWidth(518) |
fbar1:SetHeight(58) |
fbar1:SetPoint(frame_positions[2].a,frame_positions[2].x,frame_positions[2].y) |
end |
if testmode == 1 then |
fbar1:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 0, right = 0, top = 0, bottom = 0 }}); |
end |
--fbar1:SetFrameStrata("LOW") |
fbar1:Show() |
-- Frame to hold the MultibarLeft |
local fbar2 = CreateFrame("Frame","rABS_Bar2Holder",UIParent) |
if button_system == 1 then |
fbar2:SetWidth(264) |
fbar2:SetHeight(116) |
fbar2:SetPoint(frame_positions[3].a,frame_positions[3].x,frame_positions[3].y) |
else |
fbar2:SetWidth(518) |
fbar2:SetHeight(58) |
fbar2:SetPoint(frame_positions[4].a,frame_positions[4].x,frame_positions[4].y) |
end |
if testmode == 1 then |
fbar2:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 0, right = 0, top = 0, bottom = 0 }}); |
end |
fbar2:Show() |
-- Frame to hold the MultibarRight |
local fbar3 = CreateFrame("Frame","rABS_Bar3Holder",UIParent) |
fbar3:SetWidth(518) |
fbar3:SetHeight(58) |
if testmode == 1 then |
fbar3:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 0, right = 0, top = 0, bottom = 0 }}); |
end |
fbar3:SetPoint(frame_positions[5].a,frame_positions[5].x,frame_positions[5].y) |
fbar3:Hide() |
-- Frame to hold the right bars |
local fbar45 = CreateFrame("Frame","rABS_Bar45Holder",UIParent) |
fbar45:SetWidth(100) -- size the width here |
fbar45:SetHeight(60) -- size the height here |
if testmode == 1 then |
fbar45:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 0, right = 0, top = 0, bottom = 0 }}); |
end |
fbar45:SetPoint(frame_positions[6].a,frame_positions[6].x,frame_positions[6].y) |
-- Frame to hold the bag buttons |
local fbag = CreateFrame("Frame","rABS_BagHolder",UIParent) |
fbag:SetWidth(220) |
fbag:SetHeight(60) |
if testmode == 1 then |
fbag:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 0, right = 0, top = 0, bottom = 0 }}); |
end |
fbag:SetPoint(frame_positions[7].a,frame_positions[7].x,frame_positions[7].y) |
fbag:Show() |
-- Frame to hold the micro menu |
local fmicro = CreateFrame("Frame","rABS_MicroMenuHolder",UIParent) |
fmicro:SetWidth(263) |
fmicro:SetHeight(60) |
if testmode == 1 then |
fmicro:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 0, right = 0, top = 0, bottom = 0 }}); |
end |
fmicro:SetPoint(frame_positions[8].a,frame_positions[8].x,frame_positions[8].y) |
fmicro:Show() |
-- Frame to hold the pet bars |
local fpet = CreateFrame("Frame","rABS_PetBarHolder",UIParent) |
fpet:SetWidth(400) -- size the width here |
fpet:SetHeight(53) -- the height here |
if testmode == 1 then |
fpet:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 0, right = 0, top = 0, bottom = 0 }}); |
end |
fpet:SetPoint(frame_positions[9].a,frame_positions[9].x,frame_positions[9].y) |
-- Frame to hold the shapeshift bars |
local fshift = CreateFrame("Frame","rABS_ShapeShiftHolder",UIParent) |
fshift:SetWidth(355) -- size the width here |
fshift:SetHeight(50) -- size the height here |
if testmode == 1 then |
fshift:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 0, right = 0, top = 0, bottom = 0 }}); |
end |
fshift:SetPoint(frame_positions[10].a,frame_positions[10].x,frame_positions[10].y) |
--------------------------------------------------- |
-- CREATE MY OWN VEHICLE EXIT BUTTON |
--------------------------------------------------- |
local fveb = CreateFrame("Frame","rABS_VEBHolder",UIParent) |
fveb:SetWidth(70) -- size the width here |
fveb:SetHeight(70) -- size the height here |
if testmode == 1 then |
fveb:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 0, right = 0, top = 0, bottom = 0 }}); |
end |
fveb:SetPoint(frame_positions[11].a,frame_positions[11].x,frame_positions[11].y) |
local veb = CreateFrame("BUTTON", "rABS_VehicleExitButton", fveb, "SecureActionButtonTemplate"); |
veb:SetWidth(50) |
veb:SetHeight(50) |
veb:SetPoint("CENTER",0,0) |
veb:RegisterForClicks("AnyUp") |
veb:SetNormalTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up") |
veb:SetPushedTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Down") |
veb:SetHighlightTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Down") |
veb:SetScript("OnClick", function(self) VehicleExit() end) |
veb:RegisterEvent("UNIT_ENTERING_VEHICLE") |
veb:RegisterEvent("UNIT_ENTERED_VEHICLE") |
veb:RegisterEvent("UNIT_EXITING_VEHICLE") |
veb:RegisterEvent("UNIT_EXITED_VEHICLE") |
veb:SetScript("OnEvent", function(self,event,...) |
local arg1 = ...; |
if(((event=="UNIT_ENTERING_VEHICLE") or (event=="UNIT_ENTERED_VEHICLE")) and arg1 == "player") then |
veb:SetAlpha(1) |
elseif(((event=="UNIT_EXITING_VEHICLE") or (event=="UNIT_EXITED_VEHICLE")) and arg1 == "player") then |
veb:SetAlpha(0) |
end |
end) |
veb:SetAlpha(0) |
--------------------------------------------------- |
-- MOVE STUFF INTO POSITION |
--------------------------------------------------- |
local i,f |
--bar1 |
for i=1, 6 do |
_G["ActionButton"..i]:SetParent(fbar1); |
end |
ActionButton1:ClearAllPoints() |
ActionButton1:SetPoint("BOTTOMLEFT",fbar1,"BOTTOMLEFT",10,10); |
--bonus bar |
BonusActionBarFrame:SetParent(fbar1) |
BonusActionBarFrame:SetWidth(0.01) |
BonusActionBarTexture0:Hide() |
BonusActionBarTexture1:Hide() |
BonusActionButton1:ClearAllPoints() |
BonusActionButton1:SetPoint("BOTTOMLEFT", fbar1, "BOTTOMLEFT", 10, 10); |
--bar2 |
MultiBarBottomLeft:SetParent(fbar2) |
MultiBarBottomLeftButton1:ClearAllPoints() |
MultiBarBottomLeftButton1:SetPoint("BOTTOMLEFT", fbar2, "BOTTOMLEFT", 10, 10); |
--bar3 |
MultiBarBottomRight:SetParent(fbar3) |
MultiBarBottomRightButton1:ClearAllPoints() |
MultiBarBottomRightButton1:SetPoint("BOTTOMLEFT", fbar3, "BOTTOMLEFT", 10, 10); |
if button_system == 1 then |
ActionButton7:ClearAllPoints() |
ActionButton7:SetPoint("BOTTOMLEFT",ActionButton1,"TOPLEFT",0,5); |
BonusActionButton7:ClearAllPoints() |
BonusActionButton7:SetPoint("BOTTOMLEFT",BonusActionButton1,"TOPLEFT",0,5); |
MultiBarBottomLeftButton7:ClearAllPoints() |
MultiBarBottomLeftButton7:SetPoint("BOTTOMLEFT",MultiBarBottomLeftButton1,"TOPLEFT",0,5); |
end |
--bags |
local BagButtons = { |
MainMenuBarBackpackButton, |
CharacterBag0Slot, |
CharacterBag1Slot, |
CharacterBag2Slot, |
CharacterBag3Slot, |
KeyRingButton, |
} |
local function rABS_MoveBagButtons() |
for _, f in pairs(BagButtons) do |
f:SetParent(fbag); |
end |
MainMenuBarBackpackButton:ClearAllPoints(); |
MainMenuBarBackpackButton:SetPoint("BOTTOMRIGHT", -15, 15); |
end |
rABS_MoveBagButtons(); |
--mircro menu |
local MicroButtons = { |
CharacterMicroButton, |
SpellbookMicroButton, |
TalentMicroButton, |
AchievementMicroButton, |
QuestLogMicroButton, |
SocialsMicroButton, |
PVPMicroButton, |
LFGMicroButton, |
MainMenuMicroButton, |
HelpMicroButton, |
} |
local function rABS_MoveMicroButtons(skinName) |
for _, f in pairs(MicroButtons) do |
f:SetParent(fmicro); |
end |
CharacterMicroButton:ClearAllPoints(); |
CharacterMicroButton:SetPoint("BOTTOMLEFT", 5, 5); |
SocialsMicroButton:ClearAllPoints(); |
SocialsMicroButton:SetPoint("LEFT", QuestLogMicroButton, "RIGHT", -3, 0); |
UpdateTalentButton(); |
end |
hooksecurefunc("VehicleMenuBar_MoveMicroButtons", rABS_MoveMicroButtons); |
rABS_MoveMicroButtons(); |
--shift |
ShapeshiftBarFrame:SetParent(fshift) |
ShapeshiftBarFrame:SetWidth(0.01) |
ShapeshiftButton1:ClearAllPoints() |
ShapeshiftButton1:SetPoint("BOTTOMLEFT",fshift,"BOTTOMLEFT",10,10) |
local function rABS_MoveShapeshift() |
ShapeshiftButton1:SetPoint("BOTTOMLEFT",fshift,"BOTTOMLEFT",10,10) |
end |
hooksecurefunc("ShapeshiftBar_Update", rABS_MoveShapeshift); |
--possess bar |
PossessBarFrame:SetParent(fshift) |
PossessButton1:ClearAllPoints() |
PossessButton1:SetPoint("BOTTOMLEFT", fshift, "BOTTOMLEFT", 10, 10); |
--pet |
PetActionBarFrame:SetParent(fpet) |
PetActionBarFrame:SetWidth(0.01) |
PetActionButton1:ClearAllPoints() |
PetActionButton1:SetPoint("BOTTOMLEFT",fpet,"BOTTOMLEFT",10,10) |
--right bars |
MultiBarRight:SetParent(fbar45); |
MultiBarLeft:SetParent(fbar45); |
MultiBarRight:ClearAllPoints() |
MultiBarRight:SetPoint("TOPRIGHT",-10,-10) |
--------------------------------------------------- |
-- ACTIONBUTTONS MUST BE HIDDEN |
--------------------------------------------------- |
-- hide actionbuttons when the bonusbar is visible (rogue stealth and such) |
local function rABS_showhideactionbuttons(alpha) |
local f = "ActionButton" |
for i=1, 12 do |
_G[f..i]:SetAlpha(alpha) |
end |
end |
BonusActionBarFrame:HookScript("OnShow", function(self) rABS_showhideactionbuttons(0) end) |
BonusActionBarFrame:HookScript("OnHide", function(self) rABS_showhideactionbuttons(1) end) |
if BonusActionBarFrame:IsShown() then |
rABS_showhideactionbuttons(0) |
end |
--------------------------------------------------- |
-- ON MOUSEOVER STUFF |
--------------------------------------------------- |
--functions |
local function rABS_showhidebar1(alpha) |
if BonusActionBarFrame:IsShown() then |
for i=1, 12 do |
local pb = _G["BonusActionButton"..i] |
pb:SetAlpha(alpha) |
end |
else |
for i=1, 12 do |
local pb = _G["ActionButton"..i] |
pb:SetAlpha(alpha) |
end |
end |
end |
local function rABS_showhidebar2(alpha) |
if MultiBarBottomLeft:IsShown() then |
for i=1, 12 do |
local pb = _G["MultiBarBottomLeftButton"..i] |
pb:SetAlpha(alpha) |
end |
end |
end |
local function rABS_showhidebar3(alpha) |
if MultiBarBottomRight:IsShown() then |
for i=1, 12 do |
local pb = _G["MultiBarBottomRightButton"..i] |
pb:SetAlpha(alpha) |
end |
end |
end |
local function rABS_showhideshapeshift(alpha) |
for i=1, NUM_SHAPESHIFT_SLOTS do |
local pb = _G["ShapeshiftButton"..i] |
pb:SetAlpha(alpha) |
end; |
end |
local function rABS_showhidepet(alpha) |
for i=1, NUM_PET_ACTION_SLOTS do |
local pb = _G["PetActionButton"..i] |
pb:SetAlpha(alpha) |
end; |
end |
local function rABS_showhiderightbar(alpha) |
if MultiBarLeft:IsShown() then |
for i=1, 12 do |
local pb = _G["MultiBarLeftButton"..i] |
pb:SetAlpha(alpha) |
end |
end |
if MultiBarRight:IsShown() then |
for i=1, 12 do |
local pb = _G["MultiBarRightButton"..i] |
pb:SetAlpha(alpha) |
end |
end |
end |
local function rABS_showhidemicro(alpha) |
for _, frame in pairs(MicroButtons) do |
frame:SetAlpha(alpha) |
end |
end |
local function rABS_showhidebags(alpha) |
for _, frame in pairs(BagButtons) do |
frame:SetAlpha(alpha) |
end |
end |
--------------------------------------------------- |
-- MAKE THE DEFAULT BARS UNVISIBLE |
--------------------------------------------------- |
local FramesToHide = { |
MainMenuBar, |
VehicleMenuBar, |
} |
local function rABS_HideDefaultFrames() |
for _, f in pairs(FramesToHide) do |
f:SetScale(0.001) |
f:SetAlpha(0) |
end |
end |
rABS_HideDefaultFrames(); |
--------------------------------------------------- |
-- SCALING |
--------------------------------------------------- |
fbar1:SetScale(bar1scale) |
fbar2:SetScale(bar2scale) |
fbar3:SetScale(bar3scale) |
fbar45:SetScale(bar45scale) |
fpet:SetScale(petscale) |
fshift:SetScale(shapeshiftscale) |
fmicro:SetScale(micromenuscale) |
fbag:SetScale(bagscale) |
--------------------------------------------------- |
-- MOVABLE FRAMES |
--------------------------------------------------- |
-- func |
local function rABS_MoveThisFrame(f,moveit,lock) |
if moveit == 1 then |
f:SetMovable(true) |
f:SetUserPlaced(true) |
if lock ~= 1 then |
f:EnableMouse(true) |
f:RegisterForDrag("LeftButton","RightButton") |
f:SetScript("OnDragStart", function(self) if IsShiftKeyDown() and IsAltKeyDown() then self:StartMoving() end end) |
f:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end) |
end |
else |
f:IsUserPlaced(false) |
end |
end |
-- calls |
rABS_MoveThisFrame(fmicro,move_micro,lock_micro) |
rABS_MoveThisFrame(fbag,move_bags,lock_bags) |
rABS_MoveThisFrame(fbar45,move_rightbars,lock_rightbars) |
rABS_MoveThisFrame(fpet,move_pet,lock_pet) |
rABS_MoveThisFrame(fshift,move_shapeshift,lock_shapeshift) |
rABS_MoveThisFrame(fbar1,move_bar1,lock_bar1) |
rABS_MoveThisFrame(fbar2,move_bar2,lock_bar2) |
rABS_MoveThisFrame(fbar3,move_bar3,lock_bar3) |
rABS_MoveThisFrame(fveb,move_veb,lock_veb) |
if hide_bags == 1 then |
fbag:SetScale(0.001) |
fbag:SetAlpha(0) |
end |
if hide_micro == 1 then |
fmicro:SetScale(0.001) |
fmicro:SetAlpha(0) |
end |
if hide_shapeshift == 1 then |
fshift:SetScale(0.001) |
fshift:SetAlpha(0) |
end |
if hide_pet == 1 then |
fpet:SetScale(0.001) |
fpet:SetAlpha(0) |
end |
for i=2, 6 do |
local b = _G["ActionButton"..i] |
local b2 = _G["ActionButton"..i-1] |
b:ClearAllPoints() |
b:SetPoint("LEFT",b2,"RIGHT",0,0) |
end |
for i=2, 6 do |
local b = _G["BonusActionButton"..i] |
local b2 = _G["BonusActionButton"..i-1] |
b:ClearAllPoints() |
b:SetPoint("LEFT",b2,"RIGHT",0,0) |
end |
for i=2, 6 do |
local b = _G["MultiBarBottomLeftButton"..i] |
local b2 = _G["MultiBarBottomLeftButton"..i-1] |
b:ClearAllPoints() |
b:SetPoint("LEFT",b2,"RIGHT",0,0) |
end |
MultiBarRightButton1:ClearAllPoints() |
MultiBarRightButton1:SetPoint("LEFT",MultiBarLeftButton1,"RIGHT",288,0) |
local securehandler = CreateFrame("Frame", nil, nil, "SecureHandlerBaseTemplate") |
for i=7,12 do |
securehandler:WrapScript(_G["MultiBarBottomLeftButton"..i], "OnShow", "self:Hide()") |
securehandler:WrapScript(_G["BonusActionButton"..i], "OnShow", "self:Hide()") |
end |
for i=2,12 do |
securehandler:WrapScript(_G["MultiBarLeftButton"..i], "OnShow", "self:Hide()") |
securehandler:WrapScript(_G["MultiBarRightButton"..i], "OnShow", "self:Hide()") |
end |
## Interface: 30200 |
## Title: rActionBarStyler |
## Author: roth |
## Notes: Styles the standard ActionBars |
rActionBarStyler.lua |
ncSpellalertDB = {} |
ncSpellalertDB.HARMFUL_SPELLS = { |
-- Priest |
["Mind Control"] = true, |
["Mind Blast"] = true, |
["Holy Fire"] = true, |
["Psychic Scream"] = true, |
["Shackle Undead"] = true, |
["Psychic Horror"] = true, |
["Mana Burn"] = true, |
["Smite"] = true, |
["Holy Fire"] = true, |
["Vampiric Touch"] = true, |
["Mind Sear"] = true, |
-- Druid |
["Entangling Roots"] = true, |
["Cyclone"] = true, |
["Wrath"] = true, |
["Starfire"] = true, |
-- Deathknight |
["Mind Freeze"] = true, |
["Army of the Dead"] = true, |
["Strangulate"] = true, |
["Hungering Cold"] = true, |
-- Hunter |
["Viper Sting"] = true, |
["Wyvern Sting"] = true, |
["Silencing Shot"] = true, |
["Scatter Shot"] = true, |
-- Mage |
["Polymorph"] = true, |
["Polymorph: Pig"] = true, |
["Polymorph: Turtle"] = true, |
["Frostbolt"] = true, |
["Fireball"] = true, |
["Arcane Blast"] = true, |
["Pyroblast"] = true, |
["Flamestrike"] = true, |
["Frostfire Bolt"] = true, |
["Slow"] = true, |
["Summon Water Elemental"] = true, |
["Scorch"] = true, |
["Mirror Image"] = true, |
-- Shaman |
["Lightning Bolt"] = true, |
["Chain Lightning"] = true, |
["Lava Burst"] = true, |
["Mana Tide Totem"] = true, |
["Feral Spirit"] = true, |
-- Warlock |
["Fear"] = true, |
["Howl of Terror"] = true, |
["Seduction"] = true, |
["Shadow Bolt"] = true, |
["Seed of Corruption"] = true, |
["Ritual of Summoning"] = true, |
["Soul Fire"] = true, |
["Haunt"] = true, |
["Searing Pain"] = true, |
["Banish"] = true, |
["Chaos Bolt"] = true, |
["Immolate"] = true, |
["Death Coil"] = true, |
["Demonic Circle: Summon"] = true, |
["Unstable Affliction"] = true, |
["Incinerate"] = true, |
["Shadowfury"] = true, |
-- Paladin |
["Exorcism"] = true, |
} |
ncSpellalertDB.HEALING_SPELLS = { |
-- Priest |
["Binding Heal"] = true, |
["Circle of Healing"] = true, |
["Lightwell"] = true, |
["Mass Dispel"] = true, |
["Flash Heal"] = true, |
["Greater Heal"] = true, |
["Heal"] = true, |
["Lesser Heal"] = true, |
["Prayer of Healing"] = true, |
["Resurrection"] = true, |
["Divine Hymn"] = true, |
["Hymn of Hope"] = true, |
["Penance"] = true, |
["Desperate Prayer"] = true, |
-- Druid |
["Healing Touch"] = true, |
["Regrowth"] = true, |
["Revive"] = true, |
["Rebirth"] = true, |
["Nourish"] = true, |
-- Paladin |
["Flash of Light"] = true, |
["Holy Light"] = true, |
["Redemption"] = true, |
["Lay on Hands"] = true, |
-- Shaman |
["Chain Heal"] = true, |
["Healing Wave"] = true, |
["Lesser Healing Wave"] = true, |
["Ancestral Spirit"] = true, |
-- Rogue |
["Blind"] = true, |
["Shadowstep"] = true, |
["Preparation"] = true, |
} |
ncSpellalertDB.BUFF_SPELLS = { |
["Nature's Grasp"] = true, |
["Summon Gargoyle"] = true, |
["Presence of Mind"] = true, |
["Icebound Fortitude"] = true, |
["Ice Block"] = true, |
["Frost Ward"] = true, |
["Fire Ward"] = true, |
["Dancing Rune Weapon"] = true, |
["Hysteria"] = true, |
["Bloodlust"] = true, |
["Arcane Power"] = true, |
["Shadow Trance"] = true, |
["Metamorphosis"] = true, |
["Bladestorm"] = true, |
["Last Stand"] = true, |
["Recklessness"] = true, |
["Retaliation"] = true, |
["Shield Wall"] = true, |
["Adrenaline Rush"] = true, |
["Avenging Wrath"] = true, |
["Blessing of Freedom"] = true, |
["Blessing of Protection"] = true, |
["Death Wish"] = true, |
["Deterrence"] = true, |
["Divine Shield"] = true, |
["Divine Protection"] = true, |
["Evasion"] = true, |
["Elemental Mastery"] = true, |
["Nature's Swiftness"] = true, |
["Heroism"] = true, |
["Pain Suppression"] = true, |
["Perception"] = true, |
["Recklessness"] = true, |
["Spell Reflection"] = true, |
["Stealth"] = true, |
["Stoneform"] = true, |
["Frenzied Regeneration"] = true, |
["The Beast Within"] = true, |
["Power Infusion"] = true, |
["Dispersion"] = true, |
["Innervate"] = true, |
["Starfall"] = true, |
["Sprint"] = true, |
["Cloak of Shadows"] = true, |
["Hand of Sacrifice"] = true, |
["Avenging Wrath"] = true, |
["Blazing Speed"] = true, |
["Fireball!"] = true, |
["Combustion"] = true, |
["Killing Spree"] = true, |
["Adrenaline Rush"] = true, |
["Blade Flurry"] = true, |
["Shadow Dance"] = true, |
} |
ncSpellalertDB.PROC_SPELLS = { |
["Shadowtrance"] = true, |
["Fingers of Frost"] = true, |
["Fireball!"] = true, |
["Backlash"] = true, |
} |
local ENEMY_PLAYER = bit.bor(COMBATLOG_OBJECT_REACTION_HOSTILE, COMBATLOG_OBJECT_TYPE_PLAYER) |
local buffFrame, spellFrame, name, unit, spell |
ncSpellalert = CreateFrame("Frame") |
local function hasFlag(flags, flag) |
return bit.band(flags, flag) == flag |
end |
local function colorize(value, color) |
return "|cff" .. color .. value .. "|r" |
end |
local onEvent = function(self, event, ...) |
self[event](self, event, ...) |
end |
function ncSpellalert:PLAYER_LOGIN() |
spellFrame = self:CreateMessageFrame("SpellAlertFrame") |
spellFrame:SetPoint("TOP", 0, -200) |
buffFrame = self:CreateMessageFrame("BuffAlertFrame") |
buffFrame:SetPoint("BOTTOM", spellFrame, "TOP", 0, 2) |
procFrame = self:CreateMessageFrame("ProcAlertFrame") |
procFrame:SetPoint("CENTER") |
procFrame:SetTimeVisible(1) |
self:RegisterEvent("ZONE_CHANGED_NEW_AREA") |
self:ZONE_CHANGED_NEW_AREA() |
end |
function ncSpellalert:CreateMessageFrame(name) |
local frame = CreateFrame("MessageFrame", name, UIParent) |
frame:SetPoint("LEFT", UIParent) |
frame:SetPoint("RIGHT", UIParent) |
frame:SetHeight(25) |
frame:SetInsertMode("TOP") |
frame:SetFrameStrata("HIGH") |
frame:SetTimeVisible(1) |
frame:SetFadeDuration(3) |
frame:SetFont(STANDARD_TEXT_FONT, 23, "OUTLINE") |
return frame |
end |
function ncSpellalert:ZONE_CHANGED_NEW_AREA() |
local pvpType = GetZonePVPInfo() |
if not pvpType or pvpType ~= "sanctuary" then |
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") |
else |
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED") |
end |
end |
function ncSpellalert:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventType, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, ...) |
local spellId, spellName = ... |
if eventType == "SPELL_AURA_APPLIED" and hasFlag(destFlags, ENEMY_PLAYER) and ncSpellalertDB.BUFF_SPELLS[spellName] then |
buffFrame:AddMessage(format(ACTION_SPELL_AURA_APPLIED_BUFF_FULL_TEXT_NO_SOURCE, nil, colorize(spellName, "00ff00"), nil, destName)) |
elseif eventType == "SPELL_AURA_APPLIED" and destName == UnitName("player") and ncSpellalertDB.PROC_SPELLS[spellName] then |
procFrame:AddMessage(">> "..colorize(spellName, "00ff00").." <<") |
elseif eventType == "SPELL_CAST_START" and hasFlag(sourceFlags, ENEMY_PLAYER) then |
local color |
if ncSpellalertDB.HARMFUL_SPELLS[spellName] then |
color = "ff0000" |
elseif ncSpellalertDB.HEALING_SPELLS[spellName] then |
color = "ffff00" |
end |
if color then |
local template |
if sourceName and destName then |
template = ACTION_SPELL_CAST_START_FULL_TEXT_NO_SOURCE |
elseif sourceName then |
template = ACTION_SPELL_CAST_START_FULL_TEXT_NO_DEST |
elseif destName then |
template = ACTION_SPELL_CAST_START_FULL_TEXT |
end |
spellFrame:AddMessage(format(template, sourceName, colorize(spellName, color), nil, destName)) |
end |
end |
end |
ncSpellalert:SetScript("OnEvent", onEvent) |
ncSpellalert:RegisterEvent("PLAYER_LOGIN") |
## Interface: 30200 |
## Title: ncSpellalert |
## Author: Nightcracker |
## Version: 1.1 |
## Notes: Addon for alerting you when enemys cast spells |
Spells.lua |
ncSpellalert.lua |
local f = CreateFrame("Frame") |
f:SetScript("OnEvent", function() |
local c = 0 |
for b=0,4 do |
for s=1,GetContainerNumSlots(b) do |
local l = GetContainerItemLink(b, s) |
if l then |
local p = select(11, GetItemInfo(l))*select(2, GetContainerItemInfo(b, s)) |
if select(3, GetItemInfo(l))==0 then |
UseContainerItem(b, s) |
PickupMerchantItem() |
c = c+p |
end |
end |
end |
end |
if c>0 then |
local g, s, c = tonumber(string.sub(c,1,-5)) or 0, tonumber(string.sub(c,-4,-3)) or 0, tonumber(string.sub(c,-2,-1)) or 0 |
print("Sold all greys and earned "..g.."|cffffd700g |cffffffff"..s.."|cffc7c7cfs|cffffffff "..c.."|cffeda55fc|cffffffff.") |
end |
hooksecurefunc("MerchantItemButton_OnModifiedClick", function(self, button) |
if (button=="RightButton") and IsShiftKeyDown() then |
OpenStackSplitFrame(100000, self, "BOTTOMLEFT", "TOPLEFT") |
end |
end) |
end) |
f:RegisterEvent("MERCHANT_SHOW") |
## Interface: 30200 |
## Title: ncImprovedMerchant |
## Author: Nightcracker |
## Notes: Some small improvements for the merchant frame. |
ncImprovedMerchant.lua |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local _VERSION = GetAddOnMetadata(parent, 'version') |
local function argcheck(value, num, ...) |
assert(type(num) == 'number', "Bad argument #2 to 'argcheck' (number expected, got "..type(num)..")") |
for i=1,select("#", ...) do |
if type(value) == select(i, ...) then return end |
end |
local types = strjoin(", ", ...) |
local name = string.match(debugstack(2,2,0), ": in function [`<](.-)['>]") |
error(("Bad argument #%d to '%s' (%s expected, got %s"):format(num, name, types, type(value)), 3) |
end |
local print = function(a) ChatFrame1:AddMessage("|cff33ff99oUF:|r "..tostring(a)) end |
local error = function(...) print("|cffff0000Error:|r "..string.format(...)) end |
local dummy = function() end |
local function SetManyAttributes(self, ...) |
for i=1,select("#", ...),2 do |
local att,val = select(i, ...) |
if not att then return end |
self:SetAttribute(att,val) |
end |
end |
-- Colors |
local colors = { |
health = {49/255, 207/255, 37/255}, -- Health |
happiness = { |
[1] = {1, 0, 0}, -- need.... | unhappy |
[2] = {1, 1, 0}, -- new..... | content |
[3] = {0, 1, 0}, -- colors.. | happy |
}, |
smooth = { |
1, 0, 0, |
1, 1, 0, |
0, 1, 0 |
}, |
disconnected = {.6, .6, .6}, |
tapped = {.6,.6,.6}, |
class = {}, |
reaction = {}, |
power = {}, |
} |
-- We do this because people edit the vars directly, and changing the default |
-- globals makes SPICE FLOW! |
if(IsAddOnLoaded'!ClassColors' and CUSTOM_CLASS_COLORS) then |
local updateColors = function() |
for eclass, color in next, CUSTOM_CLASS_COLORS do |
colors.class[eclass] = {color.r, color.g, color.b} |
end |
if(oUF) then |
for _, obj in next, oUF.objects do |
obj:PLAYER_ENTERING_WORLD() |
end |
end |
end |
updateColors() |
CUSTOM_CLASS_COLORS:RegisterCallback(updateColors) |
else |
for eclass, color in next, RAID_CLASS_COLORS do |
colors.class[eclass] = {color.r, color.g, color.b} |
end |
end |
for power, color in next, PowerBarColor do |
if(type(power) == 'string') then |
colors.power[power] = {color.r, color.g, color.b} |
end |
end |
for eclass, color in next, FACTION_BAR_COLORS do |
colors.reaction[eclass] = {color.r, color.g, color.b} |
end |
-- add-on object |
local oUF = CreateFrame"Button" |
local frame_metatable = {__index = oUF} |
local event_metatable = { |
__call = function(funcs, self, ...) |
for _, func in ipairs(funcs) do |
func(self, ...) |
end |
end, |
} |
local styles, style = {} |
local callback, units, objects = {}, {}, {} |
local _G, select, type, tostring, math_modf = |
_G, select, type, tostring, math.modf |
local UnitExists, UnitName = |
UnitExists, UnitName |
local conv = { |
['playerpet'] = 'pet', |
['playertarget'] = 'target', |
} |
local elements = {} |
local enableTargetUpdate = function(object) |
-- updating of "invalid" units. |
local OnTargetUpdate |
do |
local timer = 0 |
OnTargetUpdate = function(self, elapsed) |
if(not self.unit) then |
return |
elseif(timer >= .5) then |
self:PLAYER_ENTERING_WORLD'OnTargetUpdate' |
timer = 0 |
end |
timer = timer + elapsed |
end |
end |
object:SetScript("OnUpdate", OnTargetUpdate) |
end |
-- Events |
local OnEvent = function(self, event, ...) |
if(not self:IsShown() and not self.vehicleUnit) then return end |
return self[event](self, event, ...) |
end |
local iterateChildren = function(...) |
for l = 1, select("#", ...) do |
local obj = select(l, ...) |
if(type(obj) == 'table' and obj.isChild) then |
local unit = SecureButton_GetModifiedUnit(obj) |
local subUnit = conv[unit] or unit |
units[subUnit] = obj |
obj.unit = subUnit |
obj:PLAYER_ENTERING_WORLD() |
end |
end |
end |
local OnAttributeChanged = function(self, name, value) |
if(name == "unit" and value) then |
units[value] = self |
if(self.unit and self.unit == value) then |
return |
else |
if(self.hasChildren) then |
iterateChildren(self:GetChildren()) |
end |
self.unit = value |
self.id = value:match"^.-(%d+)" |
self:PLAYER_ENTERING_WORLD() |
end |
end |
end |
-- Gigantic function of doom |
local HandleUnit = function(unit, object) |
if(unit == "player") then |
-- Hide the blizzard stuff |
PlayerFrame:UnregisterAllEvents() |
PlayerFrame.Show = dummy |
PlayerFrame:Hide() |
PlayerFrameHealthBar:UnregisterAllEvents() |
PlayerFrameManaBar:UnregisterAllEvents() |
elseif(unit == "pet")then |
-- Hide the blizzard stuff |
PetFrame:UnregisterAllEvents() |
PetFrame.Show = dummy |
PetFrame:Hide() |
PetFrameHealthBar:UnregisterAllEvents() |
PetFrameManaBar:UnregisterAllEvents() |
elseif(unit == "target") then |
-- Hide the blizzard stuff |
TargetFrame:UnregisterAllEvents() |
TargetFrame.Show = dummy |
TargetFrame:Hide() |
TargetFrameHealthBar:UnregisterAllEvents() |
TargetFrameManaBar:UnregisterAllEvents() |
TargetFrameSpellBar:UnregisterAllEvents() |
ComboFrame:UnregisterAllEvents() |
ComboFrame.Show = dummy |
ComboFrame:Hide() |
-- Enable our shit |
object:RegisterEvent("PLAYER_TARGET_CHANGED", 'PLAYER_ENTERING_WORLD') |
elseif(unit == "focus") then |
FocusFrame:UnregisterAllEvents() |
FocusFrame.Show = dummy |
FocusFrame:Hide() |
FocusFrameHealthBar:UnregisterAllEvents() |
FocusFrameManaBar:UnregisterAllEvents() |
FocusFrameSpellBar:UnregisterAllEvents() |
object:RegisterEvent("PLAYER_FOCUS_CHANGED", 'PLAYER_ENTERING_WORLD') |
elseif(unit == "mouseover") then |
object:RegisterEvent("UPDATE_MOUSEOVER_UNIT", 'PLAYER_ENTERING_WORLD') |
elseif(unit:match"target") then |
-- Hide the blizzard stuff |
if(unit == "targettarget") then |
TargetofTargetFrame:UnregisterAllEvents() |
TargetofTargetFrame.Show = dummy |
TargetofTargetFrame:Hide() |
TargetofTargetHealthBar:UnregisterAllEvents() |
TargetofTargetManaBar:UnregisterAllEvents() |
end |
enableTargetUpdate(object) |
elseif(unit == "party") then |
for i=1,4 do |
local party = "PartyMemberFrame"..i |
local frame = _G[party] |
frame:UnregisterAllEvents() |
frame.Show = dummy |
frame:Hide() |
_G[party..'HealthBar']:UnregisterAllEvents() |
_G[party..'ManaBar']:UnregisterAllEvents() |
end |
end |
end |
local initObject = function(unit, style, ...) |
local num = select('#', ...) |
for i=1, num do |
local object = select(i, ...) |
object.__elements = {} |
object = setmetatable(object, frame_metatable) |
style(object, unit) |
local mt = type(style) == 'table' |
local height = object:GetAttribute'initial-height' or (mt and style['initial-height']) |
local width = object:GetAttribute'initial-width' or (mt and style['initial-width']) |
local scale = object:GetAttribute'initial-scale' or (mt and style['initial-scale']) |
local suffix = object:GetAttribute'unitsuffix' |
if(height) then |
object:SetAttribute('initial-height', height) |
if(unit) then object:SetHeight(height) end |
end |
if(width) then |
object:SetAttribute("initial-width", width) |
if(unit) then object:SetWidth(width) end |
end |
if(scale) then |
object:SetAttribute("initial-scale", scale) |
if(unit) then object:SetScale(scale) end |
end |
local parent = (i == 1) and object:GetParent() |
local showPlayer |
if(parent) then |
showPlayer = parent:GetAttribute'showPlayer' or parent:GetAttribute'showSolo' |
end |
if(num > 1) then |
if(i == 1) then |
object.hasChildren = true |
else |
object.isChild = true |
end |
end |
if(suffix and suffix:match'target' and (i ~= 1 and not showPlayer)) then |
enableTargetUpdate(object) |
else |
object:SetScript("OnEvent", OnEvent) |
end |
object:SetAttribute("*type1", "target") |
object:SetScript("OnAttributeChanged", OnAttributeChanged) |
object:SetScript("OnShow", object.PLAYER_ENTERING_WORLD) |
object:RegisterEvent"PLAYER_ENTERING_WORLD" |
for element in next, elements do |
object:EnableElement(element, unit) |
end |
for _, func in next, callback do |
func(object) |
end |
-- We could use ClickCastFrames only, but it will probably contain frames that |
-- we don't care about. |
table.insert(objects, object) |
_G.ClickCastFrames = ClickCastFrames or {} |
ClickCastFrames[object] = true |
end |
end |
local walkObject = function(object, unit) |
local style = styles[object:GetParent().style] or styles[style] |
initObject(unit, style, object, object:GetChildren()) |
end |
function oUF:RegisterInitCallback(func) |
table.insert(callback, func) |
end |
function oUF:RegisterStyle(name, func) |
argcheck(name, 2, 'string') |
argcheck(func, 3, 'function', 'table') |
if(styles[name]) then return error("Style [%s] already registered.", name) end |
if(not style) then style = name end |
styles[name] = func |
end |
function oUF:SetActiveStyle(name) |
argcheck(name, 2, 'string') |
if(not styles[name]) then return error("Style [%s] does not exist.", name) end |
style = name |
end |
function oUF:Spawn(unit, name, template, disableBlizz) |
argcheck(unit, 2, 'string') |
if(not style) then return error("Unable to create frame. No styles have been registered.") end |
local object |
if(unit == "header") then |
if(not template) then |
template = "SecureGroupHeaderTemplate" |
end |
HandleUnit(disableBlizz or 'party') |
local header = CreateFrame("Frame", name, UIParent, template) |
header:SetAttribute("template", "SecureUnitButtonTemplate") |
header.initialConfigFunction = walkObject |
header.style = style |
header.SetManyAttributes = SetManyAttributes |
return header |
else |
object = CreateFrame("Button", name, UIParent, "SecureUnitButtonTemplate") |
object:SetAttribute("unit", unit) |
object.unit = unit |
object.id = unit:match"^.-(%d+)" |
units[unit] = object |
walkObject(object, unit) |
HandleUnit(unit, object) |
RegisterUnitWatch(object) |
end |
return object |
end |
local RegisterEvent = oUF.RegisterEvent |
function oUF:RegisterEvent(event, func) |
argcheck(event, 2, 'string') |
if(type(func) == 'string' and type(self[func]) == 'function') then |
func = self[func] |
end |
local curev = self[event] |
if(curev and func) then |
if(type(curev) == 'function') then |
self[event] = setmetatable({curev, func}, event_metatable) |
else |
for _, infunc in ipairs(curev) do |
if(infunc == func) then return end |
end |
table.insert(curev, func) |
end |
elseif(self:IsEventRegistered(event)) then |
return |
else |
if(func) then |
self[event] = func |
elseif(not self[event]) then |
return error("Handler for event [%s] on unit [%s] does not exist.", event, self.unit or 'unknown') |
end |
RegisterEvent(self, event) |
end |
end |
local UnregisterEvent = oUF.UnregisterEvent |
function oUF:UnregisterEvent(event, func) |
argcheck(event, 2, 'string') |
local curev = self[event] |
if(type(curev) == 'table' and func) then |
for k, infunc in ipairs(curev) do |
if(infunc == func) then |
curev[k] = nil |
if(#curev == 0) then |
table.remove(curev, k) |
UnregisterEvent(self, event) |
end |
end |
end |
else |
self[event] = nil |
UnregisterEvent(self, event) |
end |
end |
function oUF:AddElement(name, update, enable, disable) |
argcheck(name, 2, 'string') |
argcheck(update, 3, 'function', 'nil') |
argcheck(enable, 4, 'function', 'nil') |
argcheck(disable, 5, 'function', 'nil') |
if(elements[name]) then return error('Element [%s] is already registered.', name) end |
elements[name] = { |
update = update; |
enable = enable; |
disable = disable; |
} |
end |
function oUF:EnableElement(name, unit) |
if(self == oUF) then return nil, 'Invalid oUF object.' end |
argcheck(name, 2, 'string') |
argcheck(unit, 3, 'string', 'nil') |
local element = elements[name] |
if(not element) then return end |
if(element.enable(self, unit or self.unit)) then |
table.insert(self.__elements, element.update) |
end |
end |
function oUF:DisableElement(name) |
if(self == oUF) then return nil, 'Invalid oUF object.' end |
argcheck(name, 2, 'string') |
local element = elements[name] |
if(not element) then return end |
for k, update in ipairs(self.__elements) do |
if(update == element.update) then |
table.remove(self.__elements, k) |
element.disable(self) |
-- We need to run a new update cycle incase we knocked ourself out of sync. |
-- The main reason we do this is to make sure the full update is completed |
-- if an element for some reason removes itself _during_ the update |
-- progress. |
self:PLAYER_ENTERING_WORLD('DisableElement', name) |
break |
end |
end |
end |
function oUF:UpdateElement(name) |
if(self == oUF) then return nil, 'Invalid oUF object.' end |
argcheck(name, 2, 'string') |
local element = elements[name] |
if(not element) then return end |
element.update(self, 'UpdateElement', self.unit) |
end |
oUF.Enable = RegisterUnitWatch |
function oUF:Disable() |
UnregisterUnitWatch(self) |
self:Hide() |
end |
--[[ |
--:PLAYER_ENTERING_WORLD() |
-- Notes: |
-- - Does a full update of all elements on the object. |
--]] |
function oUF:PLAYER_ENTERING_WORLD(event) |
local unit = self.unit |
if(not UnitExists(unit)) then return end |
for _, func in next, self.__elements do |
func(self, event, unit) |
end |
end |
-- http://www.wowwiki.com/ColorGradient |
function oUF.ColorGradient(perc, ...) |
if perc >= 1 then |
local r, g, b = select(select('#', ...) - 2, ...) |
return r, g, b |
elseif perc <= 0 then |
local r, g, b = ... |
return r, g, b |
end |
local num = select('#', ...) / 3 |
local segment, relperc = math.modf(perc*(num-1)) |
local r1, g1, b1, r2, g2, b2 = select((segment*3)+1, ...) |
return r1 + (r2-r1)*relperc, g1 + (g2-g1)*relperc, b1 + (b2-b1)*relperc |
end |
oUF.version = _VERSION |
oUF.units = units |
oUF.objects = objects |
oUF.colors = colors |
_G[global] = oUF |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local Update = function(self, event) |
local unit = self.unit |
if((UnitInParty(unit) or UnitInRaid(unit)) and UnitIsPartyLeader(unit)) then |
self.Leader:Show() |
else |
self.Leader:Hide() |
end |
end |
local Enable = function(self) |
local leader = self.Leader |
if(leader) then |
self:RegisterEvent("PARTY_LEADER_CHANGED", Update) |
self:RegisterEvent("PARTY_MEMBERS_CHANGED", Update) |
if(leader:IsObjectType"Texture" and not leader:GetTexture()) then |
leader:SetTexture[[Interface\GroupFrame\UI-Group-LeaderIcon]] |
end |
return true |
end |
end |
local Disable = function(self) |
local leader = self.Leader |
if(leader) then |
self:UnregisterEvent("PARTY_LEADER_CHANGED", Update) |
self:UnregisterEvent("PARTY_MEMBERS_CHANGED", Update) |
end |
end |
oUF:AddElement('Leader', Update, Enable, Disable) |
--[[ |
Elements handled: .Power |
Shared: |
The following settings are listed by priority: |
- colorTapping |
- colorDisconnected |
- colorHappiness |
- colorPower |
- colorClass (Colors player units based on class) |
- colorClassPet (Colors pet units based on class) |
- colorClassNPC (Colors non-player units based on class) |
- colorReaction |
- colorSmooth - will use smoothGradient instead of the internal gradient if set. |
Background: |
- multiplier - number used to manipulate the power background. (default: 1) |
This option will only enable for player and pet. |
- frequentUpdates - do OnUpdate polling of power data. |
Functions that can be overridden from within a layout: |
- :PreUpdatePower(event, unit) |
- :OverrideUpdatePower(event, unit, bar, min, max) - Setting this function |
will disable the above color settings. |
- :PostUpdatePower(event, unit, bar, min, max) |
--]] |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local UnitManaMax = UnitManaMax |
local UnitPowerType = UnitPowerType |
local min, max, bar |
local OnPowerUpdate |
do |
local UnitMana = UnitMana |
OnPowerUpdate = function(self) |
if(self.disconnected) then return end |
local power = UnitMana(self.unit) |
if(power ~= self.min) then |
self.min = power |
self:GetParent():UNIT_MAXMANA("OnPowerUpdate", self.unit) |
end |
end |
end |
local Update = function(self, event, unit) |
if(self.unit ~= unit) then return end |
if(self.PreUpdatePower) then self:PreUpdatePower(event, unit) end |
min, max = UnitMana(unit), UnitManaMax(unit) |
bar = self.Power |
bar:SetMinMaxValues(0, max) |
bar:SetValue(min) |
bar.disconnected = not UnitIsConnected(unit) |
bar.unit = unit |
if(not self.OverrideUpdatePower) then |
local r, g, b, t |
if(bar.colorTapping and UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then |
t = self.colors.tapped |
elseif(bar.colorDisconnected and not UnitIsConnected(unit)) then |
t = self.colors.disconnected |
elseif(bar.colorHappiness and unit == "pet" and GetPetHappiness()) then |
t = self.colors.happiness[GetPetHappiness()] |
elseif(bar.colorPower) then |
local _, ptype = UnitPowerType(unit) |
t = self.colors.power[ptype] |
elseif(bar.colorClass and UnitIsPlayer(unit)) or |
(bar.colorClassNPC and not UnitIsPlayer(unit)) or |
(bar.colorClassPet and UnitPlayerControlled(unit) and not UnitIsPlayer(unit)) then |
local _, class = UnitClass(unit) |
t = self.colors.class[class] |
elseif(bar.colorReaction and UnitReaction(unit, 'player')) then |
t = self.colors.reaction[UnitReaction(unit, "player")] |
elseif(bar.colorSmooth) then |
r, g, b = self.ColorGradient(min / max, unpack(bar.smoothGradient or self.colors.smooth)) |
end |
if(t) then |
r, g, b = t[1], t[2], t[3] |
end |
if(b) then |
bar:SetStatusBarColor(r, g, b) |
local bg = bar.bg |
if(bg) then |
local mu = bg.multiplier or 1 |
bg:SetVertexColor(r * mu, g * mu, b * mu) |
end |
end |
else |
self:OverrideUpdatePower(event, unit, bar, min, max) |
end |
if(self.PostUpdatePower) then self:PostUpdatePower(event, unit, bar, min, max) end |
end |
local Enable = function(self, unit) |
local power = self.Power |
if(power) then |
if(power.frequentUpdates and (unit == 'player' or unit == 'pet')) then |
power.disconnected = true |
power:SetScript("OnUpdate", OnPowerUpdate) |
else |
self:RegisterEvent("UNIT_MANA", Update) |
self:RegisterEvent("UNIT_RAGE", Update) |
self:RegisterEvent("UNIT_FOCUS", Update) |
self:RegisterEvent("UNIT_ENERGY", Update) |
self:RegisterEvent("UNIT_RUNIC_POWER", Update) |
end |
self:RegisterEvent("UNIT_MAXMANA", Update) |
self:RegisterEvent("UNIT_MAXRAGE", Update) |
self:RegisterEvent("UNIT_MAXFOCUS", Update) |
self:RegisterEvent("UNIT_MAXENERGY", Update) |
self:RegisterEvent("UNIT_DISPLAYPOWER", Update) |
self:RegisterEvent("UNIT_MAXRUNIC_POWER", Update) |
self:RegisterEvent('UNIT_HAPPINESS', Update) |
-- For tapping. |
self:RegisterEvent('UNIT_FACTION', Update) |
if(not power:GetStatusBarTexture()) then |
power:SetStatusBarTexture[[Interface\TargetingFrame\UI-StatusBar]] |
end |
return true |
end |
end |
local Disable = function(self) |
local power = self.Power |
if(power) then |
if(power:GetScript'OnUpdate') then |
power:SetScript("OnUpdate", nil) |
else |
self:UnregisterEvent("UNIT_MANA", Update) |
self:UnregisterEvent("UNIT_RAGE", Update) |
self:UnregisterEvent("UNIT_FOCUS", Update) |
self:UnregisterEvent("UNIT_ENERGY", Update) |
self:UnregisterEvent("UNIT_RUNIC_POWER", Update) |
end |
self:UnregisterEvent("UNIT_MAXMANA", Update) |
self:UnregisterEvent("UNIT_MAXRAGE", Update) |
self:UnregisterEvent("UNIT_MAXFOCUS", Update) |
self:UnregisterEvent("UNIT_MAXENERGY", Update) |
self:UnregisterEvent("UNIT_DISPLAYPOWER", Update) |
self:UnregisterEvent("UNIT_MAXRUNIC_POWER", Update) |
self:UnregisterEvent('UNIT_HAPPINESS', Update) |
self:UnregisterEvent('UNIT_FACTION', Update) |
end |
end |
oUF:AddElement('Power', Update, Enable, Disable) |
--[[ |
Elements handled: .Range |
Settings: |
- inRangeAlpha - A number for frame alpha when unit is within player range. |
Required. |
- outsideRangeAlpha - A number for frame alpha when unit is outside player |
range. Required. |
--]] |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local objects = oUF.objects |
local OnRangeFrame |
local UnitInRange, UnitIsConnected = |
UnitInRange, UnitIsConnected |
-- updating of range. |
local timer = 0 |
local OnRangeUpdate = function(self, elapsed) |
timer = timer + elapsed |
if(timer >= .25) then |
for _, object in ipairs(objects) do |
if(object:IsShown() and object.Range) then |
if(UnitIsConnected(object.unit) and not UnitInRange(object.unit)) then |
if(object:GetAlpha() == object.inRangeAlpha) then |
object:SetAlpha(object.outsideRangeAlpha) |
end |
elseif(object:GetAlpha() ~= object.inRangeAlpha) then |
object:SetAlpha(object.inRangeAlpha) |
end |
end |
end |
timer = 0 |
end |
end |
local Enable = function(self) |
if(self.Range and not OnRangeFrame) then |
OnRangeFrame = CreateFrame"Frame" |
OnRangeFrame:SetScript("OnUpdate", OnRangeUpdate) |
end |
end |
oUF:AddElement('Range', nil, Enable) |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local GetRaidTargetIndex = GetRaidTargetIndex |
local SetRaidTargetIconTexture = SetRaidTargetIconTexture |
local Update = function(self, event) |
local index = GetRaidTargetIndex(self.unit) |
local icon = self.RaidIcon |
if(index) then |
SetRaidTargetIconTexture(icon, index) |
icon:Show() |
else |
icon:Hide() |
end |
end |
local Enable = function(self) |
local ricon = self.RaidIcon |
if(ricon) then |
self:RegisterEvent("RAID_TARGET_UPDATE", Update) |
if(ricon:IsObjectType"Texture" and not ricon:GetTexture()) then |
ricon:SetTexture[[Interface\TargetingFrame\UI-RaidTargetingIcons]] |
end |
return true |
end |
end |
local Disable = function(self) |
local ricon = self.RaidIcon |
if(ricon) then |
self:UnregisterEvent("RAID_TARGET_UPDATE", Update) |
end |
end |
oUF:AddElement('RaidIcon', Update, Enable, Disable) |
--[[ Runebar: |
Author: Zariel |
Usage: expects self.Runes to be a frame, setup and positiononed by the layout itself, it also requires self.Runes through 6 to be a statusbar again setup by the user. |
Options |
Required: |
.height: (int) Height of the bar |
.width: (int) Width of each bar |
Optional: |
.spacing: (float) Spacing between each bar |
.anchor: (string) Initial anchor to the parent rune frame |
.growth: (string) LEFT or RIGHT or UP or DOWN |
.order: (table) Set custom order, full table of 1 -> 6 required |
]] |
if select(2, UnitClass("player")) ~= "DEATHKNIGHT" then return end |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local GetTime = GetTime |
local GetRuneCooldown = GetRuneCooldown |
oUF.colors.runes = { |
{ 1, 0, 0 }, |
{ 0, 0.5, 0 }, |
{ 0, 1, 1 }, |
{ 0.8, 0.1, 1 }, |
} |
local OnUpdate = function(self, elapsed) |
local time = GetTime() |
if self.finish >= time then |
self:SetValue(10 - (self.finish - time)) |
else |
self:SetScript("OnUpdate", nil) |
end |
end |
local TypeUpdate = function(self, event, i) |
local bar = self.Runes[i] |
local r, g, b = unpack(self.colors.runes[GetRuneType(i)]) |
bar:SetStatusBarColor(r, g, b) |
if(bar.bg) then |
local mu = bar.bg.multiplier or 1 |
bar.bg:SetVertexColor(r * mu, g * mu, b * mu) |
end |
end |
local Update = function(self, event, rune) |
if event == "PLAYER_ENTERING_WORLD" then |
for i = 1, 6 do |
TypeUpdate(self, event, i) |
end |
return |
end |
-- Bar could be 7, 8 for some reason |
local bar = self.Runes[rune] |
if not bar then return end |
local start, dur, ready = GetRuneCooldown(rune) |
if not ready then |
bar.finish = start + dur |
bar:SetScript("OnUpdate", OnUpdate) |
else |
bar:SetScript("OnUpdate", nil) |
end |
end |
local Enable = function(self) |
local runes = self.Runes |
if not runes or self.unit ~= "player" then return end |
RuneFrame:Hide() |
local spacing = runes.spacing or 1 |
local anchor = runes.anchor or "BOTTOMLEFT" |
local growthX, growthY = 0, 0 |
if runes.growth == "LEFT" then |
growthX = - 1 |
elseif runes.growth == "DOWN" then |
growthY = - 1 |
elseif runes.growth == "UP" then |
growthY = 1 |
else |
growthX = 1 |
end |
local width = runes.width |
local height = runes.height |
local order = runes.order |
for i = 1, 6 do |
local bar = runes[i] |
if(bar) then |
bar:SetWidth(width) |
bar:SetHeight(height) |
bar:SetMinMaxValues(0, 10) |
bar:SetPoint(anchor, runes, anchor, ((order and order[i] or i) - 1) * (width + spacing) * growthX, ((order and order[i] or i) - 1) * (height + spacing) * growthY) |
end |
end |
self:RegisterEvent("RUNE_POWER_UPDATE", Update) |
self:RegisterEvent("RUNE_TYPE_UPDATE", TypeUpdate) |
return true |
end |
local Disable = function(self) |
self.Runes:Hide() |
RuneFrame:Show() |
self:UnregisterEvent("RUNE_POWER_UPDATE", Update) |
self:UnregisterEvent("RUNE_TYPE_UPDATE", TypeUpdate) |
end |
oUF:AddElement("Runes", Update, Enable, Disable) |
--[[ |
-- Experimental oUF tags |
-- Status: Incomplete |
-- |
-- Credits: Vika, Cladhaire, Tekkub |
-- |
-- TODO: |
-- - Tag and Untag should be able to handle more than one fontstring at a time. |
]] |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local classColors = oUF.colors.class |
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 tags |
tags = { |
["[curhp]"] = UnitHealth, |
["[curpp]"] = UnitPower, |
["[maxhp]"] = UnitHealthMax, |
["[maxpp]"] = UnitPowerMax, |
["[class]"] = function(u) |
return UnitClass(u) |
end, |
["[creature]"] = function(u) |
return UnitCreatureFamily(u) or UnitCreatureType(u) |
end, |
["[dead]"] = function(u) |
return UnitIsDead(u) and "Dead" or UnitIsGhost(u) and "Ghost" |
end, |
["[difficulty]"] = function(u) |
if UnitCanAttack("player", u) then |
local l = UnitLevel(u) |
return Hex(GetQuestDifficultyColor((l > 0) and l or 99)) |
end |
end, |
["[faction]"] = function(u) |
return UnitFactionGroup(u) |
end, |
["[leader]"] = function(u) |
return UnitIsPartyLeader(u) and "(L)" |
end, |
["[leaderlong]"] = function(u) |
return UnitIsPartyLeader(u) and "(Leader)" |
end, |
["[level]"] = function(u) |
local l = UnitLevel(u) |
return (l > 0) and l or "??" |
end, |
["[missinghp]"] = function(u) |
local current = UnitHealthMax(u) - UnitHealth(u) |
if(current > 0) then |
return current |
end |
end, |
["[missingpp]"] = function(u) |
local current = UnitPowerMax(u) - UnitPower(u) |
if(current > 0) then |
return current |
end |
end, |
["[name]"] = function(u, r) |
return UnitName(r or u) |
end, |
["[offline]"] = function(u) |
return (not UnitIsConnected(u) and "Offline") |
end, |
["[perhp]"] = function(u) |
local m = UnitHealthMax(u) |
return m == 0 and 0 or math.floor(UnitHealth(u)/m*100+0.5) |
end, |
["[perpp]"] = function(u) |
local m = UnitPowerMax(u) |
return m == 0 and 0 or math.floor(UnitPower(u)/m*100+0.5) |
end, |
["[plus]"] = function(u) |
local c = UnitClassification(u) |
return (c == "elite" or c == "rareelite") and "+" |
end, |
["[pvp]"] = function(u) |
return UnitIsPVP(u) and "PvP" |
end, |
["[race]"] = function(u) |
return UnitRace(u) |
end, |
["[raidcolor]"] = function(u) |
local _, x = UnitClass(u) |
return x and Hex(classColors[x]) |
end, |
["[rare]"] = function(u) |
local c = UnitClassification(u) |
return (c == "rare" or c == "rareelite") and "Rare" |
end, |
["[resting]"] = function(u) |
return u == "player" and IsResting() and "zzz" |
end, |
["[sex]"] = function(u) |
local s = UnitSex(u) |
return s == 2 and "Male" or s == 3 and "Female" |
end, |
["[smartclass]"] = function(u) |
return UnitIsPlayer(u) and tags["[class]"](u) or tags["[creature]"](u) |
end, |
["[status]"] = function(u) |
return UnitIsDead(u) and "Dead" or UnitIsGhost(u) and "Ghost" or not UnitIsConnected(u) and "Offline" or tags["[resting]"](u) |
end, |
["[threat]"] = function(u) |
local s = UnitThreatSituation(u) |
return s == 1 and "++" or s == 2 and "--" or s == 3 and "Aggro" |
end, |
["[threatcolor]"] = function(u) |
return Hex(GetThreatStatusColor(UnitThreatSituation(u))) |
end, |
["[cpoints]"] = function(u) |
local cp = GetComboPoints(u, 'target') |
return (cp > 0) and cp |
end, |
['[smartlevel]'] = function(u) |
local c = UnitClassification(u) |
if(c == 'worldboss') then |
return 'Boss' |
else |
local plus = tags['[plus]'](u) |
local level = tags['[level]'](u) |
if(plus) then |
return level .. plus |
else |
return level |
end |
end |
end, |
["[classification]"] = function(u) |
local c = UnitClassification(u) |
return c == "rare" and "Rare" or c == "eliterare" and "Rare Elite" or c == "elite" and "Elite" or c == "worldboss" and "Boss" |
end, |
["[shortclassification]"] = function(u) |
local c = UnitClassification(u) |
return c == "rare" and "R" or c == "eliterare" and "R+" or c == "elite" and "+" or c == "worldboss" and "B" |
end, |
["[group]"] = function(unit) |
local name, server = UnitName(unit) |
if(server and server ~= "") then |
name = string.format("%s-%s", name, server) |
end |
for i=1, GetNumRaidMembers() do |
local raidName, _, group = GetRaidRosterInfo(i) |
if( raidName == name ) then |
return group |
end |
end |
end, |
["[defict:name]"] = function(u) |
return tags['[missinghp]'](u) or tags['[name]'](u) |
end, |
} |
local tagEvents = { |
["[curhp]"] = "UNIT_HEALTH", |
["[curpp]"] = "UNIT_ENERGY UNIT_FOCUS UNIT_MANA UNIT_RAGE UNIT_RUNIC_POWER", |
["[dead]"] = "UNIT_HEALTH", |
["[leader]"] = "PARTY_LEADER_CHANGED", |
["[leaderlong]"] = "PARTY_LEADER_CHANGED", |
["[level]"] = "UNIT_LEVEL PLAYER_LEVEL_UP", |
["[maxhp]"] = "UNIT_MAXHEALTH", |
["[maxpp]"] = "UNIT_MAXENERGY UNIT_MAXFOCUS UNIT_MAXMANA UNIT_MAXRAGE UNIT_MAXRUNIC_POWER", |
["[missinghp]"] = "UNIT_HEALTH UNIT_MAXHEALTH", |
["[missingpp]"] = "UNIT_MAXENERGY UNIT_MAXFOCUS UNIT_MAXMANA UNIT_MAXRAGE UNIT_ENERGY UNIT_FOCUS UNIT_MANA UNIT_RAGE UNIT_MAXRUNIC_POWER UNIT_RUNIC_POWER", |
["[name]"] = "UNIT_NAME_UPDATE", |
["[offline]"] = "UNIT_HEALTH", |
["[perhp]"] = "UNIT_HEALTH UNIT_MAXHEALTH", |
["[perpp]"] = "UNIT_MAXENERGY UNIT_MAXFOCUS UNIT_MAXMANA UNIT_MAXRAGE UNIT_ENERGY UNIT_FOCUS UNIT_MANA UNIT_RAGE UNIT_MAXRUNIC_POWER UNIT_RUNIC_POWER", |
["[pvp]"] = "UNIT_FACTION", |
["[resting]"] = "PLAYER_UPDATE_RESTING", |
["[status]"] = "UNIT_HEALTH PLAYER_UPDATE_RESTING", |
["[smartlevel]"] = "UNIT_LEVEL PLAYER_LEVEL_UP UNIT_CLASSIFICATION_CHANGED", |
["[threat]"] = "UNIT_THREAT_SITUATION_UPDATE", |
["[threatcolor]"] = "UNIT_THREAT_SITUATION_UPDATE", |
['[cpoints]'] = 'UNIT_COMBO_POINTS UNIT_TARGET', |
['[rare]'] = 'UNIT_CLASSIFICATION_CHANGED', |
['[classification]'] = 'UNIT_CLASSIFICATION_CHANGED', |
['[shortclassification]'] = 'UNIT_CLASSIFICATION_CHANGED', |
["[group]"] = "RAID_ROSTER_UPDATE", |
} |
local unitlessEvents = { |
PLAYER_LEVEL_UP = true, |
RAID_ROSTER_UPDATE = true, |
} |
local events = {} |
local frame = CreateFrame"Frame" |
frame:SetScript('OnEvent', function(self, event, unit) |
local strings = events[event] |
if(strings) then |
for k, fontstring in next, strings do |
if(not unitlessEvents[event] and fontstring.parent.unit == unit and fontstring:IsVisible()) then |
fontstring:UpdateTag() |
end |
end |
end |
end) |
local OnUpdates = {} |
local eventlessUnits = {} |
local createOnUpdate = function(timer) |
local OnUpdate = OnUpdates[timer] |
if(not OnUpdate) then |
local total = timer |
local frame = CreateFrame'Frame' |
local strings = eventlessUnits[timer] |
frame:SetScript('OnUpdate', function(self, elapsed) |
if(total >= timer) then |
for k, fs in next, strings do |
if(fs.parent:IsShown() and UnitExists(fs.parent.unit)) then |
fs:UpdateTag() |
end |
end |
total = 0 |
end |
total = total + elapsed |
end) |
OnUpdates[timer] = OnUpdate |
end |
end |
local OnShow = function(self) |
for _, fs in next, self.__tags do |
fs:UpdateTag() |
end |
end |
local RegisterEvent = function(fontstr, event) |
if(not events[event]) then events[event] = {} end |
frame:RegisterEvent(event) |
table.insert(events[event], fontstr) |
end |
local RegisterEvents = function(fontstr, tagstr) |
-- Forcefully strip away any parentheses and the characters in them. |
tagstr = tagstr:gsub('%b()', '') |
for tag in tagstr:gmatch'[%[].-[%]]' do |
local tagevents = tagEvents[tag] |
if(tagevents) then |
for event in tagevents:gmatch'%S+' do |
RegisterEvent(fontstr, event) |
end |
end |
end |
end |
local UnregisterEvents = function(fontstr) |
for event, data in pairs(events) do |
for k, tagfsstr in pairs(data) do |
if(tagfsstr == fontstr) then |
if(#data == 1) then |
frame:UnregisterEvent(event) |
end |
table.remove(data, k) |
end |
end |
end |
end |
local tagPool = {} |
local funcPool = {} |
local tmp = {} |
local Tag = function(self, fs, tagstr) |
if(not fs or not tagstr or self == oUF) then return end |
if(not self.__tags) then |
self.__tags = {} |
table.insert(self.__elements, OnShow) |
else |
-- Since people ignore everything that's good practice - unregister the tag |
-- if it already exists. |
for _, tag in pairs(self.__tags) do |
if(fs == tag) then |
-- We don't need to remove it from the __tags table as Untag handles |
-- that for us. |
self:Untag(fs) |
end |
end |
end |
fs.parent = self |
local func = tagPool[tagstr] |
if(not func) then |
-- Using .- in the match prevents use from supporting [] as prepend/append |
-- characters. Supporting these and having a single pattern here is a real |
-- headache however. |
local format = tagstr:gsub('%%', '%%%%'):gsub('[[].-[]]', '%%s') |
local args = {} |
for bracket in tagstr:gmatch'([[](.-)[]])' do |
local tfunc = funcPool[bracket] or tags[bracket] |
if(not tfunc) then |
-- ... |
local pre, tag, ap = bracket:match'[%[](%b())([%w]+)(%b())[%]]' |
if(not pre) then pre, tag = bracket:match'[%[](%b())([%w]+)[%]]' end |
if(not pre) then tag, ap = bracket:match'[%[]([%w]+)(%b())[%]]' end |
tag = (tag and '['.. tag ..']') |
tag = tags[tag] |
if(tag) then |
if(pre and ap) then |
pre = pre:sub(2,-2) |
ap = ap:sub(2,-2) |
tfunc = function(u) |
local str = tag(u) |
if(str) then |
return pre..str..ap |
end |
end |
elseif(pre) then |
pre = pre:sub(2,-2) |
tfunc = function(u) |
local str = tag(u) |
if(str) then |
return pre..str |
end |
end |
elseif(ap) then |
ap = ap:sub(2,-2) |
tfunc = function(u) |
local str = tag(u) |
if(str) then |
return str..ap |
end |
end |
end |
funcPool[bracket] = tfunc |
end |
end |
if(tfunc) then |
table.insert(args,tfunc) |
else |
return error(('Attempted to use invalid tag %s.'):format(bracket), 3) |
end |
end |
func = function(self) |
local unit = self.parent.unit |
local __unit = self.parent.__unit |
for i, func in next, args do |
tmp[i] = func(unit, __unit) or '' |
end |
self:SetFormattedText(format, unpack(tmp)) |
end |
tagPool[tagstr] = func |
end |
fs.UpdateTag = func |
local unit = self.unit |
if((unit and unit:match'%w+target') or fs.frequentUpdates) then |
local timer |
if(type(fs.frequentUpdates) == 'number') then |
timer = fs.frequentUpdates |
else |
timer = .5 |
end |
if(not eventlessUnits[timer]) then eventlessUnits[timer] = {} end |
table.insert(eventlessUnits[timer], fs) |
createOnUpdate(timer) |
else |
RegisterEvents(fs, tagstr) |
end |
table.insert(self.__tags, fs) |
end |
local Untag = function(self, fs) |
if(not fs or self == oUF) then return end |
UnregisterEvents(fs) |
for _, timers in next, eventlessUnits do |
for k, fontstr in next, timers do |
if(fs == fontstr) then |
table.remove(eventlessUnits, k) |
end |
end |
end |
for k, fontstr in next, self.__tags do |
if(fontstr == fs) then |
table.remove(self.__tags, k) |
end |
end |
fs.UpdateTag = nil |
end |
oUF.Tags = tags |
oUF.TagEvents = tagEvents |
oUF.UnitlessTagEvents = unitlessEvents |
oUF.Tag = Tag |
oUF.Untag = Untag |
--[[ |
Elements handled: .Health |
Shared: |
The following settings are listed by priority: |
- colorTapping |
- colorDisconnected |
- colorHappiness |
- colorClass (Colors player units based on class) |
- colorClassPet (Colors pet units based on class) |
- colorClassNPC (Colors non-player units based on class) |
- colorReaction |
- colorSmooth - will use smoothGradient instead of the internal gradient if set. |
- colorHealth |
Background: |
- multiplier - number used to manipulate the power background. (default: 1) |
WotLK only: |
- frequentUpdates - do OnUpdate polling of health data. |
Functions that can be overridden from within a layout: |
- :PreUpdateHealth(event, unit) |
- :OverrideUpdateHealth(event, unit, bar, min, max) - Setting this function |
will disable the above color settings. |
- :PostUpdateHealth(event, unit, bar, min, max) |
--]] |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local OnHealthUpdate |
do |
local UnitHealth = UnitHealth |
OnHealthUpdate = function(self) |
if(self.disconnected) then return end |
local health = UnitHealth(self.unit) |
if(health ~= self.min) then |
self.min = health |
self:GetParent():UNIT_MAXHEALTH("OnHealthUpdate", self.unit) |
end |
end |
end |
local Update = function(self, event, unit) |
if(self.unit ~= unit) then return end |
if(self.PreUpdateHealth) then self:PreUpdateHealth(event, unit) end |
local min, max = UnitHealth(unit), UnitHealthMax(unit) |
local bar = self.Health |
bar:SetMinMaxValues(0, max) |
bar:SetValue(min) |
bar.disconnected = not UnitIsConnected(unit) |
bar.unit = unit |
if(not self.OverrideUpdateHealth) then |
local r, g, b, t |
if(bar.colorTapping and UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then |
t = self.colors.tapped |
elseif(bar.colorDisconnected and not UnitIsConnected(unit)) then |
t = self.colors.disconnected |
elseif(bar.colorHappiness and unit == "pet" and GetPetHappiness()) then |
t = self.colors.happiness[GetPetHappiness()] |
elseif(bar.colorClass and UnitIsPlayer(unit)) or |
(bar.colorClassNPC and not UnitIsPlayer(unit)) or |
(bar.colorClassPet and UnitPlayerControlled(unit) and not UnitIsPlayer(unit)) then |
local _, class = UnitClass(unit) |
t = self.colors.class[class] |
elseif(bar.colorReaction and UnitReaction(unit, 'player')) then |
t = self.colors.reaction[UnitReaction(unit, "player")] |
elseif(bar.colorSmooth and max ~= 0) then |
r, g, b = self.ColorGradient(min / max, unpack(bar.smoothGradient or self.colors.smooth)) |
elseif(bar.colorHealth) then |
t = self.colors.health |
end |
if(t) then |
r, g, b = t[1], t[2], t[3] |
end |
if(b) then |
bar:SetStatusBarColor(r, g, b) |
local bg = bar.bg |
if(bg) then |
local mu = bg.multiplier or 1 |
bg:SetVertexColor(r * mu, g * mu, b * mu) |
end |
end |
else |
self:OverrideUpdateHealth(event, unit, bar, min, max) |
end |
if(self.PostUpdateHealth) then self:PostUpdateHealth(event, unit, bar, min, max) end |
end |
local Enable = function(self) |
local health = self.Health |
if(health) then |
if(health.frequentUpdates and (self.unit and not self.unit:match'%w+target$') or not self.unit) then |
health.disconnected = true |
health:SetScript('OnUpdate', OnHealthUpdate) |
else |
self:RegisterEvent("UNIT_HEALTH", Update) |
end |
self:RegisterEvent("UNIT_MAXHEALTH", Update) |
self:RegisterEvent('UNIT_HAPPINESS', Update) |
-- For tapping. |
self:RegisterEvent('UNIT_FACTION', Update) |
if(not health:GetStatusBarTexture()) then |
health:SetStatusBarTexture[[Interface\TargetingFrame\UI-StatusBar]] |
end |
return true |
end |
end |
local Disable = function(self) |
local health = self.Health |
if(health) then |
if(health:GetScript'OnUpdate') then |
health:SetScript('OnUpdate', nil) |
else |
self:UnregisterEvent('UNIT_HEALTH', Update) |
end |
self:UnregisterEvent('UNIT_MAXHEALTH', Update) |
self:UnregisterEvent('UNIT_HAPPINESS', Update) |
self:UnregisterEvent('UNIT_FACTION', Update) |
end |
end |
oUF:AddElement('Health', Update, Enable, Disable) |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local Update = function(self, event, unit) |
if(unit ~= self.unit) then return end |
if(self.PvP) then |
local factionGroup = UnitFactionGroup(unit) |
if(UnitIsPVPFreeForAll(unit)) then |
self.PvP:SetTexture[[Interface\TargetingFrame\UI-PVP-FFA]] |
self.PvP:Show() |
elseif(factionGroup and UnitIsPVP(unit)) then |
self.PvP:SetTexture([[Interface\TargetingFrame\UI-PVP-]]..factionGroup) |
self.PvP:Show() |
else |
self.PvP:Hide() |
end |
end |
end |
local Enable = function(self) |
if(self.PvP) then |
self:RegisterEvent("UNIT_FACTION", Update) |
return true |
end |
end |
local Disable = function(self) |
if(self.PvP) then |
self:UnregisterEvent("UNIT_FACTION", Update) |
end |
end |
oUF:AddElement('PvP', Update, Enable, Disable) |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local Update = function(self, event) |
local unit = self.unit |
if(UnitInRaid(unit) and UnitIsRaidOfficer(unit) and not UnitIsPartyLeader(unit)) then |
self.Assistant:Show() |
else |
self.Assistant:Hide() |
end |
end |
local Enable = function(self) |
local assistant = self.Assistant |
if(assistant) then |
self:RegisterEvent("PARTY_MEMBERS_CHANGED", Update) |
if(assistant:IsObjectType"Texture" and not assistant:GetTexture()) then |
assistant:SetTexture[[Interface\GroupFrame\UI-Group-AssistantIcon]] |
end |
return true |
end |
end |
local Disable = function(self) |
local assistant = self.Assistant |
if(assistant) then |
self:UnregisterEvent("PARTY_MEMBERS_CHANGED", Update) |
end |
end |
oUF:AddElement('Assistant', Update, Enable, Disable) |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local objects = oUF.objects |
local VehicleDriverFrame |
local UpdateVehicleSwitch = function(self, attr, value) |
if attr == "unit" then |
self.unit = value |
if self:GetAttribute("normalUnit") == "player" then |
PlayerFrame.unit = self.unit |
BuffFrame_Update() |
end |
end |
end |
local Enable = function(self, unit) |
if self.disallowVehicleSwap or (unit ~= "player" and unit ~= "pet") then return end |
if not VehicleDriverFrame then |
VehicleDriverFrame = CreateFrame("Frame", nil, UIParent, "SecureHandlerStateTemplate") |
RegisterStateDriver(VehicleDriverFrame, "vehicle", "[target=vehicle,exists,bonusbar:5]vehicle;novehicle") |
VehicleDriverFrame:SetAttribute("_onstate-vehicle", [[ |
if newstate == "vehicle" then |
for idx, frame in pairs(VEHICLE_FRAMES) do |
frame:SetAttribute("unit", frame:GetAttribute("vehicleUnit")) |
end |
else |
for idx, frame in pairs(VEHICLE_FRAMES) do |
frame:SetAttribute("unit", frame:GetAttribute("normalUnit")) |
end |
end |
]]) |
VehicleDriverFrame:Execute([[ |
VEHICLE_FRAMES = newtable() |
]]) |
end |
self:SetAttribute("normalUnit", unit) |
if unit == "player" then |
self:SetAttribute("vehicleUnit", "pet") |
elseif unit == "pet" then |
self:SetAttribute("vehicleUnit", "player") |
end |
VehicleDriverFrame:SetFrameRef("vehicleFrame", self) |
VehicleDriverFrame:Execute([[ |
local frame = self:GetFrameRef("vehicleFrame") |
table.insert(VEHICLE_FRAMES, frame) |
]]) |
self:HookScript("OnAttributeChanged", UpdateVehicleSwitch) |
end |
local Disable = function(self) |
self:SetAttribute("unit", self:GetAttribute("normalUnit")) |
VehicleDriverFrame:SetFrameRef("vehicleFrame", self) |
VehicleDriverFrame:Execute([[ |
local frame = self:GetFrameRef("vehicleFrame") |
for idx, value in pairs(VEHICLE_FRAMES) do |
if value == frame then |
table.remove(VEHICLE_FRAMES, idx) |
return |
end |
end |
]]) |
end |
oUF:AddElement("VehicleSwitch", nil, Enable, Disable) |
--[[ |
Original codebase: |
oUF_Castbar by starlon. |
http://svn.wowace.com/wowace/trunk/oUF_Castbar/ |
Elements handled: .Castbar |
Sub-elements: .Text, .Icon, .Time, .SafeZone, .Spark |
Notes: This element will not work on units that require a OnUpdate. |
(eventless units). |
Functions that can be overridden from within a layout: |
- :CustomDelayText(duration) |
- :CustomTimeText(duration) |
--]] |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local noop = function() end |
local UnitName = UnitName |
local GetTime = GetTime |
local UnitCastingInfo = UnitCastingInfo |
local UnitChannelInfo = UnitChannelInfo |
local UNIT_SPELLCAST_START = function(self, event, unit, spell, spellrank) |
if(self.unit ~= unit) then return end |
local castbar = self.Castbar |
local name, rank, text, texture, startTime, endTime, _, castid, interrupt = UnitCastingInfo(unit) |
if(not name) then |
castbar:Hide() |
return |
end |
endTime = endTime / 1e3 |
startTime = startTime / 1e3 |
local max = endTime - startTime |
castbar.castid = castid |
castbar.duration = GetTime() - startTime |
castbar.max = max |
castbar.delay = 0 |
castbar.casting = true |
castbar.interrupt = interrupt |
castbar:SetMinMaxValues(0, max) |
castbar:SetValue(0) |
if(castbar.Text) then castbar.Text:SetText(text) end |
if(castbar.Icon) then castbar.Icon:SetTexture(texture) end |
if(castbar.Time) then castbar.Time:SetText() end |
local sf = castbar.SafeZone |
if(sf) then |
sf:ClearAllPoints() |
sf:SetPoint'RIGHT' |
sf:SetPoint'TOP' |
sf:SetPoint'BOTTOM' |
end |
if(self.PostCastStart) then self:PostCastStart(event, unit, name, rank, text, castid, interrupt) end |
castbar:Show() |
end |
local UNIT_SPELLCAST_FAILED = function(self, event, unit, spellname, spellrank, castid) |
if(self.unit ~= unit) then return end |
local castbar = self.Castbar |
if(castbar.castid ~= castid) then |
return |
end |
castbar.casting = nil |
castbar.interrupt = nil |
castbar:SetValue(0) |
castbar:Hide() |
if(self.PostCastFailed) then self:PostCastFailed(event, unit, spellname, spellrank, castid) end |
end |
local UNIT_SPELLCAST_INTERRUPTED = function(self, event, unit, spellname, spellrank, castid) |
if(self.unit ~= unit) then return end |
local castbar = self.Castbar |
if(castbar.castid ~= castid) then |
return |
end |
castbar.casting = nil |
castbar.channeling = nil |
castbar:SetValue(0) |
castbar:Hide() |
if(self.PostCastInterrupted) then self:PostCastInterrupted(event, unit, spellname, spellrank, castid) end |
end |
local UNIT_SPELLCAST_DELAYED = function(self, event, unit, spellname, spellrank) |
if(self.unit ~= unit) then return end |
local name, rank, text, texture, startTime, endTime = UnitCastingInfo(unit) |
if(not startTime) then return end |
local castbar = self.Castbar |
local duration = GetTime() - (startTime / 1000) |
if(duration < 0) then duration = 0 end |
castbar.delay = castbar.delay + castbar.duration - duration |
castbar.duration = duration |
castbar:SetValue(duration) |
if(self.PostCastDelayed) then self:PostCastDelayed(event, unit, name, rank, text) end |
end |
local UNIT_SPELLCAST_STOP = function(self, event, unit, spellname, spellrank, castid) |
if(self.unit ~= unit) then return end |
local castbar = self.Castbar |
if(castbar.castid ~= castid) then |
return |
end |
castbar.casting = nil |
castbar.interrupt = nil |
castbar:SetValue(0) |
castbar:Hide() |
if(self.PostCastStop) then self:PostCastStop(event, unit, spellname, spellrank, castid) end |
end |
local UNIT_SPELLCAST_CHANNEL_START = function(self, event, unit, spellname, spellrank) |
if(self.unit ~= unit) then return end |
local castbar = self.Castbar |
local name, rank, text, texture, startTime, endTime, isTrade, interrupt = UnitChannelInfo(unit) |
if(not name) then |
return |
end |
endTime = endTime / 1e3 |
startTime = startTime / 1e3 |
local max = (endTime - startTime) |
local duration = endTime - GetTime() |
castbar.duration = duration |
castbar.max = max |
castbar.delay = 0 |
castbar.channeling = true |
castbar.interrupt = interrupt |
castbar:SetMinMaxValues(0, max) |
castbar:SetValue(duration) |
if(castbar.Text) then castbar.Text:SetText(name) end |
if(castbar.Icon) then castbar.Icon:SetTexture(texture) end |
if(castbar.Time) then castbar.Time:SetText() end |
local sf = castbar.SafeZone |
if(sf) then |
sf:ClearAllPoints() |
sf:SetPoint'LEFT' |
sf:SetPoint'TOP' |
sf:SetPoint'BOTTOM' |
end |
if(self.PostChannelStart) then self:PostChannelStart(event, unit, name, rank, text, interrupt) end |
castbar:Show() |
end |
local UNIT_SPELLCAST_CHANNEL_UPDATE = function(self, event, unit, spellname, spellrank) |
if(self.unit ~= unit) then return end |
local name, rank, text, texture, startTime, endTime, oldStart = UnitChannelInfo(unit) |
if(not name) then |
return |
end |
local castbar = self.Castbar |
local duration = (endTime / 1000) - GetTime() |
castbar.delay = castbar.delay + castbar.duration - duration |
castbar.duration = duration |
castbar.max = (endTime - startTime) / 1000 |
castbar:SetMinMaxValues(0, castbar.max) |
castbar:SetValue(duration) |
if(self.PostChannelUpdate) then self:PostChannelUpdate(event, unit, name, rank, text) end |
end |
local UNIT_SPELLCAST_CHANNEL_STOP = function(self, event, unit, spellname, spellrank) |
if(self.unit ~= unit) then return end |
local castbar = self.Castbar |
if(castbar:IsShown()) then |
castbar.channeling = nil |
castbar.interrupt = nil |
castbar:SetValue(castbar.max) |
castbar:Hide() |
if(self.PostChannelStop) then self:PostChannelStop(event, unit, spellname, spellrank) end |
end |
end |
local onUpdate = function(self, elapsed) |
if self.casting then |
local duration = self.duration + elapsed |
if (duration >= self.max) then |
self.casting = nil |
self:Hide() |
-- We temporary get our parent to do this. |
local parent = self:GetParent() |
if(parent.PostCastStop) then parent:PostCastStop('OnUpdate', parent.unit) end |
return |
end |
if self.SafeZone then |
local width = self:GetWidth() |
local _, _, ms = GetNetStats() |
-- MADNESS! |
local safeZonePercent = (width / self.max) * (ms / 1e5) |
if(safeZonePercent > 1) then safeZonePercent = 1 end |
self.SafeZone:SetWidth(width * safeZonePercent) |
end |
if self.Time then |
if self.delay ~= 0 then |
if(self.CustomDelayText) then |
self:CustomDelayText(duration) |
else |
self.Time:SetFormattedText("%.1f|cffff0000-%.1f|r", duration, self.delay) |
end |
else |
if(self.CustomTimeText) then |
self:CustomTimeText(duration) |
else |
self.Time:SetFormattedText("%.1f", duration) |
end |
end |
end |
self.duration = duration |
self:SetValue(duration) |
if self.Spark then |
self.Spark:SetPoint("CENTER", self, "LEFT", (duration / self.max) * self:GetWidth(), 0) |
end |
elseif self.channeling then |
local duration = self.duration - elapsed |
if(duration <= 0) then |
self.channeling = nil |
self:Hide() |
-- We temporary get our parent to do this. |
local parent = self:GetParent() |
if(parent.PostChannelStop) then parent:PostChannelStop('OnUpdate', parent.unit) end |
return |
end |
if(self.SafeZone) then |
local width = self:GetWidth() |
local _, _, ms = GetNetStats() |
-- MADNESS! |
local safeZonePercent = (width / self.max) * (ms / 1e5) |
if(safeZonePercent > 1) then safeZonePercent = 1 end |
self.SafeZone:SetWidth(width * safeZonePercent) |
end |
if self.Time then |
if self.delay ~= 0 then |
if(self.CustomDelayText) then |
self:CustomDelayText(duration) |
else |
self.Time:SetFormattedText("%.1f|cffff0000-%.1f|r", duration, self.delay) |
end |
else |
if(self.CustomTimeText) then |
self:CustomTimeText(duration) |
else |
self.Time:SetFormattedText("%.1f", duration) |
end |
end |
end |
self.duration = duration |
self:SetValue(duration) |
if self.Spark then |
self.Spark:SetPoint("CENTER", self, "LEFT", (duration / self.max) * self:GetWidth(), 0) |
end |
else |
self.unitName = nil |
self.channeling = nil |
self:SetValue(1) |
self:Hide() |
end |
end |
local Enable = function(object, unit) |
local castbar = object.Castbar |
if(castbar) then |
if(not (unit and unit:match'%wtarget$')) then |
object:RegisterEvent("UNIT_SPELLCAST_START", UNIT_SPELLCAST_START) |
object:RegisterEvent("UNIT_SPELLCAST_FAILED", UNIT_SPELLCAST_FAILED) |
object:RegisterEvent("UNIT_SPELLCAST_STOP", UNIT_SPELLCAST_STOP) |
object:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED", UNIT_SPELLCAST_INTERRUPTED) |
object:RegisterEvent("UNIT_SPELLCAST_DELAYED", UNIT_SPELLCAST_DELAYED) |
object:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START", UNIT_SPELLCAST_CHANNEL_START) |
object:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE", UNIT_SPELLCAST_CHANNEL_UPDATE) |
object:RegisterEvent("UNIT_SPELLCAST_CHANNEL_INTERRUPTED", 'UNIT_SPELLCAST_INTERRUPTED') |
object:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", UNIT_SPELLCAST_CHANNEL_STOP) |
end |
castbar:SetScript("OnUpdate", object.OnCastbarUpdate or onUpdate) |
if object.unit == "player" then |
CastingBarFrame:UnregisterAllEvents() |
CastingBarFrame.Show = noop |
CastingBarFrame:Hide() |
elseif(object.unit == 'pet') then |
PetCastingBarFrame:UnregisterAllEvents() |
PetCastingBarFrame.Show = noop |
PetCastingBarFrame:Hide() |
end |
if(not castbar:GetStatusBarTexture()) then |
castbar:SetStatusBarTexture[[Interface\TargetingFrame\UI-StatusBar]] |
end |
local spark = castbar.Spark |
if(spark and spark:IsObjectType'Texture' and not spark:GetTexture()) then |
spark:SetTexture[[Interface\CastingBar\UI-CastingBar-Spark]] |
end |
local sz = castbar.SafeZone |
if(sz and sz:IsObjectType'Texture' and not sz:GetTexture()) then |
sz:SetTexture(1, 0, 0) |
end |
castbar:Hide() |
return true |
end |
end |
local Disable = function(object, unit) |
local castbar = object.Castbar |
if(castbar) then |
object:UnregisterEvent("UNIT_SPELLCAST_START", UNIT_SPELLCAST_START) |
object:UnregisterEvent("UNIT_SPELLCAST_FAILED", UNIT_SPELLCAST_FAILED) |
object:UnregisterEvent("UNIT_SPELLCAST_STOP", UNIT_SPELLCAST_STOP) |
object:UnregisterEvent("UNIT_SPELLCAST_INTERRUPTED", UNIT_SPELLCAST_INTERRUPTED) |
object:UnregisterEvent("UNIT_SPELLCAST_DELAYED", UNIT_SPELLCAST_DELAYED) |
object:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_START", UNIT_SPELLCAST_CHANNEL_START) |
object:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE", UNIT_SPELLCAST_CHANNEL_UPDATE) |
object:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_INTERRUPTED", UNIT_SPELLCAST_CHANNEL_INTERRUPTED) |
object:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", UNIT_SPELLCAST_CHANNEL_STOP) |
castbar:SetScript("OnUpdate", nil) |
end |
end |
oUF:AddElement('Castbar', function(...) |
UNIT_SPELLCAST_START(...) |
UNIT_SPELLCAST_CHANNEL_START(...) |
end, Enable, Disable) |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local GetComboPoints = GetComboPoints |
local MAX_COMBO_POINTS = MAX_COMBO_POINTS |
local Update = function(self, event, unit) |
local cpoints = self.CPoints |
if(self.unit ~= unit and (cpoints.unit and cpoints.unit ~= unit)) then return end |
local cp = GetComboPoints(cpoints.unit or unit, 'target') |
if(#cpoints == 0) then |
cpoints:SetText((cp > 0) and cp) |
else |
for i=1, MAX_COMBO_POINTS do |
if(i <= cp) then |
cpoints[i]:Show() |
else |
cpoints[i]:Hide() |
end |
end |
end |
end |
local Enable = function(self) |
if(self.CPoints) then |
self:RegisterEvent('UNIT_COMBO_POINTS', Update) |
return true |
end |
end |
local Disable = function(self) |
if(self.CPoints) then |
self:UnregisterEvent('UNIT_COMBO_POINTS', Update) |
end |
end |
oUF:AddElement('CPoints', Update, Enable, Disable) |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local function Update(self, event) |
local unit |
local method, pid, rid = GetLootMethod() |
if(method == 'master') then |
if(pid) then |
if(pid == 0) then |
unit = 'player' |
else |
unit = 'party'..pid |
end |
elseif(rid) then |
unit = 'raid'..rid |
else |
return |
end |
if(UnitIsUnit(unit, self.unit)) then |
self.MasterLooter:Show() |
elseif(self.MasterLooter:IsShown()) then |
self.MasterLooter:Hide() |
end |
elseif(self.MasterLooter:IsShown()) then |
self.MasterLooter:Hide() |
end |
end |
local function Enable(self, unit) |
local masterlooter = self.MasterLooter |
if(masterlooter) then |
self:RegisterEvent('PARTY_LOOT_METHOD_CHANGED', Update) |
self:RegisterEvent('PARTY_MEMBERS_CHANGED', Update) |
if(masterlooter:IsObjectType('Texture') and not masterlooter:GetTexture()) then |
masterlooter:SetTexture([[Interface\GroupFrame\UI-Group-MasterLooter]]) |
end |
return true |
end |
end |
local function Disable(self) |
if(self.MasterLooter) then |
self:UnregisterEvent('PARTY_LOOT_METHOD_CHANGED', Update) |
self:UnregisterEvent('PARTY_MEMBERS_CHANGED', Update) |
end |
end |
oUF:AddElement('MasterLooter', Update, Enable, Disable) |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
do |
local Update = function(self, event) |
if(IsResting()) then |
self.Resting:Show() |
else |
self.Resting:Hide() |
end |
end |
local Enable = function(self, unit) |
if(self.Resting and unit == 'player') then |
self:RegisterEvent("PLAYER_UPDATE_RESTING", Update) |
if(self.Resting:IsObjectType"Texture" and not self.Resting:GetTexture()) then |
self.Resting:SetTexture[[Interface\CharacterFrame\UI-StateIcon]] |
self.Resting:SetTexCoord(0, .5, 0, .421875) |
end |
return true |
end |
end |
local Disable = function(self) |
if(self.Resting) then |
self:UnregisterEvent("PLAYER_UPDATE_RESTING", Update) |
end |
end |
oUF:AddElement('Resting', Update, Enable, Disable) |
end |
do |
local Update = function(self, event) |
if(UnitAffectingCombat"player") then |
self.Combat:Show() |
else |
self.Combat:Hide() |
end |
end |
local Enable = function(self, unit) |
if(self.Combat and unit == 'player') then |
self:RegisterEvent("PLAYER_REGEN_DISABLED", Update) |
self:RegisterEvent("PLAYER_REGEN_ENABLED", Update) |
if(self.Combat:IsObjectType"Texture" and not self.Combat:GetTexture()) then |
self.Combat:SetTexture[[Interface\CharacterFrame\UI-StateIcon]] |
self.Combat:SetTexCoord(.5, 1, 0, .5) |
end |
return true |
end |
end |
local Disable = function(self) |
if(self.Combat) then |
self:UnregisterEvent("PLAYER_REGEN_DISABLED", Update) |
self:UnregisterEvent("PLAYER_REGEN_ENABLED", Update) |
end |
end |
oUF:AddElement('Combat', Update, Enable, Disable) |
end |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local Update = function(self, event, unit) |
if(not UnitIsUnit(self.unit, unit)) then return end |
local portrait = self.Portrait |
if(portrait:IsObjectType'Model') then |
local name = UnitName(unit) |
if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then |
portrait:SetModelScale(4.25) |
portrait:SetPosition(0, 0, -1.5) |
portrait:SetModel"Interface\\Buttons\\talktomequestionmark.mdx" |
elseif(portrait.name ~= name or event == 'UNIT_MODEL_CHANGED') then |
portrait:SetUnit(unit) |
portrait:SetCamera(0) |
portrait.name = name |
else |
portrait:SetCamera(0) |
end |
else |
SetPortraitTexture(portrait, unit) |
end |
end |
local Enable = function(self) |
if(self.Portrait) then |
self:RegisterEvent("UNIT_PORTRAIT_UPDATE", Update) |
self:RegisterEvent("UNIT_MODEL_CHANGED", Update) |
return true |
end |
end |
local Disable = function(self) |
if(self.Portrait) then |
self:UnregisterEvent("UNIT_PORTRAIT_UPDATE", Update) |
self:UnregisterEvent("UNIT_MODEL_CHANGED", Update) |
end |
end |
oUF:AddElement('Portrait', Update, Enable, Disable) |
--[[ |
Elements handled: .Threat |
Functions that can be overridden from within a layout: |
- :PreUpdateThreat(event, unit) |
- :OverrideUpdateThreat(event, unit, status) |
- :PostUpdateThreat(event, unit, status) |
--]] |
if(select(4, GetBuildInfo()) < 3e4) then return end |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local Update = function(self, event, unit) |
if(unit ~= self.unit) then return end |
if(self.PreUpdateThreat) then self:PreUpdateThreat(event, unit) end |
unit = unit or self.unit |
local threat = self.Threat |
local status = UnitThreatSituation(unit) |
if(not self.OverrideUpdateThreat) then |
if(status and status > 0) then |
local r, g, b = GetThreatStatusColor(status) |
threat:SetVertexColor(r, g, b) |
threat:Show() |
else |
threat:Hide() |
end |
else |
self:OverrideUpdateThreat(event, unit, status) |
end |
if(self.PostUpdateThreat) then self:PostUpdateThreat(event, unit, status) end |
end |
local Enable = function(self) |
local threat = self.Threat |
if(threat) then |
self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE", Update) |
threat:Hide() |
if(threat:IsObjectType"Texture" and not threat:GetTexture()) then |
threat:SetTexture[[Interface\Minimap\ObjectIcons]] |
threat:SetTexCoord(6/8, 7/8, 1/2, 1) |
end |
return true |
end |
end |
local Disable = function(self) |
local threat = self.Threat |
if(threat) then |
self:UnregisterEvent("UNIT_THREAT_SITUATION_UPDATE", Update) |
end |
end |
oUF:AddElement('Threat', Update, Enable, Disable) |
--[[ |
Elements handled: .Auras, .Buffs, .Debuffs |
Shared: |
- spacing: Padding between aura icons. (Default: 0) |
- size: Size of the aura icons. (Default: 16) |
- initialAnchor: Initial anchor in the aura frame. (Default: "BOTTOMLEFT") |
- onlyShowPlayer: Only display icons casted by the player. (Default: nil) |
- growth-x: Growth direction, affected by initialAnchor. (Default: "UP") |
- growth-y: Growth direction, affected by initialAnchor. (Default: "RIGHT") |
- disableCooldown: Disable the Cooldown Spiral on the Aura Icons. (Default: nil) |
- filter: Expects a string with filter. See the UnitAura[1] documentation for |
more information. |
.Auras only: |
- gap: Adds a empty icon to separate buffs and debuffs. (Default: nil) |
- numBuffs: The maximum number of buffs that should be shown. (Default: 32) |
- numDebuffs: The maximum number of debuffs that should be shown. (Default: 40) |
- buffFilter: See filter on Shared. (Default: "HELPFUL") |
- debuffFilter: See filter on Shared. (Default: "HARMFUL") |
- Variables set by .Auras: |
- visibleBuffs: Number of currently visible buff icons. |
- visibleDebuffs: Number of currently visible debuff icons. |
- visibleAuras: Total number of currently visible buffs + debuffs. |
.Buffs only: |
- num: The maximum number of buffs that should be shown. (Default: 32) |
- Variables set by .Buffs: |
- visibleBuffs: Number of currently visible buff icons. |
.Debuffs only: |
- num: The maximum number of debuffs that should be shown. (Default: 40) |
- Variables set by .Debuffs: |
- visibleDebuffs: Number of currently visible debuff icons. |
Functions that can be overridden from within a layout: |
- :PostCreateAuraIcon(icon, icons, index, isDebuff) |
- :CreateAuraIcon(icons, index, isDebuff) |
- :PostUpdateAuraIcon(icons, unit, icon, index, offset, filter, isDebuff) |
- :PreUpdateAura(event, unit) |
- :PreAuraSetPosition(auras, max) |
- :SetAuraPosition(auras, max) |
- :PostUpdateAura(event, unit) |
[1] http://www.wowwiki.com/API_UnitAura |
--]] |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local OnEnter = function(self) |
if(not self:IsVisible()) then return end |
GameTooltip:SetOwner(self, "ANCHOR_BOTTOMRIGHT") |
GameTooltip:SetUnitAura(self.frame.unit, self:GetID(), self.filter) |
end |
local OnLeave = function() |
GameTooltip:Hide() |
end |
-- We don't really need to validate much here as the filter should prevent us |
-- from doing something we shouldn't. |
local OnClick = function(self) |
CancelUnitBuff(self.frame.unit, self:GetID(), self.filter) |
end |
local createAuraIcon = function(self, icons, index, debuff) |
local button = CreateFrame("Button", nil, icons) |
button:EnableMouse(true) |
button:RegisterForClicks'RightButtonUp' |
button:SetWidth(icons.size or 16) |
button:SetHeight(icons.size or 16) |
local cd = CreateFrame("Cooldown", nil, button) |
cd:SetAllPoints(button) |
local icon = button:CreateTexture(nil, "BACKGROUND") |
icon:SetAllPoints(button) |
local count = button:CreateFontString(nil, "OVERLAY") |
count:SetFontObject(NumberFontNormal) |
count:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -1, 0) |
local overlay = button:CreateTexture(nil, "OVERLAY") |
overlay:SetTexture"Interface\\Buttons\\UI-Debuff-Overlays" |
overlay:SetAllPoints(button) |
overlay:SetTexCoord(.296875, .5703125, 0, .515625) |
button.overlay = overlay |
button:SetScript("OnEnter", OnEnter) |
button:SetScript("OnLeave", OnLeave) |
if(self.unit == 'player') then |
button:SetScript('OnClick', OnClick) |
end |
table.insert(icons, button) |
button.parent = icons |
button.frame = self |
button.debuff = debuff |
button.icon = icon |
button.count = count |
button.cd = cd |
if(self.PostCreateAuraIcon) then self:PostCreateAuraIcon(button, icons, index, debuff) end |
return button |
end |
local customFilter = function(icons, unit, icon, name, rank, texture, count, dtype, duration, timeLeft, caster) |
local isPlayer |
if(caster == 'player' or caster == 'vehicle') then |
isPlayer = true |
end |
if((icons.onlyShowPlayer and isPlayer) or (not icons.onlyShowPlayer and name)) then |
icon.isPlayer = isPlayer |
icon.owner = caster |
return true |
end |
end |
local updateIcon = function(self, unit, icons, index, offset, filter, isDebuff, max) |
if(index == 0) then index = max end |
local name, rank, texture, count, dtype, duration, timeLeft, caster = UnitAura(unit, index, filter) |
if(name) then |
local icon = icons[index + offset] |
if(not icon) then |
icon = (self.CreateAuraIcon or createAuraIcon) (self, icons, index, isDebuff) |
end |
local show = (self.CustomAuraFilter or customFilter) (icons, unit, icon, name, rank, texture, count, dtype, duration, timeLeft, caster) |
if(show) then |
-- We might want to consider delaying the creation of an actual cooldown |
-- object to this point, but I think that will just make things needlessly |
-- complicated. |
local cd = icon.cd |
if(cd and not icons.disableCooldown) then |
if(duration and duration > 0) then |
cd:SetCooldown(timeLeft - duration, duration) |
cd:Show() |
else |
cd:Hide() |
end |
end |
if((isDebuff and icons.showDebuffType) or (not isDebuff and icons.showBuffType) or icons.showType) then |
local color = DebuffTypeColor[dtype] or DebuffTypeColor.none |
icon.overlay:SetVertexColor(color.r, color.g, color.b) |
icon.overlay:Show() |
else |
icon.overlay:Hide() |
end |
icon.icon:SetTexture(texture) |
icon.count:SetText((count > 1 and count)) |
icon.filter = filter |
icon.debuff = isDebuff |
icon:SetID(index) |
icon:Show() |
if(self.PostUpdateAuraIcon) then |
self:PostUpdateAuraIcon(icons, unit, icon, index, offset, filter, isDebuff) |
end |
else |
-- Hide the icon in-case we are in the middle of the stack. |
icon:Hide() |
end |
return true |
end |
end |
local SetAuraPosition = function(self, icons, x) |
if(icons and x > 0) then |
local col = 0 |
local row = 0 |
local spacing = icons.spacing or 0 |
local gap = icons.gap |
local size = (icons.size or 16) + spacing |
local anchor = icons.initialAnchor or "BOTTOMLEFT" |
local growthx = (icons["growth-x"] == "LEFT" and -1) or 1 |
local growthy = (icons["growth-y"] == "DOWN" and -1) or 1 |
local cols = math.floor(icons:GetWidth() / size + .5) |
local rows = math.floor(icons:GetHeight() / size + .5) |
for i = 1, x do |
local button = icons[i] |
if(button and button:IsShown()) then |
if(gap and button.debuff) then |
if(col > 0) then |
col = col + 1 |
end |
gap = false |
end |
if(col >= cols) then |
col = 0 |
row = row + 1 |
end |
button:ClearAllPoints() |
button:SetPoint(anchor, icons, anchor, col * size * growthx, row * size * growthy) |
col = col + 1 |
end |
end |
end |
end |
local Update = function(self, event, unit) |
if(self.unit ~= unit) then return end |
if(self.PreUpdateAura) then self:PreUpdateAura(event, unit) end |
local auras, buffs, debuffs = self.Auras, self.Buffs, self.Debuffs |
if(auras) then |
local buffs = auras.numBuffs or 32 |
local debuffs = auras.numDebuffs or 40 |
local max = debuffs + buffs |
local visibleBuffs, visibleDebuffs = 0, 0 |
for index = 1, max do |
if(index > buffs) then |
if(updateIcon(self, unit, auras, index % debuffs, visibleBuffs, auras.debuffFilter or auras.filter or 'HARMFUL', true, debuffs)) then |
visibleDebuffs = visibleDebuffs + 1 |
end |
else |
if(updateIcon(self, unit, auras, index, 0, auras.buffFilter or auras.filter or 'HELPFUL')) then |
visibleBuffs = visibleBuffs + 1 |
end |
end |
end |
local index = visibleBuffs + visibleDebuffs + 1 |
while(auras[index]) do |
auras[index]:Hide() |
index = index + 1 |
end |
auras.visibleBuffs = visibleBuffs |
auras.visibleDebuffs = visibleDebuffs |
auras.visibleAuras = visibleBuffs + visibleDebuffs |
if(self.PreAuraSetPosition) then self:PreAuraSetPosition(auras, max) end |
self:SetAuraPosition(auras, max) |
end |
if(buffs) then |
local filter = buffs.filter or 'HELPFUL' |
local max = buffs.num or 32 |
local visibleBuffs = 0 |
for index = 1, max do |
if(not updateIcon(self, unit, buffs, index, 0, filter)) then |
max = index - 1 |
while(buffs[index]) do |
buffs[index]:Hide() |
index = index + 1 |
end |
break |
end |
visibleBuffs = visibleBuffs + 1 |
end |
buffs.visibleBuffs = visibleBuffs |
if(self.PreAuraSetPosition) then self:PreAuraSetPosition(buffs, max) end |
self:SetAuraPosition(buffs, max) |
end |
if(debuffs) then |
local filter = debuffs.filter or 'HARMFUL' |
local max = debuffs.num or 40 |
local visibleDebuffs = 0 |
for index = 1, max do |
if(not updateIcon(self, unit, debuffs, index, 0, filter, true)) then |
max = index - 1 |
while(debuffs[index]) do |
debuffs[index]:Hide() |
index = index + 1 |
end |
break |
end |
visibleDebuffs = visibleDebuffs + 1 |
end |
debuffs.visibleDebuffs = visibleDebuffs |
if(self.PreAuraSetPosition) then self:PreAuraSetPosition(debuffs, max) end |
self:SetAuraPosition(debuffs, max) |
end |
if(self.PostUpdateAura) then self:PostUpdateAura(event, unit) end |
end |
local Enable = function(self) |
if(self.Buffs or self.Debuffs or self.Auras) then |
if(not self.SetAuraPosition) then |
self.SetAuraPosition = SetAuraPosition |
end |
self:RegisterEvent("UNIT_AURA", Update) |
return true |
end |
end |
local Disable = function(self) |
if(self.Buffs or self.Debuffs or self.Auras) then |
self:UnregisterEvent("UNIT_AURA", Update) |
end |
end |
oUF:AddElement('Aura', Update, Enable, Disable) |
local parent = debugstack():match[[\AddOns\(.-)\]] |
local global = GetAddOnMetadata(parent, 'X-oUF') |
assert(global, 'X-oUF needs to be defined in the parent add-on.') |
local oUF = _G[global] |
local Update = function(self, event, unit) |
if(self.unit ~= unit) then return end |
if(self.Happiness) then |
local happiness = GetPetHappiness() |
local hunterPet = select(2, HasPetUI()) |
if(not (happiness or hunterPet)) then |
return self.Happiness:Hide() |
end |
self.Happiness:Show() |
if(happiness == 1) then |
self.Happiness:SetTexCoord(0.375, 0.5625, 0, 0.359375) |
elseif(happiness == 2) then |
self.Happiness:SetTexCoord(0.1875, 0.375, 0, 0.359375) |
elseif(happiness == 3) then |
self.Happiness:SetTexCoord(0, 0.1875, 0, 0.359375) |
end |
if(self.PostUpdateHappiness) then self:PostUpdateHappiness(event, unit, happiness) end |
end |
end |
local Enable = function(self) |
local happiness = self.Happiness |
if(happiness) then |
self:RegisterEvent("UNIT_HAPPINESS", Update) |
if(happiness:IsObjectType"Texture" and not happiness:GetTexture()) then |
happiness:SetTexture[[Interface\PetPaperDollFrame\UI-PetHappiness]] |
end |
return true |
end |
end |
local Disable = function(self) |
local happiness = self.Happiness |
if(happiness) then |
self:UnregisterEvent("UNIT_HAPPINESS", Update) |
end |
end |
oUF:AddElement('Happiness', Update, Enable, Disable) |
## Interface: 30200 |
## Title: oUF |
## Author: Haste |
## Version: 1.3.21 |
## OptionalDeps: !ClassColors |
## X-eMail: troeks@gmail.com |
## X-oUF: oUF |
## Notes: Unit frame framework. Does nothing by itself. |
oUF.xml |
<Ui xmlns="http://www.blizzard.com/wow/ui/"> |
<Script file='ouf.lua' /> |
<Script file='elements\power.lua' /> |
<Script file='elements\aura.lua' /> |
<Script file='elements\health.lua' /> |
<Script file='elements\cpoints.lua' /> |
<Script file='elements\ricons.lua' /> |
<Script file='elements\leader.lua' /> |
<Script file='elements\status.lua' /> |
<Script file='elements\pvp.lua' /> |
<Script file='elements\portraits.lua' /> |
<Script file='elements\range.lua' /> |
<Script file='elements\happiness.lua' /> |
<Script file='elements\castbar.lua' /> |
<Script file='elements\threat.lua' /> |
<Script file='elements\tags.lua' /> |
<Script file='elements\vehicle.lua' /> |
<Script file='elements\masterlooter.lua' /> |
<Script file='elements\assistant.lua' /> |
<Script file='elements\runebar.lua' /> |
<!-- |
This template requires the layout to set the anchoring positions from the |
sub-frame(s). These are feed to the layouts style functions as any other unit |
spawned by a header. The main difference is that they have the unitsuffix |
attribute set (and they are parented to their respective owener). |
--> |
<Button name="oUF_HeaderTargetTemplate" inherits="SecureUnitButtonTemplate" hidden="true" virtual="true"> |
<Frames> |
<Button name="$parentTarget" inherits="SecureUnitButtonTemplate"> |
<Attributes> |
<Attribute name="unitsuffix" type="string" value="target"/> |
<Attribute name="useparent-unit" type="boolean" value="true"/> |
<Attribute name="type1" type="string" value="target"/> |
<Attribute name="initial-unitWatch" type="boolean" value="true"/> |
</Attributes> |
</Button> |
</Frames> |
</Button> |
</Ui> |