1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 23:47:24 +08:00

Merge branch 'master' into mod-overlay

This commit is contained in:
Seth 2017-03-03 04:12:42 -04:00 committed by GitHub
commit fde509ab1d
11 changed files with 445 additions and 5 deletions

View File

@ -0,0 +1,28 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Screens.Testing;
using osu.Game.Graphics;
using osu.Game.Overlays;
using osu.Game.Screens.Select.Options;
namespace osu.Desktop.VisualTests
{
class TestCaseBeatmapOptionsOverlay : TestCase
{
public override string Name => @"Beatmap Options";
public override string Description => @"Beatmap options in song select";
public override void Reset()
{
base.Reset();
var overlay = new BeatmapOptionsOverlay();
Add(overlay);
AddButton(@"Toggle", overlay.ToggleVisibility);
}
}
}

View File

@ -196,6 +196,7 @@
<Compile Include="Tests\TestCasePauseOverlay.cs" />
<Compile Include="Tests\TestCaseModSelectOverlay.cs" />
<Compile Include="Tests\TestCaseDialogOverlay.cs" />
<Compile Include="Tests\TestCaseBeatmapOptionsOverlay.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup />

View File

@ -117,7 +117,8 @@ namespace osu.Game.Overlays.Options.Sections.General
{
PlaceholderText = "Password",
RelativeSizeAxes = Axes.X,
TabbableContentContainer = this
TabbableContentContainer = this,
OnCommit = (TextBox sender, bool newText) => performLogin()
},
new OsuCheckbox
{

View File

@ -0,0 +1,152 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Input;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Select.Options
{
public class BeatmapOptionsButton : ClickableContainer
{
private static readonly float width = 130;
private Box background, flash;
private TextAwesome iconText;
private OsuSpriteText firstLine, secondLine;
private Container box;
public Color4 ButtonColour
{
get { return background.Colour; }
set { background.Colour = value; }
}
public FontAwesome Icon
{
get { return iconText.Icon; }
set { iconText.Icon = value; }
}
public string FirstLineText
{
get { return firstLine.Text; }
set { firstLine.Text = value; }
}
public string SecondLineText
{
get { return secondLine.Text; }
set { secondLine.Text = value; }
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
flash.FadeTo(0.1f, 1000, EasingTypes.OutQuint);
return base.OnMouseDown(state, args);
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
flash.FadeTo(0, 1000, EasingTypes.OutQuint);
return base.OnMouseUp(state, args);
}
protected override bool OnClick(InputState state)
{
flash.ClearTransforms();
flash.Alpha = 0.9f;
flash.FadeOut(800, EasingTypes.OutExpo);
return base.OnClick(state);
}
public override bool Contains(Vector2 screenSpacePos) => box.Contains(screenSpacePos);
public BeatmapOptionsButton()
{
Width = width;
RelativeSizeAxes = Axes.Y;
Children = new Drawable[]
{
box = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Shear = new Vector2(0.2f, 0f),
Masking = true,
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Shadow,
Colour = Color4.Black.Opacity(0.2f),
Roundness = 5,
Radius = 8,
},
Children = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
EdgeSmoothness = new Vector2(1.5f, 0),
Colour = Color4.Black,
},
flash = new Box
{
RelativeSizeAxes = Axes.Both,
EdgeSmoothness = new Vector2(1.5f, 0),
BlendingMode = BlendingMode.Additive,
Colour = Color4.White,
Alpha = 0,
},
},
},
new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Down,
Children = new Drawable[]
{
iconText = new TextAwesome
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
TextSize = 30,
Shadow = true,
Icon = FontAwesome.fa_close,
Margin = new MarginPadding
{
Bottom = 5,
},
},
firstLine = new OsuSpriteText
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Font = @"Exo2.0-Bold",
Text = @"",
},
secondLine = new OsuSpriteText
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Font = @"Exo2.0-Bold",
Text = @"",
},
},
},
};
}
}
}

View File

@ -0,0 +1,24 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Game.Graphics;
namespace osu.Game.Screens.Select.Options
{
public class BeatmapOptionsClearLocalScoresButton : BeatmapOptionsButton
{
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{
ButtonColour = colour.Purple;
}
public BeatmapOptionsClearLocalScoresButton()
{
Icon = FontAwesome.fa_eraser;
FirstLineText = @"Clear";
SecondLineText = @"local scores";
}
}
}

View File

@ -0,0 +1,24 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Game.Graphics;
namespace osu.Game.Screens.Select.Options
{
public class BeatmapOptionsDeleteButton : BeatmapOptionsButton
{
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{
ButtonColour = colour.Pink;
}
public BeatmapOptionsDeleteButton()
{
Icon = FontAwesome.fa_trash;
FirstLineText = @"Delete";
SecondLineText = @"Beatmap";
}
}
}

View File

@ -0,0 +1,24 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Game.Graphics;
namespace osu.Game.Screens.Select.Options
{
public class BeatmapOptionsEditButton : BeatmapOptionsButton
{
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{
ButtonColour = colour.Yellow;
}
public BeatmapOptionsEditButton()
{
Icon = FontAwesome.fa_pencil;
FirstLineText = @"Edit";
SecondLineText = @"Beatmap";
}
}
}

View File

