Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Engine.InteractionMaster


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
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
// ====================================================================
//  Class:  Engine.InteractionMaster
//
//  The InteractionMaster controls the entire interaction system.  It's
//  job is to take input and Pre/PostRender call and route them to individual
//  Interactions and/or viewports.
//
// 	The stubs here in script are for just the GlobalInteracations as those
// 	are the only Interactions the IM routes directly too.  A new stub is
// 	created in order to limit the number of C++ -> Uscript switches.
//
// (c) 2001, Epic Games, Inc.  All Rights Reserved 
// ====================================================================

class InteractionMaster extends Interactions
	    transient
		Native;

var transient Client Client;

var transient const Interaction BaseMenu;	// Holds a pointer to the base menu system 
var transient const Interaction Console;	// Holds the special Interaction that acts as the console
var transient array<Interaction> GlobalInteractions;	// Holds a listing of all global Interactions
var transient bool bRequireRawJoystick;

native function Travel(string URL);	// Setup a travel to a new map

// ====================================================================
// Control functions
// ====================================================================

event Interaction AddInteraction(string InteractionName, optional Player AttachTo) 	// Adds an Interaction
{
	local Interaction NewInteraction;
	local class<Interaction> NewInteractionClass;
	
	NewInteractionClass = class<Interaction>(DynamicLoadObject(InteractionName, class'Class'));
	
	if (NewInteractionClass!=None)
	{
		NewInteraction = new NewInteractionClass;
		if (NewInteraction != None)
		{
			
			// Place the Interaction in the proper array
	
			if (AttachTo != None)	// Handle location Interactions
			{
				AttachTo.LocalInteractions.Length = AttachTo.LocalInteractions.Length + 1;
				AttachTo.LocalInteractions[AttachTo.LocalInteractions.Length-1] = NewInteraction;
				NewInteraction.ViewportOwner = AttachTo;
			}
			else	// Handle Global Interactions
			{
				GlobalInteractions.Length = GlobalInteractions.Length + 1;
				GlobalInteractions[GlobalInteractions.Length-1] = NewInteraction;
			}

			// Initialize the Interaction
			
			NewInteraction.Initialize();
			NewInteraction.Master = Self;

// IGA >>> PostBeginPlay the interaction
			NewInteraction.PostBeginPlay();
// IGA
			return NewInteraction;
			
		}
		else
  			Log("Could not create interaction ["$InteractionName$"]",'IMaster');
			
	}
	else
		Log("Could not load interaction ["$InteractionName$"]",'IMaster');

	return none;	 	
	
} // AddInteraction

event RemoveInteraction(interaction RemoveMe)			// Removes a Interaction
{
	local int Index;

	// Grab the array to work with
	
	if (RemoveMe.ViewportOwner != None)
	{
		for (Index = 0; Index < RemoveMe.ViewportOwner.LocalInteractions.Length; Index++)
		{
			if ( RemoveMe.ViewportOwner.LocalInteractions[Index] == RemoveMe )
			{
				RemoveMe.ViewportOwner.LocalInteractions.Remove(Index,1);
				return;
			}
		}
	}
	else
	{
		for (Index = 0; Index < GlobalInteractions.Length; Index++)
		{
			if ( GlobalInteractions[Index] == RemoveMe )
			{
				GlobalInteractions.Remove(Index,1);
				return;
			}
		}
	}
		

	// Find the Interaction to delete 
	
	Log("Could not remove interaction ["$RemoveMe$"] (Not Found)", 'IMaster');

} // RemoveInteraction			
  	
// ====================================================================
// SetFocusTo - This function will cause a window to adjust it's position
// in it's array so that it processes input first and displays last.
// ====================================================================

event SetFocusTo(Interaction Inter, optional Player ViewportOwner)
{
	local array<Interaction> InteractionArray;
	local Interaction temp;
	local int i,iIndex;
	
	
	if (ViewportOwner != none)
		InteractionArray = ViewportOwner.LocalInteractions;
	else
		InteractionArray = GlobalInteractions;
		
	if (InteractionArray.Length == 0)
	{
		Log("Attempt to SetFocus on an empty Array.",'IMaster');
		return;
	}
	
	// Search for the Interaction

	iIndex = -1;
	for ( i=0; i<InteractionArray.Length; i++ )
	{
		if (InteractionArray[i] == Inter)
		{
			iIndex = i; 
			break;
		}
	}

	// Was it found?
	
	if (iIndex<0)
	{
		Log("Interaction "$Inter$" is not in "$ViewportOwner$".",'IMaster');
		return;
	}
	else if (iIndex==0)
		return;					// Already has focus
	

	// Move it to the top.		
		
	temp = InteractionArray[iIndex];
	for ( i=iIndex-1; i>=0; i--)
		InteractionArray[i+1] = InteractionArray[i];
		
	InteractionArray[0] = temp;
	InteractionArray[0].bActive = true;		// Give it Input
	InteractionArray[0].bVisible = true;	// Make it visible	

#if IG_SHARED // rowan: 
	if (ViewportOwner != none)
		ViewportOwner.LocalInteractions = InteractionArray;
	else
		GlobalInteractions = InteractionArray;
#endif
} // SetFocusTo				
	
