internal void Activate() { if (!LiveManager.AcceptedShareInvitation) { LiveManager.FriendUpdatesEnabled = true; LiveManager.JoinableUpdatesEnabled = true; } else { LiveManager.FriendUpdatesEnabled = false; LiveManager.JoinableUpdatesEnabled = false; } // TODO: remap to a kodu-meaningful string if remote player is playing kodu (but could look odd in the dashboard and other games that show presence). InGame.SetPresence(GamerPresenceMode.CornflowerBlue); // We rebuild the grid each time the share hub is activated, to reflect the dynamic nature of the friend list. grid = new UIGrid(parent.OnSelect, parent.OnCancel, new Point(1, 0), "App.ShareHub.Grid"); elements = new List <UIGridShareHubElement>(); // Set grid properties. grid.Spacing = new Vector2(0.0f, -0.1f); // The first number doesn't really matter since we're doing a 1d column. grid.Scrolling = true; grid.Wrap = false; grid.SlopOffset = true; grid.UseMouseScrollWheel = true; // First element is the "Enter Sharing Room" button. //grid.Add(new UIGridStartSharingElement(), 0, 0); BokuGame.Load(grid, true); grid.Active = true; // Queue up session finders for the sharing servers. if (!LiveManager.AcceptedShareInvitation) { foreach (string gamerTag in SharingServers.Instance.gamerTags) { UIGridSharingServerElement elem = new UIGridSharingServerElement(gamerTag); elem.JoinableChanged += new StatusChangedDelegate(elem_JoinableChanged); elements.Add(elem); elem.StartCheckingPresence(); } } }
public void OnSelect(UIGrid grid) { // User selected a friend. grid.Active = true; int index = shared.grid.SelectionIndex.Y; UIGridShareFriendElement friendElement = shared.grid.Get(0, index) as UIGridShareFriendElement; UIGridSharingServerElement serverElement = shared.grid.Get(0, index) as UIGridSharingServerElement; if (friendElement != null) { if (friendElement.Friend.IsOnline) { if (friendElement.Friend.InvitedUs || friendElement.Friend.IsJoinable) { // Friend has a joinable session, directly join it ("jump in"). StartJumpingIn(friendElement.Friend.GamerTag, friendElement); // Don't allow the user to interact with the share hub while the SessionFinder is running. grid.Active = false; } else if (friendElement.Friend.IsJoined && LiveManager.IsConnected) { // Selected friend has joined our session, just go to the sharing room. ActivateSharingScreen(); grid.Active = false; } else if (!friendElement.Friend.InvitedThem) { // Start sending an invitation to this friend. friendElement.Friend.InvitingThem = true; if (!LiveManager.IsConnected) { openingInviteGuideMessage.Activate(); LiveManager.ClearQueuedOperations(null); // We must have a session open before we can send an invite. // Start creating the network session. SessionCreator createOp = new SessionCreator(SessionCreatorComplete_StartInvitingFriend, friendElement, this); createOp.Queue(); } else { // Session is already open, no need to create it before sending the invite. StartInvitingFriend(friendElement); } } } } else if (serverElement != null) { if (serverElement.IsOnline) { StartJumpingIn(serverElement.GamerTag, serverElement); // Don't allow the user to interact with the share hub while the SessionFinder is running. grid.Active = false; } } }
private void GetSortedGridElements(List <UIGridShareHubElement> list) { list.Clear(); // Friends playing Kodu foreach (UIGridShareHubElement elem in elements) { UIGridShareFriendElement friend = elem as UIGridShareFriendElement; if (friend == null) { continue; } if (!friend.Friend.IsOnline) { continue; } if (!friend.Friend.IsPlayingKodu) { continue; } friend.Friend.Dirty = true; list.Add(elem); } // Super-friends foreach (UIGridShareHubElement elem in elements) { UIGridSharingServerElement server = elem as UIGridSharingServerElement; if (server == null) { continue; } if (!server.IsOnline) { continue; } server.Dirty = true; list.Add(elem); } // Friends online not playing Kodu foreach (UIGridShareHubElement elem in elements) { UIGridShareFriendElement friend = elem as UIGridShareFriendElement; if (friend == null) { continue; } if (!friend.Friend.IsOnline) { continue; } if (friend.Friend.IsPlayingKodu) { continue; } friend.Friend.Dirty = true; list.Add(elem); } // Friends offline foreach (UIGridShareHubElement elem in elements) { UIGridShareFriendElement friend = elem as UIGridShareFriendElement; if (friend == null) { continue; } if (friend.Friend.IsOnline) { continue; } friend.Friend.Dirty = true; list.Add(elem); } }