translated code to English and a few bug fixes from latest alpha

This commit is contained in:
Tercio Jose
2023-06-21 17:27:58 -03:00
parent a2c5e926c9
commit 9fb2b0d66b
36 changed files with 3523 additions and 2679 deletions
+32 -27
View File
@@ -1,29 +1,29 @@
local Details = _G.Details
local DF = _G.DetailsFramework
local detailsFramework = _G.DetailsFramework
local C_Timer = _G.C_Timer
local addonName, Details222 = ...
local load = loadstring
--auto run scripts
Details.AutoRunCode = {}
local codeTable
local functionCache = {}
--compile and store code
function Details:RecompileAutoRunCode()
for codeKey, code in pairs(codeTable) do
local func, errorText = _G.loadstring(code)
function Details222.AutoRunCode.RecompileAutoRunCode()
for codeKey, code in pairs(Details222.AutoRunCode.CodeTable) do
local func, errorText = load(code)
if (func) then
DetailsFramework:SetEnvironment(func)
Details.AutoRunCode[codeKey] = func
detailsFramework:SetEnvironment(func)
functionCache[codeKey] = func
else
--if the code didn't pass, create a dummy function for it without triggering errors
Details.AutoRunCode[codeKey] = function() end
functionCache[codeKey] = function() end
end
end
end
--function to dispatch events
function Details:DispatchAutoRunCode(codeKey)
local func = Details.AutoRunCode[codeKey]
function Details222.AutoRunCode.DispatchAutoRunCode(codeKey)
local func = functionCache[codeKey]
if (type(func) ~= "function") then
Details:Msg("error running function for auto run script", codeKey)
@@ -39,15 +39,15 @@ function Details:DispatchAutoRunCode(codeKey)
end
--auto run frame to dispatch scrtips for some events that details! doesn't handle
local autoRunCodeEventFrame = _G.CreateFrame("frame")
local autoRunCodeEventFrame = CreateFrame("frame")
if (not _G.DetailsFramework.IsTimewalkWoW()) then
if (not 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
if (autoRunCodeEventFrame[event] and not autoRunCodeEventFrame[event]:IsCancelled()) then
return
end
@@ -55,13 +55,13 @@ autoRunCodeEventFrame.OnEventFunc = function(self, event)
--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")
Details222.AutoRunCode.DispatchAutoRunCode("on_specchanged")
--clear and invalidate the timer
autoRunCodeEventFrame[event]:Cancel()
autoRunCodeEventFrame[event] = nil
end)
--store the trigger
autoRunCodeEventFrame[event] = newTimer
end
@@ -71,21 +71,26 @@ 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")
Details222.AutoRunCode.DispatchAutoRunCode("on_init")
Details222.AutoRunCode.DispatchAutoRunCode("on_specchanged")
Details222.AutoRunCode.DispatchAutoRunCode("on_zonechanged")
if (_G.InCombatLockdown()) then
Details:DispatchAutoRunCode("on_entercombat")
Details222.AutoRunCode.DispatchAutoRunCode("on_entercombat")
else
Details:DispatchAutoRunCode("on_leavecombat")
Details222.AutoRunCode.DispatchAutoRunCode("on_leavecombat")
end
Details:DispatchAutoRunCode("on_groupchange")
Details222.AutoRunCode.DispatchAutoRunCode("on_groupchange")
end)
function Details:StartAutoRun()
--compile code
codeTable = Details.run_code
Details:RecompileAutoRunCode()
function Details222.AutoRunCode.StartAutoRun()
local newData = detailsFramework.table.copy({}, Details.run_code)
Details.run_code = nil
Details222.AutoRunCode.CodeTable = newData
Details222.AutoRunCode.RecompileAutoRunCode()
end
function Details222.AutoRunCode.OnLogout()
Details.run_code = Details222.AutoRunCode.CodeTable
end