Little help fixing too flashy garrison frames
I'm trying to make a permanent fix to abusive garrison interface.
I've found a way to disable flash for order queue frame, … lua Code:
How can I go about it firing automatically at the right moment? |
Garrison UI is probably a LoD Blizzard addon.
You should register ADDON_LOADED and watch for arg1 being "Blizzard_GarrisonUI", then do whatever to the frame. |
That's an idea. Thankfully I've the necessary infrastructure already in place.
|
On a second thought, I could use a little hint or two.
Right now, I have everything in a single file. Which, quite unsurprisingly, grow "a little" unwieldy. I plan to separate stuff into more manageable chunks. However, the order of execution is important. Right now, the code is laid like this: Main addon frame (listener) is created right away, along with events table. Then some additional stuff happens, that is not relevant to anything at this point. Then events table is populated by callback functions, one per event. Like, Code:
function events:PLAYER_ENTERING_WORLD(...) … end Then the callbacks are registered as listeners. Like the usual lua Code:
The problem as I see it is I can no longer registed events right away in the main block. I need to postpone them. May be I should hook some event that is fired very early first, and do the registration there? Which event, if that is a good idea? P.S. I plan to use Code:
local addonName, addon = ... |
Just add "##Dependencies: Blizzard_GarrisonUI" to the toc file, unless your addon needs to do something before the garrison addon loads.
|
That would cause Garrison UI to load unconditionally, wouldn't it?
I'd like to avoid it, if I can help it. My loading times already quite long. Besides, I can use some coding practice. :rolleyes: |
If you use this instead, it would tag your addon as LoD and load with the Blizzard addon.
Code:
## LoadOnDemand: 1 Edit: LoadWith does automatically set your addon as LoD and it requires the target to be LoD as well. |
Yeah, that could be a solution, too. If I would to write a separate addon :)
Which I probably would, considering other factors. |
Quote:
It doesn't force the dependency to load. |
Quote:
What Dependencies does is modify the load order so the target loads before your addon. If the addon isn't found, yours will not be loaded. OptionalDeps has the same behavior with the exception that it will allow your addon to load without the target if it doesn't exist. If the target is LoD and your addon isn't, the target will be loaded at startup. LoadWith was created to allow an addon to load immediately after a target LoD addon loads. Edit: If Dependencies is used with LoadOnDemand flagged, your addon will never load unless called by LoadAddOn(). Forcing your addon to load at such time will also force the target LoD addon to load too. However, your addon will not load with the target as the OP had wanted. This is what LoadWith is for. |
Going back to events and order of execution. (Not related to Garrison UI now, but just because we've touched that already.)
Is there any documentation on the order of events firing? Or a library that may help managing accumulation and registration of event callbacks? |
Quote:
However, with Code:
## LoadWith: Blizzard_GarrisonUI |
Quote:
Code:
local MyAddon = CreateFrame("Frame") Was there some specific aspect of event handling you're having trouble with? |
There was, but it seems it was lost in the beginning of the thread :)
I'lll reiterate. I have an addon that grew a little to big to manage it in one function. But it IS, basically, a few functions - event listeners. I want to split it into several files. But I would like to retain core functionality in one file. Passing the data around seems to be a nonissue through global addon table. But registration of events, I can't do it in one file straight away (create fame, register events, then write handlers in separate files? - I just don't know, what these handlers will be). Now, that I'm writing it, I've got an idea. What if I add a metatable to my events table? And every time a key is added or removed, I would registed the main frame for listening on that event, or remove listeners, if table is empty? Seems like a very simple idea. Perhaps, there is already a library to manage such kind of things? Although, I'll probably try to write one myself, just for practice. Never used metatables before. |
I use this in my personal "do a bunch of random stuff" mod:
Code:
local _, addon = ... Code:
addon:RegisterEvent("UNIT_HEALTH", function(unit) Code:
local function healthFunc(unit) Code:
function addon:UpdateHealth(unit) Code:
local healthFrame = CreateFrame("Frame", "MyHealthFrame", UIParent) Other options would be to use AceEvent-3.0 with or without AceAddon-3.0, or to just create a separate event handler frame in each file. |
Thank you very much for your examples! Have a happy new year!
|
Correct me, if I wrong, but this one:
Lua Code:
|
No. If there's no "handler" then it's assumed that the "func" is a function. You could add some type checks but there's not really any point -- it's not a shared library, so your mistakes won't break other addons.
If you meant the "next" part, the answer is also no -- "next" returns two values, with the first being a key, the second the value of that key. The code in question there only cares about the first value -- the key -- which can only be a function. |
Quote:
When you check for f[event][func], it'll return your "false" and unregister will not succeed. |
Quote:
Code:
if func and f[event] and f[event][func] ~= nil then |
All times are GMT -6. The time now is 04:38 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI