Thread Tools Display Modes
03-07-12, 09:10 AM   #21
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
How to do tabs like this!



--- my gui



Uploaded with ImageShack.us

LUA Code:
  1. local _G = _G -- import globals for faster usage
  2.  
  3. -- Create an function so we can give all the frames texts in a smart way!
  4.  
  5. function CreateOptions(self, TextTitle, DescriptionsText) -- CreateOptions(self, "Header Text", "Description Text")
  6.     local title = self:CreateFontString(nil, "OVERLAY")
  7.     title:SetFontObject('GameFontNormalLarge')
  8.     title:SetPoint('TOPLEFT', 16, -16)
  9.     title:SetText(TextTitle) -- Header Text
  10.    
  11.     local title2 = self:CreateFontString(nil, "OVERLAY")
  12.     title2:SetFontObject('GameFontHighlightSmall')
  13.     title2:SetPoint('TOPLEFT', 17, -37)
  14.     title2:SetText(DescriptionsText) -- Description Text.
  15. end
  16.  
  17. function CloseButton(self) -- CloseButton(self, id)
  18.     local closeButton = CreateFrame("CheckButton", "CheckBoxButton", self, "UIPanelCloseButton")
  19.     closeButton:SetSize(26, 26)
  20.     closeButton:SetPoint("TOPRIGHT", self)
  21.     closeButton:SetNormalTexture("")
  22.     closeButton:SetHighlightTexture("")
  23.     closeButton:SetPushedTexture("")
  24.     closeButton:SetDisabledTexture("")
  25.     closeButton:SetBackdrop({
  26.         bgFile = AftermathhUI.media.backdrop,
  27.         insets = {top = 1, left = 1, bottom = 1, right = 1},
  28.     })
  29.    
  30.     CreateBorderLight(closeButton, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, -3)
  31.  
  32.     local closeButtonfont = closeButton:CreateFontString(nil, "OVERLAY")
  33.     closeButtonfont:SetFont(AftermathhUI.media.font, 14, AftermathhUI.media.fontflag)
  34.     if AftermathhUI.media.shadowoffset == true then
  35.         closeButtonfont:SetShadowOffset(1, -1)
  36.         closeButtonfont:SetShadowColor(0, 0, 0)
  37.     end
  38.     closeButtonfont:SetPoint("CENTER", 1, 1)
  39.     closeButtonfont:SetText("x")
  40.  
  41.     closeButton:HookScript("OnEnter", function(self)
  42.         closeButtonfont:SetTextColor(1, 0, 0)
  43.         ColorBorder(closeButton, 1, 0, 0)
  44.     end)
  45.     closeButton:HookScript("OnLeave", function(self)
  46.         closeButtonfont:SetTextColor(1, 1, 1)
  47.         ColorBorder(closeButton, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor)
  48.     end)
  49. end
  50.  
  51. function Checkbox(self, selfid, px, py, description, SetChecked, OnClick) -- Checkbox(self, 1, 14, -55, "Description Text", SetChecked, OnClick)
  52.     local checkbox = CreateFrame("CheckButton", "CheckBoxButton" .. selfid, self, "OptionsSmallCheckButtonTemplate")
  53.     checkbox:SetPoint("TOPLEFT", self, px, py)
  54.     checkbox:SetScript("OnClick", OnClick)
  55.     checkbox:SetWidth(28)
  56.     checkbox:SetHeight(28)
  57.     checkbox:SetFrameStrata("HIGH")
  58.     checkbox:SetChecked(SetChecked)
  59.     checkbox:SetHitRectInsets(0, -60, 0, 0)
  60.     --checkbox:GetNormalTexture():SetAlpha(0.6)
  61.     checkbox:SetNormalTexture("")
  62.     checkbox:SetPushedTexture("")
  63.     checkbox:SetHighlightTexture("")
  64.     checkbox:SetBackdrop({
  65.         bgFile = AftermathhUI.media.backdrop,
  66.         insets = {top = 1, left = 1, bottom = 1, right = 1},
  67.     })
  68.  
  69.     CreateBorderLight(checkbox, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, -4)
  70.    
  71.     checkbox:HookScript("OnEnter", function(self)
  72.         ColorBorder(checkbox, 1.0, 0.82, 0)
  73.     end)
  74.    
  75.     checkbox:HookScript("OnLeave", function(self)
  76.         ColorBorder(checkbox, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor)
  77.     end)
  78.    
  79.     local checkboxtexture = checkbox:CreateTexture(nil, "ARTWORK")
  80.     checkboxtexture:SetWidth(25)
  81.     checkboxtexture:SetHeight(22)
  82.     checkboxtexture:SetAlpha(0.9)
  83.     checkboxtexture:SetPoint("LEFT", 2, 1)
  84.     checkboxtexture:SetTexture("Interface\\RAIDFRAME\\ReadyCheck-Ready")
  85.     checkbox:SetCheckedTexture(checkboxtexture)
  86.    
  87.     local checkboxtext = self:CreateFontString(nil, "ARTWORK", "GameFontNormal")
  88.     checkboxtext:SetPoint("LEFT", checkbox, "RIGHT", 5, 1)
  89.     checkboxtext:SetFontObject("GameFontNormal")
  90.     checkboxtext:SetTextColor(1, 1, 1)
  91.     checkboxtext:SetText(description)
  92. end
  93.  
  94. function ShowBuffs_OnClick()
  95.  
  96. end
  97.  
  98. ------------------------- MAIN -------------------------------------------------
  99.  
  100. local AftermathhUIFrame = CreateFrame("Frame", "AftermathhUIFrame", UIParent)
  101. AftermathhUIFrame:SetSize(800, 550)
  102. AftermathhUIFrame:SetFrameStrata("HIGH")
  103. AftermathhUIFrame:SetFrameLevel(25)
  104. AftermathhUIFrame:SetBackdrop({
  105.     bgFile = AftermathhUI.media.blank,
  106.     insets = {top = -1, left = -1, bottom = -1, right = -1},
  107. })
  108. AftermathhUIFrame:SetBackdropColor(unpack(AftermathhUI.media.backdropcolor))
  109. AftermathhUIFrame:Hide()
  110.  
  111. ----- Make it moveable! --------
  112.  
  113. AftermathhUIFrame:SetClampedToScreen(true)
  114. AftermathhUIFrame:SetMovable(true)
  115. AftermathhUIFrame:SetUserPlaced(true)
  116. AftermathhUIFrame:EnableMouse(true)
  117. AftermathhUIFrame:RegisterForDrag("LeftButton")
  118. AftermathhUIFrame:SetHitRectInsets(-15, -15, -5, -5)
  119.  
  120. AftermathhUIFrame:ClearAllPoints()
  121. AftermathhUIFrame.ClearAllPoints = function() end
  122. AftermathhUIFrame:SetPoint("CENTER", UIParent)
  123. AftermathhUIFrame.SetPoint = function() end
  124.  
  125. AftermathhUIFrame:SetScript("OnDragStart", function(self)
  126.     AftermathhUIFrame:StartMoving()
  127. end)
  128.  
  129. AftermathhUIFrame:SetScript("OnDragStop", function(self)
  130.     AftermathhUIFrame:StopMovingOrSizing()
  131. end)
  132.  
  133. -----------------------
  134.  
  135. CreateOptions(AftermathhUIFrame, "AftermathhUI_GUI", "Welcome to AftermathhUI_GUI. Here you can find most of the options that are needed!")
  136.  
  137. CloseButton(AftermathhUIFrame)
  138.  
  139. CreateBorderLight(AftermathhUIFrame, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 2)
  140.  
  141. Checkbox(AftermathhUIFrame, 1, 14, -95, "Show PvP Icon.", AftermathhUI.ouf.showpvpicon)
  142. Checkbox(AftermathhUIFrame, 2, 14, -115, "Show Buffs.", AftermathhUI.ouf.showbuffs, ShowBuffs_OnClick)
  143. Checkbox(AftermathhUIFrame, 3, 14, -135, "Show Debuffs.", AftermathhUI.ouf.showdebuffs)
  144. Checkbox(AftermathhUIFrame, 4, 14, -155, "Only Show Player Debuffs.", AftermathhUI.ouf.onlyshowplayerdebuffs)
  145. Checkbox(AftermathhUIFrame, 5, 14, -175, "Show Aggroo.", AftermathhUI.ouf.showaggroo)
  146. Checkbox(AftermathhUIFrame, 6, 14, -195, "Show Debuff Highlight", AftermathhUI.ouf.showdebuffhighlight)
  147. Checkbox(AftermathhUIFrame, 7, 14, -215, "Tooltip On Mouseover (Player etc).", AftermathhUI.ouf.tooltiponouf)
  148. Checkbox(AftermathhUIFrame, 8, 14, -235, "Show Role Icon.", AftermathhUI.ouf.showroleicon)
  149. Checkbox(AftermathhUIFrame, 9, 14, -255, "Show Boss Frames.", AftermathhUI.ouf.bossframes)
  150. Checkbox(AftermathhUIFrame, 10, 14, -275, "Show Party Frames.", AftermathhUI.ouf.showparty)
  151. Checkbox(AftermathhUIFrame, 11, 14, -295, "Tooltip On Mouseover (Raidframes).", AftermathhUI.ouf.tooltiponraid)
  152. Checkbox(AftermathhUIFrame, 12, 14, -315, "Highlight On Mouseover (Raidframes).", AftermathhUI.ouf.highlightontarget)
  153. Checkbox(AftermathhUIFrame, 13, 14, -335, "Make Raid Frames Vertical.", AftermathhUI.ouf.raidframesvertical)
  154. Checkbox(AftermathhUIFrame, 14, 14, -355, "Aura Watch (Raidframes).", AftermathhUI.ouf.aurawatch)
  155. Checkbox(AftermathhUIFrame, 15, 14, -375, "Raid Debuffs.", AftermathhUI.ouf.raiddebuffs)
  156. Checkbox(AftermathhUIFrame, 16, 14, -395, "Show Aggro On Raidframes.", AftermathhUI.ouf.showaggroonraidframes)
  157. Checkbox(AftermathhUIFrame, 17, 14, -415, "Experiance Bar.", AftermathhUI.ouf.expbar)
  158. Checkbox(AftermathhUIFrame, 18, 14, -435, "Reputation Bar.", AftermathhUI.ouf.repbar)
  159. Checkbox(AftermathhUIFrame, 19, 14, -455, "Moveable Frames.", AftermathhUI.ouf.moveableframes)
  160. Checkbox(AftermathhUIFrame, 20, 14, -475, "Totembar from oUF.", AftermathhUI.ouf.totembar)
  161. Checkbox(AftermathhUIFrame, 21, 14, -495, "Heal Prediction.", AftermathhUI.ouf.healprediction)
  162. Checkbox(AftermathhUIFrame, 22, 14, -515, "Combat Feedback.", AftermathhUI.ouf.combatfeedback)
  163.  
  164. --- Coulum 2
  165.  
  166. Checkbox(AftermathhUIFrame, 23, 350, -95, "Classcolor on Castbar.", AftermathhUI.ouf.castbarclasscolor)
  167. Checkbox(AftermathhUIFrame, 24, 350, -115, "Show Safe Zone.", AftermathhUI.ouf.showsafezone)
  168. Checkbox(AftermathhUIFrame, 25, 350, -135, "Show Latency.", AftermathhUI.ouf.showlatency)
  169. Checkbox(AftermathhUIFrame, 26, 350, -155, "Target Castbar Icon.", AftermathhUI.ouf.targetcastbaricon)
  170. Checkbox(AftermathhUIFrame, 27, 350, -175, "Focus Castbar Icon.", AftermathhUI.ouf.focuscastbaricon)
  171. Checkbox(AftermathhUIFrame, 28, 350, -195, "Show Interrupt Highlight.", AftermathhUI.ouf.showinterrupthighlight)
  172.  
  173. local function AftermathhUIFrameOnEnter(self, fontsub)
  174.     self:HookScript("OnEnter", function(self)
  175.         ColorBorder(self, 1.0, 0.82, 0)
  176.     end)
  177.     self:HookScript("OnLeave", function(self)
  178.         ColorBorder(self, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor)
  179.     end)
  180. end
  181.  
  182. -------------------- SUB 1 ------------------------------------------
  183.  
  184. local AftermathhUIFrameSub1 = CreateFrame("Button", nil, AftermathhUIFrame)
  185. AftermathhUIFrameSub1:SetSize(73, 20)
  186. AftermathhUIFrameSub1:SetFrameStrata("HIGH")
  187. AftermathhUIFrameSub1:SetFrameLevel(26)
  188. AftermathhUIFrameSub1:SetBackdrop({
  189.     bgFile = AftermathhUI.media.texture2,
  190.     --insets = {top = -1, left = -1, bottom = -1, right = -1},
  191. })
  192. AftermathhUIFrameSub1:SetBackdropColor(.40, .40, .40, 1)
  193. AftermathhUIFrameSub1:SetPoint("TOPLEFT", AftermathhUIFrame, 19, -65)
  194. AftermathhUIFrameSub1:Hide()
  195.  
  196. CreateBorderLight(AftermathhUIFrameSub1, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 1)
  197.  
  198. AftermathhUIFrameOnEnter(AftermathhUIFrameSub1)
  199.  
  200. local AftermathhUIFrameSub1Font = AftermathhUIFrameSub1:CreateFontString(nil, "OVERLAY")
  201. AftermathhUIFrameSub1Font:SetFontObject('GameFontHighlightSmall')
  202. AftermathhUIFrameSub1Font:SetText("Unitframes")
  203. AftermathhUIFrameSub1Font:SetTextColor(1.0, 0.82, 0)
  204. AftermathhUIFrameSub1Font:SetPoint("CENTER")
  205.  
  206. ----------------------------- SUB 2 -------------------------------------
  207.  
  208. local AftermathhUIFrameSub2 = CreateFrame("Button", nil, AftermathhUIFrame)
  209. AftermathhUIFrameSub2:SetSize(73, 20)
  210. AftermathhUIFrameSub2:SetFrameStrata("HIGH")
  211. AftermathhUIFrameSub2:SetFrameLevel(26)
  212. AftermathhUIFrameSub2:SetBackdrop({
  213.     bgFile = AftermathhUI.media.texture2,
  214.     --insets = {top = -1, left = -1, bottom = -1, right = -1},
  215. })
  216. AftermathhUIFrameSub2:SetBackdropColor(.40, .40, .40, 1)
  217. AftermathhUIFrameSub2:SetPoint("TOPLEFT", AftermathhUIFrame, 97, -65)
  218. AftermathhUIFrameSub2:Hide()
  219.  
  220. CreateBorderLight(AftermathhUIFrameSub2, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 1)
  221.  
  222. AftermathhUIFrameOnEnter(AftermathhUIFrameSub2)
  223.  
  224. local AftermathhUIFrameSub2Font = AftermathhUIFrameSub2:CreateFontString(nil, "OVERLAY")
  225. AftermathhUIFrameSub2Font:SetFontObject('GameFontHighlightSmall')
  226. AftermathhUIFrameSub2Font:SetText("Buffs")
  227. AftermathhUIFrameSub2Font:SetTextColor(1.0, 0.82, 0)
  228. AftermathhUIFrameSub2Font:SetPoint("CENTER")
  229.  
  230. -------------------- SUB 3 -------------------------------------------------
  231.  
  232. local AftermathhUIFrameSub3 = CreateFrame("Button", nil, AftermathhUIFrame)
  233. AftermathhUIFrameSub3:SetSize(73, 20)
  234. AftermathhUIFrameSub3:SetFrameStrata("HIGH")
  235. AftermathhUIFrameSub3:SetFrameLevel(26)
  236. AftermathhUIFrameSub3:SetBackdrop({
  237.     bgFile = AftermathhUI.media.texture2,
  238.     --insets = {top = -1, left = -1, bottom = -1, right = -1},
  239. })
  240. AftermathhUIFrameSub3:SetBackdropColor(.40, .40, .40, 1)
  241. AftermathhUIFrameSub3:SetPoint("TOPLEFT", AftermathhUIFrame, 175, -65)
  242. AftermathhUIFrameSub3:Hide()
  243.  
  244. CreateBorderLight(AftermathhUIFrameSub3, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 1)
  245.  
  246. AftermathhUIFrameOnEnter(AftermathhUIFrameSub3)
  247.  
  248. local AftermathhUIFrameSub3Font = AftermathhUIFrameSub3:CreateFontString(nil, "OVERLAY")
  249. AftermathhUIFrameSub3Font:SetFontObject('GameFontHighlightSmall')
  250. AftermathhUIFrameSub3Font:SetText("Chat")
  251. AftermathhUIFrameSub3Font:SetTextColor(1.0, 0.82, 0)
  252. AftermathhUIFrameSub3Font:SetPoint("CENTER")
  253.  
  254.  
  255. -------------------------------------------------------------------------------------------
  256.  
  257. SlashCmdList['OPENAFTERMATHHUI'] = function()
  258.     --InterfaceOptionsFrame_OpenToCategory(AftermathhUI.panel)
  259.     AftermathhUIFrame:Show()
  260.     AftermathhUIFrameSub1:Show()
  261.     AftermathhUIFrameSub2:Show()
  262.     AftermathhUIFrameSub3:Show()
  263.    
  264. end
  265. SLASH_OPENAFTERMATHHUI1 = '/after'
  266. SLASH_OPENAFTERMATHHUI2 = '/aftermathhui'
  267.  
  268. SlashCmdList['CLOSEAFTERMATHHUI'] = function()
  269.     --InterfaceOptionsFrame_OpenToCategory(AftermathhUI.panel)
  270.     AftermathhUIFrame:Hide()
  271.     AftermathhUIFrameSub1:Hide()
  272.     AftermathhUIFrameSub2:Hide()
  273.     AftermathhUIFrameSub3:Hide()
  274. end
  275. SLASH_CLOSEAFTERMATHHUI1 = '/afterclose'
  Reply With Quote
