ChatBlade How To Documentation
How To Hook Up a Text Window to ChatBlade

Related ChatBlade Classes and functions:  
    CBTextWindowData
    CBChatMessage
    CBClientImplementation::OnMessageAddedToTextWindow()

 
Summary:  
  Jump to section   Call CBData::AddTextWindowData(nTextWindowID) once for each Text Window or Chat Tab displayed in the Game.  
  Jump to section Add Chat Channels to Monitor for the Text Window via CBTextWindowData::AddChannelID(nTextWindowID, nChannelID).  
  Jump to section Implement CBClientImplementation::OnMessageAddedToTextWindow() so that the GUI Text Window knows when a Chat Message has been added.  
  Jump to section When a Chat Message is received get the Chat Message via CBTextWindowData::GetLastChatMessage() and display its text.  
  Jump to section Implement the ability for Players to set which Chat Channels to Monitor.  
  Jump to section For Hyperlinking, modify the Text Window to remove Chat Hyperlink tags and add in clickable Hyperlink functionality.  
ChatBlade mandates that each Text Window/Chat Tab have a unique ID.  

 
Details:  
 
Call CBData::AddTextWindowData(nTextWindowID) once for each Text Window or Chat Tab displayed in the Game.  
     Each GUI Text Window or Chat Tab needs to have a unique int ID.  
Each GUI Text Window has a related CBTextWindowData instance that keeps track of its Chat Messages and which Chat Channels the Text Window should Monitor.  
To create this instance in ChatBlade developers should call  CBData::AddTextWindowData(nTextWindowID) once for each GUI Text Window or Chat Tab in the Game.  
The instance created by this call is stored in CBData::mTextWindowDataMap and is keyed via the Text Window ID.  
It can be accessed via CBData::mTextWindowDataMap[nTextWindowID].  
Sample Code:  
 
Add Chat Channels to Monitor for the Text Window via CBTextWindowData::AddChannelID(nTextWindowID, nChannelID).  
     The CBTextWindowData instance which is assisting a GUI Text Window keeps track of which Chat Channels the Text Window should Monitor.   
Initially each Text Window is not Monitoring any Chat Channels.  Developers shall need to add in the Chat Channel IDs of Chat Channels the Text Window should Monitor.   
This can be done via the static CBTextWindowData::AddChannelID(nTextWindowID, nChannelType) which adds in a single Chat Channel.  
ChatBlade has created some Helper functions which add in specific groups of Chat Channels.  Developers may invoke such functions as CBTextWindowData::AddAllCombatChannelIDs() or CBTextWindowData::AddCombatHealingChannelIDs().  See CBTextWindowData.  
To access the non static members of CBTextWindowData one would need to get the correct instance.  This can be done like so:  CBData::mTextWindowDataMap[nTextWindowID]
For Example:  CBData::mTextWindowDataMap[nTextWindowID].AddAllChannelIDs() would add in all the Chat Channels to those Monitored by the specified Text Window.  
Sample Code:  
 
Implement CBClientImplementation::OnMessageAddedToTextWindow() so that the GUI Text Window knows when a Chat Message has been added.  
     ChatBlade shall call CBClientImplementation::OnMessageAddedToTextWindow(nGUITextWindowID) each time a Chat Message is added to an underlying CBTextWindowData instance.  It shall pass in the Text Window ID of the Text Window which has received a new Chat Message.  
Developers should implement CBClientImplementation::OnMessageAddedToTextWindow(nGUITextWindowID) and have it call into the Games GUI Text Window and inform it that its contents have changed.  
Sample Code:  
 
When a Chat Message is received get the Chat Message via CBTextWindowData::GetLastChatMessage() and display its text.  
     When a Text Window/Tab receives a new Chat Message the Text Window should get the text out of the Chat Message and display that Chat if the Text Window or Chat Tab is viewable.  
GUI Text Windows can get the latest Chat Message by calling the static CBTextWindowData::GetLastChatMessage(nTextWindowID,cbcmChatMessage).  
The Text Window can get the Chat Text out of the Chat Message in a few ways.  If the Text Window wants all the Hyperlink Tags which may be in a Chat Message they should call cbcmChatMessage.GetChatStringWithHyperlinks(sChatString).  If the Hyperlink Tags should be left off they can get the text via cbcmChatMessage.GetChatString(sChatString).  
If Hyperlink Tags are included in the text, the GUI Text Window needs to remove the Tags before display.  ChatBlade Hyperlinks with tags look like so:  href=1T3M1D<Item Name>.  Without Tags only the Item Name portion is returned.  
ChatBlade also provides a couple static functions to retrieve all the Chat Text of a Text Window via CBTextWindowData::GetAllChatTextWithHyperlinkTags(nTextWindowID , sChatText) and CBTextWindowData::GetAllChatText(nTextWindowID, sChatText ).  
Sample Code:  
 
Implement the ability for Players to set which Chat Channels to Monitor.  
     Each Text Window/Chat Tab has a related CBTextWindowData instance that keeps track of which Chat Channels the Text Window should Monitor.  
