mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:22:55 +08:00
Small cleanups
This commit is contained in:
parent
d70cbd37dd
commit
f8cbc35f8e
@ -24,50 +24,55 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
Add(new Box
|
||||
Children = new Drawable[]
|
||||
{
|
||||
ColourInfo = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke),
|
||||
RelativeSizeAxes = Framework.Graphics.Axes.Both
|
||||
});
|
||||
new Box
|
||||
{
|
||||
ColourInfo = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke),
|
||||
RelativeSizeAxes = Framework.Graphics.Axes.Both
|
||||
},
|
||||
pauseOverlay = new PauseOverlay
|
||||
{
|
||||
Depth = -1
|
||||
},
|
||||
new FlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Origin = Anchor.TopLeft,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Button
|
||||
{
|
||||
Text = @"Pause",
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
Width = 100,
|
||||
Height = 50,
|
||||
Colour = Color4.Black,
|
||||
Action = (() => pauseOverlay.Show())
|
||||
},
|
||||
new Button
|
||||
{
|
||||
Text = @"Add Retry",
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
Width = 100,
|
||||
Height = 50,
|
||||
Colour = Color4.Black,
|
||||
Action = (delegate {
|
||||
retryCount++;
|
||||
pauseOverlay.SetRetries(retryCount);
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Add(pauseOverlay = new PauseOverlay { Depth = -1 });
|
||||
pauseOverlay.OnResume += (() => Logger.Log(@"Resume"));
|
||||
pauseOverlay.OnRetry += (() => Logger.Log(@"Retry"));
|
||||
pauseOverlay.OnQuit += (() => Logger.Log(@"Quit"));
|
||||
|
||||
Add(new FlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Origin = Anchor.TopLeft,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Button
|
||||
{
|
||||
Text = @"Pause",
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
Width = 100,
|
||||
Height = 50,
|
||||
Colour = Color4.Black,
|
||||
Action = (() => pauseOverlay.Show())
|
||||
},
|
||||
new Button
|
||||
{
|
||||
Text = @"Add Retry",
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
Width = 100,
|
||||
Height = 50,
|
||||
Colour = Color4.Black,
|
||||
Action = (delegate {
|
||||
retryCount++;
|
||||
pauseOverlay.SetRetries(retryCount);
|
||||
}),
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,12 +16,10 @@ namespace osu.Game.Overlays.Pause
|
||||
{
|
||||
public class PauseButton : ClickableContainer
|
||||
{
|
||||
private float height = 70;
|
||||
private float colourWidth = 0.8f;
|
||||
private float colourExpandedWidth = 0.9f;
|
||||
private float colourExpandTime = 500;
|
||||
private float shear = 0.2f;
|
||||
private float glowGradientEndAlpha = 0f;
|
||||
private const float colourWidth = 0.8f;
|
||||
private const float colourExpandedWidth = 0.9f;
|
||||
private const float colourExpandTime = 500;
|
||||
private Vector2 colourShear = new Vector2(0.2f, 0);
|
||||
|
||||
private Color4 buttonColour;
|
||||
private Color4 backgroundColour = OsuColour.Gray(34);
|
||||
@ -56,7 +54,7 @@ namespace osu.Game.Overlays.Pause
|
||||
private Container colourContainer;
|
||||
private Container glowContainer;
|
||||
|
||||
private bool didClick;
|
||||
private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos);
|
||||
|
||||
@ -113,7 +111,7 @@ namespace osu.Game.Overlays.Pause
|
||||
break;
|
||||
|
||||
case PauseButtonType.Quit:
|
||||
// For whatever reason the red from the mockup is not in the osu! palette
|
||||
// The red from the design isn't in the palette so it's used directly
|
||||
buttonColour = new Color4(170, 27, 39, 255);
|
||||
sampleClick = audio.Sample.Get(@"Menu/menuback");
|
||||
break;
|
||||
@ -149,7 +147,7 @@ namespace osu.Game.Overlays.Pause
|
||||
Origin = Anchor.TopLeft,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Width = 0.125f,
|
||||
ColourInfo = ColourInfo.GradientHorizontal(new Color4(buttonColour.R, buttonColour.G, buttonColour.B, glowGradientEndAlpha), buttonColour)
|
||||
ColourInfo = ColourInfo.GradientHorizontal(new Color4(buttonColour.R, buttonColour.G, buttonColour.B, 0f), buttonColour)
|
||||
},
|
||||
new Box
|
||||
{
|
||||
@ -165,14 +163,13 @@ namespace osu.Game.Overlays.Pause
|
||||
Origin = Anchor.TopRight,
|
||||
Anchor = Anchor.TopRight,
|
||||
Width = 0.125f,
|
||||
ColourInfo = ColourInfo.GradientHorizontal(buttonColour, new Color4(buttonColour.R, buttonColour.G, buttonColour.B, glowGradientEndAlpha))
|
||||
ColourInfo = ColourInfo.GradientHorizontal(buttonColour, new Color4(buttonColour.R, buttonColour.G, buttonColour.B, 0f))
|
||||
}
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = height,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Masking = true,
|
||||
@ -192,7 +189,7 @@ namespace osu.Game.Overlays.Pause
|
||||
Radius = 5
|
||||
},
|
||||
Colour = buttonColour,
|
||||
Shear = new Vector2(shear, 0),
|
||||
Shear = colourShear,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
@ -206,7 +203,7 @@ namespace osu.Game.Overlays.Pause
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
TriangleScale = 4,
|
||||
Alpha = 0.05f,
|
||||
Shear = new Vector2(-shear, 0)
|
||||
Shear = -colourShear
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -228,8 +225,7 @@ namespace osu.Game.Overlays.Pause
|
||||
|
||||
public PauseButton()
|
||||
{
|
||||
Height = height;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,8 @@ namespace osu.Game.Overlays.Pause
|
||||
{
|
||||
public class PauseOverlay : OverlayContainer
|
||||
{
|
||||
private int fadeDuration = 200;
|
||||
private const int fadeDuration = 200;
|
||||
private const int buttonHeight = 70;
|
||||
|
||||
public Action OnResume;
|
||||
public Action OnRetry;
|
||||
@ -120,8 +121,10 @@ namespace osu.Game.Overlays.Pause
|
||||
new PauseButton
|
||||
{
|
||||
Type = PauseButtonType.Resume,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Height = buttonHeight,
|
||||
Action = (delegate
|
||||
{
|
||||
Hide();
|
||||
@ -131,8 +134,10 @@ namespace osu.Game.Overlays.Pause
|
||||
new PauseButton
|
||||
{
|
||||
Type = PauseButtonType.Retry,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Height = buttonHeight,
|
||||
Action = (delegate
|
||||
{
|
||||
Hide();
|
||||
@ -142,8 +147,10 @@ namespace osu.Game.Overlays.Pause
|
||||
new PauseButton
|
||||
{
|
||||
Type = PauseButtonType.Quit,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Height = buttonHeight,
|
||||
Action = (delegate
|
||||
{
|
||||
Hide();
|
||||
|
Loading…
Reference in New Issue
Block a user