示例#1
0
 public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null)
 {
     Beatmap       = beatmap;
     InternalChild = fadeContainer = CreateFadeContainer();
     fadeContainer.EnableUserDim.BindTo(EnableUserDim);
     fadeContainer.BlurAmount.BindTo(BlurAmount);
 }
示例#2
0
文件: Player.cs 项目: yazici/osu
        private void load(AudioManager audio, APIAccess api, OsuConfigManager config)
        {
            this.api = api;

            WorkingBeatmap working = Beatmap.Value;

            if (working is DummyWorkingBeatmap)
            {
                return;
            }

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

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

            IBeatmap beatmap;

            try
            {
                beatmap = working.Beatmap;

                if (beatmap == null)
                {
                    throw new InvalidOperationException("Beatmap was not loaded");
                }

                ruleset = Ruleset.Value ?? beatmap.BeatmapInfo.Ruleset;
                var rulesetInstance = ruleset.CreateInstance();

                try
                {
                    RulesetContainer = rulesetInstance.CreateRulesetContainerWith(working);
                }
                catch (BeatmapInvalidForRulesetException)
                {
                    // we may fail to create a RulesetContainer if the beatmap cannot be loaded with the user's preferred ruleset
                    // let's try again forcing the beatmap's ruleset.
                    ruleset          = beatmap.BeatmapInfo.Ruleset;
                    rulesetInstance  = ruleset.CreateInstance();
                    RulesetContainer = rulesetInstance.CreateRulesetContainerWith(Beatmap.Value);
                }

                if (!RulesetContainer.Objects.Any())
                {
                    Logger.Log("Beatmap contains no hit objects!", level: LogLevel.Error);
                    return;
                }
            }
            catch (Exception e)
            {
                Logger.Error(e, "Could not load beatmap sucessfully!");
                //couldn't load, hard abort!
                return;
            }

            sourceClock     = (IAdjustableClock)working.Track ?? new StopwatchClock();
            adjustableClock = new DecoupleableInterpolatingFramedClock {
                IsCoupled = false
            };

            adjustableClock.Seek(AllowLeadIn
                ? Math.Min(0, RulesetContainer.GameplayStartTime - beatmap.BeatmapInfo.AudioLeadIn)
                : RulesetContainer.GameplayStartTime);

            adjustableClock.ProcessFrame();

            // Lazer's audio timings in general doesn't match stable. This is the result of user testing, albeit limited.
            // This only seems to be required on windows. We need to eventually figure out why, with a bit of luck.
            var platformOffsetClock = new FramedOffsetClock(adjustableClock)
            {
                Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 22 : 0
            };

            // the final usable gameplay clock with user-set offsets applied.
            var offsetClock = new FramedOffsetClock(platformOffsetClock);

            userAudioOffset.ValueChanged += offset => offsetClock.Offset = offset.NewValue;
            userAudioOffset.TriggerChange();

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

            InternalChildren = new Drawable[]
            {
                PausableGameplayContainer = new PausableGameplayContainer(offsetClock, adjustableClock)
                {
                    Retries       = RestartCount,
                    OnRetry       = restart,
                    OnQuit        = performUserRequestedExit,
                    CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded.Value,
                    Children      = new Container[]
                    {
                        StoryboardContainer = CreateStoryboardContainer(),
                        new ScalingContainer(ScalingMode.Gameplay)
                        {
                            Child = new LocalSkinOverrideContainer(working.Skin)
                            {
                                RelativeSizeAxes = Axes.Both,
                                Child            = RulesetContainer
                            }
                        },
                        new BreakOverlay(beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor)
                        {
                            Anchor = Anchor.Centre,
                            Origin = Anchor.Centre,
                            Breaks = beatmap.Breaks
                        },
                        new ScalingContainer(ScalingMode.Gameplay)
                        {
                            Child = RulesetContainer.Cursor?.CreateProxy() ?? new Container(),
                        },
                        HUDOverlay = new HUDOverlay(ScoreProcessor, RulesetContainer, working, adjustableClock)
                        {
                            Anchor = Anchor.Centre,
                            Origin = Anchor.Centre
                        },
                        new SkipOverlay(RulesetContainer.GameplayStartTime)
                        {
                            RequestSeek = time => adjustableClock.Seek(time)
                        },
                    }
                },
                failOverlay = new FailOverlay
                {
                    OnRetry = restart,
                    OnQuit  = performUserRequestedExit,
                },
                new HotkeyRetryOverlay
                {
                    Action = () =>
                    {
                        if (!this.IsCurrentScreen())
                        {
                            return;
                        }

                        fadeOut(true);
                        restart();
                    },
                }
            };

            HUDOverlay.HoldToQuit.Action = performUserRequestedExit;
            HUDOverlay.KeyCounter.Visible.BindTo(RulesetContainer.HasReplayLoaded);

            RulesetContainer.IsPaused.BindTo(PausableGameplayContainer.IsPaused);

            if (ShowStoryboard.Value)
            {
                initializeStoryboard(false);
            }

            // Bind ScoreProcessor to ourselves
            ScoreProcessor.AllJudged += onCompletion;
            ScoreProcessor.Failed    += onFail;

            foreach (var mod in Beatmap.Value.Mods.Value.OfType <IApplicableToScoreProcessor>())
            {
                mod.ApplyToScoreProcessor(ScoreProcessor);
            }
        }
