mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Add the concept of a "WorkingBeatmap" and make player load beatmaps and audio from SongSelect.
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
@ -12,6 +11,9 @@ using osu.Game.GameModes.Play.Osu;
|
||||
using osu.Game.GameModes.Play.Taiko;
|
||||
using osu.Framework;
|
||||
using osu.Game.Database;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.GameModes;
|
||||
using osu.Framework.Audio.Track;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
{
|
||||
@ -20,10 +22,29 @@ namespace osu.Game.GameModes.Play
|
||||
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
|
||||
|
||||
public BeatmapInfo BeatmapInfo;
|
||||
public Beatmap Beatmap;
|
||||
public WorkingBeatmap Beatmap;
|
||||
|
||||
public PlayMode PlayMode;
|
||||
|
||||
protected override IFrameBasedClock Clock => playerClock;
|
||||
|
||||
private InterpolatingFramedClock playerClock;
|
||||
private IAdjustableClock sourceClock;
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
Beatmap?.Dispose();
|
||||
base.Dispose(isDisposing);
|
||||
}
|
||||
|
||||
protected override bool OnExiting(GameMode next)
|
||||
{
|
||||
//eagerly dispose as the finalizer runs too late right now.
|
||||
Beatmap?.Dispose();
|
||||
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
@ -31,7 +52,7 @@ namespace osu.Game.GameModes.Play
|
||||
try
|
||||
{
|
||||
if (Beatmap == null)
|
||||
Beatmap = ((OsuGame)game).Beatmaps.GetBeatmap(BeatmapInfo);
|
||||
Beatmap = ((OsuGame)game).Beatmaps.GetBeatmapData(BeatmapInfo);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -40,6 +61,22 @@ namespace osu.Game.GameModes.Play
|
||||
return;
|
||||
}
|
||||
|
||||
AudioTrack track = Beatmap.Track;
|
||||
|
||||
if (track != null)
|
||||
{
|
||||
game.Audio.Track.SetExclusive(track);
|
||||
sourceClock = track;
|
||||
}
|
||||
|
||||
sourceClock = (IAdjustableClock)Beatmap.Track ?? new StopwatchClock();
|
||||
playerClock = new InterpolatingFramedClock(sourceClock);
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
sourceClock.Start();
|
||||
});
|
||||
|
||||
HitRenderer hitRenderer;
|
||||
ScoreOverlay scoreOverlay;
|
||||
|
||||
@ -50,7 +87,7 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
hitRenderer = new OsuHitRenderer
|
||||
{
|
||||
Objects = Beatmap.HitObjects,
|
||||
Objects = Beatmap.Beatmap.HitObjects,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
};
|
||||
@ -60,7 +97,7 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
hitRenderer = new TaikoHitRenderer
|
||||
{
|
||||
Objects = Beatmap.HitObjects,
|
||||
Objects = Beatmap.Beatmap.HitObjects,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
};
|
||||
@ -70,7 +107,7 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
hitRenderer = new CatchHitRenderer
|
||||
{
|
||||
Objects = Beatmap.HitObjects,
|
||||
Objects = Beatmap.Beatmap.HitObjects,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
};
|
||||
@ -80,7 +117,7 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
hitRenderer = new ManiaHitRenderer
|
||||
{
|
||||
Objects = Beatmap.HitObjects,
|
||||
Objects = Beatmap.Beatmap.HitObjects,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
};
|
||||
@ -96,5 +133,11 @@ namespace osu.Game.GameModes.Play
|
||||
scoreOverlay,
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
playerClock.ProcessFrame();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user