Johnny C. Lam [03-28-13 - 04:34]
diff --git a/Ovale.lua b/Ovale.lua
index 7856a61..79318fb 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -12,20 +12,17 @@ local Ovale = LibStub("AceAddon-3.0"):NewAddon(addonNamespace, "Ovale", "AceCons
--<private-static-properties>
local L = LibStub("AceLocale-3.0"):GetLocale("Ovale")
+local OvaleGUID = nil
local OvaleOptions = nil
local pairs = pairs
-local strsplit = string.split
local wipe = table.wipe
local API_GetTime = GetTime
-local API_RegisterAddonMessagePrefix = RegisterAddonMessagePrefix
local API_SendAddonMessage = SendAddonMessage
local API_UnitCanAttack = UnitCanAttack
local API_UnitExists = UnitExists
local API_UnitHasVehicleUI = UnitHasVehicleUI
local API_UnitIsDead = UnitIsDead
-
-local self_damageMeterModules = {}
--</private-static-properties>
--<public-static-properties>
@@ -74,13 +71,12 @@ end
function Ovale:OnEnable()
-- Called when the addon is enabled
- API_RegisterAddonMessagePrefix("Ovale")
+ OvaleGUID = Ovale:GetModule("OvaleGUID")
+ OvaleOptions = Ovale:GetModule("OvaleOptions")
+
self:RegisterEvent("PLAYER_REGEN_ENABLED");
self:RegisterEvent("PLAYER_REGEN_DISABLED");
self:RegisterEvent("PLAYER_TARGET_CHANGED")
- self:RegisterEvent("CHAT_MSG_ADDON")
-
- OvaleOptions = Ovale:GetModule("OvaleOptions")
self.frame = LibStub("AceGUI-3.0"):Create("OvaleFrame")
self:UpdateFrame()
@@ -91,7 +87,6 @@ function Ovale:OnDisable()
self:UnregisterEvent("PLAYER_REGEN_ENABLED")
self:UnregisterEvent("PLAYER_REGEN_DISABLED")
self:UnregisterEvent("PLAYER_TARGET_CHANGED")
- self:UnregisterEvent("CHAT_MSG_ADDON")
self.frame:Hide()
end
@@ -103,14 +98,6 @@ function Ovale:PLAYER_TARGET_CHANGED()
self:UpdateVisibility()
end
-function Ovale:CHAT_MSG_ADDON(event, prefix, msg, type, author)
- if prefix ~= "Ovale" then return end
- if type ~= "RAID" and type~= "PARTY" then return end
-
- local value, maxValue, guid = strsplit(";", msg)
- self:SendScoreToDamageMeter(author, guid, value, maxValue)
-end
-
function Ovale:PLAYER_REGEN_ENABLED()
self.enCombat = false
self:UpdateVisibility()
@@ -120,8 +107,10 @@ function Ovale:PLAYER_REGEN_ENABLED()
end
function Ovale:PLAYER_REGEN_DISABLED()
- if self.maxScore>0 then
- API_SendAddonMessage("Ovale", self.score..";"..self.maxScore..";"..UnitGUID("player"), "RAID")
+ if self.maxScore > 0 then
+ -- Broadcast message is "score;maxScore;playerGUID"
+ local message = self.score .. ";" .. self.maxScore .. ";" .. OvaleGUID:GetGUID("player")
+ API_SendAddonMessage("Ovale", message, "RAID")
end
self.enCombat = true
self.score = 0
@@ -130,20 +119,6 @@ function Ovale:PLAYER_REGEN_DISABLED()
self:UpdateVisibility()
end
-function Ovale:AddDamageMeter(name, module)
- self_damageMeterModules[name] = module
-end
-
-function Ovale:RemoveDamageMeter(name)
- self_damageMeterModules[name] = nil
-end
-
-function Ovale:SendScoreToDamageMeter(name, guid, scored, scoreMax)
- for _, module in pairs(self_damageMeterModules) do
- module:SendScoreToDamageMeter(name, guid, scored, scoreMax)
- end
-end
-
function Ovale:Log(text)
if self.trace then
self:Print(text)
diff --git a/OvaleRecount.lua b/OvaleRecount.lua
index 384e959..61e37aa 100644
--- a/OvaleRecount.lua
+++ b/OvaleRecount.lua
@@ -8,7 +8,7 @@
----------------------------------------------------------------------]]
local _, Ovale = ...
-local OvaleRecount = Ovale:NewModule("OvaleRecount")
+local OvaleRecount = Ovale:NewModule("OvaleRecount", "AceEvent-3.0")
Ovale.OvaleRecount = OvaleRecount
--<private-static-properties>
@@ -17,6 +17,9 @@ local L = LibStub("AceLocale-3.0"):GetLocale("Recount", true)
if not L then
L = setmetatable({}, { __index = function(t, k) t[k] = k; return k; end })
end
+
+local strsplit = string.split
+local API_RegisterAddonMessagePrefix = RegisterAddonMessagePrefix
--</private-static-properties>
--<private-static-methods>
@@ -53,16 +56,23 @@ function OvaleRecount:OnInitialize()
end
function OvaleRecount:OnEnable()
- Ovale:AddDamageMeter("OvaleRecount", self)
+ if not Recount then return end
+ self:RegisterEvent("CHAT_MSG_ADDON")
+ API_RegisterAddonMessagePrefix("Ovale")
end
function OvaleRecount:OnDisable()
- Ovale:RemoveDamageMeter("OvaleRecount")
+ if not Recount then return end
+ self:UnregisterEvent("CHAT_MSG_ADDON")
end
-function OvaleRecount:SendScoreToDamageMeter(name, guid, scored, scoreMax)
- if not Recount then return end
- local source = Recount.db2.combatants[name]
+function OvaleRecount:CHAT_MSG_ADDON(event, ...)
+ local prefix, message, channel, sender = ...
+ if prefix ~= "Ovale" then return end
+ if channel ~= "RAID" and channel ~= "PARTY" then return end
+
+ local scored, scoreMax, guid = strsplit(";", message)
+ local source = Recount.db2.combatants[sender]
if source then
Recount:AddAmount(source, "Ovale", scored)
Recount:AddAmount(source, "OvaleMax", scoreMax)
diff --git a/OvaleSkada.lua b/OvaleSkada.lua
index 7495717..393d9f3 100644
--- a/OvaleSkada.lua
+++ b/OvaleSkada.lua
@@ -8,7 +8,7 @@
----------------------------------------------------------------------]]
local _, Ovale = ...
-local OvaleSkada = Ovale:NewModule("OvaleSkada")
+local OvaleSkada = Ovale:NewModule("OvaleSkada", "AceEvent-3.0")
Ovale.OvaleSkada = OvaleSkada
--<private-static-properties>
@@ -17,7 +17,9 @@ local SkadaModule = Skada and Skada:NewModule("Ovale Spell Priority") or { noSka
local ipairs = ipairs
local math = math
+local strsplit = string.split
local tostring = tostring
+local API_RegisterAddonMessagePrefix = RegisterAddonMessagePrefix
--</private-static-properties>
--<private-static-methods>
@@ -93,22 +95,27 @@ end
function OvaleSkada:OnEnable()
if SkadaModule.noSkada then return end
- Ovale:AddDamageMeter("OvaleSkada", self)
if not SkadaModule:IsEnabled() then
SkadaModule:Enable()
end
+ self:RegisterEvent("CHAT_MSG_ADDON")
+ API_RegisterAddonMessagePrefix("Ovale")
end
function OvaleSkada:OnDisable()
if SkadaModule.noSkada then return end
- Ovale:RemoveDamageMeter("OvaleSkada")
+ self:UnregisterEvent("CHAT_MSG_ADDON")
if SkadaModule:IsEnabled() then
SkadaModule:Disable()
end
end
-function OvaleSkada:SendScoreToDamageMeter(name, guid, scored, scoreMax)
- if SkadaModule.noSkada then return end
+function OvaleSkada:CHAT_MSG_ADDON(event, ...)
+ local prefix, message, channel, sender = ...
+ if prefix ~= "Ovale" then return end
+ if channel ~= "RAID" and channel ~= "PARTY" then return end
+
+ local scored, scoreMax, guid = strsplit(";", message)
if not guid or not Skada.current or not Skada.total then return end
local player = Skada:get_player(Skada.current, guid, nil)