diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index 7f7ec2d161..5caaaafb13 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -12,7 +12,6 @@ using osu.Game.Modes.UI; using System.Linq; using osu.Game.Graphics.Cursor; using osu.Game.Modes.Osu.Judgements; -using OpenTK.Graphics; namespace osu.Game.Modes.Osu.UI { @@ -63,7 +62,7 @@ namespace osu.Game.Modes.Osu.UI protected override void LoadComplete() { base.LoadComplete(); - AddInternal(new OsuCursorContainer { Colour = Color4.LightYellow }); + AddInternal(new GameplayCursor()); } public override void Add(DrawableHitObject h) diff --git a/osu.Game/Graphics/Cursor/GameplayCursor.cs b/osu.Game/Graphics/Cursor/GameplayCursor.cs new file mode 100644 index 0000000000..df31017734 --- /dev/null +++ b/osu.Game/Graphics/Cursor/GameplayCursor.cs @@ -0,0 +1,129 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transforms; +using osu.Framework.Input; +using osu.Game.Configuration; +using System; + +namespace osu.Game.Graphics.Cursor +{ + public class GameplayCursor : CursorContainer + { + protected override Drawable CreateCursor() => new OsuCursor(); + + public GameplayCursor() + { + Add(new CursorTrail { Depth = 1 }); + } + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + ActiveCursor.Scale = new Vector2(1); + ActiveCursor.ScaleTo(1.2f, 100, EasingTypes.OutQuad); + return base.OnMouseDown(state, args); + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + if (!state.Mouse.HasMainButtonPressed) + ActiveCursor.ScaleTo(1, 200, EasingTypes.OutQuad); + return base.OnMouseUp(state, args); + } + + public class OsuCursor : Container + { + private Container cursorContainer; + private Bindable cursorScale; + + public OsuCursor() + { + Origin = Anchor.Centre; + Size = new Vector2(42); + } + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + cursorScale = config.GetBindable(OsuConfig.CursorSize); + + Children = new Drawable[] + { + cursorContainer = new CircularContainer + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Scale = new Vector2((float)cursorScale), + Masking = true, + BorderThickness = Size.X / 6, + BorderColour = Color4.White, + EdgeEffect = new EdgeEffect { + Type = EdgeEffectType.Shadow, + Colour = Color4.Pink.Opacity(0.5f), + Radius = 5, + }, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + AlwaysPresent = true, + }, + new CircularContainer + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Masking = true, + BorderThickness = Size.X / 3, + BorderColour = Color4.White.Opacity(0.5f), + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + AlwaysPresent = true, + }, + }, + }, + new CircularContainer + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Scale = new Vector2(0.1f), + Masking = true, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White, + }, + }, + }, + } + }, + }; + cursorScale.ValueChanged += scaleChanged; + } + + private void scaleChanged(object sender, EventArgs e) + { + cursorContainer.Scale = new Vector2((float)cursorScale); + } + } + } +} diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs new file mode 100644 index 0000000000..ffdfd37a67 --- /dev/null +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -0,0 +1,106 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; +using osu.Game.Configuration; +using System; +using osu.Framework.Graphics.Textures; +using osu.Framework.Graphics.Transforms; + +namespace osu.Game.Graphics.Cursor +{ + public class MenuCursor : CursorContainer + { + protected override Drawable CreateCursor() => new Cursor(); + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + ActiveCursor.Scale = new Vector2(1); + ActiveCursor.ScaleTo(0.90f, 800, EasingTypes.OutQuint); + + ((Cursor)ActiveCursor).AdditiveLayer.Alpha = 0; + ((Cursor)ActiveCursor).AdditiveLayer.FadeInFromZero(800, EasingTypes.OutQuint); + return base.OnMouseDown(state, args); + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + if (!state.Mouse.HasMainButtonPressed) + { + ((Cursor)ActiveCursor).AdditiveLayer.FadeOut(500, EasingTypes.OutQuint); + ActiveCursor.RotateTo(0, 200, EasingTypes.OutQuint); + ActiveCursor.ScaleTo(1, 500, EasingTypes.OutElastic); + } + + return base.OnMouseUp(state, args); + } + + protected override bool OnClick(InputState state) + { + ((Cursor)ActiveCursor).AdditiveLayer.FadeOutFromOne(500, EasingTypes.OutQuint); + + return base.OnClick(state); + } + + protected override bool OnDragStart(InputState state) + { + ActiveCursor.RotateTo(-30, 600, EasingTypes.OutElastic); + return base.OnDragStart(state); + } + + public class Cursor : Container + { + private Container cursorContainer; + private Bindable cursorScale; + + public Sprite AdditiveLayer; + + public Cursor() + { + Size = new Vector2(42); + } + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config, TextureStore textures) + { + cursorScale = config.GetBindable(OsuConfig.CursorSize); + + Children = new Drawable[] + { + cursorContainer = new Container + { + Size = new Vector2(28), + Children = new Drawable[] + { + new Sprite + { + FillMode = FillMode.Fit, + Texture = textures.Get(@"Cursor/menu-cursor"), + }, + AdditiveLayer = new Sprite + { + FillMode = FillMode.Fit, + BlendingMode = BlendingMode.Additive, + Alpha = 0, + Texture = textures.Get(@"Cursor/menu-cursor"), + }, + } + } + }; + cursorScale.ValueChanged += scaleChanged; + } + + private void scaleChanged(object sender, EventArgs e) + { + cursorContainer.Scale = new Vector2((float)cursorScale); + } + } + } +} diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 50c8aab5ef..b815d0028f 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -137,7 +137,7 @@ namespace osu.Game { Children = new[] { - Cursor = new OsuCursorContainer { Depth = float.MinValue } + Cursor = new MenuCursor { Depth = float.MinValue } } }); } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 80d5c906e0..8b0a5fd307 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -79,6 +79,7 @@ + @@ -221,7 +222,7 @@ - +