Thread Tools Display Modes
03-01-14, 05:47 PM   #1
wiMp
A Deviate Faerie Dragon
Join Date: Mar 2008
Posts: 10
:SetTexture() only works for abilities on actionbar.

I've been working on an AddOn that replaces the weapon icons temporary enchant frame to the icons of the weapon enchant.

The AddOn works fine, the only issue I've run into, is that I can only use the textures if I have the icons on my actionbar.

This is the code I've been working with:
Lua Code:
  1. local f = CreateFrame('GameTooltip', 'tempEnchantScanner', UIParent, 'GameTooltipTemplate')
  2. f:SetOwner(UIParent, 'ANCHOR_NONE')
  3.  
  4. local _, playerClass = UnitClass("player")
  5.  
  6. local tempEnchants
  7. if playerClass == "SHAMAN" then
  8.     tempEnchants = {
  9.         ["Earthliving"] = GetSpellTexture(51730),
  10.         ["Flametongue"] = GetSpellTexture(8024),
  11.         ["Frostbrand"]  = GetSpellTexture(8033),
  12.         ["Rockbiter"]   = GetSpellTexture(8017),
  13.         ["Windfury"]    = GetSpellTexture(8232),
  14.     }
  15. elseif playerClass == "ROGUE" then
  16.     tempEnchants = {
  17.         ["Mind-Numbing Poison"] = GetSpellTexture(5761),
  18.         ["Crippling Poison"]    = GetSpellTexture(3408),
  19.         ["Paralytic Poison"]    = GetSpellTexture(108215),
  20.         ["Leeching Poison"]     = GetSpellTexture(108211),
  21.         ["Deadly Poison"]       = GetSpellTexture(2823),
  22.         ["Wound Poison"]        = GetSpellTexture(8679),
  23.     }
  24. end
  25.  
  26.  
  27. local function getTempEnchantTextureOnSlotId(slotid)
  28.     local found
  29.     f:SetInventoryItem("player",slotid)
  30.     for i = 1,f:NumLines() do
  31.         local text = _G["tempEnchantScannerTextLeft"..i]:GetText()
  32.             for k,v in pairs(tempEnchants) do
  33.             if strmatch(text,k) then
  34.                 found = v
  35.             end
  36.         end
  37.     end
  38.     return found
  39. end
  40.  
  41.  
  42. hooksecurefunc('TemporaryEnchantFrame_Update', function(self,...)
  43.     local mh,_,_,oh = ...
  44.     local mhtexture = getTempEnchantTextureOnSlotId(16)
  45.     local ohtexture = getTempEnchantTextureOnSlotId(17)
  46.    
  47.     if mh and oh and mhtexture and ohtexture then
  48.         TempEnchant2Icon:SetTexture(mhtexture)
  49.         TempEnchant1Icon:SetTexture(ohtexture)
  50.     elseif mh and not oh and mhtexture then
  51.         TempEnchant1Icon:SetTexture(mhtexture)
  52.     elseif oh and not mh and ohtexture then
  53.         TempEnchant1Icon:SetTexture(ohtexture)
  54.     end
  55. end)

I'm relatively new at writing AddOns, so any tips or criticism is appreciated.
  Reply With Quote
03-01-14, 06:49 PM   #2
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Try:
Code:
local _, class = UnitClass("player")
if class ~= "ROGUE" and class ~= "SHAMAN" then return end

local addonName = ...
local tooltip = CreateFrame("GameTooltip", addonName .. "TempEnchantScanner", UIParent, "GameTooltipTemplate")
tooltip:Hide()

local tempEnchants
if class == "ROGUE" then
    tempEnchants = {
        ["Mind-Numbing Poison"] = GetSpellTexture(5761),
        ["Crippling Poison"]    = GetSpellTexture(3408),
        ["Paralytic Poison"]    = GetSpellTexture(108215),
        ["Leeching Poison"]     = GetSpellTexture(108211),
        ["Deadly Poison"]       = GetSpellTexture(2823),
        ["Wound Poison"]        = GetSpellTexture(8679),
    }
elseif class == "SHAMAN" then
    tempEnchants = {
        ["Earthliving"] = GetSpellTexture(51730),
        ["Flametongue"] = GetSpellTexture(8024),
        ["Frostbrand"]  = GetSpellTexture(8033),
        ["Rockbiter"]   = GetSpellTexture(8017),
        ["Windfury"]    = GetSpellTexture(8232),
    }
end

