XIDInterf
Class XIIIMenuLiveAccountWindow

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

class XIIIMenuLiveAccountWindow
extends XIDInterf.XIIILiveWindow


Variables
 bool AutoLoginNotNow
 string AutoLoginUser
 newAccountString2, areYouSureString
 XIIIGUIMultiListBox listbox


Function Summary
 void Created()
 void FindAccounts()
 string GetPageParameters()
     
// if subclassed, this parent function must always be called first
 void InitComponent(GUIController MyController, GUIComponent MyOwner)
 bool InternalOnClick(GUIComponent Sender)
     
/*
 bool InternalOnKeyEvent(out byte, out byte, float delta)
 bool LoginUser(string username)
 void MsgBoxBtnClicked(byte bButton)
     
//      for (i=0; i
 void Paint(Canvas C, float X, float Y)
 void SetPageParameters(string PageParameters)
     
// if GetPageParameters() is subclassed, you'd better have this one too !
 void ShowWindow()
 void Update()



Source Code


00001	class XIIIMenuLiveAccountWindow extends XIIILiveWindow;
00002	
00003	var XIIIGUIMultiListBox listbox;
00004	
00005	var localized string newAccountString, TitleText, failedToLoginString, newAccountString2, areYouSureString;
00006	var string AutoLoginUser;
00007	var bool AutoLoginNotNow;
00008	
00009	function Created()
00010	{
00011	  local int i;
00012	     Super.Created();
00013	   bCheckNetworkCable=false;
00014	   if (xboxlive == none)
00015		   xboxlive=New Class'XboxLiveManager';
00016	    xboxlive.ShutdownAndCleanup();
00017	}
00018	
00019	
00020	function FindAccounts()
00021	{
00022	  local int accountCount,q,oldindex;
00023	  local string temp;
00024	  accountCount = xboxlive.GetNumberOfAccounts();
00025	
00026	  oldindex = listbox.list.index;
00027	    listbox.list.clear();
00028	
00029	    for (q=0; q<accountCount; q++)
00030	    {
00031	     temp = xboxlive.GetAccountName(q);
00032	     listbox.list.Add(temp);
00033	    }
00034	    listbox.list.Add(newAccountString);
00035	
00036	    if (oldindex < listbox.list.elements.length)
00037	      listbox.list.index = oldindex;
00038	}
00039	
00040	
00041	function InitComponent(GUIController MyController,GUIComponent MyOwner)
00042	{
00043	  local int numberOfAccounts;
00044	
00045	  Super.InitComponent(MyController, MyOwner);
00046	     listbox = XIIIGUIMultiListBox(Controls[0]);
00047	
00048	     FindAccounts();
00049	     listbox.bVisibleWhenEmpty = true;
00050	     listbox.SetColumnAlignment(0, 1);
00051	  if (xboxlive.IsJoiningAfterBoot())
00052	  {
00053	    if (!LoginUser(xboxlive.GetUserInvitedAfterBoot()))
00054	    {
00055	    }
00056	  }
00057	}
00058	
00059	
00060	function ShowWindow()
00061	{
00062	     OnMenu = 0; myRoot.bFired = false;
00063	     Super.ShowWindow();
00064	     bShowBCK = true;
00065	     bShowRUN = false;
00066	     bShowSEL = true;
00067	}
00068	
00069	function Update()
00070	{
00071	  if (xboxlive.IsAccountListUpdated())
00072	  {
00073	     FindAccounts();
00074	  }
00075	}
00076	
00077	
00078	function Paint(Canvas C, float X, float Y)
00079	{
00080	  if (myRoot.ActivePage == self)
00081	  {
00082	    Update();
00083	
00084	    if (!AutoLoginNotNow && AutoLoginUser != "")
00085	    {
00086	      LoginUser(AutoLoginUser);
00087	      AutoLoginUser = "";
00088	    }
00089	  }
00090	
00091	  Super.Paint(C, X, Y);
00092	  PaintStandardBackground(C, X, Y, TitleText);
00093	}
00094	
00095	
00096	// Called when a button is clicked
00097	/*
00098	function bool InternalOnClick(GUIComponent Sender)
00099	{
00100	    local int i;
00101	    if (Sender == NewButton) {
00102	      Controller.OpenMenu("XIDInterf.XIIIMenuDifficultyWindow");
00103	    XIIIMenuDifficultyWindow(myRoot.ActivePage).bLoad = true;
00104	    XIIIMenuDifficultyWindow(myRoot.ActivePage).bNewGame = true;
00105	//      for (i=0; i<myRoot.MenuStack.Length; i++)
00106	//        log(i$": "$myRoot.MenuStack[i]);
00107	    }
00108	    if (Sender == LoadButton)
00109	      Controller.OpenMenu("XIDInterf.XIIIMenuLoadGameWindow");
00110	    if (Sender == OptionsButton)
00111	      Controller.OpenMenu("XIDInterf.XIIIMenuOptions");
00112	    if (Sender == MultiButton)
00113	      Controller.OpenMenu("XIDInterf.XIIIMenuSplitSetupClient");
00114	    if (Sender == WorkButton)
00115	      Controller.OpenMenu("XIDInterf.XIIIMenuChooseMap");
00116	    if (Sender == LiveButton)
00117	      Controller.OpenMenu("XIDInterf.XIIIMenuLiveAccountWindow");
00118	    return true;
00119	}
00120	*/
00121	
00122	function MsgBoxBtnClicked(byte bButton)
00123	{
00124	  switch (bButton)
00125	  {
00126	    case QBTN_Yes:
00127	      xboxlive.ShutdownAndCleanup();
00128		    myRoot.CloseMenu(true);
00129		    xboxlive.RebootToDashboard(xboxlive.dashboardPage.DASHBOARD_ACCOUNT_CREATION);
00130	    break;
00131	    case QBTN_No:
00132	    break;
00133	  }
00134	}
00135	
00136	function bool LoginUser(string username)
00137	{
00138	  local int msg;
00139	  if (AutoLoginUser!="" || !xboxlive.HasPasscode(username))
00140	  {
00141	    xboxlive.SetCurrentUser(username);
00142	    //if (xboxlive.StartLogin(xboxlive.GetCurrentUser()))
00143	    //{
00144	      Controller.OpenMenu("XIDInterf.XIIIMenuLiveLoginWait");
00145	    //}
00146	    /*else
00147	    {
00148	      msg = xboxlive.GetLastError();
00149	      Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00150	      msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00151	      if (msg == 21) // XBLE_LOGON_SERVERS_TOO_BUSY
00152	      {
00153	        msgbox.SetupQuestion(serverBusyString, QBTN_Ok|QBTN_Cancel, QBTN_Ok);
00154	        msgbox.OnButtonClick=MsgBoxRetryBtnClicked;
00155	      }
00156	      else
00157	      {
00158	        msgbox.SetupQuestion(failedToLoginString, QBTN_Ok, QBTN_Ok);
00159	        msgbox.OnButtonClick=MsgBoxBtnClicked;
00160	      }
00161	      msgbox.InitBox(120, 130, 16, 16, 400, 230);
00162	      return false;
00163	    }*/
00164	  }
00165	  else
00166	  {
00167	    xboxlive.SetCurrentUser(username);
00168	    Controller.OpenMenu("XIDInterf.XIIIMenuLivePassword");
00169	  }
00170	  return true;
00171	}
00172	
00173	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
00174	{
00175	  local int msg;
00176	    if (state==1/* || state==2*/)// IST_Press // to avoid auto-repeat
00177	    {
00178	      if ((Key==0x0D/*IK_Enter*/) || (Key==0x01))
00179		    {
00180		      if (listbox.list.SelectedText() == newAccountString)
00181		      {
00182	          Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00183	          msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00184	          msgbox.SetupQuestion(areYouSureString, QBTN_Yes|QBTN_No, QBTN_No, newAccountString2);
00185	          msgbox.OnButtonClick=MsgBoxBtnClicked;
00186	          msgbox.InitBox(120, 130, 16, 16, 400, 230);
00187	          //xboxlive.ShutdownAndCleanup();
00188	    	    //myRoot.CloseMenu(true);
00189	          //Controller.OpenMenu("XIDInterf.XIIIMenuLiveAccountWindow",true);
00190		      }
00191	        else
00192	        {
00193	          LoginUser(listbox.list.SelectedText());
00194	        }
00195	        return true;
00196	      }
00197		    if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B))
00198		    {
00199		        xboxlive.ShutdownAndCleanup();
00200		        myRoot.CloseMenu(true);
00201	    	    return true;
00202		    }
00203	    }
00204	    return super.InternalOnKeyEvent(Key, state, delta);
00205	}
00206	
00207	// if subclassed, this parent function must always be called first
00208	function string GetPageParameters()
00209	{
00210	    return Super.GetPageParameters()$"?AutoLoginUser="$AutoLoginUser;
00211	}
00212	
00213	// if GetPageParameters() is subclassed, you'd better have this one too !
00214	function SetPageParameters(string PageParameters)
00215	{
00216	    log("SetPageParameters("$PageParameters$") called for "$self);
00217	
00218	    AutoLoginUser = (localParseOption(PageParameters, "AutoLoginUser", ""));
00219	}
00220	
00221	

End Source Code