ChatBlade SDK Documentation

Class   CBData
Header   CBData.h

Data    Member Summary    Member Details


Information 

CBData is a class that is designed to hold Static data elements that can be accessed by all of ChatBlades Classes.  
 
All the members of CBData are static and are the equivalent of Scoped Globals.  
They can be referenced by using the Class name, such as CBData::pChatHandler.  
 
CBData::pChatHandler is an important member of this class.  It gives access to our CBChatHandler instance.  
CBData::mTextWindowDataMap contains a Map of all the CBTextWindowData instances where all Chat Messages are stored.  
 
CBData contains a pointer to our CBChatHandler instance, as well as Maps of our CBTextWindowData and CBEditFieldData instances.  In addition, an array of all of ChatBlades Command Maps is stored here as well as information relating to /tells and AFK/DND settings.  
CBData also contains a few static functions which act upon the Data members.  
 
An instance of CBData does not need to be instantiated.  All members are Static.  
 
 

Game Developer Implementation:  

CBData provides a class that can be used to house data that needs to be Globally accessible.  
 
For each Edit Field in the GUI, Developers should call CBData::AddEditFieldData() with the ID of the Edit Field.  
ChatBlade shall keep track the Chat History and default Slash Command for each Edit field via the related CBEditFieldData instance that CBData::AddEditFieldData() creates.  
The CBEditFieldData instance is stored in the Map CBData::mEditFieldDataMap, and an individual instance can be accessed by providing the ID of the Edit Field as the key, like so:  CBData::mEditFieldDataMap[nEditFieldID].  
 
For each Text Window or Tab in the GUI, Developers should call CBData::AddTextWindowData() with the ID of the Text Window or Tab.   
ChatBlade shall keep track the Chat Messages and Chat Channels to Monitor for each Text Window/Tab via the related CBTextWindowData instance that CBData::AddTextWindowData() creates.  
The CBTextWindowData instance is stored in the Map CBData::mTextWindowDataMap, and an individual instance can be accessed by providing the ID of the Text Window/Tab as the key, like so:  CBData::mTextWindowDataMap[nTextWindowID].  
Typically after creating a CBTextWindowData instance via CBData::AddTextWindowData(), Developers should immediately add in what Chat Channels the related Text Window should initially monitor. This can be done like so:  
CBData::mTextWindowDataMap[nTextWindowID].AddAllChannelIDs() or 
CBData::mTextWindowDataMap[nTextWindowID].AddChannelID(CB_CHANNEL_GROUP) or 
via other AddChannelXXX() functions from CBTextWindowData.   
 
The CBTextWindowData instances contained in CBData::mTextWindowDataMap are where ChatBlade stores all the Games Chat Messages.  When a new Chat Message is added to one of these instances, ChatBlade shall call CBClientImplementation::OnMessageAddedToTextWindow() with the ID of the Chat Window that the message was added to.  CBClientImplementation::OnMessageAddedToTextWindow() should then call the Text Window and inform it that it should redraw its contents.  
The Contents of the Text Window are contained in the CBTextWindowData instance referred to by CBData::mTextWindowDataMap[nTextWindowID].  
To access the text of last Chat Message added, the Code may look something like:  
    nMessageDequeSize = CBData::mTextWindowDataMap[nTextWindowID].dqMessageArray.size();
    CBData::mTextWindowDataMap[nTextWindowID].dqMessageArray[nMessageDequeSize-1].GetChatString(sTempString);
This would fill sTempString (a CBSTRING instance) with the Text contained in the last Chat Message added to this Text Window.  
See the ChatBlade Sample GUI Test Application (CBMFCTestClient) for more complete sample code of how to access the Chat Messages a Text Window should display.  
 
If a User modifies their Game UI and removes Chat Windows or Chat Tabs then the game should invoke CBData::RemoveTextWindowData() and CBData::RemoveEditFieldData() as appropriate.  
 
CBData contains a list of all Characters that have given this Player a /tell this session.  It is contained in CBData::vTellerNamesSet.  ChatBlade does not make use of this information, but it is provided to the Game Developers in case they want to make a GUI drop down list of all Characters the Player can /reply to.  
 
CBData contains a helper Map of all the Slash Command function pointers as indexed by the UPPERCASE function name in CBData::mCommandFunctionPointerMap.  Developers may want to use this Map when implementing CBClientImplementation::LoadSlashCommands().  
 
ChatBlade automatically takes care of most /AFK and /DND (Do Not Disturb) functionality.  
 
 

Source File Comments:  

