## XIDInterf
Class XIIIMenuInGameMulti

source: C:\XIII\XIDInterf\Classes\XIIIMenuInGameMulti.uc

    Core.Object
       |
       +--GUI.GUI
          |
          +--GUI.GUIComponent
             |
             +--GUI.GUIMultiComponent
                |
                +--GUI.GUIPage
                   |
                   +--XIDInterf.XIIIWindow
                      |
                      +--XIDInterf.XIIIMenuInGameMulti

Direct Known Subclasses:None

class XIIIMenuInGameMulti
extends XIDInterf.XIIIWindow

    //============================================================================
    // The In Game menu for multiplayer mode
    //
    //============================================================================

Variables
`BackgroundWidth,` | `BackgroundHeight`
`KickButton,` | `BombButton`
`BoxHeight,` | `NbPlayers`
`BombText,` | `QuitTextAsHost`
`bTeamMode,` | `bBombMode`

States
STA_ResetInputs

Function Summary
`void` | `BeforePaint(Canvas C, float X, float Y)`
`void` | `Created()`
    //============================================================================
`bool` | `InternalOnClick(GUIComponent Sender)`
    // Called when a button is clicked
`bool` | `InternalOnKeyEvent(out byte, out byte, float delta)`
`void` | `Paint(Canvas C, float X, float Y)`
`void` | `QuitGame()`
`void` | `QuitMsgBoxReturn(byte bButton)`
`void` | `RestartGame()`
`void` | `ShowWindow()`

State STA_ResetInputs Function Summary

