/trunk/Stuf
## Interface: 60200 |
## Interface: 70000 |
## LoadOnDemand: 1 |
## X-Curse-Packaged-Version: 6.2.0 |
## X-Curse-Packaged-Version: r95 |
## X-Curse-Project-Name: LibSharedMedia-3.0 |
## X-Curse-Project-ID: libsharedmedia-3-0 |
## X-Curse-Repository-ID: wow/libsharedmedia-3-0/mainline |
## Title: Lib: SharedMedia-3.0 |
## Notes: Shared handling of media data (fonts, sounds, textures, ...) between addons. |
## Author: Elkano |
## Version: 3.0-93 |
## Version: 3.0-95 |
## X-Website: http://www.wowace.com/projects/libsharedmedia-3-0/ |
## X-Category: Library |
## X-Revision: 93 |
## X-Date: 2015-06-24T01:30:16Z |
## X-Revision: 95 |
## X-Date: 2016-07-19T22:45:58Z |
LibStub\LibStub.lua |
CallbackHandler-1.0\CallbackHandler-1.0.lua |
end |
end |
local CLASS_BUTTONS = CLASS_ICON_TCOORDS or CLASS_BUTTONS |
local function UpdateInfoIcon(unit, uf, f) -- Class/info icon |
uf = uf or su[unit] |
f = f or (uf and not uf.hidden and uf.infoicon) |
uf = uf or su[unit] |
local f = uf and not uf.hidden and uf.comboframe |
if not f or f.db.hide then return end |
local points = (config and 5) or GetComboPoints(Stuf.vunit, unit) |
local points = (config and 6) or GetComboPoints(Stuf.vunit, unit) |
if points > 0 then |
if f.individual then |
for i = 1, 5, 1 do |
for i = 1, 6, 1 do |
if i <= points then |
f[i]:Show() |
else |
end |
end |
else |
local offsetr = points * 0.2 |
local offsetl = offsetr - 0.2 |
local offsetr = points * 0.167 |
local offsetl = offsetr - 0.167 |
if f.db.tflip then |
f.texture:SetTexCoord(offsetr, offsetl, 0, 0.5) |
f.glow:SetTexCoord(offsetr, offsetl, 0.5, 1) |
end |
end |
local function UpdateComboPoints(unit, uf, _, _, _, config) |
if uf then |
UpdateFrameCombo(unit, uf, config) |
elseif unit == "player" or unit == "vehicle" then |
--if uf then |
-- UpdateFrameCombo(unit, uf, config) |
--elseif unit == "player" or unit == "vehicle" then |
UpdateFrameCombo("target", nil, config) |
UpdateFrameCombo("focus", nil, config) |
end |
--end |
end |
local function ComboOnUpdate(this, a1) |
local dir = this.dir or 1 |
this.alp = alp |
if this.individual then |
for i = 1, 5, 1 do |
for i = 1, 6, 1 do |
local g = this[i].glow |
if g.a > 0.2 then |
g:SetAlpha(alp) |
f = CreateFrame("Frame", nil, uf) |
f:SetScript("OnUpdate", ComboOnUpdate) |
Stuf:AddEvent("UNIT_COMBO_POINTS", UpdateComboPoints) |
Stuf:AddEvent("UNIT_POWER_FREQUENT", UpdateComboPoints) |
uf.refreshfuncs[name] = UpdateComboPoints |
f.db = db |
if db.combostyle == 2 then -- individual circles |
f.individual = true |
for i = 1, 5, 1 do |
for i = 1, 6, 1 do |
local c = f[i] or CreateFrame("Frame", nil, f) |
c:SetWidth(db["combo"..i.."w"] or 10) |
c:SetHeight(db["combo"..i.."h"] or 10) |
f.texture:Show() |
f:Show() |
if f[1] then |
for i = 1, 5, 1 do |
for i = 1, 6, 1 do |
f[i]:Hide() |
end |
end |
end) |
local CreateFrame = CreateFrame |
local UnitCanAttack, UnitIsTapped, UnitIsTappedByPlayer = UnitCanAttack, UnitIsTapped, UnitIsTappedByPlayer |
local UnitCanAttack = UnitCanAttack |
local UnitIsTapDenied = UnitIsTapDenied |
local UnitIsDeadOrGhost, UnitIsDead, UnitIsGhost, UnitIsConnected = UnitIsDeadOrGhost, UnitIsDead, UnitIsGhost, UnitIsConnected |
local UnitIsAFK, UnitIsDND = UnitIsAFK, UnitIsDND |
local UnitSex = UnitSex |
helpful = function(ca, unit) return ca.assist end, |
hostile = function(ca, unit) return ca.hostile end, |
attackable = function(ca, unit) return ca.attackable end, |
tapped = function(ca, unit) return UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) end, |
tapped = function(ca, unit) return UnitIsTapDenied(unit) end, |
alive = function(ca, unit) return not ca.dead end, |
dead = function(ca, unit) return ca.dead and UnitIsDead(unit) end, |
ghost = function(ca, unit) return ca.dead and UnitIsGhost(unit) end, |
if amount ~= 0 then |
if amount > 999999 then |
text = format("-%.2fM", amount/1000000) |
elseif amount > 99999 then |
text = format("-%dK", amount/1000) |
else |
text = "-"..amount |
end |
elseif cevent == "HEAL" then |
if amount > 999999 then |
text = format("+%.2fM", amount/1000000) |
elseif amount > 99999 then |
text = format("-%dK", amount/1000) |
else |
text = "+"..amount |
end |
## Interface: 60200 |
## Interface: 70000 |
## Title: Stuf Unit Frames |
## Author: TotalPackage |
## Notes: Main unitframes replacement. Assembly optional. |
## Version: 6.2.002 |
## Version: 7.0.001 |
## SavedVariables: StufDB |
## SavedVariablesPerCharacter: StufCharDB |
end) |
end |
if CLS == "DRUID" then -- Druid Bar ------------------------------------------------------------------------------ |
if CLS == "DRUID" or CLS == "PRIEST" or "SHAMAN" then -- Druid Bar ------------------------------------------------------------------------------ |
Stuf:AddBuilder("druidbar", function(unit, uf, name, db) |
if unit ~= "player" then return end |
local f = uf[name] |
local c = db.barcolor or Stuf.whitecolor |
f.bar:SetVertexColor(c.r, c.g, c.b, db.baralpha or c.a or 1) |
end) |
Stuf:AddBuilder("eclipsebar", function(unit, uf, name, db, a5, config) |
end |
if CLS == "DEATHKNIGHT" then -- Rune Bar ------------------------------------------------------------------------------------------------------- |
Stuf:AddBuilder("runebar", function(unit, uf, name, db, a5, config) |
if unit ~= "player" then return end |
local f = EclipseBarFrame |
local f = RuneFrame |
if not f or db.hide then |
if f then f:Hide() end |
if f then |
f:Hide() |
f:SetAlpha(0) |
end |
return |
end |
f:EnableMouse(not db.nomouse) |
f:Show() |
end) |
end |
if CLS == "DEATHKNIGHT" then -- Rune Bar ------------------------------------------------------------------------------------------------------- |
local UpdateRuneBar, UpdateRuneType, UpdateAllRunes |
Stuf:AddBuilder("runebar", function(unit, uf, name, db, a5, config) |
if unit ~= "player" then return end |
local f = uf[name] |
if db.usedefault then |
local d = RuneFrame |
d:SetParent(uf) |
d:SetPoint("TOP", uf, "BOTTOM", db.x or 0, db.y or 0) |
d:SetScale(db.scale or 1) |
d:SetAlpha(db.alpha or 1) |
if db.framelevel then |
d:SetFrameLevel(db.framelevel) |
end |
d:Show() |
d:RegisterEvent("RUNE_POWER_UPDATE") |
d:RegisterEvent("RUNE_TYPE_UPDATE") |
d:RegisterEvent("PLAYER_ENTERING_WORLD") |
RuneFrame_OnEvent(d, "PLAYER_ENTERING_WORLD") |
if f then f:Hide() end |
return |
end |
if db.hide then |
if f then f:Hide() end |
return |
end |
RuneFrame:UnregisterAllEvents() |
RuneFrame:Hide() |
if not f then |
f = CreateFrame("Frame", nil, uf) |
f:SetWidth(2) |
f:SetHeight(2) |
f.db = db |
uf[name] = f |
db.growth = db.growth or "TBLR" |
db.rows = db.rows or 2 |
db.spacing = db.spacing or 1 |
dbg.runecolor = dbg.runecolor or { } |
local dbgr = dbg.runecolor |
dbgr.BLOOD = dbgr.BLOOD or { r = 1, g = 0, b = 0, } |
dbgr.UNHOLY = dbgr.UNHOLY or { r = 0, g = 0.7, b = 0, } |
dbgr.FROST = dbgr.FROST or { r = 0, g = 1, b = 1, } |
dbgr.DEATH = dbgr.DEATH or { r = 0.8, g = 0.1, b = 1, } |
local function RuneOnUpdate(this, a1) |
local e = (this.elapsed or 0) + a1 |
if e > 0.07 then |
e = 0 |
local value = (GetTime() - this.start) * this.duration |
if value < 1 then |
this.bar:SetValue(value, this.bvalue) |
this.bar:SetAlpha(value * 0.4 + 0.3) |
else |
this.bar:SetValue(1, this.bvalue) |
this.bar:SetAlpha(1) |
end |
end |
this.elapsed = e |
end |
for i = 1, 8, 1 do |
local b = CreateFrame("Frame", nil, f) |
b.bg = b:CreateTexture(nil, "BACKGROUND") |
b.bg:SetAllPoints(b) |
b.barbase = CreateFrame("Frame", nil, b) |
b.bar = b:CreateTexture(nil, "ARTWORK") |
b.ename = name |
b.id = i |
f[i] = b |
end |
local GetRuneType, GetRuneCooldown = GetRuneType, GetRuneCooldown |
local runeMapping = { "BLOOD", "UNHOLY", "FROST", "DEATH", } |
UpdateRuneBar = function(rune, usable) |
local rf = f[rune or 20] |
if not rf then return end |
if usable then |
rf:SetScript("OnUpdate", nil) |
rf.bar:SetValue(1, rf.bvalue) |
rf.bar:SetAlpha(1) |
else |
local start, duration, runeReady = GetRuneCooldown(rune) |
if not duration or duration == 0 then |
rf:SetScript("OnUpdate", nil) |
rf.bar:SetValue(1, rf.bvalue) |
rf.bar:SetAlpha(1) |
else |
rf.elapsed = 1 |
rf.start = start |
rf.duration = 1 / duration |
rf:SetScript("OnUpdate", RuneOnUpdate) |
end |
end |
end |
UpdateRuneType = function(rune) |
if not rune then return end |
local runeType = GetRuneType(rune) |
local rf = f[rune] |
if runeType then |
local c = dbg.runecolor[ runeMapping[runeType] ] |
rf.bar:SetVertexColor(c.r, c.g, c.b) |
rf:Show() |
UpdateRuneBar(rune, select(3, GetRuneCooldown(rune))) |
else |
rf:Hide() |
end |
end |
UpdateAllRunes = function() |
for i = 1, 8, 1 do |
UpdateRuneType(i) |
end |
end |
Stuf:AddEvent("RUNE_POWER_UPDATE", UpdateRuneBar) |
Stuf:AddEvent("RUNE_TYPE_UPDATE", UpdateRuneType) |
uf.refreshfuncs[name] = UpdateAllRunes |
else |
f:Show() |
end |
f:SetPoint("TOPLEFT", db.x, db.y) |
f:SetFrameLevel(db.framelevel or 3) |
f:SetAlpha(db.alpha or 1) |
local d1, d2, d3, d4, hdir, vdir = Stuf.GrowthBreakdown(db.growth) |
local cols, rows, spacing, vspacing = 8/db.rows, db.rows, db.spacing, db.vspacing or db.spacing |
local hfirst = (d1 == "LEFT" or d1 == "RIGHT") |
for i = 1, 8, 1 do |
local rf = f[i] |
UpdateBarLook(unit, uf, rf, db) |
rf:ClearAllPoints() |
if hfirst then -- LRTB, LRBT, RLTB, RLBT |
local crow = ceil(i / cols) |
local ccol = i % cols |
ccol = (ccol == 0 and cols) or ccol |
if i == 1 then -- first row, first col |
rf:SetPoint(d3..d1, f, d3..d1) |
elseif ccol == 1 then -- start of a new row (first column) |
rf:SetPoint(d3, f[i - cols], d4, 0, vspacing * vdir) |
else |
rf:SetPoint(d1, f[i - 1], d2, spacing * hdir, 0) |
end |
else -- TBLR, TBRL, BTLR, BTRL |
local ccol = ceil(i / rows) |
local crow = i % rows |
crow = (crow == 0 and rows) or crow |
if i == 1 then -- first row, first col |
rf:SetPoint(d1..d3, f, d1..d3) |
elseif crow == 1 then -- start of a new column (first row) |
rf:SetPoint(d3, f[i - rows], d4, spacing * hdir, 0) |
else |
rf:SetPoint(d1, f[i - 1], d2, 0, vspacing * vdir) |
end |
end |
end |
if Stuf.inworld then |
UpdateAllRunes() |
end |
end) |
end |
if CLS == "PALADIN" then -- Holy Bar ------------------------------------------------------------------------------------------------------- |
Stuf:AddBuilder("holybar", function(unit, uf, name, db, a5, config) |
if unit ~= "player" then return end |
local f = PaladinPowerBar |
local f = PaladinPowerBarFrame |
if not f or db.hide then |
if f then f:Hide() end |
return |
f:SetFrameStrata(db.strata) |
end |
f:EnableMouse(not db.nomouse) |
PaladinPowerBar_OnLoad(f) |
--PaladinPowerBar_OnLoad(f) |
end) |
end |
f:SetFrameStrata(db.strata) |
end |
f:EnableMouse(not db.nomouse) |
PriestBarFrame_OnLoad(f) |
end) |
end |
if CLS == "MONK" then -- Monk Power Frame ----------------------------------------------------------------------------------------------- |
Stuf:AddBuilder("chibar", function(unit, uf, name, db, a5, config) |
if unit ~= "player" then return end |
local f = MonkHarmonyBar |
local f = MonkHarmonyBarFrame |
if not f or db.hide then |
if f then f:Hide() end |
return |
_G.MonkHarmonyBar["lightEnergy"..i]:EnableMouse(not db.nomouse) |
end |
end |
MonkHarmonyBar_OnLoad(f) |
end) |
end |
end |
end |
if UnitGroupRolesAssigned and not db.player.lfgicon then |
db.player.lfgicon = db.player.lfgicon or { alpha=0.6, w=16, h=16, } |
db.party1.lfgicon = db.party1.lfgicon or { alpha=0.6, w=14, h=14, } |
db.target.lfgicon = db.target.lfgicon or { hide=true, } |
end |
db.player.holybar = db.player.holybar or { x=0, y=0, } |
db.player.shardbar = db.player.shardbar or { x=0, y=0, } |
db.player.chibar = db.player.chibar or { x=0, y=0, } |
db.player.eclipsebar = db.player.eclipsebar or { x=0, y=0, } |
db.player.priestbar = db.player.priestbar or { x=0, y=0, } |
dbg = db.global |
classcolor, powercolor, reactioncolor = dbg.classcolor, dbg.powercolor, dbg.reactioncolor |
classcolor.MONK = classcolor.MONK or { r=RAID_CLASS_COLORS.MONK.r, g=RAID_CLASS_COLORS.MONK.g, b=RAID_CLASS_COLORS.MONK.b, } |
if dbg.initlegion ~= 1 then |
for i = 0, 20, 1 do |
local color = PowerBarColor[i] |
if color and (not powercolor[i] or not powercolor[i].r) then |
powercolor[i]={ r=color.r, g=color.g, b=color.b, } |
end |
end |
for class, color in pairs(CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS) do |
if not classcolor[class] or not classcolor[class].r then |
classcolor[class]={ r=color.r, g=color.g, b=color.b, } |
end |
end |
dbg.classification.unknown = dbg.classification.unknown or "??" |
dbg.nK, dbg.nM = dbg.nK or "K", dbg.nM or "M" |
if UnitGroupRolesAssigned and not db.player.lfgicon then |
db.player.lfgicon = db.player.lfgicon or { alpha=0.6, w=16, h=16, } |
db.party1.lfgicon = db.party1.lfgicon or { alpha=0.6, w=14, h=14, } |
db.target.lfgicon = db.target.lfgicon or { hide=true, } |
end |
db.player.holybar = db.player.holybar or { x=0, y=0, } |
db.player.shardbar = db.player.shardbar or { x=0, y=0, } |
db.player.chibar = db.player.chibar or { x=0, y=0, } |
db.player.eclipsebar = db.player.eclipsebar or { x=0, y=0, } |
db.player.priestbar = db.player.priestbar or { x=0, y=0, } |
dbg.initlegion = 1 |
end |
hpgreen, hpred, gray = dbg.hpgreen, dbg.hpred, dbg.gray |
dbg.classification.unknown = dbg.classification.unknown or "??" |
dbg.nK, dbg.nM = dbg.nK or "K", dbg.nM or "M" |
Stuf.dbg = db.global |
Stuf.statusbar = Stuf:GetMedia("statusbar", dbg.bartexture) |