03-07-12, 10:57 AM   #22
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Those tabs are only possible when you use the default Addons config panel. You could of course make buttons yourself and have them show different content in the window (preferably in a different frame) to replicate them.
  Reply With Quote
03-07-12, 11:10 AM   #23
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Haleth View Post
Those tabs are only possible when you use the default Addons config panel. You could of course make buttons yourself and have them show different content in the window (preferably in a different frame) to replicate them.
Okey. I know Tukui has almost the same in his config




This is what i'm thinking of

Last edited by Aftermathhqt : 03-07-12 at 11:23 AM.
  Reply With Quote
03-07-12, 11:28 AM   #24
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
I suppose those are frames with a modified panel button template or just a simple OnClick, shouldn't be too hard to make.
  Reply With Quote
03-07-12, 11:50 AM   #25
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Haleth View Post
I suppose those are frames with a modified panel button template or just a simple OnClick, shouldn't be too hard to make.
Hmm i tried OnClick but didn't work out very good.
  Reply With Quote
03-07-12, 03:28 PM   #26
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
If you really want your options UI to be a separate window, apart from the regular Interface Options window, make sure you still add a panel to the regular window that has a button to open your addon's standalone options UI. Users nowadays expect options for addons to be in the Interface Options window, and are likely to get confused and/or post a comment about "the options are broken" rather than reading the addon's description to find the slash command they have to type to open the options.
  Reply With Quote
