Quantcast Issues with SetPoint and a Few Other Questions - WoWInterface
Thread Tools Display Modes
06-08-19, 06:26 PM   #1
JDoubleU00
A Scalebane Royal Guard
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 410
Issues with SetPoint and a Few Other Questions

I'm working on a personal addon that will place addons listed in a table based on which addons are loaded and visible. SetPoint seems to be my kryptonite, as you can see, I have triedtwo ways to anchor the frames. No matter how hard I try to place them, they tend to overlap. What am I missing?


Lua Code:
  1. local name, mod = ...
  2. local peorder = {
  3.     {"JWXPBar","JWXPBarFrame",0,5},
  4.     {"JWRepBar","JWRepBarFrame",0,5},
  5.     {"BFAInvasionTimer","BFAInvasionTimer",0,25},
  6.     {"Skada","SkadaBarWindowSkada",0,25},
  7. }
  8. local pestartpoint = {"BOTTOMRIGHT","UIParent", "BOTTOMRIGHT",-10,30}
  9. local lt = {}
  10.  
  11. local function PlaceStuff()
  12.     for key, value in pairs(peorder) do
  13.       if IsAddOnLoaded(peorder[key][1]) and _G[peorder[key][2]]:IsVisible() then
  14.          table.insert(lt,peorder[key])
  15.       end
  16.    end
  17.    
  18.    for j, k in pairs(lt) do
  19.       _G[lt[j][2]]:SetMovable(true)
  20.       _G[lt[j][2]]:SetUserPlaced(true)
  21.       _G[lt[j][2]]:ClearAllPoints()
  22.       if j == 1 then
  23.          _G[lt[j][2]]:SetPoint(unpack(pestartpoint)) --first frame gets anchored to UIParent
  24.       else
  25.          --_G[lt[j][2]]:SetPoint("BOTTOM",_G[lt[j-1][2]],"TOP",lt[3],lt[4]) --look at the table entry for anchoring
  26.          _G[lt[j][2]]:SetPoint("BOTTOMLEFT",_G[lt[j-1][2]],"TOPLEFT",lt[3],lt[4])
  27.          _G[lt[j][2]]:SetPoint("BOTTOMRIGHT",_G[lt[j-1][2]],"TOPRIGHT",lt[3],lt[4])
  28.       end
  29.    end
  30. end
  31.  
  32. local PEF = CreateFrame("Frame", name, UIParent)
  33. PEF:RegisterEvent("PLAYER_ENTERING_WORLD")
  34. PEF:SetScript("OnEvent", PlaceStuff)

Is it OK to use _G to lookup the frames? I tried just using the name, but I wasn't successful.

Finally, maybe I am overthinking the design. I'm not sure if using two loops is the most efficient way, or creating a second table to correctly list the active and visible addons.

Thanks as always.
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote
06-08-19, 07:22 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,115
Code:
lt[j-1][2]
The lt table only has one entry per key so lt[j][2] and lt[j-1][2] is always nil (visually the same as using UIParent as the anchor for all frames). Just use _G[lt[j]] or _G[lt[j-1]]


Code:
_G[lt[j][2]]:SetPoint("BOTTOMLEFT",_G[lt[j-1][2]],"TOPLEFT",lt[3],lt[4])
lt[3], lt[4] are the third and fourth key in the lt table, frame name strings or nil depending. Did you mean
Code:
pestartpoint[4], pestartpoint[5] -- -10, 30
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 06-08-19 at 07:29 PM.
  Reply With Quote
06-08-19, 08:52 PM   #3
JDoubleU00
A Scalebane Royal Guard
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 410
Originally Posted by Fizzlemizz View Post
Code:
lt[j-1][2]
The lt table only has one entry per key so lt[j][2] and lt[j-1][2] is always nil (visually the same as using UIParent as the anchor for all frames). Just use _G[lt[j]] or _G[lt[j-1]]


Code:
_G[lt[j][2]]:SetPoint("BOTTOMLEFT",_G[lt[j-1][2]],"TOPLEFT",lt[3],lt[4])
lt[3], lt[4] are the third and fourth key in the lt table, frame name strings or nil depending. Did you mean
Code:
pestartpoint[4], pestartpoint[5] -- -10, 30
The lt table has four items per key. It will look just like peorder but only has the active addons listed. I tested that with this code:

Lua Code:
  1. local peorder = {
  2.    {"JWXPBar","JWXPBarFrame",0,5},
  3.    {"JWRepBar","JWRepBarFrame",0,5},
  4.    {"BFAInvasionTimer","BFAInvasionTimer",0,25},
  5.    {"Skada","SkadaBarWindowSkada",0,25},
  6. }
  7.  
  8. local lt = {}
  9.  
  10. for key, value in pairs(peorder) do
  11.    if IsAddOnLoaded(peorder[key][1]) and _G[peorder[key][2]]:IsVisible() then
  12.       table.insert(lt,peorder[key])
  13.    end
  14. end
  15.  
  16. for j, k in pairs(lt) do
  17.    print(lt[j][1]..","..lt[j][2]..","..lt[j][3]..","..lt[j][4])
  18. end

The second piece of each key is the frame name I use for anchoring (except for the first time where I use unpack(pestartpoint). The third and fourth pieces are the x and y offset. I went back to a single line for setpoint:

_G[lt[j][2]]:SetPoint("BOTTOM",_G[lt[j-1][2]],"TOP",lt[j][3],lt[j][4])

The code works without errors, but does not always place the addons where I think they should be. Sorry, my screen grabs are crappy looking. In this image, JWXPBars is not enabled.

Click image for larger version

Name:	peo.jpg
Views:	18
Size:	41.3 KB
ID:	9239
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote
06-08-19, 09:27 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,115
My bad, too much deciphering for a Sunday .

Have you checked the actual height of the frames you are anchoring. If a frame is taller than the visible components within it (if they are anchored to the top) then you will see a gap (you only anchor the bottom edge).

I don't know Skada (if it has an option for the bar count to "grow" upward might work).
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 06-08-19 at 09:44 PM.
  Reply With Quote
06-08-19, 09:40 PM   #5
JDoubleU00
A Scalebane Royal Guard
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 410
Originally Posted by Fizzlemizz View Post
My bad, too much deciphering for a Sunday .

Have you checked the actual height of the frames you are anchoring. If a frame is taller than the visible components within it (if they are anchored to the top) then you will see a gap (you only anchor the bottom edge).

I don't know Skada, I don't see an XPbar.
I'll let you return to decipherless Sunday. You should not have seen XPbar, it is not loaded. You've given me some food for thought about frame heights that I did not realize.
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Issues with SetPoint and a Few Other Questions

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off