Merge branch 'master' into add-perfect-mod-icon

This commit is contained in:
Dan Balasescu 2018-03-23 21:32:15 +09:00 committed by GitHub
commit 1576b31a48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 115 additions and 85 deletions

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Skinning;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -82,7 +83,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
public class OsuCursor : Container public class OsuCursor : Container
{ {
private Container cursorContainer; private Drawable cursorContainer;
private Bindable<double> cursorScale; private Bindable<double> cursorScale;
private Bindable<bool> autoCursorScale; private Bindable<bool> autoCursorScale;
@ -97,66 +98,66 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config, OsuGameBase game) private void load(OsuConfigManager config, OsuGameBase game)
{ {
Children = new Drawable[] Child = cursorContainer = new SkinnableDrawable("cursor", _ => new CircularContainer
{ {
cursorContainer = new CircularContainer RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = Size.X / 6,
BorderColour = Color4.White,
EdgeEffect = new EdgeEffectParameters
{ {
Origin = Anchor.Centre, Type = EdgeEffectType.Shadow,
Anchor = Anchor.Centre, Colour = Color4.Pink.Opacity(0.5f),
RelativeSizeAxes = Axes.Both, Radius = 5,
Masking = true,
BorderThickness = Size.X / 6,
BorderColour = Color4.White,
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Colour = Color4.Pink.Opacity(0.5f),
Radius = 5,
},
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
},
new CircularContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = Size.X / 3,
BorderColour = Color4.White.Opacity(0.5f),
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
},
},
},
new CircularContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0.1f),
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
},
},
},
}
}, },
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
},
new CircularContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = Size.X / 3,
BorderColour = Color4.White.Opacity(0.5f),
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
},
},
},
new CircularContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0.1f),
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
},
},
},
}
}, restrictSize: false)
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
}; };
beatmap = game.Beatmap.GetBoundCopy(); beatmap = game.Beatmap.GetBoundCopy();

View File

@ -4,9 +4,6 @@
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Input; using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
@ -30,7 +27,6 @@ namespace osu.Game.Overlays.Mods
private ModIcon backgroundIcon; private ModIcon backgroundIcon;
private readonly SpriteText text; private readonly SpriteText text;
private readonly Container<ModIcon> iconsContainer; private readonly Container<ModIcon> iconsContainer;
private SampleChannel sampleOn, sampleOff;
/// <summary> /// <summary>
/// Fired when the selection changes. /// Fired when the selection changes.
@ -100,7 +96,6 @@ namespace osu.Game.Overlays.Mods
foregroundIcon.Highlighted = Selected; foregroundIcon.Highlighted = Selected;
(selectedIndex == -1 ? sampleOff : sampleOn).Play();
SelectionChanged?.Invoke(SelectedMod); SelectionChanged?.Invoke(SelectedMod);
return true; return true;
} }
@ -152,13 +147,6 @@ namespace osu.Game.Overlays.Mods
public virtual Mod SelectedMod => Mods.ElementAtOrDefault(selectedIndex); public virtual Mod SelectedMod => Mods.ElementAtOrDefault(selectedIndex);
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleOn = audio.Sample.Get(@"UI/check-on");
sampleOff = audio.Sample.Get(@"UI/check-off");
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{ {
switch (args.Button) switch (args.Button)

View File

@ -15,6 +15,8 @@ using osu.Game.Rulesets.Mods;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
@ -49,7 +51,7 @@ namespace osu.Game.Overlays.Mods
} }
[BackgroundDependencyLoader(permitNulls: true)] [BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuColour colours, OsuGame osu, RulesetStore rulesets) private void load(OsuColour colours, OsuGame osu, RulesetStore rulesets, AudioManager audio)
{ {
SelectedMods.ValueChanged += selectedModsChanged; SelectedMods.ValueChanged += selectedModsChanged;
@ -63,6 +65,9 @@ namespace osu.Game.Overlays.Mods
Ruleset.ValueChanged += rulesetChanged; Ruleset.ValueChanged += rulesetChanged;
Ruleset.TriggerChange(); Ruleset.TriggerChange();
sampleOn = audio.Sample.Get(@"UI/check-on");
sampleOff = audio.Sample.Get(@"UI/check-off");
} }
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
@ -154,10 +159,21 @@ namespace osu.Game.Overlays.Mods
section.DeselectTypes(modTypes, immediate); section.DeselectTypes(modTypes, immediate);
} }
private SampleChannel sampleOn, sampleOff;
private void modButtonPressed(Mod selectedMod) private void modButtonPressed(Mod selectedMod)
{ {
if (selectedMod != null) if (selectedMod != null)
{
if (State == Visibility.Visible) sampleOn?.Play();
DeselectTypes(selectedMod.IncompatibleMods, true); DeselectTypes(selectedMod.IncompatibleMods, true);
}
else
{
if (State == Visibility.Visible) sampleOff?.Play();
}
refreshSelectedMods(); refreshSelectedMods();
} }

