WoWInterface SVN RaidFramesPlus

Compare Revisions

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

Rev 2 → Rev 3

DebuffBorder.tga Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
RaidFramesPlus.toc File deleted \ No newline at end of file
core.lua File deleted \ No newline at end of file
watching.tga Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
trunk/RaidFramesPlus.toc New file
0,0 → 1,9
## Interface: 30000
## Title: RaidFrames+
## Notes: provides some usefull additions to your default Blizzard Interface, to configure you need GetOpt
## Author: Christoph Bähr
## Version: 2.0
## OptionalDeps: GetOpt
## SavedVariables: RaidFramesPlus_Health, RaidFramesPlus_CompactPullouts, RaidFramesPlus_ColorizeNames, RaidFramesPlus_HideTargetFrameNameBackground, RaidFramesPlus_CustomFormat
 
core.lua
\ No newline at end of file
trunk/core.lua New file
0,0 → 1,553
-- AddonFrame
local RaidFramesPlus = CreateFrame("Frame")
 
-- local variables
local RaidFramesPlus_ShowBuffs = 0 -- Raidwide toggle status for Debuff/Buff display
RaidFramesPlus_FontStringArray = {} -- Associated Lookuptable (key : UnitId; value : Array of FontStrings )
RaidFramesPlus_DebuffBackgroundArray = {} -- Associated Lookuptable (key: UnitId; value : Array of Textures )
local RaidFramesPlus_ReplaceTable = { -- Associated Lookuptable (key: replaceable-token; value : function )
["$abs"] = function(UnitId)
return UnitHealth(UnitId)
end,
 
["$max"] = function(UnitId)
return UnitHealthMax(UnitId)
end,
 
["$dif"] = function(UnitId)
return UnitHealth(UnitId) - UnitHealthMax(UnitId)
end,
 
["$abk"] = function(UnitId)
local value = UnitHealth(UnitId)
if value > 1000 then
return string.format("%.1fk", value/1000)
else
return value
end
end,
["$mak"] = function(UnitId)
local value = UnitHealthMax(UnitId)
if value > 1000 then
return string.format("%.1fk", value/1000)
else
return value
end
end,
["$difk"] = function(UnitId)
local value = UnitHealthMax(UnitId) - UnitHealth(UnitId)
if value > 1000 then
return string.format("-%.1fk", value/1000)
else
return value
end
end,
}
local RaidFramesPlus_ParseTable = { -- Slashcommand Table for GetOpt.getopt
{"health", "h", "#",
"change the display of healthtext (0 : No Text; 1 : Absolute Value; 2 : Percent; 3: K-values;"..
"4: custom-format (use -f <format> )"},
{"compact", "p", "#",
"change the position of the Debuffs and the name text into a more compact style (1 : compact;"..
"0 : default)"},
{"colorize", "c", "#",
"colorize the name of partymember, player and target into the raid class color (1 : colorize;"..
"0 : do not colorize)"},
{"format", "f", ":",
"choose the format to customize health-display format"},
{"targetframe", "t", "#",
"hide the targetframe background to read a colorized name better (1: hide; 0: show)"},
{"debuffs", "d", nil,
"Toggle between debuff and buff display"},
{"help", "?", nil,
"show this help file"},
}
 
