2017-03-02 20:40:55 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
2017-03-03 15:54:59 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2017-03-02 20:40:55 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-03-02 21:05:10 +08:00
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2017-03-02 20:40:55 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
|
2017-03-03 09:20:30 +08:00
|
|
|
|
namespace osu.Game.Screens.Select.Options
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
|
|
|
|
public class BeatmapOptionsOverlay : FocusedOverlayContainer
|
|
|
|
|
{
|
|
|
|
|
private const float transition_duration = 500;
|
|
|
|
|
private const float x_position = 290;
|
|
|
|
|
|
2017-03-03 15:54:59 +08:00
|
|
|
|
private const float height = 100;
|
|
|
|
|
|
2017-03-03 15:11:23 +08:00
|
|
|
|
private Box holder;
|
2017-03-02 20:40:55 +08:00
|
|
|
|
private FillFlowContainer<BeatmapOptionsButton> buttonsContainer;
|
|
|
|
|
|
|
|
|
|
public Action OnRemoveFromUnplayed;
|
|
|
|
|
public Action OnClearLocalScores;
|
|
|
|
|
public Action OnEdit;
|
|
|
|
|
public Action OnDelete;
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
base.PopIn();
|
|
|
|
|
|
|
|
|
|
if (buttonsContainer.Position.X >= DrawWidth || buttonsContainer.Alpha <= 0)
|
|
|
|
|
buttonsContainer.MoveToX(-buttonsContainer.DrawWidth);
|
|
|
|
|
|
|
|
|
|
buttonsContainer.Alpha = 1;
|
|
|
|
|
|
2017-03-03 15:11:23 +08:00
|
|
|
|
holder.ScaleTo(new Vector2(1, 1), transition_duration / 2, EasingTypes.OutQuint);
|
|
|
|
|
|
2017-03-02 20:40:55 +08:00
|
|
|
|
buttonsContainer.MoveToX(x_position, transition_duration, EasingTypes.OutQuint);
|
|
|
|
|
buttonsContainer.TransformSpacingTo(Vector2.Zero, transition_duration, EasingTypes.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
base.PopOut();
|
|
|
|
|
|
2017-03-03 15:11:23 +08:00
|
|
|
|
holder.ScaleTo(new Vector2(1, 0), transition_duration / 2, EasingTypes.InSine);
|
|
|
|
|
|
2017-03-02 20:40:55 +08:00
|
|
|
|
buttonsContainer.MoveToX(DrawWidth, transition_duration, EasingTypes.InSine);
|
|
|
|
|
buttonsContainer.TransformSpacingTo(new Vector2(200f, 0f), transition_duration, EasingTypes.InSine);
|
|
|
|
|
|
|
|
|
|
Delay(transition_duration);
|
|
|
|
|
Schedule(() =>
|
|
|
|
|
{
|
|
|
|
|
if (State == Visibility.Hidden)
|
|
|
|
|
buttonsContainer.Alpha = 0;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BeatmapOptionsOverlay()
|
|
|
|
|
{
|
2017-03-03 15:11:23 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Anchor = Anchor.BottomLeft;
|
|
|
|
|
Origin = Anchor.BottomLeft;
|
|
|
|
|
|
2017-03-02 20:40:55 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-03-03 15:11:23 +08:00
|
|
|
|
holder = new Box
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
2017-03-03 15:11:23 +08:00
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
2017-03-02 20:40:55 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-03-03 15:11:23 +08:00
|
|
|
|
Height = 0.5f,
|
|
|
|
|
Scale = new Vector2(1, 0),
|
|
|
|
|
Colour = Color4.Black.Opacity(0.5f),
|
2017-03-02 20:40:55 +08:00
|
|
|
|
},
|
2017-03-03 15:54:59 +08:00
|
|
|
|
buttonsContainer = new ButtonFlow
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
2017-03-03 15:54:59 +08:00
|
|
|
|
Height = height,
|
2017-03-03 12:53:17 +08:00
|
|
|
|
AutoSizeAxes = Axes.X,
|
2017-03-02 20:40:55 +08:00
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Children = new BeatmapOptionsButton[]
|
|
|
|
|
{
|
2017-03-03 15:54:59 +08:00
|
|
|
|
new BeatmapOptionsRemoveFromUnplayedButton
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
Hide();
|
2017-03-03 15:54:59 +08:00
|
|
|
|
OnRemoveFromUnplayed?.Invoke();
|
2017-03-02 20:40:55 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
2017-03-03 15:54:59 +08:00
|
|
|
|
new BeatmapOptionsClearLocalScoresButton
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
Hide();
|
2017-03-03 15:54:59 +08:00
|
|
|
|
OnClearLocalScores?.Invoke();
|
2017-03-02 20:40:55 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
2017-03-03 15:54:59 +08:00
|
|
|
|
new BeatmapOptionsEditButton
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
Hide();
|
2017-03-03 15:54:59 +08:00
|
|
|
|
OnEdit?.Invoke();
|
2017-03-02 20:40:55 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
2017-03-03 15:54:59 +08:00
|
|
|
|
new BeatmapOptionsDeleteButton
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
Hide();
|
2017-03-03 15:54:59 +08:00
|
|
|
|
OnDelete?.Invoke();
|
2017-03-02 20:40:55 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2017-03-03 15:54:59 +08:00
|
|
|
|
|
|
|
|
|
class ButtonFlow : FillFlowContainer<BeatmapOptionsButton>
|
|
|
|
|
{
|
|
|
|
|
protected override IComparer<Drawable> DepthComparer => new ReverseCreationOrderDepthComparer();
|
|
|
|
|
protected override IEnumerable<BeatmapOptionsButton> FlowingChildren => base.FlowingChildren.Reverse();
|
|
|
|
|
|
|
|
|
|
public ButtonFlow()
|
|
|
|
|
{
|
|
|
|
|
Direction = FillDirection.Right;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-02 20:40:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|