Thread Tools Display Modes
Prev Previous Post   Next Post Next
04-30-23, 05:25 AM   #4
AeroMaxxD
An Aku'mai Servant
Join Date: Dec 2022
Posts: 33
On another note I also asked about how to add a tab to the character frame on the official Blizzard forums, someone there responded with the code below.

This is what gave me the idea of a scroll frame, initially, I dismissed it however, and was still going to go with the next and previous buttons, I've since changed my mind.

Lua Code:
  1. local TabName = "MyNewTab";
  2.  
  3. local TabID = CharacterFrame.numTabs + 1;
  4. local Tab = CreateFrame("Button", "$parentTab"..TabID, CharacterFrame, "CharacterFrameTabTemplate", TabID);
  5. PanelTemplates_SetNumTabs(CharacterFrame, TabID);
  6. Tab:SetPoint("LEFT", "$parentTab" .. (TabID-1), "RIGHT", -16, 0);
  7. Tab:SetText(TabName);
  8.  
  9. local Panel = CreateFrame("Frame", nil, CharacterFrame);
  10. Panel:SetAllPoints(CharacterFrame);
  11.  
  12. Panel.ScrollBox = CreateFrame("ScrollFrame", nil, Panel, "UIPanelScrollFrameTemplate")
  13. Panel.ScrollBox:SetPoint("TOPLEFT", Panel, "TOPLEFT", 10, -64) --Left / Up
  14. Panel.ScrollBox:SetPoint("BOTTOMRIGHT", Panel, "BOTTOMRIGHT", -30, 10) --Right / Down
  15.  
  16. Panel.Content = CreateFrame("Frame", nil, Panel)
  17. Panel.Content:SetPoint("CENTER", 0, -25)
  18. Panel.Content:SetSize(305, 351) -- Width / Height
  19. Panel.Content.Background = Panel.Content:CreateTexture(nil, "OVERLAY")
  20. Panel.Content.Background:SetColorTexture(math.random(), math.random(), math.random(), 0.2)
  21. Panel.Content.Background:SetAllPoints()
  22.  
  23. Tab:SetScript("OnClick", function(self, arg1)
  24.     PanelTemplates_SetTab(CharacterFrame, TabID)
  25.     if _G["HonorFrame"] ~= nil then
  26.         _G["HonorFrame"]:Hide()
  27.     end
  28.     if _G["PaperDollFrame"] ~= nil then
  29.         _G["PaperDollFrame"]:Hide()
  30.     end
  31.     if _G["PetPaperDollFrame"] ~= nil then
  32.         _G["PetPaperDollFrame"]:Hide()
  33.     end
  34.     if _G["HonorFrame"] ~= nil then
  35.         _G["HonorFrame"]:Hide()
  36.     end
  37.     if _G["SkillFrame"] ~= nil then
  38.         _G["SkillFrame"]:Hide()
  39.     end
  40.     if _G["ReputationFrame"] ~= nil then
  41.         _G["ReputationFrame"]:Hide()
  42.     end
  43.     if _G["TokenFrame"] ~= nil then
  44.         _G["TokenFrame"]:Hide()
  45.     end
  46.     Panel:Show()
  47.     Panel.ScrollBox:SetScrollChild(Panel.Content)
  48. end)
  49.  
  50. hooksecurefunc("ToggleCharacter", function(tab, onlyShow)
  51.     if Panel:IsShown() then
  52.         Panel:Hide()
  53.     end
  54. end)
  55.  
  56. local Header = Panel.Content:CreateFontString()
  57. Header:SetFont("Fonts\\FRIZQT__.TTF", 35, "GameFontHighlightSmall")
  58. Header:SetPoint("TOP", 0, -10)
  59. Header:SetTextColor(0, 1, 0, 1)
  60. Header:SetText(TabName)
  61.  
  62. -- This is what extends the ScrollBox, it will auto extend as you position thing further down
  63. local EndOfScrollFrame = Panel.Content:CreateFontString()
  64. EndOfScrollFrame:SetFont("Fonts\\FRIZQT__.TTF", 20, "GameFontHighlightSmall")
  65. EndOfScrollFrame:SetPoint("TOP", 0, -1000)
  66. EndOfScrollFrame:SetTextColor(1, 0, 0, 1)
  67. EndOfScrollFrame:SetText("End of ScrollFrame")
  Reply With Quote
 

WoWInterface » Developer Discussions » General Authoring Discussion » Adding a ScrollFrame to a CharacterFrame tab


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