Exemple #1
0
        private void Display()
        {
            pDialog dialog = new pDialog(null, false);

            dialog.spriteManager.HandleOverlayInput = true;
            dialog.ButtonOffset = new Vector2(50, 60);

            ChatEngine.RequestUserStats(new List <User>()
            {
                User
            }, true);

            bool isSelf = User.Name == GameBase.User.Name;

            dialog.Closed += delegate { ActiveProfiles.Remove(this); };

            if (User.IsOsu && !isSelf)
            {
                if (GameBase.Mode != OsuModes.Edit && (GameBase.Mode != OsuModes.Play || !GameBase.TestMode))
                {
                    dialog.AddOption(User == StreamingManager.CurrentlySpectating ? LocalisationManager.GetString(OsuString.UserProfile_StopSpectating) : LocalisationManager.GetString(OsuString.UserProfile_StartSpectating),
                                     Color.YellowGreen,
                                     delegate
                    {
                        if (Lobby.Status != LobbyStatus.NotJoined)
                        {
                            NotificationManager.ShowMessage(
                                LocalisationManager.GetString(OsuString.UserProfile_CantSpectate));
                            return;
                        }

                        if (GameBase.Mode == OsuModes.Play && !InputManager.ReplayMode)
                        {
                            NotificationManager.ShowMessage(
                                LocalisationManager.GetString(OsuString.UserProfile_CantSpectate));
                            return;
                        }

                        if (User.Name == ConfigManager.sUsername ||
                            User == StreamingManager.CurrentlySpectating)
                        {
                            StreamingManager.StopSpectating(true);
                        }
                        else
                        {
                            StreamingManager.StartSpectating(User);
                        }
                    });
                }
            }

            dialog.AddOption(LocalisationManager.GetString(OsuString.UserProfile_ViewProfile), new Color(58, 110, 165),
                             delegate
            {
                GameBase.ProcessStart(User.Id == 0 ? @"https://osu.ppy.sh/wiki/BanchoBot" : String.Format(Urls.USER_PROFILE, User.Id));
            });

            if (isSelf)
            {
                if (GameBase.Mode == OsuModes.Menu && BanchoClient.AllowUserSwitching)
                {
                    dialog.AddOption(LocalisationManager.GetString(OsuString.UserProfile_SignOut), Color.Orange, delegate
                    {
                        GameBase.Options.PerformLogout();
                        if (!GameBase.Options.Expanded)
                        {
                            GameBase.ShowLogin();
                        }
                    });
                }
                dialog.AddOption(LocalisationManager.GetString(OsuString.UserProfile_ChangeAvatar), Color.Orange, delegate { GameBase.ProcessStart(Urls.USER_SET_AVATAR); });
            }
            else
            {
                dialog.AddOption(LocalisationManager.GetString(OsuString.UserProfile_StartChat), Color.MediumPurple,
                                 delegate { ChatEngine.StartChat(User); });

                if (User.IsOsu)
                {
                    if (MatchSetup.Match != null)
                    {
                        dialog.AddOption(LocalisationManager.GetString(OsuString.UserProfile_Invitetogame), Color.Yellow, delegate
                        {
                            BanchoClient.SendRequest(new Request(RequestType.Osu_Invite, new bInt(User.Id)));
                            NotificationManager.ShowMessageMassive(string.Format(LocalisationManager.GetString(OsuString.ChatEngine_UserInvited), User.Name));
                        });
                    }
                }

                dialog.AddOption(User.IsFriend ? LocalisationManager.GetString(OsuString.UserProfile_CancelFriendship) : LocalisationManager.GetString(OsuString.UserProfile_AddFriend), Color.Pink, delegate { ChatEngine.ToggleFriend(User, !User.IsFriend); });

                if (ShowExtraOptions && User.Id > 0)
                {
                    dialog.AddOption(LocalisationManager.GetString(OsuString.UserProfile_ReportUser), Color.Red,
                                     delegate
                    {
                        UserReportDialog report = new UserReportDialog(User, ChatEngine.activeChannel);
                        GameBase.ShowDialog(report);
                    });

                    if (ChatEngine.CheckIgnore(User))
                    {
                        dialog.AddOption(LocalisationManager.GetString(OsuString.UserProfile_UnignoreUser), Color.Gray, delegate { ChatEngine.UnignoreUser(User); });
                    }
                    else
                    {
                        dialog.AddOption(LocalisationManager.GetString(OsuString.UserProfile_IgnoreUser), Color.Gray, delegate { ChatEngine.IgnoreUser(User); });
                    }
                }
            }

            dialog.AddOption(LocalisationManager.GetString(OsuString.General_Close), Color.DarkGray, null);


            if (DisplayedUser.DrawAt(new Vector2(5, 5), true, 0))
            {
                dialog.spriteManager.Add(DisplayedUser.Sprites);
            }

            GameBase.ShowDialog(dialog);

            /*if (User.Id != 0)
             * {
             *  GameBase.Scheduler.Add(delegate
             *  {
             *      if (!dialog.IsDisplayed) return;
             *
             *      if (browser == null)
             *      {
             *          GameBase.OnResolutionChange += GameBase_OnResolutionChange;
             *          browser = new pBrowser(null, Vector2.Zero, new Vector2(220, GameBase.WindowManager.Height - 48 * GameBase.WindowManager.Ratio), 0.911f, Color.White);
             *          browser.Disposable = false;
             *          browser.OnLoaded += delegate
             *          {
             *              browser.FadeIn(500);
             *              browser.MoveToRelative(new Vector2(88, 0), 500, EasingTypes.In);
             *          };
             *      }
             *
             *      browser.Transformations.Clear();
             *      browser.CurrentAlpha = 0;
             *      browser.AlwaysDraw = true;
             *      browser.CurrentPosition = new Vector2(-88, 48);
             *      browser.Load(string.Format(Urls.USER_PROFILE_COMPACT, User.Id));
             *
             *      dialog.spriteManager.Add(browser);
             *  }, 1000);
             * }*/
        }