Heya, this is probably not the best approach to do this but it does what you want I think -
Also your code does produce errors, you should enable error messages when dealing with code
/run C_CVar.SetCVar("scriptErrors",1);ReloadUI()
or you can download BugGrabber and BugSack
So there is 2 issues with this code,
hooksecurefunc("CharacterFrame_UpdateSelectedTab",function(self)
is not a function and
CharacterFrameTab
is not a template so that’s why it can’t create the Tab
You can view the Blizzard code for the CharacterFrame Tabs here:
https://github.com/Gethe/wow-ui-source/blob/live/Interface/FrameXML/CharacterFrame.lua
https://github.com/Gethe/wow-ui-source/blob/live/Interface/FrameXML/CharacterFrame.xml
Now as for the code I’ve added a ScrollFrame similar to the Reputation/Currency Tabs and added a background for demonstration how it renders.
local TabName = "MyNewTab";
local TabID = CharacterFrame.numTabs + 1;
local Tab = CreateFrame("Button", "$parentTab"..TabID, CharacterFrame, "CharacterFrameTabTemplate", TabID);
PanelTemplates_SetNumTabs(CharacterFrame, TabID);
Tab:SetPoint("LEFT", "$parentTab" .. (TabID-1), "RIGHT", -16, 0);
Tab:SetText(TabName);
local Panel = CreateFrame("Frame", nil, CharacterFrame);
Panel:SetAllPoints(CharacterFrame);
Panel.ScrollBox = CreateFrame("ScrollFrame", nil, Panel, "UIPanelScrollFrameTemplate")
Panel.ScrollBox:SetPoint("TOPLEFT", Panel, "TOPLEFT", 10, -64) --Left / Up
Panel.ScrollBox:SetPoint("BOTTOMRIGHT", Panel, "BOTTOMRIGHT", -30, 10) --Right / Down
Panel.Content = CreateFrame("Frame", nil, Panel)
Panel.Content:SetPoint("CENTER", 0, -25)
Panel.Content:SetSize(305, 351) -- Width / Height
Panel.Content.Background = Panel.Content:CreateTexture(nil, "OVERLAY")
Panel.Content.Background:SetColorTexture(math.random(), math.random(), math.random(), 0.2)
Panel.Content.Background:SetAllPoints()
Tab:SetScript("OnClick", function(self, arg1)
PanelTemplates_SetTab(CharacterFrame, TabID)
if _G["HonorFrame"] ~= nil then
_G["HonorFrame"]:Hide()
end
if _G["PaperDollFrame"] ~= nil then
_G["PaperDollFrame"]:Hide()
end
if _G["PetPaperDollFrame"] ~= nil then
_G["PetPaperDollFrame"]:Hide()
end
if _G["HonorFrame"] ~= nil then
_G["HonorFrame"]:Hide()
end
if _G["SkillFrame"] ~= nil then
_G["SkillFrame"]:Hide()
end
if _G["ReputationFrame"] ~= nil then
_G["ReputationFrame"]:Hide()
end
if _G["TokenFrame"] ~= nil then
_G["TokenFrame"]:Hide()
end
Panel:Show()
Panel.ScrollBox:SetScrollChild(Panel.Content)
end)
hooksecurefunc("ToggleCharacter", function(tab, onlyShow)
if Panel:IsShown() then
Panel:Hide()
end
end)
local Header = Panel.Content:CreateFontString()
Header:SetFont("Fonts\\FRIZQT__.TTF", 35, "GameFontHighlightSmall")
Header:SetPoint("TOP", 0, -10)
Header:SetTextColor(0, 1, 0, 1)
Header:SetText(TabName)
-- This is what extends the ScrollBox, it will auto extend as you position thing further down
local EndOfScrollFrame = Panel.Content:CreateFontString()
EndOfScrollFrame:SetFont("Fonts\\FRIZQT__.TTF", 20, "GameFontHighlightSmall")
EndOfScrollFrame:SetPoint("TOP", 0, -1000)
EndOfScrollFrame:SetTextColor(1, 0, 0, 1)
EndOfScrollFrame:SetText("End of ScrollFrame")