02-19-12, 06:14 PM | #1 |
Class coloring panels
I wrote this little addon a while ago to add some panels to my UI just to pretty things up a little, I've been trying to get them class colored off and on for a while now and can't figure out what I'm doing wrong. I'd really appreciate any help I can get here, for some reason today it's driving me a little nuts.
Here's the code: LUA Code:
|
|
02-19-12, 06:52 PM | #2 | |
AftermathhUI.Classcolor = RAID_CLASS_COLORS[AftermathhUI.Class] This what i use |
||
02-19-12, 06:58 PM | #3 |
Actually your code should work... not sure what's wrong with it.
Try printing it and see what it returns. Are you getting any lua errors? Maybe the texture is invalid. I'm not sure if textures with spaces in them are allowed. Last edited by Haleth : 02-19-12 at 07:13 PM. |
|
02-19-12, 07:07 PM | #4 | |
is wrong should be RAID_CLASS_COLORS[AftermathhUI.Class] only |
||
02-19-12, 07:09 PM | #5 |
You shouldn't assume that everyone uses your UI.
|
|
02-19-12, 07:14 PM | #6 |
02-19-12, 07:17 PM | #7 |
The thing is that his code works so there is no reason to change it. Your code is actually exactly the same, just written in a different way.
|
|
02-19-12, 07:24 PM | #8 |
I tried printing it and got nothing. I'm lost here lol I use the same method to class color my XP bar addon and it works fine for that.
This is the relevant code from my XP Bar addon: LUA Code:
Last edited by Othgar : 02-19-12 at 07:31 PM. Reason: added info |
|
02-19-12, 07:32 PM | #9 | |
1. He clearly defined the variable class on the line before the one you're claiming is wrong. 2. Later in the code, he is clearly using three separate variables r, g, and b, instead of looking them up every time he wants to use them (eg. color.r and so forth) which would be a pointless waste of CPU time anyway. The only reason to look up the values "on demand" instead of upvaluing them at runtime is if you expect them to change at unpredictable times while you are logged in, or if they change at predictable times (eg. an event fires to indicate that they've changed) but change more often than you need to use them (so it's more efficient to just look them up on use instead of every time they change). I don't even know how you looked at any of the code he posted and picked out that one, obviously-correct line and decided it was wrong... |
||
02-19-12, 07:38 PM | #10 |
Othgar; Try using a texture without a space in its name, I'm fairly convinced that's the problem because the code in your OP works for me (using a different texture though ofc).
|
|
02-19-12, 07:39 PM | #11 | |
|
||
02-19-12, 07:40 PM | #12 | |
Wait none of the textures have names with spaces... corner, lchat, rchat and tlcorner are the texture names. Last edited by Othgar : 02-19-12 at 07:44 PM. |
||
02-19-12, 07:47 PM | #13 |
"Lust Panels" has a space.
|
|
02-19-12, 07:48 PM | #14 |
On the other hand, there are several actual issues with your code. In no particular order:
#1 - I can't see your actual textures, but in your code, you specify something like "width = 256, height = 350". If the actual pixel dimensions of your texture are 256 x 350, this is why it does not work. WoW will only recognize texture files whose pixel dimensions are powers of 8. To get a different size in-game, you can either resize the texture with SetSize (or SetWidth and SetHeight if you don't like shortcuts), or you can use multiple textures and position them adjacent to each other if you see too much distortion through resizing. #2 - You give every panel frame the same global name, "mpanel". If you want the panels to be accessible from outside the file, you need to give them unique names, and I'd suggest something more descriptive, like "LustMinimapPanel" or "LustGuildChatPanel". If you don't need them to be accessible from outside, don't give them global names at all. #3 - Using an OnUpdate script to watch for changes which have an associated event is hugely inefficient. Instead, use an OnEvent script, and register the frame for the relevant events (eg. PLAYER_TARGET_CHANGED fires when your target changes, including when you no longer have one, and PLAYER_REGEN_DISABLED and PLAYER_REGEN_ENABLED fire when you enter or leave combat, respectively). #4 - Using a space in your addon's folder name is not recommended, due to the way operating systems handle spaces in file paths. I can't say for sure that this will cause any problems, but you should just stick to convention and rename your addon folder and TOC from "Lust Panels" to "LustPanels". #5 - You should probably just parent some of these panels to the frame they're relevant to. The minimap panel, for example, should probably be parented to the minimap. This way, if someone moves the minimap, the panel will move with it. #6 - For panels that do not need any scripts or mouse interactivity, you should just use a texture instead of a frame. |
|
02-19-12, 08:04 PM | #15 | |
Ok so rename the main folder and TOC then got it.
#2 Honestly didn't even notice that I did that but I'll take a look at fixing it when I get them class colored. #3 The on update script was the only way I could get the alpha to change with my Bartender4 bars. It is commented out because I have since moved the bars and that texture is no longer used. I tried to find a better method of doing this but was unable to do so See here #4 Will be fixing this after I finish this post. #5 I'm not really worried about anyone else moving the panels since I will probably never release this addon unless I include it as part of a full UI. And these textures won't look very good anywhere but where they are anyways. #6 This is probably true, but since I'm pretty new to Lua and was a lot newer when I wrote it, this was the only way I knew how to do it. It works so I'm not worried about changing it unless I decide to release it as a complete UI. |
||
02-19-12, 08:26 PM | #16 |
I changed the addon name to LustPanels, changed the name of its folder to LustPanels, and Changed the TOC to LustPanels, gave each frame a unique name, and disabled everything but LustPanels and ACP and still no dice. all I get when I print the r, g, b is 0.96 ...grrr.. so here's the TOC and the Lua for the whole addon.
Lua: LUA Code:
Code:
## Interface: 40300 ## Author: Othgar/Lust ## Title: Lust Panels ## Version: 1.0 ## Notes: Panels of lusti-tribali-ness-esque ## OptionalDeps: Bartender4 panels.lua LustPanels.zip |
|
02-19-12, 08:26 PM | #17 |
That said, I loaded your code in-game and discovered one other (fairly major) issue. You defined your color values as r, g, and b, but then you later assign the variable name g to your guild chat panel, so the coloring of all further panels (everything except the minimap panel) is wrong, because :SetBackdropColor ignores any non-number values passed to it, so you're losing the green color information.
Other than that, though, all of the panels are colored, and after I changed the local variable name for the guild chat panel, they're all the correct class color. The only other change I made before testing was to alter the bgFile texture paths to a file that actually exists on my system. If the code isn't working for you (after changing the guild chat panel's local variable name) I don't really know why. The only things I can suggest: #1 - Try manually setting the color of a panel in-game: Code:
/run local c=RAID_CLASS_COLORS.SHAMAN mpanel:SetBackdropColor(c.r, c.g, c.b, 0.5) #2 - Try to load only the code you posted, in its own addon, with all other addons disabled. If neither of those work, then there is something severely wrong with your WoW installation, and you should delete the Cache folder and then run the Repair.exe tool. |
|
02-19-12, 08:43 PM | #18 | |
Update: I recolored the MinimapPanel texture to solid white and it works fine now. Apparently the solid black can't be colored by Lua. Last edited by Othgar : 02-19-12 at 08:54 PM. Reason: Update |
||
02-19-12, 09:02 PM | #19 |
Yes. If you want to color your textures, it's best if they're white (or a similarly light color). Think of the textures as paper. If you are using black paper, you won't notice what color is drawn on top of it.
|
|
02-19-12, 09:06 PM | #20 |
Man I feel like an idiot now lol. But at least all is working as it's supposed to now. Thanks a lot for the help everyone. You guys rock!
|
|
WoWInterface » Developer Discussions » Lua/XML Help » Class coloring panels |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|