ChatBlade How To Documentation
How To Hook Up an Edit Field to ChatBlade

Related ChatBlade Classes and functions:  
    CBEditFieldData
    CBChatHandler
    CBData

 
Summary:  
  Jump to section   Call CBData::AddEditFieldData(int nEditFieldID) once for each Chat related Edit Field in the Game.  
  Jump to section Call CBChatHandler::OnLineEntered() when the Player types in a line of Chat.  
  Jump to section Hook up the Chat History by calling CBEditFieldData::OnUpArrow() and CBEditFieldData::OnDownArrow() when the user wants to repeat previously entered Chat.  
  Jump to section Add in a GUI mechanism to allow the Player to change the Default Slash Command for an Edit Field and call CBEditFieldData::SetDefaultSlashCommmand() to set the Default Slash Command.  
  Jump to section For Hyperlinking, allow the Players to Hyperlink items in Chat Messages.  
Note:  Each GUI Edit Field in the Game should have a related CBEditFieldData instance which keeps track of the Edit Fields Chat History and Default Slash Command.  
ChatBlade mandates that each GUI Edit Field have a unique ID.  

 
Details:  
 
Call CBData::AddEditFieldData(int nEditFieldID) once for each Chat related Edit Field in the Game.  
     Each GUI Edit Field needs to have a unique int ID.  
Each GUI Edit Field should have a related CBEditFieldData instance to assist it and keep track of its Chat History and Default Slash Command.  
The CBEditFieldData instance is created by ChatBlade in response to a call to CBData::AddEditFieldData(int nEditFieldID).  
Developers should call the static CBData::AddEditFieldData(nEditFieldID) once for each Chat related Edit Field.  
A Map of all the CBEditFieldData instances is stored in CBData::mEditFieldDataMap and is keyed via the Edit Field ID.  
Developers can retrieve the CBEditFieldData instance like so:  CBData::mEditFieldDataMap[nEditFieldID], which would return the CBEditFieldData instance associated with the specified nEditFieldID.  
Sample Code:  
 
Call CBChatHandler::OnLineEntered() when the Player types in a line of Chat.  
     When a Player types in a line of Chat, the Game should pass the text entered into ChatBlade by calling CBChatHandler::OnLineEntered(sText, nEditFieldID).  
ChatBlade shall process this line of Text by doing the following:  
     Adds the line of Text to the Chat History of the specified Edit Field.  
Expands any Quick Command character the line of Text may start with (!,@,#, etc.  )
Prepends the Default Slash Command for any lines which do not start with a Slash Command.  
Expands any Aliases found into the associated Slash Command.  
Expands any %Macros found in the line of Text
Processes the Slash Command of the line of Text and passes control onto the correct OnCommandXXX() function of CBSlashCommands.  
Sample Code:  
 
Hook up the Chat History by calling CBEditFieldData::OnUpArrow() and CBEditFieldData::OnDownArrow() when the user wants to repeat previously entered Chat.  
     ChatBlade allows Players to easily repeat previously entered in lines of Chat.  This functionality is referred to as the Chat History.  
Each time a Player types in a line of Chat, ChatBlade stores this line in the Chat History of the CBEditFieldData instance that is assisting the GUI Edit Field that produced the line of Chat.  
Players can typically retrieve any previously entered in Chat text by pressing the Up Arrow key or Down Arrow key while a GUI Edit Field has focus.  
Doing so should replace whatever text is in the Edit Field with a line of Text retrieved from the Chat History.  
Developers should call the static functions CBEditFieldData::OnUpArrow(nEditFieldID) and CBEditFieldData::OnDownArrow(nEditFieldID) and use their CBSTRING return values as the new replacement text that should be placed into the GUI Edit Field.  
Calling these functions multiple times allows the Player to cycle through previously entered lines of Chat.  
ChatBlade keeps track of where a Player is in the Chat History and resets this back to the newest line once a Player actually hits Enter and sends a line of Chat to ChatBlade.  
Sample Code:  
 
Add in a GUI mechanism to allow the Player to change the Default Slash Command for an Edit Field.  
     Each GUI Edit Field can have a different Default Slash Command that is prepended to lines of Chat which do not already start with a Slash Command.  
For Example: One GUI Edit Field may always default to "/group" while another might default to "/guild", or "/tell Irridia,".  
Initially all CBEditFieldData instances use "/say" as their Default Slash Command (actually they use the special case "/CBSAY" which is equivalent to "/say").    
Generally a Game shall provide some GUI mechanism to allow the Player to set the Default Slash Command for each GUI Edit Field.  
Preferably this mechanism is a free-form Edit area where the Player can type in any Slash Command desired to be the Default.  
Alternatively the Game Developers can hard-code a drop down list of possible choices such as Group, Guild, Auction, Say, OOC, etc.  This style of choosing a Default Slash Command is more limiting to the Player though.  
Regardless of which mechanism is used, Developers should then call the static  CBEditFieldData::SetDefaultSlashCommmand(nEditWindowID, sDefaultCommandString).  
In cases where the GUI uses Chat Tabs which share a single GUI Edit Field, Developers may call CBEditFieldData::SetDefaultSlashCommmand() each time the Player changes focus to a new Chat Tab.  
ChatBlade shall prepend the Default Slash Command to any lines of Chat entered from a GUI Edit Field which do not already start with a Slash Command.  
Sample Code:  
 
For Hyperlinking, allow the Players to Hyperlink items in Chat Messages.  
     Most MMORPGS allow Players to Hyperlink items in Chat Messages and send those Chat Messages to other Players, allowing them to click on the Hyperlink and see the stats of the item linked.  
Game UIs need a mechanism to allow Players to Hyperlink items.  Preferably a Game shall allow Players to drag and drop and item from their inventory to the Chat Edit Field and have it create a Hyperlink.  
Game Developers shall need to add this functionality to their UI.  
A Hyperlinked item should be in a special format and start with "href=" and an ITEMID of the item linked, followed by the clickable name of the items surrounded by angle brackets ('<','>').  
A sample Chat Hyperlink might look like href=IB38472C<Sword of Thunder>.  
A UI Edit Field should be designed to add in this Hyperlink Text to the Edit Field when a User wants to Hyperlink an item.  
A UI Edit Field 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.  
A UI Edit Field 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 Edit Field Data instance in ChatBlade with an ID of 1: 
     CBData::AddEditFieldData(1);
 
Passing a Player entered line of Chat to ChatBlade from Edit Field 1:  
     //  In response to a Return Key Up notification
//  Get the text out of the GUI Edit Field
GetWindowText(sChatLine);  //  Assuming the GUI Edit Field has a similar command
//  Clear out the text in the Edit Field
SetWindowText("");  //  Assuming the GUI Edit Field has a similar command
//  Pass the line of Chat to ChatBlade
CBData::pChatHandler->OnLineEntered(sChatLine, 1);
 
Implementing Chat History for Edit Field 1:  
//  In response to an Up Arrow Key Up notification when the Edit Field has focus
SetWindowText(CBEditFieldData::OnUpArrow(1));  //  Assuming the GUI Edit Field has a similar command
//  In response to a Down Arrow Key Up notification when the Edit Field has focus
     SetWindowText(CBEditFieldData::OnDownArrow(1);  //  Assuming the GUI Edit Field has a similar command
 
Setting the Default Slash Command of Edit Field 1 to /guild:  
     CBEditFieldData::SetDefaultSlashCommmand(1, "/guild");
 

 

 

 

 

 

 
 
 
 
ChatBlade Copyright Flex Dolphynn