Exemple #1
0
        public static void StopSpectating(bool ExitPlayMode)
        {
            if (ExitPlayMode && GameBase.Mode == Modes.Play)
            {
                InputManager.ReplayMode = false;
                if (CurrentlySpectating == null)
                {
                    GameBase.ChangeMode(Modes.SelectPlay, true);
                }
                else
                {
                    GameBase.ChangeMode(Modes.Menu, true);
                }
            }

            lock (LockReplayScore)
                if (CurrentlySpectating != null)
                {
                    BanchoClient.SendRequest(RequestType.Osu_StopSpectating, null);
                    GameBase.ShowMessage("Stopped spectating " + CurrentlySpectating.Name, Color.Tomato, 3000);
                    CurrentlySpectating = null;
                }

            FellowSpectators.Clear();
            ReplayQueue.Clear();
        }
Exemple #2
0
        public static void StartSpectating(User u)
        {
            if (Lobby.Status != LobbyStatus.NotJoined)
            {
                GameBase.ShowMessage("Can't spectate while in multiplayer mode!", Color.Tomato, 3000);
                return;
            }

            lock (LockReplayScore)
                if (CurrentlySpectating != u)
                {
                    FellowSpectators.Clear();

                    if (GameBase.Mode == Modes.Edit || GameBase.Mode == Modes.Play)
                    {
                        GameBase.ChangeMode(Modes.Menu, true);
                    }

                    CurrentlySpectating      = u;
                    iDontHaveThatBeatmap     = false;
                    InputManager.ReplayScore = null;

                    BanchoClient.SendRequest(RequestType.Osu_StartSpectating, new bInt(u.Id));
                    GameBase.ShowMessage("Started spectating " + u.Name, Color.Green, 3000);

                    //WaitingLoad = true;
                }
        }
Exemple #3
0
        internal static void PurgeFrames(ReplayAction action)
        {
            if (!HasSpectators || InputManager.ReplayMode)
            {
                return;
            }

            if (action == ReplayAction.NewSong)
            {
                lock (Spectators)
                    foreach (User u in Spectators)
                    {
                        u.CantSpectate = false;
                    }
            }

            bScoreFrame scoreFrame = Player.GetScoreFrame();

            BanchoClient.SendRequest(RequestType.Osu_SpectateFrames,
                                     new bReplayFrameBundle(waitingOutgoingFrames, action, scoreFrame));
#if DEBUG
            /*   GameBase.ShowMessage("sending " + waitingOutgoingFrames.Count + " frames to spectators", Color.LightBlue,
             *                      200);*/
#endif
            waitingOutgoingFrames = new List <bReplayFrame>();
        }
Exemple #4
0
 public void Join()
 {
     if (!Joined)
     {
         BanchoClient.SendRequest(RequestType.Osu_ChannelJoin, new bString(name));
         messageBuffer.Add(new Message("Attempting to join channel...", "", Color.LightCoral));
     }
 }
Exemple #5
0
        internal static bool QueryAll()
        {
            if (lastFullPresenceRequest > 0 && GameBase.Time - lastFullPresenceRequest < 300000)
            {
                return(false);
            }

            lastFullPresenceRequest = GameBase.Time;
            BanchoClient.SendRequest(RequestType.Osu_UserPresenceRequestAll, GameBase.Time);
            return(true);
        }
