mirror of
https://github.com/ppy/osu.git
synced 2025-03-22 21:00:33 +08:00
Made PauseButton more visually responsive, added force option to Player.Pause, added very basic implementation of the progress bar
This commit is contained in:
parent
feba3f35ba
commit
582599a8de
@ -21,6 +21,7 @@ namespace osu.Game.Overlays.Pause
|
||||
private float colourExpandTime = 500;
|
||||
private float shear = 0.2f;
|
||||
private float glowGradientEndAlpha = 0f;
|
||||
private double pressExpandTime = 100;
|
||||
|
||||
private Color4 buttonColour;
|
||||
private Color4 backgroundColour = OsuColour.Gray(34);
|
||||
@ -54,12 +55,18 @@ namespace osu.Game.Overlays.Pause
|
||||
private Container backgroundContainer;
|
||||
private Container colourContainer;
|
||||
private Container glowContainer;
|
||||
private SpriteText spriteText;
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos);
|
||||
|
||||
protected override bool OnMouseDown(Framework.Input.InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
colourContainer.ResizeTo(new Vector2(colourWidth, 1f), 1000, EasingTypes.Out);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(Framework.Input.InputState state, MouseUpEventArgs args)
|
||||
{
|
||||
colourContainer.ResizeTo(new Vector2(1.1f, 1f), pressExpandTime, EasingTypes.In);
|
||||
sampleClick?.Play();
|
||||
return true;
|
||||
}
|
||||
@ -67,7 +74,7 @@ namespace osu.Game.Overlays.Pause
|
||||
protected override bool OnHover(Framework.Input.InputState state)
|
||||
{
|
||||
colourContainer.ResizeTo(new Vector2(colourExpandedWidth, 1f), colourExpandTime, EasingTypes.OutElastic);
|
||||
glowContainer.FadeTo(1f, colourExpandTime, EasingTypes.Out);
|
||||
glowContainer.FadeTo(1f, colourExpandTime / 2, EasingTypes.Out);
|
||||
sampleHover?.Play();
|
||||
return true;
|
||||
}
|
||||
@ -75,7 +82,7 @@ namespace osu.Game.Overlays.Pause
|
||||
protected override void OnHoverLost(Framework.Input.InputState state)
|
||||
{
|
||||
colourContainer.ResizeTo(new Vector2(colourWidth, 1f), colourExpandTime, EasingTypes.OutElastic);
|
||||
glowContainer.FadeTo(0f, colourExpandTime, EasingTypes.Out);
|
||||
glowContainer.FadeTo(0f, colourExpandTime / 2, EasingTypes.Out);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -187,7 +194,7 @@ namespace osu.Game.Overlays.Pause
|
||||
},
|
||||
}
|
||||
},
|
||||
spriteText = new SpriteText
|
||||
new SpriteText
|
||||
{
|
||||
Text = Text,
|
||||
Anchor = Anchor.Centre,
|
||||
|
@ -3,8 +3,6 @@ using OpenTK;
|
||||
using OpenTK.Input;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
@ -20,18 +18,29 @@ namespace osu.Game.Overlays.Pause
|
||||
|
||||
public Action OnResume;
|
||||
public Action OnRetry;
|
||||
public Action OnQuit;
|
||||
public Action OnQuit;
|
||||
|
||||
private SpriteText retryCounter;
private PauseProgressBar progressBar;
|
||||
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
new ClickableContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.75f,
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.75f,
|
||||
}
|
||||
}
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
@ -56,7 +65,7 @@ namespace osu.Game.Overlays.Pause
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
},
|
||||
new SpriteText
|
||||
retryCounter = new SpriteText
|
||||
{
|
||||
Text = @"You've retried 0 times in this session",
|
||||
Origin = Anchor.TopCentre,
|
||||
@ -67,6 +76,12 @@ namespace osu.Game.Overlays.Pause
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
TextSize = 18,
|
||||
},
|
||||
progressBar = new PauseProgressBar
|
||||
{
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Width = 1f,
|
||||
},
|
||||
new FlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -82,7 +97,6 @@ namespace osu.Game.Overlays.Pause
|
||||
Radius = 50,
|
||||
Offset = new Vector2(0, 0),
|
||||
},
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new PauseButton
|
||||
@ -138,10 +152,11 @@ namespace osu.Game.Overlays.Pause
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.Escape:
|
||||
if (State == Visibility.Hidden) return false;
|
||||
Hide();
|
||||
OnResume?.Invoke();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
|
||||
@ -149,7 +164,6 @@ namespace osu.Game.Overlays.Pause
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Depth = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
141
osu.Game/Overlays/Pause/PauseProgressBar.cs
Normal file
141
osu.Game/Overlays/Pause/PauseProgressBar.cs
Normal file
@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using OpenTK;
|
||||
using OpenTK.Input;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
|
||||
namespace osu.Game.Overlays.Pause
|
||||
{
|
||||
public class PauseProgressBar : Container
|
||||
{
|
||||
private Container fill;
|
||||
private WorkingBeatmap current;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase osuGame)
|
||||
{
|
||||
current = osuGame.Beatmap.Value;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (current?.TrackLoaded ?? false)
|
||||
{
|
||||
fill.Width = (float)(current.Track.CurrentTime / current.Track.Length);
|
||||
}
|
||||
}
|
||||
|
||||
public PauseProgressBar()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 60;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
Origin = Anchor.BottomRight,
|
||||
Anchor = Anchor.BottomRight,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 5,
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = new Color4(0, 0, 0, 255),
|
||||
Alpha = 0.5f,
|
||||
}
|
||||
}
|
||||
},
|
||||
fill = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Width = 0,
|
||||
Height = 60,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 5,
|
||||
Masking = true,
|
||||
EdgeEffect = new EdgeEffect
|
||||
{
|
||||
Type = EdgeEffectType.Glow,
|
||||
Colour = new Color4(130, 204, 255, 150),
|
||||
Radius = 5,
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = new Color4(221, 255, 255, 255),
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Origin = Anchor.BottomRight,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Width = 2,
|
||||
Height = 35,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.White,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Width = 14,
|
||||
Height = 25,
|
||||
CornerRadius = 5,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.White
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -104,9 +104,9 @@ namespace osu.Game.Screens.Play
|
||||
scoreOverlay = ruleset.CreateScoreOverlay();
|
||||
scoreOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count));
|
||||
|
||||
pauseOverlay = new PauseOverlay();
|
||||
pauseOverlay = new PauseOverlay { Depth = -1 };
|
||||
pauseOverlay.OnResume = Resume;
|
||||
//pauseOverlay.OnRetry = Retry; Add when retrying is implemented
|
||||
pauseOverlay.OnRetry = Restart;
|
||||
pauseOverlay.OnQuit = Exit;
|
||||
|
||||
hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects);
|
||||
@ -137,9 +137,9 @@ namespace osu.Game.Screens.Play
|
||||
};
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
public void Pause(bool force = false)
|
||||
{
|
||||
if (Time.Current >= (lastActionTime + pauseCooldown))
|
||||
if (Time.Current >= (lastActionTime + pauseCooldown) || force)
|
||||
{
|
||||
lastActionTime = Time.Current;
|
||||
isPaused = true;
|
||||
@ -165,7 +165,12 @@ namespace osu.Game.Screens.Play
|
||||
public void TogglePaused()
|
||||
{
|
||||
isPaused = !isPaused;
|
||||
(isPaused ? (Action)Pause : Resume)?.Invoke();
|
||||
if (isPaused) Pause(); else Resume();
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
{
|
||||
// TODO: Implement retrying
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
@ -238,6 +238,7 @@
|
||||
<Compile Include="Screens\Select\Footer.cs" />
|
||||
<Compile Include="Overlays\Pause\PauseButton.cs" />
|
||||
<Compile Include="Overlays\Pause\PauseOverlay.cs" />
|
||||
<Compile Include="Overlays\Pause\PauseProgressBar.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||
|
Loading…
x
Reference in New Issue
Block a user