## XIDInterf
Class XIIIMenuLiveFriendsMainPage

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

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

Direct Known Subclasses:None

class XIIIMenuLiveFriendsMainPage
extends XIDInterf.XIIILiveWindow

Variables
`TitleText2,` | `TitleText3`
`bool` | `firsttime`
`string` | `friendsListNames[100]`
`string` | `friendsListTitles[100]`
`XboxLiveManager.FRIEND_PACKET` | `friendsList[100]`
`XIIIGUIMultiListBox` | `listbox`
`int` | `nrFriends`
`int` | `numberOfFriendsInList`
`Texture` | `onlineIcons[7]`
`XIIIGUIButton` | `statusButton`
`string` | `strOnlineStatus[7]`
`strLRHelp,` | `strPlaying`
`Texture` | `voiceIcons[3]`

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

Source Code

    00001	class XIIIMenuLiveFriendsMainPage extends XIIILiveWindow;
    00002
    00003	#exec OBJ LOAD FILE=XIIIXboxPacket.utx
    00004	//#exec OBJ LOAD FILE=GUIContent.utx
    00005	//var string MapList[64];
    00006	//var int MaxMaps, onMap;
    00007
    00008	var XIIIGUIMultiListBox listbox;
    00009	//var GUISlider  slider;
    00010	var localized string TitleText1, TitleText2, TitleText3;
    00011	var localized string YouHaveNoFriends, strLRHelp, strPlaying;
    00012	//var localized string strOnline;
    00013	//var localized string strOffline;
    00014
    00015	var localized string strOnlineStatus[7];
    00016	var int nrFriends;
    00017
    00018
    00019	enum eFriendStatus
    00020	{
    00021	  FRIENDSTATUS_receivedinvitation,
    00022	  FRIENDSTATUS_receivedfriendrequest,
    00023	  FRIENDSTATUS_sentinvitation,
    00024	  FRIENDSTATUS_sentfriendrequest,
    00025	  FRIENDSTATUS_onlinefriendsignedin,
    00026	  FRIENDSTATUS_offline,
    00027	  FRIENDSTATUS_none
    00028	};
    00029
    00030	enum eVoiceStatus
    00031	{
    00032	  VOICESTATUS_voiceon,
    00033	  VOICESTATUS_voicemuted,
    00034	  VOICESTATUS_voicetv,
    00035	  VOICESTATUS_voicenone,
    00036	};
    00037
    00038	/*
    00039	enum FriendStatusFlags      in scripts use:  xboxlive.XONLINE_FRIENDSTATE_FLAG_INVITEACCEPTED   etc.
    00040	{
    00041		FLAG_INVITEACCEPTED = XONLINE_FRIENDSTATE_FLAG_INVITEACCEPTED,
    00042		FLAG_INVITEREJECTED = XONLINE_FRIENDSTATE_FLAG_INVITEREJECTED,
    00043		FLAG_JOINABLE				= XONLINE_FRIENDSTATE_FLAG_JOINABLE,
    00044		FLAG_ONLINE					= XONLINE_FRIENDSTATE_FLAG_ONLINE,
    00045		FLAG_RECEIVEDREQUEST= XONLINE_FRIENDSTATE_FLAG_RECEIVEDREQUEST,
    00046		FLAG_SENTREQUEST		= XONLINE_FRIENDSTATE_FLAG_SENTREQUEST,
    00047		FLAG_PLAYING				= XONLINE_FRIENDSTATE_FLAG_PLAYING,
    00048		FLAG_RECEIVEDINVITE = XONLINE_FRIENDSTATE_FLAG_RECEIVEDINVITE,
    00049		FLAG_SENTINVITE			= XONLINE_FRIENDSTATE_FLAG_SENTINVITE,
    00050		FLAG_VOICE					= XONLINE_FRIENDSTATE_FLAG_VOICE
    00051	};
    00052	*/
    00053
    00054
    00055	//var GUIMultiListBoxLine friendsList[100];
    00056	var XboxLiveManager.FRIEND_PACKET friendsList[100];
    00057	var string friendsListNames[100];
    00058	var string friendsListTitles[100];
    00059
    00060	var int           numberOfFriendsInList;
    00061
    00062	var bool firsttime;
    00063
    00064	var texture onlineIcons[7];
    00065	var texture voiceIcons[3];
    00066
    00067	var XIIIGUIButton statusButton;
    00068
    00069
    00070
    00071	function Created()
    00072	{
    00073	  local int i;
    00074	     Super.Created();
    00075
    00076
    00077	/*     leftArrow = XIIIArrowbutton(CreateControl(class'XIIIArrowbutton', 0, 0, 12, 12));
    00078	     leftArrow.WinLeft = 200;
    00079	     leftArrow.WinTop = ControlOffset + 4;
    00080	     leftArrow.bLeftOrient = true;
    00081	     rightArrow = XIIIArrowbutton(CreateControl(class'XIIIArrowbutton', 0, 0, 12, 12));
    00082	     rightArrow.WinLeft = 208;
    00083	     rightArrow.WinTop = ControlOffset + 4;  */
    00084
    00085	/*AJ
    00086	     listbox = GUIListBox(CreateControl(class'GUIListBox', 100, 100, 440, 300));
    00087	     listbox.StyleName = "Listbox";
    00088	     listbox.List = new class'GUIMultiList';
    00089	     listbox.List.Add("Hello");
    00090	     listbox.List.Add("World");
    00091	     listbox.List.ItemsPerPage = 5;
    00092	     Controls[0]=listbox;
    00093	*/
    00094
    00095
    00096	     //slider = GUISlider(CreateControl(class'GUISlider', 0, 120, 100, 20));
    00097	     //Controls[2]=slider;
    00098
    00099	}
    00100
    00101
    00102	function InitComponent(GUIController MyController,GUIComponent MyOwner)
    00103	{
    00104	  //local int numberOfAccounts, q;
    00105	  //local string temp;
    00106	  local GUIMultiListBoxLine pack;
    00107	  local int q;
    00108
    00109
    00110	  Super.InitComponent(MyController, MyOwner);
    00111
    00112	  //xboxlive.EnumerateFriends(TRUE);
    00113
    00114	  listbox = XIIIGUIMultiListBox(Controls[0]);
    00115	  listbox.bVisibleWhenEmpty = true;
    00116	  listbox.ScrollBar.bVisible = false;
    00117	  //listbox.List = new class'GUIMultiList';
    00118
    00119	  onlineIcons[eFriendStatus.FRIENDSTATUS_receivedinvitation]=texture'XIIIXboxPacket.GameInviteReceived';
    00120	  onlineIcons[eFriendStatus.FRIENDSTATUS_receivedfriendrequest]=texture'XIIIXboxPacket.FriendInviteReceived';
    00121	  onlineIcons[eFriendStatus.FRIENDSTATUS_sentinvitation]=texture'XIIIXboxPacket.GameInviteSent';
    00122	  onlineIcons[eFriendStatus.FRIENDSTATUS_sentfriendrequest]=texture'XIIIXboxPacket.FriendInviteSent';
    00123	  onlineIcons[eFriendStatus.FRIENDSTATUS_onlinefriendsignedin]=texture'XIIIXboxPacket.FriendOnline';
    00124	  onlineIcons[eFriendStatus.FRIENDSTATUS_offline]=none;
    00125
    00126	  voiceIcons[eVoiceStatus.VOICESTATUS_voiceon]=texture'XIIIXboxPacket.CommunicatorON';
    00127	  voiceIcons[eVoiceStatus.VOICESTATUS_voicemuted]=texture'XIIIXboxPacket.CommunicatorMUTED';
    00128	  voiceIcons[eVoiceStatus.VOICESTATUS_voicetv]=none;//AJ
    00129
    00130
    00131	  listbox.SetNumberOfColumns(3);
    00132	  listbox.SetColumnOffset(0, 0);
    00133	  listbox.SetColumnOffset(1, 252);
    00134	  listbox.SetColumnOffset(2, 286);
    00135	  listbox.List.UserDefinedItemHeight = 36;
    00136
    00137	  statusButton         = XIIIGUIButton(Controls[1]);
    00138	  statusButton.Caption = "";
    00139
    00140
    00141
    00142	/*
    00143		Buttons[0] = XIIIGUIButton(Controls[0]);
    00144		Buttons[0].Caption = ButtonNames[0];
    00145		Buttons[1] = XIIIGUIButton(Controls[1]);
    00146		Buttons[1].Caption = ButtonNames[1];
    00147		Buttons[2] = XIIIGUIButton(Controls[2]);
    00148		Buttons[2].Caption = ButtonNames[2];
    00149		Buttons[3] = XIIIGUIButton(Controls[3]);
    00150		Buttons[3].Caption = ButtonNames[3];
    00151		Buttons[4] = XIIIGUIButton(Controls[4]);
    00152		Buttons[4].Caption = ButtonNames[4];
    00153		Buttons[5] = XIIIGUIButton(Controls[5]);
    00154		Buttons[5].Caption = ButtonNames[5];
    00155	*/
    00156		OnClick = InternalOnClick;
    00157
    00158
    00159	     /*
    00160	     listbox.list.clear();
    00161	     numberOfAccounts = xboxlive.GetNumberOfAccounts();
    00162	     for (q=0; q<numberOfAccounts; q++)
    00163	     {
    00164	       temp = xboxlive.GetAccountName(q);
    00165	       listbox.list.Add(temp);
    00166	     }
    00167
    00168	     listbox.list.Add(newAccountString);
    00169	     listbox.bVisibleWhenEmpty = true;
    00170	     */
    00171	}
    00172
    00173
    00174	function ShowWindow()
    00175	{
    00176	  OnMenu = 0; myRoot.bFired = false;
    00177	//  bShowBCK = true;
    00178	//  bShowRUN = false;
    00179	  //bShowSEL = true;
    00180
    00181	   bShowSEL = true;
    00182	   bShowBCK = true;
    00183	   Super.ShowWindow();
    00184
    00185	  xboxlive.UpdateFriends();
    00186
    00187	}
    00188
    00189
    00190	function Paint(Canvas C, float X, float Y)
    00191	{
    00192
    00193	  local GUIMultiListBoxLine pack;
    00194	  local string str;
    00195
    00196	  // populate the local friends list
    00197	  local bool friendsUpdated;
    00198	  local int q, temptop, tempindex;
    00199
    00200	  friendsUpdated = xboxlive.IsFriendsListChanged();
    00201
    00202	  nrFriends = xboxlive.GetNumberOfFriends();
    00203	  if (friendsUpdated || firsttime )
    00204	  {
    00205	    firsttime = false;
    00206
    00207	    temptop   = listbox.List.top;
    00208	    tempindex = listbox.List.Index;
    00209
    00210	    listbox.List.Clear();
    00211
    00212	    for (q=0; q<nrFriends; q++)
    00213	    {
    00214	      friendsList[q]     = xboxlive.GetFriendAtIndex(q);
    00215	      friendsListNames[q] = xboxlive.GetFriendNameAtIndex(q);
    00216	      friendsListTitles[q] = xboxlive.GetFriendTitleAtIndex(q);
    00217	      //friendsList[q].items[0].tex = onlineIcons[friendPost.onlineStatus];
    00218	      //friendsList[q].items[1].tex = onlineIcons[1]; //friendPost.voiceStatus
    00219	      //friendsList[q].items[0].str = "";
    00220	      //friendsList[q].items[1].str = ""; //friendPost.voiceStatus
    00221
    00222
    00223	      pack = new class'GUIMultiListBoxLine';
    00224	      pack.items[0].tex = onlineIcons[friendsList[q].onlineStatus];
    00225	      if (friendsList[q].isOnline)
    00226	        pack.items[1].tex = voiceIcons[friendsList[q].voiceStatus]; //
    00227	      else
    00228	        pack.items[1].tex = none;
    00229	      //listbox.List.Add(friendPost.name, friendsList[q]);
    00230	      listbox.List.Add(friendsListNames[q], pack);
    00231
    00232	    }
    00233	    if (nrFriends == 0 && !xboxlive.IsUpdatingFriends())
    00234	    {
    00235	      pack = new class'GUIMultiListBoxLine';
    00236	      pack.items[0].tex = none;
    00237	      pack.items[1].tex = none;
    00238	      listbox.List.Add(YouHaveNoFriends, pack);
    00239	    }
    00240
    00241	    if (listbox.List.ItemCount>tempindex)
    00242	    {
    00243	      listbox.List.top   = temptop;
    00244	      listbox.List.Index = tempindex;
    00245
} 00246 } 00247 00248 if (nrFriends > 0) 00249 { 00250 str = ""; 00251 if (friendsList[listbox.list.Index].isOnline) 00252 { 00253 if ((friendsList[listbox.list.Index].onlineStatusFlags & xboxlive.XONLINE_FRIENDSTATE_FLAG_PLAYING) != 0 ) 00254 { 00255 if (friendsListTitles[listbox.list.Index] != "") 00256 str = strPlaying$" "$friendsListTitles[listbox.list.Index]; 00257 else 00258 str = strPlaying; 00259 } 00260 else 00261 { 00262 if (friendsListTitles[listbox.list.Index] != "") 00263 str = strOnlineStatus[eFriendStatus.FRIENDSTATUS_onlinefriendsignedin]$" ("$friendsListTitles[listbox.list.Index]$")"; 00264 else 00265 str = strOnlineStatus[eFriendStatus.FRIENDSTATUS_onlinefriendsignedin]; 00266 } 00267 } 00268 else 00269 str = strOnlineStatus[eFriendStatus.FRIENDSTATUS_offline]; 00270 00271 if (friendsList[listbox.list.Index].onlineStatus <= eFriendStatus.FRIENDSTATUS_sentfriendrequest) 00272 str = strOnlineStatus[friendsList[listbox.list.Index].onlineStatus]; 00273 00274 //C.SetPos(X+columnOffset[0]+10, Y+(H-16.0)*0.5-2); 00275 //C.DrawText(Elements[item].Item, false); 00276 statusButton.Caption = str; 00277 00278 } 00279 else 00280 statusButton.Caption = ""; 00281 00282 /* AJ no room right now 00283 if (xboxlive.IsPlaying()) 00284 { 00285 C.DrawColor = BlackColor; 00286 C.SetPos(260, 400); 00287 C.DrawText(strLRHelp, false); 00288 C.DrawColor = WhiteColor; 00289 C.bUseBorder = false; 00290 } 00291 */ 00292 Super.Paint(C, X, Y); 00293 if (xboxlive.IsPlaying()) 00294 PaintStandardBackground3(C, X, Y, TitleText1, TitleText2, TitleText3, 2); 00295 else 00296 PaintStandardBackground3(C, X, Y, "", TitleText2, TitleText3, 2); 00297 } 00298 00299 function JoinGameTest() 00300 { 00301 local string URL, Checksum; 00302 local int N; 00303 00304 URL = "192.168.0.18"; 00305 //URL = "192.168.0.18:7777"; 00306 /* class'StatLog'.Static.GetPlayerChecksum(GetPlayerOwner(), Checksum); 00307 if (Checksum == "") 00308 URL = URL $ "?Checksum=NoChecksum"; 00309 else 00310 URL = URL $ "?Checksum="$Checksum; 00311 */ 00312 myRoot.bXboxStartup = true; 00313 myRoot.GotoState(''); 00314 myRoot.CloseAll(true); 00315 GetPlayerOwner().AttribPadToViewport(); 00316 //log("TRAVELING w/URL: "$URL); 00317 //GetPlayerOwner().ClientTravel(URL, TRAVEL_Absolute, false); 00318 GetPlayerOwner().ConsoleCommand("start 192.168.0.18"); 00319 } 00320 00321 // Called when a button is clicked 00322 function bool InternalOnClick(GUIComponent Sender) 00323 { 00324 00325 if (nrFriends > 0) 00326 { 00327 if ((friendsList[listbox.list.Index].onlineStatusFlags & xboxlive.XONLINE_FRIENDSTATE_FLAG_RECEIVEDINVITE) != 0) 00328 { 00329 xboxlive.SetActiveFriend(friendsListNames[listbox.list.Index]); 00330 myRoot.OpenMenu("XIDInterf.XIIIMenuLiveGameInviteReceived"); 00331 } 00332 00333 else if ((friendsList[listbox.list.Index].onlineStatusFlags & xboxlive.XONLINE_FRIENDSTATE_FLAG_RECEIVEDREQUEST) != 0) 00334 { 00335 xboxlive.SetActiveFriend(friendsListNames[listbox.list.Index]); 00336 myRoot.OpenMenu("XIDInterf.XIIIMenuLiveFriendsshipRequested"); 00337 } 00338 00339 else if ((friendsList[listbox.list.Index].onlineStatusFlags & xboxlive.XONLINE_FRIENDSTATE_FLAG_SENTINVITE) != 0) 00340 { 00341 xboxlive.SetActiveFriend(friendsListNames[listbox.list.Index]); 00342 myRoot.OpenMenu("XIDInterf.XIIIMenuLiveFriendsInvited"); 00343 } 00344 00345 else if ((friendsList[listbox.list.Index].onlineStatusFlags & xboxlive.XONLINE_FRIENDSTATE_FLAG_SENTREQUEST) != 0) 00346 { 00347 xboxlive.SetActiveFriend(friendsListNames[listbox.list.Index]); 00348 myRoot.OpenMenu("XIDInterf.XIIIMenuLiveFriendsCancelFriendRequest"); 00349 } 00350 00351 00352 00353 00354 00355 else if (friendsList[listbox.list.Index].isOnline) 00356 { 00357 xboxlive.SetActiveFriend(friendsListNames[listbox.list.Index]); 00358 myRoot.OpenMenu("XIDInterf.XIIIMenuLiveFriendsOnline"); 00359 } 00360 else 00361 { 00362 xboxlive.SetActiveFriend(friendsListNames[listbox.list.Index]); 00363 myRoot.OpenMenu("XIDInterf.XIIIMenuLiveFriendsOffline"); 00364 } 00365 return true; 00366 } 00367 00368 return false; 00369 } 00370 00371 00372 function bool InternalOnKeyEvent(out byte Key, out byte State, float delta) 00373 { 00374 if (state==1/* || state==2*/)// IST_Press // to avoid auto-repeat 00375 { 00376 if ((Key==0x0D/*IK_Enter*/) || (Key==0x01)) 00377 { 00378 //Controller.FocusedControl.OnClick(Self); 00379 InternalOnClick(Controller.FocusedControl); 00380 return true; 00381 } 00382 if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B)) 00383 { 00384 //AJxboxlive.EnumerateFriends(FALSE); 00385 myRoot.CloseMenu(true); 00386 return true; 00387 } 00388 if (Key==0x25/*IK_Left*/) 00389 { 00390 myRoot.CloseMenu(true); 00391 00392 if (xboxlive.IsPlaying()) 00393 myRoot.OpenMenu("XIDInterf.XIIIMenuLivePlayerList"); 00394 else 00395 myRoot.OpenMenu("XIDInterf.XIIIMenuLiveOldPlayerList"); 00396 return true; 00397 } 00398 if (Key==0x27/*IK_Right*/) 00399 { 00400 myRoot.CloseMenu(true); 00401 // if (xboxlive.IsPlaying()) 00402 myRoot.OpenMenu("XIDInterf.XIIIMenuLiveOldPlayerList"); 00403 return true; 00404 } 00405 } 00406 return super.InternalOnKeyEvent(Key, state, delta); 00407 } 00408 00409 00410 00411 00412

End Source Code