Johnny C. Lam [03-02-13 - 17:58]
diff --git a/Ovale.lua b/Ovale.lua
index eac3bcf..daca869 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -11,13 +11,13 @@ local _, Ovale = ...
_G.Ovale = LibStub("AceAddon-3.0"):NewAddon(Ovale, "Ovale", "AceConsole-3.0", "AceEvent-3.0")
--<private-static-properties>
-local Recount = Recount
-local Skada = Skada
local L = LibStub("AceLocale-3.0"):GetLocale("Ovale")
local ipairs, pairs, strsplit, tinsert, tsort = ipairs, pairs, string.split, table.insert, table.sort
local SendAddonMessage, UnitAura, UnitCanAttack = SendAddonMessage, UnitAura, UnitCanAttack
local UnitExists, UnitHasVehicleUI, UnitIsDead = UnitExists, UnitHasVehicleUI, UnitIsDead
+
+local damageMeterModules = {}
--</private-static-properties>
--<public-static-properties>
@@ -184,25 +184,17 @@ function Ovale:PLAYER_REGEN_DISABLED()
self:UpdateVisibility()
end
+function Ovale:AddDamageMeter(name, module)
+ damageMeterModules[name] = module
+end
+
+function Ovale:RemoveDamageMeter(name)
+ damageMeterModules[name] = nil
+end
+
function Ovale:SendScoreToDamageMeter(name, guid, scored, scoreMax)
- if Recount then
- local source = Recount.db2.combatants[name]
- if source then
- Recount:AddAmount(source,"Ovale",scored)
- Recount:AddAmount(source,"OvaleMax",scoreMax)
- end
- end
- if Skada then
- if not guid or not Skada.current or not Skada.total then return end
- local player = Skada:get_player(Skada.current, guid, nil)
- if not player then return end
- if not player.ovale then player.ovale = 0 end
- if not player.ovaleMax then player.ovaleMax = 0 end
- player.ovale = player.ovale + scored
- player.ovaleMax = player.ovaleMax + scoreMax
- player = Skada:get_player(Skada.total, guid, nil)
- player.ovale = player.ovale + scored
- player.ovaleMax = player.ovaleMax + scoreMax
+ for _, module in pairs(damageMeterModules) do
+ module:SendScoreToDamageMeter(name, guid, scored, scoreMax)
end
end
diff --git a/OvaleRecount.lua b/OvaleRecount.lua
index eb3d68c..f26c133 100644
--- a/OvaleRecount.lua
+++ b/OvaleRecount.lua
@@ -7,18 +7,26 @@
file accompanying this program.
----------------------------------------------------------------------]]
-local Recount = Recount
-local RL
-if Recount then
- RL = LibStub("AceLocale-3.0"):GetLocale("Recount")
+local _, Ovale = ...
+OvaleRecount = Ovale:NewModule("OvaleRecount")
+
+--<private-static-properties>
+local Recount = LibStub("AceAddon-3.0"):GetAddon("Recount", true)
+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
+--</private-static-properties>
-local function DataModes(self,data, num)
- if not data then return 0, 0 end
+--<private-static-methods>
+local function DataModes(self, data, num)
+ if not data then
+ return 0, 0
+ end
local fight = data.Fights[Recount.db.profile.CurDataSet]
local score
if fight and fight.Ovale and fight.OvaleMax then
- score = fight.Ovale*1000/fight.OvaleMax
+ score = fight.Ovale * 1000 / fight.OvaleMax
else
score = 0
end
@@ -28,14 +36,35 @@ local function DataModes(self,data, num)
return score, nil
end
-local function TooltipFuncs(self,name,data)
- local SortedData,total
+local function TooltipFuncs(self, name, data)
+ local SortedData, total
GameTooltip:ClearLines()
GameTooltip:AddLine(name)
- -- Recount:AddSortedTooltipData(RL["Top 3"].." Ovale",data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].Ovale,3)
- -- GameTooltip:AddLine("<"..RL["Click for more Details"]..">",0,0.9,0)
+ -- Recount:AddSortedTooltipData(L["Top 3"].." Ovale",data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].Ovale,3)
+ -- GameTooltip:AddLine("<"..L["Click for more Details"]..">",0,0.9,0)
+end
+--</private-static-methods>
+
+--<public-static-methods>
+function OvaleRecount:OnInitialize()
+ if not Recount then return end
+ Recount:AddModeTooltip("Ovale", DataModes, TooltipFuncs, nil, nil, nil, nil)
+end
+
+function OvaleRecount:OnEnable()
+ Ovale:AddDamageMeter("OvaleRecount", self)
+end
+
+function OvaleRecount:OnDisable()
+ Ovale:RemoveDamageMeter("OvaleRecount")
end
-if Recount then
- Recount:AddModeTooltip("Ovale",DataModes,TooltipFuncs,nil,nil,nil,nil)
-end
\ No newline at end of file
+function OvaleRecount:SendScoreToDamageMeter(name, guid, scored, scoreMax)
+ if not Recount then return end
+ local source = Recount.db2.combatants[name]
+ if source then
+ Recount:AddAmount(source, "Ovale", scored)
+ Recount:AddAmount(source, "OvaleMax", scoreMax)
+ end
+end
+--</public-static-methods>
diff --git a/OvaleSkada.lua b/OvaleSkada.lua
index 4bae9a0..5d480a5 100644
--- a/OvaleSkada.lua
+++ b/OvaleSkada.lua
@@ -7,78 +7,119 @@
file accompanying this program.
----------------------------------------------------------------------]]
-local Skada = Skada
+local _, Ovale = ...
+OvaleSkada = Ovale:NewModule("OvaleSkada")
-if Skada then
- local module = Skada:NewModule("Ovale Spell Priority")
+--<private-static-properties>
+local Skada = LibStub("AceAddon-3.0"):GetAddon("Skada", true)
+local SkadaModule = {}
- local function getValue(set)
- if set.ovaleMax and set.ovaleMax>0 then
- return math.floor(1000*set.ovale/set.ovaleMax)
- else
- return nil
- end
+local ipairs = ipairs
+local math = math
+local tostring = tostring
+--</private-static-properties>
+
+--<public-static-properties>
+OvaleSkada.module = Skada and Skada:NewModule("Ovale Spell Priority", SkadaModule) or nil
+--</public-static-properties>
+
+--<private-static-methods>
+local function getValue(set)
+ if set.ovaleMax and set.ovaleMax > 0 then
+ return math.floor(1000 * set.ovale / set.ovaleMax)
+ else
+ return nil
end
+end
+
+function SkadaModule:OnEnable()
+ self.metadata = { showspots = true }
+ Skada:AddMode(self)
+end
+
+function SkadaModule:OnDisable()
+ Skada:RemoveMode(self)
+end
- function module:Update(win, set)
- local max = 0
- local nr = 1
-
- for i, player in ipairs(set.players) do
- if player.ovaleMax > 0 then
-
- local d = win.dataset[nr] or {}
- win.dataset[nr] = d
- d.value = getValue(player)
- d.label = player.name
- d.class = player.class
- d.id = player.id
- d.valuetext = tostring(getValue(player))
- if d.value > max then
- max = d.value
- end
- nr = nr + 1
+function SkadaModule:Update(win, set)
+ local max = 0
+ local nr = 1
+
+ for i, player in ipairs(set.players) do
+ if player.ovaleMax and player.ovaleMax > 0 then
+ local d = win.dataset[nr] or {}
+ win.dataset[nr] = d
+ d.value = getValue(player)
+ d.label = player.name
+ d.class = player.class
+ d.id = player.id
+ d.valuetext = tostring(getValue(player))
+ if d.value > max then
+ max = d.value
end
+ nr = nr + 1
end
-
- win.metadata.maxvalue = max
end
- function module:OnEnable()
- module.metadata = {showspots = true}
-
- Skada:AddMode(self)
- end
+ win.metadata.maxvalue = max
+end
- function module:OnDisable()
- Skada:RemoveMode(self)
- end
+function SkadaModule:AddToTooltip(set, tooltip)
+ GameTooltip:AddDoubleLine("Ovale", getValue(set), 1, 1, 1)
+end
- function module:AddToTooltip(set, tooltip)
- GameTooltip:AddDoubleLine("Ovale", getValue(set), 1,1,1)
+-- Called by Skada when a new player is added to a set.
+function SkadaModule:AddPlayerAttributes(player)
+ if not player.ovale then
+ player.ovale = 0
+ end
+ if not player.ovaleMax then
+ player.ovaleMax = 0
end
+end
- -- Called by Skada when a new player is added to a set.
- function module:AddPlayerAttributes(player)
- if not player.ovale then
- player.ovale = 0
- end
- if not player.ovaleMax then
- player.ovaleMax = 0
- end
+-- Called by Skada when a new set is created.
+function SkadaModule:AddSetAttributes(set)
+ if not set.ovale then
+ set.ovale = 0
+ end
+ if not set.ovaleMax then
+ set.ovaleMax = 0
end
+end
- -- Called by Skada when a new set is created.
- function module:AddSetAttributes(set)
- if not set.ovale then
- set.ovale = 0
- end
- if not set.ovaleMax then
- set.ovaleMax = 0
- end
+function SkadaModule:GetSetSummary(set)
+ return getValue(set)
+end
+--</private-static-methods>
+
+--<public-static-methods>
+function OvaleSkada:OnEnable()
+ Ovale:AddDamageMeter("OvaleSkada", self)
+ if not self.module:IsEnabled() then
+ self.module:Enable()
end
+end
- function module:GetSetSummary(set)
- return getValue(set)
+function OvaleSkada:OnDisable()
+ Ovale:RemoveDamageMeter("OvaleSkada")
+ if self.module:IsEnabled() then
+ self.module:Disable()
end
-end
\ No newline at end of file
+end
+
+function OvaleSkada:SendScoreToDamageMeter(name, guid, scored, scoreMax)
+ if not Skada then return end
+ if not guid or not Skada.current or not Skada.total then return end
+
+ local player = Skada:get_player(Skada.current, guid, nil)
+ if not player then return end
+
+ self.module:AddPlayerAttributes(player)
+ player.ovale = player.ovale + scored
+ player.ovaleMax = player.ovaleMax + scoreMax
+ player = Skada:get_player(Skada.total, guid, nil)
+ player.ovale = player.ovale + scored
+ player.ovaleMax = player.ovaleMax + scoreMax
+end
+--</public-static-methods>