1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 09:37:24 +08:00

Merge branch 'master' into moreOptionsFromSkin.ini

This commit is contained in:
Dean Herbert 2018-12-12 19:54:56 +09:00 committed by GitHub
commit 3110427eaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 108 additions and 134 deletions

View File

@ -1,111 +1,28 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq; using System.Linq;
using osuTK.Input;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking; using osuTK.Input;
using osu.Game.Skinning;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
public class PlaySongSelect : SongSelect public class PlaySongSelect : SongSelect
{ {
private OsuScreen player;
private readonly ModSelectOverlay modSelect;
protected readonly BeatmapDetailArea BeatmapDetails;
private bool removeAutoModOnResume; private bool removeAutoModOnResume;
private OsuScreen player;
public PlaySongSelect() [BackgroundDependencyLoader]
private void load(OsuColour colours)
{ {
FooterPanels.Add(modSelect = new ModSelectOverlay
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
});
LeftContent.Add(BeatmapDetails = new BeatmapDetailArea
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 10, Right = 5 },
});
BeatmapDetails.Leaderboard.ScoreSelected += s => Push(new Results(s));
}
private SampleChannel sampleConfirm;
[Cached]
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
private readonly Bindable<IEnumerable<Mod>> selectedMods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
[BackgroundDependencyLoader(true)]
private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, SkinManager skins, DialogOverlay dialogOverlay, Bindable<IEnumerable<Mod>> selectedMods)
{
if (selectedMods != null) this.selectedMods.BindTo(selectedMods);
sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
Footer.AddButton(@"mods", colours.Yellow, modSelect, Key.F1, float.MaxValue);
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1);
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2);
BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.fa_pencil, colours.Yellow, () => BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.fa_pencil, colours.Yellow, () =>
{ {
ValidForResume = false; ValidForResume = false;
Edit(); Edit();
}, Key.Number3); }, Key.Number3);
if (dialogOverlay != null)
{
Schedule(() =>
{
// if we have no beatmaps but osu-stable is found, let's prompt the user to import.
if (!beatmaps.GetAllUsableBeatmapSets().Any() && beatmaps.StableInstallationAvailable)
dialogOverlay.Push(new ImportFromStablePopup(() =>
{
beatmaps.ImportFromStableAsync();
skins.ImportFromStableAsync();
}));
});
}
}
protected override void ExitFromBack()
{
if (modSelect.State == Visibility.Visible)
{
modSelect.Hide();
return;
}
base.ExitFromBack();
}
protected override void UpdateBeatmap(WorkingBeatmap beatmap)
{
beatmap.Mods.BindTo(selectedMods);
base.UpdateBeatmap(beatmap);
BeatmapDetails.Beatmap = beatmap;
if (beatmap.Track != null)
beatmap.Track.Looping = true;
} }
protected override void OnResuming(Screen last) protected override void OnResuming(Screen last)
@ -115,38 +32,13 @@ namespace osu.Game.Screens.Select
if (removeAutoModOnResume) if (removeAutoModOnResume)
{ {
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType(); var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType();
modSelect.DeselectTypes(new[] { autoType }, true); ModSelect.DeselectTypes(new[] { autoType }, true);
removeAutoModOnResume = false; removeAutoModOnResume = false;
} }
BeatmapDetails.Leaderboard.RefreshScores();
Beatmap.Value.Track.Looping = true;
base.OnResuming(last); base.OnResuming(last);
} }
protected override void OnSuspending(Screen next)
{
modSelect.Hide();
base.OnSuspending(next);
}
protected override bool OnExiting(Screen next)
{
if (base.OnExiting(next))
return true;
if (Beatmap.Value.Track != null)
Beatmap.Value.Track.Looping = false;
selectedMods.UnbindAll();
Beatmap.Value.Mods.Value = new Mod[] { };
return false;
}
protected override bool OnStart() protected override bool OnStart()
{ {
if (player != null) return false; if (player != null) return false;
@ -157,10 +49,10 @@ namespace osu.Game.Screens.Select
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod(); var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
var autoType = auto.GetType(); var autoType = auto.GetType();
var mods = selectedMods.Value; var mods = SelectedMods.Value;
if (mods.All(m => m.GetType() != autoType)) if (mods.All(m => m.GetType() != autoType))
{ {
selectedMods.Value = mods.Append(auto); SelectedMods.Value = mods.Append(auto);
removeAutoModOnResume = true; removeAutoModOnResume = true;
} }
} }
@ -168,7 +60,7 @@ namespace osu.Game.Screens.Select
Beatmap.Value.Track.Looping = false; Beatmap.Value.Track.Looping = false;
Beatmap.Disabled = true; Beatmap.Disabled = true;
sampleConfirm?.Play(); SampleConfirm?.Play();
LoadComponentAsync(player = new PlayerLoader(new Player()), l => LoadComponentAsync(player = new PlayerLoader(new Player()), l =>
{ {

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using osuTK; using osuTK;
using osuTK.Input; using osuTK.Input;
@ -21,12 +22,15 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Edit; using osu.Game.Screens.Edit;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Screens.Ranking;
using osu.Game.Screens.Select.Options; using osu.Game.Screens.Select.Options;
using osu.Game.Skinning;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
@ -60,29 +64,24 @@ namespace osu.Game.Screens.Select
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(); protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
protected Container LeftContent;
protected readonly BeatmapCarousel Carousel; protected readonly BeatmapCarousel Carousel;
private readonly BeatmapInfoWedge beatmapInfoWedge; private readonly BeatmapInfoWedge beatmapInfoWedge;
private DialogOverlay dialogOverlay; private DialogOverlay dialogOverlay;
private BeatmapManager beatmaps; private BeatmapManager beatmaps;
protected readonly ModSelectOverlay ModSelect;
protected SampleChannel SampleConfirm;
private SampleChannel sampleChangeDifficulty; private SampleChannel sampleChangeDifficulty;
private SampleChannel sampleChangeBeatmap; private SampleChannel sampleChangeBeatmap;
protected readonly BeatmapDetailArea BeatmapDetails;
protected new readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>(); protected new readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
private DependencyContainer dependencies; [Cached]
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) protected readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
{
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs(this);
dependencies.CacheAs(Ruleset);
dependencies.CacheAs<IBindable<RulesetInfo>>(Ruleset);
return dependencies;
}
protected SongSelect() protected SongSelect()
{ {
@ -105,7 +104,7 @@ namespace osu.Game.Screens.Select
} }
} }
}, },
LeftContent = new Container new Container
{ {
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
@ -117,6 +116,11 @@ namespace osu.Game.Screens.Select
Top = wedged_container_size.Y + left_area_padding, Top = wedged_container_size.Y + left_area_padding,
Left = left_area_padding, Left = left_area_padding,
Right = left_area_padding * 2, Right = left_area_padding * 2,
},
Child = BeatmapDetails = new BeatmapDetailArea
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 10, Right = 5 },
} }
}, },
new Container new Container
@ -194,21 +198,36 @@ namespace osu.Game.Screens.Select
OnBack = ExitFromBack, OnBack = ExitFromBack,
}); });
FooterPanels.Add(BeatmapOptions = new BeatmapOptionsOverlay()); FooterPanels.AddRange(new Drawable[]
{
BeatmapOptions = new BeatmapOptionsOverlay(),
ModSelect = new ModSelectOverlay
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
}
});
} }
BeatmapDetails.Leaderboard.ScoreSelected += s => Push(new Results(s));
} }
protected virtual void ExitFromBack() => Exit();
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours) private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins, Bindable<IEnumerable<Mod>> selectedMods)
{ {
if (selectedMods != null)
SelectedMods.BindTo(selectedMods);
if (Footer != null) if (Footer != null)
{ {
Footer.AddButton(@"mods", colours.Yellow, ModSelect, Key.F1);
Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2); Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2);
Footer.AddButton(@"options", colours.Blue, BeatmapOptions, Key.F3); Footer.AddButton(@"options", colours.Blue, BeatmapOptions, Key.F3);
BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.fa_trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue); BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.fa_trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue);
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1);
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2);
} }
if (this.beatmaps == null) if (this.beatmaps == null)
@ -223,8 +242,46 @@ namespace osu.Game.Screens.Select
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty"); sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand"); sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand");
SampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
Carousel.LoadBeatmapSetsFromManager(this.beatmaps); Carousel.LoadBeatmapSetsFromManager(this.beatmaps);
if (dialogOverlay != null)
{
Schedule(() =>
{
// if we have no beatmaps but osu-stable is found, let's prompt the user to import.
if (!beatmaps.GetAllUsableBeatmapSets().Any() && beatmaps.StableInstallationAvailable)
dialogOverlay.Push(new ImportFromStablePopup(() =>
{
beatmaps.ImportFromStableAsync();
skins.ImportFromStableAsync();
}));
});
}
}
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs(this);
dependencies.CacheAs(Ruleset);
dependencies.CacheAs<IBindable<RulesetInfo>>(Ruleset);
return dependencies;
}
protected virtual void ExitFromBack()
{
if (ModSelect.State == Visibility.Visible)
{
ModSelect.Hide();
return;
}
Exit();
} }
public void Edit(BeatmapInfo beatmap = null) public void Edit(BeatmapInfo beatmap = null)
@ -421,6 +478,10 @@ namespace osu.Game.Screens.Select
protected override void OnResuming(Screen last) protected override void OnResuming(Screen last)
{ {
BeatmapDetails.Leaderboard.RefreshScores();
Beatmap.Value.Track.Looping = true;
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending) if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
{ {
UpdateBeatmap(Beatmap.Value); UpdateBeatmap(Beatmap.Value);
@ -438,6 +499,8 @@ namespace osu.Game.Screens.Select
protected override void OnSuspending(Screen next) protected override void OnSuspending(Screen next)
{ {
ModSelect.Hide();
Content.ScaleTo(1.1f, 250, Easing.InSine); Content.ScaleTo(1.1f, 250, Easing.InSine);
Content.FadeOut(250); Content.FadeOut(250);
@ -448,6 +511,12 @@ namespace osu.Game.Screens.Select
protected override bool OnExiting(Screen next) protected override bool OnExiting(Screen next)
{ {
if (ModSelect.State == Visibility.Visible)
{
ModSelect.Hide();
return true;
}
FinaliseSelection(performStartAction: false); FinaliseSelection(performStartAction: false);
beatmapInfoWedge.State = Visibility.Hidden; beatmapInfoWedge.State = Visibility.Hidden;
@ -456,6 +525,12 @@ namespace osu.Game.Screens.Select
FilterControl.Deactivate(); FilterControl.Deactivate();
if (Beatmap.Value.Track != null)
Beatmap.Value.Track.Looping = false;
SelectedMods.UnbindAll();
Beatmap.Value.Mods.Value = new Mod[] { };
return base.OnExiting(next); return base.OnExiting(next);
} }
@ -481,6 +556,8 @@ namespace osu.Game.Screens.Select
/// <param name="beatmap">The working beatmap.</param> /// <param name="beatmap">The working beatmap.</param>
protected virtual void UpdateBeatmap(WorkingBeatmap beatmap) protected virtual void UpdateBeatmap(WorkingBeatmap beatmap)
{ {
beatmap.Mods.BindTo(SelectedMods);
Logger.Log($"working beatmap updated to {beatmap}"); Logger.Log($"working beatmap updated to {beatmap}");
if (Background is BackgroundScreenBeatmap backgroundModeBeatmap) if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)
@ -491,6 +568,11 @@ namespace osu.Game.Screens.Select
} }
beatmapInfoWedge.Beatmap = beatmap; beatmapInfoWedge.Beatmap = beatmap;
BeatmapDetails.Beatmap = beatmap;
if (beatmap.Track != null)
beatmap.Track.Looping = true;
} }
private void ensurePlayingSelected(bool preview = false) private void ensurePlayingSelected(bool preview = false)