mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 23:23:30 +08:00
Merge pull request #247 from peppy/song-select-async-player
Load player async
This commit is contained in:
commit
3e42fa4f90
@ -134,7 +134,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
FadeOut(TIME_FADEOUT / 5);
|
||||
break;
|
||||
case ArmedState.Hit:
|
||||
const double flash_in = 30;
|
||||
const double flash_in = 40;
|
||||
|
||||
flash.FadeTo(0.8f, flash_in);
|
||||
flash.Delay(flash_in);
|
||||
|
@ -13,6 +13,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class Triangles : Container<Triangle>
|
||||
{
|
||||
public override bool HandleInput => false;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
@ -54,7 +54,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapGroup(WorkingBeatmap beatmap)
|
||||
public BeatmapGroup(WorkingBeatmap beatmap, BeatmapSetInfo set = null)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
|
||||
|
@ -15,6 +15,8 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
{
|
||||
public class Triangles : Container<Triangle>
|
||||
{
|
||||
public override bool HandleInput => false;
|
||||
|
||||
public Triangles()
|
||||
{
|
||||
Alpha = 0.3f;
|
||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
protected set;
|
||||
}
|
||||
|
||||
private double animationDelay => 150;
|
||||
private double animationDelay => 80;
|
||||
|
||||
private double scalingDuration => 500;
|
||||
private EasingTypes scalingEasing => EasingTypes.OutElasticHalf;
|
||||
|
@ -44,6 +44,8 @@ namespace osu.Game.Modes.Objects.Drawables
|
||||
|
||||
UpdateState(state);
|
||||
|
||||
Expire();
|
||||
|
||||
if (State == ArmedState.Hit)
|
||||
PlaySample();
|
||||
}
|
||||
@ -75,6 +77,8 @@ namespace osu.Game.Modes.Objects.Drawables
|
||||
|
||||
//force application of the state that was set before we loaded.
|
||||
UpdateState(State);
|
||||
|
||||
Expire(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,19 +1,21 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Game.Database;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using OpenTK;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Game.Database;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
@ -244,5 +246,47 @@ namespace osu.Game.Screens.Select
|
||||
updatePanel(p, halfHeight);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
int direction = 0;
|
||||
bool skipDifficulties = false;
|
||||
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.Up:
|
||||
direction = -1;
|
||||
break;
|
||||
case Key.Down:
|
||||
direction = 1;
|
||||
break;
|
||||
case Key.Left:
|
||||
direction = -1;
|
||||
skipDifficulties = true;
|
||||
break;
|
||||
case Key.Right:
|
||||
direction = 1;
|
||||
skipDifficulties = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (direction != 0)
|
||||
{
|
||||
int index = SelectedGroup.BeatmapPanels.IndexOf(SelectedPanel) + direction;
|
||||
|
||||
if (!skipDifficulties && index >= 0 && index < SelectedGroup.BeatmapPanels.Count)
|
||||
//changing difficulty panel, not set.
|
||||
SelectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[index]);
|
||||
else
|
||||
{
|
||||
index = (groups.IndexOf(SelectedGroup) + direction + groups.Count) % groups.Count;
|
||||
SelectBeatmap(groups[index].BeatmapPanels.First().Beatmap);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
@ -141,17 +143,38 @@ namespace osu.Game.Screens.Select
|
||||
Width = 100,
|
||||
Text = "Play",
|
||||
Colour = new Color4(238, 51, 153, 255),
|
||||
Action = () => Push(new Player
|
||||
{
|
||||
BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap,
|
||||
PreferredPlayMode = playMode.Value
|
||||
})
|
||||
Action = start
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Player player;
|
||||
|
||||
private void start()
|
||||
{
|
||||
if (player != null)
|
||||
return;
|
||||
|
||||
//in the future we may want to move this logic to a PlayerLoader gamemode or similar, so we can rely on the SongSelect transition
|
||||
//and provide a better loading experience (at the moment song select is still accepting input during preload).
|
||||
player = new Player
|
||||
{
|
||||
BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap,
|
||||
PreferredPlayMode = playMode.Value
|
||||
};
|
||||
|
||||
player.Preload(Game, delegate
|
||||
{
|
||||
if (!Push(player))
|
||||
{
|
||||
player = null;
|
||||
//error occured?
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game, OsuGame osuGame)
|
||||
{
|
||||
@ -199,6 +222,8 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
protected override void OnResuming(GameMode last)
|
||||
{
|
||||
player = null;
|
||||
|
||||
changeBackground(Beatmap);
|
||||
ensurePlayingSelected();
|
||||
base.OnResuming(last);
|
||||
@ -316,10 +341,15 @@ namespace osu.Game.Screens.Select
|
||||
private void addBeatmapSet(BeatmapSetInfo beatmapSet, BaseGame game)
|
||||
{
|
||||
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.BeatmapSetID);
|
||||
beatmapSet.Beatmaps.ForEach(b => database.GetChildren(b));
|
||||
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 = database.GetWorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault());
|
||||
var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database);
|
||||
|
||||
var group = new BeatmapGroup(beatmap) { SelectionChanged = selectionChanged };
|
||||
|
||||
@ -348,5 +378,17 @@ namespace osu.Game.Screens.Select
|
||||
addBeatmapSet(beatmapSet, game);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.Enter:
|
||||
start();
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user