-- functions
--[[
-- RaidFramesPlus_UnitThreatSituationUpdate
-- TAKES
-- UnitId (uitype:UNIT)
-- RETURNS
-- nil
--
-- DESCRIPTION
-- this function scopes in RaidFramesPlus_FontStringArray with given UnitId parameter to access
-- fontStrings that are associated to the UnitButton in RaidPullouts to color it by the
-- corresponding Threat Situation.
--]]
local function RaidFramesPlus_UnitThreatSituationUpdate(UnitId)
local FontStringArray = RaidFramesPlus_FontStringArray[UnitId]
if FontStringArray == {} or FontStringArray == nil then
return
end
for i, fontString in pairs(FontStringArray) do
local threatState = UnitThreatSituation(UnitId)
if threatState == 0 then
_G[fontString]:SetVertexColor(1,1,1,1)
elseif threatState == 1 then
_G[fontString]:SetVertexColor(1, 0.75, 0, 1)
elseif threatState == 2 then
_G[fontString]:SetVertexColor(1, 0.5, 0, 1)
else
_G[fontString]:SetVertexColor(1, 0, 0, 1)
end
end
end
--[[
-- RaidFramesPlus_PlayerTargetchanged
-- TAKES
-- nil
-- RETURNS
-- nil
--
-- DESCRIPTION
-- color name of the target by the corresponding class color (if the flag RaidFramesPlus_ColorizeNames is set)
--]]
local function RaidFramesPlus_PlayerTargetChanged()
if RaidFramesPlus_ColorizeNames == 1 then
local classcolor = RAID_CLASS_COLORS[select(2, UnitClass("Target"))] or {r = 1, g = 0.82, b = 0}
TargetName:SetVertexColor(classcolor.r, classcolor.g, classcolor.b, 1)
else
TargetName:SetVertexColor(1, 0.82, 0, 1)
end
if RaidFramesPlus_HideTargetFrameNameBackground == 1 then
TargetFrameNameBackground:Hide()
else
TargetFrameNameBackground:Show()
end
end
--[[
-- RaidFramesPlus_GetDebuffColor
-- TAKES
-- UnitId (uitype:UNIT)
-- RETURNS
-- r (type:number)
-- g (type:number)
-- b (type:number)
-- a (type:number)
--
-- DESCRIPTION
-- this function returns the color of the latest debuff from the Unit with the given UnitId-Token.
--]]
local function RaidFramesPlus_GetDebuffColor(UnitId)
local r,g,b,a
local latestDebuffType
if GetCVarBool("showDispelDebuffs") then
latestDebuffType = select(5, UnitAura(UnitId, 1, "HARMFUL|RAID"))
else
latestDebuffType = select(5, UnitAura(UnitId, 1, "HARMFUL"))
end
if latestDebuffType ~= nil then
r = DebuffTypeColor[latestDebuffType].r
g = DebuffTypeColor[latestDebuffType].g
b = DebuffTypeColor[latestDebuffType].b
a = 1
else
r = 0
g = 0
b = 0
a = 0
end
return r,g,b,a
end
--[[
-- RaidFramesPlus_UnitAura
-- TAKES
-- UnitId (uitype:UNIT)
-- RETURNS
-- nil
--
-- DESCRIPTION
-- this function change the color or hide the scoped debuff background's with the corresponding
-- UnitId by using RaidFramesPlus_GetDebuffColor
--
-- SEE ALSO
-- RaidFramesPlus_GetDebuffColor
-- RaidFramesPlus_UnitThreatSituationUpdate
--]]
local function RaidFramesPlus_UnitAura(UnitId)
-- check the probably populated Array for an associated texture
local backgroundArray = RaidFramesPlus_DebuffBackgroundArray[UnitId]
if backgroundArray == nil then
return
end
for i, background in pairs(backgroundArray) do
if background then
 
