XIDInterf
Class XIIIMenuLiveFriendsOnline

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

class XIIIMenuLiveFriendsOnline
extends XIDInterf.XIIILiveWindow


Variables
 string ButtonNames[4]
 XIIIGUIButton Buttons[3]
 string TitleText
 bool acceptinvite
 XboxLiveManager.FRIEND_PACKET activeFriend
 string activeFriendName
 XIIILiveMsgBox msgbox
 string pleaseInsertGameString
 int popupStatus
 strLeaving, strNoSession
 bool waitForUserToReboot


Function Summary
 void Created()
 void InitComponent(GUIController MyController, GUIComponent MyOwner)
 bool InternalOnClick(GUIComponent Sender)
     
// Called when a button is clicked
 bool InternalOnKeyEvent(out byte, out byte, float delta)
 void MsgBoxBtnClicked(byte bButton)
 void MsgBoxBtnClicked2(byte bButton)
 void Paint(Canvas C, float X, float Y)
 void ReturnMsgBox(byte bButton)
 void ShowWindow()



Source Code


00001	class XIIIMenuLiveFriendsOnline extends XIIILiveWindow;
00002	
00003	var localized string TitleText;
00004	
00005	var XIIIGUIButton Buttons[3];
00006	var localized string ButtonNames[4];
00007	var localized string strOnline, strAcceptGameInviteQuestion, strJoinFriend, strRemoveFriendQuestion, strSendGameInviteQuestion, strLeaving, strNoSession;
00008	var bool acceptinvite;
00009	var XboxLiveManager.FRIEND_PACKET activeFriend;
00010	var string                        activeFriendName;
00011	
00012	var localized string pleaseInsertGameString;
00013	
00014	var bool waitForUserToReboot;
00015	
00016	var XIIILiveMsgBox msgbox;
00017	var int popupStatus;
00018	
00019	function Created()
00020	{
00021	  local int i;
00022	     Super.Created();
00023	
00024	}
00025	
00026	
00027	function InitComponent(GUIController MyController,GUIComponent MyOwner)
00028	{
00029	
00030	  Super.InitComponent(MyController, MyOwner);
00031	
00032		Buttons[0] = XIIIGUIButton(Controls[0]);
00033		Buttons[0].Caption = ButtonNames[0];
00034		Buttons[1] = XIIIGUIButton(Controls[1]);
00035		Buttons[1].Caption = ButtonNames[1];
00036		Buttons[2] = XIIIGUIButton(Controls[2]);
00037		Buttons[2].Caption = "";//ButtonNames[2];
00038	
00039		OnClick = InternalOnClick;
00040	
00041	}
00042	
00043	
00044	function ShowWindow()
00045	{
00046	  local bool insamesession;
00047	
00048	  OnMenu = 0; myRoot.bFired = false;
00049	  Super.ShowWindow();
00050	  bShowBCK = true;
00051	  bShowRUN = false;
00052	  bShowSEL = true;
00053	
00054	  activeFriend = xboxlive.GetActiveFriend();
00055	  activeFriendName = xboxlive.GetActiveFriendName();
00056	
00057	  TitleText = activeFriendName $ " - " $ strOnline;
00058	
00059	//  ButtonNames(0)="Send a game invitation"
00060	//  ButtonNames(1)="Remove friend"
00061	//  ButtonNames(2)="Join"
00062	
00063	  insamesession = xboxlive.IsInSameSession(activeFriendName);
00064	  if ( (activeFriend.onlineStatusFlags & xboxlive.XONLINE_FRIENDSTATE_FLAG_RECEIVEDINVITE) != 0 && !insamesession)
00065	  {
00066	    Buttons[2].bVisible=true;
00067	    Buttons[2].Caption = ButtonNames[3];
00068	  }
00069	  else if ( (activeFriend.onlineStatusFlags & xboxlive.XONLINE_FRIENDSTATE_FLAG_JOINABLE) != 0 && !insamesession)
00070	  {
00071	    Buttons[2].bVisible=true;
00072	    Buttons[2].Caption = ButtonNames[2];
00073	  }
00074	  else
00075	    Buttons[2].bVisible=false;
00076	
00077	
00078	  if (xboxlive.IsPlaying() && !insamesession && !xboxlive.IsLadderGame())
00079	  {
00080	    Buttons[0].bVisible=true;
00081	    SetFocus(Buttons[0]);
00082	    Buttons[0].SetFocus(none);
00083	  }
00084	  else
00085	  {
00086	    Buttons[0].bVisible=false;
00087	    SetFocus(Buttons[1]);
00088	    Buttons[1].SetFocus(none);
00089	  }
00090	
00091	}
00092	
00093	
00094	function Paint(Canvas C, float X, float Y)
00095	{
00096	     Super.Paint(C, X, Y);
00097	  PaintStandardBackground(C, X, Y, TitleText);
00098	}
00099	
00100	function MsgBoxBtnClicked(byte bButton)
00101	{
00102	  waitForUserToReboot = false;
00103	}
00104	
00105	function MsgBoxBtnClicked2(byte bButton)
00106	{
00107	  myRoot.CloseMenu(true);
00108	}
00109	
00110	function ReturnMsgBox(byte bButton)
00111	{
00112	  switch (bButton)
00113	  {
00114	    case QBTN_Ok:
00115	      if (popupStatus == 1)
00116	      {
00117	        xboxlive.SendGameInvite(activeFriendName);
00118	        myRoot.CloseMenu(true);
00119	      }
00120	      else if (popupStatus == 2)
00121	      {
00122	        xboxlive.RemoveFriend(activeFriendName);
00123	        myRoot.CloseMenu(true);
00124	      }
00125	      else if (popupStatus == 3)
00126	      {
00127	        //
00128	        if (acceptinvite)
00129	        {
00130	          xboxlive.AcceptGameInvite(activeFriendName);
00131	
00132	          if (xboxlive.FriendIsInSameGame(activeFriendName))
00133	          {
00134	            Controller.OpenMenu("XIDInterf.XIIIMenuLiveJoinFriendWindow", true);
00135	          }
00136	          else if (xboxlive.GetFriendGameName(activeFriendName) != "")
00137	          {
00138	            waitForUserToReboot = true;
00139	            //myRoot.CloseMenu(true);
00140	            Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00141	            msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00142	            msgbox.SetupQuestion(xboxlive.GetFriendGameName(activeFriendName), QBTN_Cancel, QBTN_Cancel, pleaseInsertGameString);
00143	            msgbox.OnButtonClick=MsgBoxBtnClicked;
00144	            msgbox.InitBox(160*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 320*fRatioX, 230*fRatioY*fScaleTo);
00145	          }
00146	          else // Session no longer valid
00147	          {
00148	            msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00149	            msgbox.SetupQuestion(strNoSession, QBTN_Ok, QBTN_Ok);
00150	            msgbox.OnButtonClick=MsgBoxBtnClicked2;
00151	            msgbox.InitBox(160*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 320*fRatioX, 230*fRatioY*fScaleTo);
00152	          }
00153	        }
00154	        else
00155	        {
00156	          if (xboxlive.FriendIsInSameGame(activeFriendName))
00157	          {
00158	          Controller.OpenMenu("XIDInterf.XIIIMenuLiveJoinFriendWindow",true);
00159	      }
00160	          else if (xboxlive.GetFriendGameName(activeFriendName) != "")
00161	          {
00162	            waitForUserToReboot = true;
00163	            //myRoot.CloseMenu(true);
00164	            Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00165	            msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00166	            msgbox.SetupQuestion(xboxlive.GetFriendGameName(activeFriendName), QBTN_Cancel, QBTN_Cancel, pleaseInsertGameString);
00167	            msgbox.OnButtonClick=MsgBoxBtnClicked;
00168	            msgbox.InitBox(160*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 320*fRatioX, 230*fRatioY*fScaleTo);
00169	          }
00170	          else // Session is no longer valid
00171	          {
00172	            msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00173	            msgbox.SetupQuestion(strNoSession, QBTN_Ok, QBTN_Ok);
00174	            msgbox.OnButtonClick=MsgBoxBtnClicked2;
00175	            msgbox.InitBox(160*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 320*fRatioX, 230*fRatioY*fScaleTo);
00176	          }
00177	          
00178	        }
00179	      }
00180	      popupStatus = 0;
00181	      return;
00182	    break;
00183	
00184	    case QBTN_Cancel:
00185	      popupStatus = 0;
00186	    break;
00187	
00188	  }
00189	}
00190	
00191	
00192	// Called when a button is clicked
00193	function bool InternalOnClick(GUIComponent Sender)
00194	{
00195	    local int i;
00196	
00197	  if (waitForUserToReboot)
00198	    return true;
00199	
00200	    if (Sender == Controls[0])
00201	    {
00202	      Controller.OpenMenu("XIDInterf.XIIILiveMsgBox",false);
00203	      msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00204	      msgbox.SetupQuestion(strSendGameInviteQuestion, QBTN_Ok | QBTN_Cancel, QBTN_Cancel, activeFriendName);
00205	      msgbox.OnButtonClick=ReturnMsgBox;
00206	      msgbox.InitBox(160*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 320*fRatioX, 230*fRatioY*fScaleTo);
00207	      popupStatus=1;
00208	
00209	      return true;
00210	      //Controller.OpenMenu("XIDInterf.XIIIMenuLiveJoinStartWindow");
00211	    }
00212	    else if (Sender == Controls[1])
00213	    {
00214	      // remove friend
00215	      Controller.OpenMenu("XIDInterf.XIIILiveMsgBox",false);
00216	      msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00217	      msgbox.SetupQuestion(strRemoveFriendQuestion, QBTN_Ok | QBTN_Cancel, QBTN_Cancel, activeFriendName);
00218	      msgbox.OnButtonClick=ReturnMsgBox;
00219	      msgbox.InitBox(160*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 320*fRatioX, 230*fRatioY*fScaleTo);
00220	      popupStatus=2;
00221	//      xboxlive.RemoveFriend(activeFriendName);
00222	//      myRoot.CloseMenu(true);
00223	      return true;
00224	    }
00225	    else if (Sender == Controls[2])
00226	    { // Accept game invite or join
00227	      Controller.OpenMenu("XIDInterf.XIIILiveMsgBox",false);
00228	      msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00229	
00230	      if ( (activeFriend.onlineStatusFlags & xboxlive.XONLINE_FRIENDSTATE_FLAG_RECEIVEDINVITE) != 0 )
00231	      {
00232	        if (xboxlive.IsIngame())
00233	          msgbox.SetupQuestion(strLeaving$" "$strAcceptGameInviteQuestion, QBTN_Ok | QBTN_Cancel, QBTN_Cancel, activeFriendName);
00234	        else
00235	          msgbox.SetupQuestion(strAcceptGameInviteQuestion, QBTN_Ok | QBTN_Cancel, QBTN_Cancel, activeFriendName);
00236	        acceptinvite = true;
00237	      }
00238	      else
00239	      {
00240	        if (xboxlive.IsIngame())
00241	          msgbox.SetupQuestion(strLeaving$" "$strJoinFriend, QBTN_Ok | QBTN_Cancel, QBTN_Cancel, activeFriendName);
00242	        else
00243	          msgbox.SetupQuestion(strJoinFriend, QBTN_Ok | QBTN_Cancel, QBTN_Cancel, activeFriendName);
00244	        acceptinvite = false;
00245	      }
00246	      msgbox.OnButtonClick=ReturnMsgBox;
00247	      msgbox.InitBox(160*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 320*fRatioX, 230*fRatioY*fScaleTo);
00248	      popupStatus=3;
00249	      return true;
00250	      //Controller.OpenMenu("XIDInterf.XIIIMenuLiveFriendsMainPage");
00251	    }
00252	
00253	    return true;
00254	}
00255	
00256	
00257	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
00258	{
00259	    if (state==1/* || state==2*/)// IST_Press // to avoid auto-repeat
00260	    {
00261	        if ((Key==0x0D/*IK_Enter*/) || (Key==0x01))
00262		    {
00263	          //Controller.FocusedControl.OnClick(Self);
00264	          InternalOnClick(Controller.FocusedControl);
00265	          return true;
00266		    }
00267		    if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B))
00268		    {
00269		        myRoot.CloseMenu(true);
00270	    	    return true;
00271		    }
00272		    if (Key==0x25/*IK_Left*/)
00273		    {
00274	    	    return true;
00275		    }
00276		    if (Key==0x27/*IK_Right*/)
00277		    {
00278	    	    return true;
00279		    }
00280	    }
00281	    return super.InternalOnKeyEvent(Key, state, delta);
00282	}
00283	
00284	
00285	

End Source Code