Main   Class List   Namespace List   Wiki

MessageVector Class Reference
[Utility Controls]

Store a list of chat messages. More...

Inheritance diagram for MessageVector:
Inheritance graph
[legend]

List of all members.

Public Member Functions

void clear ()
 Clear all messages in the vector.
bool deleteLine (int deletePos)
 Delete the line at the specified position.
void dump (string filename)
 Dump the message vector to a file without a header.
void dump (string filename, string header)
 Dump the message vector to a file with a header.
int getLineIndexByTag (int tag)
 Scan through the vector, returning the line number of the first line that matches the specified tag; else returns -1 if no match was found.
int getLineTag (int pos)
 Get the tag of a specified line.
string getLineText (int pos)
 Get the text at a specified line.
string getLineTextByTag (int tag)
 Scan through the lines in the vector, returning the first line that has a matching tag.
int getNumLines ()
 Get the number of lines in the vector.
bool insertLine (int insertPos, string msg, int tag)
 Push a line onto the back of the list.
bool popBackLine ()
 Pop a line from the back of the list; destroys the line.
bool popFrontLine ()
 Pop a line from the front of the vector, destroying the line.
void pushBackLine (string msg, int tag)
 Push a line onto the back of the list.
void pushFrontLine (string msg, int tag)
 Push a line onto the front of the vector.

Detailed Description

Store a list of chat messages.

This is responsible for managing messages which appear in the chat HUD, not the actual control rendered to the screen

Example:
// Declare ChatHud, which is what will display the actual chat from a MessageVector
new GuiMessageVectorCtrl(ChatHud) {
   profile = "ChatHudMessageProfile";
   horizSizing = "width";
   vertSizing = "height";
   position = "1 1";
   extent = "252 16";
   minExtent = "8 8";
   visible = "1";
   helpTag = "0";
   lineSpacing = "0";
   lineContinuedIndex = "10";
   matchColor = "0 0 255 255";
   maxColorIndex = "5";
};

// All messages are stored in this HudMessageVector, the actual
// MainChatHud only displays the contents of this vector.
new MessageVector(HudMessageVector);

// Attach the MessageVector to the chat control
chatHud.attach(HudMessageVector);
See also:
GuiMessageVectorCtrl for more details on how this is used.

Member Function Documentation

void MessageVector::clear (  ) 

Clear all messages in the vector.

Example:
HudMessageVector.clear();
bool MessageVector::deleteLine ( int  deletePos  ) 

Delete the line at the specified position.

Parameters:
deletePos Position in the vector containing the line to be deleted
Example:
// Delete the first line (index 0) in the vector...
HudMessageVector.deleteLine(0);
Returns:
False if deletePos is greater than the number of lines in the current vector
void MessageVector::dump ( string  filename  ) 

Dump the message vector to a file without a header.

Parameters:
filename Name and path of file to dump text to.
Example:
// Dump the entire chat log to a text file
HudMessageVector.dump("./chatLog.txt");
void MessageVector::dump ( string  filename,
string  header 
)

Dump the message vector to a file with a header.

Parameters:
filename Name and path of file to dump text to.
header Prefix information for write out
Example:
// Arbitrary header data
%headerInfo = "Ars Moriendi Chat Log";

// Dump the entire chat log to a text file
HudMessageVector.dump("./chatLog.txt", %headerInfo);
int MessageVector::getLineIndexByTag ( int  tag  ) 

Scan through the vector, returning the line number of the first line that matches the specified tag; else returns -1 if no match was found.

Parameters:
tag Numerical value assigned to a message when it was added or inserted
Example:
// Locate a line of text tagged with the value "1", then delete it.
%taggedLine = HudMessageVector.getLineIndexByTag(1);
HudMessageVector.deleteLine(%taggedLine);
Returns:
Line with matching tag, other wise -1
int MessageVector::getLineTag ( int  pos  ) 

Get the tag of a specified line.

Parameters:
pos Position in vector to grab tag from
Example:
// Remove all lines that do not have a tag value of 1.
while( HudMessageVector.getNumLines())
{
   %tag = HudMessageVector.getLineTag(1);
   if(%tag != 1)
      %tag.delete();
   HudMessageVector.popFrontLine();
}
Returns:
Tag value of a given line, if the position is greater than the number of lines return 0
string MessageVector::getLineText ( int  pos  ) 

Get the text at a specified line.

Parameters:
pos Position in vector to grab text from
Example:
// Print a line of text at position 1.
%text = HudMessageVector.getLineText(1);
echo(%text);
Returns:
Text at specified line, if the position is greater than the number of lines return ""
string MessageVector::getLineTextByTag ( int  tag  ) 

Scan through the lines in the vector, returning the first line that has a matching tag.

Parameters:
tag Numerical value assigned to a message when it was added or inserted
Example:
// Locate text in the vector tagged with the value "1", then print it
%taggedText = HudMessageVector.getLineTextByTag(1);
echo(%taggedText);
Returns:
Text from a line with matching tag, other wise ""
int MessageVector::getNumLines (  ) 

Get the number of lines in the vector.

Example:
// Find out how many lines have been stored in HudMessageVector
%chatLines = HudMessageVector.getNumLines();
echo(%chatLines);
bool MessageVector::insertLine ( int  insertPos,
string  msg,
int  tag 
)

Push a line onto the back of the list.

Parameters:
msg Text that makes up the message
tag Numerical value associated with this message, useful for searching.
Example:
// Add the message...
HudMessageVector.insertLine(1, "Hello World", 0);
Returns:
False if insertPos is greater than the number of lines in the current vector
bool MessageVector::popBackLine (  ) 

Pop a line from the back of the list; destroys the line.

Example:
HudMessageVector.popBackLine();
Returns:
False if there are no lines to pop (underflow), true otherwise
bool MessageVector::popFrontLine (  ) 

Pop a line from the front of the vector, destroying the line.

Example:
HudMessageVector.popFrontLine();
Returns:
False if there are no lines to pop (underflow), true otherwise
void MessageVector::pushBackLine ( string  msg,
int  tag 
)

Push a line onto the back of the list.

Parameters:
msg Text that makes up the message
tag Numerical value associated with this message, useful for searching.
Example:
// Add the message...
HudMessageVector.pushBackLine("Hello World", 0);
void MessageVector::pushFrontLine ( string  msg,
int  tag 
)

Push a line onto the front of the vector.

Parameters:
msg Text that makes up the message
tag Numerical value associated with this message, useful for searching.
Example:
// Add the message...
HudMessageVector.pushFrontLine("Hello World", 0);


Copyright © GarageGames, LLC. All Rights Reserved.