03-07-12, 04:52 PM   #27
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Phanx View Post
If you really want your options UI to be a separate window, apart from the regular Interface Options window, make sure you still add a panel to the regular window that has a button to open your addon's standalone options UI. Users nowadays expect options for addons to be in the Interface Options window, and are likely to get confused and/or post a comment about "the options are broken" rather than reading the addon's description to find the slash command they have to type to open the options.
true dat :P

And i made this instead ^^


Last edited by Aftermathhqt : 03-08-12 at 10:09 AM.
  Reply With Quote
03-08-12, 05:40 AM   #28
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Came up with somthing about the OnClick.

But it does't work for the other buttons the: AftermathhUIFrameSub2:ButtonClicked() Cause i have no idea what it should be named.

And also if you press on the button twice it spawns more check buttons.

LUA Code:
  1. AftermathhUIFrameSub1:SetScript("OnClick", function()
  2.  
  3. Checkbox(AftermathhUIFrame, 1, 14, -95, "Show PvP Icon.", AftermathhUI.ouf.showpvpicon)
  4. Checkbox(AftermathhUIFrame, 2, 14, -115, "Show Buffs.", AftermathhUI.ouf.showbuffs, ShowBuffs_OnClick)
  5. Checkbox(AftermathhUIFrame, 3, 14, -135, "Show Debuffs.", AftermathhUI.ouf.showdebuffs)
  6. Checkbox(AftermathhUIFrame, 4, 14, -155, "Only Show Player Debuffs.", AftermathhUI.ouf.onlyshowplayerdebuffs)
  7. Checkbox(AftermathhUIFrame, 5, 14, -175, "Show Aggroo.", AftermathhUI.ouf.showaggroo)
  8. Checkbox(AftermathhUIFrame, 6, 14, -195, "Show Debuff Highlight", AftermathhUI.ouf.showdebuffhighlight)
  9. Checkbox(AftermathhUIFrame, 7, 14, -215, "Tooltip On Mouseover (Player etc).", AftermathhUI.ouf.tooltiponouf)
  10. Checkbox(AftermathhUIFrame, 8, 14, -235, "Show Role Icon.", AftermathhUI.ouf.showroleicon)
  11. Checkbox(AftermathhUIFrame, 9, 14, -255, "Show Boss Frames.", AftermathhUI.ouf.bossframes)
  12. Checkbox(AftermathhUIFrame, 10, 14, -275, "Show Party Frames.", AftermathhUI.ouf.showparty)
  13. Checkbox(AftermathhUIFrame, 11, 14, -295, "Tooltip On Mouseover (Raidframes).", AftermathhUI.ouf.tooltiponraid)
  14. Checkbox(AftermathhUIFrame, 12, 14, -315, "Highlight On Mouseover (Raidframes).", AftermathhUI.ouf.highlightontarget)
  15. Checkbox(AftermathhUIFrame, 13, 14, -335, "Make Raid Frames Vertical.", AftermathhUI.ouf.raidframesvertical)
  16. Checkbox(AftermathhUIFrame, 14, 14, -355, "Aura Watch (Raidframes).", AftermathhUI.ouf.aurawatch)
  17. Checkbox(AftermathhUIFrame, 15, 14, -375, "Raid Debuffs.", AftermathhUI.ouf.raiddebuffs)
  18. Checkbox(AftermathhUIFrame, 16, 14, -395, "Show Aggro On Raidframes.", AftermathhUI.ouf.showaggroonraidframes)
  19. Checkbox(AftermathhUIFrame, 17, 14, -415, "Experiance Bar.", AftermathhUI.ouf.expbar)
  20. Checkbox(AftermathhUIFrame, 18, 14, -435, "Reputation Bar.", AftermathhUI.ouf.repbar)
  21. Checkbox(AftermathhUIFrame, 19, 14, -455, "Moveable Frames.", AftermathhUI.ouf.moveableframes)
  22. Checkbox(AftermathhUIFrame, 20, 14, -475, "Totembar from oUF.", AftermathhUI.ouf.totembar)
  23. Checkbox(AftermathhUIFrame, 21, 14, -495, "Heal Prediction.", AftermathhUI.ouf.healprediction)
  24. Checkbox(AftermathhUIFrame, 22, 14, -515, "Combat Feedback.", AftermathhUI.ouf.combatfeedback)
  25.  
  26. --- Coulum 2
  27.  
  28. Checkbox(AftermathhUIFrame, 23, 350, -95, "Classcolor on Castbar.", AftermathhUI.ouf.castbarclasscolor)
  29. Checkbox(AftermathhUIFrame, 24, 350, -115, "Show Safe Zone.", AftermathhUI.ouf.showsafezone)
  30. Checkbox(AftermathhUIFrame, 25, 350, -135, "Show Latency.", AftermathhUI.ouf.showlatency)
  31. Checkbox(AftermathhUIFrame, 26, 350, -155, "Target Castbar Icon.", AftermathhUI.ouf.targetcastbaricon)
  32. Checkbox(AftermathhUIFrame, 27, 350, -175, "Focus Castbar Icon.", AftermathhUI.ouf.focuscastbaricon)
  33. Checkbox(AftermathhUIFrame, 28, 350, -195, "Show Interrupt Highlight.", AftermathhUI.ouf.showinterrupthighlight)
  34.  
  35.     for i = 1, 28 do
  36.         if not AftermathhUIFrameSub2:ButtonClicked() or AftermathhUIFrameSub3:ButtonClicked() then
  37.             _G["AfterCheckBoxButton"..i]:Show()
  38.         else
  39.             _G["AfterCheckBoxButton"..i]:Hide()
  40.         end
  41.     end
  42. end)
  Reply With Quote
