Example #1
0
        /// <summary>
        /// Starts displaying the cover image for the specified mapset.
        /// </summary>
        public void Setup(OnlineMapset mapset)
        {
            Reset();

            this.mapset = mapset;
            if (mapset == null)
            {
                return;
            }

            string cardImage = mapset.CardImage;

            // If the image is already loaded in cacher, just load image immediately.
            if (WebImageCacher.IsCached(cardImage))
            {
                Load(cardImage);
            }
            // Else, load the image after delay to reduce performance implications when scrolling quickly.
            else
            {
                loadDelay = new SynchronizedTimer()
                {
                    Limit = 1f
                };
                loadDelay.OnFinished += () =>
                {
                    loadDelay = null;
                    Load(cardImage);
                };
                loadDelay.Start();
            }
        }
Example #2
0
 /// <summary>
 /// Returns the music preview progress value for specified mapset.
 /// </summary>
 public float GetPreviewProgress(OnlineMapset mapset)
 {
     if (!IsPreviewingMapset(mapset))
     {
         return(0f);
     }
     return(MusicController.Progress);
 }
Example #3
0
        /// <summary>
        /// Hides the cover image.
        /// </summary>
        public void Reset()
        {
            this.mapset = null;
            Unload();

            if (loadDelay != null)
            {
                loadDelay.Stop();
                loadDelay = null;
            }
        }
Example #4
0
        /// <summary>
        /// Resets the current mapset context for actions.
        /// </summary>
        public void Reset()
        {
            if (mapset == null)
            {
                return;
            }

            Model.PreviewingMapset.OnNewValue -= OnPreviewMapsetChange;

            mapset = null;
        }
Example #5
0
        /// <summary>
        /// Makes the specified mapset the previewing mapset.
        /// </summary>
        public void SetPreview(OnlineMapset mapset)
        {
            bool isPreviewing = mapset == previewingMapset.Value;

            ResetPreviewingMapset();

            if (!isPreviewing && mapset != null && !string.IsNullOrEmpty(mapset.PreviewAudio))
            {
                previewingMapset.Value = mapset;
                musicAgent.Request(mapset.PreviewAudio);
            }
        }
        /// <summary>
        /// Initializes the display for cell using the specified mapset.
        /// </summary>
        public void Setup(OnlineMapset mapset)
        {
            this.mapset = mapset;

            coverImage.Setup(mapset);
            previewBar.Setup(mapset);
            metaDisplayer.Setup(mapset);
            actionBar.Setup(mapset);

            titleLabel.Text  = mapset?.Title;
            artistLabel.Text = mapset?.Artist;
            mapperLabel.Text = mapset?.Creator;
        }
Example #7
0
        /// <summary>
        /// Initializes the action bar for specified mapset.
        /// </summary>
        public void Setup(OnlineMapset mapset)
        {
            grid.CellSize = new Vector2(this.Width / 2f, this.Height);

            Reset();
            if (mapset == null)
            {
                return;
            }

            this.mapset = mapset;

            Model.PreviewingMapset.BindAndTrigger(OnPreviewMapsetChange);
        }
        /// <summary>
        /// Sets meta tags for specified mapset.
        /// </summary>
        public void Setup(OnlineMapset mapset)
        {
            Reset();

            if (mapset == null)
            {
                return;
            }

            rankTag.SetRank(mapset.Status);
            playCountTag.SetPlayCount(mapset.PlayCount);
            favoriteCountTag.SetFavoriteCount(mapset.FavoriteCount);

            float tagX = rankTag.Width + HorizontalTagSpace;

            foreach (var mode in mapset.Maps.GroupBy(m => m.GameMode))
            {
                var tag = mapTagRecycler.GetNext();
                tag.SetMapCount(mode.Key, mode.Count());
                tag.Position = new Vector3(tagX, 0f);
                tagX        += MapTagWidth + HorizontalTagSpace;
            }
        }
