Exemple #1
0
        private void ensureLoaded(OsuGameBase osu, int timeout = 100)
        {
            IEnumerable<BeatmapSetInfo> resultSets = null;

            Action waitAction = () =>
            {
                while ((resultSets = osu.Dependencies.Get<BeatmapDatabase>()
                    .Query<BeatmapSetInfo>().Where(s => s.OnlineBeatmapSetID == 241526)).Count() != 1)
                    Thread.Sleep(1);
            };

            Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout),
                @"BeatmapSet did not import to the database");

            //ensure we were stored to beatmap database backing...

            Assert.IsTrue(resultSets.Count() == 1);

            IEnumerable<BeatmapInfo> resultBeatmaps = null;

            //if we don't re-check here, the set will be inserted but the beatmaps won't be present yet.
            waitAction = () =>
            {
                while ((resultBeatmaps = osu.Dependencies.Get<BeatmapDatabase>()
                    .Query<BeatmapInfo>().Where(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12)
                    Thread.Sleep(1);
            };

            Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout),
                @"Beatmaps did not import to the database");

            //fetch children and check we can load from the post-storage path...
            var set = osu.Dependencies.Get<BeatmapDatabase>().GetChildren(resultSets.First());

            Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count());

            foreach (BeatmapInfo b in resultBeatmaps)
                Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineBeatmapID == b.OnlineBeatmapID));

            Assert.IsTrue(set.Beatmaps.Count > 0);

            var beatmap = osu.Dependencies.Get<BeatmapDatabase>().GetBeatmap(set.Beatmaps.First(b => b.Mode == PlayMode.Osu));

            Assert.IsTrue(beatmap.HitObjects.Count > 0);
        }
Exemple #2
0
 public DummyWorkingBeatmap(OsuGameBase game = null)
     : base(new BeatmapInfo
 {
     Metadata = new BeatmapMetadata
     {
         Artist = "please load a beatmap!",
         Title  = "no beatmaps available!"
     },
     BeatmapSet     = new BeatmapSetInfo(),
     BaseDifficulty = new BeatmapDifficulty
     {
         DrainRate         = 0,
         CircleSize        = 0,
         OverallDifficulty = 0,
     },
     Ruleset = new DummyRulesetInfo()
 })
 {
     this.game = game;
 }
Exemple #3
0
        private void load(OsuGameBase game, OsuGame osuGame, AudioManager audio)
        {
            if (game != null)
            {
                //if we were given a beatmap at ctor time, we want to pass this on to the game-wide beatmap.
                var localMap = beatmap.Value;
                beatmap.BindTo(game.Beatmap);
                if (localMap != null)
                {
                    beatmap.Value = localMap;
                }
            }

            if (osuGame != null)
            {
                ruleset.BindTo(osuGame.Ruleset);
            }

            sampleExit = audio.Sample.Get(@"UI/melodic-1");
        }
Exemple #4
0
        private void load(OsuGameBase game, OsuGame osuGame)
        {
            if (game != null)
            {
                //if we were given a beatmap at ctor time, we want to pass this on to the game-wide beatmap.
                var localMap = beatmap.Value;
                beatmap.BindTo(game.Beatmap);
                if (localMap != null)
                {
                    beatmap.Value = localMap;
                }
            }

            beatmap.ValueChanged += OnBeatmapChanged;

            if (osuGame != null)
            {
                ruleset.BindTo(osuGame.Ruleset);
            }
        }
Exemple #5
0
        private static void ensureLoaded(OsuGameBase osu, int timeout = 60000)
        {
            var realm = osu.Dependencies.Get <RealmAccess>();

            realm.Run(r => BeatmapImporterTests.EnsureLoaded(r, timeout));

            // TODO: add back some extra checks outside of the realm ones?
            // var set = queryBeatmapSets().First();
            // foreach (BeatmapInfo b in set.Beatmaps)
            //     Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineID == b.OnlineID));
            // Assert.IsTrue(set.Beatmaps.Count > 0);
            // var beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 0))?.Beatmap;
            // Assert.IsTrue(beatmap?.HitObjects.Any() == true);
            // beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 1))?.Beatmap;
            // Assert.IsTrue(beatmap?.HitObjects.Any() == true);
            // beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 2))?.Beatmap;
            // Assert.IsTrue(beatmap?.HitObjects.Any() == true);
            // beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 3))?.Beatmap;
            // Assert.IsTrue(beatmap?.HitObjects.Any() == true);
        }
        private void load(OsuGameBase game)
        {
            Beatmap.Value = new DummyWorkingBeatmap(game);

            InputManager.Add(stack = new ScreenStack {
                RelativeSizeAxes = Axes.Both
            });

            AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => new Player
            {
                AllowPause   = false,
                AllowLeadIn  = false,
                AllowResults = false,
            })));

            AddUntilStep(() => loader.IsCurrentScreen(), "wait for current");

            AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));

            AddUntilStep(() => !loader.IsCurrentScreen(), "wait for no longer current");

            AddStep("exit loader", () => loader.Exit());

            AddUntilStep(() => !loader.IsAlive, "wait for no longer alive");

            AddStep("load slow dummy beatmap", () =>
            {
                SlowLoadPlayer slow = null;

                stack.Push(loader = new PlayerLoader(() => slow = new SlowLoadPlayer
                {
                    AllowPause   = false,
                    AllowLeadIn  = false,
                    AllowResults = false,
                }));

                Scheduler.AddDelayed(() => slow.Ready = true, 5000);
            });

            AddUntilStep(() => !loader.IsCurrentScreen(), "wait for no longer current");
        }
