mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 06:52:56 +08:00
Use DI for Player
This commit is contained in:
parent
19fd6fe249
commit
dc03f36793
@ -1 +1 @@
|
||||
Subproject commit 25b8c3c6cfead49acf5659a750c7e604289d5b81
|
||||
Subproject commit eb16219058e87210c9ad90b1e214ccc2c1556058
|
@ -11,6 +11,7 @@ using osu.Game.Beatmaps.Objects;
|
||||
using osu.Game.Beatmaps.Objects.Osu;
|
||||
using osu.Game.GameModes.Play;
|
||||
using OpenTK;
|
||||
using osu.Framework;
|
||||
|
||||
namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
@ -24,6 +25,14 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
protected override IFrameBasedClock Clock => localClock;
|
||||
|
||||
private BaseGame game;
|
||||
|
||||
protected override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
@ -55,10 +64,9 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
decoder.Process(b);
|
||||
|
||||
Add(new Player
|
||||
{
|
||||
Beatmap = new WorkingBeatmap(b)
|
||||
});
|
||||
var player = game.Dependencies.Get<Player>();
|
||||
player.Beatmap = new WorkingBeatmap(b);
|
||||
Add(player);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
|
@ -113,10 +113,13 @@ namespace osu.Game.GameModes.Play
|
||||
Width = 100,
|
||||
Text = "Play",
|
||||
Colour = new Color4(238, 51, 153, 255),
|
||||
Action = () => Push(new Player {
|
||||
BeatmapInfo = selectedBeatmapGroup.SelectedPanel.Beatmap,
|
||||
PreferredPlayMode = playMode.Value
|
||||
}),
|
||||
Action = () =>
|
||||
{
|
||||
var player = Game.Dependencies.Get<Player>();
|
||||
player.BeatmapInfo = selectedBeatmapGroup.SelectedPanel.Beatmap;
|
||||
player.PreferredPlayMode = playMode.Value;
|
||||
Push(player);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,12 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
private InterpolatingFramedClock playerClock;
|
||||
private IAdjustableClock sourceClock;
|
||||
private BeatmapDatabase beatmaps;
|
||||
|
||||
public Player(BeatmapDatabase beatmaps)
|
||||
{
|
||||
this.beatmaps = beatmaps;
|
||||
}
|
||||
|
||||
protected override void Load(BaseGame game)
|
||||
{
|
||||
@ -37,7 +43,6 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
try
|
||||
{
|
||||
var beatmaps = Game.Dependencies.Get<BeatmapDatabase>();
|
||||
if (Beatmap == null)
|
||||
Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user