WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Legion Beta archived threads (https://www.wowinterface.com/forums/forumdisplay.php?f=177)
-   -   Modifying Alertframes (https://www.wowinterface.com/forums/showthread.php?t=53443)

Miiru 05-15-16 06:41 AM

Modifying Alertframes
 
It seems like Alertframes (for example achievement) no longer have names but are children of UiParent?

AchievementAlertSystem:AddAlert(...) calls the alert frame (/run AchievementAlertSystem:AddAlert(112) to test). How can i now easily access them without having to scan for children of UiParent?

(It's the same for all alerts, all names are gone :()

lucro 05-15-16 01:30 PM

If you look at the source you'll see that the achievement alerts are created using a queued subsystem with
Code:

AchievementAlertSystem = AlertFrame:AddQueuedAlertFrameSubSystem("AchievementAlertFrameTemplate", AchievementAlertFrame_SetUp, 2, 6);
If you look at the source of the queued subsystem definition you'll see the important part is in OnLoad
Code:

function AlertFrameQueueMixin:OnLoad(alertFrameTemplate, setUpFunction, maxAlerts, maxQueue)
        self.alertFramePool = CreateFramePool("BUTTON", UIParent, alertFrameTemplate, OnPooledAlertFrameQueueReset);
-- .. more code ...
end

Primarily the CreateFramePool call returns an instance of a frame pool that now handles the creation and recycling of the alert frames.

The frame pool has some functions that may be relevant to you. Primarily EnumerateActive() that you can use in an a loop to go through all the alerts that are being displayed currently.

For example:
Code:

local achievementAlertPool = AchievementAlertSystem.alertFramePool
for alertFrame in achievementAlertPool:EnumerateActive() do
    --modify the alertFrame however
end


Miiru 05-15-16 02:02 PM

Thank you for your response, I will try to work through this tomorrow, I cant make much sense of it as of right now :D

lucro 05-15-16 02:12 PM

The frames won't be created until they're needed, so it may be sufficient to just hook the setup function AchievementAlertFrame_SetUp and adjust it there.

Miiru 05-15-16 02:38 PM

Quote:

Originally Posted by lucro (Post 314833)
The frames won't be created until they're needed, so it may be sufficient to just hook the setup function AchievementAlertFrame_SetUp and adjust it there.

I got it working like this:

Lua Code:
  1. hooksecurefunc(AchievementAlertSystem,"ShowAlert",function()
  2.             local achievementAlertPool = AchievementAlertSystem.alertFramePool
  3.                 for alertFrame in achievementAlertPool:EnumerateActive() do
  4.                     alertFrame.Icon:Hide()
  5.                     alertFrame.Background:ClearAllPoints()
  6.                     alertFrame.Background:SetSize(512,64)
  7.                     alertFrame.Background:SetTexCoord(0,1,1,0)
  8.                     alertFrame.Background:SetParent(alertFrame)
  9.                     alertFrame.Background:SetPoint("Center",29,1)
  10.                     alertFrame.Background:SetTexture("Interface\\Achievementframe\\miirgui_ach.tga")
  11.  
  12.                     alertFrame.Unlocked:SetTextColor(unpack(miirgui.Color))
  13.                     alertFrame.Unlocked:SetFont(unpack(miirgui.small))
  14.                     alertFrame.Unlocked:SetShadowColor(0,0,0,0)
  15.  
  16.                     alertFrame.Name:SetTextColor(1,1,1,1)
  17.                     alertFrame.Name:SetFont(unpack(miirgui.medium))
  18.                     alertFrame.Name:SetShadowColor(0,0,0,0)
  19.                 end
  20.         end)

I do not know if it's the best method, but it works just fine :). I tried hooking the setup function, but the hook did not seem to fire.

Miiru 05-18-16 01:07 PM

I am done with the alertframe now. It was pretty stright forward after your help :)

Here are some /run commands to test most alertframes incase somebody needs them.

Lua Code:
  1. /run LootAlertSystem:AddAlert("|cff9d9d9d|Hitem:7073:0:0:0:0:0:0:0:80:0:0:0:0|h[Broken Fang]|h|r", 1, specID, 3, 1, 3, Awesome);
  2.  
  3. /run MoneyWonAlertSystem:AddAlert(815)
  4.  
  5. /run AchievementAlertSystem:AddAlert(5192)
  6.  
  7. /run CriteriaAlertSystem:ShowAlert(80,1)
  8.  
  9. /run GuildChallengeAlertSystem:AddAlert(3, 2, 5)
  10.  
  11. /run InvasionAlertSystem:AddAlert(1,20)
  12.  
  13. /run DigsiteCompleteAlertSystem:AddAlert(1)
  14.  
  15.  /run LootUpgradeAlertSystem:AddAlert("|cff9d9d9d|Hitem:7073:0:0:0:0:0:0:0:80:0:0:0:0|h[Broken Fang]|h|r", 1, specID, 3, "Cesaor", 3, Awesome);
  16.  
  17.  /run GarrisonFollowerAlertSystem:AddAlert(112, "Cool Guy", "100", 3, 1)
  18.  
  19.  /run GarrisonShipFollowerAlertSystem:AddAlert(592, "Test", "Transport", "GarrBuilding_Barracks_1_H", 3, 2, 1)
  20.  
  21.  /run GarrisonBuildingAlertSystem:AddAlert("miau")
  22.  
  23.  /run WorldQuestCompleteAlertSystem:AddAlert(112)


All times are GMT -6. The time now is 06:34 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI