# SpatialFear.SFCommWindow

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 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 |
    //=============================================================================
    // Spatial Fear
    // Name: SFCommWindow
    // Description: General window base class, that is used for communication
    //				windows. e.g Captain communication.
    //
    // Author: Markus Nuebel
    //=============================================================================

    class SFCommWindow extends SFFadeWindow;

    var int			m_nCommIconHeight;	// Private: Height of comm icon window;
    var int			m_nCommIconWidth;     // Private: Width of comm icon window;
    var int			m_nModelOffsetX;		// Private: X offset of weapon model to window top/left corner
    var int			m_nModelOffsetY;		// Private: Y offset of weapon model to window top/left corner
    var bool		m_bParserAlreadySet;	// Private: Allows the contained comparser to prevent the window from setting the timer, because the comparset has already modified it.
    var bool		m_bFirstTime;				// Private: To determine, if the running text has already been enabled
    var bool		m_bPaused;	// Private: Pauses a communication.
    var bool		m_bEOW;
    var String		m_strRestOfLine;
    var SFComParser		m_oParser;	// Private: Reference to parser, that drives this window
    var Decoration		m_actMesh;  // Private: Mesh actor for weapon display
    var int			m_nLastTextPos; // Private: Saves the textpos from the last run

    // All initialization stuff
    simulated function init(float fHUDScale, int X, int Y, int nWidth, int nHeight, optional Pawn Owner, optional string strText, optional SFWindow wndParent)
    {
    	// Call to base class
    	Super.init(fHUDScale, X, Y, nWidth, nHeight, Owner, strText, wndParent);

    	// Setup the parser
    	m_oParser = Spawn(class'SFComParser');
    	m_oParser.m_actOwner = m_oPawnOwner;

    	m_nTextOffset = 8;
    }

    // Sets the current communication to play
    simulated function setCommunication(SFCommunication oComm)
    {
    	// Clear the window
    	m_strDisplayText="";
    	m_strText="";
    	// Set the new content
    	m_oParser.setData(oComm, Self);
    }

    // Cleanup
    simulated function terminate()
    {
    	// Call to base class
    	Super.terminate();

    	// Release references
    	m_oParser	= None;
    }

    // Overwritten in child class, to do different backgrounds and effects
    simulated function renderBackground(Canvas C)
    {
    	local float          OldFov;
    	local float			fSpeed;
    	local vector		  vectLocation;

    	// Call to base class
    	Super.renderBackground(C);

    	fSpeed	= SFGameInfo(Level.Game).fReadingSpeed;
    	if(!isFading() && m_bFirstTime)
    	{
    		setRunningText(" ", fSpeed);
    		m_bFirstTime = false;
    	}
    }

    simulated function show()
    {
    	// Set fading
    	setSingleFadeReverse(1.0f);

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

    }

    simulated function hide()
    {
    	setSingleFade(2.0f);

    	stopRunning();
    	// Force window do fade out
    	m_bUsedRunningText=false;

    	// Because the fade out replaces the hide command
    	if(None == m_oPawnOwner)
    		PlaySound(m_sndClose,SLOT_Misc,m_fCloseSoundVol);
    	else
    		m_oPawnOwner.PlaySound(m_sndClose,SLOT_Misc,m_fCloseSoundVol);

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

    	m_bFirstTime=true;

    	// Clear the contents
    	m_strDisplayText="";

    }

    // Pauses the communication
    simulated function pause()
    {
    	m_bPaused	= true;
    }

    // Resumes the communication
    simulated function resume(bool bYes)
    {
    	// Pass the decision to the parser
    	m_oParser.resumeComm(bYes);

    	m_bPaused	= false;
    }

    // displays text instantly and sets the fadout timeout
    simulated function instantShow(float fNewInterval)
    {
    	SetTimer(fNewInterval, false);
    	m_oParser.advanceToEnd();
    	m_bParserAlreadySet=true;
    }

    // Called during running text display;
    simulated function Timer()
    {
    	local string strChar;
    	local string strMacro;

    	if(m_bEOW)
    	{
    		m_oParser.m_nTextPos -= Len(m_strRestOfLine);
    		m_oParser.executeCLS();
    		m_bEOW = false;
    	}

    	// Check if visible
    	if(!isVisible() || PlayerPawn(m_oPawnOwner).IsInState('Dying'))
    	{
    		m_bRunningText=false;
    		return;
    	}

    	// Check, if the communication is paused.
    	if(m_bPaused)
    	{
    		SetTimer(m_fIntervall, false);
    		return;
    	}

    	if(!m_oParser.process()) // returns true, to abort communication
    	{
    		m_strDisplayText = m_oParser.m_strDisplayText;

    		// Do a new round of parsing
    		if(!m_bParserAlreadySet)
    		{
    			SetTimer(m_fIntervall, false);
    			// Add a dot to the current text output
    			if((0 == (m_nTextPos%4)) && (m_nLastTextPos != m_oParser.m_nTextPos))
    			{
    				// Blinking cursor
    //				m_strDisplayText = m_strDisplayText $ ".";
    				// Play sound
    				if(None == m_oPawnOwner)
    					PlaySound(m_sndTick,SLOT_Misc,2.0);
    				else
    					m_oPawnOwner.PlaySound(m_sndTick,SLOT_Misc,2.0);

    				// Save last text pos
    				m_nLastTextPos= m_oParser.m_nTextPos;
    			}
    		}
    		else
    			// Reset the flag
    			m_bParserAlreadySet=false;
    	}
    	else
    	{
    		// Copy the display text to the text, to not show the macro tags.
    		m_strText		= m_strDisplayText;
    		hide();
    	}

    }

    // Base class override, to do a CLS in
    // case the end of the window is reached
    simulated event EndOfWidowReached(optional string strRestOfLine)
    {
    	// Ignor EOW if we are currently pausing for the next display.
    	if(m_bEOW)
    		return;

    	m_bEOW			= true;
    	m_strRestOfLine	= strRestOfLine;
    	m_oParser.m_nTextPos -= Len(m_strRestOfLine);
    	SetTimer(4.0f, false);

    }

    defaultproperties
    {
         m_nCommIconHeight=250
         m_nCommIconWidth=200
         m_nModelOffsetX=25
         m_nModelOffsetY=30
         m_bFirstTime=True
         m_nLastTextPos=-1
         m_nTextOffset=180
         m_nTextIndent=16
         m_texBkg=Texture'SfResource1.Background.CaptainWin'
         m_nBorderSize=20
    }

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