Thread Tools Display Modes
05/08/15, 06:23 AM   #1
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,913
FCOChatTabBrain - Error with colorizing chat tab headers

Hey all,

This question bases on FCOChatTabBrain version 0.2.1b!

I've added an option to color the chat tab header text (the text shown at the chat tabs as the "description", like "Combat", "Guilds", "Chat", "New tab" whatever you specify it to be in the chat tab options) with this light blue color (like shown at the whisper messages already), if you are not currently using this chat tab and a message arrives at this tab.

For me this is working pretty well without any errors. Some other players, until today only 2, got an lua error messge if a new chat message arrives and the source code is trying to colorize the chat tab:

Code:
EsoUI/Libraries/Utility/ZO_TabButtonGroup.lua:571: attempt to index a nil value
stack traceback:
EsoUI/Libraries/Utility/ZO_TabButtonGroup.lua:571: in function
'ZO_TabButton_Text_SetTextColor'
user:/AddOns/FCOChatTabBrain/FCOChatTabBrain.lua:4553: in function 'func'
EsoUI/Libraries/Globals/globalapi.lua:181 in function '(anonymous)'
I'm using the standard ZOs function to color the chat tab, like they do it with the whisper messages:
'ZO_TabButton_Text_SetTextColor(tabControl, colorConstant)'

If I check the sources of ZOs file ZO_TabButtonGroup.lua, line 571, where the error appears:
They are just using GetControl(tabControl, "Text") to get the Text label of the tab and then they use this to change the color of the text.

I've implemented the same check inside my source code to see if the Text control is not NIL, and I even checked if the tab itsself is not equal NIL, if the color code exists.
I've added a zo_callLater with some ms to see if this will help.
Everytime I, personally, won't get any error message and the colorizing just works as intended!
-> The 2 other players still get this error message and I don't know why :-(


If any1 is interested in tracking this down or got an idea how to prevent this, or just finds out WHY this happens, I'd be really glad to get informed.

Thank you very much.

Last edited by Baertram : 05/08/15 at 06:25 AM.
  Reply With Quote
05/08/15, 09:06 AM   #2
Werewolf Finds Dragon
AddOn Author - Click to view addons
Join Date: Apr 2015
Posts: 17
My first step with this would be to test it in game by doing the following, if possible:

/script local label = GetControl(tabObject, "Text"); label:SetColor({255, 255, 255, 1.0})

If you know the tabObject exists, then that's going to give you some very interesting results, and possibly a way forward with how to proceed. I mean, depending on whether it's still nil or not.

Edit: If it doesn't return nil, it might have something to do with the timing of when the function is run. I've seen weird stuff like that in every lua-enabled game since WoW, where sometimes the passed along self object won't be fully initialised until X happens.
  Reply With Quote
