View Single Post
07/08/19, 10:59 PM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,976
I only did a quick search, and you might have found this already:

Code:
--[[
        EVENT_COLLECTIBLE_UPDATED fires when a nickname changes or a collectible is set as active/inactive. It does not encompass unlock state changes.
        EVENT_COLLECTION_UPDATED happens on init or when a command forces all collectibles to lock/unlock (re-init). Those cases don't use dirty unlock mappings from C, so we do that delta work here while we refresh everything.
        EVENT_ESO_PLUS_FREE_TRIAL_STATUS_CHANGED can happen at any time, and is an event that tells us to re-evaluate unlock status for everything because anything could be based on that. Like with EVENT_COLLECTION_UPDATED, we handle the delta here, not in C.
        EVENT_COLLECTIBLES_UNLOCK_STATE_CHANGED happens when the client maps out dirty unlock states (collectibles go on trial or ownership changes like crown store or rewards). We consume the dirty mapping from C and broadcast it out.
        The later 3 all fire the same callback ("OnCollectionUpdated") to all systems registering with the callback manager with info to help determine what happened: collectionUpdateType (ZO_COLLECTION_UPDATE_TYPE), collectiblesByNewUnlockState
    --]]
EVENT_MANAGER:RegisterForEvent("ZO_CollectibleDataManager", EVENT_COLLECTIBLE_UPDATED, function(_, ...) self:OnCollectibleUpdated(...) end)
EVENT_MANAGER:RegisterForEvent("ZO_CollectibleDataManager", EVENT_COLLECTION_UPDATED, function(_, ...) self:OnCollectionUpdated(...) end)
EVENT_MANAGER:RegisterForEvent("ZO_CollectibleDataManager", EVENT_ESO_PLUS_FREE_TRIAL_STATUS_CHANGED, function(_, ...) self:OnESOPlusFreeTrialStatusChanged(...) end)
EVENT_MANAGER:RegisterForEvent("ZO_CollectibleDataManager", EVENT_COLLECTIBLES_UNLOCK_STATE_CHANGED, function(_, ...) self:OnCollectiblesUnlockStateChanged(...) end)
EVENT_MANAGER:RegisterForEvent("ZO_CollectibleDataManager", EVENT_COLLECTIBLE_NEW_STATUS_CLEARED, function(_, ...) self:OnCollectibleNewStatusCleared(...) end)
EVENT_MANAGER:RegisterForEvent("ZO_CollectibleDataManager", EVENT_COLLECTIBLE_CATEGORY_NEW_STATUS_CLEARED, function(_, ...) self:OnCollectibleCategoryNewStatusCleared(...) end)
EVENT_MANAGER:RegisterForEvent("ZO_CollectibleDataManager", EVENT_COLLECTIBLE_NOTIFICATION_NEW, function(_, ...) self:OnCollectibleNotificationNew(...) end)
EVENT_MANAGER:RegisterForEvent("ZO_CollectibleDataManager", EVENT_COLLECTIBLE_NOTIFICATION_REMOVED, function(_, ...) self:OnCollectibleNotificationRemoved(...) end)
EVENT_MANAGER:RegisterForEvent("ZO_CollectibleDataManager", EVENT_HOUSING_PRIMARY_RESIDENCE_SET, function(_, ...) self:OnPrimaryResidenceSet(...) end)

https://github.com/esoui/esoui/blob/...atamanager.lua

Maybe you can use EVENT_COLLECTIBLES_UNLOCK_STATE_CHANGED (if this is not the one which you meant was removed).
Or you use the callback function "function ZO_CollectibleDataManager:OnCollectiblesUnlockStateChanged()" with a ZO_PreHook.
As the are no parameter you might need to rebuild the code in there yourself to get the colelctibleIds unlocked:

Lua Code:
  1. ZO_PreHook(ZO_COLLECTIBLE_DATA_MANAGER, "OnCollectiblesUnlockStateChanged", function()
  2. d("A collectible was unlocked!")
  3.     --Copied from [url]https://github.com/esoui/esoui/blob/c47af79c7c51681ae315d4f9a6d70d9e965ad514/esoui/ingame/collections/collectibledatamanager.lua[/url]
  4.  
  5.     local function GetNextDirtyUnlockStateCollectibleIdIter(_, lastCollectibleId)
  6.         --Attention: PLease test here, if your PreHook to the event function, which callls GetNextDirtyUnlockStateCollectibleId before the non-prehooked original code will call GetNextDirtyUnlockStateCollectibleId again, does break the function GetNextDirtyUnlockStateCollectibleId somehow so that the original code won't find any new collectible afterwards! If this is the case you need to copy the whole function somehow and assure all original code is run beside yours. But please do not overwrite it as other addons might get destroyed this way.
  7.         return GetNextDirtyUnlockStateCollectibleId(lastCollectibleId)
  8.     end
  9.  
  10.     function ZO_CollectibleDataManager:OnCollectiblesUnlockStateChanged()
  11.         local collectiblesByNewUnlockState = {}
  12.         for collectibleId in GetNextDirtyUnlockStateCollectibleIdIter do
  13. d(">collectibleId: " .. tostring(collectibelId)
  14. --[[
  15.             --If needed use this code as well to check if the colelctibelId and data is valid
  16.             local collectibleData = ZO_COLLECTIBLE_DATA_MANAGER.collectibleIdToDataMap[collectibleId]
  17.             if collectibleData then
  18.                 --sanity checks finished, run code
  19.             end
  20. ]]
  21.       end
  22. return false -- to call original code afterwards
  23. end)

Edit:
Please check if the PreHook will break the function GetNextDirtyUnlockStateCollectibleId somehow so that the original code won't get any new collectibelids after your prehook anymore.

Last edited by Baertram : 07/08/19 at 11:55 PM.
  Reply With Quote