: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:
I'm relatively new at writing AddOns, so any tips or criticism is appreciated. |
Try:
Code:
local _, class = UnitClass("player") |
There is also working code to provide exactly this feature in my addon PhanxBuffs; you're welcome to use it.
|
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? |
Try using GetSpellInfo instead of GetSpellTexture.
Also, Vrul's code could be cleaned up a bit further: Code:
hooksecurefunc("TemporaryEnchantFrame_Update", function(_, mainhand, _, _, offhand) |
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") |
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. |
Quote:
|
Quote:
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") |
I just tried this with my lvl 13 shaman (don't has windfury right now):
Lua Code:
Result: texture is 'empty' (means GetTexture() returns the correct path but the texture is not visible). So I tried Lua Code:
Shows the texture as expected. (lvl 14 shaman has Flametongue) Then I tried Lua Code:
Result: TempEnchant1Icon shows the windfury texture. |
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") |
Quote:
Quote:
This is the frames template: Code:
<Button name="AuraButtonTemplate" virtual="true"> |
Why don't you just create a texture on top of the button and set that?
Quote:
|
Quote:
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:
[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. ;) |
Looks like it's solved :D 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:
I really appreciate everyone for helping me out! Thanks! :D |
You don't need this bit anymore either:
Code:
tooltip[index] = _G[addonName .. "TempEnchantScannerTexture" .. index] 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. |
Quote:
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? |
Quote:
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. |
Quote:
|
Quote:
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. |
The following code will never display a texture as long as "SetNonBlocking" is enabled unless the texture is loaded elsewhere.
Lua Code:
|
All times are GMT -6. The time now is 10:52 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI