XIDInterf
Class XIIIMenuLiveStartup

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

class XIIIMenuLiveStartup
extends XIDInterf.XIIILiveWindow


Variables
 string TitleText
 bool WaitForCreate
 bool WaitForStart
 string creatingSessionString
 XIIILiveMsgBox msgbox
 string pleaseWaitString
 float starttime
 XboxLiveManager xboxlive


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 Paint(Canvas C, float X, float Y)
 void ProcessCreate()
 void ProcessWait()
 void ShowWindow()



Source Code


00001	class XIIIMenuLiveStartup extends XIIILiveWindow;
00002	
00003	var localized string TitleText;
00004	var XboxLiveManager xboxlive;
00005	var XIIILiveMsgBox msgbox;
00006	var localized string creatingSessionString;
00007	var localized string pleaseWaitString;
00008	var float starttime;
00009	var bool WaitForStart;
00010	var bool WaitForCreate;
00011	
00012	
00013	function Created()
00014	{
00015	  local int i;
00016	  Super.Created();
00017	
00018	  if (xboxlive == none)
00019	    xboxlive=New Class'XboxLiveManager';
00020	}
00021	
00022	function MsgBoxBtnClicked(byte bButton)
00023	{
00024	  switch (bButton)
00025	  {
00026	    case QBTN_Ok:
00027	      xboxlive.SessionReset();
00028		    myRoot.CloseMenu(true);
00029	    break;
00030	  }
00031	}
00032	
00033	function InitComponent(GUIController MyController,GUIComponent MyOwner)
00034	{
00035	  local int msg, userState;
00036	
00037	  Super.InitComponent(MyController, MyOwner);
00038		OnClick = InternalOnClick;
00039	
00040	  // Why do I have to set these? They are 0 at the moment. Only valid inside the render or what?
00041	  fRatioX = 1.0;
00042	  fRatioY = 1.0;
00043	  fScaleTo = 1.0;
00044	
00045	  Log("[XIIIMenuProfileClient] Created...");
00046	  if (xboxlive.IsLoggedIn(xboxlive.GetCurrentUser()) && (GetPlayerOwner().Level.NetMode==NM_DedicatedServer || GetPlayerOwner().Level.NetMode==NM_ListenServer))
00047	  {
00048	    Log("[XIIIMenuProfileClient] Xbox live running (server)");
00049	    if (!xboxlive.SessionCreate())
00050	    {
00051	      Log("[XIIIMenuProfileClient] Failed to create session!");
00052	      msg = xboxlive.GetLastError();
00053	      myRoot.OpenMenu("XIDInterf.XIIILiveMsgBox");
00054	      msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00055	      msgbox.SetupQuestion(xboxlive.GetErrorString(msg), QBTN_Ok, QBTN_Ok);
00056	      msgbox.OnButtonClick=MsgBoxBtnClicked;
00057	    }
00058	    else
00059	    {
00060	      Log("[XIIIMenuProfileClient] Created session!");
00061	      WaitForCreate = true;
00062	      starttime = GetPlayerOwner().Level.TimeSeconds;
00063	      myRoot.OpenMenu("XIDInterf.XIIILiveMsgBox");
00064	      msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00065	      msgbox.SetupQuestion(pleaseWaitString, 0, 0, creatingSessionString);
00066	      //msgbox.OnButtonClick=MsgBoxBtnClicked;
00067	      msgbox.InitBox(160*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 320*fRatioX, 230*fRatioY*fScaleTo);
00068	    }
00069	  }
00070	  else if (xboxlive.IsLoggedIn(xboxlive.GetCurrentUser()) && GetPlayerOwner().Level.NetMode==NM_Client)
00071	  {
00072	    Log("[XIIIMenuProfileClient] Xbox live running (client)");
00073	    userState = xboxlive.US_ONLINE;
00074	    if (xboxlive.HasUserVoice(xboxlive.GetCurrentUser()))
00075	      userState = userState | xboxlive.US_VOICE;
00076	    //if (!xboxlive.IsLadderGame())
00077	    //  userState = userState | xboxlive.US_JOINABLE;
00078	    userState = userState | xboxlive.US_PLAYING;
00079	    xboxlive.SetUserState(xboxlive.GetCurrentUser(), userState);
00080	    myRoot.CloseAll(true);
00081	    myRoot.GotoState('');
00082	  }
00083	}
00084	
00085	
00086	function ShowWindow()
00087	{
00088	     OnMenu = 0; myRoot.bFired = false;
00089	     Super.ShowWindow();
00090	     bShowBCK = false;
00091	     bShowRUN = false;
00092	     bShowSEL = false;
00093	     myRoot.GetLevel().Game.ChangeName(GetPlayerOwner(), xboxlive.GetCurrentUser(), false);
00094	}
00095	
00096	function ProcessWait()
00097	{
00098	  local int msg, userState;
00099	  if (xboxlive.SessionIsSubnetStarted())// && (GetPlayerOwner().Level.TimeSeconds - starttime)>2.0)
00100	  {
00101	  	Log("[XIIIMenuProfileClient] Subnet started...");
00102	    WaitForStart = false;
00103	    myRoot.CloseAll(true);
00104	    myRoot.GotoState('');
00105	    userState = xboxlive.US_ONLINE;
00106	    if (xboxlive.HasUserVoice(xboxlive.GetCurrentUser()))
00107	      userState = userState | xboxlive.US_VOICE;
00108	    //if (!xboxlive.IsLadderGame())
00109	    //  userState = userState | xboxlive.US_JOINABLE;
00110	    userState = userState | xboxlive.US_PLAYING;
00111	    xboxlive.SetUserState(xboxlive.GetCurrentUser(), userState);
00112	  }
00113	  else
00114	  {
00115	  }
00116	}
00117	
00118	function ProcessCreate()
00119	{
00120	  local int msg, userState;
00121	  if (xboxlive.SessionIsCreateFinished())
00122	  {
00123	  	Log("[XIIIMenuProfileClient] Create finished...");
00124	    WaitForCreate = false;
00125	    //WaitForStart = true;
00126	    //myRoot.CloseMenu(true);
00127	
00128	    if (xboxlive.SessionStartSubnet())
00129	    {
00130	      Log("[XIIIMenuProfileClient] Starting subnet... "$fRatioX$" "$fRatioY$" "$fScaleTo);
00131	      WaitForStart = true;
00132	    }
00133	    else
00134	    {
00135	      myRoot.CloseMenu(true);
00136	      Log("[XIIIMenuProfileClient] Failed to start subnet...");
00137	      msg = xboxlive.GetLastError();
00138	      myRoot.OpenMenu("XIDInterf.XIIILiveMsgBox");
00139	      msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00140	      msgbox.SetupQuestion(xboxlive.GetErrorString(msg), QBTN_Ok, QBTN_Ok);
00141	      msgbox.OnButtonClick=MsgBoxBtnClicked;
00142	      msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo);
00143	    }
00144	  }
00145	  else
00146	  {
00147	  }
00148	}
00149	
00150	function Paint(Canvas C, float X, float Y)
00151	{
00152	  if (WaitForCreate)
00153	    ProcessCreate();
00154	
00155	  if (WaitForStart)
00156	    ProcessWait();
00157	
00158	  Super.Paint(C, X, Y);
00159	
00160	  if (BackGround != none)
00161	    PaintStandardBackground(C, X, Y, TitleText);
00162	}
00163	
00164	// Called when a button is clicked
00165	function bool InternalOnClick(GUIComponent Sender)
00166	{
00167	  return true;
00168	}
00169	
00170	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
00171	{
00172	  if (waitForStart)
00173	    return true;
00174	
00175	    if (state==1/* || state==2*/)// IST_Press // to avoid auto-repeat
00176	    {
00177	        if ((Key==0x0D/*IK_Enter*/) || (Key==0x01))
00178		    {
00179	          //Controller.FocusedControl.OnClick(Self);
00180	          InternalOnClick(Controller.FocusedControl);
00181	          return true;
00182		    }
00183		    if (Key==0x25/*IK_Left*/)
00184		    {
00185	    	    return true;
00186		    }
00187		    if (Key==0x27/*IK_Right*/)
00188		    {
00189	    	    return true;
00190		    }
00191	    }
00192	    return super.InternalOnKeyEvent(Key, state, delta);
00193	}
00194	
00195	
00196	

End Source Code