2017-02-07 12:59:30 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
2017-02-02 16:33:39 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-03-05 02:42:37 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-02-02 16:33:39 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-03-03 09:17:39 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using osu.Game.Graphics;
|
2017-02-15 20:37:43 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-03-03 09:17:39 +08:00
|
|
|
|
using osu.Game.Screens.Play.Pause;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using OpenTK.Input;
|
2017-01-27 17:24:49 +08:00
|
|
|
|
|
2017-03-03 09:17:39 +08:00
|
|
|
|
namespace osu.Game.Screens.Play
|
2017-02-02 16:33:39 +08:00
|
|
|
|
{
|
|
|
|
|
public class PauseOverlay : OverlayContainer
|
|
|
|
|
{
|
|
|
|
|
private const int transition_duration = 200;
|
|
|
|
|
private const int button_height = 70;
|
|
|
|
|
private const float background_alpha = 0.75f;
|
|
|
|
|
|
2017-02-09 11:46:53 +08:00
|
|
|
|
protected override bool HideOnEscape => false;
|
|
|
|
|
|
2017-02-02 16:33:39 +08:00
|
|
|
|
public Action OnResume;
|
|
|
|
|
public Action OnRetry;
|
|
|
|
|
public Action OnQuit;
|
|
|
|
|
|
|
|
|
|
public int Retries
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
2017-01-31 21:17:47 +08:00
|
|
|
|
if (retryCounterContainer != null)
|
|
|
|
|
{
|
|
|
|
|
// "You've retried 1,065 times in this session"
|
2017-02-02 16:33:39 +08:00
|
|
|
|
// "You've retried 1 time in this session"
|
2017-01-31 21:17:47 +08:00
|
|
|
|
|
|
|
|
|
retryCounterContainer.Children = new Drawable[]
|
2017-02-02 16:33:39 +08:00
|
|
|
|
{
|
2017-02-15 20:37:43 +08:00
|
|
|
|
new OsuSpriteText
|
2017-02-02 16:33:39 +08:00
|
|
|
|
{
|
|
|
|
|
Text = "You've retried ",
|
|
|
|
|
Shadow = true,
|
|
|
|
|
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
|
|
|
|
TextSize = 18
|
|
|
|
|
},
|
2017-02-15 20:37:43 +08:00
|
|
|
|
new OsuSpriteText
|
2017-02-02 16:33:39 +08:00
|
|
|
|
{
|
2017-03-09 13:24:16 +08:00
|
|
|
|
Text = $"{value:n0}",
|
2017-02-02 16:33:39 +08:00
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
|
Shadow = true,
|
|
|
|
|
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
|
|
|
|
TextSize = 18
|
|
|
|
|
},
|
2017-02-15 20:37:43 +08:00
|
|
|
|
new OsuSpriteText
|
2017-02-02 16:33:39 +08:00
|
|
|
|
{
|
2017-03-07 09:59:19 +08:00
|
|
|
|
Text = $" time{(value == 1 ? "" : "s")} in this session",
|
2017-02-02 16:33:39 +08:00
|
|
|
|
Shadow = true,
|
|
|
|
|
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
|
|
|
|
TextSize = 18
|
2017-01-31 21:17:47 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
2017-02-02 16:33:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-02 02:33:01 +08:00
|
|
|
|
private FillFlowContainer retryCounterContainer;
|
2017-02-02 16:33:39 +08:00
|
|
|
|
|
|
|
|
|
public override bool HandleInput => State == Visibility.Visible;
|
|
|
|
|
|
|
|
|
|
protected override void PopIn() => FadeIn(transition_duration, EasingTypes.In);
|
|
|
|
|
protected override void PopOut() => FadeOut(transition_duration, EasingTypes.In);
|
|
|
|
|
|
2017-02-06 03:17:29 +08:00
|
|
|
|
// Don't let mouse down events through the overlay or people can click circles while paused.
|
|
|
|
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
|
|
|
|
|
2017-03-16 21:50:16 +08:00
|
|
|
|
protected override bool OnMouseMove(InputState state) => true;
|
|
|
|
|
|
2017-02-02 16:33:39 +08:00
|
|
|
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Key == Key.Escape)
|
|
|
|
|
{
|
2017-01-31 21:17:47 +08:00
|
|
|
|
if (State == Visibility.Hidden) return false;
|
|
|
|
|
resume();
|
2017-02-02 16:33:39 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2017-02-09 11:46:53 +08:00
|
|
|
|
|
2017-02-02 16:33:39 +08:00
|
|
|
|
return base.OnKeyDown(state, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
2017-01-28 02:18:57 +08:00
|
|
|
|
{
|
2017-02-02 16:33:39 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
Alpha = background_alpha,
|
|
|
|
|
},
|
2017-03-02 02:33:01 +08:00
|
|
|
|
new FillFlowContainer
|
2017-02-02 16:33:39 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
2017-03-02 02:33:01 +08:00
|
|
|
|
Spacing = new Vector2(0, 50),
|
2017-02-02 16:33:39 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-03-02 02:33:01 +08:00
|
|
|
|
new FillFlowContainer
|
2017-02-02 16:33:39 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
2017-03-04 22:24:13 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Spacing = new Vector2(0, 20),
|
2017-02-02 16:33:39 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-02-15 20:37:43 +08:00
|
|
|
|
new OsuSpriteText
|
2017-02-02 16:33:39 +08:00
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
},
|
2017-02-15 20:37:43 +08:00
|
|
|
|
new OsuSpriteText
|
2017-02-02 16:33:39 +08:00
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
ShadowColour = new Color4(0, 0, 0, 0.25f)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-03-02 02:33:01 +08:00
|
|
|
|
new FillFlowContainer
|
2017-02-02 16:33:39 +08:00
|
|
|
|
{
|
2017-03-04 22:24:13 +08:00
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
2017-02-02 16:33:39 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Masking = true,
|
|
|
|
|
EdgeEffect = new EdgeEffect
|
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Colour = Color4.Black.Opacity(0.6f),
|
|
|
|
|
Radius = 50
|
|
|
|
|
},
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new ResumeButton
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Height = button_height,
|
|
|
|
|
Action = resume
|
|
|
|
|
},
|
|
|
|
|
new RetryButton
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Height = button_height,
|
|
|
|
|
Action = delegate
|
|
|
|
|
{
|
|
|
|
|
OnRetry?.Invoke();
|
2017-02-03 01:25:27 +08:00
|
|
|
|
Hide();
|
2017-02-02 16:33:39 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new QuitButton
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Height = button_height,
|
|
|
|
|
Action = delegate
|
|
|
|
|
{
|
|
|
|
|
OnQuit?.Invoke();
|
2017-02-03 01:25:27 +08:00
|
|
|
|
Hide();
|
2017-02-02 16:33:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-03-02 02:33:01 +08:00
|
|
|
|
retryCounterContainer = new FillFlowContainer
|
2017-02-02 16:33:39 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2017-03-04 22:24:13 +08:00
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2017-02-02 16:33:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new PauseProgressBar
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Width = 1f
|
2017-01-30 20:45:10 +08:00
|
|
|
|
}
|
2017-02-02 16:33:39 +08:00
|
|
|
|
};
|
|
|
|
|
|
2017-01-31 21:17:47 +08:00
|
|
|
|
Retries = 0;
|
2017-02-02 16:33:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void resume()
|
|
|
|
|
{
|
|
|
|
|
OnResume?.Invoke();
|
2017-02-03 01:25:27 +08:00
|
|
|
|
Hide();
|
2017-02-02 16:33:39 +08:00
|
|
|
|
}
|
2017-01-27 17:24:49 +08:00
|
|
|
|
|
|
|
|
|
public PauseOverlay()
|
|
|
|
|
{
|
2017-03-16 16:38:36 +08:00
|
|
|
|
AlwaysReceiveInput = true;
|
2017-01-27 17:24:49 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
}
|
2017-02-02 16:33:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|