mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 23:13:20 +08:00
Small cleanups
This commit is contained in:
parent
d70cbd37dd
commit
f8cbc35f8e
@ -24,50 +24,55 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
{
|
{
|
||||||
base.Reset();
|
base.Reset();
|
||||||
|
|
||||||
Add(new Box
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
ColourInfo = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke),
|
new Box
|
||||||
RelativeSizeAxes = Framework.Graphics.Axes.Both
|
{
|
||||||
});
|
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.OnResume += (() => Logger.Log(@"Resume"));
|
||||||
pauseOverlay.OnRetry += (() => Logger.Log(@"Retry"));
|
pauseOverlay.OnRetry += (() => Logger.Log(@"Retry"));
|
||||||
pauseOverlay.OnQuit += (() => Logger.Log(@"Quit"));
|
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
|
public class PauseButton : ClickableContainer
|
||||||
{
|
{
|
||||||
private float height = 70;
|
private const float colourWidth = 0.8f;
|
||||||
private float colourWidth = 0.8f;
|
private const float colourExpandedWidth = 0.9f;
|
||||||
private float colourExpandedWidth = 0.9f;
|
private const float colourExpandTime = 500;
|
||||||
private float colourExpandTime = 500;
|
private Vector2 colourShear = new Vector2(0.2f, 0);
|
||||||
private float shear = 0.2f;
|
|
||||||
private float glowGradientEndAlpha = 0f;
|
|
||||||
|
|
||||||
private Color4 buttonColour;
|
private Color4 buttonColour;
|
||||||
private Color4 backgroundColour = OsuColour.Gray(34);
|
private Color4 backgroundColour = OsuColour.Gray(34);
|
||||||
@ -56,7 +54,7 @@ namespace osu.Game.Overlays.Pause
|
|||||||
private Container colourContainer;
|
private Container colourContainer;
|
||||||
private Container glowContainer;
|
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);
|
public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos);
|
||||||
|
|
||||||
@ -113,7 +111,7 @@ namespace osu.Game.Overlays.Pause
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PauseButtonType.Quit:
|
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);
|
buttonColour = new Color4(170, 27, 39, 255);
|
||||||
sampleClick = audio.Sample.Get(@"Menu/menuback");
|
sampleClick = audio.Sample.Get(@"Menu/menuback");
|
||||||
break;
|
break;
|
||||||
@ -149,7 +147,7 @@ namespace osu.Game.Overlays.Pause
|
|||||||
Origin = Anchor.TopLeft,
|
Origin = Anchor.TopLeft,
|
||||||
Anchor = Anchor.TopLeft,
|
Anchor = Anchor.TopLeft,
|
||||||
Width = 0.125f,
|
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
|
new Box
|
||||||
{
|
{
|
||||||
@ -165,14 +163,13 @@ namespace osu.Game.Overlays.Pause
|
|||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Width = 0.125f,
|
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
|
new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Height = height,
|
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
@ -192,7 +189,7 @@ namespace osu.Game.Overlays.Pause
|
|||||||
Radius = 5
|
Radius = 5
|
||||||
},
|
},
|
||||||
Colour = buttonColour,
|
Colour = buttonColour,
|
||||||
Shear = new Vector2(shear, 0),
|
Shear = colourShear,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
@ -206,7 +203,7 @@ namespace osu.Game.Overlays.Pause
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
TriangleScale = 4,
|
TriangleScale = 4,
|
||||||
Alpha = 0.05f,
|
Alpha = 0.05f,
|
||||||
Shear = new Vector2(-shear, 0)
|
Shear = -colourShear
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,8 +225,7 @@ namespace osu.Game.Overlays.Pause
|
|||||||
|
|
||||||
public PauseButton()
|
public PauseButton()
|
||||||
{
|
{
|
||||||
Height = height;
|
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,8 @@ namespace osu.Game.Overlays.Pause
|
|||||||
{
|
{
|
||||||
public class PauseOverlay : OverlayContainer
|
public class PauseOverlay : OverlayContainer
|
||||||
{
|
{
|
||||||
private int fadeDuration = 200;
|
private const int fadeDuration = 200;
|
||||||
|
private const int buttonHeight = 70;
|
||||||
|
|
||||||
public Action OnResume;
|
public Action OnResume;
|
||||||
public Action OnRetry;
|
public Action OnRetry;
|
||||||
@ -120,8 +121,10 @@ namespace osu.Game.Overlays.Pause
|
|||||||
new PauseButton
|
new PauseButton
|
||||||
{
|
{
|
||||||
Type = PauseButtonType.Resume,
|
Type = PauseButtonType.Resume,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
|
Height = buttonHeight,
|
||||||
Action = (delegate
|
Action = (delegate
|
||||||
{
|
{
|
||||||
Hide();
|
Hide();
|
||||||
@ -131,8 +134,10 @@ namespace osu.Game.Overlays.Pause
|
|||||||
new PauseButton
|
new PauseButton
|
||||||
{
|
{
|
||||||
Type = PauseButtonType.Retry,
|
Type = PauseButtonType.Retry,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
|
Height = buttonHeight,
|
||||||
Action = (delegate
|
Action = (delegate
|
||||||
{
|
{
|
||||||
Hide();
|
Hide();
|
||||||
@ -142,8 +147,10 @@ namespace osu.Game.Overlays.Pause
|
|||||||
new PauseButton
|
new PauseButton
|
||||||
{
|
{
|
||||||
Type = PauseButtonType.Quit,
|
Type = PauseButtonType.Quit,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
|
Height = buttonHeight,
|
||||||
Action = (delegate
|
Action = (delegate
|
||||||
{
|
{
|
||||||
Hide();
|
Hide();
|
||||||
|
Loading…
Reference in New Issue
Block a user