示例#3
0
 public BackgroundScreenBeatmap()
 {
     InternalChild = fadeContainer = CreateFadeContainer();
     fadeContainer.EnableUserDim.BindTo(EnableUserDim);
     fadeContainer.BlurAmount.BindTo(BlurAmount);
 }
示例#4
0
        private void load(AudioManager audio, APIAccess api, OsuConfigManager config)
        {
            this.api = api;

            WorkingBeatmap working = loadBeatmap();

            if (working == null)
            {
                return;
            }

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

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

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

            InternalChild = gameplayClockContainer = new GameplayClockContainer(working, AllowLeadIn, RulesetContainer.GameplayStartTime);

            gameplayClockContainer.Children = new Drawable[]
            {
                PausableGameplayContainer = new PausableGameplayContainer
                {
                    Retries       = RestartCount,
                    OnRetry       = restart,
                    OnQuit        = performUserRequestedExit,
                    Start         = gameplayClockContainer.Start,
                    Stop          = gameplayClockContainer.Stop,
                    IsPaused      = { BindTarget = gameplayClockContainer.IsPaused },
                    CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded.Value,
                    Children      = new[]
                    {
                        StoryboardContainer = CreateStoryboardContainer(),
                        new ScalingContainer(ScalingMode.Gameplay)
                        {
                            Child = new LocalSkinOverrideContainer(working.Skin)
                            {
                                RelativeSizeAxes = Axes.Both,
                                Child            = RulesetContainer
                            }
                        },
                        new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor)
                        {
                            Anchor = Anchor.Centre,
                            Origin = Anchor.Centre,
                            Breaks = working.Beatmap.Breaks
                        },
                        // display the cursor above some HUD elements.
                        RulesetContainer.Cursor?.CreateProxy() ?? new Container(),
                        HUDOverlay = new HUDOverlay(ScoreProcessor, RulesetContainer, working)
                        {
                            HoldToQuit            = { Action = performUserRequestedExit },
                            PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = gameplayClockContainer.UserPlaybackRate } } },
                            KeyCounter            = { Visible = { BindTarget = RulesetContainer.HasReplayLoaded } },
                            RequestSeek           = gameplayClockContainer.Seek,
                            Anchor = Anchor.Centre,
                            Origin = Anchor.Centre
                        },
                        new SkipOverlay(RulesetContainer.GameplayStartTime)
                        {
                            RequestSeek = gameplayClockContainer.Seek
                        },
                    }
                },
                failOverlay = new FailOverlay
                {
                    OnRetry = restart,
                    OnQuit  = performUserRequestedExit,
                },
                new HotkeyRetryOverlay
                {
                    Action = () =>
                    {
                        if (!this.IsCurrentScreen())
                        {
                            return;
                        }

                        fadeOut(true);
                        restart();
                    },
                }
            };

            // bind clock into components that require it
            RulesetContainer.IsPaused.BindTo(gameplayClockContainer.IsPaused);

            if (ShowStoryboard.Value)
            {
                initializeStoryboard(false);
            }

            // Bind ScoreProcessor to ourselves
            ScoreProcessor.AllJudged += onCompletion;
            ScoreProcessor.Failed    += onFail;

            foreach (var mod in Beatmap.Value.Mods.Value.OfType <IApplicableToScoreProcessor>())
            {
                mod.ApplyToScoreProcessor(ScoreProcessor);
            }
        }