Different font colours for different chat channels.
by C. N. · in Torque Game Engine · 07/03/2008 (2:33 pm) · 2 replies
Hi,
How's everybody doing?
I've been trying to do something for more than few days now and it's driving me batty. :)
All I'm trying to do is show that a chat message is a general, team or private chat by having the text appear as a different colour for each.
I have produced some results with the below code, but it doesn't seem to affect much. I know I must have the text control that's attached to the GuiMessageVectorCtrl wrong?
EDIT: I believe it's something like: myTextControl -> MessageVector -> GuiMessageVectorCtrl (?)
// code **********************************************
if(%this.isGeneralMsg) {
MessageHud_Text.profile = "GeneralTextProfile"; // switch profile based on channel (not proper way?)
%text = "GLOBAL:";
}
else if(%this.isTeamMsg) {
MessageHud_Text.profile = "TeamTextProfile"; // switch profile based on channel (not proper way?)
%text = "TEAM:";
}
else if(%this.isPrivateMsg) {
MessageHud_Text.profile = "PrivateTextProfile"; // switch profile based on channel (not proper way?)
%text = "WHISPER:";
}
// end code **********************************************
etc... This works, but only on one of the fields.
Then I saw this profile:
// code **********************************************
new GuiControlProfile ("ChatHudMessageProfile")
{
fontType = "Arial";
fontSize = 16;
fontColor = "250 20 20";// "44 172 181"; // default color (death msgs, scoring, inventory)
fontColors[1] = "150 150 150"; // client join/drop, tournament mode
fontColors[2] = "50 50 225"; // gameplay, admin/voting, pack/deployable
fontColors[3] = "50 225 50"; // 77 253 95 team chat, spam protection message, client tasks
fontColors[4] = "225 50 50"; // global chat 40 231 240
fontColors[5] = "200 200 50 200"; // used in single player game
// WARNING! Colors 6-9 are reserved for name coloring
autoSizeWidth = true;
autoSizeHeight = true;
};
// end code **********************************************
So it looks like TGE already has different text colours built in for different chat situations. My question is this: How do I access the colour info in the fontColors[n] array? TGE seems to know if it was a TEAM chat or GENERAL chat but I can't find out where it's doing the check.
Sorry to be a bother for something that should be a simple matter. I very much appreciate any advice.
One last thing I'm confused about is the difference between the custom profiles with quotes and without:
// code **********************************************
new GuiControlProfile("WithQuotesGuiProfile"){}
// and
new GuiControlProfile(NoQuotesGuiProfile){}
// end code **********************************************
Would anybody know what the difference is?
Much thanks.
Chris.
How's everybody doing?
I've been trying to do something for more than few days now and it's driving me batty. :)
All I'm trying to do is show that a chat message is a general, team or private chat by having the text appear as a different colour for each.
I have produced some results with the below code, but it doesn't seem to affect much. I know I must have the text control that's attached to the GuiMessageVectorCtrl wrong?
EDIT: I believe it's something like: myTextControl -> MessageVector -> GuiMessageVectorCtrl (?)
// code **********************************************
if(%this.isGeneralMsg) {
MessageHud_Text.profile = "GeneralTextProfile"; // switch profile based on channel (not proper way?)
%text = "GLOBAL:";
}
else if(%this.isTeamMsg) {
MessageHud_Text.profile = "TeamTextProfile"; // switch profile based on channel (not proper way?)
%text = "TEAM:";
}
else if(%this.isPrivateMsg) {
MessageHud_Text.profile = "PrivateTextProfile"; // switch profile based on channel (not proper way?)
%text = "WHISPER:";
}
// end code **********************************************
etc... This works, but only on one of the fields.
Then I saw this profile:
// code **********************************************
new GuiControlProfile ("ChatHudMessageProfile")
{
fontType = "Arial";
fontSize = 16;
fontColor = "250 20 20";// "44 172 181"; // default color (death msgs, scoring, inventory)
fontColors[1] = "150 150 150"; // client join/drop, tournament mode
fontColors[2] = "50 50 225"; // gameplay, admin/voting, pack/deployable
fontColors[3] = "50 225 50"; // 77 253 95 team chat, spam protection message, client tasks
fontColors[4] = "225 50 50"; // global chat 40 231 240
fontColors[5] = "200 200 50 200"; // used in single player game
// WARNING! Colors 6-9 are reserved for name coloring
autoSizeWidth = true;
autoSizeHeight = true;
};
// end code **********************************************
So it looks like TGE already has different text colours built in for different chat situations. My question is this: How do I access the colour info in the fontColors[n] array? TGE seems to know if it was a TEAM chat or GENERAL chat but I can't find out where it's doing the check.
Sorry to be a bother for something that should be a simple matter. I very much appreciate any advice.
One last thing I'm confused about is the difference between the custom profiles with quotes and without:
// code **********************************************
new GuiControlProfile("WithQuotesGuiProfile"){}
// and
new GuiControlProfile(NoQuotesGuiProfile){}
// end code **********************************************
Would anybody know what the difference is?
Much thanks.
Chris.
About the author
#2
I thought that the \c1, \c2, etc was for colouring the console output only. I'm going to try that solution immediately.
Thanks a lot for the help, Gary.
Chris.
07/04/2008 (9:37 am)
Ah!I thought that the \c1, \c2, etc was for colouring the console output only. I'm going to try that solution immediately.
Thanks a lot for the help, Gary.
Chris.
Torque Owner Gary Preston
ChatHud.addLine("\c1This is one colour\c2This is another\c3and this is a third");There's also the option to push/pop and reset the colour using \cp \co and \cr. If you need any further mark-up, you can always consider switching to the MLTextCtrl.
As for where the check for Team takes place, have a look in message.cs. It has the various chat message functions for teams, clients, all...