XIDInterf
Class XIIIMenuLiveScoreboardMain

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

class XIIIMenuLiveScoreboardMain
extends XIDInterf.XIIILiveWindow


Variables
 string ButtonNames[4]
 XIIIGUIButton Buttons[4]
 string TitleText
 bProcessFriendsStats, bProcessOverallStats
 failedStatsUserNonexistant, failedFSYouhavenofriends
 string strTitle[5]


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 Paint(Canvas C, float X, float Y)
 void ProcessFriendsStats()
 void ProcessOverallStats()
 void ProcessReset()
 void ProcessUserStats()
 void ResetFriendsStatsMsgBoxClicked(byte bButton)
 void ResetOverallStatsMsgBoxClicked(byte bButton)
 void ResetUserStatsMsgBoxClicked(byte bButton)
 void ResetWaitMsgBoxClicked(byte bButton)
 void ShowWindow()
 void SureMsgBoxClicked(byte bButton)



Source Code


00001	class XIIIMenuLiveScoreboardMain extends XIIILiveWindow;
00002	
00003	var string TitleText;
00004	
00005	var XIIIGUIButton Buttons[4];
00006	var localized string ButtonNames[4];
00007	var localized string failedToResetString, sureResetStatsString, failedToGetStatsString, failedStatsUserNonexistant, failedFSYouhavenofriends;
00008	var bool bProcessReset, bProcessUserStats, bProcessFriendsStats, bProcessOverallStats;
00009	
00010	var localized string strTitle[5];
00011	
00012	function Created()
00013	{
00014	  local int i;
00015	  Super.Created();
00016	}
00017	
00018	
00019	function InitComponent(GUIController MyController,GUIComponent MyOwner)
00020	{
00021	  local int i;
00022	  Super.InitComponent(MyController, MyOwner);
00023		OnClick = InternalOnClick;
00024		
00025		for (i=0; i<4; i++)
00026		{
00027	  	Buttons[i] = XIIIGUIButton(Controls[i]);
00028	  	Buttons[i].Caption = ButtonNames[i];
00029	  }
00030	}
00031	
00032	
00033	function ShowWindow()
00034	{
00035	  OnMenu = 0; myRoot.bFired = false;
00036	  Super.ShowWindow();
00037	  bShowBCK = true;
00038	  bShowRUN = false;
00039	  bShowSEL = true;
00040	
00041	  if (xboxlive.GetStatisticsType() == GT_DM)
00042	  {
00043	    TitleText = strTitle[0];
00044	  }
00045	  else if (xboxlive.GetStatisticsType() == GT_TeamDM)
00046	  {
00047	    TitleText = strTitle[1];
00048	  }
00049	  else if (xboxlive.GetStatisticsType() == GT_CTF)
00050	  {
00051	    TitleText = strTitle[2];
00052	  }
00053	  else if (xboxlive.GetStatisticsType() == GT_Sabotage)
00054	  {
00055	    TitleText = strTitle[3];
00056	  }
00057	  else if (xboxlive.GetStatisticsType() == GT_Ladder)
00058	  {
00059	    TitleText = strTitle[4];
00060	  }
00061	  else  // Must never happen!
00062	    TitleText = "";
00063	
00064	}
00065	
00066	function ProcessReset()
00067	{
00068	  local int err;
00069	  if (!xboxlive.StatsPumpReset())
00070	  { // Finished or error
00071	    err = xboxlive.GetLastError();
00072	    myRoot.CloseMenu(true);
00073	    bProcessReset = false;
00074	    if (err != 0)
00075	    {
00076	      ShowErrorBox(failedToResetString);
00077	    }
00078	  }
00079	}
00080	
00081	function ProcessUserStats()
00082	{
00083	  local int err;
00084	  if (!xboxlive.StatsPumpRequestUser())
00085	  { // Finished or error
00086	    err = xboxlive.GetLastError();
00087	    myRoot.CloseMenu(true);
00088	    bProcessUserStats = false;
00089	    if (err != 0)
00090	    {
00091	      if(err == 112) //user doesn't exist
00092	        ShowErrorBox(failedStatsUserNonexistant);
00093	      else
00094	        ShowErrorBox(failedToGetStatsString);
00095	    }
00096	    else
00097	      Controller.OpenMenu("XIDInterf.XIIIMenuLiveScoreboardView",false, "user");
00098	  }
00099	}
00100	
00101	function ProcessFriendsStats()
00102	{
00103	  local int err;
00104	  if (!xboxlive.StatsPumpRequestFriends())
00105	  { // Finished or error
00106	    err = xboxlive.GetLastError();
00107	    myRoot.CloseMenu(true);
00108	    bProcessFriendsStats = false;
00109	    if (err != 0)
00110	    {
00111	      if(err == 131)
00112	        ShowErrorBox(failedToGetStatsString);
00113	      else
00114	        ShowErrorBox(failedToGetStatsString);
00115	    }
00116	    else
00117	      Controller.OpenMenu("XIDInterf.XIIIMenuLiveScoreboardViewFriends",false);
00118	  }
00119	}
00120	
00121	function ProcessOverallStats()
00122	{
00123	  local int err;
00124	  if (!xboxlive.StatsPumpRequestOverall())
00125	  { // Finished or error
00126	    err = xboxlive.GetLastError();
00127	    myRoot.CloseMenu(true);
00128	    bProcessOverallStats = false;
00129	    if (err != 0)
00130	    {
00131	      ShowErrorBox(failedToGetStatsString);
00132	    }
00133	    else
00134	      Controller.OpenMenu("XIDInterf.XIIIMenuLiveScoreboardView",false);
00135	  }
00136	}
00137	
00138	function Paint(Canvas C, float X, float Y)
00139	{
00140	  Super.Paint(C, X, Y);
00141	  PaintStandardBackground(C, X, Y, TitleText);
00142	  
00143	  if(xboxlive.GetNumberOfFriends() == 0)
00144	  {
00145	    Buttons[2].bNeverFocus = true;
00146	    Buttons[2].MenuState = MSAT_Disabled;
00147	  }
00148	  else
00149	  {
00150	    Buttons[2].bNeverFocus = false;
00151	    if(Buttons[2].MenuState != MSAT_Watched && Buttons[2].MenuState != MSAT_Focused)
00152	      Buttons[2].MenuState = MSAT_Blurry;
00153	  }
00154	
00155	  if (bProcessReset)
00156	  {
00157	    ProcessReset();
00158	  }
00159	
00160	  if (bProcessUserStats)
00161	  {
00162	    ProcessUserStats();
00163	  }
00164	
00165	  if (bProcessFriendsStats)
00166	  {
00167	    ProcessFriendsStats();
00168	  }
00169	
00170	  if (bProcessOverallStats)
00171	  {
00172	    ProcessOverallStats();
00173	  }
00174	}
00175	
00176	
00177	// Called when a button is clicked
00178	function bool InternalOnClick(GUIComponent Sender)
00179	{
00180	    local int i;
00181	    if (Sender == Buttons[0]) // USER
00182	    {
00183	      if (!xboxlive.StatsRequestUser(0,20))
00184	      {
00185	        ShowErrorBox(failedToGetStatsString);
00186	      }
00187	      else
00188	      {
00189	        Controller.OpenMenu("XIDInterf.XIIILiveMsgBox",false);
00190	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00191	        msgbox.SetupQuestion(pleaseWaitString, QBTN_Cancel, QBTN_Cancel);
00192	        msgbox.OnButtonClick=ResetUserStatsMsgBoxClicked;
00193	        msgbox.InitBox(160, 130, 16, 16, 320, 230);
00194	        bProcessUserStats = true;
00195	      }
00196	    }
00197	    else if (Sender == Buttons[1]) // OVERALL
00198	    {
00199	      if (!xboxlive.StatsRequestOverall(0,20))
00200	      {
00201	        ShowErrorBox(failedToGetStatsString);
00202	      }
00203	      else
00204	      {
00205	        Controller.OpenMenu("XIDInterf.XIIILiveMsgBox",false);
00206	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00207	        msgbox.SetupQuestion(pleaseWaitString, QBTN_Cancel, QBTN_Cancel);
00208	        msgbox.OnButtonClick=ResetOverallStatsMsgBoxClicked;
00209	        msgbox.InitBox(160, 130, 16, 16, 320, 230);
00210	        bProcessOverallStats = true;
00211	      }
00212	    }
00213	    else if (Sender == Buttons[2]) // FRIENDS
00214	    {
00215	      if (!xboxlive.StatsRequestFriends(0,20))
00216	      {
00217	        ShowErrorBox(failedToGetStatsString);
00218	      }
00219	      else
00220	      {
00221	        Controller.OpenMenu("XIDInterf.XIIILiveMsgBox",false);
00222	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00223	        msgbox.SetupQuestion(pleaseWaitString, QBTN_Cancel, QBTN_Cancel);
00224	        msgbox.OnButtonClick=ResetFriendsStatsMsgBoxClicked;
00225	        msgbox.InitBox(160, 130, 16, 16, 320, 230);
00226	        bProcessFriendsStats = true;
00227	      }
00228	    }
00229	    else if (Sender == Buttons[3]) // RESET
00230	    { // Reset
00231	      Controller.OpenMenu("XIDInterf.XIIILiveMsgBox",false);
00232	      msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00233	      msgbox.SetupQuestion(sureResetStatsString, QBTN_Ok|QBTN_Cancel, QBTN_Cancel);
00234	      msgbox.OnButtonClick=SureMsgBoxClicked;
00235	      msgbox.InitBox(160, 130, 16, 16, 320, 230);
00236	    }
00237	    return true;
00238	}
00239	
00240	function SureMsgBoxClicked(byte bButton)
00241	{
00242	  switch (bButton)
00243	  {
00244	    case QBTN_Ok:
00245	      if (!xboxlive.StatsReset())
00246	      {
00247	        ShowErrorBox(failedToResetString);
00248	        return;
00249	      }
00250	      else
00251	      {
00252	        Controller.OpenMenu("XIDInterf.XIIILiveMsgBox",false);
00253	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00254	        msgbox.SetupQuestion(pleaseWaitString, QBTN_Cancel, QBTN_Cancel);
00255	        msgbox.OnButtonClick=ResetWaitMsgBoxClicked;
00256	        msgbox.InitBox(160, 130, 16, 16, 320, 230);
00257	        bProcessReset = true;
00258	        return;
00259	      }
00260	    break;
00261	  }
00262	}
00263	
00264	function ResetUserStatsMsgBoxClicked(byte bButton)
00265	{
00266	  xboxlive.StatsCancelRequestUser();
00267	  bProcessUserStats = false;
00268	}
00269	
00270	function ResetOverallStatsMsgBoxClicked(byte bButton)
00271	{
00272	  xboxlive.StatsCancelRequestOverall();
00273	  bProcessOverallStats = false;
00274	}
00275	
00276	function ResetFriendsStatsMsgBoxClicked(byte bButton)
00277	{
00278	  xboxlive.StatsCancelRequestFriends();
00279	  bProcessFriendsStats = false;
00280	}
00281	
00282	
00283	function ResetWaitMsgBoxClicked(byte bButton)
00284	{
00285	  xboxlive.StatsCancelReset();
00286	  bProcessReset = false;
00287	}
00288	
00289	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
00290	{
00291	    if (state==1/* || state==2*/)// IST_Press // to avoid auto-repeat
00292	    {
00293	        if ((Key==0x0D/*IK_Enter*/) || (Key==0x01))
00294		    {
00295	          //Controller.FocusedControl.OnClick(Self);
00296	          InternalOnClick(Controller.FocusedControl);
00297	          return true;
00298		    }
00299		    if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B))
00300		    {
00301		        myRoot.CloseMenu(true);
00302	    	    return true;
00303		    }
00304		    if (Key==0x25/*IK_Left*/)
00305		    {
00306	    	    return true;
00307		    }
00308		    if (Key==0x27/*IK_Right*/)
00309		    {
00310	    	    return true;
00311		    }
00312	    }
00313	    return super.InternalOnKeyEvent(Key, state, delta);
00314	}
00315	
00316	
00317	
00318	

End Source Code