Exemplo n.º 1
0
        public override void Reset()
        {
            base.Reset();

            //ensure we are at offset 0
            Clock = new FramedClock();

            if (beatmap == null)
            {

                var objects = new List<HitObject>();

                int time = 1500;
                for (int i = 0; i < 50; i++)
                {
                    objects.Add(new HitCircle()
                    {
                        StartTime = time,
                        Position = new Vector2(i % 4 == 0 || i % 4 == 2 ? 0 : 512,
                        i % 4 < 2 ? 0 : 384),
                        NewCombo = i % 4 == 0
                    });

                    time += 500;
                }

                var decoder = new ConstructableBeatmapDecoder();

                Beatmap b = new Beatmap
                {
                    HitObjects = objects
                };

                decoder.Process(b);

                beatmap = new WorkingBeatmap(b);
            }

            Add(new Box
            {
                RelativeSizeAxes = Framework.Graphics.Axes.Both,
                Colour = Color4.Gray,
            });

            Add(new Player
            {
                PreferredPlayMode = PlayMode.Osu,
                Beatmap = beatmap
            });
        }
Exemplo n.º 2
0
 private void play(BeatmapInfo info, bool isNext)
 {
     current = beatmaps.GetWorkingBeatmap(info, current);
     Task.Run(() =>
     {
         trackManager.SetExclusive(current.Track);
         current.Track.Start();
         beatmapSource.Value = current;
     });
     updateDisplay(current, isNext ? TransformDirection.Next : TransformDirection.Prev);
 }
Exemplo n.º 3
0
 private void workingChanged(object sender = null, EventArgs e = null)
 {
     progress.IsEnabled = (beatmapSource.Value != null);
     if (beatmapSource.Value == current) return;
     bool audioEquals = current?.BeatmapInfo.AudioEquals(beatmapSource.Value.BeatmapInfo) ?? false;
     current = beatmapSource.Value;
     updateDisplay(current, audioEquals ? TransformDirection.None : TransformDirection.Next);
     appendToHistory(current.BeatmapInfo);
 }
Exemplo n.º 4
0
        private void addBeatmapSet(BeatmapSetInfo beatmapSet, BaseGame game)
        {
            beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.ID);
            beatmapSet.Beatmaps.ForEach(b =>
            {
                database.GetChildren(b);
                if (b.Metadata == null) b.Metadata = beatmapSet.Metadata;
            });

            beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty).ToList();

            var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database);

            var group = new BeatmapGroup(beatmap)
            {
                SelectionChanged = selectionChanged,
                StartRequested = b => start()
            };

            //for the time being, let's completely load the difficulty panels in the background.
            //this likely won't scale so well, but allows us to completely async the loading flow.
            Task.WhenAll(group.BeatmapPanels.Select(panel => panel.Preload(game))).ContinueWith(task => Schedule(delegate
            {
                carousel.AddGroup(group);

                if (Beatmap == null)
                    carousel.SelectBeatmap(beatmapSet.Beatmaps.First());
                else
                {
                    var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(Beatmap.BeatmapInfo));
                    if (panel != null)
                        carousel.SelectGroup(group, panel);
                }
            }));
        }
Exemplo n.º 5
0
        /// <summary>
        /// The global Beatmap was changed.
        /// </summary>
        protected override void OnBeatmapChanged(WorkingBeatmap beatmap)
        {
            base.OnBeatmapChanged(beatmap);

            //todo: change background in selectionChanged instead; support per-difficulty backgrounds.
            changeBackground(beatmap);

            selectBeatmap(beatmap.BeatmapInfo);
        }
Exemplo n.º 6
0
        private void changeBackground(WorkingBeatmap beatmap)
        {
            if (beatmap == null)
                return;

            var backgroundModeBeatmap = Background as BackgroundModeBeatmap;
            if (backgroundModeBeatmap != null)
            {
                backgroundModeBeatmap.Beatmap = beatmap;
                // TODO: Remove this once we have non-nullable Beatmap
                (Background as BackgroundModeBeatmap)?.BlurTo(BACKGROUND_BLUR, 1000);
            }

            beatmapInfoWedge.UpdateBeatmap(beatmap);
        }