local tooltipLine = addonName .. "TempEnchantScannerTextLeft"
tooltip:SetScript("OnTooltipSetItem", function(self)
    for lineNum = 1, self:NumLines() do
        local texture = tempEnchants[_G[tooltipLine .. lineNum]:GetText():match("^(.+) %(")]
        if texture then
            self.texture = texture
            return
        end
    end
    self.texture = nil
end)

hooksecurefunc("TemporaryEnchantFrame_Update", function(_, mainhand, _, _, offhand)
    if mainhand then
        tooltip:SetInventoryItem("player", 16)
        mainhand = tooltip.texture
    end
    if offhand then
        tooltip:SetInventoryItem("player", 17)
        offhand = tooltip.texture
    end
    if mainhand then
        if offhand then
            TempEnchant2Icon:SetTexture(mainhand)
            TempEnchant1Icon:SetTexture(offhand)
        else
            TempEnchant1Icon:SetTexture(mainhand)
        end
    elseif offhand then
        TempEnchant1Icon:SetTexture(offhand)
    end
end)
  Reply With Quote
03-01-14, 07:29 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
There is also working code to provide exactly this feature in my addon PhanxBuffs; you're welcome to use it.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-01-14, 07:35 PM   #4
wiMp
A Deviate Faerie Dragon
Join Date: Mar 2008
Posts: 10
Thanks, you've cleaned up my code a whole lot. Same issue still seems to persist though.

On my Enhancement Shaman, I use a macro to buff my weapons with Windfury Weapon and Flametongue Weapon, this macro uses the Windfury Weapon icon. The Windfury Weapon icon will be displayed on the right weapon and the Offhand's icon will be blank. It does give it the right texture, which I'm testing using :GetTexture(). As soon as I place Flametongue Weapon on my actionbars everything will work perfectly.

I don't really know why... Are textures created when I place them on the actionbars and emptied again when you take them off?

Last edited by wiMp : 03-01-14 at 07:45 PM.
  Reply With Quote
03-01-14, 10:56 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Try using GetSpellInfo instead of GetSpellTexture.

Also, Vrul's code could be cleaned up a bit further:
Code:
hooksecurefunc("TemporaryEnchantFrame_Update", function(_, mainhand, _, _, offhand)
    if mainhand then
        tooltip:SetInventoryItem("player", 16)
        (offhand and TempEnchant2Icon or TempEnchant1Icon):SetTexture(tooltip.texture)
    end
    if offhand then
        tooltip:SetInventoryItem("player", 17)
        TempEnchant1Icon:SetTexture(tooltip.texture)
    end
end)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-01-14, 11:35 PM   #6
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
I leveled a shaman to 10 so I could see what you were talking about and I can't explain why that is happening but here is something that works (on a level 10 shaman at least):
Code:
local _, class = UnitClass("player")
if class ~= "ROGUE" and class ~= "SHAMAN" then return end

local addonName = ...
local tooltip = CreateFrame("GameTooltip", addonName .. "TempEnchantScanner", UIParent, "GameTooltipTemplate")
tooltip:Hide()

local tempEnchants
if class == "ROGUE" then
    tempEnchants = {
        ["Mind-Numbing Poison"] = GetSpellTexture(5761),
        ["Crippling Poison"]    = GetSpellTexture(3408),
        ["Paralytic Poison"]    = GetSpellTexture(108215),
        ["Leeching Poison"]     = GetSpellTexture(108211),
        ["Deadly Poison"]       = GetSpellTexture(2823),
        ["Wound Poison"]        = GetSpellTexture(8679),
    }
elseif class == "SHAMAN" then
    tempEnchants = {
        ["Earthliving"] = GetSpellTexture(51730),
        ["Flametongue"] = GetSpellTexture(8024),
        ["Frostbrand"]  = GetSpellTexture(8033),
        ["Rockbiter"]   = GetSpellTexture(8017),
        ["Windfury"]    = GetSpellTexture(8232),
    }
end

local tooltipText = setmetatable({ }, { __index = function(self, index)
    self[index] = _G[addonName .. "TempEnchantScannerTextLeft" .. index]
    return self[index]
end })

tooltip:SetScript("OnTooltipSetItem", function(self)
    for index = 1, self:NumLines() do
        local texture = tempEnchants[tooltipText[index]:GetText():match("^(.+) %(")]
        if texture then
            self.texture = texture
            return
        end
    end
    self.texture = nil
end)

