From 5787b435869b5b6bd6d1e3f950a8ae0b804e7c04 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 27 Jan 2017 19:14:44 +0900 Subject: [PATCH] wip --- osu.Game/Graphics/UserInterface/SkipButton.cs | 53 +++++++++++++++++++ osu.Game/Screens/Play/Player.cs | 3 +- osu.Game/osu.Game.csproj | 1 + 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 osu.Game/Graphics/UserInterface/SkipButton.cs diff --git a/osu.Game/Graphics/UserInterface/SkipButton.cs b/osu.Game/Graphics/UserInterface/SkipButton.cs new file mode 100644 index 0000000000..856506d306 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/SkipButton.cs @@ -0,0 +1,53 @@ +using System; +using OpenTK.Graphics; +using OpenTK.Input; +using osu.Framework.Graphics; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; +using osu.Framework.Timing; + +namespace osu.Game.Graphics.UserInterface +{ + class SkipButton : Button + { + private IAdjustableClock sourceClock; + private double time; + public SkipButton(IAdjustableClock clock, double time) + { + Height = 60; + Width = 100; + Text = "skip"; + Colour = new Color4(238, 51, 153, 255); + Action = skip; + sourceClock = clock; + this.time = time; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + Delay(time - 3000, true); + Content.FadeOut(250); + } + + private void skip() + { + sourceClock.Seek(time - 3000); + FadeOut(250); + } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + switch (args.Key) + { + case Key.Space: + if(sourceClock.CurrentTime + 3000 < time) + skip(); + return true; + } + + return base.OnKeyDown(state, args); + } + } +} diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index d6594dd2be..9ec00c3215 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -12,7 +12,6 @@ using osu.Framework.Timing; using osu.Game.Database; using osu.Game.Modes; -using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; using osu.Game.Screens.Backgrounds; using OpenTK.Input; @@ -24,6 +23,7 @@ using osu.Game.Configuration; using osu.Framework.Configuration; using System; +using osu.Game.Graphics.UserInterface; using OpenTK.Graphics; namespace osu.Game.Screens.Play @@ -119,6 +119,7 @@ private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game } }, scoreOverlay, + new SkipButton(sourceClock, beatmap.HitObjects.First().StartTime) }; } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index a90fa2a8cb..c19af7f784 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -67,6 +67,7 @@ +