XIDInterf
Class XIIIMenuInGameXboxLive

source: C:\XIII\XIDInterf\Classes\XIIIMenuInGameXboxLive.uc
Core.Object
   |
   +--GUI.GUI
      |
      +--GUI.GUIComponent
         |
         +--GUI.GUIMultiComponent
            |
            +--GUI.GUIPage
               |
               +--XIDInterf.XIIIWindow
                  |
                  +--XIDInterf.XIIILiveWindow
                     |
                     +--XIDInterf.XIIIMenuInGameXboxLive
Direct Known Subclasses:None

class XIIIMenuInGameXboxLive
extends XIDInterf.XIIILiveWindow

//============================================================================ // The In Game menu for xbox live mode // //============================================================================
Variables
 string ChangeClass
           RestartText,
 ReturnButton, ChangeClassButton
           , RestartButton;
 serverDownString, ConfirmQuitTxt
           RestartText,
 XIIIMsgBox MsgBox
           RestartText,
 XIIIMsgBoxInGame MsgBoxIngm
           RestartText,
 ReturnText, QuitText2
           RestartText,
 bool bTeamMode
           RestartText,
 inviteReceivedIcon, friendRequestReceivedIcon
           RestartText,
 bool hasstatsstarted
           RestartText,
 statwritefailedString, statwritestartingString
           RestartText,
 int userState
           RestartText,
 XboxLiveManager xboxlive
           RestartText,
 float yPosInviteIcon
           RestartText,

States
STA_ResetInputs, NormalQuit, StatSaveQuit

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)
     
// LN
}
*/
 void MsgBoxBtnClicked(byte bButton)
 void Paint(Canvas C, float X, float Y)
 void QuitGame()
 void QuitMsgBoxReturn(byte bButton)
 void QuitMsgBoxStatCancel(byte bButton)
 void QuitMsgBoxStatOkReturn(byte bButton)
 void RestartGame()
     
