/
------------------------------------------------------------------------------------- |
--Config |
------------------------------------------------------------------------------------- |
local scale = 1.0 |
local relpoint = "BOTTOMRIGHT" |
local point = "BOTTOMRIGHT" |
local xpoint = -10 |
local ypoint = 215 |
local cursor = false |
local playerTitles = false |
local addonName = ... |
local texture = "Interface\\AddOns\\"..addonName.."\\textures\\tex_striped" --Health Bar |
local colorStatusBar = true |
local backdrop = { |
bgFile = "Interface\\Buttons\\WHITE8x8", |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
tile = true, |
tileSize = 16, |
edgeSize = 16, |
insets = {left = 3, right = 3, top = 3, bottom = 3}, |
} |
local bdcR, bdcG, bdcB = .05, .05, .05 --Background color |
local bdbcR, bdbcG, bdbcB = .3, .3, .3 --Border color |
local gColorR, gColorG, gColorB = 255/255, 20/255, 200/255 --Guild Color |
local TARGET = "|cfffed100"..TARGET..":|r " |
local TARGETYOU = "<You>" |
local worldBoss = "??" |
local rareElite = "Rare+" |
local rare = "Rare" |
------------------------------------------------------------------------------------- |
--End Config |
------------------------------------------------------------------------------------- |
local function GetHexColor(color) |
return ("|cff%.2x%.2x%.2x"):format(color.r * 255, color.g * 255, color.b * 255) |
end |
local ClassColors = {} |
for class, color in pairs(RAID_CLASS_COLORS) do |
ClassColors[class] = GetHexColor(RAID_CLASS_COLORS[class]) |
end |
local Reaction = {} |
for i = 1, #FACTION_BAR_COLORS do |
Reaction[i] = GetHexColor(FACTION_BAR_COLORS[i]) |
end |
local function getTargetLine(unit) |
if UnitIsUnit(unit, "player") then |
return ("|cffff0000%s|r"):format(TARGETYOU) |
elseif UnitIsPlayer(unit, "player")then |
return ClassColors[select(2, UnitClass(unit, "player"))]..UnitName(unit).."|r" |
elseif UnitReaction(unit, "player") then |
return ("%s%s|r"):format(Reaction[UnitReaction(unit, "player")], UnitName(unit)) |
else |
return ("|cffffffff%s|r"):format(UnitName(unit)) |
end |
end |
function GameTooltip_UnitColor(unit) |
local r, g, b |
local reaction = UnitReaction(unit, "player") |
if reaction then |
r = FACTION_BAR_COLORS[reaction].r |
g = FACTION_BAR_COLORS[reaction].g |
b = FACTION_BAR_COLORS[reaction].b |
else |
r = 1.0 |
g = 1.0 |
b = 1.0 |
end |
if UnitPlayerControlled(unit) then |
if UnitCanAttack(unit, "player") then |
if not UnitCanAttack("player", unit) then |
r = 1.0 |
g = 1.0 |
b = 1.0 |
else |
r = FACTION_BAR_COLORS[2].r |
g = FACTION_BAR_COLORS[2].g |
b = FACTION_BAR_COLORS[2].b |
end |
elseif UnitCanAttack("player", unit) then |
r = FACTION_BAR_COLORS[4].r |
g = FACTION_BAR_COLORS[4].g |
b = FACTION_BAR_COLORS[4].b |
elseif UnitIsPVP(unit) then |
r = FACTION_BAR_COLORS[6].r |
g = FACTION_BAR_COLORS[6].g |
b = FACTION_BAR_COLORS[6].b |
end |
end |
if UnitIsPlayer(unit) then |
local class = select(2, UnitClass(unit)) |
if class then |
r = RAID_CLASS_COLORS[class].r |
g = RAID_CLASS_COLORS[class].g |
b = RAID_CLASS_COLORS[class].b |
end |
end |
return r, g, b |
end |
GameTooltip:HookScript("OnTooltipSetUnit", function(self) |
local unit = select(2, self:GetUnit()) |
if unit then |
local level = UnitLevel(unit) |
local color = GetQuestDifficultyColor(level) |
local textLevel = ("%s%d|r"):format(GetHexColor(color), level) |
local unitPvP = "" |
local pattern = "%s" |
if level == "??" or level == -1 then |
textLevel = "|cffff0000??|r" |
end |
if UnitIsPlayer(unit) then |
local unitRace = UnitRace(unit) |
local unitClass = UnitClass(unit) |
if UnitIsAFK(unit) then |
self:AppendText((" |cff00cc00%s|r"):format(CHAT_FLAG_AFK)) |
elseif UnitIsDND(unit) then |
self:AppendText((" |cff00cc00%s|r"):format(CHAT_FLAG_DND)) |
end |
for i = 2, GameTooltip:NumLines() do |
if _G["GameTooltipTextLeft"..i]:GetText():find(LEVEL) then |
pattern = pattern.." %s %s %s" |
_G["GameTooltipTextLeft"..i]:SetText((pattern):format(unitPvP, textLevel, unitRace, unitClass):trim()) |
break |
end |
end |
local unitGuild = GetGuildInfo(unit) |
local text = GameTooltipTextLeft2:GetText() |
if unitGuild and text and text:find("^"..unitGuild) then |
GameTooltipTextLeft2:SetTextColor(gColorR, gColorG, gColorB) |
end |
else |
local text = GameTooltipTextLeft2:GetText() |
local reaction = UnitReaction(unit, "player") |
if reaction and text and not text:find(LEVEL) then |
GameTooltipTextLeft2:SetTextColor(FACTION_BAR_COLORS[reaction].r, FACTION_BAR_COLORS[reaction].g, FACTION_BAR_COLORS[reaction].b) |
end |
if level ~= 0 then |
local class = UnitClassification(unit) |
if class == "worldboss" then |
textLevel = ("|cffff0000%s|r"):format(worldBoss) |
elseif class == "rareelite" then |
if level == -1 then |
textLevel = ("|cffff0000??+|r %s"):format(rareElite) |
else |
textLevel = ("%s%d+|r %s"):format(GetHexColor(color), level, rareElite) |
end |
elseif class == "elite" then |
if level == -1 then |
textLevel = "|cffff0000??+|r" |
else |
textLevel = ("%s%d+|r"):format(GetHexColor(color), level) |
end |
elseif class == "rare" then |
if level == -1 then |
textLevel = ("|cffff0000??|r %s"):format(rare) |
else |
textLevel = ("%s%d|r %s"):format(GetHexColor(color), level, rare) |
end |
end |
local creatureType = UnitCreatureType(unit) |
for i = 2, GameTooltip:NumLines() do |
if _G["GameTooltipTextLeft"..i]:GetText():find(LEVEL) then |
pattern = pattern.." %s %s" |
_G["GameTooltipTextLeft"..i]:SetText((pattern):format(unitPvP, textLevel, creatureType or ""):trim()) |
break |
end |
end |
end |
end |
if UnitIsPVP(unit) then |
for i = 2, GameTooltip:NumLines() do |
if _G["GameTooltipTextLeft"..i]:GetText():find(PVP) then |
_G["GameTooltipTextLeft"..i]:SetText(nil) |
break |
end |
end |
end |
if (UnitExists(unit .. "target")) then |
local text = ("%s%s"):format(TARGET, getTargetLine(unit.."target")) |
GameTooltip:AddLine(text) |
end |
if colorStatusBar then |
local r, g, b = GameTooltip_UnitColor(unit) |
GameTooltipStatusBar:SetStatusBarColor(r, g, b) |
end |
if (UnitIsDead(unit) or UnitIsGhost(unit)) then |
GameTooltipStatusBar:Hide() |
else |
self:AddLine(" ") |
GameTooltipStatusBar:Show() |
GameTooltipStatusBar:ClearAllPoints() |
GameTooltipStatusBar:SetPoint("LEFT", self:GetName().."TextLeft"..self:NumLines(), "LEFT", 0, -1) |
GameTooltipStatusBar:SetPoint("RIGHT", self, "RIGHT", -10, -1) |
end |
end |
end) |
GameTooltipStatusBar:SetStatusBarTexture(texture) |
GameTooltipStatusBar:SetHeight(7) |
local bg = GameTooltipStatusBar:CreateTexture(nil, "BACKGROUND") |
bg:SetAllPoints(GameTooltipStatusBar) |
bg:SetTexture(texture) |
bg:SetVertexColor(0.5, 0.5, 0.5, 0.5) |
local function ShortValue(value) |
if value >= 1e7 then |
return ('%.1fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1') |
elseif value >= 1e6 then |
return ('%.2fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1') |
elseif value >= 1e5 then |
return ('%.0fk'):format(value / 1e3) |
elseif value >= 1e3 then |
return ('%.1fk'):format(value / 1e3):gsub('%.?0+([km])$', '%1') |
else |
return value |
end |
end |
GameTooltipStatusBar:SetScript("OnValueChanged", function(self, value) |
if not value then |
return |
end |
local min, max = self:GetMinMaxValues() |
if (value < min) or (value > max) then |
return |
end |
local unit = select(2, GameTooltip:GetUnit()) |
if unit then |
min, max = UnitHealth(unit), UnitHealthMax(unit) |
if not self.text then |
self.text = self:CreateFontString(nil, "OVERLAY") |
self.text:SetPoint("CENTER", GameTooltipStatusBar) |
self.text:SetFont("Fonts\\FRIZQT__.TTF", 11, "THINOUTLINE") |
end |
self.text:Show() |
local hp = ShortValue(min).." / "..ShortValue(max) |
self.text:SetText(hp) |
end |
end) |
local Tooltips = {GameTooltip, ItemRefTooltip, ShoppingTooltip1, ShoppingTooltip2, ShoppingTooltip3} |
for i, v in ipairs(Tooltips) do |
v:SetBackdrop(backdrop) |
v:SetScale(scale) |
v:SetScript("OnShow", function(self) |
self:SetBackdropColor(bdcR, bdcG, bdcB) |
local name, item = self:GetItem() |
if(item) then |
local quality = select(3, GetItemInfo(item)) |
if(quality) then |
local r, g, b = GetItemQualityColor(quality) |
self:SetBackdropBorderColor(r, g, b) |
end |
else |
self:SetBackdropBorderColor(bdbcR, bdbcG, bdbcB) |
end |
end) |
end |
hooksecurefunc("GameTooltip_SetDefaultAnchor", function(tooltip, parent) |
local frame = GetMouseFocus() |
if cursor and frame == WorldFrame then |
tooltip:SetOwner(parent, "ANCHOR_CURSOR") |
else |
tooltip:SetOwner(parent, "ANCHOR_NONE") |
tooltip:SetPoint(point, UIParent, relpoint, xpoint, ypoint) |
end |
tooltip.default = 1 |
end) |
if playerTitles then return end |
GameTooltip:HookScript("OnTooltipSetUnit", function(self) |
local unitName, unit = self:GetUnit() |
if unit and UnitIsPlayer(unit) then |
local title = UnitPVPName(unit) |
if title then |
title = title:gsub(unitName, "") |
name = GameTooltipTextLeft1:GetText() |
name = name:gsub(title, "") |
if name then GameTooltipTextLeft1:SetText(name) end |
end |
end |
end) |
local settings = oUF_Settings |
local font = settings.font |
local format = string.format |
local floor = math.floor |
local OmniCC_Settings = { |
FontSize = 13, -- Font size for frames of NormalizedSize, will be scaled for other sizes |
NormalizedSize = 31, -- At this frame width font will have 100% size |
ChangeColorTime = 5, -- Time in seconds when text color will be changed |
longR = 0.8, -- Color for cooldowns longer than ChangeColorTime. More info: http://www.wowwiki.com/API_FontString_SetTextColor |
longG = 0.8, |
longB = 0.8, |
shortR = 1, -- Color for cooldowns shorter than ChangeColorTime. |
shortG = 0.2, |
shortB = 0.2, |
Point = {"BOTTOM", 0, -2}, -- Where to place cooldown text. More info: http://www.wowwiki.com/API_Region_SetPoint |
} |
local function GetFormattedTime(s) |
if s >= 3600 then |
return format('%dh', floor(s/3600 + 0.5)), s % 3600 |
elseif s >= 60 then |
return format('%dm', floor(s/60 + 0.5)), s % 60 |
end |
return floor(s + 0.5), s - floor(s) |
end |
local function Timer_OnUpdate(self, elapsed) |
if self.text:IsShown() then |
if self.nextUpdate > 0 then |
self.nextUpdate = self.nextUpdate - elapsed |
else |
local remain = self.duration - (GetTime() - self.start) |
if floor(remain + 0.5) > 0 then |
local time, nextUpdate = GetFormattedTime(remain) |
self.text:SetText(time) |
self.nextUpdate = nextUpdate |
if(floor(remain + 0.5) > OmniCC_Settings.ChangeColorTime) then |
self.text:SetTextColor(OmniCC_Settings.longR, OmniCC_Settings.longG, OmniCC_Settings.longB) |
else |
self.text:SetTextColor(OmniCC_Settings.shortR, OmniCC_Settings.shortG, OmniCC_Settings.shortB) |
end |
else |
self.text:Hide() |
end |
end |
end |
end |
local function Timer_Create(self) |
if self:GetParent() then |
local realsize = self:GetParent():GetWidth() * OmniCC_Settings.FontSize / OmniCC_Settings.NormalizedSize |
if(realsize>8) then |
local text = self:CreateFontString(nil, "OVERLAY") |
text:SetPoint(unpack(OmniCC_Settings.Point)) |
text:SetJustifyH("CENTER") |
text:SetFont(font, realsize, "THINOUTLINE") |
self.text = text |
self:SetScript("OnUpdate", Timer_OnUpdate) |
return text |
end |
end |
end |
local function Timer_Start(self, start, duration) |
self.start = start |
self.duration = duration |
self.nextUpdate = 0 |
local text = self.text or Timer_Create(self) |
if text then |
text:Show() |
end |
end |
local methods = getmetatable(ActionButton1Cooldown).__index |
hooksecurefunc(methods, "SetCooldown", function(self, start, duration) |
if(start>0 and duration>3) then |
Timer_Start(self, start, duration) |
else |
local text = self.text |
if text then |
text:Hide() |
end |
end |
end) |
<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' /> |
<Script file='elements\lfdrole.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> |
local parent, ns = ... |
local global = GetAddOnMetadata(parent, 'X-oUF') |
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(...) print("|cff33ff99oUF:|r", ...) 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 = { |
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 = {}, |
} |
-- 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 |
local oUF = ns.oUF or _G[parent] |
if(oUF) then |
for _, obj in next, oUF.objects do |
obj:PLAYER_ENTERING_WORLD"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 eclass, color in next, FACTION_BAR_COLORS do |
colors.reaction[eclass] = {color.r, color.g, color.b} |
end |
-- add-on object |
local oUF = {} |
local event_metatable = { |
__call = function(funcs, self, ...) |
for _, func in next, funcs do |
func(self, ...) |
end |
end, |
} |
local styles, style = {} |
local callback, units, objects = {}, {}, {} |
local select = select |
local UnitExists = UnitExists |
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()) 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"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 = SecureButton_GetModifiedUnit(self) |
self.id = value:match"^.-(%d+)" |
self:PLAYER_ENTERING_WORLD"PLAYER_ENTERING_WORLD" |
end |
end |
end |
-- Gigantic function of doom |
-- XXX: Clean it up for 1.4. |
local HandleUnit = function(unit, object) |
if(unit == "player") then |
-- Hide the blizzard stuff |
PlayerFrame:UnregisterAllEvents() |
PlayerFrame.Show = dummy |
PlayerFrame:Hide() |
-- For the damn vehicle support: |
PlayerFrame:RegisterEvent('UNIT_ENTERING_VEHICLE') |
PlayerFrame:RegisterEvent('UNIT_ENTERED_VEHICLE') |
PlayerFrame:RegisterEvent('UNIT_EXITING_VEHICLE') |
PlayerFrame:RegisterEvent('UNIT_EXITED_VEHICLE') |
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'boss%d') then |
for i=1,MAX_BOSS_FRAMES do |
local name = "Boss" .. i .."TargetFrame" |
local frame = _G[name] |
frame:UnregisterAllEvents() |
frame.Show = dummy |
frame:Hide() |
_G[name..'HealthBar']:UnregisterAllEvents() |
_G[name..'ManaBar']:UnregisterAllEvents() |
end |
enableTargetUpdate(object) |
elseif(unit:match"target") then |
-- Hide the blizzard stuff |
if(unit == "targettarget") then |
if TargetFrameToT then -- 3.3 |
TargetFrameToT:UnregisterAllEvents() |
TargetFrameToT.Show = dummy |
TargetFrameToT:Hide() |
TargetFrameToTHealthBar:UnregisterAllEvents() |
TargetFrameToTManaBar:UnregisterAllEvents() |
else -- 3.2 |
TargetofTargetFrame:UnregisterAllEvents() |
TargetofTargetFrame.Show = dummy |
TargetofTargetFrame:Hide() |
TargetofTargetHealthBar:UnregisterAllEvents() |
TargetofTargetManaBar:UnregisterAllEvents() |
end |
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 frame_metatable = { |
__index = CreateFrame"Button" |
} |
for k, v in pairs{ |
colors = colors; |
EnableElement = function(self, name, unit) |
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, |
DisableElement = function(self, name) |
argcheck(name, 2, 'string') |
local element = elements[name] |
if(not element) then return end |
for k, update in next, self.__elements do |
if(update == element.update) then |
table.remove(self.__elements, k) |
-- 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 |
return element.disable(self) |
end, |
UpdateElement = function(self, name) |
argcheck(name, 2, 'string') |
local element = elements[name] |
if(not element) then return end |
element.update(self, 'UpdateElement', self.unit) |
end, |
Enable = RegisterUnitWatch, |
Disable = function(self) |
UnregisterUnitWatch(self) |
self:Hide() |
end, |
--[[ |
--:PLAYER_ENTERING_WORLD() |
-- Notes: |
-- - Does a full update of all elements on the object. |
--]] |
PLAYER_ENTERING_WORLD = function(self, 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, |
} do |
frame_metatable.__index[k] = v |
end |
do |
local RegisterEvent = frame_metatable.__index.RegisterEvent |
function frame_metatable.__index: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 next, 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 |
end |
do |
local UnregisterEvent = frame_metatable.__index.UnregisterEvent |
function frame_metatable.__index:UnregisterEvent(event, func) |
argcheck(event, 2, 'string') |
local curev = self[event] |
if(type(curev) == 'table' and func) then |
for k, infunc in next, curev do |
if(infunc == func) then |
curev[k] = nil |
if(#curev == 0) then |
table.remove(curev, k) |
UnregisterEvent(self, event) |
end |
break |
end |
end |
else |
self[event] = nil |
UnregisterEvent(self, event) |
end |
end |
end |
do |
local inf = math.huge |
-- http://www.wowwiki.com/ColorGradient |
function frame_metatable.__index.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 |
-- Translate divison by zeros into 0, so we don't blow select. |
-- We check perc against itself because we rely on the fact that NaN can't equal NaN. |
if(perc ~= perc or perc == inf) then perc = 0 end |
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 |
end |
local initObject = function(unit, style, styleFunc, ...) |
local num = select('#', ...) |
for i=1, num do |
local object = select(i, ...) |
object.__elements = {} |
object = setmetatable(object, frame_metatable) |
styleFunc(object, unit) |
local mt = type(styleFunc) == 'table' |
local height = object:GetAttribute'initial-height' or (mt and styleFunc['initial-height']) |
local width = object:GetAttribute'initial-width' or (mt and styleFunc['initial-width']) |
local scale = object:GetAttribute'initial-scale' or (mt and styleFunc['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 |
object.style = style |
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 = object:GetParent().style or style |
local styleFunc = styles[style] or styles[style] |
initObject(unit, style, styleFunc, 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 |
unit = unit:lower() |
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 |
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 |
oUF.version = _VERSION |
oUF.units = units |
oUF.objects = objects |
oUF.colors = colors |
-- Temporary stuff, hopefully |
oUF.frame_metatable = frame_metatable |
oUF.ColorGradient = frame_metatable.__index.ColorGradient |
if(global) then |
if(parent ~= 'oUF' and global == 'oUF' and IsAddOnLoaded'oUF') then |
error("%s attempted to override oUF's default global with its internal oUF.", parent) |
else |
_G[global] = oUF |
end |
end |
ns.oUF = oUF |
local parent, ns = ... |
local oUF = ns.oUF |
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, ns = ... |
local oUF = ns.oUF |
local Update = function(self, event, unit) |
if(not UnitIsUnit(self.unit, unit)) then return end |
if(self.PreUpdatePortrait) then self:PreUpdatePortrait(event, unit) 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 |
local alpha = portrait:GetAlpha() |
portrait:SetUnit(unit) |
portrait:SetCamera(0) |
portrait:SetAlpha(alpha) |
portrait.name = name |
else |
portrait:SetCamera(0) |
end |
else |
SetPortraitTexture(portrait, unit) |
end |
if(self.PostUpdatePortrait) then |
return self:PostUpdatePortrait(event, 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) |
local parent, ns = ... |
local oUF = ns.oUF |
local Update = function(self, event) |
local lfdrole = self.LFDRole |
local isTank, isHealer, isDamage = UnitGroupRolesAssigned(self.unit) |
if isTank then |
lfdrole:SetTexCoord(0, 19/64, 22/64, 41/64) |
lfdrole:Show() |
elseif isHealer then |
lfdrole:SetTexCoord(20/64, 39/64, 1/64, 20/64) |
lfdrole:Show() |
elseif isDamage then |
lfdrole:SetTexCoord(20/64, 39/64, 22/64, 41/64) |
lfdrole:Show() |
else |
lfdrole:Hide() |
end |
end |
local Enable = function(self) |
local lfdrole = self.LFDRole |
if(lfdrole) then |
if self.unit == "player" then |
self:RegisterEvent("PLAYER_ROLES_ASSIGNED", Update) |
else |
self:RegisterEvent("PARTY_MEMBERS_CHANGED", Update) |
end |
if(lfdrole:IsObjectType"Texture" and not lfdrole:GetTexture()) then |
lfdrole:SetTexture[[Interface\LFGFrame\UI-LFG-ICON-PORTRAITROLES]] |
end |
return true |
end |
end |
local Disable = function(self) |
local lfdrole = self.LFDRole |
if(lfdrole) then |
self:UnregisterEvent("PLAYER_ROLES_ASSIGNED", Update) |
self:UnregisterEvent("PARTY_MEMBERS_CHANGED", Update) |
end |
end |
oUF:AddElement('LFDRole', 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) |
--]] |
local parent, ns = ... |
local oUF = ns.oUF |
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 |
return 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, ns = ... |
local oUF = ns.oUF |
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, isStealable, shouldConsolidate, spellID = 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, isStealable, shouldConsolidate, spellID) |
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, #icons 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 |
elseif(not button) then |
break |
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 |
return 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, ns = ... |
local oUF = ns.oUF |
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 |
return 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) |
local parent, ns = ... |
local oUF = ns.oUF |
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, ns = ... |
local oUF = ns.oUF |
oUF.colors.power = {} |
for power, color in next, PowerBarColor do |
if(type(power) == 'string') then |
oUF.colors.power[power] = {color.r, color.g, color.b} |
end |
end |
local Update = function(self, event, unit) |
if(self.unit ~= unit) then return end |
if(self.PreUpdatePower) then self:PreUpdatePower(event, unit) end |
local min, max = UnitPower(unit), UnitPowerMax(unit) |
local disconnected = not UnitIsConnected(unit) |
local bar = self.Power |
bar:SetMinMaxValues(0, max) |
if(disconnected) then |
bar:SetValue(max) |
else |
bar:SetValue(min) |
end |
bar.disconnected = disconnected |
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, ptoken, altR, altG, altB = UnitPowerType(unit) |
t = self.colors.power[ptoken] |
if(not t and altR) then |
r, g, b = altR, altG, altB |
end |
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 |
return self:PostUpdatePower(event, unit, bar, min, max) |
end |
end |
local OnPowerUpdate |
do |
local UnitPower = UnitPower |
OnPowerUpdate = function(self) |
if(self.disconnected) then return end |
local power = UnitPower(self.unit) |
if(power ~= self.min) then |
self.min = power |
return Update(self:GetParent(), 'OnPowerUpdate', self.unit) |
end |
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: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, ns = ... |
local oUF = ns.oUF |
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 next, 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:RegisterInitCallback(Enable) |
local parent, ns = ... |
local oUF = ns.oUF |
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) |
--[[ |
-- 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, ns = ... |
local oUF = ns.oUF |
local classColors |
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 |
-- XXX: Fix this for 1.4 |
classColors = fontstring.parent.colors.class |
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 |
-- XXX: Fix this for 1.4. |
classColors = fs.parent.colors.class |
fs:UpdateTag() |
end |
end |
total = 0 |
end |
total = total + elapsed |
end) |
OnUpdates[timer] = OnUpdate |
end |
end |
local OnShow = function(self) |
-- XXX: Fix this for 1.4. |
classColors = self.colors.class |
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) 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.realUnit |
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) 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.frame_metatable.__index.Tag = Tag |
oUF.frame_metatable.__index.Untag = Untag |
--[[ Runebar: |
Authors: Zariel, Haste |
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 |
.runeMap: (table) Set custom order, only remapped runes are required. |
Example: .runeMap = {[3] = 5, [4] = 6} |
]] |
if select(2, UnitClass("player")) ~= "DEATHKNIGHT" then return end |
local parent, ns = ... |
local oUF = ns.oUF |
oUF.colors.runes = { |
{1, 0, 0}; |
{0, .5, 0}; |
{0, 1, 1}; |
{.9, .1, 1}; |
} |
local OnUpdate = function(self, elapsed) |
local duration = self.duration + elapsed |
if(duration >= self.max) then |
return self:SetScript("OnUpdate", nil) |
else |
self.duration = duration |
return self:SetValue(duration) |
end |
end |
local UpdateType = function(self, event, rune, alt) |
local colors = self.colors.runes[GetRuneType(rune) or alt] |
local rune = self.Runes[rune] |
local r, g, b = colors[1], colors[2], colors[3] |
rune:SetStatusBarColor(r, g, b) |
if(rune.bg) then |
local mu = rune.bg.multiplier or 1 |
rune.bg:SetVertexColor(r * mu, g * mu, b * mu) |
end |
end |
local Update = function(self, event, rid, usable) |
local rune = self.Runes[rid] |
if(rune) then |
local start, duration, runeReady = GetRuneCooldown(rune:GetID()) |
if(runeReady) then |
rune:SetValue(duration) |
rune:SetScript("OnUpdate", nil) |
else |
rune.duration = GetTime() - start |
rune.max = duration |
rune:SetMinMaxValues(1, duration) |
rune:SetScript("OnUpdate", OnUpdate) |
end |
end |
end |
local Enable = function(self, unit) |
local runes = self.Runes |
if(runes and unit == 'player') then |
for i=1, 6 do |
local rune = runes[i] |
rune:SetID(i) |
-- From my minor testing this is a okey solution. A full login always remove |
-- the death runes, or at least the clients knowledge about them. |
UpdateType(self, nil, i, math.floor((i+1)/2)) |
if(not rune:GetStatusBarTexture()) then |
rune:SetStatusBarTexture[[Interface\TargetingFrame\UI-StatusBar]] |
end |
end |
self:RegisterEvent("RUNE_POWER_UPDATE", Update) |
self:RegisterEvent("RUNE_TYPE_UPDATE", UpdateType) |
runes:Show() |
RuneFrame:Hide() |
-- ããå æ§ãã©ããå§æ§ã« |
local runeMap = runes.runeMap |
if(runeMap) then |
for f, t in pairs(runeMap) do |
runes[f], runes[t] = runes[t], runes[f] |
end |
else |
runes[3], runes[5] = runes[5], runes[3] |
runes[4], runes[6] = runes[6], runes[4] |
end |
-- XXX: Fix this for 1.4. |
-- I really hate how this is done: |
local width = runes.width |
local height = runes.height |
local spacing = runes.spacing or 0 |
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 |
for i=1, 6 do |
local bar = runes[i] |
if(bar) then |
bar:SetWidth(width) |
bar:SetHeight(height) |
bar:SetPoint(anchor, runes, anchor, (i - 1) * (width + spacing) * growthX, (i - 1) * (height + spacing) * growthY) |
end |
end |
-- ãããå æ§ã |
if(runeMap) then |
for f, t in pairs(runeMap) do |
runes[f], runes[t] = runes[t], runes[f] |
end |
else |
runes[3], runes[5] = runes[5], runes[3] |
runes[4], runes[6] = runes[6], runes[4] |
end |
return true |
end |
end |
local Disable = function(self) |
self.Runes:Hide() |
RuneFrame:Show() |
self:UnregisterEvent("RUNE_POWER_UPDATE", Update) |
self:UnregisterEvent("RUNE_TYPE_UPDATE", UpdateType) |
end |
oUF:AddElement("Runes", Update, Enable, Disable) |
--[[ |
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, ns = ... |
local oUF = ns.oUF |
oUF.colors.health = {49/255, 207/255, 37/255} |
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 disconnected = not UnitIsConnected(unit) |
local bar = self.Health |
bar:SetMinMaxValues(0, max) |
if(disconnected) then |
bar:SetValue(max) |
else |
bar:SetValue(min) |
end |
bar.disconnected = disconnected |
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) 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 |
return self:PostUpdateHealth(event, unit, bar, min, max) |
end |
end |
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 |
return Update(self:GetParent(), "OnHealthUpdate", self.unit) |
end |
end |
end |
local Enable = function(self, unit) |
local health = self.Health |
if(health) then |
if(health.frequentUpdates and (unit and not unit:match'%w+target$') or not unit) then |
health:SetScript('OnUpdate', OnHealthUpdate) |
-- The party frames need this to handle disconnect states correctly. |
if(not unit) then |
self:RegisterEvent("UNIT_HEALTH", Update) |
end |
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, ns = ... |
local oUF = ns.oUF |
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, ns = ... |
local oUF = ns.oUF |
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, ns = ... |
local oUF = ns.oUF |
local Update = function(self, event, unit) |
if(event == 'VehicleSwitch') then return end |
-- Calculate units to work with |
local realUnit, modUnit = SecureButton_GetUnit(self), SecureButton_GetModifiedUnit(self) |
if(modUnit == "pet" and realUnit ~= "pet") then |
modUnit = "vehicle" |
end |
-- Avoid unnecessary changes |
if(modUnit == self.unit) then return end |
-- Update the frame unit properties |
self.unit = modUnit |
if(modUnit ~= realUnit) then |
self.realUnit = realUnit |
else |
self.realUnit = nil |
end |
-- Refresh the frame |
return self:PLAYER_ENTERING_WORLD('VehicleSwitch') |
end |
local Enable = function(self, unit) |
if( |
self.disallowVehicleSwap or |
(unit and unit:match'target') or |
self:GetAttribute'unitsuffix' == 'target' |
) then return end |
self:RegisterEvent('UNIT_ENTERED_VEHICLE', Update) |
self:RegisterEvent('UNIT_EXITED_VEHICLE', Update) |
self:SetAttribute('toggleForVehicle', true) |
return true |
end |
local Disable = function(self) |
self:UnregisterEvent('UNIT_ENTERED_VEHICLE', Update) |
self:UnregisterEvent('UNIT_EXITED_VEHICLE', Update) |
self:SetAttribute('toggleForVehicle', nil) |
end |
oUF:AddElement("VehicleSwitch", Update, 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, ns = ... |
local oUF = ns.oUF |
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 |
return 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 |
return 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 |
return 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 |
return 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 |
return 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 |
return 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(...) |
return UNIT_SPELLCAST_CHANNEL_START(...) |
end, Enable, Disable) |
local parent, ns = ... |
local oUF = ns.oUF |
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, ns = ... |
local oUF = ns.oUF |
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) |
## Interface: 30300 |
## Title: oUF |
## Author: Haste |
## Version: 1.3.28 |
## OptionalDeps: !ClassColors |
## X-eMail: troeks@gmail.com |
## X-oUF: oUF |
## Notes: Unit frame framework. Does nothing by itself. |
oUF.xml |
Copyright (c) 2006-2009 Trond A Ekseth <troeks@gmail.com> |
local settings = oUF_Settings |
local startx, endx = 285, 285 |
local starty, endy = 500, 250 |
local Scale = 0.8 |
local locations = { |
startX = startx / Scale, |
endX = endx / Scale, |
startY = starty / Scale, |
endY = endy / Scale, |
} |
local function OnEvent(self, event, addon) |
if(addon=="Blizzard_CombatText") then |
CombatTextFont:SetFont("Fonts\\FRIZQT__.TTF", 25, "THINOUTLINE") |
CombatTextFont:SetShadowColor(0.19, 0.19, 0.19, 0) |
COMBAT_TEXT_DEFLECT = "Deflect" |
COMBAT_TEXT_REFLECT = "Reflect" |
COMBAT_TEXT_IMMUNE = "Immune" |
COMBAT_TEXT_RESIST = "Resist" |
COMBAT_TEXT_ABSORB = "Absorb" |
COMBAT_TEXT_BLOCK = "Block" |
COMBAT_TEXT_DODGE = "Dodge" |
COMBAT_TEXT_PARRY = "Parry" |
COMBAT_TEXT_EVADE = "Evade" |
COMBAT_TEXT_MISS = "Miss" |
DEFLECT = "Deflect" |
REFLECT = "Reflect" |
IMMUNE = "Immune" |
RESIST = "Resist" |
ABSORB = "Absorb" |
BLOCK = "Block" |
DODGE = "Dodge" |
PARRY = "Parry" |
EVADE = "Evade" |
MISS = "Miss" |
BLOCK_TRAILER = "(Block %d)" |
ABSORB_TRAILER = "(Absorb %d)" |
RESIST_TRAILER = "(Resist %d)" |
ENTERING_COMBAT = "++COMBAT++" |
LEAVING_COMBAT = "--COMBAT--" |
COMBAT_TEXT_SCROLLSPEED = 3.2 |
function CombatText_UpdateDisplayedMessages() |
if ( UnitHasVehicleUI("player") ) then |
CombatText.unit = "vehicle" |
else |
CombatText.unit = "player" |
end |
CombatTextSetActiveUnit(CombatText.unit) |
CombatText:SetScale(Scale) |
CombatTextFont:SetFont(settings.font, 23, "THINOUTLINE") |
CombatText:RegisterEvent("COMBAT_TEXT_UPDATE") |
CombatText:RegisterEvent("UNIT_HEALTH") |
CombatText:RegisterEvent("UNIT_MANA") |
CombatText:RegisterEvent("PLAYER_REGEN_DISABLED") |
CombatText:RegisterEvent("PLAYER_REGEN_ENABLED") |
CombatText:RegisterEvent("PLAYER_COMBO_POINTS") |
CombatText:RegisterEvent("RUNE_POWER_UPDATE") |
CombatText:RegisterEvent("UNIT_ENTERED_VEHICLE") |
CombatText:RegisterEvent("UNIT_EXITING_VEHICLE") |
COMBAT_TEXT_Y_SCALE = WorldFrame:GetHeight() / 768 |
COMBAT_TEXT_X_SCALE = WorldFrame:GetWidth() / 1024 |
COMBAT_TEXT_SPACING = 10 * COMBAT_TEXT_Y_SCALE |
COMBAT_TEXT_MAX_OFFSET = 130 * COMBAT_TEXT_Y_SCALE |
COMBAT_TEXT_X_ADJUSTMENT = 80 * COMBAT_TEXT_X_SCALE |
for index, value in pairs(COMBAT_TEXT_TYPE_INFO) do |
if ( value.var ) then |
if ( getglobal(value.var) == "1" ) then |
value.show = 1; |
else |
value.show = nil; |
end |
end |
end |
COMBAT_TEXT_SCROLL_FUNCTION = CombatText_StandardScroll |
COMBAT_TEXT_LOCATIONS = locations |
CombatText_ClearAnimationList() |
end |
self:UnregisterEvent"ADDON_LOADED" |
OnEvent = nil |
end |
end |
local eventframe = CreateFrame"Frame" |
eventframe:RegisterEvent"ADDON_LOADED" |
eventframe:SetScript("OnEvent", OnEvent) |
if IsAddOnLoaded"Blizzard_CombatText" then OnEvent(eventframe, "ADDON_LOADED", "Blizzard_CombatText") end |
--[[------------------------------------------------------------------------- |
Trond A Ekseth grants anyone the right to use this work for any purpose, |
without any conditions, unless such conditions are required by law. |
ALZA uses this right to conquer the whole world! |
---------------------------------------------------------------------------]] |
--[[ Options start here ]] |
local settings = oUF_Settings |
--[[ Options end ]] |
--[[ Font creation func ]] |
-- arguments: parent (parent frame of fontstring), justify (horisontal justification, optional) |
-- returns: FontString |
local createFs = function(parent, justify, ownfsize) |
local f = parent:CreateFontString(nil, "OVERLAY") |
f:SetFont(settings.font, ownfsize or settings.fsize, "THINOUTLINE") |
if(justify) then f:SetJustifyH(justify) end |
return f |
end |
local function SecondsToTimeAbbrev(time) |
local hr, m, s, text |
if time <= 0 then text = "" |
elseif(time < 3600 and time > 60) then |
hr = floor(time / 3600) |
m = floor(mod(time, 3600) / 60 + 1) |
s = mod(time, 60) |
text = format("%dм %dÑ", m, s) |
elseif time < 60 then |
m = floor(time / 60) |
s = mod(time, 60) |
text = (m == 0 and format("%dÑ", s)) |
else |
hr = floor(time / 3600 + 1) |
text = format("%dÑ", hr) |
end |
return text |
end |
--[[ Right click menu ]] |
local menu = function(self) |
local unit = self.unit:sub(1, -2) |
local cunit = self.unit:gsub("(.)", string.upper, 1) |
if(unit=="party" or unit=="partypet") then |
ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..self.id.."DropDown"], "cursor") |
elseif(_G[cunit.."FrameDropDown"]) then |
ToggleDropDownMenu(1, nil, _G[cunit.."FrameDropDown"], "cursor") |
end |
end |
--[[ Short numbarz! ]] |
local format = string.format |
local siValue = function(val) |
if val >= 10000000 then |
return format("%.1fm", val / 1000000) |
elseif val >= 1000000 then |
return format("%.2fm", val / 1000000) |
elseif val >= 100000 then |
return format("%.0fk", val / 1000) |
elseif val >= 10000 then |
return format("%.1fk", val / 1000) |
else |
return val |
end |
end |
--[[ Health update ]] |
local ColorGradient = oUF.ColorGradient -- we need it for hp and druid power coloring |
local unpack = unpack |
local OverrideUpdateHealth = function(self, event, unit, bar, min, max) -- this func replaces standart health update func |
local r, g, b = 1, 1, 1 |
if(max~=0) then |
r, g, b = ColorGradient(min/max, 1, 0, 0, 1, 1, 0, 0, 1, 0) -- we color percent hp by color gradient from green to red |
end |
if(not UnitIsConnected(unit)) then |
bar:SetValue(0) |
bar.value:SetText("Off") |
elseif(UnitIsDead(unit)) then |
bar:SetValue(0) |
bar.value:SetText("Dead") |
elseif(UnitIsGhost(unit)) then |
bar:SetValue(0) |
bar.value:SetText("Ghost") |
else |
if(unit=="player") then |
bar.value:SetFormattedText("|cff%02x%02x%02x%s|r %s", r*255, g*255, b*255, siValue(min), siValue(max)) -- text for player: "curhp percenthp" |
elseif(unit=="pet") then |
bar.value:SetFormattedText("%s", siValue(min)) -- text for pet: "shortcurhp" |
elseif(unit=="target") then |
bar.value:SetFormattedText("%s |cff%02x%02x%02x%.1f|r", siValue(min), r*255, g*255, b*255, (min/max)*100) -- text for target: "shortcurhp percenthp" |
else |
bar.value:SetText() -- no hp text for others. Feel free to add other units. Info about SetFormattedText can be found on wowwiki.com |
end |
end |
if(settings.ClassColor==true) then -- determine what color to use |
if(UnitIsPlayer(unit)) then |
local _, englass = UnitClass(unit) |
if(self.colors.class[englass]) then |
r, g, b = unpack(self.colors.class[englass]) |
end |
else |
r, g, b = UnitSelectionColor(unit) |
end |
else |
r, g, b = unpack(OwnColor) |
end |
if(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then -- grey color for tapped mobs |
r, g, b = .6, .6, .6 |
end |
if(unit=="pet" and GetPetHappiness()) then -- petframe is colored by happiness |
r, g, b = unpack(self.colors.happiness[GetPetHappiness()]) |
end |
bar:SetStatusBarColor(r, g, b) -- hp bar coloring |
bar.bg:SetVertexColor(r, g, b, .2) -- hp background - same color but 20% opacity |
if(self.Castbar) then -- same with castbar |
self.Castbar:SetStatusBarColor(r, g, b) |
self.Castbar.bg:SetVertexColor(r, g, b, .2) |
end |
if settings.Portraits then |
self.Portrait:SetAlpha(.1) |
end |
end |
local PostUpdatePower = function(self, event, unit, bar, min, max) |
if(not UnitIsConnected(unit) or min==0) then -- no unit - no mana! |
bar.value:SetText() |
elseif(UnitIsDead(unit) or UnitIsGhost(unit)) then -- dead unit - no mana! |
bar:SetValue(0) |
bar.value:SetText() |
elseif(unit=="player" or unit=="target" or unit=="pet") then |
bar.value:SetFormattedText("%s", siValue(min)) -- text for player, pet, target: "shortcurrentmana" |
else |
bar.value:SetText() -- no text for other units |
end |
local r, g, b = 1, 1, 1 -- manabar coloring |
if(settings.PowerColorByType==true) then |
local _, ptype = UnitPowerType(unit) |
if(settings.powercolors[ptype]) then |
r, g, b = unpack(settings.powercolors[ptype]) |
end |
else |
r, g, b = unpack(settings.OwnPowerColor) |
end |
bar:SetStatusBarColor(r, g, b) |
bar.value:SetTextColor(r, g, b) -- power text colored with same color as power bar |
bar.bg:SetVertexColor(r, g, b, .2) |
end |
--[[ Druid power update. Credits to p3lim for code and idea ]] |
oUF.TagEvents["[druidpower]"] = "UNIT_MANA UPDATE_SHAPESHIFT_FORM" |
oUF.Tags["[druidpower]"] = function(unit) -- druid power text: "shortcurrentmana percentmana" |
local min, max = UnitPower(unit, 0), UnitPowerMax(unit, 0) |
local r, g, b = 0, 0, 1 |
if(max~=0) then |
r, g, b = ColorGradient(min/max, 1, 0, 0, 1, 1, 0, 0, 1, 0) -- gradient for percent mp |
end |
return UnitPowerType(unit)~=0 and format("|cff0090ff%d |cff%02x%02x%02x%.1f|r", min, r*255, g*255, b*255, (min/max)*100) |
end |
--[[ Castbar time styling ]] |
local CustomTimeText = function(self, duration) |
self.Time:SetFormattedText("%.1f", duration) -- text for casts: "elapsed / casttime" |
--self.Time:SetFormattedText("%.1f / %.1f", duration, self.max) -- text for casts: "elapsed / casttime" |
end |
--[[ Disabling default buff frames ]] |
local _G = getfenv(0) -- speed up getting globals |
--[[local buff = _G["BuffFrame"] |
buff:Hide() |
buff:UnregisterAllEvents() |
buff:SetScript("OnUpdate", nil)]] |
--[[ Aura settings ]] |
local noHide = function(self) -- we don't want aura border to hide on buffs |
self:SetVertexColor(0, 0, 0) |
end |
local CancelBuff = function(self, button) -- cancel buffs on right click |
if(button=="RightButton") then |
CancelUnitBuff("player", self:GetID()) |
end |
end |
local PostCreateAuraIcon = function(self, button, icons, index, isDebuff) |
button.cd:SetReverse() |
button.count:ClearAllPoints() |
button.count:SetPoint("TOPLEFT") -- Stacks text will be on top of icon |
button.count:SetFont(settings.font, settings.fsize, "THINOUTLINE") |
button.count:SetTextColor(.8, .8, .8) -- Color for stacks text |
button.icon:SetTexCoord(0, 1, 0, 1) |
button.overlay:SetTexture(settings.buffTex) |
button.overlay:SetTexCoord(0, 1, 0, 1) |
button.overlay.Hide = noHide |
if(not isDebuff and self.unit=="player") then -- Cancel buffs on right click |
button:SetScript("OnMouseUp", CancelBuff) |
end |
end |
local MyUnits = { -- true to show cooldown for debuffs from that units, false to hide |
player = true, |
pet = true, |
vehicle = true |
} |
local PostUpdateAuraIcon = function(self, icons, unit, icon, index, offset, filter, isDebuff) |
if(icon.cd:IsShown() and self.unit=="target" and isDebuff and not MyUnits[icon.owner]) then |
icon.cd:Hide() |
end |
end |
local _, class = UnitClass("player") |
--[[ Let's start! ]] |
local func = function(self, unit) |
self.menu = menu |
self:SetScript("OnEnter", OnEnter) |
self:SetScript("OnLeave", OnLeave) |
self:RegisterForClicks("anyup") |
self:SetAttribute("*type2", "menu") |
self.disallowVehicleSwap = true |
local s = settings.Frames[unit] -- Getting settings for every unit |
--[[ Frame sizes ]] |
self:SetAttribute("initial-width", s.Width) |
self:SetAttribute("initial-height", s.Height) |
self.FrameBackdrop = CreateFrame("Frame", nil, self) |
self.FrameBackdrop:SetPoint("TOPLEFT", self, "TOPLEFT", -4 , 4) |
self.FrameBackdrop:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 4 , -4) |
self.FrameBackdrop:SetFrameStrata("BACKGROUND") |
self.FrameBackdrop:SetBackdrop { |
edgeFile = glowTex, edgeSize = 4, |
tile = true, tileSize = 16, |
insets = {left = 6, right = 6, top = 6, bottom = 6} |
} |
self.FrameBackdrop:SetBackdropColor(0, 0, 0, 0) |
self.FrameBackdrop:SetBackdropBorderColor(0, 0, 0) |
--[[ Healthbar ]] |
local hp = CreateFrame("StatusBar", nil, self) |
hp:SetStatusBarTexture(settings.texture) |
hp.frequentUpdates = true |
hp:SetPoint("TOPRIGHT") |
hp:SetPoint("TOPLEFT") |
hp:SetHeight(s.ManaBarHeight==0 and s.Height or (s.Height - s.ManaBarHeight - 1)) |
local hpbg = hp:CreateTexture(nil, "BACKGROUND") |
hpbg:SetTexture(settings.texture) |
hpbg:SetAllPoints(hp) |
local hpp = createFs(hp) |
hpp:SetPoint("RIGHT", hp, "RIGHT", -5, 0) -- health text for player - on right side |
hp.bg = hpbg |
hp.value = hpp |
self.Health = hp |
self.OverrideUpdateHealth = OverrideUpdateHealth |
--[[ Manabar ]] |
local pp = CreateFrame("StatusBar", nil, self) |
pp:SetStatusBarTexture(settings.texture) |
pp.frequentUpdates = true |
pp:SetPoint("BOTTOMLEFT") |
pp:SetPoint("BOTTOMRIGHT") |
pp:SetHeight(s.ManaBarHeight) |
local ppbg = pp:CreateTexture(nil, "BACKGROUND") |
ppbg:SetTexture(settings.texture) |
ppbg:SetAllPoints(pp) |
local ppp = createFs(pp) |
ppp:SetPoint("RIGHT", pp, "RIGHT", -2, 0) |
pp.bg = ppbg |
pp.value = ppp |
self.Power = pp |
self.PostUpdatePower = PostUpdatePower |
self.PostUpdateAuraIcon = PostUpdateAuraIcon |
--[[ Info text ]] |
local info = createFs(self) |
if(unit=="player") then |
info:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 3) |
self:Tag(info, "[name]") -- look into \Interface\AddOns\oUF\elements\tags.lua for more tags |
elseif(unit=="target") then |
info:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 3) |
self:Tag(info, "[difficulty][smartlevel]|r [name]") -- look into \Interface\AddOns\oUF\elements\tags.lua for more tags |
elseif(unit=="targettarget" or unit=="focus" or unit=="focustarget") then |
info:SetPoint("BOTTOM", self, "TOP", 0, 3) |
self:Tag(info, "[name]") |
elseif(not unit) then |
info:SetParent(self.Health) |
info:SetJustifyH("CENTER") |
self:Tag(info, "[name]") |
end |
--[[ Global bg, 2 px border ]] |
local allbg = self:CreateTexture(nil, "BORDER") |
allbg:SetPoint("BOTTOMRIGHT", 1, -1) |
allbg:SetPoint("TOPLEFT", -1, 1) |
allbg:SetTexture(0, 0, 0) -- we want it black |
--[[ Castbar ]] |
if(unit=="player" or unit=="target" or unit=="pet" or unit=="focus") then |
local _, class = UnitClass(unit) |
local space = 0 |
if class == "DEATHKNIGHT" or class=="SHAMAN" then |
space = 12 |
end |
local cb = CreateFrame("StatusBar", nil, self) |
cb:SetStatusBarTexture(settings.texture) |
cb:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", 0, -30-space) |
cb:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 0, -30-space) |
cb:SetHeight(s.ManaBarHeight==0 and s.Height or (s.Height / 2)) -- Castbar will be as big as healthbar |
local cbblackbg = cb:CreateTexture(nil, "BACKGROUND") -- that's the black thingie like global background |
cbblackbg:SetPoint("TOPLEFT", -1, 1) |
cbblackbg:SetPoint("BOTTOMRIGHT", 1, -1) |
cbblackbg:SetTexture(0, 0, 0) |
local cbbg = cb:CreateTexture(nil, "BORDER") |
cbbg:SetTexture(settings.texture) |
cbbg:SetAllPoints(cb) |
local time = createFs(cb, "RIGHT", 12) |
time:SetPoint("RIGHT", cb, "RIGHT", -4, 0) |
local text = createFs(cb, "LEFT", 12) |
text:SetPoint("LEFT", cb, "LEFT", cb:GetHeight() + 4, 0) |
text:SetPoint("RIGHT", time, "LEFT") |
local spark = cb:CreateTexture(nil, "OVERLAY") |
spark:SetVertexColor(1, 1, 1) |
spark:SetBlendMode("ADD") |
spark:SetHeight(cb:GetHeight()*2.5) |
spark:SetWidth(20) |
cbicon = cb:CreateTexture(nil, "OVERLAY") |
cbicon:SetTexCoord(.1,.9,.1,.9) |
cbicon:SetWidth(cb:GetHeight()) |
cbicon:SetHeight(cb:GetHeight()) |
cbicon:SetPoint("LEFT") |
cb.bg = cbbg |
cb.Time = time |
cb.Text = text |
cb.Spark = spark |
cb.CustomTimeText = CustomTimeText |
cb.Icon = cbicon |
self.Castbar = cb |
end |
if unit=="player" then |
local _, class = UnitClass(unit) |
if class == "DEATHKNIGHT" then |
self.Runes = CreateFrame('Frame', nil, self) |
self.Runes:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -1) |
self.Runes:SetHeight(10) |
self.Runes:SetWidth(s.Width) |
self.Runes.anchor = "TOPLEFT" |
self.Runes.growth = "RIGHT" |
self.Runes.height = 10 |
self.Runes.width = s.Width / 6 - 0.85 |
self.Runes.spacing = 1 |
for i = 1, 6 do |
self.Runes[i] = CreateFrame("StatusBar", "oUFRune"..i, self.Runes) |
self.Runes[i]:SetStatusBarTexture(settings.texture) |
self.Runes[i]:SetStatusBarColor(unpack(settings.runecolors[i])) |
self.Runes[i].bg = self.Runes[i]:CreateTexture(nil, "BACKGROUND") -- that's the black thingie like global background |
self.Runes[i].bg:SetPoint("TOPLEFT", -1, 1) |
self.Runes[i].bg:SetPoint("BOTTOMRIGHT", 1, -1) |
self.Runes[i].bg:SetTexture(0, 0, 0) |
end |
end |
end |
if settings.Portraits then |
self.Portrait = CreateFrame("PlayerModel", nil, self) |
self.Portrait:SetAllPoints(self.Health) |
self.Portrait:SetAlpha(.1) |
end |
if(unit=="player") then |
-- [[ Temporary enchants icons ]] -- |
local ench = {} |
for i = 1,2 do |
ench[i] = _G["TempEnchant"..i] |
_G["TempEnchant"..i.."Border"]:Hide() |
ench[i]:ClearAllPoints() |
if (i==1) then |
ench[i]:SetPoint("TOPRIGHT", self, "TOPLEFT", -3, 1) |
else |
ench[i]:SetPoint("RIGHT", ench[i-1], "LEFT", -2, 0) |
end |
ench[i]:SetWidth(32) |
ench[i]:SetHeight(32) |
ench[i]:Show() |
ench[i].t = ench[i]:CreateTexture(nil,"BORDER") |
ench[i].t:SetTexture(settings.buffTex) |
ench[i].t:SetVertexColor(0.7, 0, 0.7) |
ench[i].t:SetAllPoints(ench[i]) |
ench[i].dur = _G["TempEnchant"..i.."Duration"] |
ench[i].dur:ClearAllPoints() |
ench[i].dur:SetAllPoints(ench[i]) |
ench[i].dur:SetFont(settings.font, 11, "THINOUTLINE") |
ench[i].dur:SetVertexColor(1, 1, 1) |
ench[i].dur.SetVertexColor = function() end |
end |
-- Hide old buffs |
_G["BuffFrame"]:Hide() |
_G["BuffFrame"]:UnregisterAllEvents() |
_G["BuffFrame"]:SetScript("OnUpdate", nil) |
local buffs = CreateFrame("Frame", nill, self) |
buffs:SetPoint("TOPRIGHT", Minimap, "TOPLEFT", -25, 0) |
buffs.initialAnchor = "TOPRIGHT" |
buffs["growth-y"] = "DOWN" |
buffs["growth-x"] = "LEFT" |
buffs:SetHeight(500) |
buffs:SetWidth(220) |
buffs.spacing = 4 |
buffs.size = 30 |
self.Buffs = buffs |
local debuffs = CreateFrame("Frame", nill, self) |
debuffs:SetPoint("TOPRIGHT", Minimap, "BOTTOMRIGHT", 0, -35) |
debuffs.initialAnchor = "TOPRIGHT" |
debuffs["growth-x"] = "LEFT" |
debuffs["growth-y"] = "DOWN" |
debuffs:SetHeight(500) |
debuffs:SetWidth(220) |
debuffs.spacing = 4 |
debuffs.size = 45 |
self.Debuffs = debuffs |
end |
if(unit=="target") then -- For target we make one frame. Buffs first, then debuffs |
local auras = CreateFrame("Frame", nill, self) |
auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 20) |
auras.initialAnchor = "BOTTOMLEFT" |
auras["growth-x"] = "RIGHT" |
auras["growth-y"] = "UP" |
auras.numDebuffs = 16 -- Max amount of debuffs to show |
auras:SetHeight(373) |
auras:SetWidth(s.Width) |
auras.spacing = 1 |
auras.size = 28 |
auras.gap = false -- A gap between buffs and debuffs |
self.Auras = auras |
end |
if(unit=="focus" or unit=="targettarget") then |
local debuffs = CreateFrame("Frame", nill, self) -- Debuffs for focus |
debuffs:SetPoint("TOPLEFT", self, "BOTTOMLEFT", -2, -3) |
debuffs.initialAnchor = "TOPLEFT" |
debuffs["growth-x"] = "RIGHT" |
debuffs["growth-y"] = "DOWN" |
debuffs:SetHeight(20) |
debuffs:SetWidth(104) |
debuffs.spacing = 1 |
debuffs.size = 20 |
self.Debuffs = debuffs |
end |
local sentTime = 0 |
local lagTime = 0 |
local UNIT_SPELLCAST_SENT = function (self, event, unit, spell, spellrank) |
if(self.unit~=unit) then return end |
sentTime = GetTime() |
end |
local PostCastStart = function(self, event, unit, name, rank, text, castid) |
lagTime = GetTime() - sentTime |
end |
local PostChannelStart = function(self, event, unit, name, rank, text) |
lagTime = GetTime() - sentTime |
end |
local OnCastbarUpdate = function(self, elapsed) |
if(self.casting) then |
local duration = self.duration + elapsed |
if(duration>=self.max) then |
self.casting = nil |
self:Hide() |
return |
end |
local width = self:GetWidth() |
local safeZonePercent = lagTime / self.max |
if(safeZonePercent>1) then safeZonePercent=1 end |
self.SafeZone:SetWidth(width * safeZonePercent) |
if(self.delay~=0) then |
self.Time:SetFormattedText("%.1f|cffff0000-%.1f|r", duration, self.delay) |
else |
self.Time:SetFormattedText("%.1f / %.1f", duration, self.max) |
self.Lag:SetFormattedText("%d ms", lagTime * 1000) |
end |
self.duration = duration |
self:SetValue(duration) |
self.Spark:SetPoint("CENTER", self, "LEFT", (duration / self.max) * self:GetWidth(), 0) |
elseif(self.channeling) then |
local duration = self.duration - elapsed |
if(duration<=0) then |
self.channeling = nil |
self:Hide() |
return |
end |
if(lagTime > 1e5) then |
lagTime = 0 |
self.SafeZone:SetWidth(0) |
else |
local width = self:GetWidth() |
local safeZonePercent = lagTime / self.max |
if(safeZonePercent > 1 or safeZonePercent<=0) then safeZonePercent = 1 end |
self.SafeZone:SetWidth(width * safeZonePercent) |
end |
if(self.delay~=0) then |
self.Time:SetFormattedText("%.1f|cffff0000-%.1f|r", duration, self.delay) |
else |
self.Time:SetFormattedText("%.1f / %.1f", duration, self.max) |
self.Lag:SetFormattedText( "%d ms ", lagTime * 1000 ) |
end |
self.duration = duration |
self:SetValue(duration) |
self.Spark:SetPoint("CENTER", self, "LEFT", (duration / self.max) * self:GetWidth(), 0) |
else |
self.unitName = nil |
self.channeling = nil |
self:SetValue(1) |
self:Hide() |
end |
end |
if(unit=="player") then |
local sz = self.Castbar:CreateTexture(nil, "ARTWORK") |
sz:SetTexture(settings.texture) |
sz:SetVertexColor(1, 0.3, 0.3) |
sz:SetPoint("BOTTOMRIGHT") |
sz:SetPoint("TOPRIGHT") |
self.Castbar.SafeZone = sz |
local lag = createFs(self.Castbar) |
lag:SetFont(settings.font, 10, "THINOUTLINE") |
lag:SetPoint("LEFT", self.Castbar, "RIGHT", -2, 0) |
lag:SetJustifyH("RIGHT") |
self.Castbar.Lag = lag |
self.PostCastStart = PostCastStart |
self.OnCastbarUpdate = OnCastbarUpdate |
self.PostChannelStart = PostChannelStart |
self:RegisterEvent("UNIT_SPELLCAST_SENT", UNIT_SPELLCAST_SENT) |
end |
self.PostCreateAuraIcon = PostCreateAuraIcon |
--[[ Druid mana ]] |
if(unit=="player" and class=="DRUID") then |
local druid = createFs(self) |
druid:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", -2, 3) |
self:Tag(druid, "[druidpower]") |
self.DruidPower = druid |
end |
--[[ Raid Target Icon ]] |
if(unit=="player" or unit=="target") then |
local ricon = self.Health:CreateTexture(nil, "OVERLAY") |
ricon:SetHeight(16) |
ricon:SetWidth(16) |
ricon:SetPoint("CENTER") |
self.RaidIcon = ricon |
end |
--[[ Resting icon ]] |
if(unit=="player") then |
local rest = self.Health:CreateTexture(nil, "OVERLAY") |
rest:SetHeight(20) |
rest:SetWidth(20) |
rest:SetPoint("LEFT") |
self.Resting = rest |
end |
--[[ Combat icon ]] |
if(unit=="player") then |
local combat = self.Health:CreateTexture(nil, "OVERLAY") |
combat:SetHeight(18) |
combat:SetWidth(18) |
combat:SetPoint("LEFT") |
self.Combat = combat |
end |
--[[ Leader icon ]] |
if(not unit) then -- only for party frames |
local leader = self:CreateTexture(nil, "OVERLAY") |
leader:SetHeight(16) |
leader:SetWidth(16) |
leader:SetPoint("RIGHT", hp, "LEFT", -2, 0) |
self.Leader = leader |
end |
--[[ Combo Points ]] |
if(unit=="target") then -- this is for Malygos. Text will be shown on right of target healthbar |
local UpdateCPoints = function(self, event, unit) |
if unit == PlayerFrame.unit and unit ~= self.CPoints.unit then |
self.CPoints.unit = unit |
end |
end |
self.cpFrame = self.cpFrame or CreateFrame("Frame", nil, self) |
self.cpFrame:SetPoint("TOPLEFT",self,"BOTTOMLEFT",0,0) |
self.cpFrame:SetPoint("BOTTOMRIGHT",self,"BOTTOMRIGHT",0,-12) |
self.cpFrame:CreateTexture(nil):SetTexture(0,0,0) |
self.cpFrame:Show() |
self.CPoints = {} |
self.CPoints.unit = PlayerFrame.unit |
for i = 1, 5 do |
self.CPoints[i] = self.cpFrame:CreateTexture(nil, "OVERLAY") |
self.CPoints[i]:SetHeight(12) |
self.CPoints[i]:SetWidth(12) |
self.CPoints[i]:SetTexture(settings.indicator) |
if i == 1 then |
self.CPoints[i]:SetPoint("LEFT") |
self.CPoints[i]:SetVertexColor(0.69, 0.31, 0.31) |
else |
self.CPoints[i]:SetPoint("LEFT", self.CPoints[i-1], "RIGHT", 2, 0) |
end |
end |
self.CPoints[2]:SetVertexColor(0.69, 0.31, 0.31) |
self.CPoints[3]:SetVertexColor(0.65, 0.63, 0.35) |
self.CPoints[4]:SetVertexColor(0.65, 0.63, 0.35) |
self.CPoints[5]:SetVertexColor(0.33, 0.59, 0.33) |
self:RegisterEvent("UNIT_COMBO_POINTS", UpdateCPoints) |
end |
--[[ Totems ]]-- |
local _, pClass = UnitClass("player") |
if unit=="player" and pClass == "SHAMAN" then |
local GetTotemInfo, SetValue, GetTime = GetTotemInfo, SetValue, GetTime |
local Abbrev = function(name) |
return (string.len(name) > 10) and string.gsub(name, "%s*(.)%S*%s*", "%1. ") or name |
end |
self.TotemBar = {} |
self.TotemBar.colors = { |
[1] = {0.752,0.172,0.02}, |
[2] = {0.741,0.580,0.04}, |
[3] = {0,0.443,0.631}, |
[4] = {0.6,1,0.945}, |
} |
local total = 0 |
local delay = 1 |
self.TotemBarFrame = CreateFrame("frame", "oUF_TotemBarFrame",self) |
self.TotemBarFrame:SetPoint("TOPLEFT", self, "BOTTOMLEFT", -1, 0) |
self.TotemBarFrame:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 1, -settings.Frames.player.ManaBarHeight+1) |
local tfbg = self.TotemBarFrame:CreateTexture(nil, "BACKGROUND") |
tfbg:SetAllPoints(self.TotemBarFrame) |
tfbg:SetTexture(settings.texture) |
tfbg:SetVertexColor(0,0,0) |
self.TotemBarFrame:Show() |
for i = 1, 4 do |
self.TotemBar[i] = CreateFrame("StatusBar", self:GetName().."_TotemBar"..i, self) |
self.TotemBar[i]:SetHeight(settings.Frames.player.ManaBarHeight-3) |
self.TotemBar[i]:SetWidth(s.Width/4-1) |
if (i==1) then |
self.TotemBar[i]:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -1) |
else |
self.TotemBar[i]:SetPoint("LEFT", self.TotemBar[i-1], "RIGHT", 1, 0) |
end |
self.TotemBar[i]:SetStatusBarTexture(settings.texture) |
self.TotemBar[i]:SetMinMaxValues(0, 1) |
self.TotemBar[i].bg = self.TotemBar[i]:CreateTexture(nil, "BORDER") |
self.TotemBar[i].bg:SetAllPoints(self.TotemBar[i]) |
self.TotemBar[i].bg:SetTexture(settings.texture) |
self.TotemBar[i].bg:SetVertexColor(.2,.2,.2) |
self.TotemBar[i].fs = createFs(self.TotemBar[i], nil, 8) |
self.TotemBar[i].fs:SetAllPoints(self.TotemBar[i]) |
self.TotemBar[i]:Hide() |
end |
local function TotemOnClick(self,...) |
local id = self.ID |
local mouse = ... |
if IsShiftKeyDown() then |
for j = 1,4 do |
DestroyTotem(j) |
end |
else |
DestroyTotem(id) |
end |
end |
self.TotemBar.Destroy = true |
local function InitDestroy(self) |
local totem = self.TotemBar |
for i = 1 , 4 do |
local Destroy = CreateFrame("Button",nil, totem[i]) |
Destroy:SetAllPoints(totem[i]) |
Destroy:RegisterForClicks("LeftButtonUp", "RightButtonUp") |
Destroy.ID = i |
Destroy:SetScript("OnClick", TotemOnClick) |
end |
end |
local function UpdateSlot(self, slot) |
local totem = self.TotemBar |
self.TotemBar[slot]:Show() |
if(totem) then |
if totem.Destroy then |
InitDestroy(self) |
end |
end |
haveTotem, name, startTime, duration, totemIcon = GetTotemInfo(slot) |
totem[slot]:SetStatusBarColor(unpack(totem.colors[slot])) |
totem[slot]:SetValue(0) |
totem[slot].ID = slot |
-- If we have a totem then set his value |
if(haveTotem) then |
if totem[slot].Name then |
totem[slot].Name:SetText(Abbrev(name)) |
end |
if(duration >= 0) then |
totem[slot]:SetValue(1 - ((GetTime() - startTime) / duration)) |
-- Status bar update |
totem[slot]:SetScript("OnUpdate",function(self,elapsed) |
total = total + elapsed |
if total >= delay then |
total = 0 |
haveTotem, name, startTime, duration, totemIcon = GetTotemInfo(self.ID) |
if ((GetTime() - startTime) == 0) then |
self:SetValue(0) |
self.fs:SetText("") |
else |
self:SetValue(1 - ((GetTime() - startTime) / duration)) |
self.fs:SetText(SecondsToTimeAbbrev(floor(duration - (GetTime() - startTime)))) |
end |
end |
end) |
else |
-- There's no need to update because it doesn't have any duration |
totem[slot]:SetScript("OnUpdate",nil) |
totem[slot]:SetValue(0) |
totem[slot]:Hide() |
end |
else |
-- No totem = no time |
if totem[slot].Name then |
totem[slot].Name:SetText(" ") |
end |
totem[slot]:SetValue(0) |
totem[slot]:Hide() |
end |
end |
local function Event(self,event,...) |
if event == "PLAYER_TOTEM_UPDATE" then |
UpdateSlot(self, ...) |
end |
end |
self:RegisterEvent("PLAYER_TOTEM_UPDATE", Event) |
end |
--[[ Fading for party ]] |
if(not unit) then |
self.Range = true |
self.inRangeAlpha = 1.0 |
self.outsideRangeAlpha = 0.5 |
end |
return self |
end |
oUF:RegisterStyle("style", func) |
oUF:SetActiveStyle("style") |
--[[ Positions ]] |
oUF:Spawn("player", "oUF_player"):SetPoint(unpack(settings.Positions.player)) |
oUF:Spawn("target", "oUF_target"):SetPoint(unpack(settings.Positions.target)) |
oUF:Spawn("targettarget", "oUF_targettarget"):SetPoint(unpack(settings.Positions.targettarget)) |
oUF:Spawn("focus", "oUF_focus"):SetPoint(unpack(settings.Positions.focus)) |
oUF:Spawn("focustarget", "oUF_focustarget"):SetPoint(unpack(settings.Positions.focustarget)) |
oUF:Spawn("pet", "oUF_pet"):SetPoint("TOPRIGHT", oUF.units.player, "TOPLEFT", -5, 0) |
local settings = oUF_Settings |
local caelNamePlates = CreateFrame("Frame", nil, UIParent) |
caelNamePlates:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end) |
local barTexture = settings.normTex |
local overlayTexture = [=[Interface\Tooltips\Nameplate-Border]=] |
local glowTexture = settings.glowTex |
local font, fontSize, fontOutline = settings.font, 10, "THINOUTLINE" |
local backdrop = { |
edgeFile = glowTexture, edgeSize = 5, |
insets = {left = 3, right = 3, top = 3, bottom = 3} |
} |
local select = select |
local IsValidFrame = function(frame) |
if frame:GetName() then |
return |
end |
overlayRegion = select(2, frame:GetRegions()) |
return overlayRegion and overlayRegion:GetObjectType() == "Texture" and overlayRegion:GetTexture() == overlayTexture |
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) |
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.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(80) |
self.castBar:ClearAllPoints() |
self.castBar:SetPoint("TOP", self.healthBar, "BOTTOM", 0, -4) |
self.castBar:SetHeight(10) |
self.castBar:SetWidth(80) |
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(10) |
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 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 |
frame.level = levelTextRegion |
levelTextRegion:SetFont(font, fontSize, fontOutline) |
levelTextRegion:SetShadowOffset(1.25, -1.25) |
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 numKids = 0 |
local lastUpdate = 0 |
local OnUpdate = function(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 |
caelNamePlates:SetScript("OnUpdate", OnUpdate) |
--caelNamePlates:RegisterEvent("PLAYER_REGEN_ENABLED") |
function caelNamePlates:PLAYER_REGEN_ENABLED() |
SetCVar("nameplateShowEnemies", 0) |
end |
caelNamePlates:RegisterEvent("PLAYER_REGEN_DISABLED") |
function caelNamePlates.PLAYER_REGEN_DISABLED() |
SetCVar("nameplateShowEnemies", 1) |
end |
-- config |
local settings = oUF_Settings |
local _, myclass = UnitClass("player") |
---------------- |
local function do_format(v) |
local string = "" |
if v > 1000000 then |
string = (floor((v/1000000)*10)/10).."m" |
elseif v > 1000 then |
string = (floor((v/1000)*10)/10).."k" |
else |
string = v |
end |
return string |
end |
local PostIcon = function(self, button, ...) |
button.icon:SetTexCoord(0, 1, 0, 1) |
button.overlay:SetTexture(settings.bordertex) |
button.overlay:SetTexCoord(0, 1, 0, 1) |
button.overlay.Hide = function(self) self:SetVertexColor(0, 0, 0) end |
end |
local function GetDebuffType(unit) |
if not UnitCanAssist("player", unit) then return nil end |
local CanDispel = { |
PRIEST = { Magic = true, Disease = true, }, |
SHAMAN = { Poison = true, Disease = true, Curse = true, }, |
PALADIN = { Magic = true, Poison = true, Disease = true, }, |
MAGE = { Curse = true, }, |
DRUID = { Curse = true, Poison = true, }, |
WARLOCK = { Magic = true, }, |
} |
local dispellist = CanDispel[myclass] or {} |
local i=1 |
while true do |
local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(unit, i, "HARMFUL") |
if icon and dispellist[debuffType] then |
return debuffType, icon, spellId, count |
else |
break |
end |
i=i+1 |
end |
end |
local function CheckDebuffs(self, event, unit) |
if self.unit ~= unit then return end |
local debuffType, texture, spellId, count = GetDebuffType(unit) |
if debuffType then |
local color = DebuffTypeColor[debuffType] or {0,0,1} |
self.Health:SetBackdropColor(color.r,color.g, color.b,1) |
self.Icon.Icon:SetTexture(texture) |
self.Icon.Count:SetText((count~=0) and count) |
self.Icon:Show() |
else |
self.Health:SetBackdropColor(0,0,0) |
self.Icon:Hide() |
end |
end |
local function createAuraWatch(self, unit) |
local corners = settings.corners |
local auras = CreateFrame("Frame", nil, self) |
auras:SetAllPoints(self.Health) |
auras.presentAlpha = 1 |
auras.missingAlpha = 0 |
auras.icons = {} |
for i, corner in pairs(corners) do |
local icon = CreateFrame("Frame", nil, auras) |
icon.spellID = corner.spellID |
if corner.action == "HARMFUL" then |
icon.anyUnit = true |
icon:SetWidth(20) |
icon:SetHeight(20) |
icon:SetPoint("CENTER",0,0) |
icon.PostCreateAuraIcon = PostIcon |
else |
local tex = icon:CreateTexture(nil, "BACKGROUND") |
tex:SetAllPoints(icon) |
local cd = CreateFrame("Cooldown", nil, icon) |
cd:SetAllPoints(icon) |
cd:SetReverse() |
icon.cd = cd |
icon:SetWidth(corner.width) |
icon:SetHeight(corner.height) |
icon:SetPoint(corner.point, 0, 0) |
tex:SetTexture(settings.indicator) |
tex:SetVertexColor(unpack(corner.color)) |
if corner.count == true then |
local count = icon:CreateFontString(nil, "OVERLAY") |
count:SetFont(settings.font, 10,"THINOUTLINE") |
count:SetPoint(corner.point, -7, 0) |
icon.count = count |
end |
icon.icon = tex |
end |
auras.icons[corner.spellID] = icon |
auras.icons[corner.spellID]:Hide() |
end |
self.AuraWatch = auras |
end |
local function check_threat(self,event,unit) |
if unit then |
if self.unit ~= unit then |
return |
end |
if self.Aggro then |
local threat = UnitThreatSituation(unit) |
if threat == 3 then |
self.Aggro:SetText("|cffFF0000AGGRO") |
self.Health:SetBackdropColor(1,0,0) |
elseif threat == 2 then |
self.Aggro:SetText("|cffFFAA00THREAT") |
self.Health:SetBackdropColor(1,0.6,0) |
else |
self.Aggro:SetText("") |
self.Health:SetBackdropColor(0,0,0) |
end |
end |
end |
end |
local function updateHealth(self, event, unit, bar, min, max) |
if (self.unit ~= unit) and unit then |
return |
end |
self.Name:SetText(UnitName(unit):sub(1, 12)) |
if (UnitIsDead(unit) or UnitIsGhost(unit) or not UnitIsConnected(unit)) then |
bar.value:SetText((UnitIsDead(unit) and 'Dead') or (UnitIsGhost(unit) and 'Ghost') or (not UnitIsConnected(unit) and 'Offline')) |
bar.value:SetTextColor(0.5, 0.5, 0.5) |
self.Health:SetStatusBarColor(0.5, 0.5, 0.5) |
else |
bar.value:SetText("") |
local color = RAID_CLASS_COLORS[select(2, UnitClass(unit))] |
if (color) then |
bar:SetStatusBarColor(color.r*0.6, color.g*0.6, color.b*0.6) |
bar.bg:SetVertexColor(color.r*0.2, color.g*0.2, color.b*0.2) |
end |
end |
end |
local powerbar = function(self) |
local pp = CreateFrame("StatusBar") |
pp:SetStatusBarTexture(settings.texture) |
pp:SetOrientation("VERTICAL") |
pp.colorPower = true |
pp.frequentUpdates = true |
pp:SetParent(self) |
pp:SetPoint("TOPLEFT", self.Health,"TOPRIGHT", 0, 0) |
pp:SetPoint("BOTTOMRIGHT", self.Health,"BOTTOMRIGHT", settings.RaidFrames.ManaBar, 0) |
self.Health:SetWidth(settings.RaidFrames.Width-settings.RaidFrames.ManaBar-4) |
self.Health:SetPoint("BOTTOMRIGHT",self,"BOTTOMRIGHT",-(settings.RaidFrames.ManaBar+2),2) |
local ppbg = pp:CreateTexture(nil, "BORDER") |
ppbg:SetAllPoints(pp) |
ppbg:SetTexture(settings.texture) |
ppbg:SetVertexColor(.1,.1,.1) |
ppbg.multiplier = .2 |
pp.bg = ppbg |
self.Power = pp |
end |
local stylefunc = function(self, unit) |
self:SetScript("OnEnter", UnitFrame_OnEnter) |
self:SetScript("OnLeave", UnitFrame_OnLeave) |
self:SetAttribute('initial-height', settings.RaidFrames.Height) |
self:SetAttribute('initial-width', settings.RaidFrames.Width) |
self.Health = CreateFrame("StatusBar",nil,self) |
self.Health:SetPoint("TOPLEFT",self,"TOPLEFT",2,-2) |
self.Health:SetPoint("BOTTOMRIGHT",self,"BOTTOMRIGHT",-2,2) |
self.Health:SetStatusBarTexture(settings.texture) |
self.Health:SetOrientation("VERTICAL") |
self.Health:SetBackdrop{ |
bgFile = 'Interface\\Buttons\\WHITE8x8', |
tile = true, |
tileSize = 16, |
insets = { |
left = -2, |
right = -2, |
top = -2, |
bottom = -2 |
}, |
} |
self.Health:SetBackdropColor(0, 0, 0) |
self.Health.bg = self.Health:CreateTexture(nil, "BORDER") |
self.Health.bg:SetAllPoints(self.Health) |
self.Health.bg:SetTexture(settings.texture) |
self.Health.value = self.Health:CreateFontString(nil, 'OVERLAY') |
self.Health.value:SetPoint('BOTTOM', 0, 5) |
self.Health.value:SetFont(settings.font, 10) |
self.Health.value:SetShadowOffset(1, -1) |
self.Name = self.Health:CreateFontString(nil, "ARTWORK") |
self.Name:SetPoint("LEFT", 2, 0) |
self.Name:SetPoint("RIGHT", -2, 0) |
self.Name:SetFont(settings.font, floor((settings.fsize/100)*90), "THINOUTLINE") |
self.Name:SetShadowColor(0,0,0,0) |
self.Name:SetTextColor(1, 1, 1) |
self.Aggro = self.Health:CreateFontString(nil, 'OVERLAY') |
self.Aggro:SetPoint('CENTER', self, 'TOP') |
self.Aggro:SetFont(settings.font, 8, 'THINOUTLINE') |
self.Aggro:SetShadowColor(0, 0, 0, 0) |
self.Aggro:SetTextColor(1, 1, 1) |
-- debuff icons |
self.Icon = CreateFrame('Frame', nil, self.Health) |
self.Icon:SetAllPoints(self.Health) |
self.Icon:SetFrameStrata("MEDIUM") |
self.Icon.Icon = self.Icon:CreateTexture(nil, 'ARTWORK') |
self.Icon.Icon:SetPoint('CENTER', self.Icon) |
self.Icon.Icon:SetHeight(20) |
self.Icon.Icon:SetWidth(20) |
self.Icon.Icon:SetTexCoord(0.07, 0.93, 0.07, 0.93) |
self.Icon.Count = self.Icon:CreateFontString(nil, 'OVERLAY') |
self.Icon.Count:SetPoint('BOTTOMRIGHT', self.Icon.Icon, 1, 0) |
self.Icon.Count:SetFont(settings.font, 10, 'THINOUTLINE') |
self.Icon.Count:SetShadowColor(0, 0, 0, 0) |
self.Icon.Count:SetTextColor(1, 1, 1) |
self.Icon.Border = self.Icon:CreateTexture(nil, 'BORDER') |
self.Icon.Border:SetPoint('CENTER', self.Health) |
self.Icon.Border:SetHeight(20 + 4) |
self.Icon.Border:SetWidth(20 + 4) |
self.Icon.Border:SetTexture(settings.buffTex) |
self.Icon.Border:SetVertexColor(1, 1, 1) |
self.Icon:Hide() |
if settings.powerbar == true then |
powerbar(self) |
end |
self:RegisterEvent("UNIT_DEAD", CheckDebuffs) |
self:RegisterEvent("UNIT_AURA", CheckDebuffs) |
self:RegisterEvent('PLAYER_TARGET_CHANGED', check_threat) |
self:RegisterEvent('UNIT_THREAT_LIST_UPDATE', check_threat) |
self:RegisterEvent('UNIT_THREAT_SITUATION_UPDATE', check_threat) |
if settings.cornerPoints == true then |
createAuraWatch(self,unit) |
end |
local ricon = self.Health:CreateTexture(nil, "OVERLAY") |
ricon:SetHeight(10) |
ricon:SetWidth(10) |
ricon:SetPoint("BOTTOM", self.Name, "TOP", 0, -1) |
ricon:SetTexture"Interface\\TargetingFrame\\UI-RaidTargetingIcons" |
self.RaidIcon = ricon |
if (not unit) then |
self.Range = true |
self.outsideRangeAlpha = 0.4 |
self.inRangeAlpha = 1 |
end |
self.PostUpdateHealth = updateHealth |
return self |
end |
oUF:RegisterStyle("ouf_raid", stylefunc) |
oUF:SetActiveStyle("ouf_raid") |
local function make_me_movable(f) |
f:SetMovable(true) |
f:SetUserPlaced(true) |
f:EnableMouse(true) |
f:RegisterForDrag("LeftButton","RightButton") |
f:SetScript("OnDragStart", function(self) self:StartMoving() end) |
f:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end) |
end |
local RaidDragFrame = CreateFrame("Frame","RaidDragFrame",UIParent) |
RaidDragFrame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 20, -20) |
RaidDragFrame:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 0, right = 0, top = 0, bottom = 0 }}) |
RaidDragFrame:SetWidth(settings.RaidFrames.Width/2) |
RaidDragFrame:SetHeight(10) |
RaidDragFrame:SetAlpha(0) |
RaidDragFrame:SetScript("OnEnter", function(self) self:SetAlpha(1) end) |
RaidDragFrame:SetScript("OnLeave", function(self) self:SetAlpha(0) end) |
RaidDragFrame:Show() |
make_me_movable(RaidDragFrame) |
local raid = oUF:Spawn('header', 'oUF_Raid', nil) |
raid:SetPoint("TOPLEFT", RaidDragFrame, "BOTTOMLEFT", -2, 0) |
raid:SetManyAttributes( |
'showPlayer', 1, |
'showSolo', 1, |
'showParty', 1, |
'showRaid', 1, |
'xoffset', 0, |
'yOffset', 0, |
'point', 'TOP', |
'groupFilter', '1,2,3,4,5,6,7,8', |
'groupingOrder', '1,2,3,4,5,6,7,8', |
'groupBy', 'GROUP', |
'maxColumns', 8, |
'unitsPerColumn', 5, |
'columnSpacing', 0, |
'columnAnchorPoint', 'LEFT' |
) |
raid:Show() |
local pets = oUF:Spawn('header', 'oUF_Pet', 'SecureGroupPetHeaderTemplate') |
pets:SetPoint('TOPLEFT', oUF_Raid, 'TOPRIGHT') |
pets:SetManyAttributes( |
'showSolo', 1, |
'showParty', 1, |
'showRaid', 1, |
'xoffset', 0, |
'yOffset', 0, |
'point', 'BOTTOM', |
'maxColumns', 5, |
'unitsPerColumn', 5, |
'columnSpacing', 0, |
'columnAnchorPoint', 'RIGHT' |
) |
pets:Show() |
--[[------------------------------------------------------------------------------------------------------ |
oUF_AuraWatch by Astromech |
Please leave comments, suggestions, and bug reports on this addon's WoWInterface page |
To setup, create a table with the following entries: |
icons |
A table of frames to be used as icons. oUF_Aurawatch does not position |
these frames, so you must do so yourself. Each icon needs a sid entry, |
which is the spell ID of the aura to watch. Table should be set up |
such that values are icon frames, but the keys can be anything. |
missingAlpha |
This is the alpha for icons not present on the unit. |
presentAlpha |
This is the alpha for icons present on the unit. |
onlyShowMissing |
If this is true, oUF_AW will hide icons if they are present on the unit. |
You can specify this in the icons as well for individual auras. |
onlyShowPresent |
If this is true, oUF_AW will hide icons if they are missing on the unit. |
You can specify this in the icons as well for individual auras. |
hideCooldown |
If this is true, oUF_AW will hide the cooldown frame |
fromUnits |
A table of units from which auras can originate from. Have the units be the keys |
and "true" be the values. If this is nil, oUF_AuraWatch will only display |
auras originating from units "player", "pet", and "vehicle." |
You can specify this in the icons as well for individual auras. |
anyUnit |
Set to true for oUF_AW to to show an aura no matter what unit it |
originates from. This will override any fromUnits setting. |
You can specify this in the icons as well for individual auras. |
PostCreateIcon |
A function to call when an icon is created to modify it, such as adding |
a border or repositioning the count fontstring. Leave as nil to ignore. |
The arguements are: icon, auraSpellID, auraName |
Here is an example of how to set oUF_AW up: |
local createAuraWatch = function(self, unit) |
if unit ~= "target" then return end |
-- We only want to create this for the target |
local auras = CreateFrame("Frame", nil, self) |
auras:SetWidth(24) |
auras.SetHeight(128) |
auras:SetPoint("BOTTOM", self, "TOP") |
-- A table of spellIDs to create icons for |
-- To find spellIDs, look up a spell on www.wowhead.com and look at the URL |
-- http://www.wowhead.com/?spell=SPELL_ID |
local spellIDs = { ... } |
auras.presentAlpha = 1 |
auras.expiredAlpha = .7 |
auras.PostCreateIcon = myCustomIconSkinnerFunction |
auras.icons = {} |
for i, sid in pairs(spellIDs) do |
local icon = CreateFrame("Frame", nil, auras) |
icon.spellID = sid |
icon:SetWidth(24) |
icon:SetHeight(24) |
icon:SetPoint("BOTTOM", auras, "BOTTOM", 0, 28 * i) |
auras.icons[sid] = icon |
end |
self.AuraWatch = auras |
end |
-----------------------------------------------------------------------------------------------------------]] |
local UnitBuff, UnitDebuff, UnitGUID = UnitBuff, UnitDebuff, UnitGUID |
local GUIDs = {} |
local PLAYER_UNITS = { |
player = true, |
vehicle = true, |
pet = true, |
} |
local setupGUID |
do |
local cache = setmetatable({}, {__type = "k"}) |
local frame = CreateFrame"Frame" |
frame:SetScript("OnEvent", function(self, event) |
for k,t in pairs(GUIDs) do |
GUIDs[k] = nil |
for a in pairs(t) do |
t[a] = nil |
end |
cache[t] = true |
end |
end) |
frame:RegisterEvent"PLAYER_REGEN_ENABLED" |
frame:RegisterEvent"PLAYER_ENTERING_WORLD" |
function setupGUID(guid) |
local t = next(cache) |
if t then |
cache[t] = nil |
else |
t = {} |
end |
GUIDs[guid] = t |
end |
end |
local function resetIcon(icon, frame, count, duration, remaining) |
if icon.onlyShowMissing then |
icon:Hide() |
else |
icon:Show() |
if not frame.hideCooldown and duration and duration > 0 then |
icon.cd:SetCooldown(remaining - duration, duration) |
icon.cd:Show() |
else |
icon.cd:Hide() |
end |
icon.count:SetText((count > 1 and count)) |
icon.overlay:Hide() |
icon:SetAlpha(frame.presentAlpha) |
end |
end |
local function expireIcon(icon, frame) |
if icon.onlyShowPresent then |
icon:Hide() |
else |
icon.cd:Hide() |
icon.count:SetText() |
icon:SetAlpha(frame.missingAlpha) |
icon.overlay:Show() |
icon:Show() |
end |
end |
local found = {} |
local function Update(frame, event, unit) |
if frame.unit ~= unit then return end |
local watch = frame.AuraWatch |
local index, icons = 1, watch.watched |
local name, rank, texture, count, type, duration, remaining, caster, key, icon |
local guid = UnitGUID(unit) |
if not GUIDs[guid] then setupGUID(guid) end |
for key, icon in pairs(icons) do |
icon:Hide() |
end |
while true do |
if index > 40 then |
name, rank, texture, count, type, duration, remaining, caster = UnitDebuff(unit, index-40) |
else |
name, rank, texture, count, type, duration, remaining, caster = UnitBuff(unit, index) |
end |
if not name then |
if index > 40 then |
break |
else |
index = 40 |
end |
else |
key = name..texture |
icon = icons[key] |
if icon and (icon.anyUnit or (caster and icon.fromUnits[caster])) then |
resetIcon(icon, watch, count, duration, remaining) |
GUIDs[guid][key] = true |
found[key] = true |
end |
end |
index = index + 1 |
end |
for key in pairs(GUIDs[guid]) do |
if icons[key] and not found[key] then |
expireIcon(icons[key], watch) |
end |
end |
for k in pairs(found) do |
found[k] = nil |
end |
end |
local function setupIcons(self) |
local frame = self.AuraWatch |
local icons = frame.icons |
frame.watched = {} |
if not frame.missingAlpha then frame.missingAlpha = 0.75 end |
if not frame.presentAlpha then frame.presentAlpha = 1 end |
for _,icon in pairs(icons) do |
local name, _, image = GetSpellInfo(icon.spellID) |
if not name then error("oUF_AuraWatch error: no spell with "..tostring(icon.spellID).." spell ID exists") end |
icon.name = name |
if not icon.cd then |
local cd = CreateFrame("Cooldown", nil, icon) |
cd:SetAllPoints(icon) |
icon.cd = cd |
end |
if not icon.icon then |
local tex = icon:CreateTexture(nil, "BACKGROUND") |
tex:SetAllPoints(icon) |
tex:SetTexture(image) |
icon.icon = tex |
end |
if not icon.count then |
local count = icon:CreateFontString(nil, "OVERLAY") |
count:SetFontObject(NumberFontNormal) |
count:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT", -1, 0) |
icon.count = count |
end |
if not icon.overlay then |
local overlay = icon:CreateTexture(nil, "OVERLAY") |
overlay:SetTexture"Interface\\Buttons\\UI-Debuff-Overlays" |
overlay:SetAllPoints(icon) |
overlay:SetTexCoord(.296875, .5703125, 0, .515625) |
overlay:SetVertexColor(1, 0, 0) |
icon.overlay = overlay |
end |
if icon.onlyShowMissing == nil then |
icon.onlyShowMissing = frame.onlyShowMissing |
end |
if icon.onlyShowPresent == nil then |
icon.onlyShowPresent = frame.onlyShowPresent |
end |
if icon.fromUnits == nil then |
icon.fromUnits = frame.fromUnits or PLAYER_UNITS |
end |
if icon.anyUnit == nil then |
icon.anyUnit = frame.anyUnit |
end |
frame.watched[name..image] = icon |
if frame.PostCreateIcon then frame:PostCreateIcon(icon, icon.spellID, name) end |
end |
end |
local function Enable(self) |
if self.AuraWatch then |
self:RegisterEvent("UNIT_AURA", Update) |
setupIcons(self) |
return true |
else |
return false |
end |
end |
local function Disable(self) |
if self.AuraWatch then |
self:UnregisterEvent("UNIT_AURA", Update) |
for _,icon in pairs(self.AuraWatch.icons) do |
icon:Hide() |
end |
end |
end |
oUF:AddElement("AuraWatch", Update, Enable, Disable) |
for i, frame in ipairs(oUF.objects) do Enable(frame) end |
-- variables |
local settings = oUF_Settings |
local gsub = string.gsub |
local ipairs = _G.ipairs |
local pairs = _G.pairs |
local fmt = _G.string.format |
local sub = _G.string.sub |
local hooks = {} |
local h |
local buffer = {} |
local lastMessageID = {0, 0, 0, 0, 0, 0, 0} |
local bufferSize = 128 |
local _G = getfenv(0) |
local date = date |
local currentLink = nil |
local ref = _G["SetItemRef"] |
local tlds = { |
COM = true, |
UK = true, |
NET = true, |
INFO = true, |
CO = true, |
DE = true, |
FR = true, |
ES = true, |
BE = true, |
CC = true, |
US = true, |
KO = true, |
CH = true, |
TW = true, |
RU = true, |
} |
local style = "|cffffffff|Hurl:%s|h[%s]|h|r" |
local tokennum, matchTable = 1, {} |
-- |
--[[ Buttons ]]-- |
local dummy = function() end |
ChatFrameMenuButton:Hide() -- Menu button |
for i = 1, 7 do |
local u = _G["ChatFrame"..i.."UpButton"] -- Scroll Up button |
u:Hide() -- Delete these 2 lines if you don't want to hide this button |
u.Show = dummy -- Delete these 2 lines if you don't want to hide this button |
local d = _G["ChatFrame"..i.."DownButton"] -- Scroll Down button |
d:Hide() |
d.Show = dummy |
local b = _G["ChatFrame"..i.."BottomButton"] -- Scroll to bottom button |
b:Hide() |
b.Show = dummy |
end |
--[[ Channel names ]]-- |
CHAT_GUILD_GET = "|Hchannel:Guild|h[G]|h %s " |
CHAT_RAID_GET = "|Hchannel:raid|h[R]|h %s " |
CHAT_PARTY_GET = "|Hchannel:Party|h[P]|h %s " |
CHAT_RAID_WARNING_GET = "[RW] %s " |
CHAT_RAID_LEADER_GET = "|Hchannel:raid|h[RL]|h %s " |
CHAT_OFFICER_GET = "|Hchannel:o|h[O]|h %s " |
CHAT_BATTLEGROUND_GET = "|Hchannel:Battleground|h[BG]|h %s " |
CHAT_BATTLEGROUND_LEADER_GET = "|Hchannel:Battleground|h[BGL]|h %s " |
CHAT_WHISPER_INFORM_GET = "To %s " |
CHAT_WHISPER_GET = "From %s " |
CHAT_SAY_GET = "%s " |
CHAT_YELL_GET = "%s " |
CHAT_FLAG_AFK = "[AFK] " |
CHAT_FLAG_DND = "[DND] " |
CHAT_FLAG_GM = "[GM] " |
--[[ Editing custon channels here (general, trade etc) ]] |
local str = "[%d|h] %3$s" -- pattern. Returns "[1] [Name] text", where 1 is channel number. |
local channel = function(...) |
return str:format(...) |
end |
--[[ Chat copy ]]-- |
local function AddMessage(frame, text, ...) |
text = text:gsub("|Hchannel:(%d+)|h%[?(.-)%]?|h.+(|Hplayer.+)", channel) |
if (text) then |
local chatFrameID = tonumber(strsub(frame:GetName(), 10)) |
local messageID = lastMessageID[chatFrameID] + 1 |
lastMessageID[chatFrameID] = messageID |
buffer[math.fmod(messageID - 1, bufferSize) + (1 + ((chatFrameID - 1) * bufferSize))] = text |
text = "|cffaabb00|Hcopybutton:"..chatFrameID..":"..messageID.."|h#|h|r "..text |
return hooks[frame](frame, text, ...) |
else |
return |
end |
end |
for i = 1, 7 do |
if(i ~= 2) then -- skip combatlog |
h = _G["ChatFrame"..i] |
hooks[h] = h.AddMessage |
h.AddMessage = AddMessage |
end |
end |
local ref = SetItemRef |
SetItemRef = function(link, text, button) |
if sub(link, 1, 3) == "url" then |
currentLink = sub(link, 5) |
StaticPopup_Show("BCMUrlCopyDialog") |
return |
end |
if (strsub(link, 1, 11) ~= "copybutton:") then |
return ref(link, text, button) |
end |
local function strip(str) |
str = gsub(str, "|Hplayer:.-%[(.-)%]|h", "%1") |
str = gsub(str, "(|c%x%x%x%x%x%x%x%x(.-)|r)", function (full, text) |
if not strmatch(text, "^|H.-|h$") then |
return text |
end |
end) |
return str |
end |
local chatFrameID, messageID = strmatch(link, "^copybutton:(%d+):(%d+)$") |
local text = strip(buffer[math.fmod(messageID - 1, bufferSize) + (1 + ((chatFrameID - 1) * bufferSize))]) |
local editbox = _G["ChatFrameEditBox"] |
if text and editbox then |
editbox:SetText(text) |
editbox:Show() |
editbox:SetFocus() |
end |
end |
--[[ Editbox ]]-- |
local eb = ChatFrameEditBox |
eb:ClearAllPoints() |
eb:SetAltArrowKeyMode(false) |
eb:SetPoint("BOTTOMLEFT", ChatFrame1, "TOPLEFT", -5, 18) |
eb:SetPoint("BOTTOMRIGHT", ChatFrame1, "TOPRIGHT", 5, 18) |
local a, b, c = select(6, eb:GetRegions()) |
a:Hide(); b:Hide(); c:Hide() |
local ebbg = eb:CreateTexture(nil, "BACKGROUND") |
ebbg:SetPoint("BOTTOMRIGHT", -5, 5) |
ebbg:SetPoint("TOPLEFT", 5, -5) |
ebbg:SetTexture(0, 0, 0, .4) |
--[[ Scroll ]]-- |
local scroll = function(self, dir) |
if(dir > 0) then |
if(IsShiftKeyDown()) then |
self:ScrollToTop() |
else |
self:ScrollUp() |
end |
elseif(dir < 0) then |
if(IsShiftKeyDown()) then |
self:ScrollToBottom() |
else |
self:ScrollDown() |
end |
end |
end |
for i = 1, 7 do |
local cf = _G["ChatFrame"..i] |
cf:EnableMouseWheel(true) |
cf:SetScript("OnMouseWheel", scroll) |
end |
--[[ Sticky ]] -- |
ChatTypeInfo["YELL"].sticky = 1 |
ChatTypeInfo["OFFICER"].sticky = 1 |
ChatTypeInfo["WHISPER"].sticky = 1 |
ChatTypeInfo["CHANNEL"].sticky = 1 |
ChatTypeInfo["RAID_WARNING"].sticky = 1 |
--[[ Url copy ]]-- |
local function RegisterMatch(text) |
local token = "\255\254\253"..tokennum.."\253\254\255" |
matchTable[token] = strreplace(text, "%", "%%") |
tokennum = tokennum + 1 |
return token |
end |
local function Link(link, ...) |
if not link then |
return "" |
end |
return RegisterMatch(fmt(style, link, link)) |
end |
local function Link_TLD(link, tld, ...) |
if not link or not tld then |
return "" |
end |
if tlds[strupper(tld)] then |
return RegisterMatch(fmt(style, link, link)) |
else |
return RegisterMatch(link) |
end |
end |
local patterns = { |
-- X://Y url |
{ pattern = "^(%a[%w%.+-]+://%S+)", matchfunc=Link}, |
{ pattern = "%f[%S](%a[%w%.+-]+://%S+)", matchfunc=Link}, |
-- www.X.Y url |
{ pattern = "^(www%.[%w_-%%]+%.%S+)", matchfunc=Link}, |
{ pattern = "%f[%S](www%.[%w_-%%]+%.%S+)", matchfunc=Link}, |
-- X@Y.Z email |
{ pattern = "(%S+@[%w_-%%%.]+%.(%a%a+))", matchfunc=Link_TLD}, |
-- X.Y.Z/WWWWW url with path |
{ pattern = "^([%w_-%%%.]+[%w_-%%]%.(%a%a+)/%S+)", matchfunc=Link_TLD}, |
{ pattern = "%f[%S]([%w_-%%%.]+[%w_-%%]%.(%a%a+)/%S+)", matchfunc=Link_TLD}, |
-- X.Y.Z url |
{ pattern = "^([%w_-%%%.]+[%w_-%%]%.(%a%a+))", matchfunc=Link_TLD}, |
{ pattern = "%f[%S]([%w_-%%%.]+[%w_-%%]%.(%a%a+))", matchfunc=Link_TLD}, |
} |
local function filterFunc(self, event, msg, ...) |
for _, v in ipairs(patterns) do |
msg = gsub(msg, v.pattern, v.matchfunc) |
end |
for k,v in pairs(matchTable) do |
msg = gsub(msg, k, v) |
matchTable[k] = nil |
end |
return false, msg, ... |
end |
local function AddEvents() |
local events = { |
"CHAT_MSG_CHANNEL", "CHAT_MSG_YELL", |
"CHAT_MSG_GUILD", "CHAT_MSG_OFFICER", |
"CHAT_MSG_PARTY", "CHAT_MSG_RAID", |
"CHAT_MSG_RAID_LEADER", |
"CHAT_MSG_SAY", "CHAT_MSG_WHISPER", |
} |
for _,event in ipairs(events) do |
ChatFrame_AddMessageEventFilter(event, filterFunc) |
end |
end |
AddEvents() |
--Popup Box |
StaticPopupDialogs["BCMUrlCopyDialog"] = { |
text = "URL", |
button2 = TEXT(CLOSE), |
hasEditBox = 1, |
hasWideEditBox = 1, |
showAlert = 1, |
OnShow = function() |
local editBox = _G[this:GetName().."WideEditBox"] |
editBox:SetText(currentLink) |
editBox:SetFocus() |
editBox:HighlightText(0) |
local button = _G[this:GetName().."Button2"] |
button:ClearAllPoints() |
button:SetWidth(200) |
button:SetPoint("CENTER", editBox, "CENTER", 0, -30) |
_G[this:GetName().."AlertIcon"]:Hide() |
end, |
EditBoxOnEscapePressed = function() this:GetParent():Hide() end, |
timeout = 0, |
whileDead = 1, |
hideOnEscape = 1, |
} |
--[[ Extras ]]-- |
local chatsetup = CreateFrame("Frame") |
chatsetup:RegisterEvent("PLAYER_ENTERING_WORLD") |
chatsetup:SetScript("OnEvent", function(self, event) |
chatsetup:UnregisterEvent("PLAYER_ENTERING_WORLD") |
for i = 1, 7 do |
_G["ChatFrame"..i.."TabLeft"]:Hide() |
_G["ChatFrame"..i.."TabRight"]:Hide() |
_G["ChatFrame"..i.."TabMiddle"]:Hide() |
_G["ChatFrame"..i.."TabText"]:SetFont(settings.font, 12, "THINOUTLINE") |
_G["ChatFrame"..i.."ResizeRightTexture"]:SetAlpha(0) |
_G["ChatFrame"..i.."ResizeRightTexture"].SetAlpha = function() return end |
_G["ChatFrame"..i.."ResizeLeftTexture"]:SetAlpha(0) |
_G["ChatFrame"..i.."ResizeLeftTexture"].SetAlpha = function() return end |
_G["ChatFrame"..i.."ResizeTopTexture"]:SetAlpha(0) |
_G["ChatFrame"..i.."ResizeTopTexture"].SetAlpha = function() return end |
_G["ChatFrame"..i.."ResizeBottomTexture"]:SetAlpha(0) |
_G["ChatFrame"..i.."ResizeBottomTexture"].SetAlpha = function() return end |
_G["ChatFrame"..i.."ResizeTopRightTexture"]:SetAlpha(0) |
_G["ChatFrame"..i.."ResizeTopRightTexture"].SetAlpha = function() return end |
_G["ChatFrame"..i.."ResizeTopLeftTexture"]:SetAlpha(0) |
_G["ChatFrame"..i.."ResizeTopLeftTexture"].SetAlpha = function() return end |
_G["ChatFrame"..i.."ResizeBottomRightTexture"]:SetAlpha(0) |
_G["ChatFrame"..i.."ResizeBottomRightTexture"].SetAlpha = function() return end |
_G["ChatFrame"..i.."ResizeBottomLeftTexture"]:SetAlpha(0) |
_G["ChatFrame"..i.."ResizeBottomLeftTexture"].SetAlpha = function() return end |
_G["ChatFrame"..i.."Background"]:SetTexture(settings.texture) |
_G["ChatFrame"..i.."Background"].SetTexture = function() return end |
_G["ChatFrame"..i.."Background"]:SetAlpha(settings.chatalpha) |
_G["ChatFrame"..i.."Background"].SetAlpha = function() return end |
_G["ChatFrame"..i.."Background"]:SetVertexColor(unpack(settings.chatcolor)) |
_G["ChatFrame"..i.."Background"].SetVertexColor = function() return end |
local bg = _G["ChatFrame"..i]:CreateTexture(nil, "BACKGROUND") |
bg:SetTexture(0,0,0) |
bg:SetPoint("TOPLEFT", _G["ChatFrame"..i], "TOPLEFT", -4, 5) |
bg:SetPoint("BOTTOMRIGHT", _G["ChatFrame"..i], "BOTTOMRIGHT", 4, -8) |
end |
end) |
nMainbar = { |
MainMenuBar = { |
scale = 0.8, |
shortBar = true, |
}, |
vehicle = { |
scale = 1, |
}, |
petbar = { |
mouseover = false, |
scale = 1, |
alpha = 1, |
}, |
possessbar = { |
scale = 1, |
alpha = 1, |
}, |
stanceBar = { |
mouseover = false, |
hide = false, |
scale = 1.3, |
alpha = 1, |
}, |
multiBarLeft = { |
mouseover = true, |
alpha = 1, |
}, |
multiBarRight = { |
mouseover = true, |
alpha = 1, |
}, |
multiBarBottomLeft = { |
mouseover = false, |
alpha = 1, |
}, |
multiBarBottomRight = { |
mouseover = false, |
alpha = 1, |
}, |
totemManager = { |
scale = 1, |
alpha = 1, |
hideRecallButton = false, |
}, |
} |
local bars = { |
"MainMenuBarArtFrame", |
"MultiBarBottomLeft", |
"MultiBarBottomRight", |
"MultiBarRight", |
"MultiBarLeft", |
"BonusActionBarFrame", |
"ShapeshiftBarFrame", |
"PossessBarFrame", |
} |
function clearTextures(frame) |
for i = 1, select('#', frame:GetRegions()) do |
local texture = select(i, frame:GetRegions()) |
if (texture and texture:GetObjectType() == 'Texture') then |
texture:Hide() |
end |
end |
end |
for i, v in ipairs(bars) do |
local bar = getglobal(v) |
bar:SetAttribute("unit2", "player") |
end |
local f = CreateFrame("frame","RightClickSelfCast",UIParent) |
f:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end) |
function f:PLAYER_LOGIN() |
self:UnregisterEvent("PLAYER_LOGIN") |
self.PLAYER_LOGIN = nil |
--this is for the mod ExtraBar (Author: Cowmonster) |
--http://www.wowinterface.com/downloads/info14492-ExtraBar.html |
for id=1, 12 do |
local button = getglobal("ExtraBarButton"..id) |
if button ~= nil then |
button:SetAttribute("unit2", "player") |
end |
end |
--this is for the mod ExtraBars (Author: Alternator) |
--http://www.wowinterface.com/downloads/info13335-ExtraBars.html |
for id=1, 4 do |
local frame = getglobal("ExtraBar"..id) |
if frame ~= nil then |
frame:SetAttribute("unit2", "player") |
for bid=1, 12 do |
local button = getglobal("ExtraBar"..id.."Button"..bid) |
if button ~= nil then |
button:SetAttribute("unit2", "player") |
end |
end |
end |
end |
end |
if IsLoggedIn() then f:PLAYER_LOGIN() else f:RegisterEvent("PLAYER_LOGIN") end |
if (nMainbar.MainMenuBar.shortBar) then |
MultiBarBottomLeft:ClearAllPoints() |
MultiBarBottomLeft:SetPoint('BOTTOMLEFT', ActionButton1, 'TOPLEFT', 0, 6) |
MultiBarBottomLeft.SetPoint = function() end |
MultiBarBottomRight:ClearAllPoints() |
MultiBarBottomRight:SetPoint('BOTTOM', MultiBarBottomLeft, 'TOP', 0, 4) |
MultiBarBottomRight.SetPoint = function() end |
function ShapeshiftBar_Update() |
ShapeshiftBar_UpdateState() |
end |
for _, frame in pairs({ |
'MultiBarRight', |
'MultiBarBottomRight', |
'ShapeshiftBarFrame', |
'PossessBarFrame', |
'MULTICASTACTIONBAR_YPOS', |
'MultiCastActionBarFrame', |
'PETACTIONBAR_YPOS', |
}) do |
UIPARENT_MANAGED_FRAME_POSITIONS[frame] = nil |
end |
for _, frame in pairs({ |
_G['PetActionBarFrame'], |
_G['ShapeshiftBarFrame'], |
_G['PossessBarFrame'], |
_G['MultiCastActionBarFrame'], |
}) do |
frame:SetMovable(true) |
frame:SetUserPlaced(true) |
frame:EnableMouse(false) |
end |
-- ----------------------------------- |
-- make the new totemmanager moveable |
-- ----------------------------------- |
local f = CreateFrame('Frame', 'MultiCastActionBarFrameAnchor') |
f:RegisterEvent('PLAYER_ENTERING_WORLD') |
f:SetHeight(10) |
f:SetWidth(10) |
f:SetScript('OnEvent', function(self, event) |
MultiCastActionBarFrame:ClearAllPoints() |
MultiCastActionBarFrame:SetPoint('CENTER', MultiCastActionBarFrameAnchor) |
MultiCastActionBarFrame.SetPoint = function() end |
self:UnregisterAllEvents() |
end) |
for i = 1, 12 do |
for _, button in pairs({ |
_G['MultiCastActionButton'..i], |
_G['MultiCastSlotButton1'], |
_G['MultiCastSlotButton2'], |
_G['MultiCastSlotButton3'], |
_G['MultiCastSlotButton4'], |
_G['MultiCastRecallSpellButton'], |
_G['MultiCastSummonSpellButton'], |
}) do |
MultiCastActionBarFrameAnchor:ClearAllPoints() |
MultiCastActionBarFrameAnchor:SetPoint('CENTER', UIParent) |
MultiCastActionBarFrameAnchor:SetMovable(true) |
MultiCastActionBarFrameAnchor:SetUserPlaced(true) |
button:RegisterForDrag('LeftButton') |
button:HookScript('OnDragStart', function() |
if (IsControlKeyDown()) then |
MultiCastActionBarFrameAnchor:StartMoving() |
end |
end) |
button:HookScript('OnDragStop', function() |
MultiCastActionBarFrameAnchor:StopMovingOrSizing() |
end) |
end |
end |
for i = 1, 12 do |
for _, button in pairs({ |
_G['MultiCastActionButton'..i], |
_G['MultiCastSlotButton1'], |
_G['MultiCastSlotButton2'], |
_G['MultiCastSlotButton3'], |
_G['MultiCastSlotButton4'], |
_G['MultiCastRecallSpellButton'], |
_G['MultiCastSummonSpellButton'], |
_G['MultiCastActionBarFrame'], |
}) do |
button:SetScale(nMainbar.totemManager.scale) |
button:SetAlpha(nMainbar.totemManager.alpha) |
end |
end |
MultiCastActionButton1:ClearAllPoints() |
MultiCastActionButton1:SetPoint('CENTER', MultiCastSlotButton1) |
MultiCastActionButton5:ClearAllPoints() |
MultiCastActionButton5:SetPoint('CENTER', MultiCastSlotButton1) |
MultiCastActionButton9:ClearAllPoints() |
MultiCastActionButton9:SetPoint('CENTER', MultiCastSlotButton1) |
hooksecurefunc('MultiCastFlyoutFrame_LoadSlotSpells', function(self, slot, ...) |
local numSpells = select('#', ...) |
if (numSpells == 0) then |
return false |
end |
numSpells = numSpells + 1 |
for i = 2, numSpells do |
_G['MultiCastFlyoutButton'..i..'Icon']:SetTexCoord(0.1, 0.9, 0.1, 0.9) |
end |
end) |
MultiCastFlyoutFrame:SetScale(nMainbar.totemManager.scale * 1.1) |
if (nMainbar.totemManager.hideRecallButton) then |
MultiCastRecallSpellButton:SetAlpha(0) |
MultiCastRecallSpellButton.SetAlpha = function() end |
MultiCastRecallSpellButton:EnableMouse(false) |
MultiCastRecallSpellButton.EnableMouse = function() end |
end |
-- ----------------------------------- |
-- moveable bars |
-- ----------------------------------- |
for _, button in pairs({ |
_G['PossessButton1'], |
_G['PetActionButton1'], |
_G['ShapeshiftButton1'], |
}) do |
button:ClearAllPoints() |
button:SetPoint('CENTER', UIParent) |
button:SetMovable(true) |
button:SetUserPlaced(true) |
button:RegisterForDrag('LeftButton') |
button:HookScript('OnDragStart', function(self) |
if (IsShiftKeyDown() and IsAltKeyDown()) then |
self:StartMoving() |
end |
end) |
button:HookScript('OnDragStop', function(self) |
self:StopMovingOrSizing() |
end) |
end |
for _, button in pairs({ |
_G['ActionBarUpButton'], |
_G['ActionBarDownButton'], |
_G['MainMenuBarBackpackButton'], |
_G['KeyRingButton'], |
_G['CharacterBag0Slot'], |
_G['CharacterBag1Slot'], |
_G['CharacterBag2Slot'], |
_G['CharacterBag3Slot'], |
}) do |
button:SetAlpha(0) |
button:EnableMouse(false) |
end |
local f = CreateFrame('Frame') |
f:Hide() |
for i = 2, 3 do |
for _, texture in pairs({ |
_G['MainMenuBarTexture'..i], |
_G['MainMenuMaxLevelBar'..i], |
_G['MainMenuXPBarTexture'..i], |
_G['ReputationWatchBarTexture'..i], |
_G['ReputationXPBarTexture'..i], |
_G['MainMenuBarPageNumber'], |
_G['SlidingActionBarTexture0'], |
_G['SlidingActionBarTexture1'], |
_G['ShapeshiftBarLeft'], |
_G['ShapeshiftBarMiddle'], |
_G['ShapeshiftBarRight'], |
_G['PossessBackground1'], |
_G['PossessBackground2'], |
_G['MainMenuExpBar'], |
_G["ReputationWatchBar"], |
_G["VehicleMenuBarHealthBar"], |
_G["VehicleMenuBarPowerBar"], |
}) do |
texture:SetParent(f) |
end |
end |
for _, bar in pairs({ |
_G['MainMenuBar'], |
_G['MainMenuExpBar'], |
_G['MainMenuBarMaxLevelBar'], |
_G['ReputationWatchStatusBar'], |
_G['ReputationWatchBar'], |
}) do |
bar:SetWidth(512) |
end |
for _, texture in pairs ( |
{ |
_G["MainMenuBarTexture0"], |
_G["MainMenuBarTexture1"], |
_G["MainMenuBarTexture2"], |
_G["MainMenuMaxLevelBar0"], |
_G["MainMenuXPBarTexture0"], |
_G["MainMenuXPBarTexture1"], |
_G["MainMenuXPBarTexture2"], |
_G["MainMenuXPBarTexture3"], |
_G["MainMenuBarLeftEndCap"], |
_G["MainMenuBarRightEndCap"], |
_G["BonusActionBarTexture0"], |
_G["BonusActionBarTexture1"], |
_G["MainMenuMaxLevelBar0"], |
_G["MainMenuMaxLevelBar1"], |
_G["MainMenuMaxLevelBar2"], |
_G["MainMenuMaxLevelBar3"], |
_G["ExhaustionTickNormal"], |
_G["ExhaustionTickHighlight"], |
_G["ExhaustionLevelFillBar"], |
} |
) do |
texture:Hide() |
end |
clearTextures(MainMenuBar) |
clearTextures(VehicleMenuBarArtFrame) |
CharacterMicroButton:ClearAllPoints() |
CharacterMicroButton:SetPoint('BOTTOMLEFT', 9000, 9000) |
SocialsMicroButton:ClearAllPoints() |
SocialsMicroButton:SetPoint('TOPLEFT', CharacterMicroButton, 'BOTTOMLEFT', 0, 20) |
hooksecurefunc('VehicleMenuBar_MoveMicroButtons', function() |
if (not self) then |
CharacterMicroButton:ClearAllPoints() |
CharacterMicroButton:SetPoint('BOTTOMLEFT', 9000, 9000) |
elseif (self == 'Mechanical') then |
CharacterMicroButton:ClearAllPoints() |
CharacterMicroButton:SetPoint('BOTTOMLEFT', VehicleMenuBar, 'BOTTOMRIGHT', -340, 41) |
elseif (self == 'Natural') then |
CharacterMicroButton:ClearAllPoints() |
CharacterMicroButton:SetPoint('BOTTOMLEFT', VehicleMenuBar, 'BOTTOMRIGHT', -340, 41) |
end |
end) |
end |
local function GetNumShapeSlots() |
local _, class = UnitClass('Player') |
if (class == 'DEATHKNIGHT' or class == 'WARRIOR') then |
return 3 |
elseif (class == 'ROGUE') then |
return 1 |
else |
return 10 |
end |
end |
-- if you move the bar you get some problems, so what can we make? We move the buttons! |
do |
MultiBarRightButton1:ClearAllPoints() |
MultiBarRightButton1:SetPoint('TOPRIGHT', UIParent, 'RIGHT', -6, (MultiBarRight:GetHeight() / 2)) |
MultiBarLeftButton1:ClearAllPoints() |
MultiBarLeftButton1:SetPoint('TOPRIGHT', MultiBarRightButton1, 'TOPLEFT', -6, 0) |
end |
if (nMainbar.stanceBar.hide) then |
for i = 1, NUM_SHAPESHIFT_SLOTS do |
local button = _G['ShapeshiftButton'..i] |
button:SetAlpha(0) |
button.SetAlpha = function() end |
button:EnableMouse(false) |
button.EnableMouse = function() end |
end |
end |
local function EnableMouseOver(self, bar, min, max, alpha) |
local minAlpha = 0 |
for i = min, max do |
local button = _G[self..i] |
local f = CreateFrame('Frame', bar, bar) |
f:RegisterEvent('PLAYER_LOGIN') |
f:SetFrameStrata('LOW') |
f:SetFrameLevel(1) |
f:EnableMouse() |
f:SetPoint('TOPLEFT', self..min, -5, 5) |
f:SetPoint('BOTTOMRIGHT', self..max, 5, 5) |
f:SetScript('OnEvent', function(self) |
bar:SetAlpha(minAlpha) |
self:UnregisterAllEvents() |
end) |
f:SetScript('OnEnter', function() |
bar:SetAlpha(alpha) |
end) |
f:SetScript('OnLeave', function() |
if (not MouseIsOver(button)) then |
bar:SetAlpha(minAlpha) |
end |
end) |
button:HookScript('OnEnter', function() |
bar:SetAlpha(alpha) |
end) |
button:HookScript('OnLeave', function() |
if (not MouseIsOver(bar)) then |
bar:SetAlpha(minAlpha) |
end |
end) |
end |
end |
if (nMainbar.multiBarLeft.mouseover) then |
EnableMouseOver('MultiBarLeftButton', MultiBarLeft, 1, 12, nMainbar.multiBarLeft.alpha) |
end |
if (nMainbar.multiBarRight.mouseover) then |
EnableMouseOver('MultiBarRightButton', MultiBarRight, 1, 12, nMainbar.multiBarRight.alpha) |
end |
if (nMainbar.multiBarBottomLeft.mouseover) then |
EnableMouseOver('MultiBarBottomLeftButton', MultiBarBottomLeft, 1, 12, nMainbar.multiBarBottomLeft.alpha) |
end |
if (nMainbar.multiBarBottomRight.mouseover) then |
EnableMouseOver('MultiBarBottomRightButton', MultiBarBottomRight, 1, 12, nMainbar.multiBarBottomRight.alpha) |
end |
if (nMainbar.petbar.mouseover) then |
PetActionBarFrame:SetFrameStrata('HIGH') |
EnableMouseOver('PetActionButton', PetActionBarFrame, 1, 10, nMainbar.petbar.alpha) |
end |
if (nMainbar.stanceBar.mouseover) then |
ShapeshiftBarFrame:SetFrameStrata('HIGH') |
EnableMouseOver('ShapeshiftButton', ShapeshiftBarFrame, 1, GetNumShapeSlots(), nMainbar.stanceBar.alpha) |
end |
## Interface: 30300 |
## Title: |cffee00ffFernir's UI|r |
## Notes: Fernir's UI |
## Version: 1.0 |
## SavedVariables: fdb |
oUF\oUF.xml |
settings.lua |
core.lua |
binder.lua |
actionbars.lua |
actionbars_style.lua |
chat.lua |
minimap.lua |
combattext.lua |
helpers.lua |
ntooltip.lua |
caelnameplates.lua |
teksLoot.lua |
butsu.lua |
#win.lua |
omnicc.lua |
unitframes.lua |
raid.lua |
aurawatch.lua |
fernir_UI = CreateFrame("Frame", nil, UIParent) |
fernir_UI:Show() |
--[[ Options start here ]] |
local _G = getfenv(0) |
local guildtable = {} |
local objects = {} |
local get_guild = "# / #" |
local tcolor = "637eae" |
local settings = oUF_Settings |
local objCount = 12 |
local damage, ctime, stime = 0, 0, 0 |
--[[ Options end ]] |
SlashCmdList.RELOADUI = ReloadUI |
SLASH_RELOADUI1 = "/rl" |
SLASH_RELOADUI2 = "/кд" |
SlashCmdList.RCSLASH = DoReadyCheck |
SLASH_RCSLASH1 = "/rc" |
SLASH_RCSLASH2 = "/кÑ" |
util = { |
round = function(val, num) return (floor(val*10*num))/(10*num) end, |
rgbt2str = function(col) local r, g, b = unpack(col) return format("|cff%02x%02x%02x", r*255, g*255, b*255) end, |
rgb2str = function(r, g, b) return format("|cff%02x%02x%02x", r*255, g*255, b*255) end, |
money = function(val) return format("|cffffd700%d|r.|cffbbbbdd%d|r.|cffeda55f%d|r", mod(val/10000, 10000), mod(val/100, 100), mod(val, 100)) end, |
level = function(val) |
local lcol = GetDifficultyColor(val) |
if not lcol then return 1, 1, 1 end |
return lcol.r, lcol.g, lcol.b |
end, |
letter = function(value) |
if value then |
if value < 1 then |
return string.format("%.2f", value) |
elseif value >= 10000000 then |
return string.format("%.1fm", value / 1000000) |
elseif value >= 1000000 then |
return string.format("%.2fm", value / 1000000) |
elseif value >= 100000 then |
return string.format("%.0fk", value / 1000) |
elseif value >= 10000 then |
return string.format("%.1fk", value / 1000) |
else |
return math.ceil(value) |
end |
end |
end, |
gradient_s = function(val, bad, good) |
gradient = function(val, bad, good) |
local percent, r, g |
if (good > bad) then |
percent = val/(good-bad) |
else |
percent = 1-val/(bad-good) |
end |
if (percent > 1) then percent = 1 end |
if (percent < 0) then percent = 0 end |
if(percent < 0.5) then r, g = 1, 2*percent else r, g = (1-percent)*2, 1 end |
return r, g, 0 |
end |
return util.rgb2str(gradient(val, bad, good))..val.."|r" |
end, |
} |
local line = function(m1, m2) GameTooltip:AddDoubleLine(m1, m2, 0.5, 02, 0.7, 0.7, 0.7, 0.2) end |
local space = function() GameTooltip:AddLine("\n") end |
local aFrame = CreateFrame("Frame", "fernir_UI_Window", MinimapCanvas) |
local createFs = function(parent, justify, ownfsize) |
local f = parent:CreateFontString(nil, "OVERLAY") |
f:SetFont(settings.font, ownfsize or settings.fsize, "THINOUTLINE") |
if(justify) then f:SetJustifyH(justify) end |
return f |
end |
fernir_UI.PLAYER_LOGIN = function(self, ...) |
if (settings.UIScale) then |
local index = GetCurrentResolution() |
local resolution = select(index, GetScreenResolutions()) |
if(resolution == "1680x1050" or resolution == "1920x1080" or resolution == "1920x1200" or resolution == "1600x900" or resolution == "1440x900") then |
SetCVar("useUiScale", 1) |
SetCVar("uiScale", 768/string.match(({GetScreenResolutions()})[GetCurrentResolution()], "%d+x(%d+)")) |
else |
print("Current resolution:", resolution) |
SetCVar("useUiScale", 0) |
StaticPopup_Show("DISABLE_UI") |
end |
end |
end |
fernir_UI.ADDON_LOADED = function(self, ...) |
if arg1 ~= "fernir_UI" then |
return |
end |
--[[ Changing some variables ]] |
SetCVar("screenshotQuality", 10) |
SetCVar("cameraDistanceMax", 50) |
SetCVar("cameraDistanceMaxFactor", 3.4) |
aFrame:SetFrameStrata("BACKGROUND") |
local tt = aFrame:CreateTexture(nil, "BACKGROUND") |
tt:SetTexture(settings.texture) |
tt:SetVertexColor(.2, .2, .2, .4) |
tt:SetAllPoints(aFrame) |
aFrame:SetPoint("TOPLEFT", UIParent) |
aFrame:SetPoint("TOPRIGHT", UIParent) |
aFrame:SetHeight(15) |
aFrame:Show() |
cString("gold") |
cString("dura", "progress", 0, 100) |
cString("lag") |
cString("guild", show_guild) |
cString("loot") |
cString("xp", "progress", 0, 100) |
cString("mem", show_addons) |
cString("wgtime") |
cString("honor") |
cString("fps", "progress", 0, 200) |
cString("dps") |
cString("zone") |
checkStats() |
for i, object in pairs(objects) do |
object.bar:SetWidth(object.text:GetStringWidth()+30) |
end |
--GuildRoster() |
fernir_UI.GUILD_ROSTER_UPDATE() |
updFrame = CreateFrame("Frame") |
updFrame.timeSinceLastUpdate = 0 |
updFrame:SetScript("OnUpdate", function(this, elapsed) |
updFrame.timeSinceLastUpdate = updFrame.timeSinceLastUpdate + elapsed |
if (updFrame.timeSinceLastUpdate >= 1) then |
checkStats() |
updFrame.timeSinceLastUpdate = 0 |
end |
end) |
end |
function checkStats() |
for i, object in pairs(objects) do |
if (i=="gold") then |
object.text:SetText("|TInterface\\BUTTONS\\UI-GroupLoot-Coin-Up:0:0:0:-1|t "..util.money(GetMoney())) |
elseif i=="dura" then |
object.text:SetText("|TInterface\\MINIMAP\\Tracking\\Repair:0:0:0:-1|t "..select(1, show_durability()).." ") |
object.progress:SetValue(select(2, show_durability()) or 0) |
elseif i=="fps" then |
object.text:SetText(" |cff"..tcolor.." fps:|r "..floor(GetFramerate())) |
object.progress:SetValue(floor(GetFramerate())) |
elseif i=="tm" then |
object.text:SetText("|cff"..tcolor.." T: |r"..date("%H:%M").." ") |
elseif i=="lag" then |
object.text:SetText("|TInterface\\MINIMAP\\Tracking\\FlightMaster:0:0:0:-1|t "..select(3, GetNetStats())) |
elseif i=="loot" then |
if UnitInParty("player") or UnitInRaid("player") then |
object.text:SetText("|TInterface\\MINIMAP\\Tracking\\Banker:0:0:0:-1|t "..show_loot()) |
end |
elseif i=="xp" then |
if UnitLevel("player") < 80 then |
object.text:SetText("|cff"..tcolor.." XP:|r |caa0033ee"..util.letter((UnitXPMax("player")-UnitXP("player")) + 1).." ("..util.letter(GetXPExhaustion() or 0)..")|r") |
object.progress:SetValue((floor((UnitXP("player")/UnitXPMax("player"))*100))) |
else |
object.progress = nil |
end |
elseif i=="guild" then |
if IsInGuild() then |
object.text:SetText("|TInterface\\MINIMAP\\Tracking\\Profession:0:0:0:-1|t "..get_guild) |
end |
elseif i=="mem" then |
object.text:SetText("|cff"..tcolor.." M:|r "..memoryval(collectgarbage("count"))) |
elseif i=="wgtime" then |
object.text:SetText("|TInterface\\PVPFrame\\PVP-Currency-Alliance:0:0:0:-1|t "..WGConvertTime(GetWintergraspWaitTime())) |
elseif i=="honor" then |
object.text:SetText("|TInterface\\MINIMAP\\Tracking\\BattleMaster:0:0:0:-1|t "..util.letter(GetHonorCurrency())) |
elseif i=="zone" then |
object.text:SetText(GetMinimapZoneText()) |
elseif i=="dps" then |
else |
end |
end |
end |
function WGConvertTime(value) |
if(value~=nil)then |
local hours = floor(value / 3600) |
local minutes = value - (hours * 3600) |
minutescorrupt = floor(minutes / 60) |
if(minutescorrupt < 10)then minutesfixed = "0"..minutescorrupt.."" |
else minutesfixed = minutescorrupt end |
local seconds = floor(value - ((hours * 3600) + (minutescorrupt * 60))) |
if(seconds < 10)then secondsfixed = "0"..seconds.."" |
else secondsfixed = seconds end |
if (hours > 0) then |
return hours..":"..minutesfixed..":"..secondsfixed |
elseif (minutescorrupt > 0) then |
return "0:"..minutesfixed..":"..secondsfixed |
else |
return "0:00:"..secondsfixed |
end |
end |
return "" |
end |
function show_addons() |
GameTooltip:SetOwner(aFrame, "ANCHOR_BOTTOMRIGHT") |
local total, addons, all_mem = 0, {}, collectgarbage("count") |
UpdateAddOnMemoryUsage() |
for i=1, GetNumAddOns(), 1 do |
if (GetAddOnMemoryUsage(i) > 0 ) then |
memory = GetAddOnMemoryUsage(i) |
entry = {name=GetAddOnInfo(i), memory = memory} |
table.insert(addons, entry) |
total = total + memory |
end |
end |
table.sort(addons, function(a, b) return a.memory > b.memory end) |
line("ADDONS MEMORY USAGE :", "\n") |
i = 0 |
for _, entry in pairs(addons) do |
line(entry.name, memoryval(entry.memory)) |
i = i + 1 |
if i >= 50 then break end |
end |
space() |
line("Addons", memoryval(total)) |
line("Blizz", memoryval(all_mem-total)) |
line("Total", memoryval(all_mem)) |
if not UnitAffectingCombat("player") then GameTooltip:Show() end |
end |
function cString(name, point, ...) |
local lastobject = nil |
for i, object in pairs(objects) do |
if object.child == false then |
objects[i].child = true |
lastobject = objects[i] |
break |
end |
end |
local btn = CreateFrame("Frame", nil, aFrame) |
if (lastobject) then |
btn:SetPoint("LEFT", lastobject.bar, "RIGHT", 0, 0) |
else |
btn:SetPoint("LEFT", aFrame, "LEFT", 0, 0) |
end |
btn:SetWidth(UIParent:GetWidth()/objCount) |
btn:SetHeight(aFrame:GetHeight()) |
btn:EnableMouse(true) |
btn:Show() |
if type(point) == "string" then |
if point == "progress" then |
local val1, val2 = select(1, ...) |
btn.pb = CreateFrame("StatusBar", nil, btn) |
btn.pb:SetStatusBarTexture(settings.striped) |
btn.pb:SetStatusBarColor(.15, .15, .15) |
btn.pb.frequentUpdates = true |
btn.pb:SetPoint("TOPLEFT", btn, "TOPLEFT", 1, -1) |
btn.pb:SetPoint("BOTTOMRIGHT", btn, "BOTTOMRIGHT", -1, 1) |
btn.pb:SetMinMaxValues(val1, val2) |
local ppbg = btn.pb:CreateTexture(nil, "BACKGROUND") |
ppbg:SetTexture(settings.texture) |
ppbg:SetAllPoints(btn.pb) |
ppbg:SetVertexColor(.3, .3, .3) |
local zstr = createFs(btn.pb, nil, 10) |
zstr:SetAllPoints(btn.pb) |
objects[name] = { |
["text"] = zstr, |
["bar"] = btn, |
["progress"] = btn.pb, |
["child"] = false, |
} |
end |
elseif type(point) == "function" then |
btn:SetScript("OnEnter", point) |
btn:SetScript("OnLeave", function() GameTooltip:Hide() end) |
local zstr = btn:CreateFontString(nil, "OVERLAY") |
zstr:SetFont(settings.font, 10, "THINOUTLINE") |
zstr:SetAllPoints(btn) |
zstr:SetTextColor(0, 1, 0.2, 1) |
zstr:SetJustifyV("MIDDLE") |
objects[name] = { |
["text"] = zstr, |
["bar"] = btn, |
["progress"] = nil, |
["child"] = false, |
} |
else |
local zstr = btn:CreateFontString(nil, "OVERLAY") |
zstr:SetFont(settings.font, 10, "THINOUTLINE") |
zstr:SetAllPoints(btn) |
zstr:SetTextColor(0, 1, 0.2, 1) |
zstr:SetJustifyV("MIDDLE") |
objects[name] = { |
["text"] = zstr, |
["bar"] = btn, |
["progress"] = nil, |
["child"] = false, |
} |
end |
return btn |
end |
function show_durability() |
local cost, ndx, durability, d_val, d_max = GetRepairAllCost(), 0, 0, 0, 0 |
for slot = 0, 19 do |
d_val, d_max = GetInventoryItemDurability(slot) |
if(d_val) then durability = durability + d_val/d_max*100 ndx=ndx+1 |
end |
end |
durability = floor(durability/ndx) |
local out_string = util.gradient_s(floor(durability), 0, 100).." % " |
if(cost > 0) then return out_string.."["..cost.."]" end |
return out_string, durability+1 |
end |
function show_guild() |
GameTooltip:SetOwner(aFrame, "ANCHOR_BOTTOMRIGHT") |
line("guild :", GetGuildInfo("player")) |
space() |
for _, val in ipairs(guildtable) do |
line(string.format("|cffdddd00%s|r %s|r [ %s ]", val[1], classcol(val[9])..val[2], val[4], val[5]), val[5]) |
end |
if not UnitAffectingCombat("player") then GameTooltip:Show() end |
end |
function memoryval(val) |
if val > 1024 then return floor(val/1024).." mb" |
else return floor(val).." kb" end |
end |
fernir_UI.GUILD_ROSTER_UPDATE = function(self, ...) |
local total, online = 0, 0 |
guildtable = {} |
if IsInGuild() then |
total = GetNumGuildMembers(true) |
for ndx = 0, total do |
name, rnk, irnk, lvl, class, zone, note, onote, on, status, engclass = GetGuildRosterInfo(ndx) |
if(on and name) then |
online = online + on |
table.insert(guildtable, {lvl, name, class, zone, note, onote, on, status, engclass}) |
end |
end |
end |
get_guild = online.."/"..total |
end |
function show_loot() |
local lootmethod, masterlooterPartyID, masterlooterRaidID = GetLootMethod() |
local master = "" |
if masterlooterPartyID then |
master = ", "..UnitName("party"..masterlooterPartyID) |
elseif masterlooterRaidID then |
master = ", "..UnitName("raid"..masterlooterPartyID) |
else |
master = "" |
end |
objects["loot"].bar:SetWidth(objects["loot"].text:GetStringWidth()+30) |
return format("%s %s", lootmethod, master) |
end |
function classcol(class) |
if not _G["RAID_CLASS_COLORS"] then return ("|cffffffff") end |
local color = _G["RAID_CLASS_COLORS"][strupper(class)] |
return format("|cff%02x%02x%02x", color.r*255, color.g*255, color.b*255) |
end |
fernir_UI.PLAYER_ENTERING_WORLD = function(self, ...) |
fernir_UI:UnregisterEvent("PLAYER_ENTERING_WORLD" ) |
--WatchFrame:ClearAllPoints() |
--WatchFrame:SetPoint("TOPLEFT", "UIParent", "TOPRIGHT", -350, -300) |
--WatchFrame:SetHeight(600) |
--WatchFrame.ClearAllPoints = function() end |
--WatchFrame.SetPoint = function() end |
--WatchFrame.SetAllPoints = function() end |
local color = _G["RAID_CLASS_COLORS"][select(2, UnitClass("player"))] or {0,0,0} |
tcolor = format("%02x%02x%02x", color.r*255, color.g*255, color.b*255) --"637eae" |
end |
fernir_UI.PLAYER_REGEN_ENABLED = function(self, ...) |
damage = 0 |
stime = 0 |
ctime = 0 |
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED") |
end |
fernir_UI.PLAYER_REGEN_DISABLED = function(self, ...) |
stime = GetTime() |
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") |
end |
fernir_UI.COMBAT_LOG_EVENT_UNFILTERED = function(_, _, timestamp, event, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, meleedamage, _, _, spelldamage) |
if sourceGUID == UnitGUID("player") or sourceGUID == UnitGUID("playerpet") then |
local duration = 1 |
if ( event == "SWING_DAMAGE" ) then |
damage = damage + meleedamage |
ctime = GetTime() |
if ((ctime - stime) > 1) then |
duration = ctime - stime |
end |
objects["dps"].text:SetText(" |cff"..tcolor.." DPS:|r "..floor(damage / duration)) |
objects["dps"].bar:SetWidth(objects["dps"].text:GetStringWidth() + 30) |
elseif (event == "SPELL_DAMAGE" or event == "SPELL_PERIODIC_DAMAGE") then |
damage = damage + spelldamage |
ctime = GetTime() |
if ((ctime - stime) > 1) then |
duration = ctime - stime |
end |
objects["dps"].text:SetText(" |cff"..tcolor.." DPS:|r "..floor(damage / duration)) |
objects["dps"].bar:SetWidth(objects["dps"].text:GetStringWidth() + 30) |
end |
end |
end |
WatchFrame:SetFrameStrata("TOOLTIP") |
WatchFrame:ClearAllPoints() |
--WatchFrame:SetPoint("TOPLEFT", UIParent, "TOPRIGHT", 350,-300) |
WatchFrame:SetHeight(600) |
WatchFrame.ClearAllPoints = function() end |
WatchFrame.SetPoint = function() end |
WatchFrame.SetAllPoints = function() end |
WatchFrame:SetMovable(true) |
WatchFrameCollapseExpandButton:RegisterForDrag("LeftButton") |
WatchFrame:SetUserPlaced(true) |
WatchFrameCollapseExpandButton:HookScript('OnDragStart', function(self) WatchFrame:StartMoving() end) |
WatchFrameCollapseExpandButton:HookScript('OnDragStop', function(self) WatchFrame:StopMovingOrSizing() end) |
WatchFrameCollapseExpandButton.Hide = function() end |
fernir_UI:RegisterEvent("ADDON_LOADED") |
fernir_UI:RegisterEvent("PLAYER_ENTERING_WORLD") |
fernir_UI:RegisterEvent("GUILD_ROSTER_UPDATE") |
fernir_UI:RegisterEvent("PLAYER_LOGIN") |
fernir_UI:RegisterEvent("PLAYER_REGEN_DISABLED") |
fernir_UI:RegisterEvent("PLAYER_REGEN_ENABLED") |
fernir_UI:SetScript("OnEvent", function(self, event, ...) self[event](self, event, ...) end) |
local settings = oUF_Settings |
Minimap:SetScale(settings.MinimapScale) |
--[[ Background ]] |
local bg = Minimap:CreateTexture(nil, "BACKGROUND") |
bg:SetPoint("TOPLEFT", Minimap, "TOPLEFT", -2, 2) |
bg:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMRIGHT", 2, -2) |
bg:SetTexture(1,1,1) |
local ef = CreateFrame("frame") |
ef:RegisterEvent("ADDON_LOADED") |
ef:SetScript("OnEvent", function(self, event, addon) |
if event == "ADDON_LOADED" then |
if(addon=="Blizzard_TimeManager") then |
bg:SetVertexColor(unpack(settings.ccolor)) |
for i = 1, select('#', TimeManagerClockButton:GetRegions()) do |
local texture = select(i, TimeManagerClockButton:GetRegions()) |
if (texture and texture:GetObjectType() == 'Texture') then |
texture:SetTexture(nil) |
end |
end |
end |
TimeManagerClockButton:SetPoint("BOTTOM", Minimap, "BOTTOM", 0, -6) |
end |
end) |
if (not IsAddOnLoaded('Blizzard_TimeManager')) then |
LoadAddOn('Blizzard_TimeManager') |
end |
for i = 1, select('#', GameTimeFrame:GetRegions()) do |
local texture = select(i, GameTimeFrame:GetRegions()) |
if (texture and texture:GetObjectType() == 'Texture') then |
texture:SetTexture(nil) |
end |
end |
GameTimeFrame:SetWidth(14) |
GameTimeFrame:SetHeight(14) |
GameTimeFrame:SetHitRectInsets(0, 0, 0, 0) |
GameTimeFrame:ClearAllPoints() |
GameTimeFrame:SetPoint('TOPRIGHT', Minimap, -3.5, -3.5) |
GameTimeFrame:GetFontString():SetFont('Fonts\\ARIALN.ttf', 16, 'OUTLINE') |
GameTimeFrame:GetFontString():SetShadowOffset(0, 0) |
GameTimeFrame:GetFontString():SetPoint('TOPRIGHT', GameTimeFrame) |
for _, texture in pairs({ |
GameTimeCalendarEventAlarmTexture, |
GameTimeCalendarInvitesTexture, |
GameTimeCalendarInvitesGlow, |
}) do |
texture.Show = function() |
GameTimeFrame:GetFontString():SetTextColor(1, 0, 1) |
end |
texture.Hide = function() |
local classColor = RAID_CLASS_COLORS[select(2, UnitClass('player'))] |
GameTimeFrame:GetFontString():SetTextColor(classColor.r, classColor.g, classColor.b) |
end |
end |
MiniMapInstanceDifficulty:SetPoint("TOPLEFT", Minimap, "TOPLEFT", -10, 10) |
MiniMapInstanceDifficulty:SetScale(.7) |
MinimapZoomIn:Hide() |
MinimapZoomOut:Hide() |
MinimapBorder:Hide() |
MinimapBorderTop:Hide() |
MinimapZoneText:Hide() |
MinimapZoneTextButton:Hide() |
MiniMapWorldMapButton:Hide() |
MiniMapLFGFrame:ClearAllPoints() |
MiniMapLFGFrame:SetPoint('BOTTOMLEFT', Minimap, -2, -2) |
MiniMapLFGFrame:SetScale(0.93) |
MiniMapTracking:Hide() |
MiniMapBattlefieldBorder:Hide() |
MiniMapMailBorder:Hide() |
BattlegroundShine:Hide() |
DurabilityFrame:Hide() |
MinimapNorthTag:SetAlpha(0) |
MinimapCluster:SetScale(1.1) |
MinimapCluster:EnableMouse(false) |
Minimap:EnableMouseWheel(true) |
Minimap:ClearAllPoints() |
Minimap:SetPoint('TOPRIGHT', UIParent, -26, -26) |
Minimap:SetMaskTexture('Interface\\ChatFrame\\ChatFrameBackground') |
MiniMapMailText = MiniMapMailFrame:CreateFontString('MiniMapMailText', 'OVERLAY') |
MiniMapMailText:SetParent(MiniMapMailFrame) |
MiniMapMailText:SetFont('Fonts\\ARIALN.ttf', 16, 'OUTLINE') |
MiniMapMailText:SetPoint('BOTTOMRIGHT', MiniMapMailFrame) |
MiniMapMailText:SetTextColor(1, 0, 1) |
MiniMapMailText:SetText('new') |
MiniMapMailFrame:SetWidth((MiniMapMailText:GetStringWidth())) |
MiniMapMailFrame:SetHeight(18) |
MiniMapMailFrame:ClearAllPoints() |
MiniMapMailFrame:SetPoint('BOTTOMRIGHT', Minimap, -4, 5) |
MiniMapMailIcon:SetTexture(nil) |
MiniMapBattlefieldFrame:ClearAllPoints() |
MiniMapBattlefieldFrame:SetPoint('TOPLEFT', Minimap, -2, 1) |
MinimapTrackingText = Minimap:CreateFontString('$parentTrackingText', 'OVERLAY') |
MinimapTrackingText:SetFont('Fonts\\ARIALN.ttf', 15) |
MinimapTrackingText:SetShadowOffset(1, -1) |
MinimapTrackingText:SetPoint('CENTER', Minimap, 0, 35) |
MinimapTrackingText:SetWidth((Minimap:GetWidth() - 25)) |
MinimapTrackingText:SetAlpha(0) |
MiniMapLFGFrameBorder:SetAlpha(0) |
Minimap:SetScript('OnMouseWheel', function() |
if (arg1 > 0) then |
Minimap_ZoomIn() |
else |
Minimap_ZoomOut() |
end |
end) |
hooksecurefunc(TicketStatusFrameButton, 'Show', function(self) |
TicketStatusFrameButton:SetBackdrop({ |
bgFile = 'Interface\\Buttons\\WHITE8x8', |
insets = { |
left = 3, |
right = 3, |
top = 3, |
bottom = 3 |
} |
}) |
TicketStatusFrameButton:SetBackdropColor(0, 0, 0, 0.5) |
end) |
local function Minimap_CreateDropDown() |
local button = { |
{ text = CHARACTER_BUTTON, func = function() ToggleCharacter('PaperDollFrame') end }, |
{ text = SPELLBOOK_ABILITIES_BUTTON, func = function() ToggleFrame(SpellBookFrame) end }, |
{ text = TALENTS_BUTTON, func = function() ToggleTalentFrame() end }, |
{ text = ACHIEVEMENT_BUTTON, func = function() ToggleAchievementFrame() end }, |
{ text = "Calendar", func = function() ToggleCalendar() end }, |
{ text = QUESTLOG_BUTTON, func = function() ToggleFrame(QuestLogFrame) end }, |
{ text = SOCIAL_BUTTON, func = function() ToggleFriendsFrame() end }, |
{ text = PLAYER_V_PLAYER, func = function() ToggleFrame(PVPParentFrame) end }, |
{ text = LFG_TITLE, func = function() ToggleLFDParentFrame() end }, |
{ text = HELP_BUTTON, func = function() ToggleHelpFrame() end }, |
} |
for i=1, 10 do |
UIDropDownMenu_AddButton(button[i]) |
end |
end |
Minimap:SetScript("OnMouseUp", function(self, button) |
if(button == 'RightButton') then |
ToggleDropDownMenu(1, nil, TimeManagerClockDropDown, self, -0, -0) |
GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMLEFT') |
else |
ToggleDropDownMenu(1, nil, MiniMapTrackingDropDown, self, - (Minimap:GetWidth() * 0.7), -3) |
end |
end) |
TimeManagerClockDropDown = CreateFrame('Frame', 'TimeManagerClockDropDown', nil, 'UIDropDownMenuTemplate') |
UIDropDownMenu_Initialize(TimeManagerClockDropDown, Minimap_CreateDropDown, 'MENU') |
local addonName, ns = ... |
oUF = ns.oUF or oUF |
if not oUF then return end |
local media = "Interface\\Addons\\"..addonName.."\\textures\\" |
local _, playerclass = UnitClass('player') |
oUF_Settings = { |
UIScale = true, |
Portraits = true, |
MinimapScale = 0.8, |
powerbar = false, |
cornerPoints = true, |
corners = { |
{spellID = 48440, point = "BOTTOMLEFT", width = 10, height = 10, action = "HELPFUL", count = false, color = {1, .1, 1, 1 }, }, --rejuvenation |
{spellID = 48443, point = "TOPLEFT", width = 10, height = 10, action = "HELPFUL", count = false, color = { 0, 1, .4, 1 }, }, --regrowth |
{spellID = 48450, point = "TOPRIGHT", width = 10, height = 10, action = "HELPFUL", count = true, color = { 0, 1, 0, 1 }, }, --lifebloom |
{spellID = 53249, point = "BOTTOMRIGHT", width = 10, height = 10, action = "HELPFUL", count = false, color = { 1, .8, 0, 1 }, }, --wildgrowth |
{spellID = 47486, action = "HARMFUL", }, --mortal strike |
{spellID = 43235, action = "HARMFUL", }, --wound poison |
}, |
runecolors = { |
[1] = {.69,.31,.31}, |
[2] = {.69,.31,.31}, |
[3] = {.33,.59,.33}, |
[4] = {.33,.59,.33}, |
[5] = {.31,.45,.63}, |
[6] = {.31,.45,.63}, |
}, |
powercolors = { -- my colors for power bars |
["MANA"] = {.2, .4, 1}, |
["RAGE"] = {.9, .1, .1}, |
["FOCUS"] = {.9, .9, .1}, |
["ENERGY"] = {.9, .9, .1}, |
["RUNIC_POWER"] = {.1, .9, .9}, |
}, |
texture = media.."tex_smooth", -- Texture for all bars |
buffTex = media.."gloss", -- border for aura icons |
indicator = media.."indicator", -- Raid corner texture |
font = media.."myriadpro.ttf", -- global font |
fsize = 13, -- global font size |
borderGlow = media.."simplesquare_glow", |
striped = media.."tex_striped", |
buffGloss = media.."gloss_border", |
normTex = media.."normTex", -- nameplate normal texture |
glowTex = media.."glowTex", -- nameplate glow texture |
ClassColor = true, -- color healthbar by class or reaction |
OwnColor = { 0.6, 1, 0.9 }, -- or use own color |
PowerColorByType = true, -- color power bar by power type (rage = red, mana = blue tc) |
OwnPowerColor = { 0.2, 0.2, 1 }, -- or use own power color |
chatcolor = { .1, .1, .1 }, |
ccolor = _G["RAID_CLASS_COLORS"][select(2, UnitClass("player"))] or {0,0,0}, -- DO NOT EDIT OR DELETE! |
chatalpha = 1, |
Frames = { |
["player"] = {Width = 200, Height = 45, ManaBarHeight = 12}, |
["target"] = {Width = 200, Height = 45, ManaBarHeight = 12}, |
["targettarget"] = {Width = 100, Height = 25, ManaBarHeight = 6}, |
["focus"] = {Width = 100, Height = 10, ManaBarHeight = 3}, |
["focustarget"] = {Width = 100, Height = 10, ManaBarHeight = 3}, |
["pet"] = {Width = 45, Height = 45, ManaBarHeight = 6}, |
}, |
Positions = { |
["player"] = {"TOPRIGHT", UIParent, "BOTTOM", -100, 300}, |
["target"] = {"TOPLEFT", UIParent, "BOTTOM", 100, 300}, |
["targettarget"] = {"TOP", UIParent, "BOTTOM", 0, 300}, |
["focus"] = {"TOPLEFT", UIParent, "BOTTOMLEFT", 32, 300}, |
["focustarget"] = {"LEFT", oUF.units.focus, "RIGHT", 5, 0}, |
["pet"] = {"TOP", oUF.units.player, "BOTTOM", 0, -20}, |
}, |
RaidFrames = {Width = 60, Height = 50, ManaBar = 3}, |
RaidPositions = {"TOPLEFT", UIParent, 27, -27}, -- first raid group |
} |
if playerclass == "DEATHKNIGHT" then |
table.insert(oUF_Settings.corners, |
{spellID = 57623, point = "TOPLEFT", width = 10, height = 10, action = "HELPFUL", count = false, color = {0, 0, 1, 1 }, } |
)--winter horn |
elseif playerclass == "SHAMAN" then |
table.insert(oUF_Settings.corners, |
{spellID = 57960, point = "TOPLEFT", width = 15, height = 15, action = "HELPFUL", count = false, color = {0, 0, 1, 1 }, } |
)--water shield |
end |
--[[ Options start here ]] |
-- "true" means enabled, "false" means disabled |
local AutoGreedOnGreen = false -- Should all be green items automatically rolled "greed" in groups and raids? |
local AutoRepair = true -- Auto repair all equipment upon visiting vendor + print repair cost info. |
local SellGreyCrap = true -- Sell all grey items to vendor automatically. |
local AcceptInvites = true -- Accept party invites from frieds and guild members |
local NoErrors = false -- Hide all erros from UIErrorsFrame |
local raidaddons = { -- Addons you use only in raids or groups |
"BigWigs", |
"oRA2", |
"SimpleRaidTargetIcons", |
"Scada", |
} |
local pvpaddons = { -- Addons you use only in arenas or BGs. Nothing here since i rarely do PvP =) |
"Gladius", |
"Capping", |
} |
--[[ Clear UIErrors frame ]] |
UIErrorsFrame:SetScale(0.8) |
--CalendarFrame:SetScale(0.8) |
if(NoErrors==true) then UIErrorsFrame:UnregisterEvent("UI_ERROR_MESSAGE") end |
WatchFrameTitle:SetAlpha(0) |
local p1, p2, p3, p4, p5 = WatchFrameCollapseExpandButton:GetPoint() |
WatchFrameCollapseExpandButton:ClearAllPoints() |
WatchFrameCollapseExpandButton:SetPoint(p1, p2, p3, p4 - 15, p5) |
local a, b, c, d, e = RaidFrameNotInRaidRaidBrowserButton:GetPoint() |
RaidFrameNotInRaidRaidBrowserButton:SetPoint(a, b, c, d, e - 25) |
-- Disabled WoW's combat log at startup |
-- local f = CreateFrame("Frame") |
-- f:SetScript("OnEvent", function() |
-- f:UnregisterEvent("COMBAT_LOG_EVENT") |
-- COMBATLOG:UnregisterEvent("COMBAT_LOG_EVENT") |
-- end) |
-- f:RegisterEvent("COMBAT_LOG_EVENT") |
--[[ Changing some variables ]] |
SetCVar("screenshotQuality", 10) |
SetCVar("cameraDistanceMax", 50) |
SetCVar("cameraDistanceMaxFactor", 3.4) |
--[[ Autogreed on green items ]] |
if(AutoGreedOnGreen==true) then |
local f = CreateFrame("Frame") |
f:RegisterEvent("START_LOOT_ROLL") |
f:SetScript("OnEvent", function(_, _, id) |
if(id and select(4, GetLootRollItemInfo(id))==2) then |
RollOnLoot(id, 2) |
end |
end) |
end |
--[[ Accept invites ]] |
if(AcceptInvites==true) then |
local IsFriend = function(name) |
for i=1, GetNumFriends() do if(GetFriendInfo(i)==name) then return true end end |
if(IsInGuild()) then for i=1, GetNumGuildMembers() do if(GetGuildRosterInfo(i)==name) then return true end end end |
end |
local ai = CreateFrame("Frame") |
ai:RegisterEvent("PARTY_INVITE_REQUEST") |
ai:SetScript("OnEvent", function(frame, event, name) |
if(IsFriend(name)) then |
AcceptGroup() |
for i = 1, 4 do |
local frame = _G["StaticPopup"..i] |
if(frame:IsVisible() and frame.which=="PARTY_INVITE") then |
frame.inviteAccepted = 1 |
StaticPopup_Hide("PARTY_INVITE") |
return |
end |
end |
else |
SendWho(name) |
end |
end) |
end |
local module = CreateFrame("Frame",nil,UIParent) |
local sells,tmp_money = 0,0 |
-- íîðìàëüíûé ôîðìàò âûâîäà äåíåã |
local money_format = function(val) |
return format("|cffffd700%dg|r |cffc7c7cf%ds|r |cffeda55f%dc|r",mod(val/10000,10000),mod(val/100,100),mod(val,100)) |
end |
module.MERCHANT_SHOW = function(self) |
if (AutoRepair==true) then |
-- ÷èíèìñÿ |
if (CanMerchantRepair()) then |
local cost,money = GetRepairAllCost(),GetMoney() |
if cost > 0 then |
RepairAllItems() |
print(string.format("repairing cost : %s",money_format(math.min(cost, money)))) |
end |
end |
end |
if (SellGreyCrap==true) then |
-- ïðîäàåì ìóñîð |
local bag,slot |
tmp_money = GetMoney() |
for bag = 0,4 do |
if GetContainerNumSlots(bag) > 0 then |
for slot = 0, GetContainerNumSlots(bag) do |
local link = GetContainerItemLink(bag,slot) |
if(link) then |
local _,_,i_rar=GetItemInfo(link) |
if i_rar == 0 then |
UseContainerItem(bag,slot) |
sells = sells+GetItemCount(link) |
end |
end |
end |
end |
end |
end |
end |
module.PLAYER_MONEY = function(self) |
if(sells>0) then |
print(string.format("sold %d items for %s",sells,money_format(GetMoney()-tmp_money))) |
sells = 0 |
end |
end |
------------------------------------------------------------------------------------------------------------- |
module:SetScript("OnEvent",function(self,event,...) self[event](self,event,...) end) |
module:RegisterEvent("MERCHANT_SHOW") |
module:RegisterEvent("PLAYER_MONEY") |
--[[------------------------------------------------------------------------- |
Copyright (c) 2007-2008, Trond A Ekseth |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are |
met: |
* Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
* Redistributions in binary form must reproduce the above |
copyright notice, this list of conditions and the following |
disclaimer in the documentation and/or other materials provided |
with the distribution. |
* Neither the name of Butsu nor the names of its contributors may |
be used to endorse or promote products derived from this |
software without specific prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---------------------------------------------------------------------------]] |
local L = { |
fish = "Fishy loot", |
empty = "Empty slot", |
} |
local addon = CreateFrame("Button", "Butsu") |
local title = addon:CreateFontString(nil, "OVERLAY") |
local print = function(a) ChatFrame1:AddMessage("|cff33ff99Butsu:|r "..a) end |
local iconsize = 35 |
local sq, ss, sn |
local OnEnter = function(self) |
local slot = self:GetID() |
if(LootSlotIsItem(slot)) then |
GameTooltip:SetOwner(self, "ANCHOR_RIGHT") |
GameTooltip:SetLootItem(slot) |
CursorUpdate(self) |
end |
self.drop:Show() |
self.drop:SetVertexColor(1, 1, 0) |
end |
local OnLeave = function(self) |
if(self.quality > 1) then |
local color = ITEM_QUALITY_COLORS[self.quality] |
self.drop:SetVertexColor(color.r, color.g, color.b) |
else |
self.drop:Hide() |
end |
GameTooltip:Hide() |
ResetCursor() |
end |
local OnClick = function(self) |
if(IsModifiedClick()) then |
HandleModifiedItemClick(GetLootSlotLink(self:GetID())) |
else |
StaticPopup_Hide"CONFIRM_LOOT_DISTRIBUTION" |
ss = self:GetID() |
sq = self.quality |
sn = self.name:GetText() |
LootSlot(ss) |
end |
end |
local OnUpdate = function(self) |
if(GameTooltip:IsOwned(self)) then |
GameTooltip:SetOwner(self, "ANCHOR_RIGHT") |
GameTooltip:SetLootItem(self:GetID()) |
CursorOnUpdate(self) |
end |
end |
local createSlot = function(id) |
local frame = CreateFrame("Button", 'ButsuSlot'..id, addon) |
frame:SetPoint("LEFT", 8, 0) |
frame:SetPoint("RIGHT", -8, 0) |
frame:SetHeight(iconsize) |
frame:SetID(id) |
frame:SetScript("OnEnter", OnEnter) |
frame:SetScript("OnLeave", OnLeave) |
frame:SetScript("OnClick", OnClick) |
frame:SetScript("OnUpdate", OnUpdate) |
local iconFrame = CreateFrame("Frame", nil, frame) |
iconFrame:SetHeight(iconsize) |
iconFrame:SetWidth(iconsize) |
iconFrame:ClearAllPoints() |
iconFrame:SetPoint("RIGHT", frame) |
local icon = iconFrame:CreateTexture(nil, "ARTWORK") |
icon:SetAlpha(.8) |
icon:SetTexCoord(.07, .93, .07, .93) |
icon:SetAllPoints(iconFrame) |
frame.icon = icon |
local count = iconFrame:CreateFontString(nil, "OVERLAY") |
count:ClearAllPoints() |
count:SetJustifyH"RIGHT" |
count:SetPoint("BOTTOMRIGHT", iconFrame, 2, 2) |
count:SetFontObject(NumberFontNormalSmall) |
count:SetShadowOffset(.8, -.8) |
count:SetShadowColor(0, 0, 0, 1) |
count:SetText(1) |
frame.count = count |
local name = frame:CreateFontString(nil, "OVERLAY") |
name:SetJustifyH"LEFT" |
name:ClearAllPoints() |
name:SetPoint("LEFT", frame) |
name:SetPoint("RIGHT", icon, "LEFT") |
name:SetNonSpaceWrap(true) |
name:SetFontObject(GameFontWhite) |
name:SetShadowOffset(.8, -.8) |
name:SetShadowColor(0, 0, 0, 1) |
frame.name = name |
local drop = frame:CreateTexture(nil, "ARTWORK") |
drop:SetTexture"Interface\\QuestFrame\\UI-QuestLogTitleHighlight" |
drop:SetPoint("LEFT", icon, "RIGHT", 0, 0) |
drop:SetPoint("RIGHT", frame) |
drop:SetAllPoints(frame) |
drop:SetAlpha(.3) |
frame.drop = drop |
frame:SetPoint("TOP", addon, 4, (-8+iconsize)-(id*iconsize)) |
addon.slots[id] = frame |
return frame |
end |
title:SetFontObject(GameTooltipHeaderText) |
title:SetPoint("BOTTOMLEFT", addon, "TOPLEFT", 5, 0) |
addon:SetScript("OnMouseDown", function(self) if(IsAltKeyDown()) then self:StartMoving() end end) |
addon:SetScript("OnMouseUp", function(self) self:StopMovingOrSizing() end) |
addon:SetScript("OnHide", function(self) |
StaticPopup_Hide"CONFIRM_LOOT_DISTRIBUTION" |
CloseLoot() |
end) |
addon:SetMovable(true) |
addon:RegisterForClicks"anyup" |
addon:SetParent(UIParent) |
addon:SetUserPlaced(true) |
addon:SetPoint("TOPLEFT", 0, -104) |
addon:SetBackdrop{ |
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16, |
insets = {left = 4, right = 4, top = 4, bottom = 4}, |
} |
addon:SetWidth(256) |
addon:SetHeight(64) |
addon:SetBackdropColor(0, 0, 0, 1) |
addon:SetClampedToScreen(true) |
addon:SetClampRectInsets(0, 0, 14, 0) |
addon:SetHitRectInsets(0, 0, -14, 0) |
addon:SetFrameStrata"HIGH" |
addon:SetToplevel(true) |
addon.slots = {} |
addon.LOOT_OPENED = function(self, event, autoloot) |
self:Show() |
if(not self:IsShown()) then |
CloseLoot(not autoLoot) |
end |
local items = GetNumLootItems() |
if(IsFishingLoot()) then |
title:SetText(L.fish) |
elseif(not UnitIsFriend("player", "target") and UnitIsDead"target") then |
title:SetText(UnitName"target") |
else |
title:SetText(LOOT) |
end |
-- Blizzard uses strings here |
if(GetCVar("lootUnderMouse") == "1") then |
local x, y = GetCursorPosition() |
x = x / self:GetEffectiveScale() |
y = y / self:GetEffectiveScale() |
self:ClearAllPoints() |
self:SetPoint("TOPLEFT", nil, "BOTTOMLEFT", x-40, y+20) |
self:GetCenter() |
self:Raise() |
end |
local m, w, t = 0, 0, title:GetStringWidth() |
if(items > 0) then |
for i=1, items do |
local slot = addon.slots[i] or createSlot(i) |
local texture, item, quantity, quality, locked = GetLootSlotInfo(i) |
local color = ITEM_QUALITY_COLORS[quality] |
if(LootSlotIsCoin(i)) then |
item = item:gsub("\n", ", ") |
end |
if(quantity > 1) then |
slot.count:SetText(quantity) |
slot.count:Show() |
else |
slot.count:Hide() |
end |
if(quality > 1) then |
slot.drop:SetVertexColor(color.r, color.g, color.b) |
slot.drop:Show() |
else |
slot.drop:Hide() |
end |
slot.quality = quality |
slot.name:SetText(item) |
slot.name:SetTextColor(color.r, color.g, color.b) |
slot.icon:SetTexture(texture) |
m = math.max(m, quality) |
w = math.max(w, slot.name:GetStringWidth()) |
slot:Enable() |
slot:Show() |
end |
else |
local slot = addon.slots[1] or createSlot(1) |
local color = ITEM_QUALITY_COLORS[0] |
slot.name:SetText(L.empty) |
slot.name:SetTextColor(color.r, color.g, color.b) |
slot.icon:SetTexture[[Interface\Icons\INV_Misc_Herb_AncientLichen]] |
items = 1 |
w = math.max(w, slot.name:GetStringWidth()) |
slot.count:Hide() |
slot.drop:Hide() |
slot:Disable() |
slot:Show() |
end |
w = w + 60 |
t = t + 5 |
local color = ITEM_QUALITY_COLORS[m] |
self:SetBackdropBorderColor(color.r, color.g, color.b, .8) |
self:SetHeight(math.max((items*iconsize)+16), 20) |
self:SetWidth(math.max(w, t)) |
end |
addon.LOOT_SLOT_CLEARED = function(self, event, slot) |
if(not self:IsShown()) then return end |
addon.slots[slot]:Hide() |
end |
addon.LOOT_CLOSED = function(self) |
StaticPopup_Hide"LOOT_BIND" |
self:Hide() |
for _, v in pairs(self.slots) do |
v:Hide() |
end |
end |
addon.OPEN_MASTER_LOOT_LIST = function(self) |
ToggleDropDownMenu(1, nil, GroupLootDropDown, addon.slots[ss], 0, 0) |
end |
addon.UPDATE_MASTER_LOOT_LIST = function(self) |
UIDropDownMenu_Refresh(GroupLootDropDown) |
end |
addon:SetScript("OnEvent", function(self, event, ...) |
self[event](self, event, ...) |
end) |
addon:RegisterEvent"LOOT_OPENED" |
addon:RegisterEvent"LOOT_SLOT_CLEARED" |
addon:RegisterEvent"LOOT_CLOSED" |
addon:RegisterEvent"OPEN_MASTER_LOOT_LIST" |
addon:RegisterEvent"UPDATE_MASTER_LOOT_LIST" |
addon:Hide() |
-- Fuzz |
LootFrame:UnregisterAllEvents() |
table.insert(UISpecialFrames, "Butsu") |
function _G.GroupLootDropDown_GiveLoot(self) |
if ( sq >= MASTER_LOOT_THREHOLD ) then |
local dialog = StaticPopup_Show("CONFIRM_LOOT_DISTRIBUTION", ITEM_QUALITY_COLORS[sq].hex..sn..FONT_COLOR_CODE_CLOSE, self:GetText()) |
if (dialog) then |
dialog.data = self.value |
end |
else |
GiveMasterLoot(ss, self.value) |
end |
CloseDropDownMenus() |
end |
StaticPopupDialogs["CONFIRM_LOOT_DISTRIBUTION"].OnAccept = function(self, data) |
GiveMasterLoot(ss, data) |
end |
local Binder=CreateFrame("Frame") |
Binder:SetScript("OnEvent",function(self,event,...) self[event](self,event,...) end) |
--Binder:RegisterEvent("PLAYER_LOGIN") |
Binder:RegisterEvent("PLAYER_ENTERING_WORLD") |
Binder:RegisterEvent("VARIABLES_LOADED") |
-- OnLoad |
function Binder.VARIABLES_LOADED() |
if Binder_BindPerChar == nil then |
Binder_BindPerChar = true |
end |
Binder.IsOn = false |
end |
function Binder.PLAYER_ENTERING_WORLD(addon) |
Binder:UnregisterEvent("PLAYER_ENTERING_WORLD") |
print("|c66FF66FF/sb|cFFFFFFFF for change your binds.") |
Binder.CreateGUI() |
KeyBindingFrame_LoadUI() |
SLASH_BINDER1 = "/sb"; |
SlashCmdList["BINDER"] = Binder.SlashCommand; |
end |
-- OnEnter |
function BinderFrame_OnEnter(self) |
local keyBind = GetBindingKey(strupper(self.button)) |
local bind = _G[self:GetName().."Binding"] |
local midText = BinderBindingKey |
if keyBind then keyBind = gsub(gsub(keyBind, "BUTTON3", "Middle Mouse"), '-', ' ') end |
bind:SetText(keyBind) |
midText:SetText(keyBind) |
midText:Show() |
self:SetBackdropColor(1,0,0,.5) |
self:EnableKeyboard(true) |
end |
-- OnLeave |
function BinderFrame_OnLeave(self) |
local bind = _G[self:GetName().."Binding"] |
BinderBindingKey:Hide() |
self:SetBackdropColor(1,1,1,.5) |
self:EnableKeyboard(false) |
end |
-- OnKeyDown |
function BinderFrame_OnKeyDown(self, key, ...) |
local bind = _G[self:GetName().."Binding"] -- Sets up a local variable for our text file |
if key == "LSHIFT" or key == "RSHIFT" or key == "LCTRL" or key == "RCTRL" or key == "LALT" or key == "RALT" or key == "LeftButton" or key == "RightButton" then |
return -- stop running function if it's being run from a modifier key down |
end |
if key == "MiddleButton" then key = "BUTTON3" end |
if key == "Button4" then key = "BUTTON4" end |
if key == "Button5" then key = "BUTTON5" end |
if key == "ESCAPE" then |
SetBinding(GetBindingKey(strupper(self.button))) |
else |
if IsShiftKeyDown() then key = "SHIFT-"..key end |
if IsControlKeyDown() then key = "CTRL-"..key end |
if IsAltKeyDown() then key = "ALT-"..key end |
if GetBindingKey(strupper(self.button)) then |
SetBinding(GetBindingKey(strupper(self.button))) |
end |
SetBinding(key, strupper(self.button)) |
end |
BinderFrame_OnEnter(self) |
for i = 1, 60 do |
local f = _G["BinderFrame"..i] |
local keyBind = GetBindingKey(strupper(f.button)) |
local bind = _G[f:GetName().."Binding"] |
if keyBind then keyBind = gsub(gsub(keyBind, "BUTTON3", "Middle Mouse"), '-', ' ') end |
bind:SetText(keyBind) |
end |
end |
function Binder.CreateGUI() |
Binder.CharSpecFrame=CreateFrame("frame") |
Binder.CharSpecFrame:EnableMouse(true) |
Binder.CharSpecFrame:SetMovable(true) |
Binder.CharSpecFrame:SetScript("OnMouseDown", function(self) self:StartMoving() end) |
Binder.CharSpecFrame:SetScript("OnMouseUp", function(self) self:StopMovingOrSizing() end) |
Binder.CharSpecFrame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end) |
Binder.CharSpecFrame:SetBackdropColor(0, 0, 0, .4) |
Binder.CharSpecFrame:SetWidth(125) Binder.CharSpecFrame:SetHeight(55) |
Binder.CharSpecFrame:SetPoint("CENTER",UIParent) |
local tt = Binder.CharSpecFrame:CreateTexture(nil,"BACKGROUND") tt:SetTexture(0.19,0.19,0.19,1) tt:SetAllPoints(Binder.CharSpecFrame) |
Binder.CharSpecButton=CreateFrame("checkbutton",nil,Binder.CharSpecFrame,"OptionsCheckButtonTemplate") |
Binder.CharSpecButton:SetText("Char Specific") |
Binder.CharSpecButton:SetChecked(Binder_BindPerChar) |
Binder.CharSpecButton:SetPoint("TOPLEFT",7,-5) |
Binder.CharSpecButton:SetScript("OnClick", function() |
Binder_BindPerChar = this:GetChecked() |
if not Binder_BindPerChar then Binder_BindPerChar = false end |
end) |
Binder.CharSpecButton:SetScript("OnMouseDown", function() this:GetParent():StartMoving() end) |
Binder.CharSpecButton:SetScript("OnMouseUp", function() this:GetParent():StopMovingOrSizing() end) |
Binder.CharSpecButton:Show() |
local fstring1 = Binder.CharSpecFrame:CreateFontString("fs1","OVERLAY","GameFontNormal") |
fstring1:SetText("Char Specific") |
fstring1:SetPoint("LEFT", Binder.CharSpecButton, "RIGHT", 2, 0) |
Binder.SaveButton=CreateFrame("button",nil,Binder.CharSpecFrame,"OptionsButtonTemplate") |
Binder.SaveButton:SetWidth(55) Binder.SaveButton:SetHeight(21) |
Binder.SaveButton:SetText("Save") |
Binder.SaveButton:SetPoint("BOTTOMLEFT",7,7) |
Binder.SaveButton:SetScript("OnClick", function() Binder.SlashCommand("bind") end) |
Binder.SaveButton:Show() |
Binder.CancelButton=CreateFrame("button",nil,Binder.CharSpecFrame,"OptionsButtonTemplate") |
Binder.CancelButton:SetWidth(55) Binder.CancelButton:SetHeight(21) |
Binder.CancelButton:SetText("Cancel") |
Binder.CancelButton:SetPoint("LEFT",Binder.SaveButton,"RIGHT",2,0) |
Binder.CancelButton:SetScript("OnClick", function() Binder.SlashCommand("bind", true) end) |
Binder.CancelButton:Show() |
Binder.CharSpecFrame:Hide() |
local function setUp(frame, anchor, str_action) |
frame:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 32,}) |
frame:SetAllPoints(anchor) |
frame:SetBackdropColor(1,1,1,.5) |
frame:Hide() |
frame:SetAlpha(1) |
frame:EnableMouse(true) |
frame:SetFrameStrata("TOOLTIP") |
frame.button = str_action |
--print (str_action) |
frame:SetScript("OnEnter", BinderFrame_OnEnter) |
frame:SetScript("OnLeave", BinderFrame_OnLeave) |
frame:SetScript("OnKeyDown", BinderFrame_OnKeyDown) |
frame:SetScript("OnMouseDown", BinderFrame_OnKeyDown) |
local s = frame:CreateFontString("$parentBinding", "ARTWORK", "GameFontNormal") |
s:SetPoint("CENTER") |
s:SetHeight(anchor:GetHeight()) |
s:SetWidth(anchor:GetWidth()) |
local keyBind = GetBindingKey(strupper(frame.button)) |
if keyBind then keyBind = gsub(gsub(keyBind, "BUTTON3", "Middle Mouse"), '-', ' ') end |
s:SetText(keyBind) |
end |
for i=1, GetNumShapeshiftForms() do |
local f = CreateFrame("Frame", "ShapeshiftBinderFrame"..i, UIParent) |
local anchor = _G["ShapeshiftButton"..i] |
setUp(f, anchor, anchor:GetName()) |
end |
if select(2, UnitClass("player")) == "SHAMAN" then |
for i = 1, 4 do |
local f = CreateFrame("Frame", "MultiCastBinderFrame"..i, UIParent) |
local anchor = _G["MultiCastActionButton"..i] |
setUp(f, anchor, anchor:GetName()) |
end |
end |
for i = 1, 12 do |
local f = CreateFrame("Frame", "BinderFrame"..i, UIParent) |
local anchor = _G["ActionButton"..i] |
setUp(f, anchor, anchor:GetName()) |
f = CreateFrame("Frame", "BinderFrame"..i+12, UIParent) |
anchor = _G["MultiBarBottomLeftButton"..i] |
setUp(f, anchor, "MULTIACTIONBAR1BUTTON"..i) |
f = CreateFrame("Frame", "BinderFrame"..i+24, UIParent) |
anchor = _G["MultiBarBottomRightButton"..i] |
setUp(f, anchor, "MULTIACTIONBAR2BUTTON"..i) |
f = CreateFrame("Frame", "BinderFrame"..i+36, UIParent) |
anchor = _G["MultiBarRightButton"..i] |
setUp(f, anchor, "MULTIACTIONBAR3BUTTON"..i) |
f = CreateFrame("Frame", "BinderFrame"..i+48, UIParent) |
anchor = _G["MultiBarLeftButton"..i] |
setUp(f, anchor, "MULTIACTIONBAR4BUTTON"..i) |
f = CreateFrame("Frame", "BinderFrame"..i+60, UIParent) |
anchor = _G["MultiBarLeftButton"..i] |
setUp(f, anchor, "MULTIACTIONBAR5BUTTON"..i) |
end |
local s = UIParent:CreateFontString("BinderBindingKey", "ARTWORK", "GameFontNormalLarge") |
s:SetPoint("CENTER") |
s:Hide() |
end |
function Binder.SlashCommand(cmd, cancel) |
local updString = "|c00aa00fBinder|cFFFFFFFF " |
local text |
Binder.IsOn = not Binder.IsOn |
for i=1, GetNumShapeshiftForms() do |
local f = _G["ShapeshiftBinderFrame"..i] |
if Binder.IsOn then |
f:Show() |
else |
f:Hide() |
end |
end |
if select(2, UnitClass("player")) == "SHAMAN" then |
for i=1, 4 do |
local f = _G["MultiCastBinderFrame"..i] |
if Binder.IsOn then |
f:Show() |
else |
f:Hide() |
end |
end |
end |
for i = 1, 60 do |
local f = _G["BinderFrame"..i] |
if Binder.IsOn then |
f:Show() |
else |
f:Hide() |
end |
end |
if Binder.IsOn then |
text = "enabled!" |
Binder.CharSpecFrame:Show() |
elseif not cancel then |
text = "saved!" |
Binder.CharSpecFrame:Hide() |
if Binder_BindPerChar then |
SaveBindings(2) |
else |
SaveBindings(1) |
end |
else |
text = "canceled!" |
Binder.CharSpecFrame:Hide() |
end |
print(updString.."bindings "..text) |
end |
local settings = oUF_Settings |
local myname, ns = ... |
local locale = GetLocale() |
ns.rollpairs = locale == "deDE" and { |
["(.*) passt automatisch bei (.+), weil [ersi]+ den Gegenstand nicht benutzen kann.$"] = "pass", |
["(.*) wurfelt nicht fur: (.+|r)$"] = "pass", |
["(.*) hat fur (.+) 'Gier' ausgewahlt"] = "greed", |
["(.*) hat fur (.+) 'Bedarf' ausgewahlt"] = "need", |
["(.*) hat fur '(.+)' Entzauberung gewahlt."] = "disenchant", |
} or locale == "frFR" and { |
["(.*) a passe pour : (.+) parce qu'((il)|(elle)) ne peut pas ramasser cette objet.$"] = "pass", |
["(.*) a passe pour : (.+)"] = "pass", |
["(.*) a choisi Cupidite pour : (.+)"] = "greed", |
["(.*) a choisi Besoin pour : (.+)"] = "need", |
} or locale == "ruRU" and { |
["(.*) àâòîìàòè÷åñêè ïåðåäàåò ïðåäìåò (.+), ïîñêîëüêó íå ìîæåò åãî çàáðàòü"] = "pass", |
["(.*) ïðîïóñêàåò ðîçûãðûø ïðåäìåòà \"(.+)\", ïîñêîëüêó íå ìîæåò åãî çàáðàòü"] = "pass", |
["(.*) îòêàçûâàåòñÿ îò ïðåäìåòà (.+)%."] = "pass", |
["Ðàçûãðûâàåòñÿ: (.+)%. (.*): \"Íå îòêàæóñü\""] = "greed", |
["Ðàçûãðûâàåòñÿ: (.+)%. (.*): \"Ìíå ýòî íóæíî\""] = "need", |
["Ðàçûãðûâàåòñÿ: (.+)%. (.*): \"Ðàñïûëèòü\""] = "disenchant", |
} or locale == "zhTW" and { |
["(.*)????:(.+),??"] = "pass", |
["(.*)???:(.+)"] = "pass", |
["(.*)???????:(.+)"] = "greed", |
["(.*)???????:(.+)"] = "need", |
["(.*)????:(.+)"] = "disenchant", |
} or { |
["^(.*) automatically passed on: (.+) because s?he cannot loot that item.$"] = "pass", |
["^(.*) passed on: (.+|r)$"] = "pass", |
["(.*) has selected Greed for: (.+)"] = "greed", |
["(.*) has selected Need for: (.+)"] = "need", |
["(.*) has selected Disenchant for: (.+)"] = "disenchant", |
} |
local backdrop = { |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", tile = true, tileSize = 16, |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16, |
insets = {left = 4, right = 4, top = 4, bottom = 4}, |
} |
local function ClickRoll(frame) |
RollOnLoot(frame.parent.rollid, frame.rolltype) |
end |
local function HideTip() GameTooltip:Hide() end |
local function HideTip2() GameTooltip:Hide(); ResetCursor() end |
local rolltypes = {"need", "greed", "disenchant", [0] = "pass"} |
local function SetTip(frame) |
GameTooltip:SetOwner(frame, "ANCHOR_RIGHT") |
GameTooltip:SetText(frame.tiptext) |
if frame:IsEnabled() == 0 then GameTooltip:AddLine("|cffff3333Cannot roll") end |
for name,roll in pairs(frame.parent.rolls) do if roll == rolltypes[frame.rolltype] then GameTooltip:AddLine(name, 1, 1, 1) end end |
GameTooltip:Show() |
end |
local function SetItemTip(frame) |
if not frame.link then return end |
GameTooltip:SetOwner(frame, "ANCHOR_TOPLEFT") |
GameTooltip:SetHyperlink(frame.link) |
if IsShiftKeyDown() then GameTooltip_ShowCompareItem() end |
if IsModifiedClick("DRESSUP") then ShowInspectCursor() else ResetCursor() end |
end |
local function ItemOnUpdate(self) |
if IsShiftKeyDown() then GameTooltip_ShowCompareItem() end |
CursorOnUpdate(self) |
end |
local function LootClick(frame) |
if IsControlKeyDown() then DressUpItemLink(frame.link) |
elseif IsShiftKeyDown() then ChatEdit_InsertLink(frame.link) end |
end |
local cancelled_rolls = {} |
local function OnEvent(frame, event, rollid) |
cancelled_rolls[rollid] = true |
if frame.rollid ~= rollid then return end |
frame.rollid = nil |
frame.time = nil |
frame:Hide() |
end |
local function StatusUpdate(frame) |
local t = GetLootRollTimeLeft(frame.parent.rollid) |
local perc = t / frame.parent.time |
frame.spark:SetPoint("CENTER", frame, "LEFT", perc * frame:GetWidth(), 0) |
frame:SetValue(t) |
end |
local function CreateRollButton(parent, ntex, ptex, htex, rolltype, tiptext, ...) |
local f = CreateFrame("Button", nil, parent) |
f:SetPoint(...) |
f:SetWidth(28) |
f:SetHeight(28) |
f:SetNormalTexture(ntex) |
if ptex then f:SetPushedTexture(ptex) end |
f:SetHighlightTexture(htex) |
f.rolltype = rolltype |
f.parent = parent |
f.tiptext = tiptext |
f:SetScript("OnEnter", SetTip) |
f:SetScript("OnLeave", HideTip) |
f:SetScript("OnClick", ClickRoll) |
f:SetMotionScriptsWhileDisabled(true) |
local txt = f:CreateFontString(nil, nil, "GameFontHighlightSmallOutline") |
txt:SetPoint("CENTER", 0, rolltype == 2 and 1 or rolltype == 0 and -1.2 or 0) |
return f, txt |
end |
local function CreateRollFrame() |
local frame = CreateFrame("Frame", nil, UIParent) |
frame:SetWidth(328) |
frame:SetHeight(26) |
frame:SetBackdrop(backdrop) |
frame:SetBackdropColor(0, 0, 0, .9) |
frame:SetScript("OnEvent", OnEvent) |
frame:RegisterEvent("CANCEL_LOOT_ROLL") |
frame:Hide() |
local button = CreateFrame("Button", nil, frame) |
button:SetPoint("LEFT", 5, 0) |
button:SetWidth(24) |
button:SetHeight(24) |
button:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2") |
button:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square") |
button:GetHighlightTexture():SetBlendMode("ADD") |
button:SetScript("OnEnter", SetItemTip) |
button:SetScript("OnLeave", HideTip2) |
button:SetScript("OnUpdate", ItemOnUpdate) |
button:SetScript("OnClick", LootClick) |
frame.button = button |
local buttonborder = CreateFrame("Frame", nil, button) |
buttonborder:SetWidth(32) |
buttonborder:SetHeight(32) |
buttonborder:SetPoint("CENTER", button, "CENTER") |
buttonborder:SetBackdrop(backdrop) |
buttonborder:SetBackdropColor(1, 1, 1, 0) |
frame.buttonborder = buttonborder |
local tfade = frame:CreateTexture(nil, "BORDER") |
tfade:SetPoint("TOPLEFT", frame, "TOPLEFT", 4, -4) |
tfade:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -4, 4) |
tfade:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") |
tfade:SetBlendMode("ADD") |
tfade:SetGradientAlpha("VERTICAL", .1, .1, .1, 0, .25, .25, .25, 1) |
local status = CreateFrame("StatusBar", nil, frame) |
status:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -4, -4) |
status:SetPoint("BOTTOM", frame, "BOTTOM", 0, 4) |
status:SetPoint("LEFT", frame.button, "RIGHT", -1, 0) |
status:SetScript("OnUpdate", StatusUpdate) |
status:SetFrameLevel(status:GetFrameLevel()-1) |
status:SetStatusBarTexture("Interface\\AddOns\\teksLoot\\DarkBottom.tga") |
status:SetStatusBarColor(.8, .8, .8, .9) |
status.parent = frame |
frame.status = status |
local spark = frame:CreateTexture(nil, "OVERLAY") |
spark:SetWidth(14) |
spark:SetHeight(35) |
spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark") |
spark:SetBlendMode("ADD") |
status.spark = spark |
local need, needtext = CreateRollButton(frame, "Interface\\Buttons\\UI-GroupLoot-Dice-Up", "Interface\\Buttons\\UI-GroupLoot-Dice-Highlight", "Interface\\Buttons\\UI-GroupLoot-Dice-Down", 1, NEED, "LEFT", frame.button, "RIGHT", 5, -1) |
local greed, greedtext = CreateRollButton(frame, "Interface\\Buttons\\UI-GroupLoot-Coin-Up", "Interface\\Buttons\\UI-GroupLoot-Coin-Highlight", "Interface\\Buttons\\UI-GroupLoot-Coin-Down", 2, GREED, "LEFT", need, "RIGHT", 0, -1) |
local de, detext |
de, detext = CreateRollButton(frame, "Interface\\Buttons\\UI-GroupLoot-DE-Up", "Interface\\Buttons\\UI-GroupLoot-DE-Highlight", "Interface\\Buttons\\UI-GroupLoot-DE-Down", 3, ROLL_DISENCHANT, "LEFT", greed, "RIGHT", 0, -1) |
local pass, passtext = CreateRollButton(frame, "Interface\\Buttons\\UI-GroupLoot-Pass-Up", nil, "Interface\\Buttons\\UI-GroupLoot-Pass-Down", 0, PASS, "LEFT", de or greed, "RIGHT", 0, 2.2) |
frame.needbutt, frame.greedbutt, frame.disenchantbutt = need, greed, de |
frame.need, frame.greed, frame.pass, frame.disenchant = needtext, greedtext, passtext, detext |
local bind = frame:CreateFontString() |
bind:SetPoint("LEFT", pass, "RIGHT", 3, 1) |
bind:SetFont(settings.font, 13, "THINOUTLINE") |
frame.fsbind = bind |
local loot = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall") |
loot:SetPoint("LEFT", bind, "RIGHT", 0, .12) |
loot:SetPoint("RIGHT", frame, "RIGHT", -5, 0) |
loot:SetHeight(16) |
loot:SetJustifyH("LEFT") |
frame.fsloot = loot |
frame.rolls = {} |
return frame |
end |
local anchor = CreateFrame("Button", nil, UIParent) |
anchor:SetWidth(300) anchor:SetHeight(22) |
anchor:SetBackdrop(backdrop) |
anchor:SetBackdropColor(0.25, 0.25, 0.25, 1) |
local label = anchor:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall") |
label:SetAllPoints(anchor) |
label:SetText("teksLoot") |
anchor:SetScript("OnClick", anchor.Hide) |
anchor:SetScript("OnDragStart", anchor.StartMoving) |
anchor:SetScript("OnDragStop", function(self) |
self:StopMovingOrSizing() |
self.db.x, self.db.y = self:GetCenter() |
end) |
anchor:SetMovable(true) |
anchor:EnableMouse(true) |
anchor:RegisterForDrag("LeftButton") |
anchor:RegisterForClicks("RightButtonUp") |
anchor:Hide() |
local frames = {} |
local f = CreateRollFrame() -- Create one for good measure |
f:SetPoint("TOPLEFT", next(frames) and frames[#frames] or anchor, "BOTTOMLEFT", 0, -4) |
table.insert(frames, f) |
local function GetFrame() |
for i,f in ipairs(frames) do |
if not f.rollid then return f end |
end |
local f = CreateRollFrame() |
f:SetPoint("TOPLEFT", next(frames) and frames[#frames] or anchor, "BOTTOMLEFT", 0, -4) |
table.insert(frames, f) |
return f |
end |
local function START_LOOT_ROLL(rollid, time) |
if cancelled_rolls[rollid] then return end |
local f = GetFrame() |
f.rollid = rollid |
f.time = time |
for i in pairs(f.rolls) do f.rolls[i] = nil end |
f.need:SetText(0) |
f.greed:SetText(0) |
f.pass:SetText(0) |
f.disenchant:SetText(0) |
local texture, name, count, quality, bop, canNeed, canGreed, canDisenchant = GetLootRollItemInfo(rollid) |
f.button:SetNormalTexture(texture) |
f.button.link = GetLootRollItemLink(rollid) |
if canNeed then f.needbutt:Enable() else f.needbutt:Disable() end |
if canGreed then f.greedbutt:Enable() else f.greedbutt:Disable() end |
if canDisenchant then f.disenchantbutt:Enable() else f.disenchantbutt:Disable() end |
SetDesaturation(f.needbutt:GetNormalTexture(), not canNeed) |
SetDesaturation(f.greedbutt:GetNormalTexture(), not canGreed) |
SetDesaturation(f.disenchantbutt:GetNormalTexture(), not canDisenchant) |
f.fsbind:SetText(bop and "BoP" or "BoE") |
f.fsbind:SetVertexColor(bop and 1 or .3, bop and .3 or 1, bop and .1 or .3) |
local color = ITEM_QUALITY_COLORS[quality] |
f.fsloot:SetVertexColor(color.r, color.g, color.b) |
f.fsloot:SetText(name) |
f:SetBackdropBorderColor(color.r, color.g, color.b, 1) |
f.buttonborder:SetBackdropBorderColor(color.r, color.g, color.b, 1) |
f.status:SetStatusBarColor(color.r, color.g, color.b, .7) |
f.status:SetMinMaxValues(0, time) |
f.status:SetValue(time) |
f:SetPoint("CENTER", WorldFrame, "CENTER") |
f:Show() |
end |
local function ParseRollChoice(msg) |
for i,v in pairs(ns.rollpairs) do |
local _, _, playername, itemname = string.find(msg, i) |
if playername and itemname and playername ~= "Everyone" then return playername, itemname, v end |
end |
end |
local in_soviet_russia = (GetLocale() == "ruRU") |
local function CHAT_MSG_LOOT(msg) |
local playername, itemname, rolltype = ParseRollChoice(msg) |
if playername and itemname and rolltype then |
if in_soviet_russia and rolltype ~= "pass" then itemname, playername = playername, itemname end |
for _,f in ipairs(frames) do |
if f.rollid and f.button.link == itemname and not f.rolls[playername] then |
f.rolls[playername] = rolltype |
f[rolltype]:SetText(tonumber(f[rolltype]:GetText()) + 1) |
return |
end |
end |
end |
end |
anchor:RegisterEvent("ADDON_LOADED") |
anchor:SetScript("OnEvent", function(frame, event, addon) |
if addon ~= "teksLoot" then return end |
anchor:UnregisterEvent("ADDON_LOADED") |
anchor:RegisterEvent("START_LOOT_ROLL") |
anchor:RegisterEvent("CHAT_MSG_LOOT") |
UIParent:UnregisterEvent("START_LOOT_ROLL") |
UIParent:UnregisterEvent("CANCEL_LOOT_ROLL") |
anchor:SetScript("OnEvent", function(frame, event, ...) if event == "CHAT_MSG_LOOT" then return CHAT_MSG_LOOT(...) else return START_LOOT_ROLL(...) end end) |
if not fdb then fdb = {} end |
anchor.db = fdb |
anchor:SetPoint("CENTER", UIParent, anchor.db.x and "BOTTOMLEFT" or "BOTTOM", anchor.db.x or 0, anchor.db.y or 221) |
end) |
SlashCmdList["TEKSLOOT"] = function() if anchor:IsVisible() then anchor:Hide() else anchor:Show() end end |
SLASH_TEKSLOOT1 = "/teksloot" |
local settings = oUF_Settings |
hooksecurefunc('PetActionBar_Update', function() |
for _, name in pairs({ |
'PetActionButton', |
'PossessButton', |
'ShapeshiftButton', |
}) do |
for i = 1, 12 do |
local button = _G[name..i] |
if (button) then |
local icon = _G[name..i..'Icon'] |
icon:SetTexCoord(.1, .9, .1, .9) |
icon:SetPoint("TOPRIGHT", button) |
icon:SetPoint("BOTTOMLEFT", button) |
icon:SetDrawLayer('BORDER') |
local cooldown = _G[name..i..'Cooldown'] |
cooldown:ClearAllPoints() |
cooldown:SetAllPoints(button) |
local normalTexture |
if (name == 'PetActionButton') then |
normalTexture = _G[name..i..'NormalTexture2'] |
else |
normalTexture = _G[name..i..'NormalTexture'] |
end |
if (not button.Border) then |
button.Border = button:CreateTexture(nil, "BACKGROUND") |
button.Border:SetPoint("TOPLEFT", -2, 2) |
button.Border:SetPoint("BOTTOMRIGHT", 2, -2) |
button.Border:SetTexture(0, 0, 0) |
end |
local border = _G[name.."Border"] |
if border then border:SetAlpha(0) end |
if normalTexture then |
normalTexture:SetAlpha(0) |
end |
end |
end |
end |
end) |
hooksecurefunc('ActionButton_Update', function(self) |
local totemButton = self:GetName():match("MultiCastAction") |
if (not totemButton) then |
local button = _G[self:GetName()] |
local normalTexture = _G[self:GetName()..'NormalTexture'] |
local icon = _G[self:GetName()..'Icon'] |
icon:SetTexCoord(.1, .9, .1, .9) |
icon:SetPoint("TOPRIGHT", button) |
icon:SetPoint("BOTTOMLEFT", button) |
icon:SetDrawLayer('BORDER') |
local hotkey = _G[self:GetName().."HotKey"] |
hotkey:SetFont(settings.font, 13, "OUTLINE") |
local count = _G[self:GetName().."Count"] |
count:SetFont(settings.font, 13, "OUTLINE") |
local name = _G[self:GetName().."Name"] |
name:SetFont(settings.font, 8, "OUTLINE") |
if (not button.Border) then |
button.Border = button:CreateTexture(nil, "BACKGROUND") |
button.Border:SetPoint("TOPLEFT", -2, 2) |
button.Border:SetPoint("BOTTOMRIGHT", 2, -2) |
button.Border:SetTexture(0, 0, 0) |
end |
local border = _G[self:GetName().."Border"] |
if border then border:SetAlpha(0) end |
if normalTexture then |
normalTexture:SetAlpha(0) |
end |
if (IsEquippedAction(self.action)) then |
_G[self:GetName()..'Border']:SetAlpha(1) |
else |
_G[self:GetName()..'Border']:SetAlpha(0) |
end |
end |
end) |
hooksecurefunc('ActionButton_ShowGrid', function(self) |
_G[self:GetName()..'NormalTexture']:SetAlpha(0) |
if (IsEquippedAction(self.action)) then |
_G[self:GetName()..'Border']:SetAlpha(1) |
else |
_G[self:GetName()..'Border']:SetAlpha(0) |
end |
end) |
hooksecurefunc('ActionButton_UpdateUsable', function(self) |
local isUsable, notEnoughMana = IsUsableAction(self.action) |
if (isUsable) then |
_G[self:GetName()..'Icon']:SetVertexColor(1, 1, 1) |
elseif (notEnoughMana) then |
_G[self:GetName()..'Icon']:SetVertexColor(.1,.3,1) |
else |
_G[self:GetName()..'Icon']:SetVertexColor(.4,.4,.4) |
end |
end) |
-- -------------------------------------------------------------------- |
-- create a new original function, |
-- its easier and do use less cpu cycles than a hooksecuredfunc (!) |
-- -------------------------------------------------------------------- |
function ActionButton_OnUpdate(self, elapsed) |
if (ActionButton_IsFlashing(self)) then |
local flashtime = self.flashtime |
flashtime = flashtime - elapsed |
if (flashtime <= 0) then |
local overtime = - flashtime |
if (overtime >= ATTACK_BUTTON_FLASH_TIME) then |
overtime = 0 |
end |
flashtime = ATTACK_BUTTON_FLASH_TIME - overtime |
local flashTexture = _G[self:GetName()..'Flash'] |
flashTexture:SetTexture(settings.glowTex) |
if (flashTexture:IsShown()) then |
flashTexture:Hide() |
else |
flashTexture:Show() |
end |
end |
self.flashtime = flashtime |
end |
local rangeTimer = self.rangeTimer |
if (rangeTimer) then |
rangeTimer = rangeTimer - elapsed |
if (rangeTimer <= 0) then |
local isInRange = false |
if (ActionHasRange(self.action) and IsActionInRange(self.action) == 0) then |
_G[self:GetName()..'Icon']:SetVertexColor(.8,.1,.1) |
isInRange = true |
end |
if (self.isInRange ~= isInRange) then |
self.isInRange = isInRange |
ActionButton_UpdateUsable(self) |
end |
rangeTimer = TOOLTIP_UPDATE_TIME |
end |
self.rangeTimer = rangeTimer |
end |
end |