Merge with upstream/master

This commit is contained in:
Alex Amadori
2017-02-24 16:54:27 +01:00
148 changed files with 609 additions and 628 deletions

View File

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using osu.Framework;
using osu.Framework.Allocation;
using OpenTK;
using OpenTK.Graphics;
@ -19,7 +18,6 @@ using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.MathUtils;
using osu.Game.Graphics;
using osu.Game.Beatmaps.Timing;
using osu.Game.Graphics.Sprites;
using osu.Game.Modes;
@ -179,7 +177,7 @@ namespace osu.Game.Screens.Select
}
},
}
}).Preload(game, delegate (Drawable d)
}).LoadAsync(game, delegate (Drawable d)
{
FadeIn(250);

View File

@ -2,7 +2,6 @@
// 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;
@ -10,7 +9,6 @@ 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;

View File

@ -58,18 +58,19 @@ namespace osu.Game.Screens.Select
Direction = FlowDirections.Vertical,
Children = new Drawable[]
{
searchTextBox = new SearchTextBox { RelativeSizeAxes = Axes.X },
searchTextBox = new SearchTextBox {
RelativeSizeAxes = Axes.X,
OnChange = (TextBox sender, bool newText) =>
{
if (newText)
FilterChanged?.Invoke();
},
Exit = () => Exit?.Invoke(),
},
new GroupSortTabs()
}
}
};
searchTextBox.OnChange += (TextBox sender, bool newText) =>
{
if (newText)
FilterChanged?.Invoke();
};
searchTextBox.Exit = () => Exit?.Invoke();
}
public void Deactivate()

View File

@ -32,6 +32,8 @@ namespace osu.Game.Screens.Select
private FlowContainer buttons;
public OsuLogo StartButton;
public void AddButton(string text, Color4 colour, Action action)
{
var button = new FooterButton
@ -76,7 +78,7 @@ namespace osu.Game.Screens.Select
Height = 3,
Position = new Vector2(0, -3),
},
new OsuLogo()
StartButton = new OsuLogo
{
Anchor = Anchor.BottomRight,
Scale = new Vector2(0.4f),

View File

@ -18,7 +18,6 @@ using osu.Game.Modes;
using osu.Game.Screens.Backgrounds;
using OpenTK;
using osu.Game.Screens.Play;
using osu.Framework;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics.Transformations;
using osu.Game.Beatmaps.Drawables;
@ -27,7 +26,6 @@ using osu.Game.Graphics;
using osu.Framework.Input;
using OpenTK.Input;
using System.Collections.Generic;
using osu.Framework.Graphics.Containers;
using osu.Framework.Threading;
namespace osu.Game.Screens.Select
@ -54,46 +52,27 @@ namespace osu.Game.Screens.Select
private Footer footer;
OsuScreen player;
private FilterControl filter;
public FilterControl Filter {
get {
public FilterControl Filter
{
get
{
return filter;
}
private set {
if (filter != value) {
}
private set
{
if (filter != value)
{
filter = value;
filterChanged();
}
}
}
Player player;
private void start()
{
if (player != null || Beatmap == 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,
private void load(BeatmapDatabase beatmaps, AudioManager audio, Framework.Game game,
OsuGame osuGame, OsuColour colours)
{
const float carousel_width = 640;
@ -144,10 +123,20 @@ namespace osu.Game.Screens.Select
Right = 20,
},
},
footer = new Footer()
footer = new Footer
{
OnBack = Exit,
OnStart = start,
OnStart = () =>
{
if (player != null || Beatmap == null)
return;
(player = new PlayerLoader(new Player
{
BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap,
PreferredPlayMode = playMode.Value
})).LoadAsync(Game, l => Push(player));
}
}
};
@ -289,6 +278,7 @@ namespace osu.Game.Screens.Select
{
backgroundModeBeatmap.Beatmap = beatmap;
backgroundModeBeatmap.BlurTo(background_blur, 1000);
backgroundModeBeatmap.FadeTo(1, 250);
}
if (beatmap != null)
@ -341,7 +331,7 @@ namespace osu.Game.Screens.Select
}
}
private void addBeatmapSet(BeatmapSetInfo beatmapSet, BaseGame game, bool select = false)
private void addBeatmapSet(BeatmapSetInfo beatmapSet, Framework.Game game, bool select = false)
{
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.ID);
beatmapSet.Beatmaps.ForEach(b =>
@ -359,12 +349,12 @@ namespace osu.Game.Screens.Select
var group = new BeatmapGroup(beatmap)
{
SelectionChanged = selectionChanged,
StartRequested = b => start()
StartRequested = b => footer.StartButton.TriggerClick()
};
//for the time being, let's completely load the difficulty panels in the background.
//this likely won't scale so well, but allows us to completely async the loading flow.
Task.WhenAll(group.BeatmapPanels.Select(panel => panel.Preload(game))).ContinueWith(task => Schedule(delegate
Task.WhenAll(group.BeatmapPanels.Select(panel => panel.LoadAsync(game))).ContinueWith(task => Schedule(delegate
{
beatmapGroups.Add(group);
@ -381,7 +371,7 @@ namespace osu.Game.Screens.Select
}));
}
private void addBeatmapSets(BaseGame game, CancellationToken token)
private void addBeatmapSets(Framework.Game game, CancellationToken token)
{
foreach (var beatmapSet in database.Query<BeatmapSetInfo>())
{
@ -396,7 +386,7 @@ namespace osu.Game.Screens.Select
switch (args.Key)
{
case Key.Enter:
start();
footer.StartButton.TriggerClick();
return true;
}

View File

@ -1,9 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
@ -16,26 +13,8 @@ namespace osu.Game.Screens.Select
/// <summary>
/// A textbox which holds focus eagerly.
/// </summary>
public class SearchTextBox : OsuTextBox
public class SearchTextBox : FocusedTextBox
{
protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255);
protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255);
public Action Exit;
private bool focus;
public bool HoldFocus
{
get { return focus; }
set
{
focus = value;
if (!focus)
TriggerFocusLost();
}
}
public override bool RequestingFocus => HoldFocus;
public SearchTextBox()
{
Height = 35;
@ -53,25 +32,6 @@ namespace osu.Game.Screens.Select
PlaceholderText = "type to search";
}
protected override bool OnFocus(InputState state)
{
var result = base.OnFocus(state);
BorderThickness = 0;
return result;
}
protected override void OnFocusLost(InputState state)
{
if (state.Keyboard.Keys.Any(key => key == Key.Escape))
{
if (Text.Length > 0)
Text = string.Empty;
else
Exit?.Invoke();
}
base.OnFocusLost(state);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (HandlePendingText(state)) return true;