Skip to content

Commit

Permalink
Merge pull request #11 from Cortes-Jeremy/develop
Browse files Browse the repository at this point in the history
Fixed issue and some cooldown missing in the aura list
  • Loading branch information
Cortes-Jeremy authored Jan 3, 2022
2 parents 4aa4d8f + fce16a7 commit ccb3a20
Show file tree
Hide file tree
Showing 33 changed files with 8,642 additions and 443 deletions.
170 changes: 152 additions & 18 deletions Gladius/Gladius.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
Gladius = LibStub("AceAddon-3.0"):NewAddon("Gladius", "AceEvent-3.0", "AceConsole-3.0")
Gladius = LibStub("AceAddon-3.0"):NewAddon("Gladius", "AceEvent-3.0", "AceConsole-3.0", "AceComm-3.0", "AceTimer-3.0", "AceSerializer-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Gladius", true)
local LSM = LibStub("LibSharedMedia-3.0")
local LCG = LibStub("LibCustomGlow-1.0")
--[[ local LHC = LibStub("LibHealCommArena-4.0") ]]
local LAM = LibStub:GetLibrary("AbsorbsMonitor-1.0", true)
local LDB = LibStub ("LibDataBroker-1.1")
local LDBIcon = LibStub("LibDBIcon-1.0")

local arenaUnits = {}
local arenaGUID = {}
Expand All @@ -24,6 +27,14 @@ function Gladius:OnInitialize()
self.buttons = {}
self.currentBracket = nil

--[[ LHC.UnregisterAllCallbacks(Gladius);
LHC.RegisterCallback(Gladius, "HealCommArena_HealStarted", "HealCommArena_Heal_Update")
LHC.RegisterCallback(Gladius, "HealCommArena_HealUpdated", "HealCommArena_Heal_Update")
LHC.RegisterCallback(Gladius, "HealCommArena_HealDelayed", "HealCommArena_Heal_Update")
LHC.RegisterCallback(Gladius, "HealCommArena_HealStopped", "HealCommArena_Heal_Update")
LHC.RegisterCallback(Gladius, "HealCommArena_ModifierChanged", "HealCommArena_Modified")
LHC.RegisterCallback(Gladius, "HealCommArena_GUIDDisappeared", "HealCommArena_Modified") ]]

-- Populate the arenaUnits table
for i=1, 5 do
arenaUnits["arena" .. i] = "playerUnit"
Expand Down Expand Up @@ -87,6 +98,9 @@ function Gladius:OnInitialize()
self.drTime = { "50%", "25%", L["immune"] }

self:SetupOptions()

-- Create Minimap Icon
self:CreateMinimapButton()
end

function Gladius:OnEnable()
Expand Down Expand Up @@ -120,6 +134,30 @@ function Gladius:OnProfileChanged(event, database, newProfileKey)
self:ToggleFrame(5)
end

function Gladius:CreateMinimapButton()
local GladiusLDB = LDB:NewDataObject("GladiusMinimapIcon", {
type = "data source",
icon = [[Interface\AddOns\Gladius\media\Icons\Gladius]],
text = "0",
OnClick = function(self, button)

if button == "LeftButton" then
Gladius:ShowOptions()
end
if button == "RightButton" then
Gladius:ToggleFrame(5)
end

end,
OnTooltipShow = function (tooltip)
tooltip:AddLine ("|cffe5e3e3Gladius|r |cff1784d1Enhanced|r")
tooltip:AddLine ("|cff1784d1Left Click|r: show/hide Gladius UI")
tooltip:AddLine ("|cff1784d1Right Click|r: show/hide Test Frames")
end,
})
LDBIcon:Register("GladiusMinimapIcon", GladiusLDB, Gladius.db.profile.minimapIcon)
end

function Gladius:ZONE_CHANGED_NEW_AREA()
local type = select(2, IsInInstance())

Expand Down Expand Up @@ -222,6 +260,22 @@ function Gladius:JoinedArena()
-- Special arena event
self:RegisterEvent("ARENA_OPPONENT_UPDATE")

-- HealComm Events
--[[ LHC.UnregisterAllCallbacks(Gladius);
LHC.UnregisterAllCallbacks(Gladius);
LHC.RegisterCallback(Gladius, "HealCommArena_HealStarted", "HealCommArena_Heal_Update")
LHC.RegisterCallback(Gladius, "HealCommArena_HealUpdated", "HealCommArena_Heal_Update")
LHC.RegisterCallback(Gladius, "HealCommArena_HealDelayed", "HealCommArena_Heal_Update")
LHC.RegisterCallback(Gladius, "HealCommArena_HealStopped", "HealCommArena_Heal_Update")
LHC.RegisterCallback(Gladius, "HealCommArena_ModifierChanged", "HealCommArena_Modified")
LHC.RegisterCallback(Gladius, "HealCommArena_GUIDDisappeared", "HealCommArena_Modified")]]

