From c223e4c4e1767a464f759e711c105f738cc7d548 Mon Sep 17 00:00:00 2001 From: Michael Wiesendanger Date: Fri, 20 Dec 2019 19:04:31 +0100 Subject: [PATCH] Fix updating of slottexture attributes after scaling --- gui/GM_ChangeMenu.lua | 2 +- gui/GM_GearBar.lua | 3 ++- gui/GM_UiHelper.lua | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/gui/GM_ChangeMenu.lua b/gui/GM_ChangeMenu.lua index a1c789e..528dcec 100644 --- a/gui/GM_ChangeMenu.lua +++ b/gui/GM_ChangeMenu.lua @@ -173,7 +173,7 @@ function me.UpdateChangeMenu(gearSlot) end local changeMenuSlot = changeMenuSlots[index] - mod.uiHelper.PrepareSlotTexture(changeMenuSlot) + mod.uiHelper.UpdateSlotTextureAttributes(changeMenuSlot) -- update metadata for slot changeMenuSlot.slotId = gearSlotMetaData.slotId diff --git a/gui/GM_GearBar.lua b/gui/GM_GearBar.lua index 1bbb93f..8ead1bc 100644 --- a/gui/GM_GearBar.lua +++ b/gui/GM_GearBar.lua @@ -139,7 +139,7 @@ function me.CreateGearSlot(gearBarFrame, position) gearSlot.position = position mod.uiHelper.CreateHighlightFrame(gearSlot) - mod.uiHelper.PrepareSlotTexture(gearSlot) + mod.uiHelper.UpdateSlotTextureAttributes(gearSlot) mod.uiHelper.CreateCooldownOverlay( gearSlot, RGGM_CONSTANTS.ELEMENT_GEAR_BAR_SLOT_COOLDOWN_FRAME, @@ -288,6 +288,7 @@ function me.UpdateGearBar() gearSlot:SetAttribute("type1", "item") gearSlot:SetAttribute("item", gearSlotMetaData.slotId) me.UpdateTexture(gearSlot, gearSlotMetaData) + mod.uiHelper.UpdateSlotTextureAttributes(gearSlot) slotCount = slotCount + 1 gearSlot:Show() else diff --git a/gui/GM_UiHelper.lua b/gui/GM_UiHelper.lua index 42c891f..93a4be1 100644 --- a/gui/GM_UiHelper.lua +++ b/gui/GM_UiHelper.lua @@ -37,9 +37,12 @@ me.tag = "UiHelper" @param {table} slot ]]-- -function me.PrepareSlotTexture(slot) - -- set a dummy texture - otherwise GetNormalTexture will return nil - slot:SetNormalTexture("//dummy") +function me.UpdateSlotTextureAttributes(slot) + if slot:GetNormalTexture() == nil then + -- set a dummy texture - otherwise GetNormalTexture will return nil + slot:SetNormalTexture("//dummy") + end + local texture = slot:GetNormalTexture() texture:SetTexCoord(0.1, 0.9, 0.1, 0.9) texture:SetPoint(