Thread Tools Display Modes
08-15-22, 04:44 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Scrolling list of frames

Hi all

I want to have a scrolling frame that displays frames.

I have other scrolling lists of buttons and they work fine so I just thought I could repurpose it yet have not been able to get them working.

Here is the frame layout I want to build, it has 1 texture and 3 strings;


Here are the parent and child scroll frames;
Lua Code:
  1. local IronManInterfaceScrollParent =
  2.     CreateFrame("Frame", "IronManInterfaceScrollParent", IronManInterfaceFrame, "HelpFrameContainerFrameTemplate")
  3. IronManInterfaceScrollParent:SetSize(NumberList.achievementFrameWidth, 300)
  4. IronManInterfaceScrollParent:SetPoint("CENTER")
  5.  
  6. local IronManInterfaceScrollFrame = CreateFrame("ScrollFrame", "IronManInterfaceScrollFrame", IronManInterfaceScrollParent, "FauxScrollFrameTemplate")
  7. IronManInterfaceScrollFrame:SetPoint("TOPLEFT", 0, -8)
  8. IronManInterfaceScrollFrame:SetPoint("BOTTOMRIGHT", -30, 8)
  9. IronManInterfaceScrollFrame:SetScript(
  10.     "OnVerticalScroll",
  11.     function(self, offset)
  12.         FauxScrollFrame_OnVerticalScroll(self, offset, NumberList.scrollFrameNumber, updateAchievementList)
  13.     end
  14. )

Here is my update function;
Lua Code:
  1. local function updateAchievementList()
  2.     FauxScrollFrame_Update(
  3.         IronManInterfaceScrollFrame,
  4.         #IronManCompleatedAchievements,
  5.         NumberList.scrollButtonNumber,
  6.         NumberList.scrollButtonHeight
  7.     )
  8.     for index = 1, NumberList.scrollButtonNumber do
  9.         local offset = index + FauxScrollFrame_GetOffset(IronManInterfaceScrollFrame)
  10.         local frame = IronManInterfaceScrollFrame.frames[index]
  11.         frame.index = offset
  12.         if offset <= #IronManCompleatedAchievements then
  13.             frametexture:SetTexture(IronManCompleatedAchievements[offset].icon)
  14.             frametitleTextBoxtext:SetText(IronManCompleatedAchievements[offset].title)
  15.             frameNameTextBoxtext:SetText(IronManCompleatedAchievements[offset].char)
  16.             frameDateTextBoxtext:SetText(IronManCompleatedAchievements[offset].date)
  17.             frame:Show()
  18.         else
  19.             frame:Hide()
  20.         end
  21.     end
  22. end

Here is my list of scroll list of frame builders;
Lua Code:
  1. IronManInterfaceScrollFrame.frames = {}
  2. for index = 1, NumberList.scrollFrameNumber do
  3.     IronManInterfaceScrollFrame.frames[index] =
  4.         CreateFrame("Frame", "IMISF" .. index, IronManInterfaceScrollParent, "HelpFrameContainerFrameTemplate")
  5.     local frame = IronManInterfaceScrollFrame.frames[index]
  6.     frame:SetSize(NumberList.scrollframeWidth, NumberList.scrollFrameHeight)
  7.     frame:SetPoint("TOPLEFT", 8, -(index - 1) * NumberList.scrollFrameHeight - 8)
  8.  
  9.     frame.texture = frame:CreateTexture("frametexture")
  10.     frametexture:SetScale(NumberList.iconAchievementTextureScale)
  11.     frametexture:SetPoint("LEFT")
  12.  
  13.     frame.titleTextBox = CreateFrame("Frame", "frametitleTextBox", frame)
  14.     frametitleTextBox:SetSize(350, 30) -- debug --
  15.     frametitleTextBox:SetPoint("TOPRIGHT")
  16.  
  17.     frametitleTextBox.text = frametitleTextBox:CreateFontString("frametitleTextBoxtext")
  18.     frametitleTextBoxtext:SetAllPoints(frametitleTextBox)
  19.     frametitleTextBoxtext:SetFontObject(FontList.rulesFont)
  20.  
  21.     frameNameTextBox = CreateFrame("Frame", "frameNameTextBox", frame)
  22.     frameNameTextBox:SetSize(350, 30) -- debug --
  23.     frameNameTextBox:SetPoint("CENTER")
  24.  
  25.     frameNameTextBox.text = frameNameTextBox:CreateFontString("frameNameTextBoxtext")
  26.     frameNameTextBoxtext:SetAllPoints(frameNameTextBox)
  27.     frameNameTextBoxtext:SetFontObject(FontList.rulesFont)
  28.  
  29.     frameDateTextBox = CreateFrame("Frame", "frameDateTextBox", frame)
  30.     frameDateTextBox:SetSize(350, 30) -- debug --
  31.     frameDateTextBox:SetPoint("CENTER")
  32.  
  33.     frameDateTextBox.text = frameDateTextBox:CreateFontString("frameDateTextBoxtext")
  34.     frameDateTextBoxtext:SetAllPoints(frameDateTextBox)
  35.     frameDateTextBoxtext:SetFontObject(FontList.rulesFont)
  36. end

