From 88d127de157c66a4e763227a7124c31196bfff3e Mon Sep 17 00:00:00 2001 From: shagu Date: Tue, 3 Mar 2020 17:37:47 +0100 Subject: [PATCH] skins: postpone slot update hook to first show This drastically increases the login speed on some servers, where the item queries take a little longer, which made the UI freeze for a few seconds. --- skins/blizzard/character.lua | 86 ++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/skins/blizzard/character.lua b/skins/blizzard/character.lua index dce7f893..c1348761 100644 --- a/skins/blizzard/character.lua +++ b/skins/blizzard/character.lua @@ -56,31 +56,8 @@ pfUI:RegisterSkin("Character", "vanilla:tbc", function () end SkinTab(tab) end - hooksecurefunc("PetTab_Update", function() - CharacterFrameTab3:ClearAllPoints() - CharacterFrameTab3:SetPoint("LEFT", HasPetUI() and CharacterFrameTab2 or CharacterFrameTab1, "RIGHT", border*2 + 1, 0) - end, 1) do -- Character Tab - StripTextures(PaperDollFrame) - StripTextures(CharacterAttributesFrame) - StripTextures(CharacterResistanceFrame) - - EnableClickRotate(CharacterModelFrame) - CharacterModelFrameRotateLeftButton:Hide() - CharacterModelFrameRotateRightButton:Hide() - - for i,c in pairs(magicResTextureCords) do - local magicResFrame = _G["MagicResFrame"..i] - magicResFrame:SetWidth(26) - magicResFrame:SetHeight(26) - CreateBackdrop(magicResFrame) - SetAllPointsOffset(magicResFrame.backdrop, magicResFrame, 2) - local icon = GetNoNameObject(magicResFrame, "Texture", "BACKGROUND", "ResistanceIcons") - SetAllPointsOffset(icon, magicResFrame, 3) - icon:SetTexCoord(c[1], c[2], c[3], c[4]) - end - local slots = { "HeadSlot", "NeckSlot", @@ -104,22 +81,12 @@ pfUI:RegisterSkin("Character", "vanilla:tbc", function () "AmmoSlot" } - for i, slot in pairs(slots) do - local frame = _G["Character"..slot] - StripTextures(frame) - CreateBackdrop(frame) - SetAllPointsOffset(frame.backdrop, frame, 0) - - HandleIcon(frame.backdrop, _G["Character"..slot.."IconTexture"]) - - if not frame.scoreText then - frame.scoreText = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal") - frame.scoreText:SetFont(pfUI.font_default, 12, "OUTLINE") - frame.scoreText:SetPoint("BOTTOMRIGHT", 0, 0) - end + local function RefreshPetPosition() + CharacterFrameTab3:ClearAllPoints() + CharacterFrameTab3:SetPoint("LEFT", HasPetUI() and CharacterFrameTab2 or CharacterFrameTab1, "RIGHT", border*2 + 1, 0) end - hooksecurefunc("PaperDollItemSlotButton_Update", function() + local function RefreshCharacterSlots() for i, slot in pairs(slots) do local slotId, _, _ = GetInventorySlotInfo(slot) local quality = GetInventoryItemQuality("player", slotId) @@ -153,7 +120,52 @@ pfUI:RegisterSkin("Character", "vanilla:tbc", function () end end end + end + + HookScript(CharacterFrame, "OnShow", function() + RefreshCharacterSlots() + RefreshPetPosition() + + if not this.hooked then + hooksecurefunc("PaperDollItemSlotButton_Update", RefreshCharacterSlots) + hooksecurefunc("PetTab_Update", RefreshPetPosition, 1) + this.hooked = true + end end) + + StripTextures(PaperDollFrame) + StripTextures(CharacterAttributesFrame) + StripTextures(CharacterResistanceFrame) + + EnableClickRotate(CharacterModelFrame) + CharacterModelFrameRotateLeftButton:Hide() + CharacterModelFrameRotateRightButton:Hide() + + for i,c in pairs(magicResTextureCords) do + local magicResFrame = _G["MagicResFrame"..i] + magicResFrame:SetWidth(26) + magicResFrame:SetHeight(26) + CreateBackdrop(magicResFrame) + SetAllPointsOffset(magicResFrame.backdrop, magicResFrame, 2) + local icon = GetNoNameObject(magicResFrame, "Texture", "BACKGROUND", "ResistanceIcons") + SetAllPointsOffset(icon, magicResFrame, 3) + icon:SetTexCoord(c[1], c[2], c[3], c[4]) + end + + for i, slot in pairs(slots) do + local frame = _G["Character"..slot] + StripTextures(frame) + CreateBackdrop(frame) + SetAllPointsOffset(frame.backdrop, frame, 0) + + HandleIcon(frame.backdrop, _G["Character"..slot.."IconTexture"]) + + if not frame.scoreText then + frame.scoreText = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal") + frame.scoreText:SetFont(pfUI.font_default, 12, "OUTLINE") + frame.scoreText:SetPoint("BOTTOMRIGHT", 0, 0) + end + end end do -- Pet Tab