Exemple #7
0
        private void load(OsuGameBase game, OsuGame osuGame, AudioManager audio)
        {
            if (game != null)
            {
                //if we were given a beatmap at ctor time, we want to pass this on to the game-wide beatmap.
                var localMap = Beatmap.Value;
                Beatmap.BindTo(game.Beatmap);
                if (localMap != null)
                {
                    Beatmap.Value = localMap;
                }
            }

            if (osuGame != null)
            {
                Ruleset.BindTo(osuGame.Ruleset);
                ShowOverlays.BindTo(osuGame.ShowOverlays);
            }

            sampleExit = audio.Sample.Get(@"UI/screen-back");
        }
Exemple #8
0
        private static void ensureLoaded(OsuGameBase osu, int timeout = 60000)
        {
            IEnumerable<BeatmapSetInfo> resultSets = null;
            var store = osu.Dependencies.Get<BeatmapManager>();
            waitForOrAssert(() => (resultSets = store.QueryBeatmapSets(s => s.OnlineBeatmapSetID == 241526)).Any(),
                @"BeatmapSet did not import to the database in allocated time.", timeout);

            //ensure we were stored to beatmap database backing...
            Assert.IsTrue(resultSets.Count() == 1, $@"Incorrect result count found ({resultSets.Count()} but should be 1).");
            IEnumerable<BeatmapInfo> queryBeatmaps() => store.QueryBeatmaps(s => s.BeatmapSet.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0);
            IEnumerable<BeatmapSetInfo> queryBeatmapSets() => store.QueryBeatmapSets(s => s.OnlineBeatmapSetID == 241526);

            //if we don't re-check here, the set will be inserted but the beatmaps won't be present yet.
            waitForOrAssert(() => queryBeatmaps().Count() == 12,
                @"Beatmaps did not import to the database in allocated time", timeout);
            waitForOrAssert(() => queryBeatmapSets().Count() == 1,
                @"BeatmapSet did not import to the database in allocated time", timeout);
            int countBeatmapSetBeatmaps = 0;
            int countBeatmaps = 0;
            waitForOrAssert(() =>
                    (countBeatmapSetBeatmaps = queryBeatmapSets().First().Beatmaps.Count) ==
                    (countBeatmaps = queryBeatmaps().Count()),
                $@"Incorrect database beatmap count post-import ({countBeatmaps} but should be {countBeatmapSetBeatmaps}).", timeout);

            var set = queryBeatmapSets().First();
            foreach (BeatmapInfo b in set.Beatmaps)
                Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineBeatmapID == b.OnlineBeatmapID));
            Assert.IsTrue(set.Beatmaps.Count > 0);
            var beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 0))?.Beatmap;
            Assert.IsTrue(beatmap?.HitObjects.Any() == true);
            beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 1))?.Beatmap;
            Assert.IsTrue(beatmap?.HitObjects.Any() == true);
            beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 2))?.Beatmap;
            Assert.IsTrue(beatmap?.HitObjects.Any() == true);
            beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 3))?.Beatmap;
            Assert.IsTrue(beatmap?.HitObjects.Any() == true);
        }
        private void load(OsuGameBase osuGame)
        {
            osuGame.Beatmap.Value = new TestWorkingBeatmap(new Beatmap
            {
                HitObjects = new List <HitObject>
                {
                    new HitCircle {
                        Position = new Vector2(256, 192), Scale = 0.5f
                    },
                    new HitCircle {
                        Position = new Vector2(344, 148), Scale = 0.5f
                    },
                    new Slider
                    {
                        Position      = new Vector2(128, 256),
                        ControlPoints = new List <Vector2>
                        {
                            Vector2.Zero,
                            new Vector2(216, 0),
                        },
                        Distance     = 400,
                        Velocity     = 1,
                        TickDistance = 100,
                        Scale        = 0.5f,
                    }
                },
            });

            var clock = new DecoupleableInterpolatingFramedClock {
                IsCoupled = false
            };

            dependencies.CacheAs <IAdjustableClock>(clock);
            dependencies.CacheAs <IFrameBasedClock>(clock);

            Child = new OsuHitObjectComposer(new OsuRuleset());
        }
Exemple #10
0
 public DummyWorkingBeatmap(OsuGameBase game)
     : base(new BeatmapInfo
 {
     Metadata = new BeatmapMetadata
     {
         Artist       = "please load a beatmap!",
         Title        = "no beatmaps available!",
         AuthorString = "no one",
     },
     BeatmapSet     = new BeatmapSetInfo(),
     BaseDifficulty = new BeatmapDifficulty
     {
         DrainRate         = 0,
         CircleSize        = 0,
         OverallDifficulty = 0,
         ApproachRate      = 0,
         SliderMultiplier  = 0,
         SliderTickRate    = 0,
     },
     Ruleset = new DummyRulesetInfo()
 })
 {
     this.game = game;
 }
        private void load(OsuGameBase osuGame, IFrameBasedClock framedClock)
        {
            beatmap.BindTo(osuGame.Beatmap);

            try
            {
                rulesetContainer       = CreateRulesetContainer(ruleset, beatmap.Value);
                rulesetContainer.Clock = framedClock;
            }
            catch (Exception e)
            {
                Logger.Error(e, "Could not load beatmap sucessfully!");
                return;
            }

            var layerBelowRuleset = new BorderLayer
            {
                RelativeSizeAxes = Axes.Both,
                Child            = CreateLayerContainer()
            };

            var layerAboveRuleset = CreateLayerContainer();

            layerAboveRuleset.Child = new HitObjectMaskLayer(rulesetContainer.Playfield, this);

            layerContainers.Add(layerBelowRuleset);
            layerContainers.Add(layerAboveRuleset);

            RadioButtonCollection toolboxCollection;

            InternalChild = new GridContainer
            {
                RelativeSizeAxes = Axes.Both,
                Content          = new[]
                {
                    new Drawable[]
                    {
                        new FillFlowContainer
                        {
                            Name             = "Sidebar",
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Right = 10
                            },
                            Children = new Drawable[]
                            {
                                new ToolboxGroup {
                                    Child = toolboxCollection = new RadioButtonCollection {
                                        RelativeSizeAxes = Axes.X
                                    }
                                }
                            }
                        },
                        new Container
                        {
                            Name             = "Content",
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                layerBelowRuleset,
                                rulesetContainer,
                                layerAboveRuleset
                            }
                        }
                    },
                },
                ColumnDimensions = new[]
                {
                    new Dimension(GridSizeMode.Absolute, 200),
                }
            };

            toolboxCollection.Items =
                CompositionTools.Select(t => new RadioButton(t.Name, () => setCompositionTool(t)))
                .Prepend(new RadioButton("Select", () => setCompositionTool(null)))
                .ToList();

            toolboxCollection.Items[0].Select();
        }
