This code runs every time you leave combat. This is fine, especially since some things may reset themselves in combat, but this also means you're creating several more function hooks (the hooksecurefunc). Let's say you get into and out of combat 100 times. Every time one of those fontstrings tries to show now, such as PlayerLevelText, the game calls PlayerLevelText:Hide() literally 100 times. Next time you leave combat adds another hook, calling :Hide() 101 times. You probably noticed the longer you played, the worse the lag was.
I removed the three buff lines, protected the hooks and the securestatedriver behind a switch so they only happen once, and cleaned up the code, including changing the function hooks into widget hooks. I'm not too familiar with securestatedriver stuff, but I'm pretty sure every time a specific register function is called, it toggles that state, so you should only call it once.
Lua Code:
-- UI Scripts - Shadowlands updated - Emil
local f=CreateFrame("frame")
f:RegisterEvent("PLAYER_ENTERING_WORLD") --Event that fires on loadingscreens
f:RegisterEvent("PLAYER_REGEN_DISABLED")
f:RegisterEvent("PLAYER_REGEN_ENABLED")
f:SetScript("OnEvent",function(self,event,...)
if event~="PLAYER_REGEN_DISABLED" then
for _,v in pairs({"Character","Spellbook","Talent","Achievement","QuestLog","Guild","LFD","Collections","EJ","Store","MainMenu"}) do
_G[v.."MicroButton"]:SetScale(.001)
end
MicroButtonAndBagsBar:Hide()
PlayerFrame:SetScale(1.2)
TargetFrame:SetScale(1.2)
FocusFrame:SetScale(1.2)
SetCVar("cameradistancemaxfactor",10)
local m1 = "MultiBarBottomRight"
_G[m1.."Button7"]:SetPoint("BOTTOMLEFT",_G[m1.."Button1"],"TOPLEFT",0,4)
UIPARENT_MANAGED_FRAME_POSITIONS[m1].xOffset = 6
ActionBarUpButton:Hide()
MainMenuBar.GetYOffset=function() return -30 end
UIParent_ManageFramePositions()
local m2 = "MainMenuBarArtFrame"
_G[m2.."Background"]:Hide()
_G[m2].PageNumber:Hide()
_G[m2].LeftEndCap:Hide()
_G[m2].RightEndCap:Hide()
ActionButton1:ClearAllPoints()
ActionButton1:SetPoint("BOTTOM",_G[m2.."Background"],-340,35)
ActionBarDownButton:Hide()
if not f.hooks then
for _,v in pairs({TargetFrame.levelText,FocusFrame.levelText,TargetFrame.name,PlayerFrame.name,FocusFrame.name,PlayerLevelText}) do
-- hooksecurefunc(v,"Show",function(s) s:Hide() end)
v:HookScript("OnShow",function(s) s:Hide() end)
v:Hide()
end
RegisterStateDriver(StanceBarFrame,"visibility","hide")
RegisterStateDriver(PetActionBarFrame,"visibility","hide")
f.hooks=true
end
C_NamePlate.SetNamePlateFriendlySize(40,20)
GameTimeFrame:Hide()
MiniMapTrackingBackground:Hide()
MiniMapTrackingButton:Hide()
MiniMapTrackingIcon:Hide()
MiniMapWorldMapButton:Hide()
MinimapBorderTop:Hide()
MinimapZoneText:Hide()
MinimapZoomIn:Hide()
MinimapZoomOut:Hide()
PetActionBarFrame:Hide()
-- Blizzard_TimeManager
LoadAddOn("Blizzard_TimeManager")
TimeManagerClockButton:Hide()
end
end)