Пример #1
0
        private void RenderLobbyData()
        {
            try 
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    Client.InviteListView.Items.Clear();
                    TeamListView.Items.Clear();
                    IsOwner = false;
                    if(Client.LoginPacket.AllSummonerData.Summoner.Name == CurrentLobby.Owner);
                    {
                        IsOwner = true;
                    }

                    if (IsOwner == true)
                    {
                        InviteButton.IsEnabled = true;
                        StartGameButton.IsEnabled = true;
                    }
                    else if (IsOwner == false)
                    {
                        InviteButton.IsEnabled = false;
                        StartGameButton.IsEnabled = false;
                    }

                    foreach (Member stats in CurrentLobby.Members)
                    {
                    //Your kidding me right
                        TeamControl TeamPlayer = new TeamControl();
                        TeamPlayerStats = TeamPlayer;
                        TeamPlayer.Name.Content = stats.SummonerName;
                        TeamPlayer.SumID.Content = stats.SummonerName;
                        TeamPlayer.Kick.Tag = stats;
                        TeamPlayer.Inviter.Tag = stats;
                        TeamPlayer.Profile.Tag = stats;
                        TeamPlayer.Owner.Tag = stats;

                        TeamPlayer.Kick.Click += Kick_Click;
                        TeamPlayer.Inviter.Click += Inviter_Click;
                        TeamPlayer.Profile.Click += Profile_Click;
                        TeamPlayer.Owner.Click += Owner_Click;


                        //
                        if (stats.SummonerName == Client.LoginPacket.AllSummonerData.Summoner.Name)
                        {
                            TeamPlayer.Kick.Visibility = Visibility.Hidden;
                            TeamPlayer.Inviter.Visibility = Visibility.Hidden;
                            TeamPlayer.Profile.Visibility = Visibility.Hidden;
                            TeamPlayer.Owner.Visibility = Visibility.Hidden;
                            if (stats.hasDelegatedInvitePower == true && IsOwner == false)
                            {
                                InviteButton.IsEnabled = true;
                            }
                            else if (stats.hasDelegatedInvitePower == false && IsOwner == false)
                            {
                                InviteButton.IsEnabled = false;
                            }
                        }
                        if (IsOwner == false)
                        {
                            //So you don't crash trying to kick someone when you can't
                            TeamPlayer.Kick.Visibility = Visibility.Hidden;
                            TeamPlayer.Inviter.Visibility = Visibility.Hidden;
                            TeamPlayer.Owner.Visibility = Visibility.Hidden;
                        }
                        TeamListView.Items.Add(TeamPlayer);
                    }

                    foreach (Invitee statsx in CurrentLobby.Invitees)
                    {
                        InvitePlayer invitePlayer = new InvitePlayer();
                        invitePlayer.StatusLabel.Content = statsx.inviteeState;
                        invitePlayer.PlayerLabel.Content = statsx.SummonerName;
                        Client.InviteListView.Items.Add(invitePlayer);
                    }
                }));
            }
            catch { }
            
        }
