示例#1
0
 public static bool StartDownload(OsuDirectDownload odd)
 {
     if (ActiveDownloads.Contains(odd))
     {
         return(false);
     }
     ActiveDownloads.Add(odd);
     UpdatePending = true;
     return(true);
 }
示例#2
0
        public static OsuDirectDownload StartDownload(OnlineBeatmap ob, bool noVideo)
        {
            //check for existing downloads for this beatmap first.
            if (ActiveDownloads.Find(d => d.beatmap.setId == ob.setId) != null)
            {
                NotificationManager.ShowMessageMassive("This beatmap is already being downloaded!", 2000);
                return(null);
            }

            GameBase.Scheduler.Add(delegate
            {
                if (RespondingBeatmap == ob)
                {
                    HideResponseDialog();
                }
            });

#if P2P
            OsuMagnetFactory.WebGetOz2Hashes(ob.setid, (hash, dummy) => GameBase.Scheduler.Add(() =>
            {
                OsuDirectDownload odd;
                if (hash != null)
                {
                    odd = new P2PDirectDownload(ob, noVideo);
                }
                else
                {
                    odd = new OsuDirectDownload(ob, noVideo);
                }
                StartDownload(odd);
                callback(odd);
            }));
#else
            OsuDirectDownload odd = new OsuDirectDownload(ob, noVideo);
            StartDownload(odd);
#endif

            return(odd);
        }
示例#3
0
        public override void Update()
        {
            downloadListPanel.Update();

            if (sampleTrack != null)
            {
                if (sampleTrack.IsPlaying && !disallowAudioPreview)
                {
                    sampleTrack.Volume = AudioEngine.VolumeMusicAdjusted / 100f;

                    if (!AudioEngine.Paused)
                    {
                        WasPlayingAudio = true;
                        AudioEngine.TogglePause();
                    }
                }
                else
                {
                    ResetAudioPreview();
                }
            }

            if (ResponseQueue.Count > 0)
            {
                ShowResponseDialog(ResponseQueue.Dequeue());
            }

            if (GameBase.Mode == OsuModes.Play && !Player.Paused && !InputManager.ReplayMode) //allow showing response dialog only in pause
            {
                HideResponseDialog();
            }

            if (ActiveDownloads.Count > 0 || RespondingBeatmap != null)
            {
                delayClose = true;
            }
            else if (GameBase.Mode == OsuModes.OnlineSelection)
            {
                delayClose = false;
            }

            alwaysShow = GameBase.Mode == OsuModes.OnlineSelection || RespondingBeatmap != null;
            mustHide   = ActiveDownloads.Count == 0 && !alwaysShow;

            if (!mustHide &&
                (alwaysShow ||
                 (!Player.Playing &&
                  (background.drawRectangle.Contains(MouseManager.MousePoint) ||
                   MouseManager.MousePosition.X > GameBase.WindowManager.Width))))
            {
                Show();
            }
            else
            {
                Hide();
            }

            if (UpdatePending)
            {
                int y = 0;

                int ActiveCount = ActiveDownloads.FindAll(d => d.Status > DownloadStatus.Waiting).Count;

                UpdatePending = false;

                for (int i = 0; i < ActiveDownloads.Count; i++)
                {
                    OsuDirectDownload d = ActiveDownloads[i];

                    if (d.Status == DownloadStatus.Waiting && ActiveCount < MAX_CONCURRENT_DOWNLOADS)
                    {
                        d.Start();
                        ActiveCount++;
                    }
                    else if (d.Status == DownloadStatus.Completed)
                    {
                        if (d.SpriteCollection != null)
                        {
                            foreach (pSprite p in d.SpriteCollection)
                            {
                                if (Visible || (Player.Playing && !ConfigManager.sPopupDuringGameplay.Value))
                                {
                                    p.FadeOut(300);
                                }
                                else
                                {
                                    downloadListPanel.ContentSpriteManager.Remove(p);
                                    GameBase.spriteManagerOverlay.Add(p);

                                    p.Field = Fields.TopRight;

                                    p.Position = new Vector2(XPOSHIDDEN, p.Position.Y + YPOS + 20);

                                    p.FadeOut(2500);
                                    p.MoveTo(new Vector2(XPOS, p.Position.Y), 800, EasingTypes.Out);
                                }
                                p.AlwaysDraw = false;
                            }
                        }
                        ActiveDownloads.RemoveAt(i--);

                        //loop from start again
                        UpdatePending = true;

                        continue;
                    }

                    if (d.DrawAt(new Vector2(0, y)))
                    {
                        downloadListPanel.ContentSpriteManager.Add(d.SpriteCollection);
                        Show(true);
                    }

                    y += 20;
                }

                downloadListPanel.SetContentDimensions(new Vector2(WIDTH, y));
            }

            base.Update();
        }