SpatialFear.SFExtractionParser

00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
//=============================================================================
// Spatial Fear
// Name: SFExtractionParser
// Description: Parser subclass that extracts the raw text data from the
//					communication.
//
// Author: Markus Nuebel
//=============================================================================


class SFExtractionParser extends SFTextParser;

var SFCommunication	m_oCurrentComm; // Private: Reference to communication actor
var string			m_strLongText;	// Private: The extracted text.
var int				m_nTextSlot;	// Private: Textslot, to add parsed data to.

// Sets the communication window to drive by this parser
simulated function setData(SFCommunication oCom)
{
	m_oCurrentComm	= oCom;

	// init the base class with the provided text
	Super.init(m_oCurrentComm.CommunicationProtocol[0]);
}

// Cleanup
simulated function terminate()
{
	// Release references
	m_oCurrentComm	= None;

	// Call to base class
	Super.terminate();

}


// Macro to branch into a new branch of the communication protocol
simulated function executeBranch(string strNext)
{
	local	int i;

	i	= int(strNext);

	if(-1 != i)
	{
		// Extract the raw text, before staring a new protocoll
		m_strLongText	= m_strLongText $ m_strDisplayText;
		// Write line to slot
		fillSlot();
		// Once again init the base class with a new text
		Super.init(m_oCurrentComm.CommunicationProtocol[i]);
	}
}


// Writes the currently extracted data to the next free DetailText slot.
// This is needed because we cannot store more than 1024 chars in a string
simulated function fillSlot()
{
	m_oCurrentComm.DetailText[m_nTextSlot] = m_strDisplayText $ "\\n";
	m_nTextSlot++;
	// Clear the detail text
	m_strDisplayText = " ";

}
// Overwritten to translate a CLS into a newline
simulated function executeCLS()
{
	local string	strLeft, strRight;
//	fillSlot();
//	m_strDisplayText = m_strDisplayText $ "\\n";
	strLeft	= Left(m_strText, m_nTextPos);
	strRight= Right(m_strText, Len(m_strText) - m_nTextPos);
	m_strText	= strLeft $ "\\n" $ strRight;
	m_nTextPos	+= 1;

}

// Base class override, to handle additional macros
simulated function bool executeMacro(string strMacro, string strParameter, string strParameter2)
{
	local bool	bRet;
	// Some inits
	bRet	= false;


	// Check for known macros
	if(strMacro == "cls")
	{
		// Call clear screen macro
		executeCLS();
	}
	// Check for known macros
	else if(strMacro == "branch")
	{
		executeBranch(strParameter);
	}

	// No delegation. Rest of macros is eaten.

	return bRet;
}


// Called every time to process a new char
simulated function bool process()
{
	local string strChar;
	local string strMacro;

	// Increment text pos
	m_nTextPos++;

	if(checkChar())
		return false;

	// Add one more character
	if(Mid(m_strText, m_nTextPos-1, 1) == "\\")
		m_strDisplayText = Left(m_strText, m_nTextPos-1);
	else
		m_strDisplayText = Left(m_strText, m_nTextPos);

	// Check, if there is a need for a new timer run
	if(m_nTextLength >= m_nTextPos)
		return false;
	else 
	{
		// End reached, fill the slot a last time
		fillSlot();
		return true;
	}
}

defaultproperties
{
}

class file time: 12/7/2003 3:58:24 PM - creation time: 12/7/2003 4:03:44 PM
Created with UnCodeX