1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 14:13:18 +08:00

Add stable-alike BackButton

This commit is contained in:
stanriders 2016-11-27 04:21:12 +03:00
parent 1427cce76f
commit e9343fe53d
5 changed files with 98 additions and 7 deletions

@ -1 +1 @@
Subproject commit 24af3b161da9447b678edd8ec32193df54f71e3b
Subproject commit ea56eab4a2bb4c9723052586ed30c687898fecb0

View File

@ -0,0 +1,84 @@
// Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
namespace osu.Game.Graphics.UserInterface
{
// Basic back button as it was on stable (kinda). No skinning possible for now
class BackButton : ExtendableButton
{
private TextAwesome icon;
private Vector2 iconPos = new Vector2(20, 0);
public BackButton()
{
InitialExtendLenght = new Vector2(40, 0);
ExtendLenght = new Vector2(60, 0);
RelativeSizeAxes = Axes.Y;
Width = 80;
//Height = 40; // should be set or should be relative?
Text = @"Back";
BGColour = new Color4(195, 40, 140, 255);
Colour = new Color4(238, 51, 153, 255);
Children = new Drawable[]
{
icon = new TextAwesome
{
Anchor = Anchor.CentreLeft,
TextSize = 25,
Position = iconPos,
Icon = FontAwesome.fa_osu_left_o
}
};
// HACK: because it never uses InitialExtendLenght that we give to it on creation
textContainer.Position = Position + InitialExtendLenght;
}
protected override bool OnHover(InputState state)
{
bool result = base.OnHover(state);
icon.ClearTransformations();
icon.MoveToX(iconPos.X + 10, 150, EasingTypes.OutElastic);
int duration = 0; //(int)(Game.Audio.BeatLength / 2);
if (duration == 0) duration = 250;
double offset = 0; //(1 - Game.Audio.SyncBeatProgress) * duration;
double startTime = Time.Current + offset;
// basic pulse
icon.Transforms.Add(new TransformScale
{
StartValue = new Vector2(1.1f, 1.1f),
EndValue = Vector2.One,
StartTime = startTime,
EndTime = startTime + duration,
Easing = EasingTypes.Out,
LoopCount = -1,
LoopDelay = duration
});
return result;
}
protected override void OnHoverLost(InputState state)
{
icon.ClearTransformations();
icon.MoveToX(iconPos.X, 150, EasingTypes.OutElastic);
base.OnHoverLost(state);
}
}
}

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Screens.Backgrounds;
using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Graphics;
@ -17,7 +18,7 @@ namespace osu.Game.Screens
{
public class GameModeWhiteBox : OsuGameMode
{
private Button popButton;
private BackButton popButton;
const int transition_time = 1000;
@ -113,14 +114,12 @@ namespace osu.Game.Screens
},
}
},
popButton = new Button
popButton = new BackButton
{
Text = @"Back",
RelativeSizeAxes = Axes.X,
Size = new Vector2(0.1f, 40),
RelativeSizeAxes = Axes.None,
Height = 40,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Colour = new Color4(235, 51, 153, 255),
Alpha = 0,
Action = delegate {
Exit();

View File

@ -19,6 +19,7 @@ using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Modes;
using osu.Game.Screens.Backgrounds;
using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Graphics;
using osu.Game.Screens.Play;
@ -120,6 +121,12 @@ namespace osu.Game.Screens.Select
Size = Vector2.One,
Colour = new Color4(0, 0, 0, 0.5f),
},
new BackButton
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Action = () => Exit()
},
new Button
{
Anchor = Anchor.CentreRight,

View File

@ -65,6 +65,7 @@
<ItemGroup>
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
<Compile Include="Graphics\Cursor\CursorTrail.cs" />
<Compile Include="Graphics\UserInterface\BackButton.cs" />
<Compile Include="Modes\Objects\HitObjectParser.cs" />
<Compile Include="Overlays\DragBar.cs" />
<Compile Include="Overlays\MusicController.cs" />