// CBData is a class designed to hold static data members needed by the ChatBlade system
// Most members shall be static and therefore accessible to various other ChatBlade classes as if they were globals
 
// CBData also holds some related functions which act upon the static data
// Examples of data include an AFK flag, and the Character Name of the last person to send this client a private Tell (used for Reply)
 

Data:  

static CBChatHandler * CBData::pChatHandler
        A Pointer to our CBChatHandler instance.  
static int CBData::bAFKFlag
        Flag indicating if the Character is Away From the Keyboard.  
static CBSTRING CBData::sAFKString
        String representing the automatic /Reply value to a /Tell if the Character is AFK.  
static int CBData::bDNDFlag
        Flag indicating if the Character is in Do Not Disturb mode.  
static CBSTRING CBData::sDNDString
        String representing the automatic /Reply value to a /Tell if the Character is DND.  
static int CBData::nCurrentMoodID
        The value of the Characters current MoodID.  
static int CBData::nCurrentLanguageID
        The value of the Characters current in-game LanguageID.  
static CBSTRING CBData::sNameOfLastTeller
        The Name of the last Character to send this Player a private /Tell.  Used for /Reply.  
static CBSTRING CBData::sDestinationOfLastOutgoingTell
        The name of the last Character this Player sent a Tell to.  Used for /Retell.  
static std::set<CBSTRING> CBData::vTellerNamesSet
        A set of Names from all Characters to give this Player a Tell.  Not use by ChatBlade.  
static std::map<int, CBEditFieldData> CBData::mEditFieldDataMap
        A map of our CBEditFieldData helper classes.  Keyed via the ID of the associated GUI edit field.  
static std::map<int, CBTextWindowData> CBData::mTextWindowDataMap
        A map of our CBTextWindowData helper classes.  Keyed via the ID of the associated GUI text window.  All Chat Messages are stored in the instances contained in this Map.  
static std::vector<CBCommandMap> CBData::vCommandMapArray
        An array of our CBCommandMap instances.  ChatBlade uses this array to find a matching function for a typed Slash Command.  
static std::map<CBSTRING, ONCOMMANDFUNCTION> CBData::mCommandFunctionPointerMap
        A helper Map of our ONCOMMANDFUNCTION function pointers.  Keyed via the UPPERCASE name of the Function.  
 

Member Function Summary:  

            CBData()
        Constructor.  
static int  AddEditFieldData(int nEditFieldID)
        Static function which adds a CBEditFieldData instance to the mEditFieldDataMap.  Should be called once for each GUI Edit Field.  
static int  AddTextWindowData(int nTextWindowID)
        Static function which adds a CBTextWindowData instance to the mTextWindowDataMap.  Should be called once for each GUI Text Window or Tab.  
static int  RemoveEditFieldData(int nEditFieldID)
        Static function which removes a CBEditFieldData instance from the mEditFieldDataMap.  
static int  RemoveTextWindowData(int nTextWindowID)
        Static function which removes a CBTextWindowData instance from the mTextWindowDataMap.  
static int  ClearEditFieldDataMap()
        Static function which removes all entries in the mEditFieldDataMap.  
static int  ClearTextWindowDataMap()
        Static function that removes all entries in the mTextWindowDataMap.  
static int  AddOnCommandFunction(CBSTRING sNameOfFunction, ONCOMMANDFUNCTION pOnCommandFunctionPointer)
        Static function which adds an ONCOMMANDFUNCTION pointer to the mCommandFunctionPointerMap.  
static int  AddCommandMap(CBCommandMap cbCommandMap)
        Static function which adds a CBCommandMap to our vCommandMapArray
 

Member Function Detail:  

     CBData::CBData()
Comments:
Empty Constructor.  
Parameters:
None
Returns:
None
 
static int  CBData::AddEditFieldData( int nEditFieldID)
Comments:
Static function which creates a CBEditFieldData instance and adds it to the mEditFieldDataMap.  
This function should be called once for each in-game GUI Edit Field related to Chat.  
CBEditFieldData contains the Chat History of all the text a Player has previously typed into the Edit Field.  It also contains the default Slash Command that should be prepended to any text the Player types in that does not already start with a Slash Command.  
ChatBlade uses the information stored in the CBEditFieldData instances to implement Chat History and to apply default Slash Commands to text typed in the Edit Field.  
It is unlikely that Game Developers shall need to worry about the CBEditFieldData instances after calling this function.  ChatBlade takes care of the information automatically.  
Parameters:
nEditFieldID
    The ID of a GUI Edit Field.  Each Chat-related GUI Edit Field should have a different Edit Field ID.  