View File

@ -12,6 +12,7 @@ using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.MathUtils;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
@ -93,19 +94,25 @@ namespace osu.Game.Overlays.Volume
Colour = colours.Gray2, Colour = colours.Gray2,
Size = new Vector2(0.8f) Size = new Vector2(0.8f)
}, },
(volumeCircle = new CircularProgress new Container
{ {
RelativeSizeAxes = Axes.Both,
InnerRadius = 0.05f,
Rotation = 180,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = new Vector2(0.8f) RelativeSizeAxes = Axes.Both,
}).WithEffect(new GlowEffect Size = new Vector2(0.8f),
{ Padding = new MarginPadding(-Blur.KernelSize(5)),
Colour = meterColour, Rotation = 180,
Strength = 2 Child = (volumeCircle = new CircularProgress
}), {
RelativeSizeAxes = Axes.Both,
InnerRadius = 0.05f,
}).WithEffect(new GlowEffect
{
Colour = meterColour,
Strength = 2,
PadExtent = true
}),
},
maxGlow = (text = new OsuSpriteText maxGlow = (text = new OsuSpriteText
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,

View File

@ -1,6 +1,7 @@
// 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.Threading.Tasks;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -27,6 +28,8 @@ namespace osu.Game.Screens.Play
private bool showOverlays = true; private bool showOverlays = true;
public override bool ShowOverlaysOnEnter => showOverlays; public override bool ShowOverlaysOnEnter => showOverlays;
private Task loadTask;
public PlayerLoader(Player player) public PlayerLoader(Player player)
{ {
this.player = player; this.player = player;
@ -55,7 +58,7 @@ namespace osu.Game.Screens.Play
Margin = new MarginPadding(25) Margin = new MarginPadding(25)
}); });
LoadComponentAsync(player); loadTask = LoadComponentAsync(player);
} }
protected override void OnResuming(Screen last) protected override void OnResuming(Screen last)
@ -65,7 +68,7 @@ namespace osu.Game.Screens.Play
contentIn(); contentIn();
//we will only be resumed if the player has requested a re-run (see ValidForResume setting above) //we will only be resumed if the player has requested a re-run (see ValidForResume setting above)
LoadComponentAsync(player = new Player loadTask = LoadComponentAsync(player = new Player
{ {
RestartCount = player.RestartCount + 1, RestartCount = player.RestartCount + 1,
RestartRequested = player.RestartRequested, RestartRequested = player.RestartRequested,
@ -154,6 +157,8 @@ namespace osu.Game.Screens.Play
{ {
if (!IsCurrentScreen) return; if (!IsCurrentScreen) return;
loadTask = null;
if (!Push(player)) if (!Push(player))
Exit(); Exit();
else else
@ -192,6 +197,14 @@ namespace osu.Game.Screens.Play
return base.OnExiting(next); return base.OnExiting(next);
} }
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
// if the player never got pushed, we should explicitly dispose it.
loadTask?.ContinueWith(_ => player.Dispose());
}
private class BeatmapMetadataDisplay : Container private class BeatmapMetadataDisplay : Container
{ {
private class MetadataLine : Container private class MetadataLine : Container

View File

@ -328,7 +328,10 @@ namespace osu.Game.Screens.Select
public void FlushPendingFilterOperations() public void FlushPendingFilterOperations()
{ {
if (FilterTask?.Completed == false) if (FilterTask?.Completed == false)
{
applyActiveCriteria(false, false); applyActiveCriteria(false, false);
Update();
}
} }
public void Filter(FilterCriteria newCriteria, bool debounce = true) public void Filter(FilterCriteria newCriteria, bool debounce = true)

View File

@ -48,13 +48,15 @@ namespace osu.Game.Skinning
this.source = source; this.source = source;
} }
private void onSourceChanged() => SourceChanged?.Invoke();
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
{ {
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
fallbackSource = dependencies.Get<ISkinSource>(); fallbackSource = dependencies.Get<ISkinSource>();
if (fallbackSource != null) if (fallbackSource != null)
fallbackSource.SourceChanged += () => SourceChanged?.Invoke(); fallbackSource.SourceChanged += onSourceChanged;
dependencies.CacheAs<ISkinSource>(this); dependencies.CacheAs<ISkinSource>(this);
@ -66,7 +68,7 @@ namespace osu.Game.Skinning
base.Dispose(isDisposing); base.Dispose(isDisposing);
if (fallbackSource != null) if (fallbackSource != null)
fallbackSource.SourceChanged -= SourceChanged; fallbackSource.SourceChanged -= onSourceChanged;
} }
} }
} }