MessageVector

consoledoc.h

Store a list of chat messages.

More...

Public Functions

void

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

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

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

int

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

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

bool

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

// 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:

GuiMessageVectorCtrl for more details on how this is used.

Public Functions

clear()

Clear all messages in the vector.

HudMessageVector.clear();

deleteLine(int deletePos)

Delete the line at the specified position.

Parameters:

deletePos

Position in the vector containing the line to be deleted

// Delete the first line (index 0) in the vector...
HudMessageVector.deleteLine(0);

return:

False if deletePos is greater than the number of lines in the current vector

dump(string filename)

Dump the message vector to a file without a header.

Parameters:

filename

Name and path of file to dump text to.

// Dump the entire chat log to a text file
HudMessageVector.dump("./chatLog.txt");

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

// Arbitrary header data
%headerInfo = "Ars Moriendi Chat Log";

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

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

// Locate a line of text tagged with the value "1", then delete it.
%taggedLine = HudMessageVector.getLineIndexByTag(1);
HudMessageVector.deleteLine(%taggedLine);

return:

Line with matching tag, other wise -1

getLineTag(int pos)

Get the tag of a specified line.

Parameters:

pos

Position in vector to grab tag from

// 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();
}

return:

Tag value of a given line, if the position is greater than the number of lines return 0

getLineText(int pos)

Get the text at a specified line.

Parameters:

pos

Position in vector to grab text from

// Print a line of text at position 1.
%text = HudMessageVector.getLineText(1);
echo(%text);

return:

Text at specified line, if the position is greater than the number of lines return ""

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

// Locate text in the vector tagged with the value "1", then print it
%taggedText = HudMessageVector.getLineTextByTag(1);
echo(%taggedText);

return:

Text from a line with matching tag, other wise ""

getNumLines()

Get the number of lines in the vector.

// Find out how many lines have been stored in HudMessageVector
%chatLines = HudMessageVector.getNumLines();
echo(%chatLines);

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.

// Add the message...
HudMessageVector.insertLine(1, "Hello World", 0);

return:

False if insertPos is greater than the number of lines in the current vector

popBackLine()

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

HudMessageVector.popBackLine();

return:

False if there are no lines to pop (underflow), true otherwise

popFrontLine()

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

HudMessageVector.popFrontLine();

return:

False if there are no lines to pop (underflow), true otherwise

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.

// Add the message...
HudMessageVector.pushBackLine("Hello World", 0);

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.

// Add the message...
HudMessageVector.pushFrontLine("Hello World", 0);