03-08-12, 07:45 PM   #29
kaels
A Cyclonian
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 46
I'm no pro at this, but I would do is something more like this:

lua Code:
  1. local function CreateCheckboxes(subframe)
  2.     local boxes = AftermathUIFrame.checkboxes or {}
  3.    
  4.     if subframe == 1 then
  5.         boxes[1] = Checkbox(AftermathhUIFrame, 1, 14, -95, "Show PvP Icon.", AftermathhUI.ouf.showpvpicon)
  6.         boxes[2] = Checkbox(AftermathhUIFrame, 2, 14, -115, "Show Buffs.", AftermathhUI.ouf.showbuffs, ShowBuffs_OnClick)
  7.         boxes[3] = Checkbox(AftermathhUIFrame, 3, 14, -135, "Show Debuffs.", AftermathhUI.ouf.showdebuffs)
  8.         -- and so on
  9.     elseif subframe == 2 then
  10.         boxes[1] = Checkbox(whatever)
  11.     elseif
  12.     else
  13.     end
  14.     for i = i, #boxes do
  15.         boxes[i]:Show()
  16.     end
  17.     AftermathUIFrame.checkboxes = checkboxes
  18. end
  19.  
  20. local function ReleaseCheckboxes()
  21.     local boxes = AftermathUIFrame.checkboxes
  22.     local bin = AftermathUIFrame.recyclebin or {}
  23.    
  24.     for i = 1, #boxes do
  25.         boxes[i]:Hide()
  26.         table.insert(bin, boxes[i])
  27.         boxes[i] = nil
  28.     end
  29. end
  30.  
  31. local function DisplayCheckboxes(subframe)
  32.     ReleaseCheckboxes()
  33.     CreateCheckboxes(subframe)
  34. end
  35.  
  36. AftermathhUIFrameSub1:SetScript("OnClick", DisplayCheckboxes(1))

That lets you keep track of the buttons you've created, recycle them when the user switches tabs so you don't just keep making new buttons, and you can reuse the same code for your other subframes, just adding their button configuration options to the creation function.

You would have to set up your Checkbox function to try to pull old buttons out of the recycle bin before creating new ones and to return the CheckButton object.

Last edited by kaels : 03-08-12 at 08:00 PM.
  Reply With Quote
03-09-12, 06:08 AM   #30
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Recycling config widgets is more trouble than it's worth, IMO. A checkbox does not require that much memory in the first place, and it's all static, so unless the user's machine is struggling to run WoW at all, having 10, 100, or even 1000 checkboxes won't have any observable performance impact. Even if you can "gain" a few KB of memory by reusing everything all the time, the user won't ever notice any benefit, and you'll just have made your code more complex (and thus more of a pain to modify and debug later) for no reason other than your own desire to micro-optimize everything.

Remember...
The First Rule of Program Optimization: Don't do it.
The Second Rule of Program Optimization (for experts only!): Don't do it yet.
  Reply With Quote
03-09-12, 06:11 AM   #31
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by kaels View Post
I'm no pro at this, but I would do is something more like this:

lua Code:
  1. local function CreateCheckboxes(subframe)
  2.     local boxes = AftermathUIFrame.checkboxes or {}
  3.    
  4.     if subframe == 1 then
  5.         boxes[1] = Checkbox(AftermathhUIFrame, 1, 14, -95, "Show PvP Icon.", AftermathhUI.ouf.showpvpicon)
  6.         boxes[2] = Checkbox(AftermathhUIFrame, 2, 14, -115, "Show Buffs.", AftermathhUI.ouf.showbuffs, ShowBuffs_OnClick)
  7.         boxes[3] = Checkbox(AftermathhUIFrame, 3, 14, -135, "Show Debuffs.", AftermathhUI.ouf.showdebuffs)
  8.         -- and so on
  9.     elseif subframe == 2 then
  10.         boxes[1] = Checkbox(whatever)
  11.     elseif
  12.     else
  13.     end
  14.     for i = i, #boxes do
  15.         boxes[i]:Show()
  16.     end
  17.     AftermathUIFrame.checkboxes = checkboxes
  18. end
  19.  
  20. local function ReleaseCheckboxes()
  21.     local boxes = AftermathUIFrame.checkboxes
  22.     local bin = AftermathUIFrame.recyclebin or {}
  23.    
  24.     for i = 1, #boxes do
  25.         boxes[i]:Hide()
  26.         table.insert(bin, boxes[i])
  27.         boxes[i] = nil
  28.     end
  29. end
  30.  
  31. local function DisplayCheckboxes(subframe)
  32.     ReleaseCheckboxes()
  33.     CreateCheckboxes(subframe)
  34. end
  35.  
  36. AftermathhUIFrameSub1:SetScript("OnClick", DisplayCheckboxes(1))

That lets you keep track of the buttons you've created, recycle them when the user switches tabs so you don't just keep making new buttons, and you can reuse the same code for your other subframes, just adding their button configuration options to the creation function.

