Skip to content
This repository has been archived by the owner on Jan 22, 2020. It is now read-only.

Commit

Permalink
another library update
Browse files Browse the repository at this point in the history
fix errors with non-unit frame oUF implementations
  • Loading branch information
Evilpaul committed Sep 27, 2009
1 parent 4f73074 commit d445588
Show file tree
Hide file tree
Showing 7 changed files with 324 additions and 185 deletions.
370 changes: 236 additions & 134 deletions libs/LibHealComm-4.0/LibHealComm-4.0.lua

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion libs/LibHealComm-4.0/LibHealComm-4.0.toc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
## Notes: Library for showing incoming heals and hots
## Author: Shadowed
## X-Category: Library
## X-Curse-Packaged-Version: b2.6-1-ge8ad1e2
## X-Curse-Packaged-Version: b3.3
## X-Curse-Project-Name: LibHealComm-4.0
## X-Curse-Project-ID: libhealcomm-4-0
## X-Curse-Repository-ID: wow/libhealcomm-4-0/mainline

libs\LibStub\LibStub.lua
libs\CallbackHandler-1.0\Callbackhandler-1.0.xml

LibHealComm-4.0.xml
80 changes: 50 additions & 30 deletions libs/LibWrapperHealComm-1.0/LibWrapperHealComm-1.0.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
local major = "LibWrapperHealComm-1.0"
local minor = 3
local minor = 6
assert(LibStub, string.format("%s requires LibStub.", major))

local CommWrapper = LibStub:NewLibrary(major, minor)
if( not CommWrapper ) then return end

local HealComm40 = LibStub:GetLibrary("LibHealComm-4.0")
local HealComm40 = LibStub:GetLibrary("LibHealComm-4.0", true)
assert(HealComm40, string.format("%s-%d requires LibHealComm-4.0 to run.", major, minor))

local playerName = UnitName("player")
local playerGUID, distribution

Expand Down Expand Up @@ -69,11 +71,10 @@ local function getName(unit)
if( not unit ) then return nil end

local name, server = UnitName(unit)
if( distribution ~= "BATTLEGROUND" ) then return name end

server = server and server ~= "" and server or GetRealmName()
name = name and string.format("%s-%s", name, server)

if( distribution == "BATTLEGROUND" and server and server ~= "" ) then
return string.format("%s-%s", name, server)
end

return name
end

