Files
coa-details/functions/autorun.lua
T
Tercio Jose 31c202c0f5 Major update
-New feature: Arena DPS Bar, can be enabled at the Broadcaster Tools section, shows a bar in 'kamehameha' style showing which team is doing more damage in the latest 3 seconds.
		-Revamp on the options section for Broadcaster tools.
		-Added 'Icon Size Offset' under Options > Bars: General, this new option allow to adjust the size of the class/spec icon shown on each bar.
		-Added 'Show Faction Icon' under Options > Bars: General, with this new option, you can choose to not show the faction icon, this icon is usually shown during battlegrounds.
		-Added 'Faction Icon Size Offset' under Options > Bars: General, new option to adjust the size of the faction icon.
		-Added 'Show Arena Role Icon' under Options > Bars: General, new option to hide or show the role icon of players during an arena match.
		-Added 'Arena Role Icon Size Offset' under Options > Bars: General, new option which allow to control the size of the arena role icon.
		-Added 'Level' option to Wallpapers, the wallpaper can now be placed on different levels which solves issues where the wallpaper is too low of certain configuration.
		-Streamer! plugin got updates, now it is more clear to pick which mode to use.
		-WotLK classic compatibility (Flamanis, Daniel Henry).
		-Fixed the title bar text not showing when using the Custom Title Bar feature.
		-Role detection in classic versions got improvements.
		-New API: Details:GetTop5Actors(attributeId), return the top 5 actors from the selected attribute.
		-New API: Details:GetActorByRank(attributeId, rankIndex), return an actor from the selected attribute and rankIndex.
		-Major cleanup and code improvements on dropdowns for library Details! Framework.
		-Cleanup on NickTag library.
		-Removed LibGroupInSpecT, LibItemUpgradeInfo and LibCompress. These libraries got replaced by OpenRaidLib and LibDeflate.
2022-08-10 17:41:06 -03:00

80 lines
2.5 KiB
Lua

local Details = _G.Details
local DF = _G.DetailsFramework
local C_Timer = _G.C_Timer
--auto run scripts
Details.AutoRunCode = {}
local codeTable
--compile and store code
function Details:RecompileAutoRunCode()
for codeKey, code in pairs(codeTable) do
local func, errorText = _G.loadstring(code)
if (func) then
DetailsFramework:SetEnvironment(func)
Details.AutoRunCode[codeKey] = func
else
--if the code didn't pass, create a dummy function for it without triggering errors
Details.AutoRunCode[codeKey] = function() end
end
end
end
--function to dispatch events
function Details:DispatchAutoRunCode(codeKey)
local func = Details.AutoRunCode[codeKey]
DF:QuickDispatch(func)
end
--auto run frame to dispatch scrtips for some events that details! doesn't handle
local autoRunCodeEventFrame = _G.CreateFrame("frame")
if (not _G.DetailsFramework.IsTimewalkWoW()) then
autoRunCodeEventFrame:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
end
autoRunCodeEventFrame.OnEventFunc = function(self, event)
--> ignore events triggered more than once in a small time window
if (autoRunCodeEventFrame [event] and not autoRunCodeEventFrame [event]:IsCancelled()) then
return
end
if (event == "PLAYER_SPECIALIZATION_CHANGED") then
--> create a trigger for the event, many times it is triggered more than once
--> so if the event is triggered a second time, it will be ignored
local newTimer = C_Timer.NewTimer(1, function()
Details:DispatchAutoRunCode("on_specchanged")
--> clear and invalidate the timer
autoRunCodeEventFrame[event]:Cancel()
autoRunCodeEventFrame[event] = nil
end)
--> store the trigger
autoRunCodeEventFrame[event] = newTimer
end
end
autoRunCodeEventFrame:SetScript("OnEvent", autoRunCodeEventFrame.OnEventFunc)
--dispatch scripts at startup
C_Timer.After(2, function()
Details:DispatchAutoRunCode("on_init")
Details:DispatchAutoRunCode("on_specchanged")
Details:DispatchAutoRunCode("on_zonechanged")
if (_G.InCombatLockdown()) then
Details:DispatchAutoRunCode("on_entercombat")
else
Details:DispatchAutoRunCode("on_leavecombat")
end
Details:DispatchAutoRunCode("on_groupchange")
end)
function Details:StartAutoRun()
--compile code
codeTable = Details.run_code
Details:RecompileAutoRunCode()
end