local enchant = { }
for index = 1, NUM_TEMP_ENCHANT_FRAMES do
    enchant[index] = _G["TempEnchant" .. index]
    enchant[index].icon = _G["TempEnchant" .. index .. "Icon"]
    tooltip[index] = _G[addonName .. "TempEnchantScannerTexture" .. index]
end

hooksecurefunc("TemporaryEnchantFrame_Update", function()
    for index = 1, NUM_TEMP_ENCHANT_FRAMES do
        if enchant[index]:IsShown() then
            tooltip:SetInventoryItem("player", enchant[index]:GetID())
            if tooltip.texture then
                tooltip[index]:SetTexture(tooltip.texture) -- ugly hack fix
                enchant[index].icon:SetTexture(tooltip.texture)
            end
        end
    end
end)
  Reply With Quote
03-02-14, 01:37 AM   #7
wiMp
A Deviate Faerie Dragon
Join Date: Mar 2008
Posts: 10
Phanx, I've tried using GetSpellInfo() instead, but also same results.

Vrul, I really appreciate you going through all this effort to help me, but it's still not perfect.

Here's some screenshots: 1, 2.

Both the icons work if the weapon enchant is the same, if you're using two different ones though, only the one on TempEnchant2Icon sticks.
  Reply With Quote
03-02-14, 02:32 AM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by wiMp View Post
Phanx, I've tried using GetSpellInfo() instead, but also same results.
Well, I don't know what to tell you, as this problem simply does not exist in my own addon that does the same thing, or in any other addon I've ever seen that does anything with spell icons. I also don't really have time to go investigate, so if Vrul is seeing the same problem, maybe he can figure it out for you.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-03-14, 11:12 AM   #9
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by wiMp View Post
Both the icons work if the weapon enchant is the same, if you're using two different ones though, only the one on TempEnchant2Icon sticks.
I leveled an enhancement shaman up to get Flametongue Weapon and Windfury Weapon on two different weapons at the same time and they both showed up fine for me using the code I posted earlier. Not sure what's going on if it is only working on one for you.

I also level a rogue up to get Deadly Poison and Crippling Poison but that was all for naught because those aren't even temporary enchants any more. With the addon disabled they still showed up with the correct spell icons. So you can completely remove the rogue stuff, unless some of the higher level poisons are still temp enchants, then just remove the ones that aren't.

Here is the code again with the rogue stuff removed and a slight change to make it easier on you if you localize it later:
Code:
local _, class = UnitClass("player")
if class ~= "SHAMAN" then return end

local addonName = ...
local tooltip = CreateFrame("GameTooltip", addonName .. "TempEnchantScanner", UIParent, "GameTooltipTemplate")
tooltip:Hide()

local tempEnchants = {
    ["Earthliving"] = GetSpellTexture(51730),
    ["Flametongue"] = GetSpellTexture(8024),
    ["Frostbrand"]  = GetSpellTexture(8033),
    ["Rockbiter"]   = GetSpellTexture(8017),
    ["Windfury"]    = GetSpellTexture(8232),
}

local tooltipText = setmetatable({ }, { __index = function(self, index)
    self[index] = _G[addonName .. "TempEnchantScannerTextLeft" .. index]
    return self[index]
end })

tooltip:SetScript("OnTooltipSetItem", function(self)
    for index = 1, self:NumLines() do
        local texture = tempEnchants[tooltipText[index]:GetText():gsub("%s*%(.-%)%s*", "")]
        if texture then
            self.texture = texture
            return
        end
    end
    self.texture = nil
end)

local enchant = { }
for index = 1, NUM_TEMP_ENCHANT_FRAMES do
    enchant[index] = _G["TempEnchant" .. index]
    enchant[index].icon = _G["TempEnchant" .. index .. "Icon"]
    tooltip[index] = _G[addonName .. "TempEnchantScannerTexture" .. index]
end

hooksecurefunc("TemporaryEnchantFrame_Update", function()
    for index = 1, NUM_TEMP_ENCHANT_FRAMES do
        if enchant[index]:IsShown() then
            tooltip:SetInventoryItem("player", enchant[index]:GetID())
            if tooltip.texture then
                tooltip[index]:SetTexture(tooltip.texture) -- ugly hack fix
                enchant[index].icon:SetTexture(tooltip.texture)
            end
        end
    end
end)
The only reason I can think this happens is that the textures for the temp enchant frames don't count when checking to remove unused textures from memory.
  Reply With Quote