-- Absorb Events
LAM.UnregisterAllCallbacks(Gladius);
LAM.RegisterCallback(Gladius, "EffectApplied");
LAM.RegisterCallback(Gladius, "EffectUpdated");
LAM.RegisterCallback(Gladius, "EffectRemoved");

-- Find out the current bracket size
for i=1, MAX_BATTLEFIELD_QUEUES do
local status, _, _, _, _, teamSize = GetBattlefieldStatus(i)
Expand All @@ -242,6 +296,7 @@ function Gladius:JoinedArena()
button = self:CreateButton(i)
self.buttons[unit] = button
self.buttons[pet] = button.pet
self.buttons[unit].unit = unit
end

button:Show()
Expand Down Expand Up @@ -324,7 +379,7 @@ function Gladius:UNIT_HEALTH(event, unit)

-- update absorb bar
if( db.absorbBar and (arenaUnits[unit] == "playerUnit" or (arenaUnits[unit] ~= "playerUnit" and db.showPets)) ) then
Gladius:UpdateAbsorb(event, unit, button)
Gladius:UpdateAbsorbBar(event, unit, button)
end

-- update cutaway
Expand Down Expand Up @@ -457,7 +512,7 @@ function Gladius:UNIT_AURA(event, unit)

-- update absorb bar
if( db.absorbBar and (arenaUnits[unit] == "playerUnit" or (arenaUnits[unit] ~= "playerUnit" and db.showPets)) ) then
Gladius:UpdateAbsorb(event, unit, button)
Gladius:UpdateAbsorbBar(event, unit, button)
end

local aura = button.auraFrame
Expand Down Expand Up @@ -617,7 +672,7 @@ function Gladius:UNIT_SPELLCAST_START(event, unit)
if(not button) then return end

local castBar = button.castBar
if( db.castBarOnCast ) then
if (db.castBar and db.castBarOnCast) then
castBar:Show()
end
castBar.isCasting = true
Expand Down Expand Up @@ -651,7 +706,7 @@ function Gladius:UNIT_SPELLCAST_CHANNEL_START(event, unit)
if(not button) then return end

local castBar = self.buttons[unit].castBar
if ( db.castBarOnCast ) then
if (db.castBar and db.castBarOnCast) then
castBar:Show()
end
castBar.isChanneling = true
Expand Down Expand Up @@ -705,7 +760,7 @@ function Gladius:UNIT_SPELLCAST_DELAYED(event, unit)
end

function Gladius:CastEnd(bar)
if ( db.castBarOnCast ) then
if (db.castBar and db.castBarOnCast) then
bar:Hide()
end
bar.isCasting = nil
Expand Down Expand Up @@ -1703,15 +1758,6 @@ function Gladius:Test()
button.manaText:Hide()
end

--set fake absorb value
if( db.absorbBar ) then
button.absorb.totalAbsorb:SetWidth(100-(i^2))
button.absorb.totalAbsorbOverlay:SetWidth(100-(i^2))
else
button.absorb.totalAbsorb:SetWidth(0)
button.absorb.totalAbsorbOverlay:SetWidth(0)
end

--Check if it's a pet class and in that case update the frame to fit
button.isPetClass = petClasses[class] and true or false

Expand Down Expand Up @@ -1744,13 +1790,42 @@ function Gladius:Test()

end

-- Utils used by absorbar
function Gladius:SearchButtonByGUID(GUID)
for _, button in pairs(self.buttons) do
if( GUID and button.GUID == GUID) then
return button
end
end
end

-- Absorb Update
function Gladius:UpdateAbsorb(event, unit, button)
function Gladius:EffectApplied(event, ...)
local sourceGUID, sourceName, destGUID, destName, spellId, value, quality, duration = ...
self:PreUpdateAbsorbBar(event, destGUID, destName)
end
function Gladius:EffectUpdated(event, ...)
local guid, spellId, value, duration = ...
self:PreUpdateAbsorbBar(event, guid)
end
function Gladius:EffectRemoved(event, ...)
local guid, spellId = ...
self:PreUpdateAbsorbBar(event, guid)
end
function Gladius:PreUpdateAbsorbBar(event, destGUID, name)
local button = self:SearchButtonByGUID(destGUID)
if (button) then
if( db.absorbBar and (arenaUnits[button.unit] == "playerUnit" or (arenaUnits[button.unit] ~= "playerUnit" and db.showPets)) ) then
self:UpdateAbsorbBar(event, button.unit, button)
end
end
end
function Gladius:UpdateAbsorbBar(event, unit, button)