You would have to set up your Checkbox function to try to pull old buttons out of the recycle bin before creating new ones and to return the CheckButton object.
Hello thanks for this!

Doh i got some errors



Message: ...terface\AddOns\AftermathhUI_GUI\AftermathhUI_GUI.lua:282: attempt to get length of global 'boxes' (a nil value)
Time: 03/09/12 13:07:53
Count: 1
Stack: ...terface\AddOns\AftermathhUI_GUI\AftermathhUI_GUI.lua:282: in function <...terface\AddOns\AftermathhUI_GUI\AftermathhUI_GUI.lua:278>
...terface\AddOns\AftermathhUI_GUI\AftermathhUI_GUI.lua:290: in function `DisplayCheckboxes'
...terface\AddOns\AftermathhUI_GUI\AftermathhUI_GUI.lua:294: in main chunk

Locals: bin = <table> {
}
(*temporary) = 1
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = "attempt to get length of global 'boxes' (a nil value)"




LUA Code:
  1. local _G = _G -- import globals for faster usage
  2.  
  3. -- Create an function so we can give all the frames texts in a smart way!
  4.  
  5. function CreateOptions(self, TextTitle, DescriptionsText) -- CreateOptions(self, "Header Text", "Description Text")
  6.     local title = self:CreateFontString(nil, "OVERLAY")
  7.     title:SetFontObject('GameFontNormalLarge')
  8.     title:SetPoint('TOPLEFT', 16, -16)
  9.     title:SetText(TextTitle) -- Header Text
  10.    
  11.     local title2 = self:CreateFontString(nil, "OVERLAY")
  12.     title2:SetFontObject('GameFontHighlightSmall')
  13.     title2:SetPoint('TOPLEFT', 17, -37)
  14.     title2:SetText(DescriptionsText) -- Description Text.
  15. end
  16.  
  17. function CloseButton(self) -- CloseButton(self, id)
  18.     local closeButton = CreateFrame("CheckButton", "CheckBoxButton", self, "UIPanelCloseButton")
  19.     closeButton:SetSize(26, 26)
  20.     closeButton:SetPoint("TOPRIGHT", self)
  21.     closeButton:SetNormalTexture("")
  22.     closeButton:SetHighlightTexture("")
  23.     closeButton:SetPushedTexture("")
  24.     closeButton:SetDisabledTexture("")
  25.     closeButton:SetBackdrop({
  26.         bgFile = AftermathhUI.media.backdrop,
  27.         insets = {top = 1, left = 1, bottom = 1, right = 1},
  28.     })
  29.    
  30.     CreateBorderLight(closeButton, AftermathhUI.media.bordersize-1, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, -2)
  31.  
  32.     local closeButtonfont = closeButton:CreateFontString(nil, "OVERLAY")
  33.     closeButtonfont:SetFont(AftermathhUI.media.font, 14, AftermathhUI.media.fontflag)
  34.     if AftermathhUI.media.shadowoffset == true then
  35.         closeButtonfont:SetShadowOffset(1, -1)
  36.         closeButtonfont:SetShadowColor(0, 0, 0)
  37.     end
  38.     closeButtonfont:SetPoint("CENTER", 1, 1)
  39.     closeButtonfont:SetText("x")
  40.  
  41.     closeButton:HookScript("OnEnter", function(self)
  42.         closeButtonfont:SetTextColor(1, 0, 0)
  43.         ColorBorder(closeButton, 1, 0, 0)
  44.     end)
  45.     closeButton:HookScript("OnLeave", function(self)
  46.         closeButtonfont:SetTextColor(1, 1, 1)
  47.         ColorBorder(closeButton, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor)
  48.     end)
  49. end
  50.  
  51. function Checkbox(self, selfid, px, py, description, SetChecked, OnClick) -- Checkbox(self, 1, 14, -55, "Description Text", SetChecked, OnClick)
  52.     local checkbox = CreateFrame("CheckButton", "AfterCheckBoxButton" .. selfid, self, "OptionsSmallCheckButtonTemplate")
  53.     checkbox:SetPoint("TOPLEFT", self, px, py)
  54.     checkbox:SetScript("OnClick", OnClick)
  55.     checkbox:SetWidth(28)
  56.     checkbox:SetHeight(28)
  57.     checkbox:SetFrameStrata("HIGH")
  58.     checkbox:SetChecked(SetChecked)
  59.     checkbox:SetHitRectInsets(0, -60, 0, 0)
  60.     checkbox:SetNormalTexture("")
  61.     checkbox:SetPushedTexture("")
  62.     checkbox:SetHighlightTexture("")
  63.     checkbox:SetBackdrop({
  64.         bgFile = AftermathhUI.media.backdrop,
  65.         insets = {top = 4, left = 4, bottom = 4, right = 4},
  66.     })
  67.  
  68.     CreateBorderLight(checkbox, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, -4)
  69.    
  70.     checkbox:HookScript("OnEnter", function(self)
  71.         ColorBorder(checkbox, 1, 1, 1)
  72.     end)
  73.    
  74.     checkbox:HookScript("OnLeave", function(self)
  75.         ColorBorder(checkbox, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor)
  76.     end)
  77.    
  78.     local checkboxtexture = checkbox:CreateTexture(nil, "OVERLAY")
  79.     checkboxtexture:SetWidth(25)
  80.     checkboxtexture:SetHeight(22)
  81.     checkboxtexture:SetAlpha(0.9)
  82.     checkboxtexture:SetPoint("LEFT", 2, 1)
  83.     checkboxtexture:SetTexture("Interface\\RAIDFRAME\\ReadyCheck-Ready")
  84.     checkbox:SetCheckedTexture(checkboxtexture)
  85.    
  86.     local checkboxtext = self:CreateFontString(nil, "ARTWORK", "GameFontNormal")
  87.     checkboxtext:SetPoint("LEFT", checkbox, "RIGHT", 5, 1)
  88.     checkboxtext:SetFontObject("GameFontNormal")
  89.     checkboxtext:SetTextColor(1, 1, 1)
  90.     checkboxtext:SetText(description)
  91. end
  92.  
  93. local function AftermathhUIFrameOnEnter(self, subfont)
  94.     self:HookScript("OnEnter", function()
  95.         ColorBorder(self, 1, 1, 1)
  96.         subfont:SetTextColor(1, 1, 1)
  97.     end)
  98.     self:HookScript("OnLeave", function()
  99.         ColorBorder(self, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor)
  100.         subfont:SetTextColor(1.0, 0.82, 0)
  101.     end)
  102. end
  103.  
  104. function ShowBuffs_OnClick()
  105.  
  106. end
  107.  
  108. ------------------------- MAIN -------------------------------------------------
  109.  
  110. local AftermathhUIFrame = CreateFrame("Frame", "AftermathhUIFrame", UIParent)
  111. AftermathhUIFrame:SetSize(800, 550)
  112. AftermathhUIFrame:SetFrameStrata("HIGH")
  113. AftermathhUIFrame:SetFrameLevel(25)
  114. AftermathhUIFrame:SetBackdrop({
  115.     bgFile = AftermathhUI.media.blank,
  116.     insets = {top = -4, left = -4, bottom = -4, right = -4},
  117. })
  118. AftermathhUIFrame:SetBackdropColor(unpack(AftermathhUI.media.backdropcolor))
  119. AftermathhUIFrame:Hide()
  120.  
  121. --------------------------------
  122. ----- Make it moveable! --------
  123. --------------------------------
  124.  
  125. AftermathhUIFrame:SetClampedToScreen(true)
  126. AftermathhUIFrame:SetMovable(true)
  127. AftermathhUIFrame:SetUserPlaced(true)
  128. AftermathhUIFrame:EnableMouse(true)
  129. AftermathhUIFrame:RegisterForDrag("LeftButton")
  130. AftermathhUIFrame:SetHitRectInsets(-15, -15, -5, -5)
  131.  
  132. AftermathhUIFrame:ClearAllPoints()
  133. AftermathhUIFrame.ClearAllPoints = function() end
  134. AftermathhUIFrame:SetPoint("CENTER", UIParent)
  135. AftermathhUIFrame.SetPoint = function() end
  136.  
  137. AftermathhUIFrame:SetScript("OnDragStart", function(self)
  138.     AftermathhUIFrame:StartMoving()
  139. end)
  140.  
  141. AftermathhUIFrame:SetScript("OnDragStop", function(self)
  142.     AftermathhUIFrame:StopMovingOrSizing()
  143. end)
  144.  
  145. -----------------------
  146. -- Create Stuff!!! ----
  147. -----------------------
  148.  
  149. CreateOptions(AftermathhUIFrame, "AftermathhUI_GUI", "Welcome to AftermathhUI_GUI. Here you can find most of the options that are needed!")
  150.  
  151. CloseButton(AftermathhUIFrame)
  152.  
  153. CreateBorderLight(AftermathhUIFrame, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 4)
  154.  
  155. -------------------- SUB 1 ------------------------------------------
  156.  
  157. local AftermathhUIFrameSub1 = CreateFrame("Button", "AftermathhUIFrameSub1", AftermathhUIFrame)
  158. AftermathhUIFrameSub1:SetSize(73, 20)
  159. AftermathhUIFrameSub1:SetFrameStrata("HIGH")
  160. AftermathhUIFrameSub1:SetFrameLevel(26)
  161. AftermathhUIFrameSub1:SetBackdrop({
  162.     bgFile = AftermathhUI.media.texture2,
  163. })
  164. AftermathhUIFrameSub1:SetBackdropColor(.40, .40, .40, 1)
  165. AftermathhUIFrameSub1:SetPoint("TOPLEFT", AftermathhUIFrame, 19, -65)
  166. AftermathhUIFrameSub1:Hide()
  167.  
  168. CreateBorderLight(AftermathhUIFrameSub1, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 1)
  169.  
  170. local AftermathhUIFrameSub1Font = AftermathhUIFrameSub1:CreateFontString(nil, "OVERLAY")
  171. AftermathhUIFrameSub1Font:SetFontObject('GameFontHighlightSmall')
  172. AftermathhUIFrameSub1Font:SetText("Unitframes")
  173. AftermathhUIFrameSub1Font:SetPoint("CENTER")
  174. AftermathhUIFrameSub1Font:SetTextColor(1.0, 0.82, 0)
  175.  
  176. ----------------------------- SUB 2 -------------------------------------
  177.  
  178. local AftermathhUIFrameSub2 = CreateFrame("Button", "AftermathhUIFrameSub2", AftermathhUIFrame)
  179. AftermathhUIFrameSub2:SetSize(73, 20)
  180. AftermathhUIFrameSub2:SetFrameStrata("HIGH")
  181. AftermathhUIFrameSub2:SetFrameLevel(26)
  182. AftermathhUIFrameSub2:SetBackdrop({
  183.     bgFile = AftermathhUI.media.texture2,
  184. })
  185. AftermathhUIFrameSub2:SetBackdropColor(.40, .40, .40, 1)
  186. AftermathhUIFrameSub2:SetPoint("TOPLEFT", AftermathhUIFrame, 97, -65)
  187. AftermathhUIFrameSub2:Hide()
  188.  
  189. CreateBorderLight(AftermathhUIFrameSub2, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 1)
  190.  
  191. --Checkbox(AftermathhUIFrameSub2, 1, 14, -55, "Show New Buff Timers Output Is; 28:30.", AftermathhUI.buffs.newbufftimers)
  192. --Checkbox(AftermathhUIFrameSub2, 2, 14, -75, "Show Old Buff Timers Output Is; 28(m with classcolors).", AftermathhUI.buffs.oldbufftimers)
  193.  
  194. local AftermathhUIFrameSub2Font = AftermathhUIFrameSub2:CreateFontString(nil, "OVERLAY")
  195. AftermathhUIFrameSub2Font:SetFontObject('GameFontHighlightSmall')
  196. AftermathhUIFrameSub2Font:SetText("Buffs")
  197. AftermathhUIFrameSub2Font:SetPoint("CENTER")
  198. AftermathhUIFrameSub2Font:SetTextColor(1.0, 0.82, 0)
  199.  
  200. -------------------- SUB 3 -------------------------------------------------
  201.  
  202. local AftermathhUIFrameSub3 = CreateFrame("Button", "AftermathhUIFrameSub3", AftermathhUIFrame)
  203. AftermathhUIFrameSub3:SetSize(73, 20)
  204. AftermathhUIFrameSub3:SetFrameStrata("HIGH")
  205. AftermathhUIFrameSub3:SetFrameLevel(26)
  206. AftermathhUIFrameSub3:SetBackdrop({
  207.     bgFile = AftermathhUI.media.texture2,
  208. })
  209. AftermathhUIFrameSub3:SetBackdropColor(.40, .40, .40, 1)
  210. AftermathhUIFrameSub3:SetPoint("TOPLEFT", AftermathhUIFrame, 175, -65)
  211. AftermathhUIFrameSub3:Hide()
  212.  
  213. CreateBorderLight(AftermathhUIFrameSub3, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 1)
  214.  
  215. local AftermathhUIFrameSub3Font = AftermathhUIFrameSub3:CreateFontString(nil, "OVERLAY")
  216. AftermathhUIFrameSub3Font:SetFontObject('GameFontHighlightSmall')
  217. AftermathhUIFrameSub3Font:SetText("Chat")
  218. AftermathhUIFrameSub3Font:SetPoint("CENTER")
  219. AftermathhUIFrameSub3Font:SetTextColor(1.0, 0.82, 0)
  220.  
  221. ------------------------
  222. -- On enter on button --
  223. ------------------------
  224.  
  225. AftermathhUIFrameOnEnter(AftermathhUIFrameSub1, AftermathhUIFrameSub1Font)
  226. AftermathhUIFrameOnEnter(AftermathhUIFrameSub2, AftermathhUIFrameSub2Font)
  227. AftermathhUIFrameOnEnter(AftermathhUIFrameSub3, AftermathhUIFrameSub3Font)
  228.  
  229. -------------------------------------------------------------------------------------------
  230.  
  231. local function CreateCheckboxes(subframe)
  232.     local boxes = AftermathUIFramecheckboxes or {}
  233.    
  234.     if subframe == 1 then
  235.         boxes[1] = Checkbox(AftermathhUIFrame, 1, 14, -95, "Show PvP Icon.", AftermathhUI.ouf.showpvpicon)
  236.         boxes[2] = Checkbox(AftermathhUIFrame, 2, 14, -115, "Show Buffs.", AftermathhUI.ouf.showbuffs, ShowBuffs_OnClick)
  237.         boxes[3] = Checkbox(AftermathhUIFrame, 3, 14, -135, "Show Debuffs.", AftermathhUI.ouf.showdebuffs)
  238.         boxes[4] = Checkbox(AftermathhUIFrame, 4, 14, -155, "Only Show Player Debuffs.", AftermathhUI.ouf.onlyshowplayerdebuffs)
  239.         boxes[5] = Checkbox(AftermathhUIFrame, 5, 14, -175, "Show Aggroo.", AftermathhUI.ouf.showaggroo)
  240.         boxes[6] = Checkbox(AftermathhUIFrame, 6, 14, -195, "Show Debuff Highlight", AftermathhUI.ouf.showdebuffhighlight)
  241.         boxes[7] = Checkbox(AftermathhUIFrame, 7, 14, -215, "Tooltip On Mouseover (Player etc).", AftermathhUI.ouf.tooltiponouf)
  242.         boxes[8] = Checkbox(AftermathhUIFrame, 8, 14, -235, "Show Role Icon.", AftermathhUI.ouf.showroleicon)
  243.         boxes[9] = Checkbox(AftermathhUIFrame, 9, 14, -255, "Show Boss Frames.", AftermathhUI.ouf.bossframes)
  244.         boxes[10] = Checkbox(AftermathhUIFrame, 10, 14, -275, "Show Party Frames.", AftermathhUI.ouf.showparty)
  245.         boxes[11] = Checkbox(AftermathhUIFrame, 11, 14, -295, "Tooltip On Mouseover (Raidframes).", AftermathhUI.ouf.tooltiponraid)
  246.         boxes[12] = Checkbox(AftermathhUIFrame, 12, 14, -315, "Highlight On Mouseover (Raidframes).", AftermathhUI.ouf.highlightontarget)
  247.         boxes[13] = Checkbox(AftermathhUIFrame, 13, 14, -335, "Make Raid Frames Vertical.", AftermathhUI.ouf.raidframesvertical)
  248.         boxes[14] = Checkbox(AftermathhUIFrame, 14, 14, -355, "Aura Watch (Raidframes).", AftermathhUI.ouf.aurawatch)
  249.         boxes[15] = Checkbox(AftermathhUIFrame, 15, 14, -375, "Raid Debuffs.", AftermathhUI.ouf.raiddebuffs)
  250.         boxes[16] = Checkbox(AftermathhUIFrame, 16, 14, -395, "Show Aggro On Raidframes.", AftermathhUI.ouf.showaggroonraidframes)
  251.         boxes[17] = Checkbox(AftermathhUIFrame, 17, 14, -415, "Experiance Bar.", AftermathhUI.ouf.expbar)
  252.         boxes[18] = Checkbox(AftermathhUIFrame, 18, 14, -435, "Reputation Bar.", AftermathhUI.ouf.repbar)
  253.         boxes[19] = Checkbox(AftermathhUIFrame, 19, 14, -455, "Moveable Frames.", AftermathhUI.ouf.moveableframes)
  254.         boxes[20] = Checkbox(AftermathhUIFrame, 20, 14, -475, "Totembar from oUF.", AftermathhUI.ouf.totembar)
  255.         boxes[21] = Checkbox(AftermathhUIFrame, 21, 14, -495, "Heal Prediction.", AftermathhUI.ouf.healprediction)
  256.         boxes[22] = Checkbox(AftermathhUIFrame, 22, 14, -515, "Combat Feedback.", AftermathhUI.ouf.combatfeedback)
  257.         boxes[23] = Checkbox(AftermathhUIFrame, 23, 350, -95, "Classcolor on Castbar.", AftermathhUI.ouf.castbarclasscolor)
  258.         boxes[24] = Checkbox(AftermathhUIFrame, 24, 350, -115, "Show Safe Zone.", AftermathhUI.ouf.showsafezone)
  259.         boxes[25] = Checkbox(AftermathhUIFrame, 25, 350, -135, "Show Latency.", AftermathhUI.ouf.showlatency)
  260.         boxes[26] = Checkbox(AftermathhUIFrame, 26, 350, -155, "Target Castbar Icon.", AftermathhUI.ouf.targetcastbaricon)
  261.         boxes[27] = Checkbox(AftermathhUIFrame, 27, 350, -175, "Focus Castbar Icon.", AftermathhUI.ouf.focuscastbaricon)
  262.         boxes[28] = Checkbox(AftermathhUIFrame, 28, 350, -195, "Show Interrupt Highlight.", AftermathhUI.ouf.showinterrupthighlight)
  263.     end
  264.     --elseif subframe == 2 then
  265.     --    boxes[1] = Checkbox(nil)
  266.     --elseif
  267.    
  268.     --else
  269.    
  270.     --end
  271.    
  272.     for i = i, #boxes do
  273.         boxes[i]:Show()
  274.     end
  275.     AftermathUIFramecheckboxes = checkboxes
  276. end
  277.  
  278. local function ReleaseCheckboxes()
  279.     local boxes = AftermathUIFramecheckboxes
  280.     local bin = AftermathUIFramerecyclebin or {}
  281.    
  282.     for i = 1, #boxes do
  283.         boxes[i]:Hide()
  284.         table.insert(bin, boxes[i])
  285.         boxes[i] = nil
  286.     end
  287. end
  288.  
  289. local function DisplayCheckboxes(subframe)
  290.     ReleaseCheckboxes()
  291.     CreateCheckboxes(subframe)
  292. end
  293.  
  294. AftermathhUIFrameSub1:SetScript("OnClick", DisplayCheckboxes(1))
  295.  
  296. SlashCmdList['OPENAFTERMATHHUI'] = function()
  297.     AftermathhUIFrame:Show()
  298.     AftermathhUIFrameSub1:Show()
  299.     AftermathhUIFrameSub2:Show()
  300.     AftermathhUIFrameSub3:Show()
  301.    
  302. end
  303. SLASH_OPENAFTERMATHHUI1 = '/after'
  304. SLASH_OPENAFTERMATHHUI2 = '/aftermathhui'

Last edited by Aftermathhqt : 03-09-12 at 06:14 AM.
  Reply With Quote
03-09-12, 06:59 AM   #32
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Cooked up somthing else... but!

LUA Code:
  1. function CheckBoxes(number)
  2.     if number == 1 then
  3.         Checkbox(AftermathhUIFrame, 1, 14, -95, "Show PvP Icon.", AftermathhUI.ouf.showpvpicon)
  4.         Checkbox(AftermathhUIFrame, 2, 14, -115, "Show Buffs.", AftermathhUI.ouf.showbuffs, ShowBuffs_OnClick)
  5.         Checkbox(AftermathhUIFrame, 3, 14, -135, "Show Debuffs.", AftermathhUI.ouf.showdebuffs)
  6.         Checkbox(AftermathhUIFrame, 4, 14, -155, "Only Show Player Debuffs.", AftermathhUI.ouf.onlyshowplayerdebuffs)
  7.         Checkbox(AftermathhUIFrame, 5, 14, -175, "Show Aggroo.", AftermathhUI.ouf.showaggroo)
  8.         Checkbox(AftermathhUIFrame, 6, 14, -195, "Show Debuff Highlight", AftermathhUI.ouf.showdebuffhighlight)
  9.         Checkbox(AftermathhUIFrame, 7, 14, -215, "Tooltip On Mouseover (Player etc).", AftermathhUI.ouf.tooltiponouf)
  10.         Checkbox(AftermathhUIFrame, 8, 14, -235, "Show Role Icon.", AftermathhUI.ouf.showroleicon)
  11.         Checkbox(AftermathhUIFrame, 9, 14, -255, "Show Boss Frames.", AftermathhUI.ouf.bossframes)
  12.         Checkbox(AftermathhUIFrame, 10, 14, -275, "Show Party Frames.", AftermathhUI.ouf.showparty)
  13.         Checkbox(AftermathhUIFrame, 11, 14, -295, "Tooltip On Mouseover (Raidframes).", AftermathhUI.ouf.tooltiponraid)
  14.         Checkbox(AftermathhUIFrame, 12, 14, -315, "Highlight On Mouseover (Raidframes).", AftermathhUI.ouf.highlightontarget)
  15.         Checkbox(AftermathhUIFrame, 13, 14, -335, "Make Raid Frames Vertical.", AftermathhUI.ouf.raidframesvertical)
  16.         Checkbox(AftermathhUIFrame, 14, 14, -355, "Aura Watch (Raidframes).", AftermathhUI.ouf.aurawatch)
  17.         Checkbox(AftermathhUIFrame, 15, 14, -375, "Raid Debuffs.", AftermathhUI.ouf.raiddebuffs)
  18.         Checkbox(AftermathhUIFrame, 16, 14, -395, "Show Aggro On Raidframes.", AftermathhUI.ouf.showaggroonraidframes)
  19.         Checkbox(AftermathhUIFrame, 17, 14, -415, "Experiance Bar.", AftermathhUI.ouf.expbar)
  20.         Checkbox(AftermathhUIFrame, 18, 14, -435, "Reputation Bar.", AftermathhUI.ouf.repbar)
  21.         Checkbox(AftermathhUIFrame, 19, 14, -455, "Moveable Frames.", AftermathhUI.ouf.moveableframes)
  22.         Checkbox(AftermathhUIFrame, 20, 14, -475, "Totembar from oUF.", AftermathhUI.ouf.totembar)
  23.         Checkbox(AftermathhUIFrame, 21, 14, -495, "Heal Prediction.", AftermathhUI.ouf.healprediction)
  24.         Checkbox(AftermathhUIFrame, 22, 14, -515, "Combat Feedback.", AftermathhUI.ouf.combatfeedback)
  25.         Checkbox(AftermathhUIFrame, 23, 350, -95, "Classcolor on Castbar.", AftermathhUI.ouf.castbarclasscolor)
  26.         Checkbox(AftermathhUIFrame, 24, 350, -115, "Show Safe Zone.", AftermathhUI.ouf.showsafezone)
  27.         Checkbox(AftermathhUIFrame, 25, 350, -135, "Show Latency.", AftermathhUI.ouf.showlatency)
  28.         Checkbox(AftermathhUIFrame, 26, 350, -155, "Target Castbar Icon.", AftermathhUI.ouf.targetcastbaricon)
  29.         Checkbox(AftermathhUIFrame, 27, 350, -175, "Focus Castbar Icon.", AftermathhUI.ouf.focuscastbaricon)
  30.         Checkbox(AftermathhUIFrame, 28, 350, -195, "Show Interrupt Highlight.", AftermathhUI.ouf.showinterrupthighlight)
  31.         for i = 1, 28 do
  32.             _G["AfterCheckBoxButton"..i]:Show()
  33.         end
  34.     elseif number == 2 then
  35.         for i = 1, 28 do
  36.             _G["AfterCheckBoxButton"..i]:Hide()
  37.         end
  38.     elseif number == 3 then
  39.         for i = 1, 28 do
  40.             _G["AfterCheckBoxButton"..i]:Hide()
  41.         end
  42.     end
  43. end
  44.  
  45. AftermathhUIFrameSub1:SetScript("OnClick", CheckBoxes(1))

But i get this error ? :S doesn't make any sense..



Message: ...terface\AddOns\AftermathhUI_GUI\AftermathhUI_GUI.lua:274: Usage: AftermathhUIFrameSub1:SetScript("type", function)
Time: 03/09/12 13:57:45
Count: 1
Stack: [C]: in function `SetScript'
...terface\AddOns\AftermathhUI_GUI\AftermathhUI_GUI.lua:274: in main chunk

