Store a list of chat messages.
More...
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:
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";
};
new MessageVector(HudMessageVector);
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:
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:
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:
%headerInfo = "Ars Moriendi Chat Log";
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:
%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:
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:
%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:
%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:
%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:
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:
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:
HudMessageVector.pushFrontLine("Hello World", 0);