// ====================================================================
// Input Functions
//
// The Process functions are here to limit the # of switches from C++ to Script. 
// ====================================================================
		
event bool Process_KeyType( array<Interaction> InteractionArray, out EInputKey Key, optional string Unicode ) // Process a single key press
{
	local int Index;
	
	// Chain through the Interactions
	
	for ( Index=0; Index<InteractionArray.Length; Index++) 
	{
		// Give each Interaction the chance to process the key event

		if ( ( InteractionArray[Index].bActive ) && (!InteractionArray[Index].bNativeEvents) && ( InteractionArray[Index].KeyType(Key,Unicode) ) )
			return true;				// and break the chain if processed
	
	}
	return false;	// Keep processing

} // Process_KeyType

event bool Process_KeyEvent( array<Interaction> InteractionArray,
				out EInputKey Key, out EInputAction Action, FLOAT Delta ) // Process the range of input events
{
	local int Index;

	// Chain through the Interactions
	
	for ( Index=0; Index<InteractionArray.Length; Index++)
	{
		// Give each Interaction the chance to process the key event
		
		if ( ( InteractionArray[Index].bActive ) && (!InteractionArray[Index].bNativeEvents) && ( InteractionArray[Index].KeyEvent(Key, Action, Delta ) ) )
		{
			return true;						// and break the chain if processed
		}
	
	}
	return false; 

} // Process_KeyEvent

// ====================================================================
// Render functions only occure on local interactions.  The process
// the array in reverse order so that the objects that have focus
// are drawn last. 
// ====================================================================

event Process_PreRender( array<Interaction> InteractionArray, canvas Canvas )
{
	local int Index;

	// Chain through the Interactions

	for ( Index=InteractionArray.Length; Index>0; Index--)	// Give each Interaction PreRender time
	{
		if ( (InteractionArray[Index-1].bVisible ) && (!InteractionArray[Index-1].bNativeEvents) )
			InteractionArray[Index-1].PreRender(Canvas);
	}			
		
} // Process_PreRender

event Process_PostRender( array<Interaction> InteractionArray, canvas Canvas )
{
	local int Index;

	// Chain through the Interactions

	for ( Index=InteractionArray.Length; Index>0; Index--)	// Give each Interaction PreRender time
	{
		if ( (InteractionArray[Index-1].bVisible ) && (!InteractionArray[Index-1].bNativeEvents) )
			InteractionArray[Index-1].PostRender(Canvas);
	}			

} // Process_PostRender

// ====================================================================
// Tick - Interactions can request access to be ticked.
// ====================================================================

event Process_Tick( array<Interaction> InteractionArray, float DeltaTime )
{
	local int Index;
	
	// Chain through the Interactions

	for ( Index=0; Index<InteractionArray.Length; Index++) 
	{
		// Give each Interaction that requires it tick

		if ( (InteractionArray[Index].bRequiresTick ) && (!InteractionArray[Index].bNativeEvents) )
			InteractionArray[Index].Tick(DeltaTime);	
	}

}	

// ====================================================================
// Message - The IM is responsible for sending Message events to all
// interactions.
// ====================================================================

event Process_Message( coerce string Msg, float MsgLife, array<Interaction> InteractionArray)
{
	local int Index;
	
	// Chain through the Interactions

	for ( Index=0; Index<InteractionArray.Length; Index++) 
	{
		// Give each Interaction the message

		InteractionArray[Index].Message(Msg, MsgLife);	
	}

} // Message

#if IG_SHARED // dbeswick: added ability to get the localized key name for a command bound in user.ini
// could be slow, try to cache results
// Returns the first key found. If bReturnMultiple is specified, returns all keys bound to the command separated by commas.
native function string GetKeyFromBinding(string BindingText, bool bLocalized, optional bool bReturnMultiple, optional bool bExactMatch);
#endif

defaultproperties
{

}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ne 5.9.2004 16:01:26.000 - Creation time: st 23.5.2018 00:10:44.680 - Created with UnCodeX