Locals: (*temporary) = AftermathhUIFrameSub1 {
0 = <userdata>
Shadow = <table> {
}
Border = <table> {
}
HasBorder = true
}
(*temporary) = "OnClick"

  Reply With Quote
03-09-12, 02:18 PM   #33
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Need to change last line to:

LUA Code:
  1. AftermathhUIFrameSub1:SetScript("OnClick", function() CheckBoxes(1) end)
  Reply With Quote
03-09-12, 03:43 PM   #34
kaels
A Cyclonian
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 46
Message: ...terface\AddOns\AftermathhUI_GUI\AftermathhUI_GUI.lua:282: attempt to get length of global 'boxes' (a nil value)
Time: 03/09/12 13:07:53
Count: 1
Stack: ...terface\AddOns\AftermathhUI_GUI\AftermathhUI_GUI.lua:282: in function <...terface\AddOns\AftermathhUI_GUI\AftermathhUI_GUI.lua:278>
...terface\AddOns\AftermathhUI_GUI\AftermathhUI_GUI.lua:290: in function `DisplayCheckboxes'
...terface\AddOns\AftermathhUI_GUI\AftermathhUI_GUI.lua:294: in main chunk

Locals: bin = <table> {
}
(*temporary) = 1
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = "attempt to get length of global 'boxes' (a nil value)"
Sorry!

In your Checkbox function, you need to add at the end:
lua Code:
  1. return checkbox

And then this line:
lua Code:
  1. AftermathUIFrame.checkboxes = checkboxes
should have been
lua Code:
  1. AftermathUIFrame.checkboxes = boxes
You should definitely listen to Phanx over me with respect to recycling...at the very least though I think you want to keep a table to hold on to the frames you're using. You could change ReleaseCheckboxes() to simply:
lua Code:
  1. local function ReleaseCheckboxes()
  2.     local boxes = AftermathUIFrame.checkboxes
  3.    
  4.     for i = 1, #boxes do
  5.         boxes[i]:Hide()
  6.         boxes[i] = nil
  7.     end
  8. end
  Reply With Quote
03-09-12, 05:22 PM   #35
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Nibelheim View Post
Need to change last line to:

LUA Code:
  1. AftermathhUIFrameSub1:SetScript("OnClick", function() CheckBoxes(1) end)
Originally Posted by kaels View Post
Sorry!

In your Checkbox function, you need to add at the end:
lua Code:
  1. return checkbox

And then this line:
lua Code:
  1. AftermathUIFrame.checkboxes = checkboxes
should have been
lua Code:
  1. AftermathUIFrame.checkboxes = boxes
You should definitely listen to Phanx over me with respect to recycling...at the very least though I think you want to keep a table to hold on to the frames you're using. You could change ReleaseCheckboxes() to simply:
lua Code:
  1. local function ReleaseCheckboxes()
  2.     local boxes = AftermathUIFrame.checkboxes
  3.    
  4.     for i = 1, #boxes do
  5.         boxes[i]:Hide()
  6.         boxes[i] = nil
  7.     end
  8. end
Thanks both =)

yaya! it works, doh... the font string is still there ><

Last edited by Aftermathhqt : 03-09-12 at 06:29 PM.
  Reply With Quote
03-09-12, 10:48 PM   #36
kaels
A Cyclonian
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 46
Which fontstring?
  Reply With Quote
03-10-12, 09:11 AM   #37
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by kaels View Post
Which fontstring?
All of them.

  Reply With Quote
03-10-12, 01:39 PM   #38
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Try creating the fontstring from the checkbox.

Code:
local checkboxtext = checkbox:CreateFontString(nil, "ARTWORK", "GameFontNormal")
  Reply With Quote
03-10-12, 01:53 PM   #39
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Nibelheim View Post
Try creating the fontstring from the checkbox.

Code:
local checkboxtext = checkbox:CreateFontString(nil, "ARTWORK", "GameFontNormal")
Yeah, that would be an brilant idea :P
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to make an GUI.

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