Updated LibOpenRaid and DetailsFramework

This commit is contained in:
Tercio Jose
2022-10-09 19:47:56 -03:00
parent 9974a87119
commit 944178f76f
126 changed files with 15502 additions and 15495 deletions
+43 -43
View File
@@ -5,9 +5,9 @@
local Loc = LibStub ("AceLocale-3.0"):GetLocale ( "Details" )
local _
--> Event types:
--Event types:
_detalhes.RegistredEvents = {
--> instances
--instances
["DETAILS_INSTANCE_OPEN"] = {},
["DETAILS_INSTANCE_CLOSE"] = {},
["DETAILS_INSTANCE_SIZECHANGED"] = {},
@@ -20,16 +20,16 @@
["DETAILS_INSTANCE_CHANGEMODE"] = {},
["DETAILS_INSTANCE_NEWROW"] = {},
--> misc
--misc
["DETAILS_OPTIONS_MODIFIED"] = {},
["UNIT_SPEC"] = {},
["UNIT_TALENTS"] = {},
--> data
--data
["DETAILS_DATA_RESET"] = {},
["DETAILS_DATA_SEGMENTREMOVED"] = {},
--> combat
--combat
["COMBAT_ENCOUNTER_START"] = {},
["COMBAT_ENCOUNTER_END"] = {},
["COMBAT_PLAYER_ENTER"] = {},
@@ -48,18 +48,18 @@
["COMBAT_MYTHICDUNGEON_START"] = {},
["COMBAT_MYTHICDUNGEON_END"] = {},
--> area
--area
["ZONE_TYPE_CHANGED"] = {},
--> roster
--roster
["GROUP_ONENTER"] = {},
["GROUP_ONLEAVE"] = {},
--> buffs
--buffs
["BUFF_UPDATE"] = {},
["BUFF_UPDATE_DEBUFFPOWER"] = {},
--> network
--network
["REALM_CHANNEL_ENTER"] = {}, --deprecated (realm channels are disabled)
["REALM_CHANNEL_LEAVE"] = {}, --deprecated
["COMM_EVENT_RECEIVED"] = {}, --added on core 129
@@ -67,7 +67,7 @@
}
local function AlreadyRegistred (_tables, _object)
for index, _this_object in ipairs (_tables) do
for index, _this_object in ipairs(_tables) do
if (_this_object.__eventtable) then
if (_this_object [1] == _object) then
return index
@@ -124,7 +124,7 @@ local common_events = {
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> register a event
--register a event
function _detalhes:RegisterEvent (object, event, func)
@@ -183,7 +183,7 @@ local common_events = {
end
------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> Unregister a Event
--Unregister a Event
function _detalhes:UnregisterEvent (object, event)
@@ -236,24 +236,24 @@ local common_events = {
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> internal functions
--internal functions
local dispatch_error = function(name, errortext)
_detalhes:Msg ((name or "<no context>"), " |cFFFF9900error|r: ", errortext)
end
--> safe call an external func with payload and without telling who is calling
--safe call an external func with payload and without telling who is calling
function _detalhes:QuickDispatchEvent (func, event, ...)
if (type (func) ~= "function") then
if (type(func) ~= "function") then
return
elseif (type (event) ~= "string") then
elseif (type(event) ~= "string") then
return
end
local okay, errortext = pcall (func, event, ...)
if (not okay) then
--> trigger an error msg
--trigger an error msg
dispatch_error (_, errortext)
return
@@ -262,22 +262,22 @@ local common_events = {
return true
end
--> quick dispatch with context, send the caller object within the payload
--quick dispatch with context, send the caller object within the payload
function _detalhes:QuickDispatchEventWithContext (context, func, event, ...)
if (type (context) ~= "table") then
if (type(context) ~= "table") then
return
elseif (type (func) ~= "function") then
elseif (type(func) ~= "function") then
return
elseif (type (event) ~= "string") then
elseif (type(event) ~= "string") then
return
end
local okay, errortext = pcall (func, context, event, ...)
if (not okay) then
--> attempt to get the context name
--attempt to get the context name
local objectName = context.__name or context._name or context.name or context.Name
--> trigger an error msg
--trigger an error msg
dispatch_error (objectName, errortext)
return
@@ -286,34 +286,34 @@ local common_events = {
return true
end
--> Send Event
function _detalhes:SendEvent (event, object, ...)
--Send Event
function _detalhes:SendEvent(event, object, ...)
--> send event to all registred plugins
--send event to all registred plugins
if (event == "PLUGIN_DISABLED" or event == "PLUGIN_ENABLED") then
return object:OnDetailsEvent (event, ...)
elseif (not object) then
--> iterate among all plugins which registered a function for this event
for _, PluginObject in ipairs (_detalhes.RegistredEvents[event]) do
--iterate among all plugins which registered a function for this event
for _, PluginObject in ipairs(_detalhes.RegistredEvents[event]) do
--> when __eventtable is true, the plugin registered a function or method name to callback
--> if is false, we call OnDetailsEvent method on the plugin
--when __eventtable is true, the plugin registered a function or method name to callback
--if is false, we call OnDetailsEvent method on the plugin
if (PluginObject.__eventtable) then
local pluginTable = PluginObject [1]
--> check if the plugin is enabled
--check if the plugin is enabled
if (pluginTable.Enabled and pluginTable.__enabled) then
--> check if fegistered a function
if (type (PluginObject [2]) == "function") then
--check if fegistered a function
if (type(PluginObject [2]) == "function") then
local func = PluginObject [2]
_detalhes:QuickDispatchEvent (func, event, ...)
--PluginObject [2] (event, ...)
--> if not it must be a method name
--if not it must be a method name
else
local methodName = PluginObject [2]
local func = pluginTable [methodName]
@@ -332,31 +332,31 @@ local common_events = {
end
end
--> plugin notifications (does not send to listeners)
elseif (type (object) == "string" and object == "SEND_TO_ALL") then
--plugin notifications (does not send to listeners)
elseif (type(object) == "string" and object == "SEND_TO_ALL") then
for _, PluginObject in ipairs (_detalhes.RaidTables.Plugins) do
for _, PluginObject in ipairs(_detalhes.RaidTables.Plugins) do
if (PluginObject.__enabled) then
_detalhes:QuickDispatchEventWithContext (PluginObject, PluginObject.OnDetailsEvent, event)
--PluginObject:OnDetailsEvent (event)
end
end
for _, PluginObject in ipairs (_detalhes.SoloTables.Plugins) do
for _, PluginObject in ipairs(_detalhes.SoloTables.Plugins) do
if (PluginObject.__enabled) then
_detalhes:QuickDispatchEventWithContext (PluginObject, PluginObject.OnDetailsEvent, event)
--PluginObject:OnDetailsEvent (event)
end
end
for _, PluginObject in ipairs (_detalhes.ToolBar.Plugins) do
for _, PluginObject in ipairs(_detalhes.ToolBar.Plugins) do
if (PluginObject.__enabled) then
_detalhes:QuickDispatchEventWithContext (PluginObject, PluginObject.OnDetailsEvent, event)
--PluginObject:OnDetailsEvent (event)
end
end
else
--> send the event only for requested plugin
--send the event only for requested plugin
if (object.Enabled and object.__enabled) then
return _detalhes:QuickDispatchEventWithContext (object, object.OnDetailsEvent, event, ...)
--return object:OnDetailsEvent (event, ...)
@@ -365,13 +365,13 @@ local common_events = {
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> special cases
--special cases
function _detalhes:SendOptionsModifiedEvent (instance)
_detalhes.last_options_modified = _detalhes.last_options_modified or (GetTime() - 5)
if (_detalhes.last_options_modified + 0.3 < GetTime()) then
_detalhes:SendEvent ("DETAILS_OPTIONS_MODIFIED", nil, instance)
_detalhes:SendEvent("DETAILS_OPTIONS_MODIFIED", nil, instance)
_detalhes.last_options_modified = GetTime()
if (_detalhes.last_options_modified_schedule) then
_detalhes:CancelTimer (_detalhes.last_options_modified_schedule)
@@ -386,7 +386,7 @@ local common_events = {
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> listeners
--listeners
local listener_meta = setmetatable ({}, _detalhes)
listener_meta.__index = listener_meta