View Single Post
09-17-14, 09:53 AM   #6
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Phanx View Post
That seems... incredibly overcomplicated. Nothing in the character frame is ever "protected" (that's only for the in-game store UI) and texture objects are never secure, so you can freely manipulate them in combat without any danger. Assuming the frame name and texture path in your code are correct, all you should need is this:

Code:
local setting
hooksecurefunc(CharacterBackSlotIconTexture, "SetTexture", function(self, texture)
     if not setting and string.find(texture, "PaperDoll") then
          setting = true
          self:SetTexture("Interface\\PaperDoll\\UI-PaperDoll-Slot-SecondaryHand")
          setting = nil
     end
end)
The only reason i wrote it like that, so i could use this LockTexture in the future in other frames. I'm not sure about textures cannot be protected or not, since you could use a simple texture as a button, and also has SetPoint and ClearAllPoint methods, i just went with the safe method, but you could be right. The issue with your code, the game using the same texture for empty and equipped slots, so you need to add this:

Lua Code:
  1. local setting
  2. hooksecurefunc(CharacterBackSlotIconTexture, "SetTexture", function(self, texture)
  3.     if not setting and string.find(texture, "PaperDoll") then
  4.         setting = true
  5.         local id = GetInventoryItemID("player", GetInventorySlotInfo("BackSlot"))
  6.         if id then
  7.             local texture = GetInventoryItemTexture("player", GetInventorySlotInfo("BackSlot"))
  8.             self:SetTexture(texture)
  9.         else
  10.             local texture = "Interface\\PaperDoll\\UI-PaperDoll-Slot-SecondaryHand"
  11.             self:SetTexture(texture)
  12.         end
  13.         setting = nil
  14.     end
  15. end)

Last edited by Resike : 09-17-14 at 10:05 AM.
  Reply With Quote