Quantcast
WoWInterface: SVN - ristrettoPower - Path Comparison - /trunk Rev 1 and /trunk Rev 2

WoWInterface SVN ristrettoPower

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

r_Power.toc New file
0,0 → 1,7
## Interface: 40000
## Title: |cFF006699ristretto|r Power
## Description: Maelstrom, Combo, Shard, and Power Display
## SavedVariablesPerCharacter: rPwrConf
 
util.lua
core.lua
\ No newline at end of file
Armory.tga Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream
core.lua New file
0,0 → 1,396
addon, ns = ...
local util = ns.util
 
local pinfo = {
class = string.upper(select(2, UnitClass('player'))),
level = UnitLevel("player")
}
 
local __, _, _, tocversion = GetBuildInfo()
 
-- color definitions
local defaults = {
["SHAMAN"] = {
colors = { 0, 0, 1 },
blips = 5,
},
["PALADIN"] = {
colors = { 0.81, 0.04, 0.97 },
blips = 3,
},
["DRUID"] = {
colors = { 1, 1, 0 },
blips = 5,
},
["ROGUE"] = {
colors = { 1, 1, 0 },
blips = 5,
},
["WARLOCK"] = {
colors = { 0.81, 0.04, 0.97 },
blips = 3,
},
["PRIEST"] = {
colors = { 0.8, 0.4, 0.8 },
blips = 3,
},
}
 
-- if we don't have a color definition we don't need to carry on
if util.tmisses(defaults, pinfo.class) then return end
 
local backdrop = {
bgFile = [[Interface\ChatFrame\ChatFrameBackground]],
edgeFile = [[Interface/Tooltips/UI-Tooltip-Border]],
tile = true, tileSize = 4, edgeSize = 4,
insets = { left = 1, right = 1, top = 1, bottom = 1 }
}
 
if rPwrConf == nil then
rPwrConf = {
ato = "CENTER",
x = 0,
y = 0,
scale = 1,
enabled = true,
mycolors = nil,
}
end
 
local max_blip, red, green, blue, catStance
local cfg_size = 19
 
rCPFrame = CreateFrame("Frame", "rCPFrame")
rCPFrame:RegisterEvent("VARIABLES_LOADED")
 
rCPFrame:SetScript("OnEvent", function(self, event, ...)
if event == "VARIABLES_LOADED" then
self:UnregisterEvent("VARIABLES_LOADED")
self:Init()
end
end)
 
function rCPFrame:Init()
max_blip, red, green, blue = initClass()
 
if pinfo.class == "DRUID" or pinfo.class == "ROGUE" then
makeFrames(max_blip, red, green, blue, false)
util.updateVisuals(max_blip, util.currCP(), red, green, blue)
 
rCPFrame:RegisterEvent("UNIT_COMBO_POINTS")
rCPFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
 
if pinfo.class == "DRUID" then -- turn display off when not in kitty
druidShowHide()
rCPFrame:RegisterEvent("UPDATE_SHAPESHIFT_FORM")
end
 
if pinfo.class == "ROGUE" then
if rPwrConf.dpstack == true then -- envenom counter
rCPFrame:RegisterEvent("UNIT_AURA")
end
end
 
rCPFrame:SetScript("OnEvent", function(self, event, unit)
 
if pinfo.class == "DRUID" and event == "UPDATE_SHAPESHIFT_FORM" then
druidShowHide()
end
 
if pinfo.class == "ROGUE" and event == "UNIT_AURA" then
if rPwrConf.dpstack == true and unit == "target" then
local count = util.currDP()
util.updateBorder(5, count, 0, 0, 0, 0, 1, 0)
end
end
 
util.updateVisuals(max_blip, util.currCP(), red, green, blue)
 
if pinfo.class == "ROGUE" then
local count = util.currDP()
util.updateBorder(5, count, 0, 0, 0, 0, 1, 0)
end
 
if pinfo.class == "DRUID" then
druidShowHide()
end
end)
end
 
if pinfo.class == "PALADIN" then
max_blip, red, green, blue = initClass()
 
