Thread: Frame Factory
View Single Post
01-27-23, 04:38 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Frame Factory

Hi all

I want to build a little frame factory; I am tired of building each fame template to see which frame I like for various addons; so I figure that I can use a factory to build and then screenshot the frames.

I have a static number 1 frame and I want the following frames using the static frame as the origin.

I want each frame to display its frame template name.

Here is an image of my desired out come.

Here is my code:
Lua Code:
  1. local frameList = {
  2.     UIDropDownCustomMenuEntryTemplate,
  3.     UIDropDownListTemplate,
  4.     UIDropDownMenuButtonTemplate,
  5.     UIDropDownMenuTemplate,
  6.     UIExpandingButtonTemplate,
  7.     UIGoldBorderButtonTemplate,
  8.     UIMenuButtonStretchTemplate,
  9.     UIMenuButtonTemplate,
  10.     UIMenuTemplate,
  11.     UIPanelBorderedButtonTemplate,
  12.     UIPanelButtonGrayTemplate,
  13.     UIPanelButtonNoTooltipResizeToFitTemplate,
  14.     UIPanelButtonNoTooltipTemplate,
  15.     UIPanelButtonTemplate,
  16.     UIPanelCloseButton,
  17.     UIPanelCloseButtonNoScripts,
  18.     UIPanelDialogTemplate,
  19.     UIPanelDynamicResizeButtonTemplate
  20. }
  21.  
  22. local right, down = 50, -50
  23. local width, height = 300, 150
  24. local frameNameTop, frameLast, frameCount = "staticTopFrame", "staticTopFrame", 2
  25.  
  26. local function layoutFrames()
  27.     for k, v in pairs(frameList) do
  28.         f = CreateFrame("Frame", "frame" .. k, UIParent, v)
  29.         f:SetSize(width, height)
  30.         f:SetPoint("TOPLEFT", frameLast, right, down)
  31.  
  32.         ftb = CreateFrame("Frame", "ftb", f)
  33.         ftb:SetSize(width, height / 2)
  34.         ftb:SetPoint("CENTER", frameLast)
  35.  
  36.         ftbt = ftb:CreateFontString("ftbt")
  37.         ftbt:SetAllPoints(ftb)
  38.         ftbt:SetFontObject(FocusFontSmall)
  39.         ftbt:SetText(v)
  40.  
  41.         frameLast = frameLast .. k
  42.         down = down - 310
  43.  
  44.         if k == 4 then
  45.             right = right + 310
  46.             down = -50
  47.             count = 1
  48.             frameNameTop = frameLast
  49.         elseif k == 1 then
  50.             frameNameTop = frameLast .. k
  51.             down = down - 160
  52.         else
  53.             frameLast = frameLast .. k
  54.             down = down - 160
  55.         end
  56.     end
  57. end
  58.  
  59. local staticTopFrame = CreateFrame("Frame", "staticTopFrame", UIParent, "UIPanelDialogTemplate")
  60. staticTopFrame:SetSize(width, height)
  61. staticTopFrame:SetPoint("TOPLEFT", right, down)
  62. staticTopFrame:EnableMouse(true)
  63. staticTopFrame:SetMovable(true)
  64. staticTopFrame:SetClampedToScreen(true)
  65. staticTopFrame:RegisterForDrag("RightButton", "LeftButton")
  66. staticTopFrame:SetScript("OnDragStart", staticTopFrame.StartMoving)
  67. staticTopFrame:SetScript("OnDragStop", staticTopFrame.StopMovingOrSizing)
  68.  
  69. staticTopFrameTextBox = CreateFrame("Frame", "staticTopFrameTextBox", staticTopFrame)
  70. staticTopFrameTextBox:SetSize(width, height / 2)
  71. staticTopFrameTextBox:SetPoint("CENTER", staticTopFrame)
  72.  
  73. staticTopFrameTextBoxText = staticTopFrameTextBox:CreateFontString(staticTopFrameTextBoxText)
  74. staticTopFrameTextBoxText:SetAllPoints(staticTopFrameTextBox)
  75. staticTopFrameTextBoxText:SetFontObject(FocusFontSmall)
  76. staticTopFrameTextBoxText:SetText("UIPanelDialogTemplate")
  77.  
  78. layoutFrames()

When I run it the static frame displays correctly yet nothing else displays and there are no errors.
I am using ReHack to run the code in game.

I have looked at button factories and have followed them without success.

There is obviously an error in my code yet I can't see it, maybe I am too close to the code that I can not see the error that I am making.

Any help would be greatly appreciated.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote