1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 00:07:26 +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>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq;
using osuTK.Input;
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.Game.Beatmaps;
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.Ranking;
using osu.Game.Skinning;
using osuTK.Input;
namespace osu.Game.Screens.Select
{
public class PlaySongSelect : SongSelect
{
private OsuScreen player;
private readonly ModSelectOverlay modSelect;
protected readonly BeatmapDetailArea BeatmapDetails;
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, () =>
{
ValidForResume = false;
Edit();
}, 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)
@ -115,38 +32,13 @@ namespace osu.Game.Screens.Select
if (removeAutoModOnResume)
{
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType();
modSelect.DeselectTypes(new[] { autoType }, true);
ModSelect.DeselectTypes(new[] { autoType }, true);
removeAutoModOnResume = false;
}
BeatmapDetails.Leaderboard.RefreshScores();
Beatmap.Value.Track.Looping = true;
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()
{
if (player != null) return false;
@ -157,10 +49,10 @@ namespace osu.Game.Screens.Select
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
var autoType = auto.GetType();
var mods = selectedMods.Value;
var mods = SelectedMods.Value;
if (mods.All(m => m.GetType() != autoType))
{
selectedMods.Value = mods.Append(auto);
SelectedMods.Value = mods.Append(auto);
removeAutoModOnResume = true;
}
}
@ -168,7 +60,7 @@ namespace osu.Game.Screens.Select
Beatmap.Value.Track.Looping = false;
Beatmap.Disabled = true;
sampleConfirm?.Play();
SampleConfirm?.Play();
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
using System;
using System.Collections.Generic;
using System.Linq;
using osuTK;
using osuTK.Input;
@ -21,12 +22,15 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Ranking;
using osu.Game.Screens.Select.Options;
using osu.Game.Skinning;
namespace osu.Game.Screens.Select
{
@ -60,29 +64,24 @@ namespace osu.Game.Screens.Select
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
protected Container LeftContent;
protected readonly BeatmapCarousel Carousel;
private readonly BeatmapInfoWedge beatmapInfoWedge;
private DialogOverlay dialogOverlay;
private BeatmapManager beatmaps;
protected readonly ModSelectOverlay ModSelect;
protected SampleChannel SampleConfirm;
private SampleChannel sampleChangeDifficulty;
private SampleChannel sampleChangeBeatmap;
protected readonly BeatmapDetailArea BeatmapDetails;
protected new readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
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;
}
[Cached]
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
protected readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
protected SongSelect()
{
@ -105,7 +104,7 @@ namespace osu.Game.Screens.Select
}
}
},
LeftContent = new Container
new Container
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
@ -117,6 +116,11 @@ namespace osu.Game.Screens.Select
Top = wedged_container_size.Y + left_area_padding,
Left = left_area_padding,
Right = left_area_padding * 2,
},
Child = BeatmapDetails = new BeatmapDetailArea
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 10, Right = 5 },
}
},
new Container
@ -194,21 +198,36 @@ namespace osu.Game.Screens.Select
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)]
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)
{
Footer.AddButton(@"mods", colours.Yellow, ModSelect, Key.F1);
Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2);
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(@"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)
@ -223,8 +242,46 @@ namespace osu.Game.Screens.Select
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand");
SampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
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)
@ -421,6 +478,10 @@ namespace osu.Game.Screens.Select
protected override void OnResuming(Screen last)
{
BeatmapDetails.Leaderboard.RefreshScores();
Beatmap.Value.Track.Looping = true;
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
{
UpdateBeatmap(Beatmap.Value);
@ -438,6 +499,8 @@ namespace osu.Game.Screens.Select
protected override void OnSuspending(Screen next)
{
ModSelect.Hide();
Content.ScaleTo(1.1f, 250, Easing.InSine);
Content.FadeOut(250);
@ -448,6 +511,12 @@ namespace osu.Game.Screens.Select
protected override bool OnExiting(Screen next)
{
if (ModSelect.State == Visibility.Visible)
{
ModSelect.Hide();
return true;
}
FinaliseSelection(performStartAction: false);
beatmapInfoWedge.State = Visibility.Hidden;
@ -456,6 +525,12 @@ namespace osu.Game.Screens.Select
FilterControl.Deactivate();
if (Beatmap.Value.Track != null)
Beatmap.Value.Track.Looping = false;
SelectedMods.UnbindAll();
Beatmap.Value.Mods.Value = new Mod[] { };
return base.OnExiting(next);
}
@ -481,6 +556,8 @@ namespace osu.Game.Screens.Select
/// <param name="beatmap">The working beatmap.</param>
protected virtual void UpdateBeatmap(WorkingBeatmap beatmap)
{
beatmap.Mods.BindTo(SelectedMods);
Logger.Log($"working beatmap updated to {beatmap}");
if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)
@ -491,6 +568,11 @@ namespace osu.Game.Screens.Select
}
beatmapInfoWedge.Beatmap = beatmap;
BeatmapDetails.Beatmap = beatmap;
if (beatmap.Track != null)
beatmap.Track.Looping = true;
}
private void ensurePlayingSelected(bool preview = false)