_G[background]:SetVertexColor(RaidFramesPlus_GetDebuffColor(UnitId))
end
end
end
--[[
-- RaidFramesPlus_PartyMemberChanged
--]]
local function RaidFramesPlus_PartyMemberChanged()
if RaidFramesPlus_ColorizeNames == 1 then
local classcolor = RAID_CLASS_COLORS[select(2, UnitClass("Player"))]
PlayerName:SetVertexColor(classcolor.r, classcolor.g, classcolor.b, 1)
else
PlayerName:SetVertexColor(1, 0.82, 0, 1)
end
if RaidFramesPlus_ColorizeNames == 1 then
local classcolor = RAID_CLASS_COLORS[select(2, UnitClass("Party1"))] or {r = 1, g = 0.82, b = 0}
PartyMemberFrame1Name:SetVertexColor(classcolor.r, classcolor.g, classcolor.b, 1)
else
PartyMemberFrame1Name:SetVertexColor(1, 0.82, 0, 1)
end
if RaidFramesPlus_ColorizeNames == 1 then
local classcolor = RAID_CLASS_COLORS[select(2, UnitClass("Party2"))] or {r = 1, g = 0.82, b = 0}
PartyMemberFrame2Name:SetVertexColor(classcolor.r, classcolor.g, classcolor.b, 1)
else
PartyMemberFrame2Name:SetVertexColor(1, 0.82, 0, 1)
end
if RaidFramesPlus_ColorizeNames == 1 then
local classcolor = RAID_CLASS_COLORS[select(2, UnitClass("Party3"))] or {r = 1, g = 0.82, b = 0}
PartyMemberFrame3Name:SetVertexColor(classcolor.r, classcolor.g, classcolor.b, 1)
else
PartyMemberFrame3Name:SetVertexColor(1, 0.82, 0, 1)
end
if RaidFramesPlus_ColorizeNames == 1 then
local classcolor = RAID_CLASS_COLORS[select(2, UnitClass("Party4"))] or {r = 1, g = 0.82, b = 0}
PartyMemberFrame4Name:SetVertexColor(classcolor.r, classcolor.g, classcolor.b, 1)
else
PartyMemberFrame4Name:SetVertexColor(1, 0.82, 0, 1)
end
end
--[[
-- RaidFramesPlus_RaidRoasterUpdate
-- TAKES
-- nil
-- RETURNS
-- nil
--
-- DESCRIPTION
-- this function adds newly added RaidPullouts (and buttons) to scoping-tables indexed with
-- UnitId. Also it colorize Partymember names by thier class color if flag
-- RaidFramesPlus_ColorizeNames is set) and hide TargetFrameNameBackground for better reading
-- the class-colored Targetname if flag RaidFramesPlus_HideTargetFrameNameBackground is set
--]]
local function RaidFramesPlus_RaidRosterUpdate()
 
-- first we depopulate the list
RaidFramesPlus_DebuffBackgroundArray = {}
RaidFramesPlus_FontStringArray = {}
 
-- we will now populate the RaidFramesPlus_FontStringArray
-- first, we check for a RaidPullout
local pullout = 0
while(_G["RaidPullout"..pullout+1] ~= nil) do
-- there is a next RaidPullout so lets use it
pullout = pullout + 1
-- now we check for RaidButtons
local button = 0
while(_G["RaidPullout"..pullout.."Button"..button+1] ~= nil) do
-- there is a next RaidPulloutButton so lets use it
button = button + 1
btn = _G["RaidPullout"..pullout.."Button"..button]
-- create a backgroundlayer for Debuff Indicator
local background = _G["RaidPullout"..pullout.."Button"..button.."Debuff"] or
btn:CreateTexture("RaidPullout"..pullout.."Button"..button.."Debuff", "BACKGROUND")
background:SetTexture("Interface\\AddOns\\RaidFramesPlus\\DebuffBorder")
background:SetBlendMode("ADD")
background:SetWidth(82)
background:SetHeight(36)
background:SetPoint("TOPLEFT", btn, "TOPLEFT", -6, 6)
background:SetTexCoord(0.0, 0.640625, 0, 0.625)
 
background:SetVertexColor(RaidFramesPlus_GetDebuffColor(btn.unit))
-- and register it
if( type(RaidFramesPlus_DebuffBackgroundArray[btn.unit]) == "table") then
tinsert(RaidFramesPlus_DebuffBackgroundArray[btn.unit],background:GetName())
else
RaidFramesPlus_DebuffBackgroundArray[btn.unit] = {background:GetName()}
end
-- use the exsiting HealthFontString or create a new one
local fontString = _G["RaidPullout"..pullout.."Button"..button.."Health"] or
getglobal(btn:GetName().."HealthBar"):CreateFontString("RaidPullout"..pullout.."Button"..button.."Health",
"OVERLAY")
 
if fontString:GetFontObject() == nil then
fontString:SetFontObject("NumberFontNormalSmall")
end
 
