Made requested changes

This commit is contained in:
DrabWeb 2017-01-31 09:17:47 -04:00
parent ecaa88a0d2
commit 91a5d0b3cf
4 changed files with 65 additions and 68 deletions

View File

@ -29,7 +29,7 @@ public override void Reset()
AddButton("Add Retry", delegate
{
retryCount++;
pauseOverlay.SetRetries(retryCount);
pauseOverlay.Retries = retryCount;
});
pauseOverlay.OnResume += () => Logger.Log(@"Resume");

View File

@ -30,7 +30,7 @@ public Color4 ButtonColour
set
{
buttonColour = value;
reapplyGlow();
updateGlow();
if (colourContainer == null) return;
colourContainer.Colour = ButtonColour;
}
@ -118,9 +118,8 @@ private void flash()
flash.Expire();
}
private void reapplyGlow()
private void updateGlow()
{
if (leftGlow == null || centerGlow == null || rightGlow == null) return;
leftGlow.ColourInfo = ColourInfo.GradientHorizontal(new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f), ButtonColour);
centerGlow.Colour = ButtonColour;
rightGlow.ColourInfo = ColourInfo.GradientHorizontal(ButtonColour, new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f));
@ -228,7 +227,7 @@ public PauseButton()
}
};
reapplyGlow();
updateGlow();
}
}
}

View File

@ -15,31 +15,67 @@ namespace osu.Game.Overlays.Pause
{
public class PauseOverlay : OverlayContainer
{
private const int transitionDuration = 200;
private const int buttonHeight = 70;
private const float backgroundAlpha = 0.75f;
private const int transition_duration = 200;
private const int button_height = 70;
private const float background_alpha = 0.75f;
public Action OnResume;
public Action OnRetry;
public Action OnQuit;
public int Retries
{
set
{
if (retryCounterContainer != null)
{
// "You've retried 1,065 times in this session"
// "You've retried 1 time in this session"
retryCounterContainer.Children = new Drawable[]
{
new SpriteText
{
Text = "You've retried ",
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),
TextSize = 18
},
new SpriteText
{
Text = String.Format("{0:n0}", value),
Font = @"Exo2.0-Bold",
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),
TextSize = 18
},
new SpriteText
{
Text = $" time{((value == 1) ? "" : "s")} in this session",
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),
TextSize = 18
}
};
}
}
}
private FlowContainer retryCounterContainer;
public override bool Contains(Vector2 screenSpacePos) => true;
public override bool HandleInput => State == Visibility.Visible;
protected override void PopIn() => FadeIn(transitionDuration, EasingTypes.In);
protected override void PopOut() => FadeOut(transitionDuration, EasingTypes.In);
protected override void PopIn() => FadeIn(transition_duration, EasingTypes.In);
protected override void PopOut() => FadeOut(transition_duration, EasingTypes.In);
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
switch (args.Key)
if (args.Key == Key.Escape)
{
case Key.Escape:
if (State == Visibility.Hidden) return false;
Hide();
OnResume?.Invoke();
return true;
if (State == Visibility.Hidden) return false;
resume();
return true;
}
return base.OnKeyDown(state, args);
}
@ -53,7 +89,7 @@ private void load(OsuColour colours)
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Alpha = backgroundAlpha,
Alpha = background_alpha,
},
new FlowContainer
{
@ -88,7 +124,7 @@ private void load(OsuColour colours)
},
new SpriteText
{
Text = @"you're not going to do what i think you're going to do, ain't ya?",
Text = @"you're not going to do what i think you're going to do, are ya?",
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Shadow = true,
@ -104,9 +140,8 @@ private void load(OsuColour colours)
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Shadow,
Colour = new Color4(0, 0, 0, 150),
Radius = 50,
Offset = new Vector2(0, 0),
Colour = Color4.Black.Opacity(0.6f),
Radius = 50
},
Children = new Drawable[]
{
@ -115,19 +150,15 @@ private void load(OsuColour colours)
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Height = buttonHeight,
Action = delegate
{
Hide();
OnResume?.Invoke();
}
Height = button_height,
Action = resume
},
new RetryButton
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Height = buttonHeight,
Height = button_height,
Action = delegate
{
Hide();
@ -139,7 +170,7 @@ private void load(OsuColour colours)
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Height = buttonHeight,
Height = button_height,
Action = delegate
{
Hide();
@ -164,47 +195,14 @@ private void load(OsuColour colours)
}
};
SetRetries(0);
Retries = 0;
}
public void SetRetries(int count)
private void resume()
{
if (retryCounterContainer != null)
{
// "You've retried 1,065 times in this session"
// "You've retried 1 time 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
}
};
}
}
Hide();
OnResume?.Invoke();
}
public PauseOverlay()
{

View File

@ -163,7 +163,7 @@ public void Pause(bool force = false)
lastPauseActionTime = Time.Current;
playerInputManager.PassThrough = true;
scoreOverlay.KeyCounter.IsCounting = false;
pauseOverlay.SetRetries(RestartCount);
pauseOverlay.Retries = RestartCount;
pauseOverlay.Show();
sourceClock.Stop();
isPaused = true;