Exemple #12
0
        private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game)
        {
            dimLevel = game.Config.GetBindable<int>(OsuConfig.DimLevel);
            try
            {
                if (Beatmap == null)
                    Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo);
            }
            catch
            {
                //couldn't load, hard abort!
                Exit();
                return;
            }

            AudioTrack track = Beatmap.Track;

            if (track != null)
            {
                audio.Track.SetExclusive(track);
                sourceClock = track;
            }

            sourceClock = (IAdjustableClock)track ?? new StopwatchClock();

            Schedule(() =>
            {
                sourceClock.Reset();
            });

            var beatmap = Beatmap.Beatmap;

            if (beatmap.BeatmapInfo?.Mode > PlayMode.Osu)
            {
                //we only support osu! mode for now because the hitobject parsing is crappy and needs a refactor.
                Exit();
                return;
            }

            PlayMode usablePlayMode = beatmap.BeatmapInfo?.Mode > PlayMode.Osu ? beatmap.BeatmapInfo.Mode : PreferredPlayMode;

            ruleset = Ruleset.GetRuleset(usablePlayMode);

            var scoreOverlay = ruleset.CreateScoreOverlay();
            scoreOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor());

            hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects);

            hitRenderer.OnJudgement += scoreProcessor.AddJudgement;
            hitRenderer.OnAllJudged += hitRenderer_OnAllJudged;

            if (Autoplay)
                hitRenderer.Schedule(() => hitRenderer.DrawableObjects.ForEach(h => h.State = ArmedState.Hit));

            Children = new Drawable[]
            {
                new PlayerInputManager(game.Host)
                {
                    Clock = new InterpolatingFramedClock(sourceClock),
                    PassThrough = false,
                    Children = new Drawable[]
                    {
                        hitRenderer,
                    }
                },
                scoreOverlay,
            };
        }
 private void load(IAPIProvider api, OsuGameBase game)
 {
     ((DummyAPIAccess)api).HandleRequest = request => handler.HandleRequest(request, api.LocalUser.Value, game);
 }
Exemple #14
0
        private async Task <SkinInfo> loadSkinIntoOsu(OsuGameBase osu, ArchiveReader archive = null)
        {
            var skinManager = osu.Dependencies.Get <SkinManager>();

            return(await skinManager.Import(archive));
        }
Exemple #15
0
 private void load(OsuGameBase game)
 {
     if (beatmap == null)
         beatmap = game?.Beatmap;
 }
 private void load(OsuGameBase osuGame)
 {
     timeline.Beatmap.BindTo(osuGame.Beatmap);
 }
Exemple #17
0
        private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config)
        {
            notificationOverlay = notification;
            this.config         = config;
            this.game           = game;

            AutoSizeAxes = Axes.Both;
            Anchor       = Anchor.BottomCentre;
            Origin       = Anchor.BottomCentre;

            Alpha = 0;

            Children = new Drawable[]
            {
                new FillFlowContainer
                {
                    AutoSizeAxes = Axes.Both,
                    Direction    = FillDirection.Vertical,
                    Children     = new Drawable[]
                    {
                        new FillFlowContainer
                        {
                            AutoSizeAxes = Axes.Both,
                            Direction    = FillDirection.Horizontal,
                            Spacing      = new Vector2(5),
                            Anchor       = Anchor.TopCentre,
                            Origin       = Anchor.TopCentre,
                            Children     = new Drawable[]
                            {
                                new OsuSpriteText
                                {
                                    Font = OsuFont.GetFont(weight: FontWeight.Bold),
                                    Text = game.Name
                                },
                                new OsuSpriteText
                                {
                                    Colour = DebugUtils.IsDebug ? colours.Red : Color4.White,
                                    Text   = game.Version
                                },
                            }
                        },
                        new OsuSpriteText
                        {
                            Anchor = Anchor.TopCentre,
                            Origin = Anchor.TopCentre,
                            Font   = OsuFont.Numeric.With(size: 12),
                            Colour = colours.Yellow,
                            Text   = @"Development Build"
                        },
                        new Sprite
                        {
                            Anchor  = Anchor.TopCentre,
                            Origin  = Anchor.TopCentre,
                            Texture = textures.Get(@"Menu/dev-build-footer"),
                        },
                    }
                }
            };
        }
