WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   How to get hidden frames? (https://www.wowinterface.com/forums/showthread.php?t=57222)

Lybrial 06-23-19 09:33 AM

How to get hidden frames?
 
I want to manipulate a hidden frame from BigWigs - the BigWigsAnchor.
Here is the code on their github:

BigWigs/Bars.lua

As you can see there at the end they do display:Hide(). I guess this is the
reason why I cannot get the frame:

Code:

local count = GetNumAddOns();
       
for i = 1, count do
        local name = GetAddOnInfo(i);
       
        if (IsAddOnLoaded(i) and (name == "BigWigs")) then
                -- BigWigs is loaded
                local frame = _G["BigWigsAnchor"];

                if (frame) then
                    -- do stuff
                else
                    print("BigWigsAnchor does not exist");
                end
        end
end


Is there a way to also get and manipulate hidden frames? Or could there be another reason why BigWigsAnchor is always nil?

Fizzlemizz 06-23-19 09:58 AM

I don't know BigWigs but that code tells me it is marked as Load On Demand (LOD).

If you open it's .TOC file you should see and entry:
Code:

## LoadOnDemand: 1
This means the addon (and it's frames) are not loaded/created until the addon is specifically loaded during play (probably by entering a dungeon or raid).

You have two choices,

1. Wait for an "ADDON_LOADED" event where the first payload parameter (the addons name for this event) is "BigWigs" and then do what you need to do,

2. Test if the addon is loaded and if not, load it yourself using
Code:

if not IsAddOnLoaded("BigWigs")
      local Loaded, Reason = LoadAddOn("BigWigs")
      if Loaded then
          -- do what you need to do
      else
            -- it didn't load for Reason
      end
end

I would suggest using the first if possible unless there is some specific reason you need the BigWigs frames earlier.

Lybrial 06-23-19 10:48 AM

Thx, did not know about load on demand.
Have to think of something to work with that. Thanks.

Fizzlemizz 06-23-19 11:14 AM

Lua Code:
  1. local f = CreateFrame("Frame", "LybrialEventFrame")
  2. f:SetScript("OnEvent", function(self, event, ...)
  3.     local arg1 = ... --(arg1 will be the name of the addon just loaded for the "ADDON_LOADED" event)
  4.     if event == "ADDON_LOADED" and arg1 == "BigWigs" then
  5.         -- Initial Bigwigs frames should be created now
  6.     end
  7. end)
  8. f:RegisterEvent("ADDON_LOADED")

Lybrial 06-23-19 02:25 PM

Yeah. The Problem ist Not the Code. I Neef to think about If it makes sense to load the addons I need or if I can find a better solution.

Here a small Video of what im working on:

https://m.youtube.com/watch?v=9N0dxKoV8Qg

It will be possible to move all the anchors. Currently it is already working for Grid2, Hekili, Raven and my own unit frames. The LOD makes it Harder.

Fizzlemizz 06-23-19 02:36 PM

The code was to show how your addon might not do anything about adding frames for BigWigs until BigWigs loads and then at that time add whatever you need.

You could also create a second addon (addon folder with it's own .TOC) and mark it to Load With BigWigs.

Lybrial 06-24-19 12:02 AM

Yes, but this would not work for my configuration mode. In my AddOn
you can press a button "Toggle Anchors" which will create and toggle
frame overlays which show all the positions and names of all anchors,
makes them moveable and resizable. You would not be able to configure
BigWigs position and size outside of dungeons, where BigWigs is loaded.

So for the configuration mode I would anyway need to load BigWigs if
it is not yet loaded.

Fizzlemizz 06-24-19 01:12 AM

Quote:

Originally Posted by Lybrial (Post 332504)
So for the configuration mode I would anyway need to load BigWigs if
it is not yet loaded.

That's OK also.

Seerah 06-25-19 06:44 PM

Doesn't BigWigs have a config mode?


All times are GMT -6. The time now is 09:35 AM.

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