Exemplo n.º 7
0
 protected virtual WorkingBeatmapCache CreateWorkingBeatmapCache(AudioManager audioManager, IResourceStore <byte[]> resources, IResourceStore <byte[]> storage, WorkingBeatmap defaultBeatmap, GameHost host)
 {
     return(new WorkingBeatmapCache(BeatmapTrackStore, audioManager, resources, storage, defaultBeatmap, host));
 }
Exemplo n.º 8
0
        public void UpdateBeatmap(WorkingBeatmap beatmap)
        {
            if (beatmap == null)
                return;

            var lastContainer = beatmapInfoContainer;

            float newDepth = lastContainer?.Depth + 1 ?? 0;

            BeatmapSetInfo beatmapSetInfo = beatmap.BeatmapSetInfo;
            BeatmapInfo beatmapInfo = beatmap.BeatmapInfo;

            (beatmapInfoContainer = new BufferedContainer
            {
                Depth = newDepth,
                PixelSnapping = true,
                CacheDrawnFrameBuffer = true,
                Shear = -Shear,
                RelativeSizeAxes = Axes.Both,
                Children = new Drawable[]
                {
                    // We will create the white-to-black gradient by modulating transparency and having
                    // a black backdrop. This results in an sRGB-space gradient and not linear space,
                    // transitioning from white to black more perceptually uniformly.
                    new Box
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour = Color4.Black,
                    },
                    // We use a container, such that we can set the colour gradient to go across the
                    // vertices of the masked container instead of the vertices of the (larger) sprite.
                    new Container
                    {
                        RelativeSizeAxes = Axes.Both,
                        ColourInfo = ColourInfo.GradientVertical(Color4.White, Color4.White.Opacity(0.3f)),
                        Children = new []
                        {
                            // Zoomed-in and cropped beatmap background
                            new BeatmapBackgroundSprite(beatmap)
                            {
                                Anchor = Anchor.Centre,
                                Origin = Anchor.Centre,
                                FillMode = FillMode.Fill,
                            },
                        },
                    },
                    // Text for beatmap info
                    new FlowContainer
                    {
                        Anchor = Anchor.BottomLeft,
                        Origin = Anchor.BottomLeft,
                        Direction = FlowDirection.VerticalOnly,
                        Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 40 },
                        AutoSizeAxes = Axes.Both,
                        Children = new[]
                        {
                            new SpriteText
                            {
                                Font = @"Exo2.0-MediumItalic",
                                Text = beatmapSetInfo.Metadata.Artist + " -- " + beatmapSetInfo.Metadata.Title,
                                TextSize = 28,
                                Shadow = true,
                            },
                            new SpriteText
                            {
                                Font = @"Exo2.0-MediumItalic",
                                Text = beatmapInfo.Version,
                                TextSize = 17,
                                Shadow = true,
                            },
                            new FlowContainer
                            {
                                Margin = new MarginPadding { Top = 10 },
                                Direction = FlowDirection.HorizontalOnly,
                                AutoSizeAxes = Axes.Both,
                                Children = new []
                                {
                                    new SpriteText
                                    {
                                        Font = @"Exo2.0-Medium",
                                        Text = "mapped by ",
                                        TextSize = 15,
                                        Shadow = true,
                                    },
                                    new SpriteText
                                    {
                                        Font = @"Exo2.0-Bold",
                                        Text = beatmapSetInfo.Metadata.Author,
                                        TextSize = 15,
                                        Shadow = true,
                                    },
                                }
                            }
                        }
                    }
                }
            }).Preload(game, delegate(Drawable d)
            {
                FadeIn(250);

                lastContainer?.FadeOut(250);
                lastContainer?.Expire();

                Add(d);
            });
        }
Exemplo n.º 9
0
 public BeatmapBackground(WorkingBeatmap beatmap)
 {
     this.beatmap = beatmap;
     CacheDrawnFrameBuffer = true;
 }
Exemplo n.º 10
0
 public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => null;
Exemplo n.º 11
0
 public void TransferTo(WorkingBeatmap working)
 {
     if (track != null && BeatmapInfo.AudioEquals(working.BeatmapInfo))
         working.track = track;
 }
Exemplo n.º 12
0
 public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 13