/*
 void ShowWindow()


State STA_ResetInputs Function Summary


State NormalQuit Function Summary


State StatSaveQuit Function Summary



Source Code


00001	//============================================================================
00002	// The In Game menu for xbox live mode
00003	//
00004	//============================================================================
00005	class XIIIMenuInGameXboxLive extends XIIILiveWindow;
00006	
00007	#exec OBJ LOAD FILE=XIIIXboxPacket.utx
00008	
00009	var  XIIIbutton          TeamButton, OptionsButton, FriendsButton, OnlineOptionsButton, QuitButton, ReturnButton, ChangeClassButton;//, RestartButton;
00010	var  localized string    TeamText, OptionsText, QuitText, FriendsText, OnlineOptionsText, ReturnText, QuitText2;//RestartText, 
00011	var  localized string    kickedString, serverDownString, ConfirmQuitTxt;
00012	var  localized string	 statwritefailedString, statwritestartingString;
00013	
00014	var texture inviteReceivedIcon, friendRequestReceivedIcon;
00015	var float yPosInviteIcon;
00016	var int userState;
00017	
00018	var XboxliveManager xboxlive;
00019	var XIIIMsgBox MsgBox;
00020	var XIIIMsgBoxInGame MsgBoxIngm;
00021	var bool hasstatsstarted;
00022	
00023	var  bool      bTeamMode;
00024	var localized string ChangeClass;
00025	
00026	function Created()
00027	{
00028		LOCAL class<GameInfo> GameClass;
00029	
00030	  Super.Created();
00031	
00032	  if (xboxlive == none)
00033	    xboxlive=New Class'XboxLiveManager';
00034	
00035		if ( GetPlayerOwner().myHUD.bShowScores )
00036			GetPlayerOwner().myHUD.HideScores();
00037		
00038		// team mode
00039		GameClass = class<GameInfo>(dynamicloadobject(GetPlayerOwner().GameReplicationInfo.GameClass, class'class'));
00040		if ( !GameClass.default.bTeamGame || ( GetPlayerOwner().Level.NetMode == 0 ) )
00041		{
00042			bTeamMode = false;
00043		}
00044		else
00045		{
00046			bTeamMode = true;
00047		}
00048	
00049	     ReturnButton = XIIIbutton(CreateControl(class'XIIIbutton', 230, 135*fScaleTo, 200, 30));
00050	     ReturnButton.Text = ReturnText;
00051	     ReturnButton.bNoBg =true;
00052	
00053	     TeamButton = XIIIbutton(CreateControl(class'XIIIbutton', 230, 175*fScaleTo, 200, 30));
00054	     TeamButton.Text = TeamText;
00055	     TeamButton.bNoBg =true;
00056	
00057	     OptionsButton = XIIIbutton(CreateControl(class'XIIIbutton', 230, 215*fScaleTo, 200, 30));
00058	     OptionsButton.Text = OptionsText;
00059	     OptionsButton.bNoBg =true;
00060	
00061	     FriendsButton = XIIIbutton(CreateControl(class'XIIIbutton', 230, 255*fScaleTo, 200, 30));
00062	     FriendsButton.Text = FriendsText;
00063	     FriendsButton.bNoBg =true;
00064	
00065	     //PlayersButton = XIIIbutton(CreateControl(class'XIIIbutton', 230, 275*fScaleTo, 200, 30));
00066	     //PlayersButton.Text = PlayersText;
00067	     //PlayersButton.bNoBg =true;
00068	
00069	     OnlineOptionsButton       = XIIIbutton(CreateControl(class'XIIIbutton', 230, 295*fScaleTo, 200, 30));
00070	     OnlineOptionsButton.Text  = OnlineOptionsText;
00071	     OnlineOptionsButton.bNoBg = true;
00072	
00073	     ChangeClassButton       = XIIIbutton(CreateControl(class'XIIIbutton', 230, 325*fScaleTo, 200, 30));
00074	     ChangeClassButton.Text  = ChangeClass;
00075	     ChangeClassButton.bNoBg = true;
00076	     
00077	     if (GetPlayerOwner().GameReplicationInfo.GameClass != "XIIIMP.XIIIMPBombGame")
00078	     {
00079	       ChangeClassButton.bVisible = false;
00080	     }
00081	
00082	     //RestartButton = XIIIbutton(CreateControl(class'XIIIbutton', 230, 325*fScaleTo, 200, 30));
00083	     //RestartButton.Text = RestartText;
00084	     //RestartButton.bNoBg =true;
00085	
00086	     QuitButton = XIIIbutton(CreateControl(class'XIIIbutton', 230, 375*fScaleTo, 200, 30));
00087	     QuitButton.Text = QuitText;
00088	     QuitButton.bNoBg =true;
00089	
00090	    Controls[0] = ReturnButton;  Controls[1] = TeamButton; Controls[2] = OptionsButton;
00091	    Controls[3] = FriendsButton; Controls[4] = OnlineOptionsButton; /*Controls[5] = RestartButton;*/ Controls[5] = ChangeClassButton; Controls[6] = QuitButton;
00092	
00093	    bPauseIfPossible=false;
00094	    
00095	    hasstatsstarted = false;
00096		GotoState('STA_ResetInputs');
00097	}
00098	
00099	
00100	function MsgBoxBtnClicked(byte bButton)
00101	{
00102	  if (bButton == QBTN_Continue)
00103	    bDoQuitGame = true;
00104	}
00105	
00106	function BeforePaint(Canvas C, float X, float Y)
00107	{
00108	  super.BeforePaint(C, X, Y);
00109	
00110	  if (bDoQuitGame)
00111	  {
00112	    QuitGame();
00113	    return;
00114	  }
00115	  /*if (bDoRestartGame)
00116	  {
00117	    RestartGame();
00118	    return;
00119	  }*/
00120	
00121	  if (myRoot.ActivePage == self && (xboxlive.IsServerDown() || xboxlive.IsKicked()))
00122	  {
00123	    Controller.OpenMenu("XIDInterf.XIIIMsgBox");
00124	    msgbox = XIIIMsgBox(myRoot.ActivePage);
00125	    if (xboxlive.IsKicked())
00126	      msgbox.SetupQuestion(kickedString, QBTN_Continue, QBTN_Continue);
00127	    else
00128	      msgbox.SetupQuestion(serverDownString, QBTN_Continue, QBTN_Continue);
00129	    msgbox.OnButtonClick=MsgBoxBtnClicked;
00130	    msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo);
00131	    xboxlive.ResetVoiceNet();
00132	  }
00133	}
00134	
00135	function Paint(Canvas C, float X, float Y)
00136	{
00137	  local float alphavalue;
00138	  local float yoffs;
00139	  
00140	  yoffs = 20.0;
00141	
00142	  Super.Paint(C,X,Y);
00143	
00144	  C.Style = 1;
00145	  C.bUseBorder = true;
00146	  C.DrawColor = WhiteColor;  //220      100 / 130              220         260   230
00147	
00148	  if (!bTeamMode)
00149	    DrawStretchedTexture(C, 185*fRatioX, (100+yoffs)*fRatioY*fScaleTo, 290*fRatioX, 240*fRatioY*fScaleTo, myRoot.FondMenu);
00150	  else
00151	    DrawStretchedTexture(C, 185*fRatioX, (100+yoffs)*fRatioY*fScaleTo, 290*fRatioX, 240*fRatioY*fScaleTo, myRoot.FondMenu);
00152	  C.bUseBorder = false;
00153	
00154	  if (/*xboxlive.IsLoggedIn(xboxlive.GetCurrentUser()) && */xboxlive.HasInvite())
00155	  {
00156	    // render an invite icon
00157	    if (!bTeamMode)
00158	      C.SetPos( 185.0*fRatioX + 5, yPosInviteIcon+yoffs/*205.0*/ + 15.0 - 16.0);
00159	    else
00160	      C.SetPos(185.0*fRatioX + 5, /*(245.0 - 35.0)*/ yPosInviteIcon +yoffs + 15.0 - 16.0);
00161	
00162	    alphavalue      = abs(sin(XIIIPlayerController(GetPlayerOwner()).Player.Actor.Level.TimeSeconds*4.0))*255.0;
00163	    C.DrawColor = WhiteColor;
00164	    C.DrawColor.A = alphavalue;
00165	    C.Style = 5; // ERenderStyle.STY_Alpha;
00166	    C.DrawTile(inviteReceivedIcon, inviteReceivedIcon.USize, inviteReceivedIcon.VSize, 0, 0, inviteReceivedIcon.USize, inviteReceivedIcon.VSize);
00167	    C.Style = 1; // ERenderStyle.STY_Normal;
00168	  }
00169	  else if (xboxlive.HasFriendRequest())
00170	  {
00171	    // render a friend request icon
00172	    if (XIIIPlayerController(GetPlayerOwner()).Player.Actor.Level.Game.IsA('XIIIMPTeamGameInfo') == false)
00173	      C.SetPos( 185.0*fRatioX + 5, yPosInviteIcon+yoffs/*205.0*/ + 15.0 - 16.0);
00174	    else
00175	      C.SetPos(185.0*fRatioX + 5, /*(245.0 - 35.0)*/ yPosInviteIcon +yoffs+ 15.0 - 16.0);
00176	
00177	    alphavalue      = abs(sin(XIIIPlayerController(GetPlayerOwner()).Player.Actor.Level.TimeSeconds*4.0))*255.0;
00178	    C.DrawColor = WhiteColor;
00179	    C.DrawColor.A = alphavalue;
00180	    C.Style = 5; // ERenderStyle.STY_Alpha;
00181	    C.DrawTile(friendRequestReceivedIcon, friendRequestReceivedIcon.USize, friendRequestReceivedIcon.VSize, 0, 0, friendRequestReceivedIcon.USize, friendRequestReceivedIcon.VSize);
00182	    C.Style = 1; // ERenderStyle.STY_Normal;
00183	  }
00184	}
00185	
00186	
00187	// Called when a button is clicked
00188	function bool InternalOnClick(GUIComponent Sender)
00189	{
00190	  local XIIIMsgBoxInGame msgbox;
00191	  local float yoffs;
00192	  yoffs = 20.0;
00193	  
00194	  /*if (Sender == RestartButton)
00195	  {
00196	    myRoot.OpenMenu("XIDInterf.XIIIMenuYesNoWindow");
00197	  }
00198	  else */
00199	  if (Sender == TeamButton)
00200	  {
00201	    myRoot.CloseAll(true);
00202	    myRoot.GotoState('');
00203	    GetPlayerOwner().ConsoleCommand("SwitchTeam");
00204	  }
00205	  else if (Sender == OptionsButton)
00206	  {
00207	    //if (myRoot.CurrentPF > 0)
00208	    myRoot.OpenMenu("XIDInterf.XIIIMultiControlsWindow");
00209	    //else
00210	    //  myRoot.OpenMenu("XIDInterf.XIIIMenuInputPC");
00211	  }
00212	  else if (Sender == returnButton)
00213	  {
00214	    myRoot.CloseAll(true);
00215	    myRoot.GotoState('');
00216	  }
00217	  else if (Sender == FriendsButton)
00218	  {
00219	    //myRoot.OpenMenu("XIDInterf.XIIIMenuLiveFriendsMainPage");
00220	    myRoot.OpenMenu("XIDInterf.XIIIMenuLivePlayerList");
00221	  }
00222	  //else if (Sender == PlayersButton)
00223	  //{
00224	  //  myRoot.OpenMenu("XIDInterf.XIIIMenuLivePlayerList");
00225	  //}
00226	  else if (Sender == OnlineOptionsButton)
00227	  {
00228	    myRoot.OpenMenu("XIDInterf.XIIIMenuLiveSettings");
00229	  }
00230	  else if (Sender == ChangeClassButton)
00231	  {
00232	    myRoot.OpenMenu("XIDInterf.XIIIMenuInGameLiveSabotage");
00233	  }
00234	  else if (Sender == QuitButton)
00235	  {
00236			bShowBCK = false;
00237			myRoot.OpenMenu("XIDInterf.XIIIMsgBoxInGame");
00238			MsgBox = XIIIMsgBoxInGame(myRoot.ActivePage);
00239			
00240	  if (!bTeamMode)
00241			MsgBox.InitBox(185*fRatioX, (100+yoffs)*fRatioY*fScaleTo, 10, 10, 290*fRatioX, 240*fRatioY*fScaleTo);
00242	  else
00243			MsgBox.InitBox(185*fRatioX, (100+yoffs)*fRatioY*fScaleTo, 10, 10, 290*fRatioX, 240*fRatioY*fScaleTo);
00244	  		
00245	    if (xboxlive.IsHost())
00246			  MsgBox.SetupQuestion(QuitText2, QBTN_Yes | QBTN_No, QBTN_No,"");
00247			else
00248			  MsgBox.SetupQuestion(ConfirmQuitTxt, QBTN_Yes | QBTN_No, QBTN_No,"");
00249			MsgBox.OnButtonClick = QuitMsgBoxReturn;
00250	    
00251	    //myRoot.OpenMenu("XIDInterf.XIIIMenuYesNoWindow");
00252	    //XIIIMenuYesNoWindow(myRoot.ActivePage).bQuitGame = true;
00253	    //if (xboxlive.IsHost())
00254	    //  XIIIMenuYesNoWindow(myRoot.ActivePage).QuitText = QuitText2;
00255	  }
00256	  return true;
00257	}
00258	
00259	function QuitMsgBoxReturn(byte bButton)
00260	{
00261		bShowBCK = true;
00262		if ((bButton & QBTN_Yes) != 0)
00263		{
00264			QuitGame();
00265		}
00266	}
00267	
00268	function QuitGame()
00269	{
00270		myRoot.OpenMenu("XIDInterf.XIIIMenuLiveStatsWritePage");	
00271	//GotoState('StatSaveQuit');
00272	//GotoState   StatUpdate;
00273	
00274	}
00275	
00276	/*
00277	function RestartGame()
00278	{
00279	    bDoRestartGame = false;
00280	    //myRoot.bProfileMenu = true;
00281	    myRoot.CloseAll(true);
00282	    myRoot.GotoState('');
00283	//        GetPlayerOwner().ConsoleCommand("RestartLevel");
00284	// NL        GetPlayerOwner().ClientTravel( "?restart", TRAVEL_Relative, false );
00285	        myRoot.Master.GlobalInteractions[0].ViewportOwner.Actor.ClientTravel( "?restart", TRAVEL_Relative, false );
00286	// LN
00287	}
00288	*/
00289	
00290	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
00291	{
00292	    local int index;
00293	    local bool bLeftOrRight, bUpOrDown;
00294	    local controller P;
00295	
00296	if(hasstatsstarted == false)
00297	{
00298	    if (State==1)// IST_Press // to avoid auto-repeat
00299	    {
00300	        if ((Key==0x0D/*IK_Enter*/) || (Key==0x01))
00301		{
00302	//            Controller.FocusedControl.OnClick(FocusedControl);
00303			return InternalOnClick(FocusedControl);
00304		}
00305		if (Key==0x08 || Key==0x1B/*IK_Backspace - IK_Escape*/)
00306		{
00307			myRoot.CloseAll(true);
00308	        	myRoot.GotoState('');
00309	        	for ( P=myRoot.GetLevel().ControllerList; P!=None; P=P.NextController )
00310	           	{
00311	                	if (XIIIRootWindow(PlayerController(P).Player.LocalInteractions[0]).bIamInMulti == true)
00312	                	myRoot.GetPlayerOwner().Player.Actor.SetPause( true );
00313	            	}
00314	          	xboxlive.EnumerateFriends(FALSE);
00315	    	    	return true;
00316		}
00317		if (Key==0x26/*IK_Up*/)
00318		{
00319			PrevControl(FocusedControl);
00320			return true;
00321		}
00322		if (Key==0x28/*IK_Down*/)
00323		{
00324			NextControl(FocusedControl);
00325			return true;
00326		}
00327	        //return false;
00328	    }
00329	}
00330	    return super.InternalOnKeyEvent(Key, state, delta);
00331	//    return false;
00332	}
00333	
00334	
00335	function ShowWindow()
00336	{
00337		local int yMove;
00338		
00339		yMove = 20;
00340	
00341		xboxlive.EnumerateFriends(TRUE);
00342		
00343		xboxlive.UpdateFriends();
00344		
00345		   log("AJ  "$bTeamMode);
00346	     //if ( (XIIIPlayerContrOller(GetPlayerOwner()).Player.Actor.Level.Game.IsA('XIIIMPTeamGameInfo') == false) ||
00347	     //    ( GetPlayerOwner().Level.NetMode == 0 ) )
00348	     if (!bTeamMode)
00349	     {
00350	        TeamButton.bNeverFocus = true;
00351	        TeamButton.bVisible = false;
00352	//        bNotATeamGame = true;
00353	//        RestartButton.WinTop = 55; OptionsButton.WinTop = 95;
00354	        //OptionsButton.WinTop = (205*fScaleTo/480); restartButton.WinTop = (255*fScaleTo/480);
00355	        //yMove = -10;
00356	        ReturnButton.WinTop  = ((125 + yMove) *fScaleTo/480);
00357	        //TeamButton.WinTop    = ((165 + yMove)*fScaleTo/480);
00358	        //yMove -= 20;
00359	        OptionsButton.WinTop = ((165 + yMove)*fScaleTo/480);
00360	        FriendsButton.WinTop = ((205 + yMove)*fScaleTo/480);
00361	        yPosInviteIcon = ((205 + yMove)*fScaleTo);
00362	        //AJPlayersButton.WinTop = ((245 + yMove)*fScaleTo/480);
00363	        OnlineOptionsButton.WinTop  = ((245 + yMove)*fScaleTo/480);
00364	        //RestartButton.WinTop = ((285 + yMove)*fScaleTo/480);
00365	        //yMove += 20;
00366	        QuitButton.WinTop    = ((285 + yMove)*fScaleTo/480);
00367	
00368	
00369	     }
00370	     else {
00371	        TeamButton.bNeverFocus = false;
00372	        TeamButton.bVisible = true;
00373	//        TeamButton.WinTop = 75;
00374	        //bNotATeamGame = false;
00375	//        RestartButton.WinTop = 35; OptionsButton.WinTop = 115;
00376	        //OptionsButton.WinTop = (215*fScaleTo/480); restartButton.WinTop = (275*fScaleTo/480);
00377	
00378	        //yMove = 0;
00379	        ReturnButton.WinTop  = ((125 + yMove - 10) *fScaleTo/480);
00380	        TeamButton.WinTop    = ((165 + yMove - 15)*fScaleTo/480);
00381	        OptionsButton.WinTop = ((205 + yMove - 25)*fScaleTo/480);
00382	        FriendsButton.WinTop = ((245 + yMove - 35)*fScaleTo/480);
00383	        yPosInviteIcon = ((245 + yMove - 35)*fScaleTo);
00384	        //AJPlayersButton.WinTop = ((285 + yMove - 35)*fScaleTo/480);
00385	        OnlineOptionsButton.WinTop = ((285 + yMove - 45)*fScaleTo/480);
00386	        //RestartButton.WinTop = ((325 + yMove - 55)*fScaleTo/480);
00387	        ChangeClassButton.WinTop = ((325 + yMove - 55)*fScaleTo/480);
00388	        QuitButton.WinTop    = ((365 + yMove - 65)*fScaleTo/480);
00389	
00390	     }
00391	     Super.ShowWindow();
00392	     // MLK The help bar text for this screen
00393	     bShowBCK = true;
00394	     bShowSEL = true;
00395	}
00396	
00397	function QuitMsgBoxStatOkReturn(byte bButton)
00398	{
00399		bShowBCK = false;
00400		if ((bButton & QBTN_Ok) != 0)
00401		{
00402			GotoState('NormalQuit');
00403		}
00404	}
00405	
00406	function QuitMsgBoxStatCancel(byte bButton)
00407	{
00408		bShowBCK = false;
00409		if ((bButton & QBTN_Cancel) != 0)
00410		{
00411			//GotoState('normalquit');
00412		}
00413	}
00414	
00415	
00416	State StatSaveQuit
00417	{
00418	Begin:	
00419		//myRoot.OpenMenu("XIDInterf.XIIIMenuLiveStatsWritePage");
00420		
00421		//if(!hasstatsstarted)
00422		//{
00423		//	XIIIMPPlayerController(GetPlayerOwner()).StatUpdate();
00424		//	hasstatsstarted = true;
00425		//}
00426	    
00427		//while (xboxlive.IsMyStatsUpdateDone() == false)
00428		//{
00429		//	Sleep(0.01);
00430		//}
00431		
00432		//if(xboxlive.WasMyStatsUpdateSuccessful() == false)
00433		//{
00434		//	myRoot.OpenMenu("XIDInterf.XIIIMsgBoxInGame");
00435		//	MsgBoxIngm = XIIIMsgBoxInGame(myRoot.ActivePage);
00436		//	MsgBoxIngm.InitBox(220*fRatioX, 130*fRatioY*fScaleTo, 10, 10, 220*fRatioX, 230*fRatioY*fScaleTo);
00437		//	MsgBoxIngm.SetupQuestion(statwritefailedString, QBTN_Ok, QBTN_Ok,"");
00438		//	MsgBoxIngm.OnButtonClick = QuitMsgBoxStatOkReturn;
00439		//}
00440		
00441		//GotoState('NormalQuit');
00442	}
00443	
00444	State NormalQuit
00445	{
00446	Begin:
00447	      userState = xboxlive.US_ONLINE;
00448	      if (xboxlive.HasUserVoice(xboxlive.GetCurrentUser()))
00449	        userState = userState | xboxlive.US_VOICE;
00450	      xboxlive.SetUserState(xboxlive.GetCurrentUser(), userState);
00451	
00452	        xboxlive.EnumerateFriends(FALSE);
00453	
00454	        xboxlive.ResetVoiceNet();
00455	
00456	        GetPlayerOwner().myHUD.bShowScores = false;
00457	        GetPlayerOwner().myHUD.bHideHud = true;
00458	
00459	        myRoot.CloseAll(true);
00460	        myRoot.GotoState('');
00461	
00462	        myRoot.Master.GlobalInteractions[0].ViewportOwner.Actor.ClientTravel("MapMenu", TRAVEL_Absolute, false);
00463	
00464		GotoState('');
00465	}
00466	
00467	State STA_ResetInputs
00468	{
00469	Begin:
00470		Sleep(0.1);
00471		GetPlayerOwner().ResetInputs();
00472		GotoState('');
00473	}
00474	
00475	

End Source Code