Exemple #18
0
        private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, OsuGameBase game)
        {
            this.game = game;

            scalingMode      = osuConfig.GetBindable <ScalingMode>(OsuSetting.Scaling);
            sizeFullscreen   = config.GetBindable <Size>(FrameworkSetting.SizeFullscreen);
            scalingSizeX     = osuConfig.GetBindable <float>(OsuSetting.ScalingSizeX);
            scalingSizeY     = osuConfig.GetBindable <float>(OsuSetting.ScalingSizeY);
            scalingPositionX = osuConfig.GetBindable <float>(OsuSetting.ScalingPositionX);
            scalingPositionY = osuConfig.GetBindable <float>(OsuSetting.ScalingPositionY);

            Container resolutionSettingsContainer;

            Children = new Drawable[]
            {
                windowModeDropdown = new SettingsEnumDropdown <WindowMode>
                {
                    LabelText = "Screen mode",
                    Bindable  = config.GetBindable <WindowMode>(FrameworkSetting.WindowMode),
                },
                resolutionSettingsContainer = new Container
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y
                },
                new SettingsSlider <float, UIScaleSlider>
                {
                    LabelText             = "UI Scaling",
                    TransferValueOnCommit = true,
                    Bindable     = osuConfig.GetBindable <float>(OsuSetting.UIScale),
                    KeyboardStep = 0.01f
                },
                new SettingsEnumDropdown <ScalingMode>
                {
                    LabelText = "Screen Scaling",
                    Bindable  = osuConfig.GetBindable <ScalingMode>(OsuSetting.Scaling),
                },
                scalingSettings = new FillFlowContainer <SettingsSlider <float> >
                {
                    Direction        = FillDirection.Vertical,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    AutoSizeDuration = transition_duration,
                    AutoSizeEasing   = Easing.OutQuint,
                    Masking          = true,
                    Children         = new []
                    {
                        new SettingsSlider <float>
                        {
                            LabelText    = "Horizontal position",
                            Bindable     = scalingPositionX,
                            KeyboardStep = 0.01f
                        },
                        new SettingsSlider <float>
                        {
                            LabelText    = "Vertical position",
                            Bindable     = scalingPositionY,
                            KeyboardStep = 0.01f
                        },
                        new SettingsSlider <float>
                        {
                            LabelText    = "Horizontal scale",
                            Bindable     = scalingSizeX,
                            KeyboardStep = 0.01f
                        },
                        new SettingsSlider <float>
                        {
                            LabelText    = "Vertical scale",
                            Bindable     = scalingSizeY,
                            KeyboardStep = 0.01f
                        },
                    }
                },
            };

            scalingSettings.ForEach(s => bindPreviewEvent(s.Bindable));

            var resolutions = getResolutions();

            if (resolutions.Count > 1)
            {
                resolutionSettingsContainer.Child = resolutionDropdown = new ResolutionSettingsDropdown
                {
                    LabelText             = "Resolution",
                    ShowsDefaultIndicator = false,
                    Items    = resolutions,
                    Bindable = sizeFullscreen
                };

                windowModeDropdown.Bindable.BindValueChanged(windowMode =>
                {
                    if (windowMode == WindowMode.Fullscreen)
                    {
                        resolutionDropdown.Show();
                        sizeFullscreen.TriggerChange();
                    }
                    else
                    {
                        resolutionDropdown.Hide();
                    }
                }, true);
            }

            scalingMode.BindValueChanged(mode =>
            {
                scalingSettings.ClearTransforms();
                scalingSettings.AutoSizeAxes = mode != ScalingMode.Off ? Axes.Y : Axes.None;

                if (mode == ScalingMode.Off)
                {
                    scalingSettings.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
                }

                scalingSettings.ForEach(s => s.TransferValueOnCommit = mode == ScalingMode.Everything);
            }, true);
        }
Exemple #19
0
 private void load(OsuGameBase game)
 {
     Beatmap.BindTo(game.Beatmap);
 }
Exemple #20
0
 private void load(OsuGameBase osuGame)
 {
     osuGame.Beatmap.ValueChanged += beatmapChanged;
 }
Exemple #21
0
 private void load(OsuGameBase game, OsuConfigManager config)
 {
     showDisclaimer = game.IsDeployedBuild;
     introSequence  = config.Get <IntroSequence>(OsuSetting.IntroSequence);
 }
Exemple #22
0
        private OsuGameBase loadOsu(BasicGameHost host)
        {
            var osu = new OsuGameBase();
            host.Add(osu);

            while (!osu.IsLoaded)
                Thread.Sleep(1);

            //reset beatmap database (sqlite and storage backing)
            osu.Dependencies.Get<BeatmapDatabase>().Reset();

            return osu;
        }
Exemple #23
0
 private void load(OsuGameBase game)
 {
     Texture = working.Background;
 }
Exemple #24
0
 private void load(OsuGameBase game)
 {
     showDisclaimer = game.IsDeployedBuild;
 }
Exemple #25
0
 private void load(OsuGameBase game)
 {
     new BeatmapBackgroundSprite(working)
     {
         Anchor = Anchor.Centre,
         Origin = Anchor.Centre,
         FillMode = FillMode.Fill,
     }.Preload(game, (bg) =>
     {
         Add(bg);
         ForceRedraw();
     });
 }
Exemple #26
0
 private void load(OsuGameBase game)
 {
     this.game = game;
 }