Exemple #6
0
        public static void HandleSongChange(bool resetStart)
        {
            lock (LockReplayScore)
            {
                if (CurrentlySpectating == null)
                {
                    return;
                }

                Beatmap b = BeatmapManager.GetBeatmapByChecksum(CurrentlySpectating.CurrentBeatmapChecksum);
                if (b != null)
                {
                    GameBase.ShowMessage("Host is playing:" + b.DisplayTitle, Color.Green, 1000);

                    BeatmapManager.Current   = b;
                    InputManager.ReplayMode  = true;
                    InputManager.ReplayToEnd = false;

                    InputManager.ReplayStreaming = true;

                    InputManager.ReplayScore = new Score();
                    InputManager.ReplayScore.AllowSubmission = false;
                    InputManager.ReplayScore.enabledMods     = CurrentlySpectating.CurrentMods;

                    if (resetStart)
                    {
                        InputManager.ReplayStreamingStart = 0;
                    }

                    ChatEngine.PendingHide = true;

                    GameBase.ChangeMode(Modes.Play, true);
                }
                else if (!string.IsNullOrEmpty(CurrentlySpectating.BeatmapName))
                {
                    GameBase.ShowMessage("You don't have the beatmap the host is playing (" +
                                         CurrentlySpectating.BeatmapName + ")");
                    BanchoClient.SendRequest(RequestType.Osu_CantSpectate, null);
                    iDontHaveThatBeatmap = true;

                    InputManager.ReplayMode = false;
                    if (GameBase.Mode == Modes.Play)
                    {
                        GameBase.ChangeMode(Modes.Menu, true);
                    }
                }
                else
                {
                    GameBase.ShowMessage("host isn't playing!");
                }
            }
            WaitingLoad = false;
        }
Exemple #7
0
        public static bool StartSpectating(User u)
        {
            if (u == null)
            {
                return(false);
            }

            if (Lobby.Status != LobbyStatus.NotJoined)
            {
                NotificationManager.ShowMessage("Can't spectate while in multiplayer mode!", Color.Tomato, 3000);
                return(false);
            }

            bool newUser = u != CurrentlySpectating;

            if (u.Id == GameBase.User.Id)
            {
                StopSpectating(CurrentlySpectating != null);
                return(false);
            }

            lock (LockReplayScore)
            {
                NewUserAndSong = true;

                if (GameBase.Mode == OsuModes.Edit || GameBase.Mode == OsuModes.Play)
                {
                    GameBase.ChangeMode(OsuModes.Menu, true);
                }

                CurrentlySpectating     = u;
                InputManager.ReplayMode = false;
                iDontHaveThatBeatmap    = false;

                if (newUser)
                {
                    FellowSpectators.Clear();
                    u.RequestPresence();

                    NotificationManager.ShowMessage("Started spectating " + u.Name, Color.Green, 3000);
                    GameBase.SetTitle();
                }

                BanchoClient.SendRequest(RequestType.Osu_StartSpectating, new bInt(u.Id));
            }

            return(true);
        }
Exemple #8
0
        private static void scheduledFill()
        {
            lock (idToPresenceCache)
            {
                if (pendingQueries.Count > 256)
                {
                    QueryAll();
                }
                else
                {
                    BanchoClient.SendRequest(RequestType.Osu_UserPresenceRequest, new bListInt(pendingQueries));
                }

                pendingQueries = new List <int>();
            }
        }
Exemple #9
0
        internal bool PullStats(bool force)
        {
            if (StatsLoaded && !force)
            {
                return(true);
            }

            if (StatsLoading)
            {
                return(false);
            }

            if (Name.Length > 0)
            {
                StatsLoading = true;

                if (Sprites != null)
                {
                    spriteBackground.FlashColour(Color.Crimson, 3000);
                    spriteName.Text = Name;

                    AvatarLoaded = false;

                    if (firstReceived)
                    {
                        spriteInfo.Text = "Loading stats...";
                    }
                }

                if (Name == ConfigManager.sUsername)
                {
                    BanchoClient.SendRequest(RequestType.Osu_RequestStatusUpdate, null);
                }
            }
            else
            {
                spriteName.Text = "Guest";
                spriteInfo.Text = "Please click here to login.";
            }

            return(true);
        }