Example #9
0
        /// <summary>
        /// Starts downloading the specified mapset.
        /// </summary>
        public void DownloadMapset(OnlineMapset mapset)
        {
            if (mapset == null)
            {
                return;
            }

            // Ensure the provider exists
            var provider = SelectedProvider;

            if (provider == null)
            {
                return;
            }

            // Setup request.
            var request = provider.MapsetDownload();

            request.DownloadStore = DownloadStore;
            request.Mapset        = mapset;

            // Start request
            Api.Request(request);
        }
Example #10
0
 protected override void OnDisable()
 {
     base.OnDisable();
     this.mapset = null;
 }
Example #11
0
 /// <summary>
 /// Returns whether the specified mapset is a previewing mapset.
 /// </summary>
 public bool IsPreviewingMapset(OnlineMapset mapset)
 {
     return(mapset != null && mapset == previewingMapset.Value);
 }
        private IEnumerator AssignMapset()
        {
            OnlineMapset mapset = new OnlineMapset()
            {
                Artist        = "Test artist",
                Bpm           = 200,
                Creator       = "Test creator",
                FavoriteCount = 50,
                Id            = 15342,
                LastUpdate    = DateTime.Now,
                Maps          = new OnlineMap[]
                {
                    new OnlineMap()
                    {
                        Accuracy      = 5.5f,
                        AR            = 9,
                        Bpm           = 200,
                        CircleCount   = 1363,
                        CS            = 4,
                        Difficulty    = 2.23f,
                        Drain         = 6,
                        HitDuration   = 132,
                        Id            = 2362,
                        ModeIndex     = (int)GameProviderType.Osu + 0,
                        SliderCount   = 25,
                        SpinnerCount  = 1,
                        TotalCount    = 3523,
                        TotalDuration = 13,
                        Version       = "Test version",
                    }
                },
                PlayCount     = 1366,
                Source        = "Test source",
                Tags          = "test tags",
                Title         = "Test title",
                Status        = "Test status",
                CardImage     = "",
                CoverImage    = "",
                HasStoryboard = false,
                HasVideo      = false,
                IsDisabled    = false,
                PreviewAudio  = "",
            };

            cell.Setup(mapset);
            {
                Assert.AreEqual("Test title", cell.FindFromPath <Label>("container/title").Text);
                Assert.AreEqual("Test artist", cell.FindFromPath <Label>("container/artist").Text);
                Assert.AreEqual("Test creator", cell.FindFromPath <Label>("container/mapper").Text);

                var metaDisplayer = cell.FindFromPath <MetaDisplayer>("container/meta");
                {
                    Assert.AreEqual("Test status", metaDisplayer.FindFromPath <RankMetaTag>("rank").LabelText);
                    Assert.AreEqual("1,366", metaDisplayer.FindFromPath <StatMetaTag>("stat").LabelText);
                    Assert.AreEqual("50", metaDisplayer.FindFromPath <StatMetaTag>("favorite").LabelText);
                    Assert.AreEqual("icon-play", metaDisplayer.FindWithName <UguiSprite>("icon").SpriteName);
                    Assert.AreEqual(1, metaDisplayer.GetComponentsInChildren <MapMetaTag>(false).Length);

                    var tag = metaDisplayer.GetComponentInChildren <MapMetaTag>(false);
                    Assert.AreEqual(
                        ModeManager.GetService(GameModeType.OsuStandard).GetIconName(32),
                        tag.FindWithName <UguiSprite>("icon").SpriteName
                        );
                    Assert.AreEqual("1", tag.LabelText);
                }
            }
            yield return(null);
        }
Example #13
0
 /// <summary>
 /// Event called on previewing mapset change.
 /// </summary>
 private void OnPreviewMapsetChange(OnlineMapset newMapset)
 {
     playButton.IconName = Model.IsPreviewingMapset(this.mapset) ? "icon-stop" : "icon-play";
 }