Merge branch 'master' into parser-sanity-checks

This commit is contained in:
Dean Herbert 2018-03-01 00:38:44 +09:00 committed by GitHub
commit e2f57ae346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 73 additions and 27 deletions

@ -1 +1 @@
Subproject commit 500a791577979669e47eece699d5bd8b9068ee4b Subproject commit e8ae207769ec26fb7ddd67a2433514fcda354ecd

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
namespace osu.Game.Rulesets.Osu.Mods namespace osu.Game.Rulesets.Osu.Mods
@ -25,7 +26,10 @@ namespace osu.Game.Rulesets.Osu.Mods
foreach (var d in drawables.OfType<DrawableOsuHitObject>()) foreach (var d in drawables.OfType<DrawableOsuHitObject>())
{ {
d.ApplyCustomUpdateState += ApplyHiddenState; d.ApplyCustomUpdateState += ApplyHiddenState;
d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier;
foreach (var h in d.HitObject.NestedHitObjects.OfType<OsuHitObject>())
h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier;
} }
} }
@ -34,16 +38,19 @@ namespace osu.Game.Rulesets.Osu.Mods
if (!(drawable is DrawableOsuHitObject d)) if (!(drawable is DrawableOsuHitObject d))
return; return;
var fadeOutStartTime = d.HitObject.StartTime - d.HitObject.TimePreempt + d.HitObject.TimeFadein; var h = d.HitObject;
var fadeOutDuration = d.HitObject.TimePreempt * fade_out_duration_multiplier;
var fadeOutStartTime = h.StartTime - h.TimePreempt + h.TimeFadein;
var fadeOutDuration = h.TimePreempt * fade_out_duration_multiplier;
// new duration from completed fade in to end (before fading out) // new duration from completed fade in to end (before fading out)
var longFadeDuration = ((d.HitObject as IHasEndTime)?.EndTime ?? d.HitObject.StartTime) - fadeOutStartTime; var longFadeDuration = ((h as IHasEndTime)?.EndTime ?? h.StartTime) - fadeOutStartTime;
switch (drawable) switch (drawable)
{ {
case DrawableHitCircle circle: case DrawableHitCircle circle:
// we don't want to see the approach circle // we don't want to see the approach circle
using (circle.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true))
circle.ApproachCircle.Hide(); circle.ApproachCircle.Hide();
// fade out immediately after fade in. // fade out immediately after fade in.

View File

@ -207,6 +207,12 @@ namespace osu.Game.Tests.Visual
checkVisibleItemCount(true, 0); checkVisibleItemCount(true, 0);
AddAssert("Selection is null", () => currentSelection == null); AddAssert("Selection is null", () => currentSelection == null);
advanceSelection(true);
AddAssert("Selection is null", () => currentSelection == null);
advanceSelection(false);
AddAssert("Selection is null", () => currentSelection == null);
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false)); AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
AddAssert("Selection is non-null", () => currentSelection != null); AddAssert("Selection is non-null", () => currentSelection != null);

View File