Exemple #10
0
        public static void StopSpectating(bool ExitPlayMode = true)
        {
            if (GameBase.TourneySpectatorName != null)
            {
                GameBase.TourneySpectatorName.Text = string.Empty;
            }

            if (ExitPlayMode && (GameBase.Mode == OsuModes.Play || (GameBase.Mode != OsuModes.Menu && GameBase.Tournament)))
            {
                InputManager.ReplayMode = false;
                if (CurrentlySpectating == null)
                {
                    GameBase.ChangeMode(OsuModes.SelectPlay, true);
                }
                else
                {
                    GameBase.ChangeMode(OsuModes.Menu, true);
                }
            }

            if (CurrentlySpectating != null)
            {
                lock (LockReplayScore)
                {
                    BanchoClient.SendRequest(RequestType.Osu_StopSpectating, null);
                    NotificationManager.ShowMessage("Stopped spectating " + CurrentlySpectating.Name, Color.Tomato, 3000);
                    CurrentlySpectating          = null;
                    InputManager.ReplayStreaming = false;
                }
                if (ChatEngine.channels.Exists(s => s.Name == "#spectator"))
                {
                    ChatEngine.RemoveChannel(ChatEngine.channels.Find(s => s.Name == "#spectator"), false, true);
                }

                InputManager.ReplayStartTime = 0;
            }

            FellowSpectators.Clear();
            ReplayQueue.Clear();
            GameBase.SetTitle();
        }
Exemple #11
0
        internal static void PurgeFrames(ReplayAction action, int?extra = null)
        {
            if (!HasSpectators || InputManager.ReplayMode)
            {
                return;
            }

            if (action == ReplayAction.NewSong)
            {
                lock (Spectators)
                    foreach (User u in Spectators)
                    {
                        u.CantSpectate = false;
                    }
            }

            bScoreFrame scoreFrame = Player.GetScoreFrame();

            BanchoClient.SendRequest(RequestType.Osu_SpectateFrames, new bReplayFrameBundle(waitingOutgoingFrames, action, scoreFrame, extra ?? Player.Seed));

            waitingOutgoingFrames = new List <bReplayFrame>();
        }
Exemple #12
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);
             * }*/
        }
Exemple #13
0
        public static void HandleFrames(bReplayFrameBundle bundle)
        {
#if DEBUG
            /*GameBase.ShowMessage(
             *  "received frames (" + bundle.Action +
             *  (bundle.ReplayFrames.Count > 0
             *       ? "," + bundle.ReplayFrames[0].time + "-" + bundle.ReplayFrames[bundle.ReplayFrames.Count - 1].time +
             *         ")"
             *       : "0)"), Color.Green, 1000);*/
#endif

            waitingOnHost = false;

            LastAction = bundle.Action;

            switch (bundle.Action)
            {
            case ReplayAction.Completion:
                InputManager.ReplayToEnd = true;
                break;

            case ReplayAction.Fail:
                InputManager.ReplayToEnd = true;
                break;

            case ReplayAction.WatchingOther:
                User u = BanchoClient.GetUserById(bundle.Extra);
                if (u != null && u.Id != GameBase.User.Id)
                {
                    NotificationManager.ShowMessage("Following host to new user...", Color.Green, 3000);
                    StartSpectating(u);
                }
                else
                {
                    StopSpectating();
                }
                break;

            case ReplayAction.NewSong:
                iDontHaveThatBeatmap = false;
                //ensure spectators use the same seed as players.
                Player.Seed = bundle.Extra;
                HandleSongChange(true, bundle.ScoreFrame.usingScoreV2);
                break;

            case ReplayAction.Skip:
                Player.QueueSkip();
                break;

            case ReplayAction.Standard:
                if (!iDontHaveThatBeatmap && InputManager.ReplayScore == null)
                {
                    if (bundle.ReplayFrames.Count > 0)
                    {
                        InputManager.ReplayStartTime = bundle.ReplayFrames[0].time - 50;
                    }
                    else     // set to 1 instead of 0 to make it not doubleskip if the first frame is a skip frame.
                    {
                        InputManager.ReplayStartTime = 1;
                    }
                    Player.Seed = bundle.Extra;
                    HandleSongChange(false, bundle.ScoreFrame.usingScoreV2);
                }
                break;

            case ReplayAction.Pause:
                if (!Player.Paused && Player.Instance != null)
                {
                    Player.Instance.TogglePause();
                }
                break;

            case ReplayAction.Unpause:
                if (Player.Paused && Player.Instance != null)
                {
                    Player.Instance.TogglePause();
                }
                break;
            }

            float lastY      = 0;
            int   lastOffset = 0;
            lock (LockReplayScore)
            {
                if (InputManager.ReplayScore != null && InputManager.ReplayScore.Replay != null)
                {
                    foreach (bReplayFrame f in bundle.ReplayFrames)
                    {
                        InputManager.ReplayScore.Replay.Add(f);
                    }
                    if (bundle.ReplayFrames.Count > 0)
                    {
                        int last = bundle.ReplayFrames.Count - 1;
                        lastY      = bundle.ReplayFrames[last].mouseY;
                        lastOffset = bundle.ReplayFrames[last].time;
                    }
                    if ((ScoreSyncNext <= 0 || ScoreSyncNext < InputManager.ReplayFrame || InputManager.ReplayScore.Replay.Count - 1 < ScoreSyncNext) && bundle.ScoreFrame.totalScore > 0)
                    {
                        ScoreSyncNext  = InputManager.ReplayScore.Replay.Count - 1;
                        ScoreSyncFrame = bundle.ScoreFrame;
                    }
                }
            }

            if (HasSpectators && CurrentlySpectating != null && CurrentlySpectating.Id != GameBase.User.Id && GameBase.Time - lastFollowNotification > 10000)
            {
                //tell spectators we are watching someone else.
                BanchoClient.SendRequest(RequestType.Osu_SpectateFrames, new bReplayFrameBundle(new List <bReplayFrame>(), ReplayAction.WatchingOther, new bScoreFrame(), CurrentlySpectating.Id));
                lastFollowNotification = GameBase.Time;
            }
        }