makeFrames(max_blip, red, green, blue, false)
util.updateVisuals(max_blip, util.currHolyPower(), red, green, blue)
rCPFrame:RegisterEvent("UNIT_POWER")
rCPFrame:SetScript("OnEvent", function(self, event, unit, power)
if unit ~= "player" or power ~= "HOLY_POWER" then return end
util.updateVisuals(max_blip, util.currHolyPower(), red, green, blue)
end)
end
 
if pinfo.class == "WARLOCK" then
max_blip, red, green, blue = initClass()
 
makeFrames(max_blip, red, green, blue, false)
util.updateVisuals(max_blip, util.currShards(), red, green, blue)
rCPFrame:RegisterEvent("UNIT_POWER")
rCPFrame:RegisterEvent("PLAYER_ALIVE")
rCPFrame:SetScript("OnEvent", function(self, event, unit, power)
if event == "PLAYER_ALIVE" then
util.updateVisuals(max_blip, util.currShards(), red, green, blue)
end
if unit ~= "player" or power ~= "SOUL_SHARDS" then return end
util.updateVisuals(max_blip, util.currShards(), red, green, blue)
end)
end
 
if pinfo.class == "SHAMAN" then
rCPFrame.spec = GetPrimaryTalentTree()
max_blip, red, green, blue = initClass()
 
if rCPFrame.spec == 2 then
cFunc = util.currMaelstrom
rCPFrame:RegisterEvent("UNIT_AURA")
elseif rCPFrame.spec == 1 then
rCPFrame:RegisterEvent("UNIT_AURA")
cFunc = util.currLB
max_blip = 6
end
 
rCPFrame:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
 
shamanShowHide(rCPFrame.spec)
if rCPFrame.spec ~= 3 then
util.updateVisuals(max_blip, cFunc(), red, green, blue)
end
 
rCPFrame:SetScript("OnEvent", function(self, event, unit)
if event == "ACTIVE_TALENT_GROUP_CHANGED" then
rCPFrame.spec = GetPrimaryTalentTree()
if rCPFrame.spec == 2 then
rCPFrame:RegisterEvent("UNIT_AURA")
cFunc = util.currMaelstrom
max_blip = 5
shamanShowHide(rCPFrame.spec)
util.updateVisuals(max_blip, cFunc(), red, green, blue)
elseif rCPFrame.spec == 1 then
rCPFrame:RegisterEvent("UNIT_AURA")
cFunc = util.currLB
max_blip = 6
shamanShowHide(rCPFrame.spec)
util.updateVisuals(max_blip, cFunc(), red, green, blue)
else
rCPFrame:UnregisterEvent("UNIT_AURA")
for i = 1, max_blip do
_G['powerframe'..i]:Hide()
end
end
else
if unit ~= "player" then return end
util.updateVisuals(max_blip, cFunc(), red, green, blue)
end
end)
end
 
if pinfo.class == "PRIEST" and GetPrimaryTalentTree() == 3 then
if pinfo.level < 80 then
print("Priest in Shadow spec detected but not 80, yet. Disabling to preserve pristine power in perpetuum. Reload UI after hitting 80.")
return false
end
max_blip, red, green, blue = initClass()
 
makeFrames(max_blip, red, green, blue, false)
util.updateVisuals(max_blip, util.currOrbs(), red, green, blue)
rCPFrame:RegisterEvent("UNIT_AURA")
rCPFrame:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
rCPFrame:SetScript("OnEvent", function(self, event, unit)
if event == "UNIT_AURA" then
if unit ~= "player" then return end
util.updateVisuals(max_blip, util.currOrbs(), red, green, blue)
elseif event == "ACTIVE_TALENT_GROUP_CHANGED" then
if GetPrimaryTalentTree() == 3 then
rCPFrame:RegisterEvent("UNIT_AURA")
priestShowHide(true)
util.updateVisuals(max_blip, util.currOrbs(), red, gree, blue)
else
rCPFrame:UnregisterEvent("UNIT_AURA")
priestShowHide(false)
end
end
end)
end
end
 
genFrame = function(red, green, blue, height, width)
local f = CreateFrame("Frame")
f:SetWidth(width * (rPwrConf.ratio or 1))
f:SetHeight(height)
f:SetBackdrop(backdrop)
f:SetBackdropColor(red,green,blue,0.5)
f:SetBackdropBorderColor(0,0,0,1)
f:Show()
return f
end
 
