Beispiel #1
0
        protected BeatmapPanel(APIBeatmapSet setInfo)
            : base(HoverSampleSet.Submit)
        {
            Debug.Assert(setInfo.OnlineID > 0);

            SetInfo = setInfo;
        }
Beispiel #2
0
        public GoToBeatmapButton(APIBeatmapSet beatmapSet)
        {
            this.beatmapSet = beatmapSet;

            Icon.Icon   = FontAwesome.Solid.AngleDoubleRight;
            TooltipText = "Go to beatmap";
        }
Beispiel #3
0
        private void updatePlaylist(MultiplayerRoomSettings settings, APIBeatmapSet onlineSet)
        {
            if (Room == null || !Room.Settings.Equals(settings))
            {
                return;
            }

            Debug.Assert(apiRoom != null);

            var beatmapSet = onlineSet.ToBeatmapSet(rulesets);
            var beatmap    = beatmapSet.Beatmaps.Single(b => b.OnlineBeatmapID == settings.BeatmapID);

            beatmap.MD5Hash = settings.BeatmapChecksum;

            var ruleset = rulesets.GetRuleset(settings.RulesetID).CreateInstance();
            var mods    = settings.Mods.Select(m => m.ToMod(ruleset));

            PlaylistItem playlistItem = new PlaylistItem
            {
                ID      = playlistItemId,
                Beatmap = { Value = beatmap },
                Ruleset = { Value = ruleset.RulesetInfo },
            };

            playlistItem.RequiredMods.AddRange(mods);

            apiRoom.Playlist.Clear(); // Clearing should be unnecessary, but here for sanity.
            apiRoom.Playlist.Add(playlistItem);
        }
        public BeatmapCardExtraInfoRow(APIBeatmapSet beatmapSet)
        {
            RelativeSizeAxes = Axes.X;
            AutoSizeAxes     = Axes.Y;

            Child = new FillFlowContainer
            {
                RelativeSizeAxes = Axes.X,
                AutoSizeAxes     = Axes.Y,
                Direction        = FillDirection.Horizontal,
                Spacing          = new Vector2(4, 0),
                Children         = new Drawable[]
                {
                    new BeatmapSetOnlineStatusPill
                    {
                        AutoSizeAxes = Axes.Both,
                        Status       = beatmapSet.Status,
                        Anchor       = Anchor.CentreLeft,
                        Origin       = Anchor.CentreLeft
                    },
                    new DifficultySpectrumDisplay(beatmapSet)
                    {
                        Anchor  = Anchor.CentreLeft,
                        Origin  = Anchor.CentreLeft,
                        DotSize = new Vector2(6, 12)
                    }
                }
            };
        }
Beispiel #5
0
        public void TestRequestHandling()
        {
            APIBeatmapSet          beatmapSetInfo    = null;
            FavouriteButton        button            = null;
            BeatmapFavouriteAction?lastRequestAction = null;

            AddStep("create beatmap set", () => beatmapSetInfo = CreateAPIBeatmapSet(Ruleset.Value));
            AddStep("create button", () => Child = button = new FavouriteButton(beatmapSetInfo)
            {
                Scale = new Vector2(2)
            });

            assertCorrectIcon(false);

            AddStep("register request handling", () => dummyAPI.HandleRequest = request =>
            {
                if (!(request is PostBeatmapFavouriteRequest favouriteRequest))
                {
                    return(false);
                }

                lastRequestAction = favouriteRequest.Action;
                request.TriggerSuccess();
                return(true);
            });
Beispiel #6
0
 public BeatmapCard(APIBeatmapSet beatmapSet)
     : base(HoverSampleSet.Submit)
 {
     this.beatmapSet = beatmapSet;
     favouriteState  = new Bindable <BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount));
     downloadTracker = new BeatmapDownloadTracker(beatmapSet);
 }
Beispiel #7
0
        public HeaderDownloadButton(APIBeatmapSet beatmapSet, bool noVideo = false)
        {
            this.beatmapSet = beatmapSet;
            this.noVideo    = noVideo;

            Width            = 120;
            RelativeSizeAxes = Axes.Y;
        }
Beispiel #8
0
        public DownloadButton(APIBeatmapSet beatmapSet)
        {
            Icon.Icon = FontAwesome.Solid.Download;

            Content.Add(spinner = new LoadingSpinner {
                Size = new Vector2(IconSize)
            });

            this.beatmapSet = beatmapSet;
        }