Exemple #27
0
        private void load(OsuGameBase osuGame, BeatmapDatabase beatmaps, AudioManager audio,
            TextureStore textures, OsuColour colours)
        {
            Children = new Drawable[]
            {
                title = new SpriteText
                {
                    Origin = Anchor.BottomCentre,
                    Anchor = Anchor.TopCentre,
                    Position = new Vector2(0, 40),
                    TextSize = 25,
                    Colour = Color4.White,
                    Text = @"Nothing to play",
                    Font = @"Exo2.0-MediumItalic"
                },
                artist = new SpriteText
                {
                    Origin = Anchor.TopCentre,
                    Anchor = Anchor.TopCentre,
                    Position = new Vector2(0, 45),
                    TextSize = 15,
                    Colour = Color4.White,
                    Text = @"Nothing to play",
                    Font = @"Exo2.0-BoldItalic"
                },
                new ClickableContainer
                {
                    AutoSizeAxes = Axes.Both,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.BottomCentre,
                    Position = new Vector2(0, -30),
                    Action = () =>
                    {
                        if (current?.Track == null) return;
                        if (current.Track.IsRunning)
                            current.Track.Stop();
                        else
                            current.Track.Start();
                    },
                    Children = new Drawable[]
                    {
                        playButton = new TextAwesome
                        {
                            TextSize = 30,
                            Icon = FontAwesome.fa_play_circle_o,
                            Origin = Anchor.Centre,
                            Anchor = Anchor.Centre
                        }
                    }
                },
                new ClickableContainer
                {
                    AutoSizeAxes = Axes.Both,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.BottomCentre,
                    Position = new Vector2(-30, -30),
                    Action = prev,
                    Children = new Drawable[]
                    {
                        new TextAwesome
                        {
                            TextSize = 15,
                            Icon = FontAwesome.fa_step_backward,
                            Origin = Anchor.Centre,
                            Anchor = Anchor.Centre
                        }
                    }
                },
                new ClickableContainer
                {
                    AutoSizeAxes = Axes.Both,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.BottomCentre,
                    Position = new Vector2(30, -30),
                    Action = next,
                    Children = new Drawable[]
                    {
                        new TextAwesome
                        {
                            TextSize = 15,
                            Icon = FontAwesome.fa_step_forward,
                            Origin = Anchor.Centre,
                            Anchor = Anchor.Centre
                        }
                    }
                },
                new ClickableContainer
                {
                    AutoSizeAxes = Axes.Both,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.BottomRight,
                    Position = new Vector2(20, -30),
                    Children = new Drawable[]
                    {
                        listButton = new TextAwesome
                        {
                            TextSize = 15,
                            Icon = FontAwesome.fa_bars,
                            Origin = Anchor.Centre,
                            Anchor = Anchor.Centre
                        }
                    }
                },
                progress = new DragBar
                {
                    Origin = Anchor.BottomCentre,
                    Anchor = Anchor.BottomCentre,
                    Height = 10,
                    Colour = colours.Yellow,
                    SeekRequested = seek
                }
            };
        
            this.beatmaps = beatmaps;
            trackManager = osuGame.Audio.Track;
            config = osuGame.Config;
            preferUnicode = osuGame.Config.GetBindable<bool>(OsuConfig.ShowUnicode);
            preferUnicode.ValueChanged += preferUnicode_changed;

            beatmapSource = osuGame.Beatmap ?? new Bindable<WorkingBeatmap>();
            playList = beatmaps.GetAllWithChildren<BeatmapSetInfo>();

            backgroundSprite = new MusicControllerBackground();
            AddInternal(backgroundSprite);
        }
Exemple #28
0
        private void load(AudioManager audio, OsuConfigManager config, OsuGameBase game)
        {
            Mods.Value = base.Mods.Value.Select(m => m.DeepClone()).ToArray();

            if (Beatmap.Value is DummyWorkingBeatmap)
            {
                return;
            }

            IBeatmap playableBeatmap = loadPlayableBeatmap();

            if (playableBeatmap == null)
            {
                return;
            }

            sampleRestart = audio.Samples.Get(@"Gameplay/restart");

            mouseWheelDisabled = config.GetBindable <bool>(OsuSetting.MouseDisableWheel);

            if (game != null)
            {
                gameActive.BindTo(game.IsActive);
            }

            if (game is OsuGame osuGame)
            {
                LocalUserPlaying.BindTo(osuGame.LocalUserPlaying);
            }

            DrawableRuleset = GameplayRuleset.CreateDrawableRulesetWith(playableBeatmap, Mods.Value);
            dependencies.CacheAs(DrawableRuleset);

            ScoreProcessor = GameplayRuleset.CreateScoreProcessor();
            ScoreProcessor.ApplyBeatmap(playableBeatmap);
            ScoreProcessor.Mods.BindTo(Mods);

            dependencies.CacheAs(ScoreProcessor);

            HealthProcessor = GameplayRuleset.CreateHealthProcessor(playableBeatmap.HitObjects[0].StartTime);
            HealthProcessor.ApplyBeatmap(playableBeatmap);

            dependencies.CacheAs(HealthProcessor);

            if (!ScoreProcessor.Mode.Disabled)
            {
                config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);
            }

            InternalChild = GameplayClockContainer = CreateGameplayClockContainer(Beatmap.Value, DrawableRuleset.GameplayStartTime);

            AddInternal(GameplayBeatmap  = new GameplayBeatmap(playableBeatmap));
            AddInternal(screenSuspension = new ScreenSuspensionHandler(GameplayClockContainer));

            dependencies.CacheAs(GameplayBeatmap);

            var rulesetSkinProvider = new RulesetSkinProvidingContainer(GameplayRuleset, playableBeatmap, Beatmap.Value.Skin);

            // load the skinning hierarchy first.
            // this is intentionally done in two stages to ensure things are in a loaded state before exposing the ruleset to skin sources.
            GameplayClockContainer.Add(rulesetSkinProvider);

            rulesetSkinProvider.AddRange(new[]
            {
                // underlay and gameplay should have access to the skinning sources.
                createUnderlayComponents(),
                createGameplayComponents(Beatmap.Value, playableBeatmap)
            });

            // add the overlay components as a separate step as they proxy some elements from the above underlay/gameplay components.
            // also give the overlays the ruleset skin provider to allow rulesets to potentially override HUD elements (used to disable combo counters etc.)
            // we may want to limit this in the future to disallow rulesets from outright replacing elements the user expects to be there.
            rulesetSkinProvider.Add(createOverlayComponents(Beatmap.Value));

            if (!DrawableRuleset.AllowGameplayOverlays)
            {
                HUDOverlay.ShowHud.Value    = false;
                HUDOverlay.ShowHud.Disabled = true;
                BreakOverlay.Hide();
            }

            DrawableRuleset.FrameStableClock.WaitingOnFrames.BindValueChanged(waiting =>
            {
                if (waiting.NewValue)
                {
                    GameplayClockContainer.Stop();
                }
                else
                {
                    GameplayClockContainer.Start();
                }
            });

            DrawableRuleset.IsPaused.BindValueChanged(paused =>
            {
                updateGameplayState();
                updateSampleDisabledState();
            });

            DrawableRuleset.FrameStableClock.IsCatchingUp.BindValueChanged(_ => updateSampleDisabledState());

            DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updateGameplayState());

            // bind clock into components that require it
            DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);

            DrawableRuleset.NewResult += r =>
            {
                HealthProcessor.ApplyResult(r);
                ScoreProcessor.ApplyResult(r);
                GameplayBeatmap.ApplyResult(r);
            };

            DrawableRuleset.RevertResult += r =>
            {
                HealthProcessor.RevertResult(r);
                ScoreProcessor.RevertResult(r);
            };

            DimmableStoryboard.HasStoryboardEnded.ValueChanged += storyboardEnded =>
            {
                if (storyboardEnded.NewValue)
                {
                    progressToResults(true);
                }
            };

            // Bind the judgement processors to ourselves
            ScoreProcessor.HasCompleted.BindValueChanged(scoreCompletionChanged);
            HealthProcessor.Failed += onFail;

            // Provide judgement processors to mods after they're loaded so that they're on the gameplay clock,
            // this is required for mods that apply transforms to these processors.
            ScoreProcessor.OnLoadComplete += _ =>
            {
                foreach (var mod in Mods.Value.OfType <IApplicableToScoreProcessor>())
                {
                    mod.ApplyToScoreProcessor(ScoreProcessor);
                }
            };

            HealthProcessor.OnLoadComplete += _ =>
            {
                foreach (var mod in Mods.Value.OfType <IApplicableToHealthProcessor>())
                {
                    mod.ApplyToHealthProcessor(HealthProcessor);
                }
            };

            IsBreakTime.BindTo(breakTracker.IsBreakTime);
            IsBreakTime.BindValueChanged(onBreakTimeChanged, true);
        }