05/08/15, 09:53 AM   #3
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,913
Thx for the ideas.
Unfortunately, in short: I already tested this :-(

-PreHooked the function that colors the tabs to see when it is nil
-Added debug chat messages
-Even now you can check the FCOChatTabBrain sources and will find many checks against ~= nil etc.
-About the not initialized part and time: As I wrote I even used zo_callLater to change the chat tab color later on after some MS, even after 2 seconds did not work.

Everytime I, with my client and pc, test if the tab control is there (I even have made it global to a FCOtest variable to see the contents etc. with ZGOO and used this one to change the color tab by help of /scripts), it is there.

So the code from ESO for the function colorizing the chat tabs looks like this:

Lua Code:
  1. function ZO_TabButton_Text_SetTextColor(self, color)
  2.     if(self.allowLabelColorChanges) then
  3.         local label = GetControl(self, "Text")
  4.         label:SetColor(color:UnpackRGBA())
  5.     end
  6. end

Line 571 is:
label:SetColor(color:UnpackRGBA())

The only two possibilities that might lead to a nil value error could be either:
-label is nil (checked this several times and it is even checked in my source code at the moment so it should never call this function if it is nil)
-the UnpackRGBA() function does not work as the color variable is nil
This color variable was checked too in my addon but currently I don't check it anymore.
for my pc, as sid above, it is always ~= nil

The color I'm using is: TAB_ALERT_TEXT_COLOR
So it might be this value.

It is defined in file \esoui\ingame\chatsystem\shardchatsystem.lua in line 39 as local variable:
local TAB_ALERT_TEXT_COLOR = ZO_SECOND_CONTRAST_TEXT

So this might be the problem then. But why don't I get an error, but others do?

I'll try to change the value in my addon to ZO_SECOND_CONTRAST_TEXT then to test it.
  Reply With Quote
05/08/15, 08:03 PM   #4
Werewolf Finds Dragon
AddOn Author - Click to view addons
Join Date: Apr 2015
Posts: 17
Wow. I have no idea then. All I can say is that that's bizarre and I empathise. I really hate it when problems like this arise. Perhaps poke that bloke from ZOS? ZOS_ChipHilseberg, I think? Maybe some smart person will figure this out.

But yes, that is... really, really strange. If no one can figure this out, poking Chip might actually be worth it.
  Reply With Quote
05/08/15, 11:24 PM   #5
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by Baertram View Post
It is defined in file \esoui\ingame\chatsystem\shardchatsystem.lua in line 39 as local variable:
local TAB_ALERT_TEXT_COLOR = ZO_SECOND_CONTRAST_TEXT
I get the exact same error and that is the cause, TAB_ALERT_TEXT_COLOR is local in their lua code so it does not exist.
Lua Code:
  1. ZO_TabButton_Text_SetTextColor(newTab, ZO_SECOND_CONTRAST_TEXT)
fixed it for me.

Originally Posted by Baertram View Post
So this might be the problem then. But why don't I get an error, but others do?
You must have some other addon that is doing something like:
Lua Code:
  1. TAB_ALERT_TEXT_COLOR = ZO_SECOND_CONTRAST_TEXT
which opens it up globally, that would be my guess.

Here are some other things I noticed while I was trying to figure out how to get it to work so I'll go ahead and thrown them in here too.

Also I noticed this duplicate code:
Lua Code:
  1. -- Line 4406-4407:
  2.     local switchToTab = chatChannelToTabs[messageType]["switchToTab"]
  3.     if switchToTab == nil then return end
  4.  
  5. -- Then on line 4429, same code:
  6.     local switchToTabIndex = chatChannelToTabs[messageType]["switchToTab"]
  7. ..
  8. -- And you check to see if its nil again, but if it was nil you would not have
  9. -- made it passed line 4407
  10.         if    settings.showChatTabColor
  11.           and switchToTabIndex ~= nil and ...

In the settings menu the following settings are missing the tooltip (doesn't look like it was intentional)
'Guild 4' Chat Tab
'Guild 5' Chat Tab
'Zone' Chat Tab
'Zone EN' Chat Tab (has a tooltip, but I don't think its what you wanted there)

One suggestion, change the instructions (tooltips) for all of those '.......' Chat Tab settings, the "Enable Automatic Chat Tab Switch", and the "Change Different Tab Color" settings. Maybe even put these two settings: "Enable Automatic Chat Tab Switch", and the "Change Different Tab Color" next to each other in the settings menu and mention that its one or the other...either it automatically changes tabs or it colorizes the tab, but not both...those settings overlap & block each other.

Here is why I suggest that:
It took me forever just to figure out how to get the chat tabs to change colors.
I didn't realize you have to enable the '.....' Chat Tab setting & then go turn off "Enable Automatic Chat Tab Switch", AND turn on "Change Different Tab Color". I thought just having "Change Different Tab Color" was enough to color the tabs and couldn't figure out why it didn't work :P

The tooltips for '.....' Chat Tab, say if you enable this setting it will automatically switch to the chat tab when you get a msg....so I didn't want to turn it on. I didn't want that, I just wanted it to change the color of the tab. It does not mention that it is also used for the chat tab coloring or that there is another setting "Enable Automatic Chat Tab Switch" that is required to be on to automatically change tabs and when its off it will just color the tabs instead (if "Change Different Tab Color" is turned on).


I would change it to something like this, then they can figure out how to turn ON/OFF the automatic tab switching & change tab color by reading the instructions on those settings:


Just a suggestion.

EDIT:
Actually, since these two settings overlap & block each other I think I'de combine them into one setting and just make it a drop down setting where they either select "Off", "Automatic Chat Tab Switch", or "Change Tab Color"

Last edited by circonian : 05/08/15 at 11:48 PM.
  Reply With Quote
05/11/15, 04:33 AM   #6
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,913
Thx for the review of the code and your sugestions circonian.
But you got it wrong

I didn't realize you have to enable the '.....' Chat Tab setting & then go turn off "Enable Automatic Chat Tab Switch", AND turn on "Change Different Tab Color". I thought just having "Change Different Tab Color" was enough to color the tabs and couldn't figure out why it didn't work :P
You must not turn off the automatic chat tab switch to see the colorization.
It depends on the inactivity timer of each chat channel.
You can get a new /guild1 message and you were 5 seconds (inactivity time for /guild1) not active at the chat (not moved the mouse inside, scrolled, wrote text, changed tabs, etc.):
The /guild1 chat tab opens up automatically if "Automatic chat tab switch" is activated.

You get a new /say message (at another chat tab) and you are currently active inside the chat window, but you did not activate the /say chat tab for 10 seconds (10 seconds = inactivity timer for /say channel):
You stay at the same chat tab (e.g. /guild1's tab) as you are doing something there, but the /say chat tab will chage it's color.

I'll check the settings and duplciates code, add some new color codes in the future and will reposition the settings so they are more obvious. I didn't like the current settings menu as well as it got bigger and bigger...
I'll see how to cope with it, as weather get's bad again
  Reply With Quote
05/11/15, 05:19 AM   #7
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by Baertram View Post
Thx for the review of the code and your sugestions circonian.
But you got it wrong
Oh, sorry....yeah I misunderstood what it was supposed to do. I thought it was supposed to color "other" tabs that you were not in if they received a message and I thought the inactivity time was for just being idle, not inactive "in that chat tab", I guess I didn't read that tooltip.

My mistake.

EDIT:
You must not turn off the automatic chat tab switch to see the colorization.
I'll throw this out here in case it wasn't supposed to do this, but the chat tabs did get colored when I disabled the "Automatic Tab Switching" & received a message in a chat tab that was not displayed, I think thats what threw me off...Or does the game do that on its own and I never noticed?

Last edited by circonian : 05/11/15 at 05:33 AM.
  Reply With Quote
05/11/15, 05:46 AM   #8
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,913
Whoops, I forgot that "must not" means something strikt in english. This was my fault hehe

I meant: You don't need to turn it off, but you can.
The tabs get colored as long as you enable that option.

Standard ESO is only coloring the chat tab for the "whisper messages" if you receive a new whisper message.

Edit:
And the inactivity time is a kind of prevention method so the chat tabs won't change to another one as you are currently reading the last incoming message.
You can set them to e.g. 5 seconds for guild messages or more frequent chat tabs and to something like 20 seconds for the /say or /zone chat. Depends on where you are more active.
The chat tabs won't change then if they were changed from last incoming mesasge and you are currently reading the last message or answering (or are on your way to answer).
Otherwise each new message would cycle the chat tabs and you would just see them flapping away after each other without beeing able to read a single word

Last edited by Baertram : 05/11/15 at 05:48 AM.
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » FCOChatTabBrain - Error with colorizing chat tab headers

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