Thread Tools Display Modes
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
01-27-23, 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
To start with, templates a passed as strings. Your frameList is empty because you're really defined it as

Lua Code:
  1. local frameList = {
  2.     [1] = nil,
  3.     [2] = nil,
  4.     [3] = nil,
  5.     [4] = nil,
  6.     [5] = nil,
  7.     [6] = nil,
  8.     -- etc.
  9. }

therefore
Code:
for k, v in pairs(frameList) do
does nothing.

I'm pretty sure you will get plenty of errors once the list contains something
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-27-23, 05:18 PM   #3
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Ah, I said it would be an obvious error.

I guarantee that I will have errors, many errors, but this is how I learn.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
01-27-23, 10:16 PM   #4
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Ok, got it going, yes there were so many bugs I pulled it apart and started again.
This time I got rid of the first static frame.
Lua Code:
  1. local frameList = {
  2.     "BaseBasicFrameTemplate",
  3.     "BasicFrameTemplate",
  4.     "BasicFrameTemplateWithInset",
  5.     "ButtonFrameTemplate",
  6.     "ButtonFrameTemplateMinimizable",
  7.     "ChatConfigBorderBoxTemplate",
  8.     "ChatConfigBoxTemplate",
  9.     "ChatConfigBoxWithHeaderTemplate",
  10.     "ChatConfigCheckBoxTemplate",
  11.     "CovenantListWideFrameTemplate",
  12.     "CovenantMissionBaseFrameTemplate",
  13.     "DefaultPanelTemplate",
  14.     "DefaultPanelTemplate",
  15.     "EtherealFrameTemplate",
  16.     "FloatingBorderedFrame",
  17.     "GarrisonMissionBaseFrameTemplate",
  18.     "GlowBorderTemplate",
  19.     "GlowBoxTemplate",
  20.     "HelpFrameContainerFrameTemplate",
  21.     "InsetFrameTemplate",
  22.     "InsetFrameTemplate2",
  23.     "InsetFrameTemplate3",
  24.     "InsetFrameTemplate4",
  25.     "KeyBindingFrameBindingButtonTemplate",
  26.     "KeyBindingFrameBindingButtonTemplateWithLabel",
  27.     "PortraitFrameTemplate",
  28.     "PortraitFrameTemplateMinimizable",
  29.     "PortraitFrameTemplateNoCloseButton",
  30.     "SimplePanelTemplate",
  31.     "ThinBorderTemplate",
  32.     "TooltipBorderedFrameTemplate",
  33.     "TranslucentFrameTemplate",
  34.     "UIPanelDialogTemplate",
  35.  }
  36.  
  37.  local width, height = 300, 150
  38.  local right, down, counter = 20, -20, 0
  39.  
  40.  for k, v in pairs(frameList) do
  41.     f = CreateFrame("Frame", "frame" .. k, UIParent, v)
  42.     f:SetSize(width, height)
  43.     f:SetPoint("TOPLEFT", right, down, counter)
  44.  
  45.     ftb = CreateFrame("Frame", "ftb", f)
  46.     ftb:SetSize(width, height / 2)
  47.     ftb:SetPoint("CENTER", "frame" .. k)
  48.  
  49.     ftbt = ftb:CreateFontString("ftbt")
  50.     ftbt:SetAllPoints(ftb)
  51.     ftbt:SetFontObject(FocusFontSmall)
  52.     ftbt:SetText(v)
  53.  
  54.     down = down - 160
  55.     counter = counter + 1
  56.  
  57.     if counter == 5 then
  58.        right = right + 310
  59.        down = -20
  60.        counter = 0
  61.     end
  62.  end
Here are the frames.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
01-28-23, 05:56 PM   #5
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Oh that looks neat
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Frame Factory

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