Beispiel #9
0
        protected BeatmapCard(APIBeatmapSet beatmapSet, bool allowExpansion = true)
            : base(HoverSampleSet.Button)
        {
            Expanded = new BindableBool {
                Disabled = !allowExpansion
            };

            BeatmapSet      = beatmapSet;
            FavouriteState  = new Bindable <BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount));
            DownloadTracker = new BeatmapDownloadTracker(beatmapSet);
        }
Beispiel #10
0
        public BeatmapCard(APIBeatmapSet beatmapSet, bool allowExpansion = true)
            : base(HoverSampleSet.Submit)
        {
            Expanded = new BindableBool {
                Disabled = !allowExpansion
            };

            this.beatmapSet = beatmapSet;
            favouriteState  = new Bindable <BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount));
            downloadTracker = new BeatmapDownloadTracker(beatmapSet);
        }
Beispiel #11
0
        /// <summary>
        /// Creates a beatmap card of the given <paramref name="size"/> for the supplied <paramref name="beatmapSet"/>.
        /// </summary>
        public static BeatmapCard Create(APIBeatmapSet beatmapSet, BeatmapCardSize size, bool allowExpansion = true)
        {
            switch (size)
            {
            case BeatmapCardSize.Normal:
                return(new BeatmapCardNormal(beatmapSet, allowExpansion));

            case BeatmapCardSize.Extra:
                return(new BeatmapCardExtra(beatmapSet, allowExpansion));

            default:
                throw new ArgumentOutOfRangeException(nameof(size), size, @"Unsupported card size");
            }
        }
Beispiel #12
0
        private void showBeatmapPanel(SpectatorState state)
        {
            Debug.Assert(state.BeatmapID != null);

            onlineBeatmapRequest          = new GetBeatmapSetRequest(state.BeatmapID.Value, BeatmapSetLookupType.BeatmapId);
            onlineBeatmapRequest.Success += beatmapSet => Schedule(() =>
            {
                this.beatmapSet             = beatmapSet;
                beatmapPanelContainer.Child = new GridBeatmapPanel(this.beatmapSet);
                checkForAutomaticDownload();
            });

            api.Queue(onlineBeatmapRequest);
        }
Beispiel #13
0
        private void updatePlaylist(MultiplayerRoomSettings settings, APIBeatmapSet onlineSet)
        {
            if (Room == null || !Room.Settings.Equals(settings))
            {
                return;
            }

            Debug.Assert(apiRoom != null);

            var beatmapSet = onlineSet.ToBeatmapSet(rulesets);
            var beatmap    = beatmapSet.Beatmaps.Single(b => b.OnlineBeatmapID == settings.BeatmapID);

            beatmap.MD5Hash = settings.BeatmapChecksum;

            var ruleset     = rulesets.GetRuleset(settings.RulesetID).CreateInstance();
            var mods        = settings.RequiredMods.Select(m => m.ToMod(ruleset));
            var allowedMods = settings.AllowedMods.Select(m => m.ToMod(ruleset));

            // Try to retrieve the existing playlist item from the API room.
            var playlistItem = apiRoom.Playlist.FirstOrDefault(i => i.ID == settings.PlaylistItemId);

            if (playlistItem != null)
            {
                updateItem(playlistItem);
            }
            else
            {
                // An existing playlist item does not exist, so append a new one.
                updateItem(playlistItem = new PlaylistItem());
                apiRoom.Playlist.Add(playlistItem);
            }

            CurrentMatchPlayingItem.Value = playlistItem;

            void updateItem(PlaylistItem item)
            {
                item.ID            = settings.PlaylistItemId == 0 ? defaultPlaylistItemId : settings.PlaylistItemId;
                item.Beatmap.Value = beatmap;
                item.Ruleset.Value = ruleset.RulesetInfo;
                item.RequiredMods.Clear();
                item.RequiredMods.AddRange(mods);
                item.AllowedMods.Clear();
                item.AllowedMods.AddRange(allowedMods);
            }
        }