Exemple #29
0
 private void load(OsuGameBase osuGame)
 {
     current = osuGame.Beatmap.Value;
 }
Exemple #30
0
        private void load(OsuGameBase game, BeatmapManager beatmaps, OsuColour colours, UserInputManager inputManager)
        {
            this.inputManager = inputManager;
            this.beatmaps     = beatmaps;

            Children = new Drawable[]
            {
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    CornerRadius     = 5,
                    Masking          = true,
                    EdgeEffect       = new EdgeEffectParameters
                    {
                        Type   = EdgeEffectType.Shadow,
                        Colour = Color4.Black.Opacity(40),
                        Radius = 5,
                    },
                    Children = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = colours.Gray3,
                            RelativeSizeAxes = Axes.Both,
                        },
                        list = new PlaylistList
                        {
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Top = 95, Bottom = 10, Right = 10
                            },
                            OnSelect = itemSelected,
                        },
                        filter = new FilterControl
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            ExitRequested    = () => State = Visibility.Hidden,
                            FilterChanged    = search => list.Filter(search),
                            Padding          = new MarginPadding(10),
                        },
                    },
                },
            };

            beatmaps.BeatmapSetAdded   += s => Schedule(() => list.AddBeatmapSet(s));
            beatmaps.BeatmapSetRemoved += s => Schedule(() => list.RemoveBeatmapSet(s));

            list.BeatmapSets = BeatmapSets = beatmaps.GetAllUsableBeatmapSets();


            beatmapBacking.BindTo(game.Beatmap);

            filter.Search.OnCommit = (sender, newText) =>
            {
                var beatmap = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault();
                if (beatmap != null)
                {
                    playSpecified(beatmap);
                }
            };
        }
Exemple #31
0
 private void load(OsuGameBase game)
 {
     Child = globalActionContainer = new GlobalActionContainer(game);
 }
