Updates, please see /details news

This commit is contained in:
Tercio Jose
2022-04-22 13:30:41 -03:00
parent 7762e29d00
commit 694b52ddc4
27 changed files with 2703 additions and 1676 deletions
+454 -388
View File
@@ -4,55 +4,27 @@ local Details = _G.Details
local DF = _G.DetailsFramework
local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0")
local width = 170
local height = 300
local bar_height = 20
--namespace
Details.CooldownTracking = {}
function Details:InitializeCDTrackerWindow()
local DetailsCDTrackerWindow = CreateFrame("frame", "DetailsCDTrackerWindow", UIParent, "BackdropTemplate")
DetailsCDTrackerWindow:SetSize(700, 480)
DetailsCDTrackerWindow.Frame = DetailsCDTrackerWindow
DetailsCDTrackerWindow.__name = "OCD Tracker"
DetailsCDTrackerWindow.real_name = "DETAILS_CDTRACKERWINDOW"
DetailsCDTrackerWindow.__icon = [[Interface\TUTORIALFRAME\UI-TUTORIALFRAME-SPIRITREZ]]
DetailsCDTrackerWindow.__iconcoords = {130/512, 256/512, 0, 1}
DetailsCDTrackerWindow.__iconcolor = "white"
_G.DetailsPluginContainerWindow.EmbedPlugin(DetailsCDTrackerWindow, DetailsCDTrackerWindow, true)
function DetailsCDTrackerWindow.RefreshWindow()
Details.OpenCDTrackerWindow()
end
--check if is enabled at startup
if (Details.CooldownTracking.IsEnabled()) then
Details.CooldownTracking.EnableTracker()
end
DetailsCDTrackerWindow:Hide()
end
--return if the cooldown tracker is enabled
function Details.CooldownTracking.IsEnabled()
return Details.ocd_tracker.enabled
end
--enable the cooldown tracker
function Details.CooldownTracking.EnableTracker()
Details.ocd_tracker.enabled = true
--register callbacks
--openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownListUpdate", "CooldownListUpdateFunc") --nao tem
--openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownListWiped", "CooldownListWipedFunc") --nao tem
--openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownListUpdate", "CooldownUpdateFunc")
--openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownListWiped", "CooldownUpdateFunc")
openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownUpdate", "CooldownUpdateFunc")
--register callbacks with the openRaidLib
openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownListUpdate", "OnReceiveUnitFullCooldownList")
openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownUpdate", "OnReceiveSingleCooldownUpdate")
openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownListWipe", "OnCooldownListWipe")
Details.CooldownTracking.RefreshCooldownFrames()
end
--disable the cooldown tracker
function Details.CooldownTracking.DisableTracker()
Details.ocd_tracker.enabled = false
@@ -62,103 +34,90 @@ function Details.CooldownTracking.DisableTracker()
end
--unregister callbacks
openRaidLib.UnregisterCallback(Details.CooldownTracking, "CooldownListUpdate", "CooldownUpdateFunc")
openRaidLib.UnregisterCallback(Details.CooldownTracking, "CooldownListWiped", "CooldownUpdateFunc")
openRaidLib.UnregisterCallback(Details.CooldownTracking, "CooldownUpdate", "CooldownUpdateFunc")
end
function Details.CooldownTracking.CooldownUpdateFunc()
Details.CooldownTracking.RefreshCooldowns()
openRaidLib.UnregisterCallback(Details.CooldownTracking, "CooldownListUpdate", "OnReceiveUnitFullCooldownList")
openRaidLib.UnregisterCallback(Details.CooldownTracking, "CooldownUpdate", "OnReceiveSingleCooldownUpdate")
openRaidLib.UnregisterCallback(Details.CooldownTracking, "CooldownListWipe", "OnCooldownListWipe")
end
function Details.CooldownTracking.HideAllBars()
for _, bar in ipairs (DetailsOnlineCDTrackerScreenPanel.bars) do
bar:ClearAllPoints()
bar:Hide()
--> Library Open Raid Callbacks
--callback on the event 'CooldownListUpdate', this is triggered when a player in the group sent the list of cooldowns
--@unitId: which unit got updated
--@unitCooldows: a table with [spellId] = cooldownInfo
--@allUnitsCooldowns: a table containing all units [unitName] = {[spellId] = cooldownInfo}
function Details.CooldownTracking.OnReceiveUnitFullCooldownList(unitId, unitCooldows, allUnitsCooldowns)
Details.CooldownTracking.RefreshCooldownFrames()
end
end
function Details.CooldownTracking.GetOrCreateNewCooldownFrame(screenPanel, frameId)
local cooldownFrame = screenPanel.bars[frameId]
if (cooldownFrame) then
--callback on the event 'CooldownUpdate', this is triggered when a player uses a cooldown or a cooldown got updated (time left reduced, etc)
--@unitId: which unit got updated
--@spellId: which cooldown spell got updated
--@cooldownInfo: cooldown information table to be passed with other functions
--@unitCooldows: a table with [spellId] = cooldownInfo
--@allUnitsCooldowns: a table containing all units [unitName] = {[spellId] = cooldownInfo}
function Details.CooldownTracking.OnReceiveSingleCooldownUpdate(unitId, spellId, cooldownInfo, unitCooldows, allUnitsCooldowns)
local screenPanel = DetailsOnlineCDTrackerScreenPanel
local gotUpdated = false
local unitName = GetUnitName(unitId, true)
if (screenPanel) then
local cooldownFrame = screenPanel.playerCache[unitName] and screenPanel.playerCache[unitName][spellId]
if (cooldownFrame) then
--get the cooldown time from the lib, it return data ready to use on statusbar
local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
if (not isReady) then
cooldownFrame:SetTimer(currentValue, minValue, maxValue)
else
cooldownFrame:SetTimer()
end
gotUpdated = true
end
end
if (not gotUpdated) then
Details.CooldownTracking.RefreshCooldownFrames()
end
end
--when the list of cooldowns got wiped, usually happens when the player left a group
--@allUnitsCooldowns: a table containing all units [unitName] = {[spellId] = cooldownInfo}
function Details.CooldownTracking.OnCooldownListWipe(allUnitsCooldowns)
Details.CooldownTracking.RefreshCooldownFrames()
end
--> Frames
--hide all bars created
function Details.CooldownTracking.HideAllBars()
for _, bar in ipairs (DetailsOnlineCDTrackerScreenPanel.bars) do
bar:ClearAllPoints()
bar:Hide()
bar.cooldownInfo = nil
bar.spellId = nil
bar.class = nil
bar.unitName = nil
end
end
--get a cooldown frame
function Details.CooldownTracking.GetOrCreateNewCooldownFrame(screenPanel, frameId)
local cooldownFrame = screenPanel.bars[frameId]
if (cooldownFrame) then
return cooldownFrame
end
local cooldownFrame = DF:CreateTimeBar(screenPanel, [[Interface\AddOns\Details\images\bar_serenity]], Details.ocd_tracker.width-2, Details.ocd_tracker.height-2, 100, nil, screenPanel:GetName() .. "CDFrame" .. frameId)
tinsert(screenPanel.bars, cooldownFrame)
cooldownFrame:EnableMouse(false)
return cooldownFrame
end
local cooldownFrame = DF:CreateTimeBar(screenPanel, [[Interface\AddOns\Details\images\bar_serenity]], width-2, bar_height-2, 100, nil, screenPanel:GetName() .. "CDFrame" .. frameId)
tinsert(screenPanel.bars, cooldownFrame)
return cooldownFrame
end
function Details.CooldownTracking.SetupCooldownFrame(cooldownFrame, unitName, class, spellId)
local spellIcon = GetSpellTexture(spellId)
if (spellIcon) then
cooldownFrame:SetIcon(spellIcon, .1, .9, .1, .9)
local classColor = C_ClassColor.GetClassColor(class)
cooldownFrame:SetStatusBarColor(classColor.r, classColor.g, classColor.b)
cooldownFrame:SetLeftText(DF:RemoveRealmName(unitName))
cooldownFrame.spellId = spellId
cooldownFrame.class = class
cooldownFrame.unitName = unitName
end
end
function Details.CooldownTracking.SetupCooldownFrameTimer(cooldownFrame, startTime, endTime, currentTime)
if (currentTime == 0) then
cooldownFrame:StopTimer()
else
cooldownFrame:SetTimer(currentTime, startTime, endTime)
end
end
function Details.CooldownTracking.ProcessUnitCooldowns(unitId, statusBarFrameId, cooldownsOrganized)
local screenPanel = DetailsOnlineCDTrackerScreenPanel
if (not screenPanel) then
return
end
local allPlayersInfo = openRaidLib.playerInfoManager.GetAllPlayersInfo()
local allCooldownsFromLib = LIB_RAID_STATUS_COOLDOWNS_BY_SPEC
local cooldownsEnabled = Details.ocd_tracker.cooldowns
local unitName = UnitName(unitId)
local thisPlayerInfo = allPlayersInfo[unitName]
local GUID = UnitGUID(unitId)
local _, unitClassEng, classId = UnitClass(unitId)
local unitSpec = (thisPlayerInfo and thisPlayerInfo.specId) or (Details:GetSpecFromSerial(GUID)) or 0
if (unitSpec and unitSpec ~= 0) then
local unitCooldowns = allCooldownsFromLib[unitSpec]
for spellId, cooldownType in pairs(unitCooldowns) do
if (cooldownsEnabled[spellId]) then
local spellName = GetSpellInfo(spellId)
--print("CD:", spellName, unitName) --problema com shadowfiend do shadowpriest the mostra 2 vezes
local cooldownFrame = Details.CooldownTracking.GetOrCreateNewCooldownFrame(screenPanel, statusBarFrameId)
Details.CooldownTracking.SetupCooldownFrame(cooldownFrame, unitName, unitClassEng, spellId)
tinsert(cooldownsOrganized[classId], cooldownFrame)
statusBarFrameId = statusBarFrameId + 1
screenPanel.playerCache[unitName] = screenPanel.playerCache[unitName] or {}
screenPanel.playerCache[unitName][spellId] = cooldownFrame
end
end
end
end
function Details.CooldownTracking.RefreshCooldownFrames()
local screenPanel = DetailsOnlineCDTrackerScreenPanel
if (not screenPanel) then
--screen panel (goes into the UIParent and show cooldowns there)
--create the screen panel, goes into the UIParent and show cooldowns
function Details.CooldownTracking.CreateScreenFrame()
DetailsOnlineCDTrackerScreenPanel = CreateFrame("frame", "DetailsOnlineCDTrackerScreenPanel", UIParent, "BackdropTemplate")
screenPanel = DetailsOnlineCDTrackerScreenPanel
screenPanel:Hide()
screenPanel:SetSize(width, height)
screenPanel:SetSize(Details.ocd_tracker.width, Details.ocd_tracker.height)
screenPanel:SetPoint("center", 0, 0)
screenPanel:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
screenPanel:SetBackdropColor(0, 0, 0, .55)
@@ -191,291 +150,398 @@ function Details.CooldownTracking.RefreshCooldownFrames()
screenPanel.bars = {}
screenPanel.cooldownCache = Details.ocd_tracker.current_cooldowns
screenPanel.playerCache = {}
screenPanel.statusBarFrameIndex = 1
return screenPanel
end
screenPanel.scheduleRosterUpdate = nil
if (Details.ocd_tracker.show_conditions.only_in_group) then
if (not IsInGroup()) then
screenPanel:Hide()
return
function Details.CooldownTracking.SetupCooldownFrame(cooldownFrame)
local spellIcon = GetSpellTexture(cooldownFrame.spellId)
if (spellIcon) then
cooldownFrame:SetIcon(spellIcon, .1, .9, .1, .9)
local classColor = C_ClassColor.GetClassColor(cooldownFrame.class)
cooldownFrame:SetStatusBarColor(classColor.r, classColor.g, classColor.b)
cooldownFrame:SetLeftText(DF:RemoveRealmName(cooldownFrame.unitName))
cooldownFrame:SetSize(Details.ocd_tracker.width, Details.ocd_tracker.height)
end
end
if (Details.ocd_tracker.show_conditions.only_inside_instance) then
local isInInstanceType = select(2, GetInstanceInfo())
if (isInInstanceType ~= "party" and isInInstanceType ~= "raid" and isInInstanceType ~= "scenario" and isInInstanceType ~= "arena") then
screenPanel:Hide()
return
end
end
function Details.CooldownTracking.ProcessUnitCooldowns(unitId, unitCooldowns, cooldownsOrganized)
if (unitCooldowns) then
local unitInfo = openRaidLib.GetUnitInfo(unitId)
if (unitInfo) then
for spellId, cooldownInfo in pairs(unitCooldowns) do
--get a bar
local cooldownFrame = Details.CooldownTracking.GetOrCreateNewCooldownFrame(screenPanel, screenPanel.statusBarFrameIndex)
cooldownFrame.cooldownInfo = cooldownInfo
local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
local cooldownsOrganized = {}
for classId = 1, 12 do --12 classes
cooldownsOrganized[classId] = {}
end
local numGroupMembers = GetNumGroupMembers()
local statusBarFrameId = 1
cooldownFrame.spellId = spellId
cooldownFrame.class = unitInfo.class
cooldownFrame.unitName = unitInfo.nameFull
wipe(screenPanel.playerCache)
--setup the cooldown in the bar
Details.CooldownTracking.SetupCooldownFrame(cooldownFrame)
--add the cooldown into the organized by class table
tinsert(cooldownsOrganized[unitInfo.classId], cooldownFrame)
--iterate to the next cooldown frame
screenPanel.statusBarFrameIndex = screenPanel.statusBarFrameIndex + 1
if (IsInRaid()) then
for i = 1, numGroupMembers do
local unitId = "raid"..i
Details.CooldownTracking.ProcessUnitCooldowns(unitId, statusBarFrameId, cooldownsOrganized)
end
elseif (IsInGroup()) then
for i = 1, numGroupMembers - 1 do
local unitId = "party"..i
Details.CooldownTracking.ProcessUnitCooldowns(unitId, statusBarFrameId, cooldownsOrganized)
end
--player
Details.CooldownTracking.ProcessUnitCooldowns("player", statusBarFrameId, cooldownsOrganized)
end
for classId = 1, 12 do --12 classes
table.sort(cooldownsOrganized[classId], function(t1, t2) return t1.spellId < t2.spellId end)
end
Details.CooldownTracking.RefreshCooldowns()
end
--esta passando NIL no startTime para o SetTimer
--o numero de frames criados é menor que o numero de frames mostrados, esta dando erro em local bar = screenPanel.bars[barIndex] 381
function Details.CooldownTracking.RefreshCooldowns()
local screenPanel = DetailsOnlineCDTrackerScreenPanel
if (not screenPanel) then
return
end
--local cache saved with the character savedVariables
local cooldownCache = screenPanel.cooldownCache
local cooldownStatus = openRaidLib.cooldownManager.GetAllPlayersCooldown()
local cooldownIndex = 1
for unitName, allPlayerCooldowns in pairs(cooldownStatus) do
for spellId, cooldownInfo in pairs(allPlayerCooldowns) do
local cooldownFrame = screenPanel.playerCache[unitName] and screenPanel.playerCache[unitName][spellId]
if (cooldownFrame) then
local cooldownCache = cooldownCache[unitName] and cooldownCache[unitName][spellId]
if (not cooldownCache) then
--a cache with cooldown timers is saved within the host addon
screenPanel.cooldownCache[unitName] = screenPanel.cooldownCache[unitName] or {}
screenPanel.cooldownCache[unitName][spellId] = screenPanel.cooldownCache[unitName][spellId] or {}
cooldownCache = screenPanel.cooldownCache[unitName][spellId]
--store the cooldown frame into a cache to get the cooldown frame quicker when a cooldown receives updates
screenPanel.playerCache[unitInfo.nameFull] = screenPanel.playerCache[unitInfo.nameFull] or {}
screenPanel.playerCache[unitInfo.nameFull][spellId] = cooldownFrame
end
end
end
end
local timeLeft = cooldownInfo[1]
local charges = cooldownInfo[2]
local startTime = GetTime() - cooldownInfo[3]
local duration = cooldownInfo[4]
local endTime = startTime + duration
--> update cooldown frames based on the amount of players in the group or raid
function Details.CooldownTracking.RefreshCooldownFrames()
local screenPanel = DetailsOnlineCDTrackerScreenPanel
--save the cooldown data in the host addon
cooldownCache[1] = timeLeft
cooldownCache[2] = charges
cooldownCache[3] = startTime
cooldownCache[4] = endTime
if (not screenPanel) then
screenPanel = Details.CooldownTracking.CreateScreenFrame()
end
cooldownFrame:Show()
if (Details.ocd_tracker.framme_locked) then
screenPanel:EnableMouse(false)
else
screenPanel:EnableMouse(true)
end
if (cooldownFrame.spellId ~= spellId or unitName ~= cooldownFrame.unitName) then
--there's a different spell showing or player using this frame
if (timeLeft ~= 0) then
local spellName = GetSpellInfo(spellId)
--print("set timer 3", spellName, startTime + timeLeft, startTime, endTime)
--cooldownFrame:SetTimer(startTime + timeLeft, startTime, endTime)
end
Details.CooldownTracking.HideAllBars()
screenPanel.scheduleRosterUpdate = nil
wipe(screenPanel.playerCache)
screenPanel.statusBarFrameIndex = 1
if (Details.ocd_tracker.show_conditions.only_in_group) then
if (not IsInGroup()) then
screenPanel:Hide()
return
end
end
if (Details.ocd_tracker.show_conditions.only_inside_instance) then
local isInInstanceType = select(2, GetInstanceInfo())
if (isInInstanceType ~= "party" and isInInstanceType ~= "raid" and isInInstanceType ~= "scenario" and isInInstanceType ~= "arena") then
screenPanel:Hide()
return
end
end
local cooldownsOrganized = {}
for classId = 1, 12 do --12 classes
cooldownsOrganized[classId] = {}
end
local numGroupMembers = GetNumGroupMembers()
local filter = ""
for filterName, isEnabled in pairs(Details.ocd_tracker.filters) do
if (isEnabled) then
filter = filter .. filterName .. ","
end
end
if (IsInRaid()) then
for i = 1, numGroupMembers do
local unitId = "raid"..i
local unitCooldowns = openRaidLib.GetUnitCooldowns(unitId, filter)
Details.CooldownTracking.ProcessUnitCooldowns(unitId, unitCooldowns, cooldownsOrganized)
end
elseif (IsInGroup()) then
for i = 1, numGroupMembers - 1 do
local unitId = "party"..i
local unitCooldowns = openRaidLib.GetUnitCooldowns(unitId, filter)
Details.CooldownTracking.ProcessUnitCooldowns(unitId, unitCooldowns, cooldownsOrganized)
end
--player
local unitCooldowns = openRaidLib.GetUnitCooldowns("player", filter)
local cooldownInfo = unitCooldowns[15286]
local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
Details.CooldownTracking.ProcessUnitCooldowns("player", unitCooldowns, cooldownsOrganized)
else
--player
local unitCooldowns = openRaidLib.GetUnitCooldowns("player", filter)
Details.CooldownTracking.ProcessUnitCooldowns("player", unitCooldowns, cooldownsOrganized)
end
for classId = 1, 12 do --12 classes
table.sort(cooldownsOrganized[classId], function(t1, t2) return t1.spellId < t2.spellId end)
end
local xPos = 1
local yPos = 0
local maxHeight = 0
local maxWidth = Details.ocd_tracker.width + 2
local cooldownFrameIndex = 1
for classId = 1, 12 do
local cooldownFrameList = cooldownsOrganized[classId]
for index, cooldownFrame in ipairs(cooldownFrameList) do
local cooldownInfo = cooldownFrame.cooldownInfo
local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
--local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromUnitSpellID(cooldownFrame.unitName, cooldownFrame.spellId)
if (not isReady) then
cooldownFrame:SetTimer(currentValue, minValue, maxValue)
else
--spell and player are the same
if (timeLeft ~= 0) then
if (cooldownFrame:HasTimer()) then
if (cooldownFrame.timeLeft ~= timeLeft) then
local spellName = GetSpellInfo(spellId)
--print("set timer 1", spellName, startTime + timeLeft, startTime, endTime)
--cooldownFrame:SetTimer(startTime + timeLeft, startTime, endTime)
end
cooldownFrame:SetTimer()
end
--positioning
if (cooldownFrameIndex % Details.ocd_tracker.lines_per_column == 0) then
xPos = xPos + Details.ocd_tracker.width + 2
maxWidth = xPos + Details.ocd_tracker.width + 2
yPos = 0
end
cooldownFrame:SetPoint("topleft", screenPanel, "topleft", xPos, yPos)
yPos = yPos - Details.ocd_tracker.height - 1
if (yPos < maxHeight) then
maxHeight = yPos
end
cooldownFrameIndex = cooldownFrameIndex + 1
end
end
maxHeight = abs(maxHeight)
if (maxHeight == 0) then
screenPanel:Hide()
return
end
screenPanel:SetSize(maxWidth, maxHeight)
screenPanel:Show()
end
--> Options panel
--initialize the cooldown options window and embed it to Details! options panel
function Details:InitializeCDTrackerWindow()
local DetailsCDTrackerWindow = CreateFrame("frame", "DetailsCDTrackerWindow", UIParent, "BackdropTemplate")
DetailsCDTrackerWindow:SetSize(700, 480)
DetailsCDTrackerWindow.Frame = DetailsCDTrackerWindow
DetailsCDTrackerWindow.__name = "Cooldown Tracker"
DetailsCDTrackerWindow.real_name = "DETAILS_CDTRACKERWINDOW"
DetailsCDTrackerWindow.__icon = [[Interface\TUTORIALFRAME\UI-TUTORIALFRAME-SPIRITREZ]]
DetailsCDTrackerWindow.__iconcoords = {130/512, 256/512, 0, 1}
DetailsCDTrackerWindow.__iconcolor = "white"
_G.DetailsPluginContainerWindow.EmbedPlugin(DetailsCDTrackerWindow, DetailsCDTrackerWindow, true)
function DetailsCDTrackerWindow.RefreshWindow()
Details.OpenCDTrackerWindow()
end
--check if is enabled at startup
if (Details.CooldownTracking.IsEnabled()) then
Details.CooldownTracking.EnableTracker()
end
DetailsCDTrackerWindow:Hide()
end
function Details.OpenCDTrackerWindow()
--check if the window exists, if not create it
if (not _G.DetailsCDTrackerWindow or not _G.DetailsCDTrackerWindow.Initialized) then
_G.DetailsCDTrackerWindow.Initialized = true
local f = _G.DetailsCDTrackerWindow or DF:CreateSimplePanel(UIParent, 700, 480, "Details! Online CD Tracker", "DetailsCDTrackerWindow")
DF:ApplyStandardBackdrop(f)
--enabled with a toggle button
--execute to reset position
--misc configs
local options_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
local options_switch_template = DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE")
local options_slider_template = DF:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE")
local options_button_template = DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
local generalOptions = {
{--enable ocd
type = "toggle",
get = function() return Details.ocd_tracker.enabled end,
set = function (self, fixedparam, value)
if (value) then
Details.CooldownTracking.EnableTracker()
else
if (timeLeft ~= 0) then
local spellName = GetSpellInfo(spellId)
--print("set timer 2", spellName, startTime + timeLeft, startTime, endTime)
--cooldownFrame:SetTimer(startTime + timeLeft, startTime, endTime)
end
Details.CooldownTracking.DisableTracker()
end
else
if (cooldownFrame:GetValue() ~= 100) then
cooldownFrame:StopTimer()
end
end
end
end,
name = "Enable Experimental Cooldown Tracker",
desc = "Enable Experimental Cooldown Tracker",
},
cooldownIndex = cooldownIndex + 1
end
end
end
{--show only in group
type = "toggle",
get = function() return Details.ocd_tracker.show_conditions.only_in_group end,
set = function (self, fixedparam, value)
Details.ocd_tracker.show_conditions.only_in_group = value
Details.CooldownTracking.RefreshCooldownFrames()
end,
name = "Only in Group",
desc = "Only in Group",
},
cooldownIndex = cooldownIndex - 1
{--show only inside instances
type = "toggle",
get = function() return Details.ocd_tracker.show_conditions.only_inside_instance end,
set = function (self, fixedparam, value)
Details.ocd_tracker.show_conditions.only_inside_instance = value
Details.CooldownTracking.RefreshCooldownFrames()
end,
name = "Only Inside Instances",
desc = "Only Inside Instances",
},
{--lock frame
type = "toggle",
get = function() return Details.ocd_tracker.framme_locked end,
set = function (self, fixedparam, value)
Details.ocd_tracker.framme_locked = value
Details.CooldownTracking.RefreshCooldownFrames()
end,
name = "Lock Frame",
desc = "Lock Frame",
},
local xAnchor = 1
local defaultY = 0
local xPos = 1
local yPos = 0
local maxHeight = 0
{type = "breakline"},
for barIndex = 1, cooldownIndex do
if (barIndex % 11 == 0) then
xPos = xPos + width + 2
yPos = 0
{--filter: show raid wide defensive cooldowns
type = "toggle",
get = function() return Details.ocd_tracker.filters["defensive-raid"] end,
set = function (self, fixedparam, value)
Details.ocd_tracker.filters["defensive-raid"] = value
Details.CooldownTracking.RefreshCooldownFrames()
end,
name = "Defensive: Raid",
desc = "Exanple: druid tranquility.",
},
{--filter: show target defensive cooldowns
type = "toggle",
get = function() return Details.ocd_tracker.filters["defensive-target"] end,
set = function (self, fixedparam, value)
Details.ocd_tracker.filters["defensive-target"] = value
Details.CooldownTracking.RefreshCooldownFrames()
end,
name = "Defensive: Target",
desc = "Exanple: priest pain suppression.",
},
{--filter: show personal defensive cooldowns
type = "toggle",
get = function() return Details.ocd_tracker.filters["defensive-personal"] end,
set = function (self, fixedparam, value)
Details.ocd_tracker.filters["defensive-personal"] = value
Details.CooldownTracking.RefreshCooldownFrames()
end,
name = "Defensive: Personal",
desc = "Exanple: mage ice block.",
},
{--filter: show ofensive cooldowns
type = "toggle",
get = function() return Details.ocd_tracker.filters["ofensive"] end,
set = function (self, fixedparam, value)
Details.ocd_tracker.filters["ofensive"] = value
Details.CooldownTracking.RefreshCooldownFrames()
end,
name = "Offensive Cooldowns",
desc = "Exanple: priest power infusion.",
},
{--filter: show utility cooldowns
type = "toggle",
get = function() return Details.ocd_tracker.filters["utility"] end,
set = function (self, fixedparam, value)
Details.ocd_tracker.filters["utility"] = value
Details.CooldownTracking.RefreshCooldownFrames()
end,
name = "Utility Cooldowns",
desc = "Exanple: druid roar.",
},
{type = "breakline"},
{--bar width
type = "range",
get = function() return Details.ocd_tracker.width end,
set = function (self, fixedparam, value)
Details.ocd_tracker.width = value
Details.CooldownTracking.RefreshCooldownFrames()
end,
min = 10,
max = 200,
step = 1,
name = "Width",
desc = "Width",
},
{--bar height
type = "range",
get = function() return Details.ocd_tracker.height end,
set = function (self, fixedparam, value)
Details.ocd_tracker.height = value
Details.CooldownTracking.RefreshCooldownFrames()
end,
min = 10,
max = 200,
step = 1,
name = "Height",
desc = "Height",
},
{--bar height
type = "range",
get = function() return Details.ocd_tracker.lines_per_column end,
set = function (self, fixedparam, value)
Details.ocd_tracker.lines_per_column = floor(value)
Details.CooldownTracking.RefreshCooldownFrames()
end,
min = 1,
max = 30,
step = 1,
name = "Lines Per Column",
desc = "Lines Per Column",
},
}
DF:BuildMenu(f, generalOptions, 5, -35, 150, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
--cooldown selection
local cooldownProfile = Details.ocd_tracker.cooldowns
local cooldownSelectionFrame = CreateFrame("frame", "$parentCooldownSelectionFrame", f, "BackdropTemplate")
cooldownSelectionFrame:SetPoint("topleft", f, "topleft", 0, -150)
cooldownSelectionFrame:SetPoint("bottomright", f, "bottomright", 0, 10)
DF:ApplyStandardBackdrop(cooldownSelectionFrame)
--lib test test warning texts
local warning1 = cooldownSelectionFrame:CreateFontString(nil, "overlay", "GameFontNormal", 5)
warning1:SetPoint("center", f, "center", 0, 0)
warning1:SetText("A cooldown tracker on Details!?\nWhat's next, a Caw counter for Elwynn Forest?")
DF:SetFontColor(warning1, "silver")
DF:SetFontSize(warning1, 14)
local animationHub = DF:CreateAnimationHub(warning1)
local anim1 = DF:CreateAnimation(animationHub, "rotation", 1, 0, 35)
anim1:SetEndDelay(math.huge)
anim1:SetSmoothProgress(1)
animationHub:Play()
animationHub:Pause()
local warning2 = cooldownSelectionFrame:CreateFontString(nil, "overlay", "GameFontNormal", 5)
warning2:SetJustifyH("left")
warning2:SetPoint("topleft", f, "topleft", 5, -160)
DF:SetFontColor(warning2, "lime")
warning2:SetText("This is a concept of a cooldown tracker using the new library 'Open Raid' which uses comms to update cooldown timers.\nThe code to implement is so small that can fit inside a weakaura\nIf you're a coder, the implementation is on Details/frames/window_cdtracker.lua")
end
local bar = screenPanel.bars[barIndex]
bar:SetPoint("topleft", screenPanel, "topleft", xPos, yPos)
yPos = yPos - bar_height
if (yPos < maxHeight) then
maxHeight = yPos
end
end
maxHeight = abs(maxHeight)
if (maxHeight == 0) then
screenPanel:Hide()
return
end
screenPanel:SetSize(width + xAnchor, abs(maxHeight))
screenPanel:Show()
end
function Details.OpenCDTrackerWindow()
--check if the window exists, if not create it
if (not _G.DetailsCDTrackerWindow or not _G.DetailsCDTrackerWindow.Initialized) then
_G.DetailsCDTrackerWindow.Initialized = true
local f = _G.DetailsCDTrackerWindow or DF:CreateSimplePanel(UIParent, 700, 480, "Details! Online CD Tracker", "DetailsCDTrackerWindow")
DF:ApplyStandardBackdrop(f)
--enabled with a toggle button
--execute to reset position
--misc configs
local options_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
local options_switch_template = DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE")
local options_slider_template = DF:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE")
local options_button_template = DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
local generalOptions = {
{--enable ocd
type = "toggle",
get = function() return Details.ocd_tracker.enabled end,
set = function (self, fixedparam, value)
if (value) then
Details.CooldownTracking.EnableTracker()
else
Details.CooldownTracking.DisableTracker()
end
end,
name = "Enable Online Cooldown Tracker",
desc = "Enable Online Cooldown Tracker",
},
{--show only in group
type = "toggle",
get = function() return Details.ocd_tracker.show_conditions.only_in_group end,
set = function (self, fixedparam, value)
Details.ocd_tracker.show_conditions.only_in_group = value
Details.CooldownTracking.RefreshCooldownFrames()
end,
name = "Only in Group",
desc = "Only in Group",
},
{--show only inside instances
type = "toggle",
get = function() return Details.ocd_tracker.show_conditions.only_inside_instance end,
set = function (self, fixedparam, value)
Details.ocd_tracker.show_conditions.only_inside_instance = value
Details.CooldownTracking.RefreshCooldownFrames()
end,
name = "Only Inside Instances",
desc = "Only Inside Instances",
},
}
DF:BuildMenu(f, generalOptions, 5, -35, 150, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
--cooldown selection
local cooldownProfile = Details.ocd_tracker.cooldowns
local cooldownSelectionFrame = CreateFrame("frame", "$parentCooldownSelectionFrame", f, "BackdropTemplate")
cooldownSelectionFrame:SetPoint("topleft", f, "topleft", 0, -150)
cooldownSelectionFrame:SetPoint("bottomright", f, "bottomright", 0, 10)
DF:ApplyStandardBackdrop(cooldownSelectionFrame)
--list of cooldowns to show, each one with a toggle button
local cooldownList = {}
local alreadyAdded = {}
if (LIB_RAID_STATUS_COOLDOWNS_BY_SPEC) then
for specId, cooldownTable in pairs(LIB_RAID_STATUS_COOLDOWNS_BY_SPEC) do
local currentIndex = #cooldownList+1
local cooldownAdded = false
for spellId, cooldownType in pairs(cooldownTable) do
if (not alreadyAdded[spellId]) then
if (cooldownType == 3 or cooldownType == 4 or cooldownType == 1 or cooldownType == 2) then
local spellName, _, spellIcon = GetSpellInfo(spellId)
if (spellName) then
cooldownList[#cooldownList+1] = {
type = "toggle",
get = function()
if (cooldownProfile[spellId] == nil) then
if (cooldownType == 3 or cooldownType == 4 or cooldownType == 1 or cooldownType == 2) then
cooldownProfile[spellId] = true
end
end
return cooldownProfile[spellId]
end,
set = function (self, fixedparam, value)
if (value) then
cooldownProfile[spellId] = value
else
cooldownProfile[spellId] = nil
end
end,
name = "|T" .. spellIcon .. ":" .. (16) .. ":" .. (16) .. ":0:0:64:64:" .. 0.1*64 .. ":" .. 0.9*64 .. ":" .. 0.1*64 .. ":" .. 0.9*64 .. "|t" .. spellName,
desc = spellName,
boxfirst = true,
}
alreadyAdded[spellId] = true
cooldownAdded = true
end
end
end
end
if (cooldownAdded) then
local _, spenName, _, specIcon = GetSpecializationInfoByID(specId)
local iconString = "|T" .. specIcon .. ":" .. (16) .. ":" .. (16) .. ":0:0:64:64:" .. 0.1*64 .. ":" .. 0.9*64 .. ":" .. 0.1*64 .. ":" .. 0.9*64 .. "|t"
tinsert(cooldownList, currentIndex, {type = "label", get = function() return iconString .. " " .. spenName end})
if (currentIndex > 1) then
tinsert(cooldownList, currentIndex, {type = "blank"})
end
end
end
end
DF:BuildMenu(cooldownSelectionFrame, cooldownList, 5, -5, cooldownSelectionFrame:GetHeight() - 40, false, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
_G.DetailsPluginContainerWindow.OpenPlugin(_G.DetailsCDTrackerWindow)
_G.DetailsCDTrackerWindow:Show()
end
_G.DetailsPluginContainerWindow.OpenPlugin(_G.DetailsCDTrackerWindow)
_G.DetailsCDTrackerWindow:Show()
end