Beispiel #14
0
        public void TestInitialState([Values] bool favourited)
        {
            APIBeatmapSet   beatmapSetInfo = null;
            FavouriteButton button         = null;

            AddStep("create beatmap set", () =>
            {
                beatmapSetInfo = CreateAPIBeatmapSet(Ruleset.Value);
                beatmapSetInfo.HasFavourited = favourited;
            });
            AddStep("create button", () => Child = button = new FavouriteButton(beatmapSetInfo)
            {
                Scale = new Vector2(2)
            });

            assertCorrectIcon(favourited);
            AddAssert("correct tooltip text", () => button.TooltipText == (favourited ? BeatmapsetsStrings.ShowDetailsUnfavourite : BeatmapsetsStrings.ShowDetailsFavourite));
        }
Beispiel #15
0
        private void load()
        {
            foreach (string filename in downloadableFilenames)
            {
                var match = Regex.Match(filename, @"([0-9]*) (.*) - (.*)\.osz");

                var beatmapSet = new APIBeatmapSet
                {
                    OnlineID = int.Parse(match.Groups[1].Value),
                    Artist   = match.Groups[2].Value,
                    Title    = match.Groups[3].Value,
                };

                var beatmapDownloadTracker = new BeatmapDownloadTracker(beatmapSet);
                downloadTrackers.Add(beatmapDownloadTracker);
                AddInternal(beatmapDownloadTracker);

                beatmapDownloader.Download(beatmapSet);
            }
        }
Beispiel #16
0
        protected override Task <APIBeatmapSet> GetOnlineBeatmapSet(int beatmapId, CancellationToken cancellationToken = default)
        {
            IBeatmapSetInfo?set = roomManager.ServerSideRooms.SelectMany(r => r.Playlist)
                                  .FirstOrDefault(p => p.BeatmapID == beatmapId)?.Beatmap.Value.BeatmapSet
                                  ?? beatmaps.QueryBeatmap(b => b.OnlineID == beatmapId)?.BeatmapSet;

            if (set == null)
            {
                throw new InvalidOperationException("Beatmap not found.");
            }

            var apiSet = new APIBeatmapSet
            {
                OnlineID = set.OnlineID,
                Beatmaps = set.Beatmaps.Select(b => new APIBeatmap {
                    OnlineID = b.OnlineID
                }).ToArray(),
            };

            return(Task.FromResult(apiSet));
        }
Beispiel #17
0
        private Task updateLocalRoomSettings(MultiplayerRoomSettings settings, CancellationToken cancellationToken = default) => scheduleAsync(() =>
        {
            if (Room == null)
            {
                return;
            }

            Debug.Assert(APIRoom != null);

            // Update a few properties of the room instantaneously.
            Room.Settings          = settings;
            APIRoom.Name.Value     = Room.Settings.Name;
            APIRoom.Password.Value = Room.Settings.Password;

            // The current item update is delayed until an online beatmap lookup (below) succeeds.
            // In-order for the client to not display an outdated beatmap, the current item is forcefully cleared here.
            CurrentMatchPlayingItem.Value = null;

            RoomUpdated?.Invoke();

            GetOnlineBeatmapSet(settings.BeatmapID, cancellationToken).ContinueWith(task => Schedule(() =>
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    return;
                }

                APIBeatmapSet beatmapSet = task.Result;

                // The incoming response is deserialised without circular reference handling currently.
                // Because we require using metadata from this instance, populate the nested beatmaps' sets manually here.
                foreach (var b in beatmapSet.Beatmaps)
                {
                    b.BeatmapSet = beatmapSet;
                }

                updatePlaylist(settings, beatmapSet);
            }), TaskContinuationOptions.OnlyOnRanToCompletion);
        }, cancellationToken);
Beispiel #18
0
        private void load()
        {
            foreach (string filename in downloadableFilenames)
            {
                var match = Regex.Match(filename, @"([0-9]*) (.*) - (.*)\.osz");

                var beatmapSet = new APIBeatmapSet
                {
                    OnlineID = int.Parse(match.Groups[1].Value),
                    Artist   = match.Groups[2].Value,
                    Title    = match.Groups[3].Value,
                };

                var beatmapDownloadTracker = new BeatmapDownloadTracker(beatmapSet);
                downloadTrackers.Add(beatmapDownloadTracker);
                AddInternal(beatmapDownloadTracker);

                // Note that this is downloading the beatmaps even if they are already downloaded.
                // We could rely more on `BeatmapDownloadTracker`'s exposed state to avoid this.
                beatmapDownloader.Download(beatmapSet);
            }
        }
Beispiel #19
0
 public BeatmapCardNormal(APIBeatmapSet beatmapSet, bool allowExpansion = true)
     : base(beatmapSet, allowExpansion)
 {
     content = new BeatmapCardContent(height);
 }