Returns:
CB_SUCCESS
 
static int  CBData::AddTextWindowData( int nTextWindowID)
Comments:
Static function which creates a CBTextWindowData instance and adds it to the mTextWindowDataMap.  
This function should be called once for each in-game GUI Text Window or Chat Tab related to Chat.  
CBTextWindowData contains all the Chat Messages belonging to a GUI Text Window.  It also contains a list of all the Chat Channels the GUI Text Window should be Monitoring.  
Developers can get access to the CBTextWindowData instance by using the Text Window ID as the key to CBData::mTextWindowDataMap.  So CBData::mTextWindowDataMap[1] would return a CBTextWindowData instance related to Text Window ID 1.  
Developers shall need to access the CBTextWindowData instances contained in the Map in order to gain access to the Chat Messages stored for the Text Window, and in order to set the Chat Channels the related Text Window should be Monitoring.  
Typically after calling this function, Developers should set the initial Chat Channels that the Text Window should be monitoring.  This might be done like so:  CBData::mTextWindowDataMap[nTextWindowID].AddAllChannelIDs(), or each Chat Channel desired can be added individually.  
Parameters:
nTextWindowID
    The ID of a GUI Text Window or Chat Tab.  Each Text Window or Chat Tab should have a unique ID.  
Returns:
CB_SUCCESS
 
static int  CBData::RemoveEditFieldData( int nEditFieldID)
Comments:
Static function which removes a CBEditFieldData instance from the mEditFieldDataMap.  
This function should be called if the User removes a Chat related Edit Field from their Game UI.   
Parameters:
nEditFieldID
    The ID of a GUI Edit Field to remove.   
Returns:
CB_SUCCESS
 
static int  CBData::RemoveTextWindowData( int nTextWindowID)
Comments:
Static function which removes a CBTextWindowData instance from the mTextWindowDataMap.  
This function should be called if a User deletes a Chat Text Window or Chat Tab from the Game UI.   
Parameters:
nTextWindowID
    The ID of a GUI Text Window or Chat Tab to remove  
Returns:
CB_SUCCESS
 
static int  CBData::ClearEditFieldDataMap()
Comments:
Static function that removes all entries in the mEditFieldDataMap.  
Useful if all Chat Windows and their Edit Fields are removed from the UI.  
Parameters:
None
 
Returns:
CB_SUCCESS
 
static int  CBData::ClearTextWindowDataMap()
Comments:
Static function that removes all entries in the mTextWindowDataMap.  
Useful is all Chat Windows/Tabs are removed from the UI.  
Parameters:
None
Returns:
CB_SUCCESS
 
static int  CBData::AddOnCommandFunction( CBSTRING sNameOfFunction,
ONCOMMANDFUNCTION pOnCommandFunctionPointer)
Comments:
Static function which adds an ONCOMMANDFUNCTION pointer to the mCommandFunctionPointerMap.  
Used to create a Map of our OnCommandXXX() functions using the UPPERCASE name of the Function as the key to the function pointer.  
Called by CBSlashCommands::InitializeCommandPointerMap().  
Parameters:
sNameOfFunction
    Typically the name of the OnCommandXXX() function.  For Example:  "OnCommandSay".  Does not need to be UPPERCASE.  
pOnCommandFunctionPointer
    A Pointer to an OnCommandXXX() function.  Typically one of the static functions contained in CBSlashCommands.  For Example:  CBSlashCommands::OnCommandSay.  
Returns:
CB_ERROR_NULL_POINTER if either the Function name is empty or the Function pointer is NULL.  
CB_SUCCESS if the entry was added into the Map.  
static int  CBData::AddCommandMap( CBCommandMap cbCommandMap)
Comments:
Static function which adds a CBCommandMap to our vCommandMapArray.  
This function should be called once for each Slash Command Function.  
CBCommandMap contains various Player typed Slash Commands and the associated OnCommandXXX() function that those typed Slash Commands should invoke.  
ChatBlade uses the information stored in the vCommandMapArray to match up a typed in Slash Command with its OnCommandXXX() function.  
This function should be invoked from CBClientImplementation::LoadSlashCommands(), once for each Slash Command Function.  See  CBSampleImplementation::LoadSlashCommands().  
Parameters:
cbCommandMap
    A CBCommandMap instance containing various Slash Commands and the OnCommandXXX() Function pointer that those Slash Commands should invoke.   
Returns:
CB_SUCCESS
 
 

 

 

 

ChatBlade Copyright Flex Dolphynn