From c4e5eac35ba1ed6454c1755b2ea82b30015c7b53 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 18:38:06 +0800 Subject: [PATCH] Move footer stuff to derived. --- osu.Game/Screens/Select/PlaySongSelect.cs | 29 +++++++++++++++++++++ osu.Game/Screens/Select/SongSelect.cs | 31 +++++------------------ 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 13395e52c2..ea453a997c 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -1,8 +1,14 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Input; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; using osu.Framework.Screens; using osu.Game.Beatmaps; +using osu.Game.Graphics; +using osu.Game.Overlays.Mods; using osu.Game.Screens.Play; namespace osu.Game.Screens.Select @@ -10,6 +16,29 @@ namespace osu.Game.Screens.Select public class PlaySongSelect : SongSelect { private OsuScreen player; + private ModSelectOverlay modSelect; + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Add(modSelect = new ModSelectOverlay + { + RelativeSizeAxes = Axes.X, + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + Margin = new MarginPadding { Bottom = 50 } + }); + + Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1); + Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2); + Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); + } + + protected override void OnBeatmapChanged(WorkingBeatmap beatmap) + { + beatmap?.Mods.BindTo(modSelect.SelectedMods); + base.OnBeatmapChanged(beatmap); + } protected override void OnResuming(Screen last) { diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 6bddebbdb2..e4d2ff9de1 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -27,9 +27,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Modes; using osu.Game.Overlays; -using osu.Game.Overlays.Mods; using osu.Game.Screens.Backgrounds; -using osu.Game.Screens.Play; using osu.Game.Screens.Select.Options; namespace osu.Game.Screens.Select @@ -47,8 +45,6 @@ namespace osu.Game.Screens.Select private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 225); private BeatmapInfoWedge beatmapInfoWedge; - private ModSelectOverlay modSelect; - private static readonly Vector2 background_blur = new Vector2(20); private CancellationTokenSource initialAddSetsTask; @@ -57,8 +53,8 @@ namespace osu.Game.Screens.Select private List beatmapGroups; - private BeatmapOptionsOverlay beatmapOptions; - private Footer footer; + protected BeatmapOptionsOverlay BeatmapOptions { get; private set; } + protected Footer Footer { get; private set; } private FilterControl filter; public FilterControl Filter @@ -130,7 +126,7 @@ namespace osu.Game.Screens.Select }, X = -50, }, - beatmapOptions = new BeatmapOptionsOverlay + BeatmapOptions = new BeatmapOptionsOverlay { OnRemoveFromUnplayed = null, OnClearLocalScores = null, @@ -141,17 +137,7 @@ namespace osu.Game.Screens.Select Bottom = 50, }, }, - modSelect = new ModSelectOverlay - { - RelativeSizeAxes = Axes.X, - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, - Margin = new MarginPadding - { - Bottom = 50, - }, - }, - footer = new Footer + Footer = new Footer { OnBack = Exit, OnStart = () => @@ -164,10 +150,6 @@ namespace osu.Game.Screens.Select }, }; - footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1); - footer.AddButton(@"random", colours.Green, carousel.SelectRandom, Key.F2); - footer.AddButton(@"options", colours.Blue, beatmapOptions.ToggleVisibility, Key.F3); - if (osu != null) playMode.BindTo(osu.PlayMode); playMode.ValueChanged += playMode_ValueChanged; @@ -189,6 +171,7 @@ namespace osu.Game.Screens.Select Task.Factory.StartNew(() => addBeatmapSets(game, initialAddSetsTask.Token), initialAddSetsTask.Token); } + public void SelectRandom() => carousel.SelectRandom(); protected abstract void OnSelected(WorkingBeatmap beatmap); private ScheduledDelegate filterTask; @@ -329,8 +312,6 @@ namespace osu.Game.Screens.Select { base.OnBeatmapChanged(beatmap); - beatmap?.Mods.BindTo(modSelect.SelectedMods); - //todo: change background in selectionChanged instead; support per-difficulty backgrounds. changeBackground(beatmap); carousel.SelectBeatmap(beatmap?.BeatmapInfo); @@ -382,7 +363,7 @@ namespace osu.Game.Screens.Select var group = new BeatmapGroup(beatmapSet, database) { SelectionChanged = selectionChanged, - StartRequested = b => footer.StartButton.TriggerClick() + StartRequested = b => Footer.StartButton.TriggerClick() }; //for the time being, let's completely load the difficulty panels in the background.