@ -0,0 +1,139 @@
// 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;
using System.Collections.Generic;
using System.Linq;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms;
using osu.Game.Graphics;
namespace osu.Game.Screens.Select.Options
{
public class BeatmapOptionsOverlay : FocusedOverlayContainer
{
private const float transition_duration = 500;
private const float x_position = 290;
private const float height = 100;
private Box holder;
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;
holder.ScaleTo(new Vector2(1, 1), transition_duration / 2, EasingTypes.OutQuint);
buttonsContainer.MoveToX(x_position, transition_duration, EasingTypes.OutQuint);
buttonsContainer.TransformSpacingTo(Vector2.Zero, transition_duration, EasingTypes.OutQuint);
}
protected override void PopOut()
{
base.PopOut();
holder.ScaleTo(new Vector2(1, 0), transition_duration / 2, EasingTypes.InSine);
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()
{
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
Anchor = Anchor.BottomLeft;
Origin = Anchor.BottomLeft;
Children = new Drawable[]
{
holder = new Box
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
Scale = new Vector2(1, 0),
Colour = Color4.Black.Opacity(0.5f),
},
buttonsContainer = new ButtonFlow
{
Height = height,
AutoSizeAxes = Axes.X,
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Children = new BeatmapOptionsButton[]
{
new BeatmapOptionsRemoveFromUnplayedButton
{
Action = () =>
{
Hide();
OnRemoveFromUnplayed?.Invoke();
},
},
new BeatmapOptionsClearLocalScoresButton
{
Action = () =>
{
Hide();
OnClearLocalScores?.Invoke();
},
},
new BeatmapOptionsEditButton
{
Action = () =>
{
Hide();
OnEdit?.Invoke();
},
},
new BeatmapOptionsDeleteButton
{
Action = () =>
{
Hide();
OnDelete?.Invoke();
},
},
},
},
};
}
class ButtonFlow : FillFlowContainer<BeatmapOptionsButton>
{
protected override IComparer<Drawable> DepthComparer => new ReverseCreationOrderDepthComparer();
protected override IEnumerable<BeatmapOptionsButton> FlowingChildren => base.FlowingChildren.Reverse();
public ButtonFlow()
{
Direction = FillDirection.Right;
}
}
}
}

View File

@ -0,0 +1,24 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Game.Graphics;
namespace osu.Game.Screens.Select.Options
{
public class BeatmapOptionsRemoveFromUnplayedButton : BeatmapOptionsButton
{
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{
ButtonColour = colour.Purple;
}
public BeatmapOptionsRemoveFromUnplayedButton()
{
Icon = FontAwesome.fa_times_circle_o;
FirstLineText = @"Remove";
SecondLineText = @"from Unplayed";
}
}
}

View File

@ -29,6 +29,7 @@ using System.Collections.Generic;
using osu.Framework.Threading;
using osu.Game.Overlays.Mods;
using osu.Game.Overlays;
using osu.Game.Screens.Select.Options;
namespace osu.Game.Screens.Select
{
@ -55,6 +56,7 @@ namespace osu.Game.Screens.Select
private List<BeatmapGroup> beatmapGroups;
private BeatmapOptionsOverlay beatmapOptions;
private Footer footer;
OsuScreen player;
@ -138,6 +140,17 @@ namespace osu.Game.Screens.Select
Bottom = 50,
},
},
beatmapOptions = new BeatmapOptionsOverlay
{
OnRemoveFromUnplayed = null,
OnClearLocalScores = null,
OnEdit = null,
OnDelete = promptDelete,
Margin = new MarginPadding
{
Bottom = 50,
},
},
footer = new Footer
{
OnBack = Exit,
@ -157,7 +170,7 @@ namespace osu.Game.Screens.Select
footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility);
footer.AddButton(@"random", colours.Green, carousel.SelectRandom);
footer.AddButton(@"options", colours.Blue, null);
footer.AddButton(@"options", colours.Blue, beatmapOptions.ToggleVisibility);
if (osu != null)
playMode.BindTo(osu.PlayMode);
@ -422,6 +435,12 @@ namespace osu.Game.Screens.Select
}
}
private void promptDelete()
{
if (Beatmap != null)
dialogOverlay?.Push(new BeatmapDeleteDialog(Beatmap));
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
switch (args.Key)
@ -432,9 +451,7 @@ namespace osu.Game.Screens.Select
case Key.Delete:
if (state.Keyboard.ShiftPressed)
{
if (Beatmap != null)
dialogOverlay?.Push(new BeatmapDeleteDialog(Beatmap));
promptDelete();
return true;
}
break;

View File

@ -295,6 +295,12 @@
<Compile Include="Overlays\DialogOverlay.cs" />
<Compile Include="Overlays\Mods\AssistedSection.cs" />
<Compile Include="Overlays\WaveOverlayContainer.cs" />
<Compile Include="Screens\Select\Options\BeatmapOptionsButton.cs" />
<Compile Include="Screens\Select\Options\BeatmapOptionsClearLocalScoresButton.cs" />
<Compile Include="Screens\Select\Options\BeatmapOptionsDeleteButton.cs" />
<Compile Include="Screens\Select\Options\BeatmapOptionsEditButton.cs" />
<Compile Include="Screens\Select\Options\BeatmapOptionsOverlay.cs" />
<Compile Include="Screens\Select\Options\BeatmapOptionsRemoveFromUnplayedButton.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">