Exemple #14
0
        public static void HandleSongChange(bool resetStart, bool useScoreV2)
        {
            lock (LockReplayScore)
            {
                if (CurrentlySpectating == null)
                {
                    return;
                }

                Beatmap b = BeatmapManager.GetBeatmapByChecksum(CurrentlySpectating.CurrentBeatmapChecksum);

                if (b != null)
                {
                    NotificationManager.ShowMessage("Host is playing:" + b.DisplayTitle, Color.Green, 1000);

                    BeatmapManager.Current   = b;
                    InputManager.ReplayMode  = true;
                    InputManager.ReplayToEnd = false;

                    InputManager.ReplayStreaming = true;

                    InputManager.ReplayScore = ScoreFactory.Create(CurrentlySpectating.PlayMode, null, BeatmapManager.Current, useScoreV2);
                    InputManager.ReplayScore.InvalidateSubmission();
                    InputManager.ReplayScore.EnabledMods = CurrentlySpectating.CurrentMods;

                    if (resetStart)
                    {
                        InputManager.ReplayStartTime = 0;
                    }

                    if (NewUserAndSong)
                    {
                        GameBase.Scheduler.Add(delegate { if (ChatEngine.IsVisible)
                                                          {
                                                              ChatEngine.Visibility = ChatVisibility.ChatOnly;
                                                          }
                                               });
                        NewUserAndSong = false;
                    }

                    GameBase.ChangeMode(OsuModes.Play, true);
                }
                else if (!string.IsNullOrEmpty(CurrentlySpectating.BeatmapName))
                {
                    if (CurrentlySpectating.BeatmapId > 0 && (BanchoClient.Permission & Permissions.Supporter) > 0)
                    {
                        if (OsuDirect.ActiveDownloads.Find(d => d.beatmap != null && d.beatmap.beatmapId == CurrentlySpectating.BeatmapId) == null &&
                            (OsuDirect.RespondingBeatmap == null || OsuDirect.RespondingBeatmap.beatmapId != CurrentlySpectating.BeatmapId))
                        {
                            OsuDirect.HandlePickup(LinkId.Beatmap, CurrentlySpectating.BeatmapId, RestartSpectating);
                        }
                    }
                    else
                    {
                        string message = string.Format("You don't have the beatmap the host is playing ({0}).", CurrentlySpectating.BeatmapName);
                        NotificationManager.ShowMessage(message);
                    }

                    BanchoClient.SendRequest(RequestType.Osu_CantSpectate, null);
                    iDontHaveThatBeatmap = true;

                    InputManager.ReplayMode = false;
                    if (GameBase.Mode == OsuModes.Play)
                    {
                        GameBase.ChangeMode(OsuModes.Menu, true);
                    }
                }
            }
        }