ChatBlade How To Documentation
How To Load the Slash Commands typed Interface

Related ChatBlade Classes and functions:  
    CBClientImplementation
    CBSampleImplementation
    CBData
    CBCommandMap
    CBSlashCommands
    SlashCommands.XML

 
Summary:  
  Jump to section   Implement CBClientImplementation::LoadSlashCommands().  
  Jump to section Create a CBCommandMap instance for each OnCommandXXX() function in CBSlashCommands.  
  Jump to section Add the Function Pointer of the OnCommandXXX() function to the CBCommandMap instance via CBCommandMap::SetPointer().  
  Jump to section Add in the typed out Slash Commands that invoke the function to the CBCommandMap instance via CBCommandMap::AddAlias().  
  Jump to section Add each CBCommandMap instance to ChatBlade via CBData::AddCommandMap().  
  Jump to section Preferably allow the Players to modify the Slash Command interface.  
 

 
Details:  
 
Implement CBClientImplementation::LoadSlashCommands().  
     The Loading of the Slash Command interface should take place in CBClientImplementation::LoadSlashCommands().  
ChatBlade shall call this function from CBChatHandler::InitializeChat() via CBChatHandler::InitializeSlashCommands().  
Developers should implement CBClientImplementation::LoadSlashCommands().  
An example of an implementation that uses a Player Modifiable XML file to store the Slash Command interface is included in CBSampleImplementation::LoadSlashCommands().  
See CBSampleImplementation.cpp and SlashCommands.XML.  
Sample Code:  
 
Create a CBCommandMap instance for each OnCommandXXX() function in CBSlashCommands.  
     The OnCommandXXX() function pointer and the typed out Slash Commands which invoke that function are stored in a CBCommandMap instance.  
For each OnCommandXXX() function in the game create a CBCommandMap instance that shall hold the function pointer and the text Slash Commands for that function.  
A single CBCommandMap instance can be reused if CBCommandMap::Clear() is called in between each use.  
Sample Code:  
 
Add the Function Pointer of the OnCommandXXX() function to the CBCommandMap instance.  
     Add a single Function Pointer to a CBCommandMap instance via CBCommandMap::SetPointer().  
ChatBlade maintains a list of all the OnCommandXXX() function pointers in the static Map CBData::mCommandFunctionPointerMap.  
This STL Map is keyed via the UPPERCASE name of the OnCommandXXX() Function.  
So to add the Function Pointer of CBSlashCommands::OnCommandSay() one might use CBCommandMap::SetPointer(CBData::mCommandFunctionPointerMap["ONCOMMANDSAY"]);
CBData::mCommandFunctionPointerMap is a helper Map designed to provide a centralized list of Function Pointers for use in implementing CBClientImplementation::LoadSlashCommands().  
Sample Code:  
 
Add in the typed out Slash Commands that invoke the function to the CBCommandMap instance.  
     After adding in the Function Pointer, the typed out Slash Commands that should invoke that Function should be added to the CBCommandMap instance.  
While each CBCommandMap instance may only contain 1 Function Pointer, they may contain an unlimited amount of Player typed Slash Commands which invoke that Function.  
Add each typed Slash Command to the CBCommandMap instance using the CBCommandMap::AddAlias() function.  Repeat for each Alias.  
For Example OnCommandAnon() might have 2 Slash Commands the Player can type to invoke it:  "/anon", or "/anonymous".  
Each Slash Command added should start with a '/' character.  
Each Slash Command should consist of a single word with no spaces.  
Case is not important.  
Sample Code:  
 
Add a copy of each CBCommandMap instance to ChatBlade via CBData::AddCommandMap().
     After the CBCommandMap has both an OnCommandXXX() function pointer and a list of Slash Commands added to it, a copy of it should be added to ChatBlade.  
Add a copy of the CBCommandMap instance to ChatBlade via the CBData::AddCommandMap() function.  
Repeat for each CBCommandMap instance.  The same instance may be reused if CBCommandMap::Clear() is called after each addition.  
ChatBlade stores an array of all the CBCommandMaps in CBData::vCommandMapArray.  
When a Player types in a Slash Command, ChatBlade shall cycle through the CBData::vCommandMapArray vector looking for a Match to the typed Slash Command.  
When ChatBlade finds a match, it shall invoke the Function Pointer stored in the found CBCommandMap instance and call the corresponding OnCommandXXX() function, passing it any parameters supplied by the Player.  
Sample Code:  
 
Preferably allow the Players to modify the Slash Command interface.  
     To Date, all MMOGs have had a hard-coded Slash Command interface, dictated by the Game Developer.  
Some Developers use "/g" to talk in Group Chat, while others might use "/p" or "/t" to do the same thing.  
This can be very frustrating to the Player Base which has become accustomed to the Slash Commands used in previously played MMORPGs.  
One of ChatBlades most innovative features is the ability to allow the Player to customize the Slash Command interface.  
This requires that Game Developers support this functionality.  
ChatBlade ships with sample code demonstrating the loading of the Slash Commands interface via a Player editable XML File.  This allows the Players to configure the Slash Command interface as they see fit, and can modify it to conform to whatever they are accustomed to.  
See CBSampleImplementation.cpp and SlashCommands.XML
If the Game Developer does not wish to use an XML implementation, some other mechanism should be provided for the Players to allow them to alter the Slash Command interface.  GUI Dialog components might be created to allow for this.  
ChatBlade also supports hard-coding of the Slash Command interface.  While this is very easy to implement, it is not optimal from the Players point of view.  
Sample Code:  
 

 

Code Samples:  

See CBSampleImplementation.cpp  and SlashCommands.XML for a complete sample of LoadSlashCommands() using an XML file.  
 
Creating a CBCommandMap instance to hold our Function Pointer and Slash Commands which invoke the Pointer.  
     CBCommandMap  cbcmCommandMap;
 
Adding the function pointer for CBSlashCommands::OnCommandTell() to the CBCommandMap instance.  
     cbcmCommandMap.SetPointer(CBData::mCommandFunctionPointerMap["ONCOMMANDTELL"]);
 
Adding the Player typed out Slash Commands which should invoke OnCommandTell().  
     cbcmCommandMap.AddAlias("/TELL");
cbcmCommandMap.AddAlias("/SEND");
cbcmCommandMap.AddAlias("/T");
cbcmCommandMap.AddAlias("/WHISPER");
cbcmCommandMap.AddAlias("/W");
cbcmCommandMap.AddAlias("/PRIVATE");
cbcmCommandMap.AddAlias("/MSG");
 
Adding the CBCommandMap instance to ChatBlade.  
     CBData::AddCommandMap(cbcmCommandMap);
//  Clearing out this instance so that it may be used for the next OnCommandXXX() function
cbcmCommandMap.Clear();
 
    

 

 

 

 

 

 
 
 
 
ChatBlade Copyright Flex Dolphynn