Пример #2
0
        private void RenderLobbyData()
        {
            try
            {
                int Players = 0;
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
                {
                    CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                    TextInfo textInfo = cultureInfo.TextInfo;

                    Client.InviteListView.Items.Clear();
                    TeamListView.Items.Clear();
                    IsOwner = false;

                    if (CurrentLobby.Owner != null &&
                        CurrentLobby.Owner.SummonerName == Client.LoginPacket.AllSummonerData.Summoner.Name)
                    {
                        IsOwner = true;
                    }

                    foreach (Invitee statsx in CurrentLobby.Invitees)
                    {
                        string InviteeState = string.Format(statsx.inviteeState.ToLower());
                        string InviteeStateTitleCase = textInfo.ToTitleCase(InviteeState);
                        var invitePlayer = new InvitePlayer();
                        invitePlayer.StatusLabel.Content = InviteeStateTitleCase;
                        invitePlayer.PlayerLabel.Content = statsx.SummonerName;
                        switch (InviteeState)
                        {
                            case "owner":
                            case "accepted":
                            case "creator":
                                invitePlayer.StatusLabel.Foreground = Brushes.Green;
                                break;
                            case "pending":
                                invitePlayer.StatusLabel.Foreground = Brushes.Yellow;
                                break;
                            case "declined":
                            case "quit":
                                invitePlayer.StatusLabel.Foreground = Brushes.Red;
                                break;
                        }
                        Client.InviteListView.Items.Add(invitePlayer);
                    }

                    if (IsOwner)
                    {
                        InviteButton.IsEnabled = true;
                        StartGameButton.IsEnabled = true;
                        Client.isOwnerOfGame = true;
                    }
                    else if (IsOwner == false)
                    {
                        InviteButton.IsEnabled = false;
                        StartGameButton.IsEnabled = false;
                        Client.isOwnerOfGame = false;
                    }
                    var m = JsonConvert.DeserializeObject<invitationRequest>(CurrentLobby.GameData);
                    queueId = m.queueId;
                    isRanked = m.isRanked;
                    rankedTeamName = m.rankedTeamName;
                    mapId = m.mapId;
                    gameTypeConfigId = m.gameTypeConfigId;
                    gameMode = m.gameMode;
                    gameType = m.gameType;

                    foreach (Member stats in CurrentLobby.Members)
                    {
                        //Your kidding me right
                        var TeamPlayer = new TeamControl();
                        TeamPlayerStats = TeamPlayer;
                        TeamPlayer.SummonerName.Content = stats.SummonerName;
                        TeamPlayer.SumId.Content = stats.SummonerName;
                        TeamPlayer.Kick.Tag = stats;
                        TeamPlayer.Inviter.Tag = stats;
                        TeamPlayer.UnInviter.Tag = stats;
                        TeamPlayer.Profile.Tag = stats;
                        TeamPlayer.Owner.Tag = stats;
                        TeamPlayer.Width = 1500;
                        TeamPlayer.HorizontalAlignment = HorizontalAlignment.Stretch;

                        TeamPlayer.Kick.Click += Kick_Click;
                        TeamPlayer.Inviter.Click += async (sender, e) =>
                        {
                            LastSender = (Button)sender;
                            var s = (Member)LastSender.Tag;
                            await RiotCalls.GrantInvite(s.SummonerId);
                            await Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                            {
                                TeamPlayer.Inviter.Visibility = Visibility.Hidden;
                                TeamPlayer.UnInviter.Visibility = Visibility.Visible;
                            }));
                        };
                        TeamPlayer.UnInviter.Click += async (sender, e) =>
                        {
                            LastSender = (Button)sender;
                            var s = (Member)LastSender.Tag;
                            await RiotCalls.RevokeInvite(s.SummonerId);
                            await Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                            {
                                TeamPlayer.Inviter.Visibility = Visibility.Visible;
                                TeamPlayer.UnInviter.Visibility = Visibility.Hidden;
                            }));
                        };
                        TeamPlayer.Profile.Click += Profile_Click;
                        TeamPlayer.Owner.Click += Owner_Click;
                        Players++;

                        PublicSummoner Summoner = await RiotCalls.GetSummonerByName(stats.SummonerName);

                        //Populate the ProfileIcon
                        int ProfileIconID = Summoner.ProfileIconId;
                        string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon",
                            ProfileIconID + ".png");

                        TeamPlayer.ProfileIcon.Source = Client.GetImage(UriSource);

                        //Make it so you cant kick yourself
                        if (stats.SummonerName == Client.LoginPacket.AllSummonerData.Summoner.Name)
                        {
                            TeamPlayer.Kick.Visibility = Visibility.Hidden;
                            TeamPlayer.Inviter.Visibility = Visibility.Hidden;
                            TeamPlayer.UnInviter.Visibility = Visibility.Hidden;
                            TeamPlayer.Profile.Visibility = Visibility.Hidden;
                            TeamPlayer.Owner.Visibility = Visibility.Hidden;
                            if (stats.hasDelegatedInvitePower && IsOwner == false)
                            {
                                InviteButton.IsEnabled = true;
                            }
                            else if (stats.hasDelegatedInvitePower == false && IsOwner == false)
                            {
                                InviteButton.IsEnabled = false;
                            }
                        }
                        if (IsOwner == false)
                        {
                            //So you don't crash trying to kick someone when you can't
                            TeamPlayer.Kick.Visibility = Visibility.Hidden;
                            TeamPlayer.Inviter.Visibility = Visibility.Hidden;
                            TeamPlayer.UnInviter.Visibility = Visibility.Hidden;
                            TeamPlayer.Owner.Visibility = Visibility.Hidden;
                        }
                        TeamListView.Items.Add(TeamPlayer);
                    }
                    if (queueId == 4)
                    {
                        if (Players >= 2)
                            InviteButton.IsEnabled = false;
                        else
                            InviteButton.IsEnabled = true;
                    }
                    if (IsOwner)
                    {
                        await RiotCalls.CallLCDS(Guid.NewGuid().ToString(), "suggestedPlayers",
                            "retrieveOnlineFriendsOfFriends", "{\"queueId\":" + queueId + "}");
                    }
                }));
            }
            catch
            {
            }
        }