Exemple #32
0
        private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game, OsuConfigManager config)
        {
            dimLevel = config.GetBindable <int>(OsuConfig.DimLevel);
            try
            {
                if (Beatmap == null)
                {
                    Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true);
                }

                if ((Beatmap?.Beatmap?.HitObjects.Count ?? 0) == 0)
                {
                    throw new Exception("No valid objects were found!");
                }
            }
            catch (Exception e)
            {
                Logger.Log($"Could not load this beatmap sucessfully ({e})!", LoggingTarget.Runtime, LogLevel.Error);

                //couldn't load, hard abort!
                Exit();
                return;
            }

            AudioTrack track = Beatmap.Track;

            if (track != null)
            {
                audio.Track.SetExclusive(track);
                sourceClock = track;
            }

            sourceClock = (IAdjustableClock)track ?? new StopwatchClock();

            Schedule(() =>
            {
                sourceClock.Reset();
            });

            var beatmap = Beatmap.Beatmap;

            if (beatmap.BeatmapInfo?.Mode > PlayMode.Osu)
            {
                //we only support osu! mode for now because the hitobject parsing is crappy and needs a refactor.
                Exit();
                return;
            }

            PlayMode usablePlayMode = beatmap.BeatmapInfo?.Mode > PlayMode.Osu ? beatmap.BeatmapInfo.Mode : PreferredPlayMode;

            ruleset = Ruleset.GetRuleset(usablePlayMode);

            scoreOverlay = ruleset.CreateScoreOverlay();
            scoreOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count));

            pauseOverlay = new PauseOverlay
            {
                Depth    = -1,
                OnResume = delegate
                {
                    Delay(400);
                    Schedule(Resume);
                },
                OnRetry = Restart,
                OnQuit  = Exit
            };

            hitRenderer = ruleset.CreateHitRendererWith(beatmap);

            //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation)
            hitRenderer.OnJudgement += scoreProcessor.AddJudgement;
            hitRenderer.OnAllJudged += onPass;

            //bind ScoreProcessor to ourselves (for a fail situation)
            scoreProcessor.Failed += onFail;

            if (Autoplay)
            {
                hitRenderer.Schedule(() => hitRenderer.DrawableObjects.ForEach(h => h.State = ArmedState.Hit));
            }

            Children = new Drawable[]
            {
                playerInputManager = new PlayerInputManager(game.Host)
                {
                    Clock       = new InterpolatingFramedClock(sourceClock),
                    PassThrough = false,
                    Children    = new Drawable[]
                    {
                        hitRenderer,
                        skipButton = new SkipButton {
                            Alpha = 0
                        },
                    }
                },
                scoreOverlay,
                pauseOverlay
            };
        }
Exemple #33
0
 private void load(OsuGameBase game)
 {
     beatmapBacking.BindTo(game.Beatmap);
     beatmapBacking.ValueChanged += beatmapChanged;
 }
Exemple #34
0
        private void ensureLoaded(OsuGameBase osu, int timeout = 10000)
        {
            IEnumerable <BeatmapSetInfo> resultSets = null;

            Action waitAction = () =>
            {
                while (!(resultSets = osu.Dependencies.Get <BeatmapDatabase>()
                                      .Query <BeatmapSetInfo>().Where(s => s.OnlineBeatmapSetID == 241526)).Any())
                {
                    Thread.Sleep(50);
                }
            };

            Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout),
                          @"BeatmapSet did not import to the database in allocated time.");

            //ensure we were stored to beatmap database backing...

            Assert.IsTrue(resultSets.Count() == 1, $@"Incorrect result count found ({resultSets.Count()} but should be 1).");

            IEnumerable <BeatmapInfo> resultBeatmaps = null;

            //if we don't re-check here, the set will be inserted but the beatmaps won't be present yet.
            waitAction = () =>
            {
                while ((resultBeatmaps = osu.Dependencies.Get <BeatmapDatabase>()
                                         .Query <BeatmapInfo>().Where(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12)
                {
                    Thread.Sleep(50);
                }
            };

            Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout),
                          @"Beatmaps did not import to the database in allocated time");

            //fetch children and check we can load from the post-storage path...
            var set = osu.Dependencies.Get <BeatmapDatabase>().GetChildren(resultSets.First());

            Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(),
                          $@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count}).");

            foreach (BeatmapInfo b in resultBeatmaps)
            {
                Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineBeatmapID == b.OnlineBeatmapID));
            }

            Assert.IsTrue(set.Beatmaps.Count > 0);

            var beatmap = osu.Dependencies.Get <BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 0))?.Beatmap;

            Assert.IsTrue(beatmap?.HitObjects.Count > 0);

            beatmap = osu.Dependencies.Get <BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 1))?.Beatmap;
            Assert.IsTrue(beatmap?.HitObjects.Count > 0);

            beatmap = osu.Dependencies.Get <BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 2))?.Beatmap;
            Assert.IsTrue(beatmap?.HitObjects.Count > 0);

            beatmap = osu.Dependencies.Get <BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 3))?.Beatmap;
            Assert.IsTrue(beatmap?.HitObjects.Count > 0);
        }
Exemple #35
0
            private void load(OsuConfigManager config, OsuGameBase game)
            {
                Children = new Drawable[]
                {
                    cursorContainer = new CircularContainer
                    {
                        Origin           = Anchor.Centre,
                        Anchor           = Anchor.Centre,
                        RelativeSizeAxes = Axes.Both,
                        Masking          = true,
                        BorderThickness  = Size.X / 6,
                        BorderColour     = Color4.White,
                        EdgeEffect       = new EdgeEffectParameters
                        {
                            Type   = EdgeEffectType.Shadow,
                            Colour = Color4.Pink.Opacity(0.5f),
                            Radius = 5,
                        },
                        Children = new Drawable[]
                        {
                            new Box
                            {
                                RelativeSizeAxes = Axes.Both,
                                Alpha            = 0,
                                AlwaysPresent    = true,
                            },
                            new CircularContainer
                            {
                                Origin           = Anchor.Centre,
                                Anchor           = Anchor.Centre,
                                RelativeSizeAxes = Axes.Both,
                                Masking          = true,
                                BorderThickness  = Size.X / 3,
                                BorderColour     = Color4.White.Opacity(0.5f),
                                Children         = new Drawable[]
                                {
                                    new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Alpha            = 0,
                                        AlwaysPresent    = true,
                                    },
                                },
                            },
                            new CircularContainer
                            {
                                Origin           = Anchor.Centre,
                                Anchor           = Anchor.Centre,
                                RelativeSizeAxes = Axes.Both,
                                Scale            = new Vector2(0.1f),
                                Masking          = true,
                                Children         = new Drawable[]
                                {
                                    new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Colour           = Color4.White,
                                    },
                                },
                            },
                        }
                    },
                };

                beatmap = game.Beatmap.GetBoundCopy();
                beatmap.ValueChanged += v => calculateScale();

                cursorScale = config.GetBindable <double>(OsuSetting.GameplayCursorSize);
                cursorScale.ValueChanged += v => calculateScale();

                autoCursorScale = config.GetBindable <bool>(OsuSetting.AutoCursorSize);
                autoCursorScale.ValueChanged += v => calculateScale();

                calculateScale();
            }