@ -14,7 +14,9 @@ namespace osu.Game.Graphics.Containers
{ {
public class ParallaxContainer : Container, IRequireHighFrequencyMousePosition public class ParallaxContainer : Container, IRequireHighFrequencyMousePosition
{ {
public float ParallaxAmount = 0.02f; public const float DEFAULT_PARALLAX_AMOUNT = 0.02f;
public float ParallaxAmount = DEFAULT_PARALLAX_AMOUNT;
private Bindable<bool> parallaxEnabled; private Bindable<bool> parallaxEnabled;

View File

@ -65,6 +65,14 @@ namespace osu.Game.Overlays.Mods
Ruleset.TriggerChange(); Ruleset.TriggerChange();
} }
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
Ruleset.UnbindAll();
SelectedMods.UnbindAll();
}
private void selectedModsChanged(IEnumerable<Mod> obj) private void selectedModsChanged(IEnumerable<Mod> obj)
{ {
foreach (ModSection section in ModSectionsContainer.Children) foreach (ModSection section in ModSectionsContainer.Children)

View File

@ -52,6 +52,10 @@ namespace osu.Game.Screens
protected readonly Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>(); protected readonly Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
protected virtual float BackgroundParallaxAmount => 1;
private ParallaxContainer backgroundParallaxContainer;
public WorkingBeatmap InitialBeatmap public WorkingBeatmap InitialBeatmap
{ {
set set
@ -102,11 +106,10 @@ namespace osu.Game.Screens
protected override void OnResuming(Screen last) protected override void OnResuming(Screen last)
{ {
base.OnResuming(last);
logo.AppendAnimatingAction(() => LogoArriving(logo, true), true);
sampleExit?.Play(); sampleExit?.Play();
applyArrivingDefaults(true);
ShowOverlays.Value = ShowOverlaysOnEnter; base.OnResuming(last);
} }
protected override void OnSuspending(Screen next) protected override void OnSuspending(Screen next)
@ -123,6 +126,8 @@ namespace osu.Game.Screens
if (lastOsu?.Background != null) if (lastOsu?.Background != null)
{ {
backgroundParallaxContainer = lastOsu.backgroundParallaxContainer;
if (bg == null || lastOsu.Background.Equals(bg)) if (bg == null || lastOsu.Background.Equals(bg))
//we can keep the previous mode's background. //we can keep the previous mode's background.
Background = lastOsu.Background; Background = lastOsu.Background;
@ -136,7 +141,7 @@ namespace osu.Game.Screens
// this makes up for the fact our padding changes when the global toolbar is visible. // this makes up for the fact our padding changes when the global toolbar is visible.
bg.Scale = new Vector2(1.06f); bg.Scale = new Vector2(1.06f);
AddInternal(new ParallaxContainer AddInternal(backgroundParallaxContainer = new ParallaxContainer
{ {
Depth = float.MaxValue, Depth = float.MaxValue,
Children = new[] Children = new[]
@ -149,11 +154,9 @@ namespace osu.Game.Screens
if ((logo = lastOsu?.logo) == null) if ((logo = lastOsu?.logo) == null)
LoadComponentAsync(logo = new OsuLogo { Alpha = 0 }, AddInternal); LoadComponentAsync(logo = new OsuLogo { Alpha = 0 }, AddInternal);
logo.AppendAnimatingAction(() => LogoArriving(logo, false), true); applyArrivingDefaults(false);
base.OnEntering(last); base.OnEntering(last);
ShowOverlays.Value = ShowOverlaysOnEnter;
} }
protected override bool OnExiting(Screen next) protected override bool OnExiting(Screen next)
@ -193,6 +196,16 @@ namespace osu.Game.Screens
logo.Ripple = true; logo.Ripple = true;
} }
private void applyArrivingDefaults(bool isResuming)
{
logo.AppendAnimatingAction(() => LogoArriving(logo, isResuming), true);
if (backgroundParallaxContainer != null)
backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount;
ShowOverlays.Value = ShowOverlaysOnEnter;
}
private void onExitingLogo() private void onExitingLogo()
{ {
logo.AppendAnimatingAction(() => { LogoExiting(logo); }, false); logo.AppendAnimatingAction(() => { LogoExiting(logo); }, false);

View File

@ -37,6 +37,8 @@ namespace osu.Game.Screens.Play
{ {
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
protected override float BackgroundParallaxAmount => 0.1f;
public override bool ShowOverlaysOnEnter => false; public override bool ShowOverlaysOnEnter => false;
public Action RestartRequested; public Action RestartRequested;
@ -351,7 +353,7 @@ namespace osu.Game.Screens.Play
protected override bool OnExiting(Screen next) protected override bool OnExiting(Screen next)
{ {
if ((!AllowPause || HasFailed || !ValidForResume || pauseContainer?.IsPaused != false || RulesetContainer?.HasReplayLoaded != false) && (!pauseContainer?.IsResuming ?? false)) if ((!AllowPause || HasFailed || !ValidForResume || pauseContainer?.IsPaused != false || RulesetContainer?.HasReplayLoaded != false) && (!pauseContainer?.IsResuming ?? true))
{ {
// In the case of replays, we may have changed the playback rate. // In the case of replays, we may have changed the playback rate.
applyRateFromMods(); applyRateFromMods();

View File

@ -192,7 +192,9 @@ namespace osu.Game.Screens.Select
/// <param name="skipDifficulties">Whether to skip individual difficulties and only increment over full groups.</param> /// <param name="skipDifficulties">Whether to skip individual difficulties and only increment over full groups.</param>
public void SelectNext(int direction = 1, bool skipDifficulties = true) public void SelectNext(int direction = 1, bool skipDifficulties = true)
{ {
if (!Items.Any()) var visibleItems = Items.Where(s => !s.Item.Filtered).ToList();
if (!visibleItems.Any())
return; return;
DrawableCarouselItem drawable = null; DrawableCarouselItem drawable = null;
@ -202,15 +204,15 @@ namespace osu.Game.Screens.Select
// we can fix this by changing this method to not reference drawables / Items in the first place. // we can fix this by changing this method to not reference drawables / Items in the first place.
return; return;
int originalIndex = Items.IndexOf(drawable); int originalIndex = visibleItems.IndexOf(drawable);
int currentIndex = originalIndex; int currentIndex = originalIndex;
// local function to increment the index in the required direction, wrapping over extremities. // local function to increment the index in the required direction, wrapping over extremities.
int incrementIndex() => currentIndex = (currentIndex + direction + Items.Count) % Items.Count; int incrementIndex() => currentIndex = (currentIndex + direction + visibleItems.Count) % visibleItems.Count;
while (incrementIndex() != originalIndex) while (incrementIndex() != originalIndex)
{ {
var item = Items[currentIndex].Item; var item = visibleItems[currentIndex].Item;
if (item.Filtered || item.State == CarouselItemState.Selected) continue; if (item.Filtered || item.State == CarouselItemState.Selected) continue;

View File

@ -1,11 +1,13 @@
// 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 OpenTK.Input; using OpenTK.Input;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Screens; using osu.Framework.Screens;
@ -47,13 +49,15 @@ namespace osu.Game.Screens.Select
private SampleChannel sampleConfirm; private SampleChannel sampleConfirm;
[BackgroundDependencyLoader(true)] public readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(new List<Mod>());
private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, OsuGame game)
{
sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
if (game != null) [BackgroundDependencyLoader(true)]
modSelect.SelectedMods.BindTo(game.SelectedMods); private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, OsuGame osu)
{
if (osu != null) SelectedMods.BindTo(osu.SelectedMods);
modSelect.SelectedMods.BindTo(SelectedMods);
sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
Footer.AddButton(@"mods", colours.Yellow, modSelect, Key.F1, float.MaxValue); Footer.AddButton(@"mods", colours.Yellow, modSelect, Key.F1, float.MaxValue);
@ -80,7 +84,7 @@ namespace osu.Game.Screens.Select
{ {
base.UpdateBeatmap(beatmap); base.UpdateBeatmap(beatmap);
beatmap.Mods.BindTo(modSelect.SelectedMods); beatmap.Mods.BindTo(SelectedMods);
BeatmapDetails.Beatmap = beatmap; BeatmapDetails.Beatmap = beatmap;
@ -95,7 +99,7 @@ namespace osu.Game.Screens.Select
if (removeAutoModOnResume) if (removeAutoModOnResume)
{ {
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType(); var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType();
modSelect.SelectedMods.Value = modSelect.SelectedMods.Value.Where(m => m.GetType() != autoType).ToArray(); SelectedMods.Value = SelectedMods.Value.Where(m => m.GetType() != autoType).ToArray();
removeAutoModOnResume = false; removeAutoModOnResume = false;
} }
@ -125,7 +129,7 @@ namespace osu.Game.Screens.Select
if (Beatmap.Value.Track != null) if (Beatmap.Value.Track != null)
Beatmap.Value.Track.Looping = false; Beatmap.Value.Track.Looping = false;
Beatmap.Value.Mods.UnbindBindings(); SelectedMods.UnbindAll();
Beatmap.Value.Mods.Value = new Mod[] { }; Beatmap.Value.Mods.Value = new Mod[] { };
return false; return false;

View File

@ -386,6 +386,8 @@ namespace osu.Game.Screens.Select
protected override bool OnExiting(Screen next) protected override bool OnExiting(Screen next)
{ {
FinaliseSelection();
beatmapInfoWedge.State = Visibility.Hidden; beatmapInfoWedge.State = Visibility.Hidden;
Content.FadeOut(100); Content.FadeOut(100);