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

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

            Icon.Icon   = FontAwesome.Solid.AngleDoubleRight;
            TooltipText = "Go to beatmap";
        }
示例#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);
        }
示例#4
0
        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)
                    }
                }
            };
        }
示例#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);
            });
示例#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);
 }
示例#7
0
        public HeaderDownloadButton(APIBeatmapSet beatmapSet, bool noVideo = false)
        {
            this.beatmapSet = beatmapSet;
            this.noVideo    = noVideo;

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

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

            this.beatmapSet = beatmapSet;
        }
示例#9
0
文件: BeatmapCard.cs 项目: Wieku/osu
        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);
        }
示例#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);
        }
示例#11
0
文件: BeatmapCard.cs 项目: Wieku/osu
        /// <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");
            }
        }
示例#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);
        }
示例#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);
            }
        }
示例#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));
        }
示例#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);
            }
        }
示例#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));
        }
示例#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);
示例#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);
            }
        }
示例#19
0
 public BeatmapCardNormal(APIBeatmapSet beatmapSet, bool allowExpansion = true)
     : base(beatmapSet, allowExpansion)
 {
     content = new BeatmapCardContent(height);
 }
示例#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)
 }
示例#21
0
 protected DashboardBeatmapPanel(APIBeatmapSet beatmapSet)
 {
     BeatmapSet = beatmapSet;
 }
示例#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();
 }
示例#23
0
 public ListBeatmapPanel(APIBeatmapSet beatmap)
     : base(beatmap)
 {
     RelativeSizeAxes = Axes.X;
     Height           = height;
 }
示例#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)
                    }
                }
            };
        }
示例#26
0
 public DownloadButton(APIBeatmapSet beatmapSet)
 {
     Icon.Icon = FontAwesome.Solid.FileDownload;
 }
示例#27
0
 public DashboardPopularBeatmapPanel(APIBeatmapSet beatmapSet)
     : base(beatmapSet)
 {
 }
示例#28
0
 public DashboardNewBeatmapPanel(APIBeatmapSet beatmapSet)
     : base(beatmapSet)
 {
 }
示例#29
0
 protected override DashboardBeatmapPanel CreateBeatmapPanel(APIBeatmapSet beatmapSet) => new DashboardNewBeatmapPanel(beatmapSet);
示例#30
0
        public DownloadButton(APIBeatmapSet beatmapSet)
        {
            Icon.Icon = FontAwesome.Solid.Download;

            this.beatmapSet = beatmapSet;
        }