1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 17:03:21 +08:00

Merge branch 'master' into menu-mvvm

This commit is contained in:
Dean Herbert 2017-08-29 15:57:19 +09:00
commit e53f2cb359
5 changed files with 45 additions and 55 deletions

View File

@ -226,9 +226,21 @@ namespace osu.Game
dependencies.Cache(notificationOverlay); dependencies.Cache(notificationOverlay);
dependencies.Cache(dialogOverlay); dependencies.Cache(dialogOverlay);
// ensure both overlays aren't presented at the same time // ensure only one of these overlays are open at once.
chat.StateChanged += (container, state) => social.State = state == Visibility.Visible ? Visibility.Hidden : social.State; var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct };
social.StateChanged += (container, state) => chat.State = state == Visibility.Visible ? Visibility.Hidden : chat.State; foreach (var overlay in singleDisplayOverlays)
{
overlay.StateChanged += (container, state) =>
{
if (state == Visibility.Hidden) return;
foreach (var c in singleDisplayOverlays)
{
if (c == container) continue;
c.State = Visibility.Hidden;
}
};
}
LoadComponentAsync(Toolbar = new Toolbar LoadComponentAsync(Toolbar = new Toolbar
{ {

View File

@ -152,14 +152,10 @@ namespace osu.Game
Beatmap.ValueChanged += b => Beatmap.ValueChanged += b =>
{ {
// compare to last baetmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo) // compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo)
if (lastBeatmap?.Track != b.Track) if (lastBeatmap?.Track != b.Track)
{ {
// this disposal is done to stop the audio track. lastBeatmap?.Track?.Dispose();
// it may not be exactly what we want for cases beatmaps are reused, as it will
// trigger a fresh load of contained resources.
lastBeatmap?.Dispose();
Audio.Track.AddItem(b.Track); Audio.Track.AddItem(b.Track);
} }

View File

@ -11,14 +11,12 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.MathUtils;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Framework.Logging; using osu.Framework.Logging;
@ -49,6 +47,23 @@ namespace osu.Game.Overlays.Direct
SetInfo = setInfo; SetInfo = setInfo;
} }
private readonly EdgeEffectParameters edgeEffectNormal = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(0f, 1f),
Radius = 2f,
Colour = Color4.Black.Opacity(0.25f),
};
private readonly EdgeEffectParameters edgeEffectHovered = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(0f, 5f),
Radius = 10f,
Colour = Color4.Black.Opacity(0.3f),
};
[BackgroundDependencyLoader(permitNulls: true)] [BackgroundDependencyLoader(permitNulls: true)]
private void load(APIAccess api, BeatmapManager beatmaps, OsuColour colours, NotificationOverlay notifications) private void load(APIAccess api, BeatmapManager beatmaps, OsuColour colours, NotificationOverlay notifications)
{ {
@ -60,13 +75,7 @@ namespace osu.Game.Overlays.Direct
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Masking = true, Masking = true,
EdgeEffect = new EdgeEffectParameters EdgeEffect = edgeEffectNormal,
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(0f, 1f),
Radius = 2f,
Colour = Color4.Black.Opacity(0.25f),
},
Children = new[] Children = new[]
{ {
// temporary blackness until the actual background loads. // temporary blackness until the actual background loads.
@ -92,8 +101,7 @@ namespace osu.Game.Overlays.Direct
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)
{ {
content.FadeEdgeEffectTo(1f, hover_transition_time, Easing.OutQuint); content.TweenEdgeEffectTo(edgeEffectHovered, hover_transition_time, Easing.OutQuint);
content.TransformTo(content.PopulateTransform(new TransformEdgeEffectRadius(), 14, hover_transition_time, Easing.OutQuint));
content.MoveToY(-4, hover_transition_time, Easing.OutQuint); content.MoveToY(-4, hover_transition_time, Easing.OutQuint);
return base.OnHover(state); return base.OnHover(state);
@ -101,8 +109,7 @@ namespace osu.Game.Overlays.Direct
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(InputState state)
{ {
content.FadeEdgeEffectTo(0.25f, hover_transition_time, Easing.OutQuint); content.TweenEdgeEffectTo(edgeEffectNormal, hover_transition_time, Easing.OutQuint);
content.TransformTo(content.PopulateTransform(new TransformEdgeEffectRadius(), 2, hover_transition_time, Easing.OutQuint));
content.MoveToY(0, hover_transition_time, Easing.OutQuint); content.MoveToY(0, hover_transition_time, Easing.OutQuint);
base.OnHoverLost(state); base.OnHoverLost(state);
@ -278,30 +285,5 @@ namespace osu.Game.Overlays.Direct
Value = value; Value = value;
} }
} }
private class TransformEdgeEffectRadius : Transform<float, Container>
{
/// <summary>
/// Current value of the transformed colour in linear colour space.
/// </summary>
private float valueAt(double time)
{
if (time < StartTime) return StartValue;
if (time >= EndTime) return EndValue;
return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
}
public override string TargetMember => "EdgeEffect.Colour";
protected override void Apply(Container c, double time)
{
EdgeEffectParameters e = c.EdgeEffect;
e.Radius = valueAt(time);
c.EdgeEffect = e;
}
protected override void ReadIntoStartValue(Container d) => StartValue = d.EdgeEffect.Radius;
}
} }
} }

View File

@ -122,14 +122,14 @@ namespace osu.Game.Overlays.KeyBinding
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)
{ {
this.FadeEdgeEffectTo<Container>(1, transition_time, Easing.OutQuint); FadeEdgeEffectTo(1, transition_time, Easing.OutQuint);
return base.OnHover(state); return base.OnHover(state);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(InputState state)
{ {
this.FadeEdgeEffectTo<Container>(0, transition_time, Easing.OutQuint); FadeEdgeEffectTo(0, transition_time, Easing.OutQuint);
base.OnHoverLost(state); base.OnHoverLost(state);
} }

View File

@ -348,23 +348,23 @@ namespace osu.Game.Overlays
playerContainer.Add(new AsyncLoadWrapper(new Background(beatmap) playerContainer.Add(new AsyncLoadWrapper(new Background(beatmap)
{ {
OnLoadComplete = d => OnLoadComplete = newBackground =>
{ {
switch (direction) switch (direction)
{ {
case TransformDirection.Next: case TransformDirection.Next:
d.Position = new Vector2(400, 0); newBackground.Position = new Vector2(400, 0);
d.MoveToX(0, 500, Easing.OutCubic); newBackground.MoveToX(0, 500, Easing.OutCubic);
currentBackground.MoveToX(-400, 500, Easing.OutCubic); currentBackground.MoveToX(-400, 500, Easing.OutCubic);
break; break;
case TransformDirection.Prev: case TransformDirection.Prev:
d.Position = new Vector2(-400, 0); newBackground.Position = new Vector2(-400, 0);
d.MoveToX(0, 500, Easing.OutCubic); newBackground.MoveToX(0, 500, Easing.OutCubic);
currentBackground.MoveToX(400, 500, Easing.OutCubic); currentBackground.MoveToX(400, 500, Easing.OutCubic);
break; break;
} }
currentBackground.Expire(); currentBackground.Expire();
currentBackground = d; currentBackground = newBackground;
} }
}) })
{ {