mirror of
https://github.com/ppy/osu.git
synced 2025-03-22 21:00:33 +08:00
Changed PauseOverlay to layout with FlowContainers and not positioning, made the retry counter in PauseOverlay have the number bolded, made it so if the player presses escape before the clock is started in Player then Exit is called instead of Pause
This commit is contained in:
parent
62282076c7
commit
015832f242
@ -22,7 +22,7 @@ namespace osu.Game.Overlays.Pause
|
||||
public Action OnRetry;
|
||||
public Action OnQuit;
|
||||
|
||||
private SpriteText retryCounter;
|
||||
private FlowContainer retryCounterContainer;
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
public override bool HandleInput => State == Visibility.Visible;
|
||||
@ -48,116 +48,121 @@ namespace osu.Game.Overlays.Pause
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.75f,
|
||||
},
|
||||
new FlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Spacing = new Vector2(0f, 50f),
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
new FlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.75f,
|
||||
}
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Spacing = new Vector2(0f, 20f),
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteText
|
||||
{
|
||||
Text = @"paused",
|
||||
Font = @"Exo2.0-Medium",
|
||||
Spacing = new Vector2(5, 0),
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
TextSize = 30,
|
||||
Colour = colours.Yellow,
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Text = @"you're not going to do what i think you're going to do, ain't ya?",
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
},
|
||||
}
|
||||
},
|
||||
new FlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Masking = true,
|
||||
EdgeEffect = new EdgeEffect
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = new Color4(0, 0, 0, 150),
|
||||
Radius = 50,
|
||||
Offset = new Vector2(0, 0),
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new PauseButton
|
||||
{
|
||||
Type = PauseButtonType.Resume,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Height = buttonHeight,
|
||||
Action = (delegate
|
||||
{
|
||||
Hide();
|
||||
Task.Delay(fadeDuration * 2).ContinueWith(task => OnResume?.Invoke());
|
||||
}),
|
||||
},
|
||||
new PauseButton
|
||||
{
|
||||
Type = PauseButtonType.Retry,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Height = buttonHeight,
|
||||
Action = (delegate
|
||||
{
|
||||
Hide();
|
||||
OnRetry?.Invoke();
|
||||
}),
|
||||
},
|
||||
new PauseButton
|
||||
{
|
||||
Type = PauseButtonType.Quit,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Height = buttonHeight,
|
||||
Action = (delegate
|
||||
{
|
||||
Hide();
|
||||
OnQuit?.Invoke();
|
||||
}),
|
||||
},
|
||||
}
|
||||
},
|
||||
retryCounterContainer = new FlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
},
|
||||
}
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Text = @"paused",
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.Centre,
|
||||
Position = new Vector2(0, -175),
|
||||
Font = @"Exo2.0-Medium",
|
||||
Spacing = new Vector2(5, 0),
|
||||
TextSize = 30,
|
||||
Colour = colours.Yellow,
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Text = @"you're not going to do what i think you're going to do, ain't ya?",
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.Centre,
|
||||
Width = 100,
|
||||
Position = new Vector2(0, -125),
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
},
|
||||
retryCounter = new SpriteText
|
||||
{
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.Centre,
|
||||
Width = 100,
|
||||
Position = new Vector2(0, 175),
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
TextSize = 18,
|
||||
},
|
||||
new PauseProgressBar
|
||||
{
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Width = 1f,
|
||||
},
|
||||
new FlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Position = new Vector2(0, 25),
|
||||
Masking = true,
|
||||
EdgeEffect = new EdgeEffect
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = new Color4(0, 0, 0, 150),
|
||||
Radius = 50,
|
||||
Offset = new Vector2(0, 0),
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new PauseButton
|
||||
{
|
||||
Type = PauseButtonType.Resume,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Height = buttonHeight,
|
||||
Action = (delegate
|
||||
{
|
||||
Hide();
|
||||
Task.Delay(fadeDuration * 2).ContinueWith(task => OnResume?.Invoke());
|
||||
}),
|
||||
},
|
||||
new PauseButton
|
||||
{
|
||||
Type = PauseButtonType.Retry,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Height = buttonHeight,
|
||||
Action = (delegate
|
||||
{
|
||||
Hide();
|
||||
OnRetry?.Invoke();
|
||||
}),
|
||||
},
|
||||
new PauseButton
|
||||
{
|
||||
Type = PauseButtonType.Quit,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Height = buttonHeight,
|
||||
Action = (delegate
|
||||
{
|
||||
Hide();
|
||||
OnQuit?.Invoke();
|
||||
}),
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@ -166,16 +171,46 @@ namespace osu.Game.Overlays.Pause
|
||||
|
||||
public void SetRetries(int count)
|
||||
{
|
||||
if (retryCounter != null)
|
||||
if (retryCounterContainer != null)
|
||||
{
|
||||
// "You've retried 1,065 times in this session"
|
||||
// "You've retried 1 time in this session"
|
||||
retryCounter.Text = $"You've retried {String.Format("{0:n0}", count)} time{(count == 1) ? "" : "s"} in this session";
|
||||
|
||||
string leading = "You've retried ";
|
||||
string countString = String.Format("{0:n0}", count);
|
||||
string trailing = $" time{((count == 1) ? "" : "s")} in this session";
|
||||
|
||||
retryCounterContainer.Children = new Drawable[]
|
||||
{
|
||||
new SpriteText
|
||||
{
|
||||
Text = leading,
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
TextSize = 18
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Text = countString,
|
||||
Font = @"Exo2.0-Bold",
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
TextSize = 18
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Text = trailing,
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
TextSize = 18
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public PauseOverlay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,8 @@ namespace osu.Game.Screens.Play
|
||||
private double pauseCooldown = 1000;
|
||||
private double lastPauseActionTime = 0;
|
||||
|
||||
private bool clockWasStarted = false;
|
||||
|
||||
private IAdjustableClock sourceClock;
|
||||
|
||||
private Ruleset ruleset;
|
||||
@ -183,14 +185,13 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public void Restart()
|
||||
{
|
||||
sourceClock.Stop(); // If the clock is not stopped and Restart is called alot of lag will happen until the game is relaunched
|
||||
sourceClock.Stop(); // If the clock is running and Restart is called the game will lag until relaunch
|
||||
|
||||
var newPlayer = new Player();
|
||||
|
||||
newPlayer.Preload(Game, delegate
|
||||
{
|
||||
RestartCount++;
|
||||
newPlayer.RestartCount = RestartCount;
|
||||
newPlayer.RestartCount = RestartCount + 1;
|
||||
Exit();
|
||||
|
||||
if (!(last?.Push(newPlayer) ?? false))
|
||||
@ -214,6 +215,7 @@ namespace osu.Game.Screens.Play
|
||||
Schedule(() =>
|
||||
{
|
||||
sourceClock.Start();
|
||||
clockWasStarted = true;
|
||||
});
|
||||
}
|
||||
|
||||
@ -270,12 +272,12 @@ namespace osu.Game.Screens.Play
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.Escape:
|
||||
if (!IsPaused)
|
||||
if (!IsPaused && clockWasStarted) // For if the user presses escape quickly when entering the map
|
||||
{
|
||||
Pause();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user