View Single Post
09-16-23, 12:25 AM   #5
miona
A Kobold Labourer
Join Date: Sep 2023
Posts: 1
Originally Posted by Kanegasi View Post
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( Workers Compensation Lawyer) 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:
  1. -- UI Scripts - Shadowlands updated - Emil
  2.  
  3. local f=CreateFrame("frame")
  4. f:RegisterEvent("PLAYER_ENTERING_WORLD") --Event that fires on loadingscreens
  5. f:RegisterEvent("PLAYER_REGEN_DISABLED")
  6. f:RegisterEvent("PLAYER_REGEN_ENABLED")
  7. f:SetScript("OnEvent",function(self,event,...)
  8.     if event~="PLAYER_REGEN_DISABLED" then
  9.  
  10.         for _,v in pairs({"Character","Spellbook","Talent","Achievement","QuestLog","Guild","LFD","Collections","EJ","Store","MainMenu"}) do
  11.             _G[v.."MicroButton"]:SetScale(.001)
  12.         end
  13.         MicroButtonAndBagsBar:Hide()
  14.  
  15.         PlayerFrame:SetScale(1.2)
  16.         TargetFrame:SetScale(1.2)
  17.         FocusFrame:SetScale(1.2)
  18.  
  19.         SetCVar("cameradistancemaxfactor",10)
  20.  
  21.         local m1 = "MultiBarBottomRight"
  22.         _G[m1.."Button7"]:SetPoint("BOTTOMLEFT",_G[m1.."Button1"],"TOPLEFT",0,4)
  23.         UIPARENT_MANAGED_FRAME_POSITIONS[m1].xOffset = 6
  24.         ActionBarUpButton:Hide()
  25.         MainMenuBar.GetYOffset=function() return -30 end
  26.         UIParent_ManageFramePositions()
  27.  
  28.         local m2 = "MainMenuBarArtFrame"
  29.         _G[m2.."Background"]:Hide()
  30.         _G[m2].PageNumber:Hide()
  31.         _G[m2].LeftEndCap:Hide()
  32.         _G[m2].RightEndCap:Hide()
  33.         ActionButton1:ClearAllPoints()
  34.         ActionButton1:SetPoint("BOTTOM",_G[m2.."Background"],-340,35)
  35.         ActionBarDownButton:Hide()
  36.  
  37.         if not f.hooks then
  38.             for _,v in pairs({TargetFrame.levelText,FocusFrame.levelText,TargetFrame.name,PlayerFrame.name,FocusFrame.name,PlayerLevelText}) do
  39.     --          hooksecurefunc(v,"Show",function(s) s:Hide() end)
  40.                 v:HookScript("OnShow",function(s) s:Hide() end)
  41.                 v:Hide()
  42.             end
  43.             RegisterStateDriver(StanceBarFrame,"visibility","hide")
  44.             RegisterStateDriver(PetActionBarFrame,"visibility","hide")
  45.             f.hooks=true
  46.         end
  47.  
  48.         C_NamePlate.SetNamePlateFriendlySize(40,20)
  49.  
  50.         GameTimeFrame:Hide()
  51.         MiniMapTrackingBackground:Hide()
  52.         MiniMapTrackingButton:Hide()
  53.         MiniMapTrackingIcon:Hide()
  54.         MiniMapWorldMapButton:Hide()
  55.         MinimapBorderTop:Hide()
  56.         MinimapZoneText:Hide()
  57.         MinimapZoomIn:Hide()
  58.         MinimapZoomOut:Hide()
  59.         PetActionBarFrame:Hide()
  60.  
  61.         -- Blizzard_TimeManager
  62.         LoadAddOn("Blizzard_TimeManager")
  63.         TimeManagerClockButton:Hide()
  64.     end
  65. end)
Thank you so much for the code.. Its really great to get easily..

Keep sharing with us.. We will be greatful to you...
  Reply With Quote