local health = UnitHealth(unit)
local maxHealth = UnitHealthMax(unit)
local _guid = UnitGUID(unit)
local myCurrentHealAbsorb = LAM.Unit_Total(_guid)
local myCurrentHealAbsorb = LAM.Unit_Total(_guid) * 2 -- only enemy

--
function CompactUnitFrameUtil_UpdateFillBar(self, frame, previousTexture, health, myCurrentHealAbsorb)
Expand Down Expand Up @@ -1789,4 +1864,63 @@ function Gladius:UpdateAbsorb(event, unit, button)
button.absorb.overAbsorbGlow:Hide();
end

end
end

-- HealComm (Heal Prediction)
--[[ local function Update(self)
local unit = self.unit
local element = self.HealCommBar
if element.PreUpdate then
element:PreUpdate(unit)
end
local guid = UnitGUID(unit)
local timeFrame = self.HealCommTimeframe and GetTime() + self.HealCommTimeframe or nil
local myIncomingHeal = HealComm:GetHealAmount(guid, HealComm.ALL_HEALS, timeFrame, UnitGUID("player")) or 0
local allIncomingHeal = HealComm:GetHealAmount(guid, HealComm.ALL_HEALS, timeFrame) or 0
local health = UnitHealth(unit)
local maxHealth = UnitHealthMax(unit)
local maxOverflowHP = maxHealth * element.maxOverflow
local otherIncomingHeal = 0
if health + allIncomingHeal > maxOverflowHP then
allIncomingHeal = maxOverflowHP - health
end
if allIncomingHeal < myIncomingHeal then
myIncomingHeal = allIncomingHeal
else
otherIncomingHeal = allIncomingHeal - myIncomingHeal
end
if element.myBar then
element.myBar:SetMinMaxValues(0, maxHealth)
element.myBar:SetValue(myIncomingHeal)
element.myBar:Show()
end
if element.otherBar then
element.otherBar:SetMinMaxValues(0, maxHealth)
element.otherBar:SetValue(otherIncomingHeal)
element.otherBar:Show()
end
end
local function MultiUpdate(...)
for i = 1, select("#", ...) do
if (UnitGUID('arena1') == select(i, ...)) then
local allIncomingHeal = LHC:GetHealAmount(select(i, ...), LHC.ALL_HEALS, nil) or 0
print('updated arena1', allIncomingHeal)
elseif (UnitGUID('arena2') == select(i, ...)) then
local allIncomingHeal = LHC:GetHealAmount(select(i, ...), LHC.ALL_HEALS, nil) or 0
print('updated arena2', allIncomingHeal)
end
end
end
function Gladius:HealCommArena_Heal_Update(event, casterGUID, spellID, spellType, endTime, ...) -- ... = unpacked guid
MultiUpdate(...)
end
function Gladius:HealCommArena_Modified(event, guid)
MultiUpdate(guid)
end ]]
2 changes: 1 addition & 1 deletion Gladius/Gladius.toc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Version: v1.2.2
## Author: Proditor, Rinu, Enhanced by Cortes
## SavedVariables: GladiusDB
## OptionalDeps: Ace3, LibStub, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, LibCustomGlow-1.0, AbsorbsMonitor-1.0
## OptionalDeps: Ace3, LibStub, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, LibCustomGlow-1.0, AbsorbsMonitor-1.0, LibDataBroker-1.1, LibDBIcon-1.0
## LoadManagers: AddonLoader
## X-LoadOn-Slash: /gladius
## X-LoadOn-InterfaceOptions: Gladius
Expand Down
4 changes: 4 additions & 0 deletions Gladius/cooldownlist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function Gladius:GetCooldownList()
[12472] = { cd = 180, spec = L["Frost"], }, -- Icy Veins
[31687] = { cd = 180, spec = L["Frost"], }, -- Summon Water Elemental
[12043] = { cd = 120, spec = L["Arcane"], }, -- Presence of Mind
[42950] = { cd = 20, spec = L["Fire"] }, -- Combustion
[11129] = { cd = 120, spec = L["Fire"] }, -- Combustion
[12042] = { cd = 120, spec = L["Arcane"], }, -- Arcane Power
[11958] = { cd = 480, spec = L["Frost"], -- Coldsnap
Expand Down Expand Up @@ -48,6 +49,8 @@ function Gladius:GetCooldownList()
[49576] = 35, -- Death Grip
[47568] = 300, -- Empower Rune Weapon
[48743] = 120, -- Death Pact
[49039] = 120, -- Lichborne
[47481] = { cd = 60, spec = L["Unholy"], }, -- Pet Gnaw
[51052] = { cd = 120, spec = L["Unholy"], }, -- Anti-Magic Zone
[46584] = { cd = 180, notSpec = L["Unholy"], }, -- Raise Dead
[49206] = { cd = 180, spec = L["Unholy"], }, -- Summon Gargoyle
Expand Down Expand Up @@ -83,6 +86,7 @@ function Gladius:GetCooldownList()
[10278] = 300, -- Hand of Protection
[1044] = 25, -- Hand of Freedom
[54428] = 60, -- Divine Plea
[6940] = 120, -- Hand of Sacrifice
[64205] = 120, -- Divine Sacrifice
[10308] = { cd = 60, [L["Protection"]] = 40, }, -- Hammer of Justice
[642] = { cd = 300, -- Divine Shield
Expand Down
35 changes: 21 additions & 14 deletions Gladius/embeds.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
<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/">

<Script file="libs\LibStub\LibStub.lua"/>
<Include file="libs\CallbackHandler-1.0\CallbackHandler-1.0.xml"/>
<Include file="libs\AceAddon-3.0\AceAddon-3.0.xml"/>
<Include file="libs\AceDB-3.0\AceDB-3.0.xml"/>
<Include file="libs\AceDBOptions-3.0\AceDBOptions-3.0.xml"/>
<Include file="libs\AceConsole-3.0\AceConsole-3.0.xml"/>
<Include file="libs\AceGUI-3.0\AceGUI-3.0.xml"/>
<Include file="libs\AceConfig-3.0\AceConfig-3.0.xml"/>
<Include file="libs\AceLocale-3.0\AceLocale-3.0.xml"/>
<Include file="libs\AceEvent-3.0\AceEvent-3.0.xml"/>
<Include file="libs\LibSharedMedia-3.0\lib.xml"/>
<Include file="libs\AceGUI-3.0-SharedMediaWidgets\widget.xml"/>
<Include file="libs\LibCustomGlow-1.0\LibCustomGlow-1.0.xml"/>
<Include file="libs\AbsorbsMonitor-1.0\AbsorbsMonitor-1.0.xml"/>
<Script file="libs\LibStub\LibStub.lua"/>
<Script file="libs\LibDBIcon-1.0\LibDBIcon-1.0.lua"/>
<Script file="libs\LibDataBroker-1.1\LibDataBroker-1.1.lua"/>
<Include file="libs\CallbackHandler-1.0\CallbackHandler-1.0.xml"/>
<Include file="libs\AceAddon-3.0\AceAddon-3.0.xml"/>
<Include file="libs\AceDB-3.0\AceDB-3.0.xml"/>
<Include file="libs\AceDBOptions-3.0\AceDBOptions-3.0.xml"/>
<Include file="libs\AceConsole-3.0\AceConsole-3.0.xml"/>
<Include file="libs\AceGUI-3.0\AceGUI-3.0.xml"/>
<Include file="libs\AceConfig-3.0\AceConfig-3.0.xml"/>
<Include file="libs\AceLocale-3.0\AceLocale-3.0.xml"/>
<Include file="libs\AceEvent-3.0\AceEvent-3.0.xml"/>
<Include file="libs\AceSerializer-3.0\AceSerializer-3.0.xml"/>
<Include file="libs\AceComm-3.0\AceComm-3.0.xml"/>
<Include file="libs\AceTimer-3.0\AceTimer-3.0.xml"/>
<Include file="libs\LibSharedMedia-3.0\lib.xml"/>
<Include file="libs\AceGUI-3.0-SharedMediaWidgets\widget.xml"/>
<Include file="libs\LibCustomGlow-1.0\LibCustomGlow-1.0.xml"/>
<Include file="libs\AbsorbsMonitor-1.0\AbsorbsMonitor-1.0.xml"/>
<!-- <Include file="libs\SpecializedAbsorbs-1.0\SpecializedAbsorbs-1.0.xml"/> -->
<!-- <Include file="libs\LibHealCommArena-4.0\LibHealCommArena-4.0.xml"/> -->

</Ui>
Loading

0 comments on commit ccb3a20

Please sign in to comment.