/trunk
LynStats.plugins = {} |
end |
local addon = CreateFrame("Button", "gPeen", LynStats) |
addon.text = gPeen:CreateFontString(nil, "OVERLAY") |
local gPeen = CreateFrame("Button", "gPeen", LynStats) |
gPeen.text = gPeen:CreateFontString(nil, "OVERLAY") |
gPeen.channel = "GUILD" |
local bit_bor = bit.bor |
local COMBATLOG_FILTER_ME = COMBATLOG_FILTER_ME |
local font = "Fonts\\skurri.ttf" |
local size = 16 |
local channel = "GUILD" |
local color = { r = 0, g = 0.8, b = 1 } |
local default = { |
normal = 0, |
critical = 0, |
} |
function addon:getHighest() |
local db = gPeenDB |
function gPeen:getHighest() |
local hit, crit = 0, 0 |
local lastHit, lastCrit = 0, 0 |
local spellHit, spellCrit |
for spell in pairs(db) do |
if db[spell].normal > lastHit then |
hit = db[spell].normal |
for spell in pairs(gPeenDB) do |
if ( gPeenDB[spell].normal > lastHit ) then |
hit = gPeenDB[spell].normal |
lastHit = hit |
spellHit = spell |
end |
if db[spell].critical > lastCrit then |
crit = db[spell].critical |
if ( gPeenDB[spell].critical > lastCrit ) then |
crit = gPeenDB[spell].critical |
lastCrit = crit |
spellCrit = spell |
end |
return hit, crit, spellHit, spellCrit |
end |
function addon:BuffPeen(spellName, amount, critical) |
function gPeen:BuffPeen(spellName, amount, critical) |
assert(type(spellName) == "string", format("bad argument #1 to 'BuffPeen' (string expected, got %s)", type(spellName))) |
assert(type(amount) == "number", format("bad argument #2 to 'BuffPeen' (number expected, got %s)", type(amount))) |
local db = gPeenDB |
if not db[spellName] then |
db[spellName] = default |
if ( not gPeenDB[spellName] ) then |
gPeenDB[spellName] = { normal = 0, critical = 0 } |
end |
if critical then |
if amount > db[spellName].critical then |
db[spellName].critical = amount |
if ( critical ) then |
if ( amount > gPeenDB[spellName].critical ) then |
gPeenDB[spellName].critical = amount |
--gPeen:AddMessage(spellName.." : "..amount.." (CRIT)", 1, 1, 1, 1, 2) |
if MikSBT and not MikSBT.IsModDisabled() then |
MikSBT.DisplayMessage(spellName.." : "..amount.." (CRIT)", MikSBT.DISPLAYTYPE_NOTIFICATION, true, 255, 255, 255, 38, nil, nil, nil) |
if ( MikSBT and not MikSBT.IsModDisabled() ) then |
MikSBT.DisplayMessage(spellName.." : "..amount.." (CRIT)", MikSBT.DISPLAYTYPE_NOTIFICATION, true, 255, 255, 255, 30, nil, nil, nil) |
elseif ( SCT ) then |
SCT:DisplayMessage(spellName.." : "..amount.." (CRIT)", addon.color) |
SCT:DisplayMessage(spellName.." : "..amount.." (CRIT)", {1, 1, 1}) |
elseif ( COMBAT_TEXT_SCROLL_FUNCTION ) then |
CombatText_AddMessage(spellName.." : "..amount.." (CRIT)", COMBAT_TEXT_SCROLL_FUNCTION, 1, 1, 1, "crit", nil) |
end |
end |
else |
if amount > db[spellName].normal then |
db[spellName].normal = amount |
if ( amount > gPeenDB[spellName].normal ) then |
gPeenDB[spellName].normal = amount |
--gPeen:AddMessage(spellName.." : "..amount, 1, 1, 1, 1, 2) |
if MikSBT and not MikSBT.IsModDisabled() then |
MikSBT.DisplayMessage(spellName.." : "..amount, MikSBT.DISPLAYTYPE_NOTIFICATION, true, 255, 255, 255, 38, nil, nil, nil) |
if ( MikSBT and not MikSBT.IsModDisabled() ) then |
MikSBT.DisplayMessage(spellName.." : "..amount, MikSBT.DISPLAYTYPE_NOTIFICATION, true, 255, 255, 255, 32, nil, nil, nil) |
elseif ( SCT ) then |
SCT:DisplayMessage(spellName.." : "..amount, addon.color) |
SCT:DisplayMessage(spellName.." : "..amount, {1, 1, 1}) |
elseif ( COMBAT_TEXT_SCROLL_FUNCTION ) then |
CombatText_AddMessage(spellName.." : "..amount, COMBAT_TEXT_SCROLL_FUNCTION, 1, 1, 1, nil, nil) |
end |
end |
end |
gPeenDB = db |
hit, crit = self:getHighest() |
addon.text:SetText("|cffffffff"..hit.."|r/|cffffffff"..crit.."|r") |
addon:SetWidth(addon.text:GetStringWidth()) |
self.text:SetText("|cffffffff"..hit.."|r/|cffffffff"..crit.."|r") |
self:SetWidth(self.text:GetStringWidth()) |
end |
local function onEnter(self) |
GameTooltip:SetPoint("BOTTOM", self, "TOP", 0, 20) |
GameTooltip:AddDoubleLine("Spell Name", "Normal / Critical", 0, .8, 1, 0, .8, 1) |
GameTooltip:AddLine(" ") |
local db = gPeenDB |
for spell in pairs(db) do |
GameTooltip:AddDoubleLine(spell, db[spell].normal.." / "..db[spell].critical, 1, 1, 1, 1, 1, 1) |
for spell in pairs(gPeenDB) do |
GameTooltip:AddDoubleLine(spell, gPeenDB[spell].normal.." / "..gPeenDB[spell].critical, 1, 1, 1, 1, 1, 1) |
end |
GameTooltip:AddLine("----------------------------------------------------------------------------------", 1, 1, 1) |
GameTooltip:AddLine("ALT + Right-click to reset database", 0, .8, 1) |
GameTooltip:AddLine("SHIFT + Left-click to announce highest records to "..string.lower(channel), 0, .8, 1) |
GameTooltip:AddLine("SHIFT + Left-click to announce highest records to "..string.lower(self.channel), 0, .8, 1) |
GameTooltip:Show() |
end |
local function onClick(self, button) |
if ( IsAltKeyDown() and button == "RightButton" ) then |
gPeenDB = {} |
addon.text:SetText("|cffffffff0|r/|cffffffff0|r") |
addon:SetWidth(addon.text:GetStringWidth()) |
self.text:SetText("|cffffffff0|r/|cffffffff0|r") |
self:SetWidth(self.text:GetStringWidth()) |
elseif ( IsShiftKeyDown() and button == "LeftButton" ) then |
hit, crit, spellHit, spellCrit = self:getHighest() |
SendChatMessage("gPeen: Highest Damage/Healing Records", channel) |
SendChatMessage("-----------------------------------------------", channel) |
SendChatMessage("(Normal) "..spellHit..": "..hit, channel) |
SendChatMessage("(Critical) "..spellCrit..": "..crit, channel) |
SendChatMessage("gPeen: Highest Damage/Healing Records", self.channel) |
SendChatMessage("-----------------------------------------------", self.channel) |
SendChatMessage("(Normal) "..spellHit..": "..hit, self.channel) |
SendChatMessage("(Critical) "..spellCrit..": "..crit, self.channel) |
end |
end |
local function onEvent(self, event, time, eventType, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellID, spellName, spellSchool, amount, school, resisted, blocked, absorbed, critical) |
if ( not addon.text:GetText() ) then |
if ( not self.text:GetText() ) then |
hit, crit = self:getHighest() |
addon.text:SetText("|cffffffff"..hit.."|r/|cffffffff"..crit.."|r") |
addon:SetWidth(addon.text:GetStringWidth()) |
self.text:SetText("|cffffffff"..hit.."|r/|cffffffff"..crit.."|r") |
self:SetWidth(self.text:GetStringWidth()) |
return |
end |
gPeenDB = {} |
addon.text:SetFont(font, size, "OUTLINE") |
addon.text:ClearAllPoints() |
addon.text:SetPoint"CENTER" |
addon.text:SetTextColor(color.r, color.g, color.b) |
addon.text:Show() |
gPeen.text:SetFont(font, size, "OUTLINE") |
gPeen.text:ClearAllPoints() |
gPeen.text:SetPoint"CENTER" |
gPeen.text:SetTextColor(color.r, color.g, color.b) |
gPeen.text:Show() |
addon:SetWidth(addon.text:GetStringWidth()) |
addon:SetHeight(15) |
addon:SetScript("OnEnter", onEnter) |
addon:SetScript("OnLeave", function() GameTooltip:Hide() end) |
addon:SetScript("OnClick", onClick) |
addon:SetScript("OnEvent", onEvent) |
addon:RegisterForClicks("AnyUp") |
addon:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") |
addon:RegisterEvent("PLAYER_LOGIN") |
gPeen:SetWidth(gPeen.text:GetStringWidth()) |
gPeen:SetHeight(15) |
gPeen:SetScript("OnEnter", onEnter) |
gPeen:SetScript("OnLeave", function() GameTooltip:Hide() end) |
gPeen:SetScript("OnClick", onClick) |
gPeen:SetScript("OnEvent", onEvent) |
gPeen:SetPoint("RIGHT", LynStats, "LEFT", -((#LynStats.plugins + 1) * 20), 0) |
gPeen:RegisterForClicks("AnyUp") |
gPeen:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") |
gPeen:RegisterEvent("PLAYER_LOGIN") |
tinsert(LynStats.plugins, addon) |
addon:SetPoint("RIGHT", LynStats, "LEFT", -(#LynStats.plugins * 20), 0) |
tinsert(LynStats.plugins, gPeen) |