Expand All @@ -86,16 +87,16 @@ function CommWrapper:HealComm_HealStarted(event, casterGUID, spellID, healType,
if( spellName == PrayerofHealing ) then
local targetList
for i=1, select("#", ...) do
local name = HealComm40.guidToUnit[select(i, ...)]
if( name ) then
local unit = HealComm40.guidToUnit[select(i, ...)]
if( unit ) then
if( targetList ) then
targetList = targetList .. ":" .. name
targetList = targetList .. ":" .. getName(unit)
else
targetList = name
targetList = getName(unit)
end
end
end

-- Grab the first heal amount it finds
local healAmount = HealComm40.pendingHeals[casterGUID][spellName][2]
if( targetList and healAmount ) then
Expand Down Expand Up @@ -177,15 +178,10 @@ local function parseDirectHeal(casterGUID, spellName, amount, endTime, ...)
pending.spellID = CommWrapper.spellNameToID[spellName] or 0
pending.bitType = HealComm40.DIRECT_HEALS

amount = math.floor(amount)

for i=1, select("#", ...) do
table.insert(pending, (select(i, ...)))
table.insert(pending, amount)
table.insert(pending, 1)
table.insert(pending, 0)
HealComm40.updateRecord(pending, select(i, ...), math.floor(amount), 1)
end

HealComm40.callbacks:Fire("HealComm_HealStarted", casterGUID, pending.spellID, pending.bitType, pending.endTime, ...)
end

Expand All @@ -196,24 +192,48 @@ local function parseHealEnd(casterGUID, spellName)
table.wipe(tempPlayerList)

local pending = pendingHeals[casterGUID][spellName]
for i=#(pending), 1, -4 do
table.remove(pending, i)
table.remove(pending, i - 1)
table.remove(pending, i - 2)
table.insert(tempPlayerList, table.remove(pending, i - 3))
for i=#(pending), 1, -5 do
table.insert(tempPlayerList, pending[i - 4])
HealComm40.removeRecord(pending, pending[i - 4])
end

if( #(tempPlayerList) > 0 ) then
HealComm40.callbacks:Fire("HealComm_HealStopped", casterGUID, pending.spellID, pending.bitType, false, unpack(tempPlayerList))
table.wipe(pendingHeals)
end
end

local function loadPlayers(...)
-- Yoinked from LHC-3
local function extractRealm(fullName)
return select(2, string.split('-', fullName, 2))
end

-- Convert a remotely generated fully qualified name to
-- a local fully qualified name.
local playerRealm = GetRealmName()

local function convertRealm(fullName, remoteRealm)
if( not remoteRealm ) then return fullName end

local name, realm = string.split('-', fullName, 2)
if( not realm ) then
-- Apply remote realm if there is no realm on the target
return fullName.."-"..remoteRealm
elseif(realm == playerRealm) then
-- Strip realm if it is equal to the local realm
return name
end

-- Sender and target realms are both different from local realm
return fullName
end

local function loadPlayers(sender, ...)
table.wipe(tempPlayerList)

local senderRealm = extractRealm(sender)
for i=1, select("#", ...) do
local guid = UnitGUID((select(i, ...)))
local guid = UnitGUID(convertRealm(select(i, ...), senderRealm))
if( guid ) then
table.insert(tempPlayerList, guid)
end
Expand Down Expand Up @@ -251,7 +271,7 @@ function CommWrapper:CHAT_MSG_ADDON(prefix, message, channel, sender)
local heal = tonumber(string.sub(message, 4, 8))
local target = string.sub(message, 9, -1)
local spellName, _, _, _, _, endTime = UnitCastingInfo(sender)
local guid = UnitGUID(target)
local guid = UnitGUID(convertRealm(target, extractRealm(sender)))

if( heal and target and endTime and guid and spellName ) then
endTime = endTime / 1000
Expand All @@ -267,7 +287,7 @@ function CommWrapper:CHAT_MSG_ADDON(prefix, message, channel, sender)
local spellName, _, _, _, _, endTime = UnitCastingInfo(sender)

if( heal and targets and endTime and spellName ) then
loadPlayers(string.split(":", targets))
loadPlayers(sender, string.split(":", targets))
if( #(tempPlayerList) == 0 ) then return end

endTime = endTime / 1000
Expand Down Expand Up @@ -297,4 +317,4 @@ frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("CHAT_MSG_ADDON")
frame:SetScript("OnEvent", OnEvent)

CommWrapper.frame = frame
CommWrapper.frame = frame
6 changes: 1 addition & 5 deletions libs/LibWrapperHealComm-1.0/LibWrapperHealComm-1.0.toc
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
## Notes: Wrapper to convert HealComm data from 3.0 to 4.0
## Author: xbeeps (3.0), Shadowed (4.0)
## X-Category: Library
## X-Curse-Packaged-Version: r3
## X-Curse-Packaged-Version: r4
## X-Curse-Project-Name: LibWrapperHealComm-1.0
## X-Curse-Project-ID: libwrapperhealcomm-1-0
## X-Curse-Repository-ID: wow/libwrapperhealcomm-1-0/mainline

#@no-lib-strip@
libs\LibStub\LibStub.lua
#@end-no-lib-strip@

LibWrapperHealComm-1.0.xml
40 changes: 28 additions & 12 deletions oUF_HealComm4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ local healcomm = LibStub("LibHealComm-4.0")

-- update a specific bar
local updateHealCommBar = function(frame, unitName, playerGUID)
if not unitName then return end

-- hide bars for any units with an unknown name
if not unitName then
frame.HealCommBar:Hide()
return
end

local maxHP = UnitHealthMax(unitName) or 0

Expand All @@ -57,6 +62,11 @@ local updateHealCommBar = function(frame, unitName, playerGUID)
local curHP = UnitHealth(unitName)
local percHP = curHP / maxHP

-- slightly inefficient to set height here for the moment but it should
-- fix different heights for units with/without a power bar
-- Changing to be able to have vertical/horizontal bars will mean we
-- have to do this here anyway...
frame.HealCommBar:SetHeight(frame.Health:GetHeight())
frame.HealCommBar:SetWidth(percInc * frame.Health:GetWidth())
frame.HealCommBar:SetPoint("LEFT", frame.Health, "LEFT", frame.Health:GetWidth() * percHP, 0)
end
Expand All @@ -72,13 +82,11 @@ local updateHealCommBars = function(...)
playerGUID = select(i, ...)
unit = unitMap[playerGUID]

if unit then
-- search current oUF frames for this unit
for frame in pairs(oUF.units) do
frameGUID = UnitGUID(frame)
if frameGUID == playerGUID and not oUF.units[frame].ignoreHealComm then
updateHealCommBar(oUF.units[frame], unit, frameGUID)
end
-- search current oUF frames for this unit
for frame in pairs(oUF.units) do
frameGUID = UnitGUID(frame)
if frameGUID == playerGUID and not oUF.units[frame].ignoreHealComm then
updateHealCommBar(oUF.units[frame], unit, playerGUID)
end
end
end
Expand All @@ -87,9 +95,16 @@ end
local function hook(frame)
if frame.ignoreHealComm then return end

-- make sure some crap implementation using oUF
-- for non-unit frames doesn't cause errors
if not frame.Health then
frame.ignoreHealComm = true
return
end

-- create heal bar here and set initial values
local hcb = CreateFrame("StatusBar")
hcb:SetHeight(frame.Health:GetHeight()) -- same height as health bar
hcb:SetHeight(0) -- no initial height
hcb:SetWidth(0) -- no initial width
hcb:SetStatusBarTexture(frame.Health:GetStatusBarTexture():GetTexture())
hcb:SetStatusBarColor(color.r, color.g, color.b, color.a)
Expand All @@ -114,16 +129,17 @@ for i, frame in ipairs(oUF.objects) do hook(frame) end
oUF:RegisterInitCallback(hook)

-- set up LibHealComm callbacks
function oUF_HealComm:HealComm_Heal_Update(_, _, _, _, ...)
function oUF_HealComm:HealComm_Heal_Update(event, casterGUID, spellID, healType, _, ...)
updateHealCommBars(...)
end

function oUF_HealComm:HealComm_Modifier_Changed(guid, _)
function oUF_HealComm:HealComm_Modified(event, guid)
updateHealCommBars(guid)
end

healcomm.RegisterCallback(oUF_HealComm, "HealComm_HealStarted", "HealComm_Heal_Update")
healcomm.RegisterCallback(oUF_HealComm, "HealComm_HealUpdated", "HealComm_Heal_Update")
healcomm.RegisterCallback(oUF_HealComm, "HealComm_HealDelayed", "HealComm_Heal_Update")
healcomm.RegisterCallback(oUF_HealComm, "HealComm_HealStopped", "HealComm_Heal_Update")
healcomm.RegisterCallback(oUF_HealComm, "HealComm_ModifierChanged", "HealComm_Modifier_Changed")
healcomm.RegisterCallback(oUF_HealComm, "HealComm_ModifierChanged", "HealComm_Modified")
healcomm.RegisterCallback(oUF_HealComm, "HealComm_GUIDDisappeared", "HealComm_Modified")
4 changes: 1 addition & 3 deletions oUF_HealComm4.toc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
## OptionalDeps: LibHealComm-4.0, LibWrapperHealComm-1.0
## X-Embeds: LibHealComm-4.0, LibWrapperHealComm-1.0

libs\LibHealComm-4.0\CallbackHandler-1.0\CallbackHandler-1.0.xml
libs\LibHealComm-4.0\LibHealComm-4.0.xml
libs\LibWrapperHealComm-1.0\LibWrapperHealComm-1.0.xml
oUF_HealComm4.xml

oUF_HealComm4.lua
6 changes: 6 additions & 0 deletions oUF_HealComm4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd">
<Script file="libs\LibHealComm-4.0\libs\CallbackHandler-1.0\Libstub\LibStub.lua"/>
<Include file="libs\LibHealComm-4.0\libs\CallbackHandler-1.0\CallbackHandler-1.0\CallbackHandler-1.0.xml"/>
<Include file="libs\LibHealComm-4.0\LibHealComm-4.0.xml"/>
<Include file="libs\LibWrapperHealComm-1.0\LibWrapperHealComm-1.0.xml"/>
</Ui>

0 comments on commit d445588

Please sign in to comment.