-- now some adjustments
fontString:SetPoint("CENTER", getglobal(btn:GetName().."HealthBar"), "BOTTOM", 0, 0)
-- and something to display
fontString:SetText(RaidFramesPlus_GetHealthValue(btn.unit))
-- and do not forget to register this fontString
if( type(RaidFramesPlus_FontStringArray[btn.unit]) == "table") then
tinsert(RaidFramesPlus_FontStringArray[btn.unit],fontString:GetName())
else
RaidFramesPlus_FontStringArray[btn.unit] = {fontString:GetName()}
end
 
-- move the first debuff/buff frame into the pulloutbutton (CT_RAID STYLE)
local orgPoint = _G["RaidPullout"..pullout.."Button"..button.."Aura1"]:GetPoint()
local show1 = _G["RaidPullout"..pullout.."Button"..button.."Aura2"].Show
local show2 = _G["RaidPullout"..pullout.."Button"..button.."Aura3"].Show
local show3 = _G["RaidPullout"..pullout.."Button"..button.."Aura4"].Show
 
 
 
if RaidFramesPlus_CompactPullouts == 1 then
_G["RaidPullout"..pullout.."Button"..button.."Aura1"]:ClearAllPoints()
_G["RaidPullout"..pullout.."Button"..button.."Aura1"]:SetPoint("BOTTOMRIGHT",
_G["RaidPullout"..pullout.."Button"..button.."HealthBar"], "TOPRIGHT", 0, 2)
_G["RaidPullout"..pullout.."Button"..button.."Aura1"]:SetFrameLevel(
_G["RaidPullout"..pullout.."Button"..button]:GetFrameLevel() + 1)
 
_G["RaidPullout"..pullout.."Button"..button.."Aura2"]:Hide()
_G["RaidPullout"..pullout.."Button"..button.."Aura2"].Show = function() end
 
_G["RaidPullout"..pullout.."Button"..button.."Aura3"]:Hide()
_G["RaidPullout"..pullout.."Button"..button.."Aura3"].Show = function() end
 
_G["RaidPullout"..pullout.."Button"..button.."Aura4"]:Hide()
_G["RaidPullout"..pullout.."Button"..button.."Aura4"].Show = function() end
 
-- justify Names left (CT_RAID STYLE)
_G["RaidPullout"..pullout.."Button"..button.."Name"]:SetJustifyH("LEFT")
else
_G["RaidPullout"..pullout.."Button"..button.."Aura1"]:ClearAllPoints()
_G["RaidPullout"..pullout.."Button"..button.."Aura1"]:SetPoint(orgPoint)
 
_G["RaidPullout"..pullout.."Button"..button.."Aura2"].Show = show1
_G["RaidPullout"..pullout.."Button"..button.."Aura2"]:Show()
 
_G["RaidPullout"..pullout.."Button"..button.."Aura3"].Show = show2
_G["RaidPullout"..pullout.."Button"..button.."Aura3"]:Show()
 
_G["RaidPullout"..pullout.."Button"..button.."Aura4"].Show = show3
_G["RaidPullout"..pullout.."Button"..button.."Aura4"]:Show()
 
_G["RaidPullout"..pullout.."Button"..button.."Name"]:SetJustifyH("CENTER")
end
 
-- fix borders
_G["RaidPullout"..pullout.."Button"..button.."HealthBar"]:GetStatusBarTexture():SetDrawLayer("BACKGROUND")
_G["RaidPullout"..pullout.."Button"..button.."ManaBar"]:GetStatusBarTexture():SetDrawLayer("BACKGROUND")
 
if _G["RaidPullout"..pullout.."Button"..button.."Target"] then
_G["RaidPullout"..pullout.."Button"..button.."Target"]:GetStatusBarTexture():SetDrawLayer("BACKGROUND")
end
 
if _G["RaidPullout"..pullout.."Button"..button.."Name"] then
_G["RaidPullout"..pullout.."Button"..button.."Name"]:SetParent(getglobal(btn:GetName().."HealthBar"))
end
 