Exemple #36
0
        private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config)
        {
            notificationOverlay = notification;
            this.config         = config;
            this.game           = game;

            AutoSizeAxes = Axes.Both;
            Anchor       = Anchor.BottomCentre;
            Origin       = Anchor.BottomCentre;

            Alpha = 0;

            Children = new Drawable[]
            {
                new FillFlowContainer
                {
                    AutoSizeAxes = Axes.Both,
                    Direction    = FillDirection.Vertical,
                    Children     = new Drawable[]
                    {
                        new FillFlowContainer
                        {
                            AutoSizeAxes = Axes.Both,
                            Direction    = FillDirection.Horizontal,
                            Spacing      = new Vector2(5),
                            Anchor       = Anchor.TopCentre,
                            Origin       = Anchor.TopCentre,
                            Children     = new Drawable[]
                            {
                                new OsuSpriteText
                                {
                                    Font = @"Exo2.0-Bold",
                                    Text = game.Name
                                },
                                new OsuSpriteText
                                {
                                    Colour = DebugUtils.IsDebug ? colours.Red : Color4.White,
                                    Text   = game.Version
                                },
                            }
                        },
                        new OsuSpriteText
                        {
                            Anchor   = Anchor.TopCentre,
                            Origin   = Anchor.TopCentre,
                            TextSize = 12,
                            Colour   = colours.Yellow,
                            Font     = @"Venera",
                            Text     = @"Development Build"
                        },
                        new Sprite
                        {
                            Anchor  = Anchor.TopCentre,
                            Origin  = Anchor.TopCentre,
                            Texture = textures.Get(@"Menu/dev-build-footer"),
                        },
                    }
                }
            };

            if (game.IsDeployedBuild)
            {
                checkForUpdateAsync();
            }
        }
Exemple #37
0
        private void load(OsuGameBase game, OsuColour colours, LocalisationEngine localisation)
        {
            this.localisation = localisation;

            Children = new Drawable[]
            {
                dragContainer = new Container
                {
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Children         = new Drawable[]
                    {
                        playlist = new PlaylistOverlay
                        {
                            RelativeSizeAxes = Axes.X,
                            Y = player_height + 10,
                        },
                        playerContainer = new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = player_height,
                            Masking          = true,
                            CornerRadius     = 5,
                            EdgeEffect       = new EdgeEffectParameters
                            {
                                Type   = EdgeEffectType.Shadow,
                                Colour = Color4.Black.Opacity(40),
                                Radius = 5,
                            },
                            Children = new[]
                            {
                                currentBackground = new Background(),
                                title             = new OsuSpriteText
                                {
                                    Origin   = Anchor.BottomCentre,
                                    Anchor   = Anchor.TopCentre,
                                    Position = new Vector2(0, 40),
                                    TextSize = 25,
                                    Colour   = Color4.White,
                                    Text     = @"Nothing to play",
                                    Font     = @"Exo2.0-MediumItalic"
                                },
                                artist = new OsuSpriteText
                                {
                                    Origin   = Anchor.TopCentre,
                                    Anchor   = Anchor.TopCentre,
                                    Position = new Vector2(0, 45),
                                    TextSize = 15,
                                    Colour   = Color4.White,
                                    Text     = @"Nothing to play",
                                    Font     = @"Exo2.0-BoldItalic"
                                },
                                new Container
                                {
                                    Padding = new MarginPadding {
                                        Bottom = progress_height
                                    },
                                    Height           = bottom_black_area_height,
                                    RelativeSizeAxes = Axes.X,
                                    Origin           = Anchor.BottomCentre,
                                    Anchor           = Anchor.BottomCentre,
                                    Children         = new Drawable[]
                                    {
                                        new FillFlowContainer <IconButton>
                                        {
                                            AutoSizeAxes = Axes.Both,
                                            Direction    = FillDirection.Horizontal,
                                            Spacing      = new Vector2(5),
                                            Origin       = Anchor.Centre,
                                            Anchor       = Anchor.Centre,
                                            Children     = new[]
                                            {
                                                new IconButton
                                                {
                                                    Action = prev,
                                                    Icon   = FontAwesome.fa_step_backward,
                                                },
                                                playButton = new IconButton
                                                {
                                                    Scale     = new Vector2(1.4f),
                                                    IconScale = new Vector2(1.4f),
                                                    Action    = play,
                                                    Icon      = FontAwesome.fa_play_circle_o,
                                                },
                                                new IconButton
                                                {
                                                    Action = next,
                                                    Icon   = FontAwesome.fa_step_forward,
                                                },
                                            }
                                        },
                                        playlistButton = new IconButton
                                        {
                                            Origin   = Anchor.Centre,
                                            Anchor   = Anchor.CentreRight,
                                            Position = new Vector2(-bottom_black_area_height / 2, 0),
                                            Icon     = FontAwesome.fa_bars,
                                            Action   = () => playlist.ToggleVisibility(),
                                        },
                                    }
                                },
                                progressBar = new DragBar
                                {
                                    Origin        = Anchor.BottomCentre,
                                    Anchor        = Anchor.BottomCentre,
                                    Height        = progress_height,
                                    Colour        = colours.Yellow,
                                    SeekRequested = seek
                                }
                            },
                        },
                    }
                }
            };

            beatmapBacking.BindTo(game.Beatmap);

            playlist.StateChanged += (c, s) => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, EasingTypes.OutQuint);
        }