1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 21:02:55 +08:00

Again separate classes

This commit is contained in:
Andrey Zavadskiy 2017-03-28 10:49:58 +03:00
parent c1009c2a3c
commit 62693a6a59
5 changed files with 60 additions and 30 deletions

View File

@ -12,25 +12,23 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"Tests the pause overlay";
private StopOverlay pauseOverlay;
private PauseOverlay pauseOverlay;
private int retryCount;
public override void Reset()
{
base.Reset();
Add(pauseOverlay = new StopOverlay
Add(pauseOverlay = new PauseOverlay
{
Depth = -1,
OnEscPressed = () => Logger.Log(@"Resume"),
OnResume = () => Logger.Log(@"Resume"),
OnRetry = () => Logger.Log(@"Retry"),
OnQuit = () => Logger.Log(@"Quit"),
Title = @"paused",
Description = @"you're not going to do what i think you're going to do, are ya?",
});
pauseOverlay.AddButton(@"Continue", Color4.Green, delegate { Logger.Log(@"Resume"); });
pauseOverlay.AddButton(@"Retry", Color4.Yellow, delegate { Logger.Log(@"Retry"); });
pauseOverlay.AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), delegate { Logger.Log(@"Quit"); });
AddButton("Pause", pauseOverlay.Show);
AddButton("Add Retry", delegate
{

View File

@ -13,10 +13,11 @@ using osu.Game.Screens.Play.Pause;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Game.Graphics;
namespace osu.Game.Screens.Play
{
public class StopOverlay : OverlayContainer
public class FailOverlay : OverlayContainer
{
private const int transition_duration = 200;
private const int button_height = 70;
@ -24,7 +25,8 @@ namespace osu.Game.Screens.Play
protected override bool HideOnEscape => false;
public Action OnEscPressed;
public Action OnRetry;
public Action OnQuit;
private string title;
private string description;
@ -98,19 +100,13 @@ namespace osu.Game.Screens.Play
if (args.Key == Key.Escape)
{
if (State == Visibility.Hidden) return false;
onEscPressed();
OnQuit();
return true;
}
return base.OnKeyDown(state, args);
}
private void onEscPressed()
{
OnEscPressed?.Invoke();
Hide();
}
public void AddButton(string text, Color4 colour, Action action)
{
buttons.Add(new PauseButton
@ -127,7 +123,7 @@ namespace osu.Game.Screens.Play
});
}
public StopOverlay()
public FailOverlay()
{
AlwaysReceiveInput = true;
@ -214,6 +210,9 @@ namespace osu.Game.Screens.Play
};
Retries = 0;
AddButton(@"Retry", Color4.Yellow, OnRetry);
AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), OnQuit);
}
}
}

View File

@ -0,0 +1,35 @@
// 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;
using osu.Framework.Input;
using osu.Game.Graphics;
using OpenTK.Input;
using osu.Framework.Graphics.Containers;
using OpenTK.Graphics;
namespace osu.Game.Screens.Play
{
public class PauseOverlay : FailOverlay
{
public Action OnResume;
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Key == Key.Escape)
{
if (State == Visibility.Hidden) return false;
OnResume();
return true;
}
return base.OnKeyDown(state, args);
}
public PauseOverlay()
{
AddButton(@"Continue", Color4.Green, OnResume);
}
}
}

View File

@ -62,8 +62,8 @@ namespace osu.Game.Screens.Play
private SkipButton skipButton;
private HudOverlay hudOverlay;
private StopOverlay pauseOverlay;
private StopOverlay failOverlay;
private PauseOverlay pauseOverlay;
private FailOverlay failOverlay;
[BackgroundDependencyLoader]
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config, OsuColour colours)
@ -125,31 +125,28 @@ namespace osu.Game.Screens.Play
hudOverlay.KeyCounter.Add(ruleset.CreateGameplayKeys());
hudOverlay.BindProcessor(scoreProcessor);
pauseOverlay = new StopOverlay
pauseOverlay = new PauseOverlay
{
Depth = -1,
OnEscPressed = delegate
OnResume = delegate
{
Delay(400);
Schedule(Resume);
},
OnRetry = Restart,
OnQuit = Exit,
Title = @"paused",
Description = @"you're not going to do what i think you're going to do, are ya?",
};
pauseOverlay.AddButton(@"Continue", colours.Green, delegate { Delay(400); Schedule(Resume); });
pauseOverlay.AddButton(@"Retry", colours.YellowDark, Restart);
pauseOverlay.AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), Exit);
failOverlay = new StopOverlay
failOverlay = new FailOverlay
{
Depth = -1,
OnEscPressed = Exit,
OnRetry = Restart,
OnQuit = Exit,
Title = @"failed",
Description = @"you're dead, try again?",
};
failOverlay.AddButton(@"Retry", colours.YellowDark, Restart);
failOverlay.AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), Exit);
if (ReplayInputHandler != null)

View File

@ -194,13 +194,14 @@
<Compile Include="Screens\Multiplayer\Lobby.cs" />
<Compile Include="Screens\Multiplayer\Match.cs" />
<Compile Include="Screens\Multiplayer\MatchCreate.cs" />
<Compile Include="Screens\Play\FailOverlay.cs" />
<Compile Include="Screens\Play\KeyConversionInputManager.cs" />
<Compile Include="Screens\Play\PauseOverlay.cs" />
<Compile Include="Screens\Play\Pause\PauseButton.cs" />
<Compile Include="Screens\Play\PlayerInputManager.cs" />
<Compile Include="Screens\Play\PlayerLoader.cs" />
<Compile Include="Screens\Play\SkipButton.cs" />
<Compile Include="Modes\UI\StandardComboCounter.cs" />
<Compile Include="Screens\Play\StopOverlay.cs" />
<Compile Include="Screens\Select\BeatmapCarousel.cs" />
<Compile Include="Screens\Select\FilterCriteria.cs" />
<Compile Include="Screens\Select\Filter\GroupMode.cs" />