A Game typically would supply a GUI Dialog to allow Players to specify which Chat Channels a Text Window should Monitor.  
Game Developers would need to implement the GUI Dialog portion.  They would then call ChatBlade functions and enable those Chat Channels which the Player specifies.  
It is envisioned that Developers can first clear all the Chat Channels being monitored by invoking the static CBTextWindowData::ClearChannelIDs(int nTextWindowID).  
Individual Chat Channels the Player has selected can be added via the static CBTextWindowData::AddChannelID(nTextWindowID, nChannelType).  
If the GUI Dialog groups up Chat Channels, entire groups of Chat Channels can be added like so:  CBData::mTextWindowDataMap[nTextWindowID].AddCombatMeleeChannelIDs().  
Sample Code:  
 
For Hyperlinking, modify the Text Window to remove Chat Hyperlink tags and add in clickable Hyperlink functionality.  
     ChatBlade includes Hyperlink support in Chat Messages.  
Hyperlinks allow Players to click on items in a Chat Message and typically pop up an examine window in the UI with the stats of the item clicked upon.  This is very useful for Auctioning, or to see what items showed up in Group loot.  
For Hyperlinks to function, Chat Text Windows shall need to be programmed to remove Hyperlink tags from Chat Messages and just display the Link text (typically in an alternate text color).  
The Game UI must also allow Players to click on the Hyperlink text in Chat Messages to bring up information on the item click on.  
ChatBlade starts Hyperlinks with a special text tag (CB_HYPERLINK_INDICATOR ("href=")).  After the tag should come an ITEMID specific to the item being linked, then the displayable Text of the link, surrounded by angle brackets ('<', '>').  
A sample Chat Hyperlink might look like href=IB38472C<Sword of Thunder>.  
A UI Text Window should be designed to strip out the href=IB38472C<> parts and only display the clickable text "Sword of Thunder".  Clicking on "Sword of Thunder" might do a database lookup of item IB38472C and display its stats to the User.  
The Text window should be designed to support multiple Hyperlinks in one Chat Message.  
Editing of the Text portion of a Hyperlink should be disallowed or remove the entire Hyperlink.  
ChatBlade internally puts each Hyperlink as a separate entry of CBChatMessage::vMessagePartsArray.  
ChatBlade ensures that Hyperlinks are not altered by Intoxicated speech or in-game artificial Languages.  
No Sample Code provided.  
 

Code Samples:  

Creating a Text Window Data instance in ChatBlade with an ID of 1:  
     CBData::AddTextWindowData(1);
 
Adding initial Chat Channels to Monitor to Text Window 1:  
     CBTextWindowData::AddChannelID(1, CB_CHANNEL_AUCTION);
CBTextWindowData::AddChannelID(1, CB_CHANNEL_OOC);
CBData::mTextWindowDataMap[1].AddAllCombatChannelIDs();
 
Implementing CBClientImplementation::OnMessageAddedToTextWindow(int nGUITextWindowID): 
     int CBClientImplementation::OnMessageAddedToTextWindow(int nGUITextWindowID)
     {
//  Assuming a Developer created function
return(CDevelopersGameGUI::OnTextAddedToGUIWindow(nGUITextWindowID));
}
 
Displaying the text of the latest Chat Message:
     int CDevelopersGUITextWindow::OnTextAdded()
     {
CBChatMessage cbChatMessageCopy;
CBSTRING sCompleteTextString;
CBSTRING sTempString;
 
if(CBTextWindowData::GetLastChatMessage(nTextWindowID, cbChatMessageCopy) == CB_ERROR_DOES_NOT_EXIST)
  {
  //  There are no Chat Messages
  sCompleteTextString = CB_EMPTY_STRING;
  }
else
   {
//  Get the Chat Text from our newest Chat Message
cbChatMessageCopy.GetChatString(sTempString);
//  Get the previous text that is currently in the Text Window
GetWindowText(sCompleteTextString);  //  Assuming the GUI Text Window has a similar function
//  Add the latest line
sCompleteTextString += sTempString;
}
//  Set the new Window text
SetWindowText(sCompleteTextString);  //  Assuming the GUI Text Window has such a function
return(CB_SUCCESS);
}
 
Implementing a GUI Dialog to allow Players to choose which Chat Channels Text Window 1 should Monitor.  
Lets assume the user has selected Group, Guild, Raid, Alliance, and Tells to go into Text Window 1.  
     //  Clear out any existing Chat Channels that had been Monitored
CBTextWindowData::ClearChannelIDs(1);
//  Add in our selected Chat Channels
CBTextWindowData::AddChannelID(1, CB_CHANNEL_GROUP);
CBTextWindowData::AddChannelID(1, CB_CHANNEL_GROUP_PRIORITY);
CBTextWindowData::AddChannelID(1, CB_CHANNEL_GUILD);
CBTextWindowData::AddChannelID(1, CB_CHANNEL_GUILD_PRIORITY);
CBTextWindowData::AddChannelID(1, CB_CHANNEL_GUILD_OFFICER);
CBTextWindowData::AddChannelID(1, CB_CHANNEL_RAID);
CBTextWindowData::AddChannelID(1, CB_CHANNEL_RAID_PRIORITY);
CBTextWindowData::AddChannelID(1, CB_CHANNEL_ALLIANCE);
CBTextWindowData::AddChannelID(1, CB_CHANNEL_ALLIANCE_PRIORITY);
CBTextWindowData::AddChannelID(1, CB_CHANNEL_TELL);
CBTextWindowData::AddChannelID(1, CB_CHANNEL_CUSTOMER_SERVICE_TELL);
    

 

 
 
 
 
ChatBlade Copyright Flex Dolphynn