I am really at a loss here and I wonder if I am at the point of being just too close to the code that I can't see obvious errors.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz

Last edited by Walkerbo : 08-15-22 at 04:52 PM.
  Reply With Quote
08-15-22, 05:11 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
The third parameter of FauxScrollFrame_OnVerticalScroll should be the height of the individual "rows" in your list. In this case ( the height of the T section in your image), NumberList.scrollFrameHeight by the looks of it even though the name sounds a bit dodgy (NumberList.scrollFrameRowHeight would be more obvious).

You seem to be doing the same with the FauxScrollFrame_Update function.

The FauxScroll calculates scroll/thumb position based on the number of rows in your list, the height of a single row, the total entries in the source table and the height of the scrollbar (I thnk that's everything).

The Wiki Has a good description of what's what.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 08-15-22 at 05:16 PM.
  Reply With Quote
08-15-22, 07:26 PM   #3
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi Fizzlemizz

Great suggestion to rename the value to be more descriptive, it just makes it easier to read.

Thanks for the link, I have been through the guide a number of times but I cant see where I have funked it up.

When I try to run it in game I get this error;
Lua Code:
  1. 5x IronMan\IronMan-1.0.9.15.lua:1040: Usage: IMISF1:SetSize(width, height)
  2. [string "=[C]"]: in function `SetSize'
  3. [string "@IronMan\IronMan-1.0.9.15.lua"]:1040: in main chunk
  4.  
  5. Locals:
  6. (*temporary) = IMISF1 {
  7. 0 = <userdata>
  8. OnBackdropLoaded = <function> defined @Blizzard_Deprecated\Deprecated_9_1_5.lua:12
  9. GetBackdropColor = <function> defined @SharedXML\SharedTooltipTemplates.lua:191
  10. SetupTextureCoordinates = <function> defined @Blizzard_Deprecated\Deprecated_9_1_5.lua:16
  11. OnBackdropSizeChanged = <function> defined @Blizzard_Deprecated\Deprecated_9_1_5.lua:13
  12. HasBackdropInfo = <function> defined @Blizzard_Deprecated\Deprecated_9_1_5.lua:18
  13. SetBackdropBorderColor = <function> defined @SharedXML\SharedTooltipTemplates.lua:195
  14. GetEdgeSize = <function> defined @Blizzard_Deprecated\Deprecated_9_1_5.lua:14
  15. NineSlice = <unnamed> {
  16. }
  17. backdropColor = <table> {
  18. }
  19. ApplyBackdrop = <function> defined @Blizzard_Deprecated\Deprecated_9_1_5.lua:22
  20. TooltipBackdropOnLoad = <function> defined @SharedXML\SharedTooltipTemplates.lua:172
  21. ClearBackdrop = <function> defined @Blizzard_Deprecated\Deprecated_9_1_5.lua:34
  22. layoutType = "TooltipDefaultLayout"
  23. GetBackdropBorderColor = <function> defined @SharedXML\SharedTooltipTemplates.lua:199
  24. GetBackdrop = <function> defined @Blizzard_Deprecated\Deprecated_9_1_5.lua:19
  25. GetBackdropCoordValue = <function> defined @Blizzard_Deprecated\Deprecated_9_1_5.lua:15
  26. SetupPieceVisuals = <function> defined @Blizzard_Deprecated\Deprecated_9_1_5.lua:17
  27. SetBackdropColor = <function> defined @SharedXML\SharedTooltipTemplates.lua:187
  28. SetBackdrop = <function> defined @Blizzard_Deprecated\Deprecated_9_1_5.lua:27
  29. SetBorderBlendMode = <function> defined @SharedXML\SharedTooltipTemplates.lua:203
  30. }
  31. (*temporary) = nil
  32. (*temporary) = 88

So it tells me that the frame width is nil which just baffles me.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
08-15-22, 07:52 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Code:
frame:SetSize(NumberList.scrollframeWidth, NumberList.scrollFrameHeight)
Is this capitalization correct?
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 08-15-22 at 08:01 PM.
  Reply With Quote
08-15-22, 08:04 PM   #5
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi SDPhantom

That was it, I had the capitalisation was borked, that is why the error was thrown.

Now I just have to get the frames to display correctly, and then get them scrolling.

These 2 items I will work on now that I am past this hump.

Cheers
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
08-18-22, 06:47 PM   #6
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi all

Back again.

I have now hit another wall.

I can get frames displaying yet not correctly, each frame should have 3 text fields, yet only the top frame displays all 3 of the text fields, while each of the following only shows 2.

Here is what I am seeing;


I also have not been able to get the scroll working either.

Both of these issues do not throw any errors at all.

Any further help would be really apreciated.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
08-19-22, 12:23 AM   #7
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
What's the code you're calling in the OnVerticalScroll script?

That's where each row is updated with information from the source table using the offset + row number and you would show/hide any row elements. You would have to specifically show any hidden elements in a row which might be why you're getting the hidden one.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 08-19-22 at 12:27 AM.
  Reply With Quote
08-19-22, 12:28 AM   #8
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi Fizzlemizz

Sorry, here is the code;
Lua Code:
  1. local function updateAchievementList() -- debug -- move to function section once working
  2.     FauxScrollFrame_Update(
  3.         IronManInterfaceScrollFrame,
  4.         #IronManCompleatedAchievements,
  5.         NumberList.scrollButtonNumber,
  6.         NumberList.scrollFrameRowHeight
  7.     )
  8.     for index = 1, NumberList.scrollButtonNumber do
  9.         local offset = index + FauxScrollFrame_GetOffset(IronManInterfaceScrollFrame)
  10.         local frame = IronManInterfaceScrollFrame.frames[index]
  11.         frame.index = offset
  12.         if offset <= #IronManCompleatedAchievements then
  13.             frametexture:SetTexture(IronManCompleatedAchievements[offset].icon)
  14.             frametitleTextBoxtext:SetText(IronManCompleatedAchievements[offset].title)
  15.             frameNameTextBoxtext:SetText(IronManCompleatedAchievements[offset].char)
  16.             frameDateTextBoxtext:SetText(IronManCompleatedAchievements[offset].date)
  17.             frame:Show()
  18.         else
  19.             frame:Hide()
  20.         end
  21.     end
  22. end
  23.  
  24. local IronManInterfaceScrollParent =
  25.     CreateFrame("Frame", "IronManInterfaceScrollParent", IronManInterfaceFrame, "HelpFrameContainerFrameTemplate")
  26. IronManInterfaceScrollParent:SetSize(NumberList.scrollParentWidth, NumberList.scrollParentHeight)
  27. IronManInterfaceScrollParent:SetPoint(
  28.     "TOP",
  29.     IronManInterfaceFrame,
  30.     "TOP",
  31.     NumberList.scrollParentGapX,
  32.     NumberList.scrollParentTopGap
  33. )
  34.  
  35. local IronManInterfaceScrollFrame =
  36.     CreateFrame("ScrollFrame", "IronManInterfaceScrollFrame", IronManInterfaceScrollParent, "FauxScrollFrameTemplate")
  37. IronManInterfaceScrollFrame:SetPoint("TOPLEFT", 0, -8)
  38. IronManInterfaceScrollFrame:SetPoint("BOTTOMRIGHT", -30, 8)
  39. IronManInterfaceScrollFrame:SetScript(
  40.     "OnVerticalScroll",
  41.     function(self, offset)
  42.         FauxScrollFrame_OnVerticalScroll(self, offset, NumberList.scrollFrameRowHeight, updateAchievementList)
  43.     end
  44. )
  45.  
  46. IronManInterfaceScrollFrame.frames = {}
  47. for index = 1, NumberList.scrollFrameNumberOfFrames do
  48.     IronManInterfaceScrollFrame.frames[index] =
  49.         CreateFrame("Frame", "IMISF" .. index, IronManInterfaceScrollParent, "HelpFrameContainerFrameTemplate")
  50.     local frame = IronManInterfaceScrollFrame.frames[index]
  51.     frame:SetSize(NumberList.scrollFrameRowWidth, NumberList.scrollFrameRowHeight)
  52.     frame:SetPoint("TOPLEFT", 5, -(index - 1) * NumberList.scrollFrameRowHeight - 5)
  53.  
  54.     frame.texture = frame:CreateTexture("frametexture")
  55.     frametexture:SetScale(NumberList.iconAchievementTextureScale)
  56.     frametexture:SetPoint("LEFT")
  57.  
  58.     frame.titleTextBox = CreateFrame("Frame", "frametitleTextBox", frame, "HelpFrameContainerFrameTemplate")
  59.     frametitleTextBox:SetSize(NumberList.scrollAchievementTextBoxWidth, NumberList.scrollAchievementTextBoxHeight)
  60.     frametitleTextBox:SetPoint("TOPRIGHT")
  61.  
  62.     frametitleTextBox.text = frametitleTextBox:CreateFontString("frametitleTextBoxtext")
  63.     frametitleTextBoxtext:SetAllPoints(frametitleTextBox)
  64.     frametitleTextBoxtext:SetFontObject(FontList.rulesFont)
  65.  
  66.     frameNameTextBox = CreateFrame("Frame", "frameNameTextBox", frame, "HelpFrameContainerFrameTemplate")
  67.     frameNameTextBox:SetSize(NumberList.scrollAchievementTextBoxWidth, NumberList.scrollAchievementTextBoxHeight)
  68.     frameNameTextBox:SetPoint("RIGHT")
  69.  
  70.     frameNameTextBox.text = frameNameTextBox:CreateFontString("frameNameTextBoxtext")
  71.     frameNameTextBoxtext:SetAllPoints(frameNameTextBox)
  72.     frameNameTextBoxtext:SetFontObject(FontList.rulesFont)
  73.  
  74.     frameDateTextBox = CreateFrame("Frame", "frameDateTextBox", frame, "HelpFrameContainerFrameTemplate")
  75.     frameDateTextBox:SetSize(NumberList.scrollAchievementTextBoxWidth, NumberList.scrollAchievementTextBoxHeight)
  76.     frameDateTextBox:SetPoint("BOTTOMRIGHT")
  77.  
  78.     frameDateTextBox.text = frameDateTextBox:CreateFontString("frameDateTextBoxtext")
  79.     frameDateTextBoxtext:SetAllPoints(frameDateTextBox)
  80.     frameDateTextBoxtext:SetFontObject(FontList.rulesFont)
  81. end
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
08-19-22, 07:39 AM   #9
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Your row creation process is not doing what you think it is and and because of that, neither is the row assigment code in updateAchievementList(). That's part of what's messing things up. Also missing the updateAchievementList() call after the frame is created (assuming the source table is loaded at that stage??)

Each row should create unique elements with unique names (if you're using them) and you should add the sub-elements to each rows "main" frame. That's what you use in the update function when you get the offset entry in IronManCompleatedAchievements table that row (IronManInterfaceScrollFrame.frames[index]) corresonds to .

I think this should work based on the code you posted so long as the information in the NumberList table matches what I think it is (just guessing as that wasn't supplied but it's important to the FauxScrollFrame_Update function).
Lua Code:
  1. local function updateAchievementList() -- debug -- move to function section once working
  2.         local os = FauxScrollFrame_GetOffset(IronManInterfaceScrollFrame)
  3.         for index = 1, NumberList.scrollFrameNumberOfFrames do
  4.             local frame = IronManInterfaceScrollFrame.frames[index]
  5.             local offset = os + index
  6.             if offset <= #IronManCompleatedAchievements then
  7.                 local row = IronManInterfaceScrollFrame.frames[index]
  8.                 row.texture:SetTexture(IronManCompleatedAchievements[offset].icon)
  9.                 row.titleTextBox.text:SetText(IronManCompleatedAchievements[offset].title)
  10.                 row.frameNameTextBox.text:SetText(IronManCompleatedAchievements[offset].char)
  11.                 row.frameDateTextBox.text:SetText(IronManCompleatedAchievements[offset].date)
  12.                 row:Show()
  13.             else
  14.                 row:Hide()
  15.             end
  16.         end
  17.         FauxScrollFrame_Update(IronManInterfaceScrollFrame, #IronManCompleatedAchievements, NumberList.scrollFrameNumberOfFrames, NumberList.scrollFrameRowHeight);
  18.     end
  19.      
  20.     local IronManInterfaceScrollParent =
  21.         CreateFrame("Frame", "IronManInterfaceScrollParent", IronManInterfaceFrame, "HelpFrameContainerFrameTemplate")
  22.     IronManInterfaceScrollParent:SetSize(NumberList.scrollParentWidth, NumberList.scrollParentHeight)
  23.     IronManInterfaceScrollParent:SetPoint(
  24.         "TOP",
  25.         IronManInterfaceFrame,
  26.         "TOP",
  27.         NumberList.scrollParentGapX,
  28.         NumberList.scrollParentTopGap
  29.     )
  30.      
  31.     local IronManInterfaceScrollFrame =
  32.         CreateFrame("ScrollFrame", "IronManInterfaceScrollFrame", IronManInterfaceScrollParent, "FauxScrollFrameTemplate")
  33.     IronManInterfaceScrollFrame:SetPoint("TOPLEFT", 0, -8)
  34.     IronManInterfaceScrollFrame:SetPoint("BOTTOMRIGHT", -30, 8)
  35.     IronManInterfaceScrollFrame:SetScript(
  36.         "OnVerticalScroll",
  37.         function(self, offset)
  38.             FauxScrollFrame_OnVerticalScroll(self, offset, NumberList.scrollFrameRowHeight, updateAchievementList)
  39.         end
  40.     )
  41.      
  42.     IronManInterfaceScrollFrame.frames = {}
  43.     for index = 1, NumberList.scrollFrameNumberOfFrames do
  44.         IronManInterfaceScrollFrame.frames[index] =
  45.             CreateFrame("Frame", "IMISF" .. index, IronManInterfaceScrollParent, "HelpFrameContainerFrameTemplate")
  46.         local frame = IronManInterfaceScrollFrame.frames[index]
  47.         frame:SetSize(NumberList.scrollFrameRowWidth, NumberList.scrollFrameRowHeight)
  48.         frame:SetPoint("TOPLEFT", 5, -(index - 1) * NumberList.scrollFrameRowHeight - 5)
  49.      
  50.         frame.texture = frame:CreateTexture("frametexture"..index)
  51.         frame.texture:SetScale(NumberList.iconAchievementTextureScale)
  52.         frame.texture:SetPoint("LEFT")
  53.      
  54.         frame.titleTextBox = CreateFrame("Frame", "frametitleTextBox"..index, frame, "HelpFrameContainerFrameTemplate")
  55.         frame.titleTextBox:SetSize(NumberList.scrollAchievementTextBoxWidth, NumberList.scrollAchievementTextBoxHeight)
  56.         frame.titleTextBox:SetPoint("TOPRIGHT")
  57.      
  58.         frame.titleTextBox.text = frame.titleTextBox:CreateFontString("frametitleTextBoxtext"..index)
  59.         frame.titleTextBox.text:SetAllPoints(frame.titleTextBox)
  60.         frame.titleTextBox.text:SetFontObject(FontList.rulesFont)
  61.      
  62.         frame.frameNameTextBox = CreateFrame("Frame", "frameNameTextBox"..index, frame, "HelpFrameContainerFrameTemplate")
  63.         frame.frameNameTextBox:SetSize(NumberList.scrollAchievementTextBoxWidth, NumberList.scrollAchievementTextBoxHeight)
  64.         frame.frameNameTextBox:SetPoint("RIGHT")
  65.      
  66.         frame.frameNameTextBox.text = frame.frameNameTextBox:CreateFontString("frameNameTextBoxtext"..index)
  67.         frame.frameNameTextBox.text:SetAllPoints(frame.frameNameTextBox)
  68.         frame.frameNameTextBox.text:SetFontObject(FontList.rulesFont)
  69.      
  70.         frame.frameDateTextBox = CreateFrame("Frame", "frameDateTextBox"..index, frame, "HelpFrameContainerFrameTemplate")
  71.         frame.frameDateTextBox:SetSize(NumberList.scrollAchievementTextBoxWidth, NumberList.scrollAchievementTextBoxHeight)
  72.         frame.frameDateTextBox:SetPoint("BOTTOMRIGHT")
  73.      
  74.         frame.frameDateTextBox.text = frame.frameDateTextBox:CreateFontString("frameDateTextBoxtext"..index)
  75.         frame.frameDateTextBox.text:SetAllPoints(frame.frameDateTextBox)
  76.         frame.frameDateTextBox.text:SetFontObject(FontList.rulesFont)
  77.     end
  78.     updateAchievementList()
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 08-19-22 at 12:30 PM.
  Reply With Quote
08-19-22, 06:09 PM   #10
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi Fizzlemizz

Thanks for your code chunks.
When I do a comparison I can see the changes and together with your explanation I can see how those changes make sense, (though it scares me that I was so far off when it came to the indexing).

I now have a question about accessing the global table
Lua Code:
  1. IronManCompleatedAchievements

I can see the table and I can access it in-game but when it comes to the update function it is throwing the following error:
Lua Code:
  1. 1x IronMan\IronMan-1.0.9.15.lua:539: attempt to get length of global 'IronManCompleatedAchievements' (a nil value)
  2. [string "@IronMan\IronMan-1.0.9.15.lua"]:539: in function `updateAchievementList'
  3. [string "@IronMan\IronMan-1.0.9.15.lua"]:1272: in main chunk
  4.  
  5. Locals:
  6. (*temporary) = <function> defined @SharedXML\SecureUIPanelTemplates.lua:258
  7. (*temporary) = IronManInterfaceScrollFrame {
  8. 0 = <userdata>
  9. ScrollBar = IronManInterfaceScrollFrameScrollBar {
  10. }
  11. offset = 0
  12. frames = <table> {
  13. }
  14. ScrollChildFrame = IronManInterfaceScrollFrameScrollChildFrame {
  15. }
  16. }
  17. (*temporary) = nil
  18. (*temporary) = nil
  19. (*temporary) = nil
  20. (*temporary) = nil
  21. (*temporary) = nil
  22. (*temporary) = nil
  23. (*temporary) = nil
  24. (*temporary) = nil
  25. (*temporary) = nil
  26. (*temporary) = "attempt to get length of global 'IronManCompleatedAchievements' (a nil value)"
  27. NumberList = <table> {
  28. scrollFrameRowWidth = 355
  29. interfaceTextureScale = 0.550000
  30. achievementFramePositionY = 150
  31. scrollAchievementTextBoxHeight = 30
  32. selectionButtonHeight = 45
  33. failTextBoxWidth = 190
  34. scrollParentGapX = 10
  35. scrollParentTopGap = -135
  36. interfaceTextureBoxSize = 50
  37. iconTextureX = -11
  38. iconAchievementTextureScale = 0.250000
  39. scrollParentWidth = 390
  40. dateNameTextBoxWidth = 500
  41. maxJumps = 100
  42. scrollFrameRowHeight = 80
  43. maxDeaths = 100
  44. scrollParentHeight = 350
  45. interfaceTextureGap = -50
  46. titleTextBoxWidth = 350
  47. titleTextBoxTopGap = -10
  48. scrollFrameWidth = 330
  49. metaAchievementFramePositionGapY = -40
  50. titleTextBoxHeight = 80
  51. dateTextBoxBottomGap = 5
  52. textBoxSpacerLeft = 0
  53. textBoxHeight = 190
  54. buttonSpacerBottom = -20
  55. selectionFrameScale = 1.200000
  56. achievementCloseButtonY = -6
  57. bottomLeftTextureX = -200
  58. insetSize = 5
  59. textBoxSpacerTop = 0
  60. selectionButtonWidth = 190
  61. iconTextureY = 30
  62. failTextBoxSpacerLeft = 200
  63. maxLevel = 19
  64. failTextBoxHeight = 80
  65. scrollAchievementTextBoxWidth = 300
  66. achievementFrameWidth = 600
  67. nameTextBoxBottomGap = -5
  68. bottomRightTextureX = 200
  69. metaAchievementTopGap = -8
  70. edgeSize = 20
  71. maxPlayed = 100
  72. iconTextureScale = 0.450000
  73. textBoxWidth = 190
  74. selectionFramePositionY = 150
  75. maxFails = 100
  76. scrollFrameNumberOfFrames = 4
  77. failTextBoxSpacerTop = 40
  78. selectionFrameHeight = 200
  79. buttonSpacerLeft = 200
  80. buttonSpacerTop = 30
  81. dateNameTextBoxHeight = 40
  82. achievementCloseButtonX = -5
  83. achievementFrameHeight = 160
  84. selectionFrameWidth = 480
  85. }

Why is it that I can query it in game but it is not available for this function?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
08-19-22, 06:42 PM   #11
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
It hasn't been created when you login/scroll.

It is a table created by a Blizzard/3rd party LOD addon or some such?

The updateAchievementList() at the bottom of the code might be executing to early and should probabl be moved when you scroll frasme is shown of after the table is created.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 08-19-22 at 06:44 PM.
  Reply With Quote
08-19-22, 07:03 PM   #12
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
It is a global table that I create that holds information about a player's achievements.

The table is created when a player first uses my addon, and then is available from that point on.

I can write to it without issue.

I did move the function call to the PLAYER_LOGIN event as at that point all the variables should be loaded and available.

In previous addons, I have accessed a global table without issue and I am just stumped as to why it is not available here.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
08-19-22, 07:08 PM   #13
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
I have uploaded my code to Pastebin;

https://pastebin.com/mhdrK0ns
https://pastebin.com/5WYKbs9t
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
08-19-22, 07:48 PM   #14
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
The way it's written, updateAchievementList() call at line 610ish is being run before the table is created and needs to be moved.

If the table will be available when IronManInterfaceScrollParent is shown then move the updateAchievementList() to the IronManInterfaceScrollParent's OnShow script or when it's created. What ever happens after the table is initialised and before the scroll list is displayed.

It's just an call to initialise the srcoll list the first time, after that the OnVertical scroll will use updateAchievementList() to scroll the list.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 08-19-22 at 08:01 PM.
  Reply With Quote
08-19-22, 08:47 PM   #15
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
The problem was mainly the function being called before is was declared (plus there was a small bug in it)

This version doesn't complain on loading but I can't guarantee everythig is in the right place for it to work.

Pastebin
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
08-19-22, 08:59 PM   #16
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Great, the onShow worked and now I can see the frames for each achievement.

Now the issue I have is that the list of frames populates 4 frames by default, so when I have 0-3 entries 4 frames will be displayed with empty frames.

How do I only display frames for each entry?

IE, Table has no entries = no frames displayed
Table has 1 entry = one frame displayed.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
08-19-22, 09:28 PM   #17
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
The code I posted on PasteBun should work for that. That was the bug mention.

As the update function loops through the row list it tests if the source table has an entry for the offset of the row. If it does than the row should be filled and :Show().

If not the row:Hide() should stop it displaying (anything).

That could be changed to just clearing out the row settings (and if these are clickable) disabling the row which would require a corresponding enabe to replace the Show().
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
08-19-22, 09:37 PM   #18
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
The pastebin link does not show, is it set to private?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
08-19-22, 09:41 PM   #19
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Unlisted. Let's try again

I haven't tested because I don't know which buttons to push to get the scroll list to show.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
08-19-22, 09:42 PM   #20
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
I got it working by hiding the initial frame list
Lua Code:
  1. IronManInterfaceScrollFrame.frames = {}
  2. for index = 1, NumberList.scrollFrameNumberOfFrames do
  3.     IronManInterfaceScrollFrame.frames[index] =
  4.         CreateFrame("Frame", "IMISF" .. index, IronManInterfaceScrollParent, "HelpFrameContainerFrameTemplate")
  5.     local frame = IronManInterfaceScrollFrame.frames[index]
  6.     frame:SetSize(NumberList.scrollFrameRowWidth, NumberList.scrollFrameRowHeight)
  7.     frame:SetPoint("TOPLEFT", 5, -(index - 1) * NumberList.scrollFrameRowHeight - 5)
  8.     frame:Hide() -- hide the frame here
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Scrolling list of frames

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