03-03-14, 11:39 AM   #10
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
I just tried this with my lvl 13 shaman (don't has windfury right now):
Lua Code:
  1. hooksecurefunc('TemporaryEnchantFrame_Update', function(self,...)
  2.     local a = GetSpellTexture(8232) --(windfury)
  3.     TempEnchant1Icon:SetTexture(a)
  4. end)

Result: texture is 'empty' (means GetTexture() returns the correct path but the texture is not visible).

So I tried
Lua Code:
  1. hooksecurefunc('TemporaryEnchantFrame_Update', function(self,...)
  2.     local a = GetSpellTexture(8024) --(Flametongue)
  3.     TempEnchant1Icon:SetTexture(a)
  4. end)

Shows the texture as expected. (lvl 14 shaman has Flametongue)

Then I tried

Lua Code:
  1. hooksecurefunc('TemporaryEnchantFrame_Update', function(self,...)
  2.     local a = GetSpellTexture(8232) --windfury
  3.     ActionButton1Icon:SetTexture(a)
  4.     TempEnchant1Icon:SetTexture(a)
  5. end)
(I know its senseless ... just to see what would happen)

Result: TempEnchant1Icon shows the windfury texture.

Last edited by Duugu : 03-03-14 at 12:25 PM.
  Reply With Quote
03-03-14, 01:26 PM   #11
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Did the texture change for Flametongue Weapon without that spell being on an action bar somewhere?

I can get the Windfury Weapon icon to show up on my level 20 rogue's Sharpening Stone temp enchant if I want, it's just the way temp enchant icons seem to need the texture to be used elsewhere that is weird.

It may have something to do with the texture being changed constantly OnUpdate as well because this works too:
Code:
local _, class = UnitClass("player")
if class ~= "SHAMAN" then return end

local addonName = ...
local tooltip = CreateFrame("GameTooltip", addonName .. "TempEnchantScanner", UIParent, "GameTooltipTemplate")
tooltip:Hide()

local tempEnchants = {
    ["Earthliving"] = GetSpellTexture(51730),
    ["Flametongue"] = GetSpellTexture(8024),
    ["Frostbrand"]  = GetSpellTexture(8033),
    ["Rockbiter"]   = GetSpellTexture(8017),
    ["Windfury"]    = GetSpellTexture(8232),
}

local tooltipText = setmetatable({ }, { __index = function(self, index)
    self[index] = _G[addonName .. "TempEnchantScannerTextLeft" .. index]
    return self[index]
end })

tooltip:SetScript("OnTooltipSetItem", function(self)
    for index = 1, self:NumLines() do
        local texture = tempEnchants[tooltipText[index]:GetText():gsub("%s*%(.-%)%s*", "")]
        if texture then
            self.texture = texture
            return
        end
    end
    self.texture = nil
end)

local function StopTexture(self, texture)
    self.inventoryTexture = texture
end

local enchant, SetTexture = { }, TempEnchant1Icon.SetTexture
for index = 1, NUM_TEMP_ENCHANT_FRAMES do
    enchant[index] = _G["TempEnchant" .. index .. "Icon"]
    enchant[index].inventoryID = index + 15
    enchant[index].SetTexture = StopTexture
end

hooksecurefunc("TemporaryEnchantFrame_Update", function()
    for index = 1, NUM_TEMP_ENCHANT_FRAMES do
        local enchant = enchant[index]
        if enchant:IsVisible() then
            tooltip:SetInventoryItem("player", enchant.inventoryID)
            local texture = tooltip.texture or enchant.inventoryTexture
            if enchant.texture ~= texture then
                enchant.texture = texture
                SetTexture(enchant, texture)
            end
        end
    end
end)
The downside to that method is the potential for taint issues down the road.
  Reply With Quote
03-03-14, 01:30 PM   #12
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by Vrul View Post
Did the texture change for Flametongue Weapon without that spell being on an action bar somewhere?
Uhm. Not sure. :/ Can't test right now.

I can get the Windfury Weapon icon to show up on my level 20 rogue's Sharpening Stone temp enchant if I want, it's just the way temp enchant icons seem to need the texture to be used elsewhere that is weird.
Indeed


This is the frames template:
Code:
	<Button name="AuraButtonTemplate" virtual="true">
		<Size x="30" y="30"/>
		<Layers>
			<Layer level="BACKGROUND">
				<Texture name="$parentIcon" nonBlocking="true"/>
				<FontString name="$parentCount" inherits="NumberFontNormal" parentKey="count">
					<Anchors>
						<Anchor point="BOTTOMRIGHT">
							<Offset>
								<AbsDimension x="-2" y="2"/>
							</Offset>
						</Anchor>
					</Anchors>
				</FontString>
				<FontString name="$parentDuration" inherits="GameFontNormalSmall" hidden="true" parentKey="duration">
					<Anchors>
						<Anchor point="TOP" relativePoint="BOTTOM" />
					</Anchors>
				</FontString>
			</Layer>
		</Layers>
		<Scripts>
			<OnEnter>
				GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT");
				GameTooltip:SetFrameLevel(self:GetFrameLevel() + 2);
				GameTooltip:SetUnitAura(PlayerFrame.unit, self:GetID(), self.filter);
			</OnEnter>
			<OnLeave>
				GameTooltip:Hide();
			</OnLeave>
		</Scripts>
	</Button>
The first thing that comes to my mind is what the hell is nonBlocking="true"?

Last edited by Duugu : 03-03-14 at 01:33 PM.
  Reply With Quote
03-03-14, 01:32 PM   #13
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Why don't you just create a texture on top of the button and set that?

Originally Posted by Duugu View Post
The first thing that comes to my mind is what the hell is nonBlocking="true"?
Nonblocking means it doesn't make the game wait for the texture to load before it continues doing other things.

Last edited by semlar : 03-03-14 at 01:40 PM.
  Reply With Quote
03-03-14, 02:49 PM   #14
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by semlar View Post
Nonblocking means it doesn't make the game wait for the texture to load before it continues doing other things.
Ok.

nonBlocking="true" is the bad guy.

Setting it to nil will fix the problem. Don't know why or what exactly wents wrong ... but the texture does show up.

Just add

Lua Code:
  1. TempEnchant1Icon:SetNonBlocking(nil)
  2. TempEnchant2Icon:SetNonBlocking(nil)
  3. TempEnchant3Icon:SetNonBlocking(nil)
to you global code.

[e]
I think the basic problem is like this:
The code sets the texture on every onupdate - again and again.
And nonBlocking="true" means the interface does not wait for the loading process to be finished. Which means the texture loading starts and before even a single line of the texture is loaded into the texture frame the loading process starts again. Which leads to a "empty" texture.
If the icons texture is cached then the 'loading process' is fast enough to load it within a single onupdate into the texture frame. If it is not cached (if it was not shown before ... like with the actionbar) than it is not fast enough (the icon must be loaded from disk ... which is to slow to finish within a single onupdate timeframe).
At least something like that.

Last edited by Duugu : 03-03-14 at 03:14 PM.
  Reply With Quote
03-03-14, 03:23 PM   #15
wiMp
A Deviate Faerie Dragon
Join Date: Mar 2008
Posts: 10
Looks like it's solved Great!

I've edited Vrul's code to add the nonBlocking stuff, I've also removed the 'hack' that set the texture to the tooltip, because it's no longer necessary.

Lua Code:
  1. local _, class = UnitClass("player")
  2. if class ~= "SHAMAN" then return end
  3.  
  4. local addonName = ...
  5. local tooltip = CreateFrame("GameTooltip", addonName .. "TempEnchantScanner", UIParent, "GameTooltipTemplate")
  6. tooltip:Hide()
  7.  
  8. local tempEnchants = {
  9.     ["Earthliving"] = GetSpellTexture(51730),
  10.     ["Flametongue"] = GetSpellTexture(8024),
  11.     ["Frostbrand"]  = GetSpellTexture(8033),
  12.     ["Rockbiter"]   = GetSpellTexture(8017),
  13.     ["Windfury"]    = GetSpellTexture(8232),
  14. }
  15.  
  16. local tooltipText = setmetatable({ }, { __index = function(self, index)
  17.     self[index] = _G[addonName .. "TempEnchantScannerTextLeft" .. index]
  18.     return self[index]
  19. end })
  20.  
  21. tooltip:SetScript("OnTooltipSetItem", function(self)
  22.     for index = 1, self:NumLines() do
  23.         local texture = tempEnchants[tooltipText[index]:GetText():gsub("%s*%(.-%)%s*", "")]
  24.         if texture then
  25.             self.texture = texture
  26.             return
  27.         end
  28.     end
  29.     self.texture = nil
  30. end)
  31.  
  32. local enchant = { }
  33. for index = 1, NUM_TEMP_ENCHANT_FRAMES do
  34.     enchant[index] = _G["TempEnchant" .. index]
  35.     enchant[index].icon = _G["TempEnchant" .. index .. "Icon"]
  36.     tooltip[index] = _G[addonName .. "TempEnchantScannerTexture" .. index]
  37.     enchant[index].icon:SetNonBlocking(nil)
  38. end
  39.  
  40. hooksecurefunc("TemporaryEnchantFrame_Update", function()
  41.     for index = 1, NUM_TEMP_ENCHANT_FRAMES do
  42.         if enchant[index]:IsShown() then
  43.             tooltip:SetInventoryItem("player", enchant[index]:GetID())
  44.             if tooltip.texture then
  45.                 enchant[index].icon:SetTexture(tooltip.texture)
  46.             end
  47.         end
  48.     end
  49. end)

I really appreciate everyone for helping me out! Thanks!
  Reply With Quote
03-03-14, 04:45 PM   #16
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
You don't need this bit anymore either:
Code:
tooltip[index] = _G[addonName .. "TempEnchantScannerTexture" .. index]
Duugu I noticed the nonBlocking bit earlier but I originally thought it was similar to __mode='kv' for garbage collection of texture memory. I disregarded that thought though since it didn't impact the buff and debuff icons in the same way. I guess I should've dumped the texture metatable to see if there was a way to manually set it just to see what it did.

Edit: I just checked and wowprogramming.com has SetNonBlocking documented where wowpedia.org does not. That could've saved some time had I known.

Side thought: The only performance hit will be on the first texture load and not each OnUpdate since it is already in memory correct? I would like to think there is a smart check on the C side of things to skip loading a texture if that is the one in use currently.

Last edited by Vrul : 03-03-14 at 05:05 PM.
  Reply With Quote
03-03-14, 06:34 PM   #17
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by Vrul View Post
You don't need this bit anymore either:
Side thought: The only performance hit will be on the first texture load and not each OnUpdate since it is already in memory correct? I would like to think there is a smart check on the C side of things to skip loading a texture if that is the one in use currently.
I've no prove that my theory is correct. I'm more or less guessing. But if it works as described there must be something like that.

On a second thought ... without any modification the enchant-thingi shows the items (weapon) icon. Right? If I buff myself with those weapon enchants, logout, and login, the buffs are still there. And they are shown correctly without any action. Even if the item icon is not at an action bar button or similar or visible or shown at least one time.
Why does the original feature with the item textures work and the same stuff with spell textures does not?

Are all the item textures loaded into memory when the client starts and the spells not?
  Reply With Quote
03-03-14, 06:54 PM   #18
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Duugu View Post
Are all the item textures loaded into memory when the client starts and the spells not?
Technically, texture files are not loaded into memory until a texture region object is instructed to display them.

Information about which texture should be displayed for which item is available as soon as the item is in the game's local data cache. Items are cached as soon as they are "seen" -- equipped on your character, in your inventory, seen in the auction house, seen in a loot window, etc. Items equipped on your character are always known, so info about them is always available immediately. You can force an item to be cached by calling GetItemInfo -- if it's not already cached, it won't return anything, but the server will request the info from the server and cache it, so the next GetItemInfo call on that item will return the info -- or by instructing a tooltip to display the item.

Spells, however, do not work the same way, and do not need to be cached; GetSpellInfo should always return correct info, even for spells you've never "seen" in the game, which is why the problem you're describing does not make any sense.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-03-14, 07:46 PM   #19
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by Duugu View Post
Why does the original feature with the item textures work and the same stuff with spell textures does not?
I think it works just like you said and the constant switching back and forth of two textures, one of which not being in memory, is what messes it up. Of the two workarounds I found, one just cached the texture in a hidden area and the other prevented the loading of the unwanted texture, both support your theory.
  Reply With Quote
03-03-14, 09:18 PM   #20
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by Phanx View Post
Spells, however, do not work the same way, and do not need to be cached; GetSpellInfo should always return correct info, even for spells you've never "seen" in the game, which is why the problem you're describing does not make any sense.
Ok. My description was unclear. "cached" meant "is loaded into memory and is available without loading it from disk" ... not "cached in the games data cache file".

It's not about item data or the texture path. GetSpellInfo does return the correct texture path. And the texture is set. The spell texture is just not rendered (or loaded or however you call it) into the region object. And the item texture is rendered. Thats it.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » :SetTexture() only works for abilities on actionbar.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off