end
end
end
--[[
-- RaidFramesPlus_GetHealthValue
-- TAKES
-- UnitId (uitype:UNIT)
-- RETURNS
-- value (type:string)
--
-- DESCRIPTION
-- according flag RaidFramesPlus_Health the function format the Healthstatus of UnitId and
-- return this formatted value
--]]
function RaidFramesPlus_GetHealthValue(UnitId)
local value = ""
if RaidFramesPlus_Health == 1 then
value = UnitHealth(UnitId)
elseif RaidFramesPlus_Health == 2 then
value = string.format("%.f%%", UnitHealth(UnitId) / UnitHealthMax(UnitId) * 100)
elseif RaidFramesPlus_Health == 3 then
value = UnitHealth(UnitId)
if value > 1000 then
value = math.ceil(value / 1000) .. "k"
end
elseif RaidFramesPlus_Health == 4 then
value = UnitHealth(UnitId) - UnitHealthMax(UnitId)
elseif RaidFramesPlus_Health == 5 and RaidFramesPlus_CustomFormat ~= nil then
value = RaidFramesPlus_CustomFormat
for key, func in pairs(RaidFramesPlus_ReplaceTable) do
 
value = value:gsub(key, func(UnitId))
 
end
elseif RaidFramesPlus_Health == 5 and RaidFramesPlus_CustomFormat == nil then
RaidFramesPlus_CustomFormat = "$abk($mak)"
value = RaidFramesPlus_CustomFormat
for key, func in pairs(replaceTable) do
 
value = value:gsub(key, func(UnitId))
 
end
elseif RaidFramesPlus_Health == 0 then
value = ""
end
return value
end
--[[
-- RaidFramesPlus_UnitHealth
-- TAKES
-- UnitId (uitype:UNIT)
-- RETURNS
-- nil
--
-- DESCRIPTION
-- this function scopes in RaidFramesPlus_FontStringArray with given UnitId parameter to
-- access fontStrings that are associated to the UnitButton in RaidPullouts to set thier text
-- to the formatted value given by RaidFramesPlus_GetHealthValue
--
-- SEE ALSO
-- RaidFramesPlus_GetHealthValue
-- RaidFramesPlus_UnitThreatSituationUpdate
--]]
function RaidFramesPlus_UnitHealth(UnitId)
-- check the probably populated Array for an associated fontString
local FontStringArray = RaidFramesPlus_FontStringArray[UnitId]
if FontStringArray == {} or FontStringArray == nil then
return
end
for i, fontString in pairs(FontStringArray) do
if fontString then
-- and change the Text to the current Health Amount
local value = RaidFramesPlus_GetHealthValue(UnitId)
 
--ChatFrame1:AddMessage(value)
_G[fontString]:SetText(value)
end
end
end
--[[
-- RaidFramesPlus_VariablesLoaded
-- TAKES
-- nil
-- RETURNS
-- nil
--
-- DESCRIPTION
-- this function acts as DefaultVariables-Loader / SavedVariables-Loader
--]]
local function RaidFramesPlus_VariablesLoaded()
if RaidFramesPlus_Health == nil then
RaidFramesPlus_Health = 1
end
if RaidFramesPlus_CompactPullouts == nil then
RaidFramesPlus_CompactPullouts = 1
end
if RaidFramesPlus_ColorizeNames == nil then
RaidFramesPlus_ColorizeNames = 1
end
if RaidFramesPlus_HideTargetFrameNameBackground == nil then
RaidFramesPlus_HideTargetFrameNameBackground = 1
end
end
--[[
-- RaidFramesPlus_ToggleBuffs
-- TAKES
-- nil
-- RETURNS
-- nil
--
-- DESCRIPTION
-- this function mass toggle the display of buffs/debuffs on all RaidPullouts
--]]
local function RaidFramesPlus_ToggleBuffs()
for index = 1, NUM_RAID_PULLOUT_FRAMES do
local pullout = _G["RaidPullout"..index]
if RaidFramesPlus_ShowBuffs then
pullout.showBuffs = nil
else
pullout.showBuffs = 1
end
RaidPullout_Update(pullout)
end
if RaidFramesPlus_ShowBuffs then
RaidFramesPlus_ShowBuffs = nil
else
RaidFramesPlus_ShowBuffs = 1
end
end
--[[
-- RaidFramesPlus_ParseSlashCommand
-- TAKES
-- argv(type:string)
-- RETURNS
-- nil
--
-- DESCRIPTION
-- this function parse the given arguments that passed to the /slashcommand and set
-- associcated flags
--]]
local function RaidFramesPlus_ParseSlashCommand(argv)
if argv ~= "" then
local arguments = GetOpt.getopt(RaidFramesPlus_ParseTable, argv)
 
