mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 22:03:21 +08:00
Add stable-alike BackButton
This commit is contained in:
parent
1427cce76f
commit
e9343fe53d
@ -1 +1 @@
|
|||||||
Subproject commit 24af3b161da9447b678edd8ec32193df54f71e3b
|
Subproject commit ea56eab4a2bb4c9723052586ed30c687898fecb0
|
84
osu.Game/Graphics/UserInterface/BackButton.cs
Normal file
84
osu.Game/Graphics/UserInterface/BackButton.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ using osu.Framework.Graphics.Sprites;
|
|||||||
using osu.Framework.Graphics.Transformations;
|
using osu.Framework.Graphics.Transformations;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Game.Screens.Backgrounds;
|
using osu.Game.Screens.Backgrounds;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ namespace osu.Game.Screens
|
|||||||
{
|
{
|
||||||
public class GameModeWhiteBox : OsuGameMode
|
public class GameModeWhiteBox : OsuGameMode
|
||||||
{
|
{
|
||||||
private Button popButton;
|
private BackButton popButton;
|
||||||
|
|
||||||
const int transition_time = 1000;
|
const int transition_time = 1000;
|
||||||
|
|
||||||
@ -113,14 +114,12 @@ namespace osu.Game.Screens
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
popButton = new Button
|
popButton = new BackButton
|
||||||
{
|
{
|
||||||
Text = @"Back",
|
RelativeSizeAxes = Axes.None,
|
||||||
RelativeSizeAxes = Axes.X,
|
Height = 40,
|
||||||
Size = new Vector2(0.1f, 40),
|
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Colour = new Color4(235, 51, 153, 255),
|
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
Action = delegate {
|
Action = delegate {
|
||||||
Exit();
|
Exit();
|
||||||
|
@ -19,6 +19,7 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Modes;
|
using osu.Game.Modes;
|
||||||
using osu.Game.Screens.Backgrounds;
|
using osu.Game.Screens.Backgrounds;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
@ -120,6 +121,12 @@ namespace osu.Game.Screens.Select
|
|||||||
Size = Vector2.One,
|
Size = Vector2.One,
|
||||||
Colour = new Color4(0, 0, 0, 0.5f),
|
Colour = new Color4(0, 0, 0, 0.5f),
|
||||||
},
|
},
|
||||||
|
new BackButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Action = () => Exit()
|
||||||
|
},
|
||||||
new Button
|
new Button
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
|
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
|
||||||
<Compile Include="Graphics\Cursor\CursorTrail.cs" />
|
<Compile Include="Graphics\Cursor\CursorTrail.cs" />
|
||||||
|
<Compile Include="Graphics\UserInterface\BackButton.cs" />
|
||||||
<Compile Include="Modes\Objects\HitObjectParser.cs" />
|
<Compile Include="Modes\Objects\HitObjectParser.cs" />
|
||||||
<Compile Include="Overlays\DragBar.cs" />
|
<Compile Include="Overlays\DragBar.cs" />
|
||||||
<Compile Include="Overlays\MusicController.cs" />
|
<Compile Include="Overlays\MusicController.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user