## XIDInterf
Class XIIIMenuLiveJoinFriendWindow

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

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

Direct Known Subclasses:None

class XIIIMenuLiveJoinFriendWindow
extends XIDInterf.XIIILiveWindow

Variables
`string` | `AutoLoginName`
`int` | `BackFromJoin`
`bool` | `BackFromJoinNotNow`
`bool` | `ConnectingToGame`
`bool` | `UpdateMe`
`failedToJoinSessionString,` | `sameSessionString`
`float` | `starttime`

Function Summary
`void` | `Created()`
`string` | `GetPageParameters()`
    // if subclassed, this parent function must always be called first
`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` | `Paint(Canvas C, float X, float Y)`
`void` | `Process()`
`void` | `ProcessConnect()`
`void` | `SetPageParameters(string PageParameters)`
    // if GetPageParameters() is subclassed, you'd better have this one too !
`void` | `ShowWindow()`

Source Code

    00001	class XIIIMenuLiveJoinFriendWindow extends XIIILiveWindow;
    00002
    00003	var localized string TitleText, failedToFindSessionString, failedToJoinSessionString, sameSessionString;
    00004
    00005	var bool UpdateMe;
    00006	var bool ConnectingToGame;
    00007	var float starttime;
    00008
    00009	var int BackFromJoin;
    00010	var bool BackFromJoinNotNow;
    00011	var string AutoLoginName;
    00012
    00013
    00014	function Created()
    00015	{
    00016	  Super.Created();
    00017	}
    00018
    00019	function InitComponent(GUIController MyController,GUIComponent MyOwner)
    00020	{
    00021	  local int numberOfAccounts;
    00022	  local int i, msg;
    00023
    00024	  Super.InitComponent(MyController, MyOwner);
    00025
    00026		OnClick = InternalOnClick;
    00027
    00028		if (!xboxlive.IsLoggedIn(xboxlive.GetCurrentUser()))
    00029		  return;
    00030
    00031		if (xboxlive.IsJoiningAfterBoot() && !xboxlive.FriendFindSession(xboxlive.GetFriendInviterAfterBoot()))
    00032	  { // Failed to find friend session
    00033	    // Show error in messagebox
    00034	    //msg = xboxlive.GetLastError();
    00035	    Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
    00036	    msgbox = XIIILiveMsgBox(myRoot.ActivePage);
    00037	    msgbox.SetupQuestion(failedToFindSessionString, QBTN_Ok, QBTN_Ok);
    00038	    msgbox.OnButtonClick=MsgBoxBtnClicked;
    00039	    msgbox.InitBox(120, 130, 16, 16, 400, 230);
    00040	  }
    00041	  else if (xboxlive.FriendIsInSameSession(xboxlive.GetActiveFriendName()))
    00042	  { // Friend is considered to be in same session already
    00043	    // Show error in messagebox
    00044	    //msg = xboxlive.GetLastError();
    00045	    Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
    00046	    msgbox = XIIILiveMsgBox(myRoot.ActivePage);
    00047	    msgbox.SetupQuestion(sameSessionString, QBTN_Ok, QBTN_Ok);
    00048	    msgbox.OnButtonClick=MsgBoxBtnClicked;
    00049	    msgbox.InitBox(120, 130, 16, 16, 400, 230);
    00050	  }
    00051	  else if (!xboxlive.IsJoiningAfterBoot() && !xboxlive.FriendFindSession(xboxlive.GetActiveFriendName()))
    00052	  { // Failed to find friend session
    00053	    // Show error in messagebox
    00054	    //msg = xboxlive.GetLastError();
    00055	    Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
    00056	    msgbox = XIIILiveMsgBox(myRoot.ActivePage);
    00057	    msgbox.SetupQuestion(failedToFindSessionString, QBTN_Ok, QBTN_Ok);
    00058	    msgbox.OnButtonClick=MsgBoxBtnClicked;
    00059	    msgbox.InitBox(120, 130, 16, 16, 400, 230);
    00060	  }
    00061	  else
    00062	  {
    00063	    Log("Trying to find friend session...");
    00064	    UpdateMe = true;
    00065	  }
    00066	  xboxlive.ResetJoiningAfterBoot();
    00067	}
    00068
    00069	function ShowWindow()
    00070	{
    00071	     OnMenu = 0; myRoot.bFired = false;
    00072	     Super.ShowWindow();
    00073	     bShowBCK = true;
    00074	     bShowRUN = false;
    00075	     bShowSEL = false;
    00076	}
    00077
    00078	function Process()
    00079	{
    00080	  local int msg;
    00081	  if (!xboxlive.FriendFindIsFinished())
    00082	  { // Not finished or failed?
    00083	    msg = xboxlive.GetLastError();
    00084	    if (msg != 0 && msg != 130)
    00085	    { // Failed!
    00086	      UpdateMe = false;
    00087	      // Show error in messagebox
    00088	      Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
    00089	      msgbox = XIIILiveMsgBox(myRoot.ActivePage);
    00090	      msgbox.SetupQuestion(failedToJoinSessionString, QBTN_Ok, QBTN_Ok);
    00091	      msgbox.OnButtonClick=MsgBoxBtnClicked;
    00092	      msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo);
    00093	    }
    00094	  }
    00095	  else
    00096	  { // Finished!!
    00097	    Log("Found friend session!!");
    00098	    if (!xboxlive.FriendJoinSession())
    00099	    { // Failed to join friends session
    00100	      // Show error in messagebox
    00101	      msg = xboxlive.GetLastError();
    00102	      Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
    00103	      msgbox = XIIILiveMsgBox(myRoot.ActivePage);
    00104	      msgbox.SetupQuestion(failedToFindSessionString, QBTN_Ok, QBTN_Ok);
    00105	      msgbox.OnButtonClick=MsgBoxBtnClicked;
    00106	      msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo);
    00107	    }
    00108	    UpdateMe = false;
    00109
    00110	    Log("Trying to join friend session!!");
    00111	    starttime = GetPlayerOwner().Level.TimeSeconds;
    00112	    Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
    00113	    msgbox = XIIILiveMsgBox(myRoot.ActivePage);
    00114	    msgbox.SetupQuestion(pleaseWaitString, 0, 0, "Connecting");
    00115	    msgbox.OnButtonClick=MsgBoxBtnClicked;
    00116	    msgbox.InitBox(160*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 320*fRatioX, 230*fRatioY*fScaleTo);
    00117	    ConnectingToGame = true;
    00118	  }
    00119	}
    00120
    00121	function ProcessConnect()
    00122	{
    00123	  local int msg;
    00124	  local string URL;
    00125	  local XIIIMenuLiveJoinMsgBox JoinMsgbox;
    00126	  local string MyClass, SkinCode;
    00127		local int i;
    00128
    00129	  if (xboxlive.FriendJoinIsFinished() /*&& (GetPlayerOwner().Level.TimeSeconds - starttime)>2.0*/)
    00130	  {
    00131	    Log("Joined friend session!!");
    00132	    ConnectingToGame = false;
    00133	    // Connect to URL
    00134	    URL = xboxlive.FriendJoinGetURL();
    00135	    if (URL != "")
    00136	    {
    00137	      myRoot.CloseMenu(true);
    00138
    00139	      BackFromJoin=1;
    00140	      AutoLoginName=xboxlive.GetCurrentUser();
    00141	      BackFromJoinNotNow=true;
    00142
    00143	      Controller.OpenMenu("XIDInterf.XIIIMenuLiveJoinMsgBox");
    00144	      JoinMsgbox = XIIIMenuLiveJoinMsgBox(myRoot.ActivePage);
    00145	      JoinMsgbox.InitBox(220*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 220*fRatioX, 230*fRatioY*fScaleTo);//, true);
    00146	      JoinMsgbox.MsgBoxStatus = 100;
    00147	      JoinMsgbox.URL = URL;//$"?SK="$SkinCode;
    00148	    }
    00149	  }
    00150	  else
    00151	  {
    00152	    msg = xboxlive.GetLastError();
    00153	    if (msg == 0) // Still waiting?
    00154	      return;
    00155
    00156	    // Error!
    00157	    myRoot.CloseMenu(true);
    00158	    Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
    00159	    msgbox = XIIILiveMsgBox(myRoot.ActivePage);
    00160	    msgbox.SetupQuestion(failedToJoinSessionString, QBTN_Ok, QBTN_Ok);
    00161	    msgbox.OnButtonClick=MsgBoxBtnClicked;
    00162	    msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo);
    00163	    ConnectingToGame = false;
    00164	  }
    00165	}
    00166
    00167	// if subclassed, this parent function must always be called first
    00168	function string GetPageParameters()
    00169	{
    00170	    return Super.GetPageParameters()$"?BackFromJoin="$BackFromJoin$"?AutoLoginName="$xboxlive.ConvertString(AutoLoginName);
    00171	}
    00172
    00173	// if GetPageParameters() is subclassed, you'd better have this one too !
    00174	function SetPageParameters(string PageParameters)
    00175	{
    00176	    log("SetPageParameters("$PageParameters$") called for "$self);
    00177
    00178	    BackFromJoin = int(localParseOption(PageParameters, "BackFromJoin", ""));
    00179	    AutoLoginName = xboxlive.UnconvertString((localParseOption(PageParameters, "AutoLoginName", "")));
    00180	}
    00181
    00182	event Tick(float deltatime)
    00183	{
    00184	  if (Controller != none && BackFromJoin==1 && !BackFromJoinNotNow)
    00185	  {
    00186	    log("Back from join and autologinname exist!");
    00187	    //BackFromJoin=0;
    00188	    //BackFromJoinNotNow=false;
    00189	    while (XIIIMenuLiveAccountWindow(myRoot.ActivePage)==none)
    00190	    myRoot.CloseMenu(true);
    00191	    //myRoot.CloseMenu(true);
    00192	    log("Back from join and autologinname exist (2)");
    00193	    Controller.OpenMenu("XIDInterf.XIIIMenuLiveAccountWindow", true);
    00194	    XIIIMenuLiveAccountWindow(myRoot.ActivePage).AutoLoginUser = AutoLoginName;
    00195	    log("Back from join and autologinname exist (3)");
    00196	    return;
    00197	  }
    00198	}
    00199
    00200	function Paint(Canvas C, float X, float Y)
    00201	{
    00202	  if (UpdateMe)
    00203	    Process();
    00204
    00205	  if (ConnectingToGame)
    00206	    ProcessConnect();
    00207
    00208	  Super.Paint(C, X, Y);
    00209	  PaintStandardBackground(C, X, Y, TitleText);
    00210	}
    00211
    00212
    00213	// Called when a button is clicked
    00214	function bool InternalOnClick(GUIComponent Sender)
    00215	{
    00216	    local int i,sel,msg;
    00217	    if (ConnectingToGame)
    00218	      return true;
    00219
    00220	/*
    00221	    if (sel >= 0 && sel < listbox.list.Elements.length)
    00222	    {
    00223	      if (!xboxlive.QuickmatchJoinSession(sel))
    00224	      {
    00225	        msg = xboxlive.GetLastError();
    00226	        Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
    00227	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
    00228	        msgbox.SetupQuestion(xboxlive.GetErrorString(msg), QBTN_Ok, QBTN_Ok);
    00229	        msgbox.OnButtonClick=MsgBoxBtnClicked;
    00230	        msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo);
    00231	      }
    00232	      else
    00233	      {
    00234	        starttime = GetPlayerOwner().Level.TimeSeconds;
    00235	        Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
    00236	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
    00237	        msgbox.SetupQuestion(pleaseWaitString, 0, 0, "Connecting");
    00238	        msgbox.OnButtonClick=MsgBoxBtnClicked;
    00239	        msgbox.InitBox(160*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 320*fRatioX, 230*fRatioY*fScaleTo);
    00240	        ConnectingToGame = true;
    00241	      }
    00242	    }
    00243	*/
    00244	    return true;
    00245
} 00246 00247 function MsgBoxBtnClicked(byte bButton) 00248 { 00249 switch (bButton) 00250 { 00251 case QBTN_Ok: 00252 myRoot.CloseMenu(true); 00253 /*log("[XIIILiveMsgBox] Ok pressed"); 00254 xboxlive.ShutdownAndCleanup(); 00255 myRoot.CloseMenu(true); 00256 Controller.ReplaceMenu("XIDInterf.XIIIMenuLiveAccountWindow"); 00257 */ 00258 break; 00259 } 00260 //log("msgbox clicked: "$bButton); 00261 } 00262 00263 function bool InternalOnKeyEvent(out byte Key, out byte State, float delta) 00264 { 00265 local int msg; 00266 if (state==1/* || state==2*/)// IST_Press // to avoid auto-repeat 00267 { 00268 if ((Key==0x0D/*IK_Enter*/) || (Key==0x01)) 00269 { 00270 //Controller.FocusedControl.OnClick(Self); 00271 InternalOnClick(Controller.FocusedControl); 00272 return true; 00273 } 00274 if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B)) 00275 { 00276 //xboxlive.QuickmatchCancelQuery(); 00277 myRoot.CloseMenu(true); 00278 return true; 00279 } 00280 } 00281 return super.InternalOnKeyEvent(Key, state, delta); 00282 } 00283 00284 00285

End Source Code