mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Moved logic to it's own class
This commit is contained in:
@ -22,9 +22,6 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Modes.Scoring;
|
using osu.Game.Modes.Scoring;
|
||||||
using OpenTK.Input;
|
|
||||||
using osu.Framework.Audio.Sample;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
@ -63,16 +60,11 @@ namespace osu.Game.Screens.Play
|
|||||||
private HudOverlay hudOverlay;
|
private HudOverlay hudOverlay;
|
||||||
private PauseOverlay pauseOverlay;
|
private PauseOverlay pauseOverlay;
|
||||||
private FailOverlay failOverlay;
|
private FailOverlay failOverlay;
|
||||||
private Box retryOverlay;
|
private RetryOverlay retryOverlay;
|
||||||
|
|
||||||
private SampleChannel SampleClick;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config)
|
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config)
|
||||||
{
|
{
|
||||||
AlwaysPresent = true;
|
|
||||||
SampleClick = audio.Sample.Get(@"Menu/menuback");
|
|
||||||
|
|
||||||
var beatmap = Beatmap.Beatmap;
|
var beatmap = Beatmap.Beatmap;
|
||||||
|
|
||||||
if (beatmap.BeatmapInfo?.Mode > PlayMode.Taiko)
|
if (beatmap.BeatmapInfo?.Mode > PlayMode.Taiko)
|
||||||
@ -168,12 +160,11 @@ namespace osu.Game.Screens.Play
|
|||||||
OnRetry = Restart,
|
OnRetry = Restart,
|
||||||
OnQuit = Exit,
|
OnQuit = Exit,
|
||||||
},
|
},
|
||||||
retryOverlay = new Box
|
retryOverlay = new RetryOverlay
|
||||||
{
|
{
|
||||||
Alpha = 0,
|
Action = Restart,
|
||||||
AlwaysPresent = true,
|
OnKeyPressed = () => Content.FadeColour(Color4.Black, 500),
|
||||||
RelativeSizeAxes = Axes.Both,
|
OnKeyReleased = () => Content.FadeColour(Color4.White, 200),
|
||||||
Colour = Color4.Black,
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -348,41 +339,5 @@ namespace osu.Game.Screens.Play
|
|||||||
private Bindable<bool> mouseWheelDisabled;
|
private Bindable<bool> mouseWheelDisabled;
|
||||||
|
|
||||||
protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !IsPaused;
|
protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !IsPaused;
|
||||||
|
|
||||||
private bool isHolded;
|
|
||||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
|
||||||
{
|
|
||||||
if (args.Repeat) return false;
|
|
||||||
|
|
||||||
if (args.Key == Key.Tilde)
|
|
||||||
{
|
|
||||||
isHolded = true;
|
|
||||||
|
|
||||||
retryOverlay.FadeIn(500);
|
|
||||||
|
|
||||||
Delay(500).Schedule(() =>{
|
|
||||||
if (isHolded)
|
|
||||||
{
|
|
||||||
SampleClick.Play();
|
|
||||||
Restart();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return base.OnKeyDown(state, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
|
|
||||||
{
|
|
||||||
if (args.Key == Key.Tilde)
|
|
||||||
{
|
|
||||||
isHolded = false;
|
|
||||||
retryOverlay.FadeOut(200);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return base.OnKeyUp(state, args);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
65
osu.Game/Screens/Play/RetryOverlay.cs
Normal file
65
osu.Game/Screens/Play/RetryOverlay.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// 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.Input;
|
||||||
|
using OpenTK.Input;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio.Sample;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play
|
||||||
|
{
|
||||||
|
public class RetryOverlay : Container
|
||||||
|
{
|
||||||
|
public Action Action;
|
||||||
|
public Action OnKeyPressed;
|
||||||
|
public Action OnKeyReleased;
|
||||||
|
|
||||||
|
private SampleChannel retrySample;
|
||||||
|
private bool keyIsHeld;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(AudioManager audio)
|
||||||
|
{
|
||||||
|
retrySample = audio.Sample.Get(@"Menu/menuback");
|
||||||
|
AlwaysPresent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.Repeat) return false;
|
||||||
|
|
||||||
|
if (args.Key == Key.Tilde)
|
||||||
|
{
|
||||||
|
keyIsHeld = true;
|
||||||
|
OnKeyPressed();
|
||||||
|
|
||||||
|
Delay(500).Schedule(() =>
|
||||||
|
{
|
||||||
|
if (keyIsHeld)
|
||||||
|
{
|
||||||
|
retrySample.Play();
|
||||||
|
Action();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnKeyDown(state, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.Key == Key.Tilde)
|
||||||
|
{
|
||||||
|
keyIsHeld = false;
|
||||||
|
OnKeyReleased();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnKeyUp(state, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -180,6 +180,7 @@
|
|||||||
<Compile Include="Screens\Backgrounds\BackgroundScreenEmpty.cs" />
|
<Compile Include="Screens\Backgrounds\BackgroundScreenEmpty.cs" />
|
||||||
<Compile Include="Screens\Charts\ChartInfo.cs" />
|
<Compile Include="Screens\Charts\ChartInfo.cs" />
|
||||||
<Compile Include="Screens\Edit\Editor.cs" />
|
<Compile Include="Screens\Edit\Editor.cs" />
|
||||||
|
<Compile Include="Screens\Play\RetryOverlay.cs" />
|
||||||
<Compile Include="Screens\ScreenWhiteBox.cs" />
|
<Compile Include="Screens\ScreenWhiteBox.cs" />
|
||||||
<Compile Include="Screens\Loader.cs" />
|
<Compile Include="Screens\Loader.cs" />
|
||||||
<Compile Include="Screens\Menu\Button.cs" />
|
<Compile Include="Screens\Menu\Button.cs" />
|
||||||
|
Reference in New Issue
Block a user