Beispiel #20
0
 public GridBeatmapPanel(APIBeatmapSet beatmap)
     : base(beatmap)
 {
     Width  = 380;
     Height = 140 + vertical_padding; // full height of all the elements plus vertical padding (autosize uses the image)
 }
Beispiel #21
0
 protected DashboardBeatmapPanel(APIBeatmapSet beatmapSet)
 {
     BeatmapSet = beatmapSet;
 }
Beispiel #22
0
 /// <summary>
 /// Show an already fully-populated beatmap set.
 /// </summary>
 /// <param name="set">The set to show.</param>
 public void ShowBeatmapSet(APIBeatmapSet set)
 {
     beatmapSet.Value = set;
     Show();
 }
Beispiel #23
0
 public ListBeatmapPanel(APIBeatmapSet beatmap)
     : base(beatmap)
 {
     RelativeSizeAxes = Axes.X;
     Height           = height;
 }
Beispiel #24
0
 protected abstract DashboardBeatmapPanel CreateBeatmapPanel(APIBeatmapSet beatmapSet);
        private void load(OsuColour colours)
        {
            var beatmapSet = new APIBeatmapSet
            {
                Beatmaps = new[]
                {
                    new APIBeatmap {
                        RulesetID = 1, StarRating = 5.76, DifficultyName = "Oni"
                    },
                    new APIBeatmap {
                        RulesetID = 1, StarRating = 3.20, DifficultyName = "Muzukashii"
                    },
                    new APIBeatmap {
                        RulesetID = 1, StarRating = 2.45, DifficultyName = "Futsuu"
                    },

                    new APIBeatmap {
                        RulesetID = 0, StarRating = 2.04, DifficultyName = "Normal"
                    },
                    new APIBeatmap {
                        RulesetID = 0, StarRating = 3.51, DifficultyName = "Hard"
                    },
                    new APIBeatmap {
                        RulesetID = 0, StarRating = 5.25, DifficultyName = "Insane"
                    },

                    new APIBeatmap {
                        RulesetID = 2, StarRating = 2.64, DifficultyName = "Salad"
                    },
                    new APIBeatmap {
                        RulesetID = 2, StarRating = 3.56, DifficultyName = "Platter"
                    },
                    new APIBeatmap {
                        RulesetID = 2, StarRating = 4.65, DifficultyName = "Rain"
                    },

                    new APIBeatmap {
                        RulesetID = 3, StarRating = 1.93, DifficultyName = "[7K] Normal"
                    },
                    new APIBeatmap {
                        RulesetID = 3, StarRating = 3.18, DifficultyName = "[7K] Hyper"
                    },
                    new APIBeatmap {
                        RulesetID = 3, StarRating = 4.82, DifficultyName = "[7K] Another"
                    },

                    new APIBeatmap {
                        RulesetID = 4, StarRating = 9.99, DifficultyName = "Unknown?!"
                    },
                }
            };

            Child = new Container
            {
                Width        = 300,
                AutoSizeAxes = Axes.Y,
                Anchor       = Anchor.Centre,
                Origin       = Anchor.Centre,
                Children     = new Drawable[]
                {
                    new Box
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour           = colourProvider.Background2
                    },
                    new Container
                    {
                        RelativeSizeAxes = Axes.X,
                        AutoSizeAxes     = Axes.Y,
                        Padding          = new MarginPadding(10),
                        Child            = new BeatmapCardDifficultyList(beatmapSet)
                    }
                }
            };
        }
Beispiel #26
0
 public DownloadButton(APIBeatmapSet beatmapSet)
 {
     Icon.Icon = FontAwesome.Solid.FileDownload;
 }
Beispiel #27
0
 public DashboardPopularBeatmapPanel(APIBeatmapSet beatmapSet)
     : base(beatmapSet)
 {
 }
Beispiel #28
0
 public DashboardNewBeatmapPanel(APIBeatmapSet beatmapSet)
     : base(beatmapSet)
 {
 }
 protected override DashboardBeatmapPanel CreateBeatmapPanel(APIBeatmapSet beatmapSet) => new DashboardNewBeatmapPanel(beatmapSet);
Beispiel #30
0
        public DownloadButton(APIBeatmapSet beatmapSet)
        {
            Icon.Icon = FontAwesome.Solid.Download;

            this.beatmapSet = beatmapSet;
        }