Source Code

    00001	//============================================================================
    00002	// The In Game menu for multiplayer mode
    00003	//
    00004	//============================================================================
    00005	class XIIIMenuInGameMulti extends XIIIWindow;
    00006
    00007	var  XIIIButton TeamButton, OptionsButton, QuitButton, ReturnButton, RestartButton, KickButton, BombButton;
    00008	var  localized string TeamText, OptionsText, QuitText, ReturnText, RestartText, KickText, ConfirmQuitTxt, BombText, QuitTextAsHost;
    00009	var bool bTeamMode, bBombMode;
    00010	var int NbButtons, BoxPosX, BoxPosY, BoxWidth, BoxHeight, NbPlayers;
    00011	var int BackgroundPosX, BackgroundPosY, BackgroundWidth, BackgroundHeight;
    00012	//var float fX, fY;
    00013
    00014
    00015	//============================================================================
    00016	function Created()
    00017	{
    00018		LOCAL int i, LineSpace, FirstLineY;
    00019	//	LOCAL class<GameInfo> GameClass;
    00020		LOCAL bool bCanKick, bShowQuitButton;
    00021
    00022		Super.Created();
    00023
    00024		// init values
    00025		BoxWidth = 200;
    00026		BoxHeight = 30;
    00027		BoxPosX = 230;
    00028		BackgroundPosX = 220;
    00029		BackgroundPosY = 130;
    00030		BackgroundWidth = 220;
    00031		BackgroundHeight = 230;
    00032
    00033		if ( GetPlayerOwner().myHUD.bShowScores )
    00034			GetPlayerOwner().myHUD.HideScores();
    00035
    00036		// team mode
    00037		//GameClass = class<GameInfo>(dynamicloadobject(GetPlayerOwner().GameReplicationInfo.GameClass, class'class'));
    00038		//!GameClass.default.bTeamGame
    00039
    00040		NbButtons = 3;
    00041
    00042		if ( !GetPlayerOwner().myHUD.IsA('XIIITeamHUD') || ( GetPlayerOwner().Level.NetMode == 0 ) )
    00043		{
    00044			bTeamMode = false;
    00045		}
    00046		else
    00047		{
    00048			bTeamMode = true;
    00049			NbButtons++;
    00050
    00051		}
    00052		if ( GetPlayerOwner().myHUD.IsA('XIIIBombHUD')  )
    00053		{
    00054			bBombMode = true;
    00055			NbButtons++;
    00056		}
    00057		else
    00058		{
    00059			bBombMode = false;
    00060		}
    00061		BoxPosY = 250 - 18*NbButtons;
    00062
    00063		bCanKick = ( GetPlayerOwner().Level.Game!=none ) && ( GetPlayerOwner().Level.NetMode != 0 );
    00064		if ( bCanKick )
    00065			NbButtons++;
    00066
    00067		if ( GetPlayerOwner().Level.NetMode != 0 ) // QUIT BUTTON ALWAYS AVAILABLE IN NET MODE
    00068			bShowQuitButton = true;
    00069		else // QUIT BUTTON ONLY AVAILABLE FOR FIRST VIEWPORT IN SPLIT MODE
    00070		{
    00071			XIIIBaseHud(GetPlayerOwner().myHUD).InitViewPortId( none, false );
    00072			bShowQuitButton =  ( XIIIBaseHud(GetPlayerowner().myHUD).ViewPortId == 0 );
    00073			if ( !bShowQuitButton )
    00074				NbButtons--;
    00075		}
    00076
    00077		BoxPosY = 250 - NbButtons * 18;
    00078		LineSpace = 35;
    00079
    00080		// values update if we are in split screen mode
    00081		if ( ( GetPlayerOwner().Level.Game!=none ) && ( GetPlayerOwner().Level.Game.NumPlayers > 1 ) && (myRoot.GetLevel().NetMode == 0) )
    00082		{
    00083			BackgroundPosY -= 100;
    00084			BackgroundHeight = 170;
    00085			BoxPosY -=70;
    00086			BoxHeight *= 1.8;
    00087			LineSpace *= 1.8;
    00088			NbPlayers = GetPlayerOwner().Level.Game.NumPlayers;
    00089			if ( NbPlayers > 2 )
    00090			{
    00091				BoxWidth *= 2;
    00092				BoxPosX -= 110;
    00093				BackgroundPosX -= 170;
    00094			}
    00095		}
    00096
    00097		FirstLineY = BoxPosY;
    00098
    00099		ReturnButton = XIIIButton(CreateControl(class'XIIIButton', BoxPosX, FirstLineY*fScaleTo, BoxWidth, BoxHeight*fScaleTo));
    00100		ReturnButton.Text = ReturnText;
    00101		ReturnButton.bUseBorder = true;
    00102		ReturnButton.NbMultiSplit = NbPlayers;
    00103		Controls[i] = ReturnButton;
    00104		FirstLineY  += LineSpace;
    00105		i++;
    00106
    00107	    if ( bTeamMode )
    00108		{
    00109			TeamButton = XIIIButton(CreateControl(class'XIIIButton', BoxPosX, FirstLineY*fScaleTo, BoxWidth, BoxHeight*fScaleTo));
    00110			TeamButton.Text = TeamText;
    00111			TeamButton.bUseBorder = true;
    00112			TeamButton.NbMultiSplit = NbPlayers;
    00113			Controls[i] = TeamButton;
    00114			FirstLineY  += LineSpace;
    00115			i++;
    00116		}
    00117		if ( bBombMode )
    00118		{
    00119			BombButton = XIIIButton(CreateControl(class'XIIIButton', BoxPosX, FirstLineY*fScaleTo, BoxWidth, BoxHeight*fScaleTo));
    00120			BombButton.Text = BombText;
    00121			BombButton.bUseBorder = true;
    00122			BombButton.NbMultiSplit = NbPlayers;
    00123			Controls[i] = BombButton;
    00124			FirstLineY  += LineSpace;
    00125			i++;
    00126		}
    00127
    00128	    if ( bCanKick )
    00129		{
    00130			KickButton = XIIIButton(CreateControl(class'XIIIButton', BoxPosX, FirstLineY*fScaleTo, BoxWidth, BoxHeight*fScaleTo));
    00131			KickButton.Text = KickText;
    00132			KickButton.bUseBorder = true;
    00133			Controls[i] = KickButton;
    00134			FirstLineY  += LineSpace;
    00135			i++;
    00136		}
    00137
    00138		OptionsButton = XIIIButton(CreateControl(class'XIIIButton', BoxPosX, FirstLineY*fScaleTo, BoxWidth, BoxHeight*fScaleTo));
    00139		OptionsButton.Text = OptionsText;
    00140		OptionsButton.bUseBorder = true;
    00141		OptionsButton.NbMultiSplit = NbPlayers;
    00142		Controls[i] = OptionsButton;
    00143		FirstLineY  += LineSpace;
    00144		i++;
    00145
    00146		if ( bShowQuitButton )
    00147		{
    00148			QuitButton = XIIIButton(CreateControl(class'XIIIButton', BoxPosX, FirstLineY*fScaleTo, BoxWidth, BoxHeight*fScaleto));
    00149			QuitButton.Text = QuitText;
    00150			QuitButton.bUseBorder = true;
    00151			QuitButton.NbMultiSplit = NbPlayers;
    00152			Controls[i] = QuitButton;
    00153			FirstLineY  += LineSpace;
    00154		}
    00155
    00156		//GetPlayerOwner().ResetInputs();
    00157
    00158		// we define default user config in XIIIRootWindow
    00159		if (( myRoot.CurrentPF == 3 ) && ( myRoot.DefaultUserConfig == -1 ))
    00160		{
    00161			log("SPLIT : define default config in XIIIRootWindow"@ GetPlayerOwner().UserPadConfig);
    00162			myRoot.DefaultUserConfig = GetPlayerOwner().UserPadConfig;
    00163		}
    00164
    00165		GotoState('STA_ResetInputs');
    00166	}
    00167
    00168
    00169
    00170	function BeforePaint(Canvas C, float X, float Y)
    00171	{
    00172
    00173		Super.BeforePaint(C, X, Y);
    00174
    00175		if (bDoQuitGame)
    00176			QuitGame();
    00177		if (bDoRestartGame)
    00178			RestartGame();
    00179	}
    00180
    00181
    00182	function Paint(Canvas C, float X, float Y)
    00183	{
    00184
    00185		local int i;
    00186
    00187		Super.Paint(C,X,Y);
    00188
    00189		if ( GetPlayerOwner().Level.Game==none || GetPlayerOwner().Level.NetMode != 0 || GetPlayerOwner().Level.Game.NumPlayers == 1 )
    00190			C.DrawMsgboxBackground(false, BackgroundPosX*fRatioX, BackgroundPosY*fScaleTo*fRatioY, 10, 10, BackgroundWidth*fRatioX, BackgroundHeight*fScaleTo*fRatioY);
    00191		else
    00192		{
    00193			C.DrawColor = WhiteColor;
    00194			C.bUseBorder = true;
    00195			DrawStretchedTexture( C, BackgroundPosX, BackgroundPosY*fScaleTo, BackgroundWidth, BackgroundHeight*fScaleTo, texture'XIIIMenu.FonDialog');
    00196			C.bUseBorder = false;
    00197		}
    00198
    00199		// only selected control has a border
    00200	    for (i=0; i<NbButtons; i++)
    00201	        XIIIButton(Controls[i]).bUseBorder = false;
    00202	    if (FindComponentIndex(FocusedControl)!= -1)
    00203	        XIIIButton(Controls[FindComponentIndex(FocusedControl)]).bUseBorder = true;
    00204
    00205		// restore old param
    00206		C.DrawColor = WhiteColor;
    00207	    C.DrawColor.A = 255;
    00208		C.Style = 1;
    00209		C.bUseBorder = false;
    00210
    00211	}
    00212
    00213
    00214	// Called when a button is clicked
    00215	function bool InternalOnClick(GUIComponent Sender)
    00216	{
    00217		local XIIIMsgBoxInGame MsgBox;
    00218		LOCAL bool bHost;
    00219
    00220		if (Sender == RestartButton)
    00221			myRoot.OpenMenu("XIDInterf.XIIIMenuYesNoWindow");
    00222
    00223		if (( bTeamMode ) && (Sender == TeamButton))
    00224		{
    00225			GetPlayerOwner().ResetInputs();
    00226			myRoot.CloseAll(true);
    00227			myRoot.GotoState('');
    00228			GetPlayerOwner().ConsoleCommand("SwitchTeam");
    00229		}
    00230
    00231		if (Sender == OptionsButton)
    00232		{
    00233			if (myRoot.CurrentPF > 0)
    00234				myRoot.OpenMenu("XIDInterf.XIIIMultiControlsWindow");
    00235			else
    00236			    myRoot.OpenMenu("XIDInterf.XIIIMenuInputPC");
    00237		}
    00238
    00239		if (Sender == ReturnButton)
    00240		{
    00241
GetPlayerOwner().ResetInputs(); 00242 myRoot.CloseAll(true); 00243 myRoot.GotoState(''); 00244 } 00245 00246 if (Sender == QuitButton) 00247 { 00248 if ( GetPlayerOwner().Level.Game==none || GetPlayerOwner().Level.NetMode != 0 || GetPlayerOwner().Level.Game.NumPlayers == 1 ) 00249 { 00250 bShowBCK = false; 00251 myRoot.OpenMenu("XIDInterf.XIIIMsgBoxInGame"); 00252 MsgBox = XIIIMsgBoxInGame(myRoot.ActivePage); 00253 MsgBox.InitBox(BackgroundPosX*fRatioX, BackgroundPosY*fScaleTo*fRatioY, 10, 10, BackgroundWidth*fRatioX, BackgroundHeight*fScaleTo*fRatioY); 00254 bHost = ( GetPlayerOwner().Level.Game!=none ) && ( GetPlayerOwner().Level.NetMode != 0 ); 00255 if (bHost) 00256 MsgBox.SetupQuestion(QuitTextAsHost, QBTN_Yes | QBTN_No, QBTN_No,""); 00257 else 00258 MsgBox.SetupQuestion(ConfirmQuitTxt, QBTN_Yes | QBTN_No, QBTN_No,""); 00259 MsgBox.OnButtonClick = QuitMsgBoxReturn; 00260 } 00261 else 00262 { 00263 myRoot.OpenMenu("XIDInterf.XIIIMenuYesNoWindow"); 00264 XIIIMenuYesNoWindow(myRoot.ActivePage).bQuitGame = true; 00265 } 00266 } 00267 00268 if (Sender == KickButton) 00269 { 00270 myRoot.OpenMenu("XIDInterf.XIIIMenuInGameMultiKick"); 00271 // XIIIMenuYesNoWindow(myRoot.ActivePage).bQuitGame = true; 00272 } 00273 if (Sender == BombButton) 00274 { 00275 myRoot.OpenMenu("XIDInterf.XIIIMenuInGameSabotage"); 00276 } 00277 00278 00279 return true; 00280 } 00281 00282 00283 function QuitMsgBoxReturn(byte bButton) 00284 { 00285 bShowBCK = true; 00286 if ((bButton & QBTN_Yes) != 0) 00287 { 00288 QuitGame(); 00289 } 00290 } 00291 00292 00293 function QuitGame() 00294 { 00295 if ( myRoot.CurrentPF == 3 ) 00296 { 00297 switch ( myRoot.DefaultUserConfig ) 00298 { 00299 case 0: 00300 // specific inputs for classic 00301 GetPlayerOwner().ConsoleCommand("set XIIIPlayerController ConfigType CT_StrafeLookNotSameAxis"); 00302 GetPlayerOwner().ConsoleCommand("SET Input JoyX Axis aStrafe SpeedBase=1.0 DeadZone=0.0"); 00303 GetPlayerOwner().ConsoleCommand("SET Input JoyU Axis aTurn SpeedBase=1.0 DeadZone=0.0"); 00304 break; 00305 case 1: 00306 // specific inputs for goofy 00307 GetPlayerOwner().ConsoleCommand("set XIIIPlayerController ConfigType CT_StrafeLookSameAxis"); 00308 GetPlayerOwner().ConsoleCommand("SET Input JoyX Axis aTurn SpeedBase=1.0 DeadZone=0.0"); 00309 GetPlayerOwner().ConsoleCommand("SET Input JoyU Axis aStrafe SpeedBase=1.0 DeadZone=0.0"); 00310 break; 00311 } 00312 } 00313 00314 GetPlayerOwner().myHUD.bShowScores = false; 00315 GetPlayerOwner().myHUD.bHideHud = true; 00316 myRoot.CloseAll(true); 00317 myRoot.GotoState(''); 00318 00319 myRoot.Master.GlobalInteractions[0].ViewportOwner.Actor.ClientTravel("MapMenu", TRAVEL_Absolute, false); 00320 myRoot.Master.GlobalInteractions[0].ViewportOwner.Actor.ConsoleCommand("SetViewPortNumberForNextMap 1"); 00321 } 00322 00323 00324 function RestartGame() 00325 { 00326 bDoRestartGame = false; 00327 myRoot.bProfileMenu = true; 00328 myRoot.CloseAll(true); 00329 myRoot.GotoState(''); 00330 myRoot.Master.GlobalInteractions[0].ViewportOwner.Actor.ClientTravel( "?restart", TRAVEL_Relative, false ); 00331 } 00332 00333 00334 function bool InternalOnKeyEvent(out byte Key, out byte State, float delta) 00335 { 00336 local int index; 00337 local bool bLeftOrRight, bUpOrDown; 00338 local controller P; 00339 00340 if (State==1)// IST_Press // to avoid auto-repeat 00341 { 00342 if ((Key==0x0D/*IK_Enter*/) || (Key==0x01)) 00343 { 00344 return InternalOnClick(FocusedControl); 00345 } 00346 if (Key==0x08 || Key==0x1B/*IK_Backspace - IK_Escape*/) 00347 { 00348 myRoot.CloseAll(true); 00349 myRoot.GotoState(''); 00350 /* for ( P=myRoot.GetLevel().ControllerList; P!=None; P=P.NextController ) 00351 { 00352 if (XIIIRootWindow(PlayerController(P).Player.LocalInteractions[0]).bIamInMulti == true) 00353 myRoot.GetPlayerOwner().Player.Actor.SetPause( true ); 00354 }*/ 00355 return true; 00356 } 00357 if (Key==0x26/*IK_Up*/) 00358 { 00359 PrevControl(FocusedControl); 00360 return true; 00361 } 00362 if (Key==0x28/*IK_Down*/) 00363 { 00364 NextControl(FocusedControl); 00365 return true; 00366 } 00367 } 00368 return super.InternalOnKeyEvent(Key, state, delta); 00369 } 00370 00371 00372 function ShowWindow() 00373 { 00374 00375 Super.ShowWindow(); 00376 00377 bShowBCK = true; 00378 bShowSEL = true; 00379 } 00380 00381 00382 State STA_ResetInputs 00383 { 00384 Begin: 00385 Sleep(0.1); 00386 GetPlayerOwner().ResetInputs(); 00387 GotoState(''); 00388 } 00389 00390 00391 00392 defaultproperties 00393 { 00394 TeamText="Change Team" 00395 OptionsText="Options" 00396 QuitText="Quit Game" 00397 ReturnText="Return to game" 00398 RestartText="Restart Game" 00399 KickText="Kick a player" 00400 ConfirmQuitTxt="Are you sure ?" 00401 BombText="Change Class" 00402 QuitTextAsHost="Leaving the game now will end this session. Are you sure?" 00403 bForceHelp=True 00404 Background=None 00405 bCheckResolution=True 00406 bRequire640x480=False 00407 bAllowedAsLast=True 00408 }

End Source Code