WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Anchoring an addon frame to another addon (https://www.wowinterface.com/forums/showthread.php?t=36225)

maltese 10-25-10 07:50 AM

Anchoring an addon frame to another addon
 
Recently I've been trying to finalize the changes to my UI and I'd really like to anchor my cooldown monitors frame to the top of my raid frames. I'm using Vlakcooldowns which I'd like to anchor to the top center of my oUF raid frames so the monitor is always right at the top of my raid frames regardless of if I', in a 10 or 25 man group.

How would I go about accomplishing this?

Vlad 10-25-10 08:20 AM

This is how I would do it:
1. /fstack and turn on showing the name of frames when you mouse over stuff.
2. Mouse over the frame you wish to move and write it's name down
3. Mouse over the frame you wish to anchor something to and write it's name down
4. /run local a,b=FrameA,FrameB a:ClearAllPoints() a:SetPoint("TOPLEFT", b, "TOPLEFT", 0, 0)
You may have to play around a bit, the documentation of "SetPoint" is http://www.wowpedia.org/API_Region_SetPoint and it may help if you are stuck on what values for "TOPLEFT" there are and what the different stuff mean.

Duugu 10-25-10 08:27 AM

Keep in mind that frame names are case sensitive when doing this.

maltese 10-25-10 10:06 AM

Quote:

Originally Posted by Vladinator (Post 213946)
This is how I would do it:
1. /fstack and turn on showing the name of frames when you mouse over stuff.
2. Mouse over the frame you wish to move and write it's name down
3. Mouse over the frame you wish to anchor something to and write it's name down
4. /run local a,b=FrameA,FrameB a:ClearAllPoints() a:SetPoint("TOPLEFT", b, "TOPLEFT", 0, 0)
You may have to play around a bit, the documentation of "SetPoint" is http://www.wowpedia.org/API_Region_SetPoint and it may help if you are stuck on what values for "TOPLEFT" there are and what the different stuff mean.

ok, I've got it semi worked out. Reloading my UI resets it obviously. Is there a way to set this in lua within the cooldown mod so I don't have to type this in/press a macro on every reload?

This is what I have right now
/run local a,b=vlakCooldownsAnchor,oUF_Raid a:ClearAllPoints() a:SetPoint("TOP", b, "TOP", 15, 70)


Code:

local anchor = CreateFrame("Frame", "vlakCooldownsAnchor", UIParent)
anchor:SetHeight(size)
anchor:SetPoint("BOTTOM", UIParent, "BOTTOM", xpos, ypos)

is the anchor code within VlakCooldowns. I tried using:
Code:

anchor:ClearAllPoints()
anchor:SetPoint("TOP", oUF_Raid, "TOP", 15, 70)

but thats not setting the anchor correctly for some reason

Duugu 10-25-10 10:25 AM

You could replace

Code:

if event == "SPELLS_CHANGED" or event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_TALENT_UPDATE" then
with

Code:

if event == "SPELLS_CHANGED" or event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_TALENT_UPDATE" then
_G["vlakCooldownsAnchor"]:ClearAllPoints()
_G["vlakCooldownsAnchor"]:SetPoint("TOP", _G["oUF_Raid"], "TOP", 15, 70)

in vlakCooldowns.lua

maltese 10-25-10 10:33 AM

works perfectly. Thanks :D

Vlad 10-25-10 02:53 PM

Also mate, this is the perfect time to bring this up: why not make yourself an addon for your private needs?

I myself got one that I use to add special functions and features, like moving frames around, anchoring, e.g. Problem by editing other addons is that when they get a new version you must remember to apply the modifications to the new version, it's a hard task if you wish to use an updater or if you don't know addon coding. Instead make your own addon that you do stuff like this in. Just a tip! ;)

maltese 10-26-10 07:21 AM

Ultimately that is the goal, but I'm in the process of learning lua right now (slow and steady process). I comment out the original lua and document what I change so I know exactly what I did so when it comes to update addons I can recreate what I have pretty effectively. I could upload "my" versions of the addons and keep them updated but it would basically be a 99.5% copy of others addons and I'd hate to get any credit for others hard work. :p

Vlad 10-26-10 05:30 PM

Don't worry about using other peoples work for your own private addon. :)

By the way one way you can do a "fix" for the position of vlakCooldowns is to make an addon and a lua file and in that file put this code (this is just a suggestion, there are far better ways of doing this, programing is like art).

lua Code:
  1. local addon = CreateFrame("Frame")
  2. addon.temp = {}
  3. addon:RegisterEvent("ADDON_LOADED")
  4. addon:SetScript("OnEvent", function(self, event, ...)
  5.   addon:HookVlak() -- will try hook each time an addon is loaded
  6. end)
  7. addon.HookVlak = function(self)
  8.   local a, b = vlakCooldownsAnchor, oUF_Raid
  9.   if self.temp.vlakHooked or not (a and b) then return end -- stop if hooked or frames do not exist yet
  10.   a:HookScript("OnShow", function(self) -- whne the frame is shown it automatically positions itself at oUF_Raid
  11.     self:ClearAllPoints()
  12.     self:SetPoint("TOP", b, "TOP", 15, 70)
  13.   end)
  14.   self.temp.vlakHooked = 1
  15. end


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

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