function makeFrames(num, red, green, blue, stretch)
local mult = 1
if stretch then
mult = 5 / num
end
for i = 1, num do
_G['powerframe'..i] = genFrame(red, green, blue, cfg_size, cfg_size * mult)
if i == 1 then
local gb = _G['powerframe1']
gb:SetPoint(rPwrConf.ato, UIParent, rPwrConf.ato, rPwrConf.x, rPwrConf.y)
gb:SetMovable(true)
gb:EnableMouse(true)
gb:RegisterForDrag("LeftButton")
gb:SetScript("OnDragStart", function(self)
if IsAltKeyDown() and IsShiftKeyDown() then
self:StartMoving()
end
end)
gb:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
_,_, rPwrConf.ato, rPwrConf.x, rPwrConf.y = self:GetPoint(1)
end)
gb:SetScale(rPwrConf.scale)
else
_G['powerframe'..i]:SetPoint("TOPLEFT", _G['powerframe'..i-1], "TOPRIGHT", 1, 0)
_G['powerframe'..i]:SetScale(rPwrConf.scale)
end
end
end
 
function initClass()
local red, green, blue
if rPwrConf.mycolors then
red, green, blue = unpack(rPwrConf.mycolors)
else
red, green, blue = unpack(defaults[pinfo.class]["colors"])
end
local blips = defaults[pinfo.class]["blips"]
return blips, red, green, blue
end
 
local function kittyStance()
local sid = 0
local cat = GetSpellInfo(768)
for i=1, GetNumShapeshiftForms() do
local _, name, _, _ = GetShapeshiftFormInfo(i)
if name == cat then sid = i end
end
return sid
end
 
function druidShowHide()
if GetShapeshiftForm() ~= kittyStance() and util.currCP() == 0 then
for i = 1, 5 do
rCPFrame:UnregisterEvent("UNIT_AURA")
_G['powerframe'..i]:Hide()
end
else
for i = 1, 5 do
rCPFrame:RegisterEvent("UNIT_AURA")
_G['powerframe'..i]:Show()
end
end
end
 
function priestShowHide(show)
if show then
for i = 1, 3 do
_G['powerframe'..i]:Show()
end
else
for i = 1, 3 do
_G['powerframe'..i]:Hide()
end
end
end
 
function shamanShowHide(spec)
if spec == 1 then
for i = 1,6 do
_G['powerframe'..i]:SetWidth(cfg_size * (5/6))
end
_G['powerframe6']:Show()
else
for i = 1,5 do
_G['powerframe'..i]:SetWidth(cfg_size)
end
_G['powerframe6']:Hide()
end
end
 
 
function ShowColorPicker(r, g, b, cback)
ColorPickerFrame:SetColorRGB(r,g,b);
ColorPickerFrame.previousValues = {r,g,b};
ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = cback, cback, cback;
ColorPickerFrame:Hide();
ColorPickerFrame:Show();
end
 
function colorCallback(bail)
local nr, ng, nb
if bail then
red, green, blue = unpack(bail)
else
red, green, blue = ColorPickerFrame:GetColorRGB();
end
util.updateVisuals(max_blip, max_blip, red, green, blue)
rPwrConf.mycolors = { red, green, blue }
end
 
SLASH_RP1 = "/rp"
SlashCmdList["RP"] = function(str)
local switch, message = str:match("^(%S*)%s*(.-)$");
local cmd = string.lower(switch)
local msg = string.lower(message)
 