0
 protected virtual WorkingBeatmapCache CreateWorkingBeatmapCache(AudioManager audioManager, IResourceStore <byte[]> resources, IResourceStore <byte[]> storage, WorkingBeatmap defaultBeatmap, GameHost host) =>
 new WorkingBeatmapCache(audioManager, resources, storage, defaultBeatmap, host);
Exemplo n.º 14
0
 public Task <List <TimedDifficultyAttributes> > GetTimedDifficultyAttributesAsync(WorkingBeatmap beatmap, Ruleset ruleset, Mod[] mods, CancellationToken token = default)
 {
     return(Task.Factory.StartNew(() => ruleset.CreateDifficultyCalculator(beatmap).CalculateTimed(mods),
                                  token,
                                  TaskCreationOptions.HideScheduler | TaskCreationOptions.RunContinuationsAsynchronously,
                                  updateScheduler));
 }
Exemplo n.º 15
0
        private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
        {
            Task.Run(() =>
            {
                if (beatmap?.Beatmap == null)
                    //todo: we may need to display some default text here (currently in the constructor).
                    return;

                BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
                title.Text = config.GetUnicodeString(metadata.Title, metadata.TitleUnicode);
                artist.Text = config.GetUnicodeString(metadata.Artist, metadata.ArtistUnicode);
            });

            MusicControllerBackground newBackground;

            (newBackground = new MusicControllerBackground(beatmap)).Preload(game, delegate
            {

                Add(newBackground);

                switch (direction)
                {
                    case TransformDirection.Next:
                        newBackground.Position = new Vector2(400, 0);
                        newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
                        backgroundSprite.MoveToX(-400, 500, EasingTypes.OutCubic);
                        break;
                    case TransformDirection.Prev:
                        newBackground.Position = new Vector2(-400, 0);
                        newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
                        backgroundSprite.MoveToX(400, 500, EasingTypes.OutCubic);
                        break;
                }

                backgroundSprite.Expire();
                backgroundSprite = newBackground;
            });
        }
Exemplo n.º 16
0
 public BackgroundModeBeatmap(WorkingBeatmap beatmap)
 {
     Beatmap = beatmap;
 }
Exemplo n.º 17
0
            public MusicControllerBackground(WorkingBeatmap beatmap = null)
            {
                this.beatmap = beatmap;
                CacheDrawnFrameBuffer = true;
                RelativeSizeAxes = Axes.Both;
                Depth = float.MaxValue;

                Children = new Drawable[]
                {
                    sprite = new Sprite
                    {
                        Colour = OsuColour.Gray(150),
                        FillMode = FillMode.Fill,
                    },
                    new Box
                    {
                        RelativeSizeAxes = Axes.X,
                        Height = 50,
                        Origin = Anchor.BottomCentre,
                        Anchor = Anchor.BottomCentre,
                        Colour = Color4.Black.Opacity(0.5f)
                    }
                };
            }
Exemplo n.º 18
0
        protected virtual void OnBeatmapChanged(WorkingBeatmap beatmap)
        {

        }
Exemplo n.º 19
0
 private void load(BeatmapDatabase db)
 {
     beatmap = db.GetWorkingBeatmap(db.Query<BeatmapInfo>().Where(b => b.Mode == PlayMode.Osu).FirstOrDefault());
 }
Exemplo n.º 20
0
        public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore <byte[]> gameResources, GameHost host = null, WorkingBeatmap defaultBeatmap = null, bool performOnlineLookups = false, AudioMixer mainTrackMixer = null)
        {
            var userResources = new FileStore(contextFactory, storage).Store;

            BeatmapTrackStore = audioManager.GetTrackStore(userResources);

            beatmapModelManager    = CreateBeatmapModelManager(storage, contextFactory, rulesets, api, host);
            beatmapModelDownloader = CreateBeatmapModelDownloader(beatmapModelManager, api, host);
            workingBeatmapCache    = CreateWorkingBeatmapCache(audioManager, gameResources, userResources, defaultBeatmap, host);

            workingBeatmapCache.BeatmapManager      = beatmapModelManager;
            beatmapModelManager.WorkingBeatmapCache = workingBeatmapCache;

            if (performOnlineLookups)
            {
                onlineBeatmapLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
                beatmapModelManager.OnlineLookupQueue = onlineBeatmapLookupQueue;
            }
        }