mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 08:03:52 +09:00
Refactor PauseOverlay, FailDialog -> FailOverlay
This commit is contained in:
@ -1,8 +1,10 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Screens.Testing;
|
using osu.Framework.Screens.Testing;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
namespace osu.Desktop.VisualTests.Tests
|
namespace osu.Desktop.VisualTests.Tests
|
||||||
@ -22,9 +24,12 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
{
|
{
|
||||||
Depth = -1,
|
Depth = -1,
|
||||||
OnResume = () => Logger.Log(@"Resume"),
|
OnResume = () => Logger.Log(@"Resume"),
|
||||||
OnRetry = () => Logger.Log(@"Retry"),
|
|
||||||
OnQuit = () => Logger.Log(@"Quit")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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("Pause", pauseOverlay.Show);
|
||||||
AddButton("Add Retry", delegate
|
AddButton("Add Retry", delegate
|
||||||
{
|
{
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using osu.Framework.Screens;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osu.Game.Screens.Backgrounds;
|
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
|
||||||
{
|
|
||||||
internal class FailDialog : OsuScreen
|
|
||||||
{
|
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
|
||||||
|
|
||||||
private static readonly Vector2 background_blur = new Vector2(20);
|
|
||||||
|
|
||||||
public FailDialog()
|
|
||||||
{
|
|
||||||
Add(new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = "You failed!",
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
TextSize = 50
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnEntering(Screen last)
|
|
||||||
{
|
|
||||||
base.OnEntering(last);
|
|
||||||
Background.Schedule(() => (Background as BackgroundScreenBeatmap)?.BlurTo(background_blur, 1000));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnExiting(Screen next)
|
|
||||||
{
|
|
||||||
Background.Schedule(() => Background.FadeColour(Color4.White, 500));
|
|
||||||
return base.OnExiting(next);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
49
osu.Game/Screens/Play/FailOverlay.cs
Normal file
49
osu.Game/Screens/Play/FailOverlay.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// 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.Allocation;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Transforms;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Screens.Play.Pause;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
using OpenTK.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play
|
||||||
|
{
|
||||||
|
public class FailOverlay : PauseOverlay
|
||||||
|
{
|
||||||
|
public Action OnQuit;
|
||||||
|
|
||||||
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.Key == Key.Escape)
|
||||||
|
{
|
||||||
|
if (State == Visibility.Hidden) return false;
|
||||||
|
quit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnKeyDown(state, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void quit()
|
||||||
|
{
|
||||||
|
OnQuit?.Invoke();
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FailOverlay()
|
||||||
|
{
|
||||||
|
title.Text = @"failed";
|
||||||
|
description.Text = @"you're dead, try again?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -27,8 +27,11 @@ namespace osu.Game.Screens.Play
|
|||||||
protected override bool HideOnEscape => false;
|
protected override bool HideOnEscape => false;
|
||||||
|
|
||||||
public Action OnResume;
|
public Action OnResume;
|
||||||
public Action OnRetry;
|
|
||||||
public Action OnQuit;
|
protected OsuSpriteText title;
|
||||||
|
protected OsuSpriteText description;
|
||||||
|
|
||||||
|
private FillFlowContainer buttons;
|
||||||
|
|
||||||
public int Retries
|
public int Retries
|
||||||
{
|
{
|
||||||
@ -92,9 +95,33 @@ namespace osu.Game.Screens.Play
|
|||||||
return base.OnKeyDown(state, args);
|
return base.OnKeyDown(state, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
private void resume()
|
||||||
private void load(OsuColour colours)
|
|
||||||
{
|
{
|
||||||
|
OnResume?.Invoke();
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddButton(string text, Color4 colour, Action action)
|
||||||
|
{
|
||||||
|
buttons.Add(new PauseButton
|
||||||
|
{
|
||||||
|
Text = text,
|
||||||
|
ButtonColour = colour,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Height = button_height,
|
||||||
|
Action = delegate {
|
||||||
|
action?.Invoke();
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public PauseOverlay()
|
||||||
|
{
|
||||||
|
AlwaysReceiveInput = true;
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
@ -123,7 +150,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Spacing = new Vector2(0, 20),
|
Spacing = new Vector2(0, 20),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
title = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = @"paused",
|
Text = @"paused",
|
||||||
Font = @"Exo2.0-Medium",
|
Font = @"Exo2.0-Medium",
|
||||||
@ -131,11 +158,11 @@ namespace osu.Game.Screens.Play
|
|||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
TextSize = 30,
|
TextSize = 30,
|
||||||
Colour = colours.Yellow,
|
Colour = Color4.Yellow,
|
||||||
Shadow = true,
|
Shadow = true,
|
||||||
ShadowColour = new Color4(0, 0, 0, 0.25f)
|
ShadowColour = new Color4(0, 0, 0, 0.25f)
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
description = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = @"you're not going to do what i think you're going to do, are ya?",
|
Text = @"you're not going to do what i think you're going to do, are ya?",
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
@ -145,12 +172,13 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
buttons = new FillFlowContainer
|
||||||
{
|
{
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
EdgeEffect = new EdgeEffect
|
EdgeEffect = new EdgeEffect
|
||||||
{
|
{
|
||||||
@ -158,38 +186,6 @@ namespace osu.Game.Screens.Play
|
|||||||
Colour = Color4.Black.Opacity(0.6f),
|
Colour = Color4.Black.Opacity(0.6f),
|
||||||
Radius = 50
|
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();
|
|
||||||
Hide();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new QuitButton
|
|
||||||
{
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Height = button_height,
|
|
||||||
Action = delegate
|
|
||||||
{
|
|
||||||
OnQuit?.Invoke();
|
|
||||||
Hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
retryCounterContainer = new FillFlowContainer
|
retryCounterContainer = new FillFlowContainer
|
||||||
{
|
{
|
||||||
@ -209,17 +205,5 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
Retries = 0;
|
Retries = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resume()
|
|
||||||
{
|
|
||||||
OnResume?.Invoke();
|
|
||||||
Hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PauseOverlay()
|
|
||||||
{
|
|
||||||
AlwaysReceiveInput = true;
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ using osu.Game.Screens.Ranking;
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Modes.Scoring;
|
using osu.Game.Modes.Scoring;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
@ -33,7 +34,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
internal override bool ShowOverlays => false;
|
internal override bool ShowOverlays => false;
|
||||||
|
|
||||||
internal override bool HasLocalCursorDisplayed => !hasReplayLoaded && !IsPaused;
|
internal override bool HasLocalCursorDisplayed => !hasReplayLoaded && !IsPaused && !IsFailed;
|
||||||
|
|
||||||
private bool hasReplayLoaded => hitRenderer.InputManager.ReplayInputHandler != null;
|
private bool hasReplayLoaded => hitRenderer.InputManager.ReplayInputHandler != null;
|
||||||
|
|
||||||
@ -41,6 +42,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public bool IsPaused { get; private set; }
|
public bool IsPaused { get; private set; }
|
||||||
|
|
||||||
|
public bool IsFailed { get; private set; }
|
||||||
|
|
||||||
public int RestartCount;
|
public int RestartCount;
|
||||||
|
|
||||||
private const double pause_cooldown = 1000;
|
private const double pause_cooldown = 1000;
|
||||||
@ -60,9 +63,10 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private HudOverlay hudOverlay;
|
private HudOverlay hudOverlay;
|
||||||
private PauseOverlay pauseOverlay;
|
private PauseOverlay pauseOverlay;
|
||||||
|
private FailOverlay failOverlay;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config)
|
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config, OsuColour colours)
|
||||||
{
|
{
|
||||||
var beatmap = Beatmap.Beatmap;
|
var beatmap = Beatmap.Beatmap;
|
||||||
|
|
||||||
@ -129,9 +133,19 @@ namespace osu.Game.Screens.Play
|
|||||||
Delay(400);
|
Delay(400);
|
||||||
Schedule(Resume);
|
Schedule(Resume);
|
||||||
},
|
},
|
||||||
OnRetry = Restart,
|
|
||||||
OnQuit = Exit
|
|
||||||
};
|
};
|
||||||
|
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 FailOverlay
|
||||||
|
{
|
||||||
|
Depth = -1,
|
||||||
|
OnQuit = Exit,
|
||||||
|
};
|
||||||
|
failOverlay.AddButton(@"Retry", colours.YellowDark, Restart);
|
||||||
|
failOverlay.AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), Exit);
|
||||||
|
|
||||||
|
|
||||||
if (ReplayInputHandler != null)
|
if (ReplayInputHandler != null)
|
||||||
@ -161,7 +175,8 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
hudOverlay,
|
hudOverlay,
|
||||||
pauseOverlay
|
pauseOverlay,
|
||||||
|
failOverlay
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,15 +276,13 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private void onFail()
|
private void onFail()
|
||||||
{
|
{
|
||||||
Content.FadeColour(Color4.Red, 500);
|
|
||||||
sourceClock.Stop();
|
sourceClock.Stop();
|
||||||
|
|
||||||
Delay(500);
|
Delay(500);
|
||||||
Schedule(delegate
|
|
||||||
{
|
IsFailed = true;
|
||||||
ValidForResume = false;
|
failOverlay.Retries = RestartCount;
|
||||||
Push(new FailDialog());
|
failOverlay.Show();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnEntering(Screen last)
|
protected override void OnEntering(Screen last)
|
||||||
@ -339,6 +352,6 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public ReplayInputHandler ReplayInputHandler;
|
public ReplayInputHandler ReplayInputHandler;
|
||||||
|
|
||||||
protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !IsPaused;
|
protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !IsPaused && !IsFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -194,8 +194,10 @@
|
|||||||
<Compile Include="Screens\Multiplayer\Lobby.cs" />
|
<Compile Include="Screens\Multiplayer\Lobby.cs" />
|
||||||
<Compile Include="Screens\Multiplayer\Match.cs" />
|
<Compile Include="Screens\Multiplayer\Match.cs" />
|
||||||
<Compile Include="Screens\Multiplayer\MatchCreate.cs" />
|
<Compile Include="Screens\Multiplayer\MatchCreate.cs" />
|
||||||
<Compile Include="Screens\Play\FailDialog.cs" />
|
<Compile Include="Screens\Play\FailOverlay.cs" />
|
||||||
<Compile Include="Screens\Play\KeyConversionInputManager.cs" />
|
<Compile Include="Screens\Play\KeyConversionInputManager.cs" />
|
||||||
|
<Compile Include="Screens\Play\Pause\PauseButton.cs" />
|
||||||
|
<Compile Include="Screens\Play\PauseOverlay.cs" />
|
||||||
<Compile Include="Screens\Play\PlayerInputManager.cs" />
|
<Compile Include="Screens\Play\PlayerInputManager.cs" />
|
||||||
<Compile Include="Screens\Play\PlayerLoader.cs" />
|
<Compile Include="Screens\Play\PlayerLoader.cs" />
|
||||||
<Compile Include="Screens\Play\SkipButton.cs" />
|
<Compile Include="Screens\Play\SkipButton.cs" />
|
||||||
@ -331,12 +333,8 @@
|
|||||||
<Compile Include="Screens\Select\SearchTextBox.cs" />
|
<Compile Include="Screens\Select\SearchTextBox.cs" />
|
||||||
<Compile Include="Screens\Select\FooterButton.cs" />
|
<Compile Include="Screens\Select\FooterButton.cs" />
|
||||||
<Compile Include="Screens\Select\Footer.cs" />
|
<Compile Include="Screens\Select\Footer.cs" />
|
||||||
<Compile Include="Screens\Play\PauseOverlay.cs" />
|
|
||||||
<Compile Include="Screens\Play\Pause\PauseProgressBar.cs" />
|
<Compile Include="Screens\Play\Pause\PauseProgressBar.cs" />
|
||||||
<Compile Include="Screens\Play\Pause\PauseProgressGraph.cs" />
|
<Compile Include="Screens\Play\Pause\PauseProgressGraph.cs" />
|
||||||
<Compile Include="Screens\Play\Pause\ResumeButton.cs" />
|
|
||||||
<Compile Include="Screens\Play\Pause\RetryButton.cs" />
|
|
||||||
<Compile Include="Screens\Play\Pause\QuitButton.cs" />
|
|
||||||
<Compile Include="Overlays\Mods\ModSelectOverlay.cs" />
|
<Compile Include="Overlays\Mods\ModSelectOverlay.cs" />
|
||||||
<Compile Include="Modes\Mods\Mod.cs" />
|
<Compile Include="Modes\Mods\Mod.cs" />
|
||||||
<Compile Include="Overlays\Mods\ModButton.cs" />
|
<Compile Include="Overlays\Mods\ModButton.cs" />
|
||||||
@ -396,4 +394,4 @@
|
|||||||
<Target Name="AfterBuild">
|
<Target Name="AfterBuild">
|
||||||
</Target>
|
</Target>
|
||||||
-->
|
-->
|
||||||
</Project>
|
</Project>
|
Reference in New Issue
Block a user