if cmd == "scale" then
msg = tonumber(msg) or 1
if not(msg <= 5) then msg = 1 end
for i=1, max_blip do
rPwrConf.scale = msg
_G['powerframe'..i]:SetScale(msg)
end
elseif cmd == "dpstack" then
if rPwrConf.dpstack == nil or rPwrConf.dpstack == false then
rPwrConf.dpstack = true
rCPFrame:RegisterEvent("UNIT_AURA")
else
rPwrConf.dpstack = false
for i = 1, 5 do
_G["powerframe"..i]:SetBackdropBorderColor(0,0,0,1) -- black
end
rCPFrame:UnregisterEvent("UNIT_AURA")
end
elseif cmd == "color" then
if msg == "set" then
ShowColorPicker(red, green, blue, colorCallback)
elseif msg == "reset" then
red, green, blue = unpack(defaults[pinfo.class]["colors"])
ShowColorPicker(red, green, blue, colorCallback)
end
elseif cmd == "ratio" then
ra = tonumber(msg)
if ra < 0.2 or ra > 10 then ra = 1 end
rPwrConf.ratio = ra
for i = 1,max_blip do
local p = _G['powerframe'..i]
p:SetWidth(rPwrConf.ratio * floor(p:GetHeight()))
end
else
print("|cFF006699ristretto|r Power")
print("by Hoern, Nesingwary <hoern@d8c.us>")
print("Usage:")
print("/rp scale x||dpstack||color (set||reset)")
print("dpstack: turn deadly poison stacks on/off")
print("scale 0-5: grow/shrink blips")
print("color set: pick a color, any color")
print("color reset: ugh, that pink is hideous")
end
end
\ No newline at end of file
util.lua New file
0,0 → 1,77
addon, ns = ...
 
util = CreateFrame("Frame")
 
util.tmisses = function(tab, el)
for k, v in pairs(tab) do
if k == el then
return false
end
end
return true
end
 
util.currDP = function()
local dp = GetSpellInfo(72330)
local _, _, _, count, _, _, _, whodunnit = UnitAura("target", dp, nil, "HARMFUL")
if count == nil then return 0 end
return count
end
 
util.currMaelstrom = function ()
local msw = GetSpellInfo(53817)
local _, _, _, count, _, _, _, whodunnit = UnitAura("player", msw, nil, "HELPFUL")
if count == nil then return 0 end
if whodunnit == "player" then
return count
end
end
 
util.currOrbs = function()
local orb = GetSpellInfo(77487)
local _, _, _, count, _, _, _, whodunnit = UnitAura("player", orb, nil, "HELPFUL")
if count == nil then return 0 end
return count
end
 
util.currShards = function()
return UnitPower("player", SPELL_POWER_SOUL_SHARDS)
end
 
util.currHolyPower = function()
return UnitPower("player", SPELL_POWER_HOLY_POWER)
end
 
util.currCP = function()
return GetComboPoints("player")
end
 
util.currLB = function()
local lb = GetSpellInfo(324)
local _, _, _, count, _, _, _, whodunnit = UnitAura("player", lb, nil, "HELPFUL")
if count == nil then return 0 end
if count < 3 then return 0 end
return count - 3
end
 
util.updateBorder = function(max, curr, red, green, blue, redset, greenset, blueset)
for i = 1, max do
if i <= curr then
_G['powerframe'..i]:SetBackdropBorderColor(redset, greenset, blueset, 1)
else
_G['powerframe'..i]:SetBackdropBorderColor(red, green, blue, 1)
end
end
end
 
util.updateVisuals = function(max, curr, red, green, blue)
for i = 1, max do
if i <= curr then
_G['powerframe'..i]:SetBackdropColor(red, green, blue,1)
else
_G['powerframe'..i]:SetBackdropColor(red, green, blue,0.1)
end
end
end
 
ns.util = util
\ No newline at end of file
README.markdown New file
0,0 → 1,13
ristretto Power displays the UnitPower values for some classes (as well as Maelstrom for Shamans). It does so in a small frame, designed to have no actual properties to itself and be easily integrated into custom UI.
 
__To move the frame__, simply shift-alt-click and drag.
 
__To scale the frame__, type /rp scale n where n is from 0.1 to 5. scale 5 is freaking HUGE!
 
__Druid Combo Points__ remain visible even when in Bear/Cow/Nelf/Twilight form. It's how I, personally, like it, since I PvP a lot and sometimes want to know if I still have CP on someone even though I am currently in Cowform, healing myself or others. I can see how that's annoying to non-ferals or people who heal/tank/lolchicken sometimes, I'll make sure it turns off for those in the next version.
 
__Maelstrom Frame__ will stay up even if you don't have Maelstrom Weapon. It's a one-liner to check for that, I'll add it into the next version (see below) if people really want it. Alternatively just turn it off per character.
 
**Next Version?**
 
I just put this together in a few minutes to have something to do heroics with, figured I'd upload it quick and then roll out a version with actual needed changes tomorrow.