if arguments ~= nil then
if arguments["h"] ~= nil then
RaidFramesPlus_Health = arguments["h"]
RaidFramesPlus_RaidRoasterUpdate()
end
 
if arguments["p"] ~= nil then
RaidFramesPlus_CompactPullouts = arguments["p"]
RaidFramesPlus_RaidRoasterUpdate()
end
 
if arguments["c"] ~= nil then
RaidFramesPlus_ColorizeNames = arguments["c"]
RaidFramesPlus_PartyMemberChanged()
end
 
if arguments["f"] ~= nil then
RaidFramesPlus_CustomFormat = arguments["f"]
RaidFramesPlus_RaidRoasterUpdate()
end
 
if arguments["t"] ~= nil then
RaidFramesPlus_HideTargetFrameNameBackground = arguments["t"]
RaidFramesPlus_PlayerTargetChanged()
end
if arguments["d"] ~= nil then
RaidFramesPlus_ToggleBuffs()
end
end
end
end
 
-- Registration of Events and SlashCommands
local function RaidFramesPlus_EventHandler(self, event, arg1)
if event == "UNIT_THREAT_SITUATION_UPDATE" then
RaidFramesPlus_UnitThreatSituationUpdate(arg1)
elseif event == "UNIT_HEALTH" then
RaidFramesPlus_UnitHealth(arg1)
elseif event == "PLAYER_TARGET_CHANGED" then
RaidFramesPlus_PlayerTargetChanged()
elseif event == "RAID_ROSTER_UPDATE" then
RaidFramesPlus_RaidRosterUpdate()
elseif event == "PARTY_MEMBER_CHANGED" then
RaidFramesPlus_PartyMemberChanged()
elseif event == "UNIT_AURA" then
RaidFramesPlus_UnitAura(UnitId)
elseif event == "VARIABLES_LOADED" then
RaidFramesPlus_VariablesLoaded()
end
end
local function RaidFramesPlus_RegisterEvents()
RaidFramesPlus_IsEnabled = true
RaidFramesPlus:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE")
RaidFramesPlus:RegisterEvent("UNIT_HEALTH")
RaidFramesPlus:RegisterEvent("RAID_ROSTER_UPDATE")
RaidFramesPlus:RegisterEvent("PLAYER_TARGET_CHANGED")
RaidFramesPlus:RegisterEvent("PARTY_MEMBER_CHANGED")
RaidFramesPlus:RegisterEvent("UNIT_AURA")
RaidFramesPlus:RegisterEvent("VARIABLES_LOADED")
-- run once
RaidFramesPlus_PlayerTargetChanged()
RaidFramesPlus_PartyMemberChanged()
-- eliminate this
RaidFramesPlus:SetScript("OnUpdate", nil)
end
 
RaidFramesPlus:SetScript("OnUpdate", RaidFramesPlus_RegisterEvents)
RaidFramesPlus:SetScript("OnEvent", RaidFramesPlus_EventHandler)
 
SlashCmdList["RAIDFRAMESPLUS"] = RaidFramesPlus_ParseSlashCommand
SLASH_RAIDFRAMESPLUS1 = "/rfp"
\ No newline at end of file
trunk/watching.tga Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream
trunk/DebuffBorder.tga Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream